View Javadoc
1   package org.apache.maven.scm.provider.local.command.mkdir;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   * http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.io.File;
23  
24  import org.apache.maven.scm.ScmFileSet;
25  import org.apache.maven.scm.command.list.ListScmResult;
26  import org.apache.maven.scm.command.mkdir.MkdirScmResult;
27  import org.apache.maven.scm.tck.command.mkdir.MkdirCommandTckTest;
28  
29  /**
30   * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
31   *
32   */
33  public class LocalMkdirCommandTckTest
34      extends MkdirCommandTckTest
35  {
36      private static final String moduleName = "checkin-tck";
37  
38      public String getScmUrl()
39          throws Exception
40      {
41          return "scm:local|" + getRepositoryRoot() + "|" + moduleName;
42      }
43  
44      public void initRepo()
45          throws Exception
46      {
47          makeRepo( getRepositoryRoot() );
48      }
49  
50      private void makeRepo( File workingDirectory )
51          throws Exception
52      {
53          makeFile( workingDirectory, moduleName + "/pom.xml", "/pom.xml" );
54  
55          makeFile( workingDirectory, moduleName + "/readme.txt", "/readme.txt" );
56  
57          makeFile( workingDirectory, moduleName + "/src/main/java/Application.java", "/src/main/java/Application.java" );
58  
59          makeFile( workingDirectory, moduleName + "/src/test/java/Test.java", "/src/test/java/Test.java" );
60  
61          makeDirectory( workingDirectory, moduleName + "/src/test/resources" );
62      }
63  
64      public void testMkdirCommandMkdirUrl()
65          throws Exception
66      {
67          ScmFileSet fileSet = new ScmFileSet( getWorkingCopy(), new File( getMissingDirectory() ) );
68  
69          MkdirScmResult result = getScmManager().mkdir( getScmRepository(), fileSet, "Mkdir message", false );
70  
71          assertResultIsSuccess( result );
72  
73          ListScmResult listResult = getScmManager().list( getScmRepository(), fileSet, true, null );
74  
75          assertTrue( "Directory should have been found.", listResult.isSuccess() );
76      }
77  
78      public void testMkdirCommandDirAlreadyAdded()
79          throws Exception
80      {
81          ScmFileSet fileSet = new ScmFileSet( getWorkingCopy(), new File( getMissingDirectory() ) );
82  
83          MkdirScmResult result = getScmManager().mkdir( getScmRepository(), fileSet, "Mkdir message", false );
84  
85          assertResultIsSuccess( result );
86  
87          ListScmResult listResult = getScmManager().list( getScmRepository(), fileSet, true, null );
88  
89          assertTrue( "Directory should have been found.", listResult.isSuccess() );
90  
91          // add the directory again
92          result = getScmManager().mkdir( getScmRepository(), fileSet, "Mkdir message", false );
93  
94          assertFalse( result.isSuccess() );
95  
96          printOutputError( result );
97      }
98  }