001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 */ 019package org.apache.maven.scm.provider.local.command.mkdir; 020 021import java.io.File; 022 023import org.apache.maven.scm.ScmFileSet; 024import org.apache.maven.scm.command.list.ListScmResult; 025import org.apache.maven.scm.command.mkdir.MkdirScmResult; 026import org.apache.maven.scm.tck.command.mkdir.MkdirCommandTckTest; 027import org.junit.Test; 028 029import static org.junit.Assert.assertFalse; 030import static org.junit.Assert.assertTrue; 031 032/** 033 * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a> 034 * 035 */ 036public class LocalMkdirCommandTckTest extends MkdirCommandTckTest { 037 private static final String moduleName = "checkin-tck"; 038 039 public String getScmUrl() throws Exception { 040 return "scm:local|" + getRepositoryRoot() + "|" + moduleName; 041 } 042 043 public void initRepo() throws Exception { 044 makeRepo(getRepositoryRoot()); 045 } 046 047 private void makeRepo(File workingDirectory) throws Exception { 048 makeFile(workingDirectory, moduleName + "/pom.xml", "/pom.xml"); 049 050 makeFile(workingDirectory, moduleName + "/readme.txt", "/readme.txt"); 051 052 makeFile(workingDirectory, moduleName + "/src/main/java/Application.java", "/src/main/java/Application.java"); 053 054 makeFile(workingDirectory, moduleName + "/src/test/java/Test.java", "/src/test/java/Test.java"); 055 056 makeDirectory(workingDirectory, moduleName + "/src/test/resources"); 057 } 058 059 @Test 060 public void testMkdirCommandMkdirUrl() throws Exception { 061 ScmFileSet fileSet = new ScmFileSet(getWorkingCopy(), new File(getMissingDirectory())); 062 063 MkdirScmResult result = getScmManager().mkdir(getScmRepository(), fileSet, "Mkdir message", false); 064 065 assertResultIsSuccess(result); 066 067 ListScmResult listResult = getScmManager().list(getScmRepository(), fileSet, true, null); 068 069 assertTrue("Directory should have been found.", listResult.isSuccess()); 070 } 071 072 @Test 073 public void testMkdirCommandDirAlreadyAdded() throws Exception { 074 ScmFileSet fileSet = new ScmFileSet(getWorkingCopy(), new File(getMissingDirectory())); 075 076 MkdirScmResult result = getScmManager().mkdir(getScmRepository(), fileSet, "Mkdir message", false); 077 078 assertResultIsSuccess(result); 079 080 ListScmResult listResult = getScmManager().list(getScmRepository(), fileSet, true, null); 081 082 assertTrue("Directory should have been found.", listResult.isSuccess()); 083 084 // add the directory again 085 result = getScmManager().mkdir(getScmRepository(), fileSet, "Mkdir message", false); 086 087 assertFalse(result.isSuccess()); 088 089 printOutputError(result); 090 } 091}