View Javadoc
1   package org.apache.maven.scm.provider.svn.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.provider.svn.SvnScmTestUtils;
28  import org.apache.maven.scm.tck.command.mkdir.MkdirCommandTckTest;
29  import org.junit.Test;
30  
31  import static org.junit.Assert.assertFalse;
32  import static org.junit.Assert.assertNotNull;
33  import static org.junit.Assert.assertTrue;
34  
35  /**
36   * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
37   *
38   */
39  public class SvnMkdirCommandTckTest
40      extends MkdirCommandTckTest
41  {
42      /** {@inheritDoc} */
43      public String getScmUrl()
44          throws Exception
45      {
46          return SvnScmTestUtils.getScmUrl( new File( getRepositoryRoot(), "trunk" ) );
47      }
48  
49      /** {@inheritDoc} */
50      public void initRepo()
51          throws Exception
52      {
53          SvnScmTestUtils.initializeRepository( getRepositoryRoot() );
54      }
55  
56      @Test
57      public void testMkdirCommandMkdirUrl()
58          throws Exception
59      {
60          ScmFileSet fileSet = new ScmFileSet( getWorkingCopy(), new File( getMissingDirectory() ) );
61      
62          MkdirScmResult result = getScmManager().mkdir( getScmRepository(), fileSet, "Mkdir message", false );
63      
64          assertResultIsSuccess( result );
65      
66          assertNotNull( result.getRevision() );
67      
68          ListScmResult listResult = getScmManager().list( getScmRepository(), fileSet, true, null );
69      
70          assertTrue( "Directory should have been found.", listResult.isSuccess() );
71      }
72  
73      @Test
74      public void testMkdirCommandDirAlreadyAdded()
75          throws Exception
76      {
77          ScmFileSet fileSet = new ScmFileSet( getWorkingCopy(), new File( getMissingDirectory() ) );
78      
79          MkdirScmResult result = getScmManager().mkdir( getScmRepository(), fileSet, null, false );
80      
81          assertResultIsSuccess( result );
82      
83          assertNotNull( result.getRevision() );
84      
85          ListScmResult listResult = getScmManager().list( getScmRepository(), fileSet, true, null );
86          
87          assertTrue( "Directory should have been found.", listResult.isSuccess() );
88                  
89          // add the directory again
90          result = getScmManager().mkdir( getScmRepository(), fileSet, null, false );
91      
92          printOutputError( result ); 
93          
94          assertFalse( result.isSuccess() );
95      }
96  }