View Javadoc
1   package org.apache.maven.scm.tck.command.list;
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  import java.util.List;
24  
25  import org.apache.maven.scm.ScmFile;
26  import org.apache.maven.scm.ScmFileSet;
27  import org.apache.maven.scm.ScmTckTestCase;
28  import org.apache.maven.scm.ScmVersion;
29  import org.apache.maven.scm.command.list.ListScmResult;
30  import org.apache.maven.scm.provider.ScmProvider;
31  
32  /**
33   * This test tests the list command.
34   *
35   * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
36   *
37   */
38  public abstract class ListCommandTckTest
39      extends ScmTckTestCase
40  {
41      public void testListCommandTest()
42          throws Exception
43      {
44          ScmFileSet fileSet = new ScmFileSet( new File( "." ), new File( "." ) );
45  
46          List<ScmFile> files = runList( fileSet, false );
47  
48          assertEquals( "The result of the list command doesn't have all the files in SCM: " + files, 3, files.size() );
49      }
50  
51      public void testListCommandRecursiveTest()
52          throws Exception
53      {
54          ScmFileSet fileSet = new ScmFileSet( new File( "." ), new File( "." ) );
55  
56          List<ScmFile> files = runList( fileSet, true );
57  
58          assertEquals( "The result of the list command doesn't have all the files in SCM: " + files, 10, files.size() );
59      }
60  
61      public void testListCommandUnexistantFileTest()
62          throws Exception
63      {
64          ScmFileSet fileSet = new ScmFileSet( new File( "." ), new File( "/void" ) );
65  
66          ScmProvider provider = getScmManager().getProviderByUrl( getScmUrl() );
67  
68          ListScmResult result = provider.list( getScmRepository(), fileSet, false, (ScmVersion) null );
69  
70          assertFalse( "Found file when shouldn't", result.isSuccess() );
71      }
72  
73      private List<ScmFile> runList( ScmFileSet fileSet, boolean recursive )
74          throws Exception
75      {
76          ScmProvider provider = getScmManager().getProviderByUrl( getScmUrl() );
77  
78          ListScmResult result = provider.list( getScmRepository(), fileSet, recursive, (ScmVersion) null );
79  
80          assertTrue( "SCM command failed: " + result.getCommandLine() + " : " + result.getProviderMessage()
81              + ( result.getCommandOutput() == null ? "" : ": " + result.getCommandOutput() ), result.isSuccess() );
82  
83          return result.getFiles();
84      }
85  }