View Javadoc
1   package org.apache.maven.scm.provider.jazz.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 org.apache.maven.scm.ScmFile;
23  import org.apache.maven.scm.ScmFileStatus;
24  import org.apache.maven.scm.log.DefaultLog;
25  import org.apache.maven.scm.provider.jazz.JazzScmTestCase;
26  import org.apache.maven.scm.provider.jazz.repository.JazzScmProviderRepository;
27  import org.codehaus.plexus.util.cli.Commandline;
28  
29  import java.util.List;
30  
31  /**
32   * @author <a href="mailto:ChrisGWarp@gmail.com">Chris Graham</a>
33   */
34  public class JazzListCommandTest
35      extends JazzScmTestCase
36  {
37      private JazzListConsumer listConsumer;
38  
39      private JazzScmProviderRepository repo;
40  
41      protected void setUp()
42          throws Exception
43      {
44          super.setUp();
45          repo = getScmProviderRepository();
46  
47          listConsumer = new JazzListConsumer( getScmProviderRepository(), new DefaultLog() );
48  
49          // Simulate the output of the parsing of the "scm status" command.
50          // IE, fill in the workspace and component details
51          // Needed for the remote workspace and component name for the list remotefiles
52          repo.setWorkspace( "Dave's Repository Workspace" );
53          repo.setComponent( "Dave's Component" );
54      }
55  
56      public void testCreateListCommand()
57          throws Exception
58      {
59          Commandline cmd = new JazzListCommand().createListCommand( repo, getScmFileSet(), true, null ).getCommandline();
60          String expected =
61              "scm list remotefiles --repository-uri https://localhost:9443/jazz --username myUserName --password myPassword \"Dave's Repository Workspace\" \"Dave's Component\"";
62          assertCommandLine( expected, getWorkingDirectory(), cmd );
63      }
64  
65      public void testConsumer()
66      {
67          listConsumer.consumeLine( "/" );
68          listConsumer.consumeLine( "/BogusTestJazz/" );
69          listConsumer.consumeLine( "/BogusTestJazz/.jazzignore" );
70          listConsumer.consumeLine( "/BogusTestJazz/pom.xml" );
71          listConsumer.consumeLine( "/BogusTestJazz/Readme.txt" );
72          listConsumer.consumeLine( "/BogusTestJazz/src/" );
73          listConsumer.consumeLine( "/BogusTestJazz/src/main/" );
74          listConsumer.consumeLine( "/BogusTestJazz/src/main/resources/" );
75          listConsumer.consumeLine( "/BogusTestJazz/src/main/resources/AFile.txt" );
76          listConsumer.consumeLine( "/BogusTestJazz/src/main/java/" );
77          listConsumer.consumeLine( "/BogusTestJazz/src/main/java/BogusTest.java" );
78  
79          // Test the ScmFile and ScmFileStatus bits.
80          List<ScmFile> changedFiles = listConsumer.getFiles();
81          assertNotNull( changedFiles );
82          assertEquals( 11, changedFiles.size() );
83          assertTrue( changedFiles.contains( new ScmFile( "/", ScmFileStatus.CHECKED_IN ) ) );
84          assertTrue( changedFiles.contains( new ScmFile( "/BogusTestJazz/", ScmFileStatus.CHECKED_IN ) ) );
85          assertTrue( changedFiles.contains( new ScmFile( "/BogusTestJazz/.jazzignore", ScmFileStatus.CHECKED_IN ) ) );
86          assertTrue( changedFiles.contains( new ScmFile( "/BogusTestJazz/pom.xml", ScmFileStatus.CHECKED_IN ) ) );
87          assertTrue( changedFiles.contains( new ScmFile( "/BogusTestJazz/Readme.txt", ScmFileStatus.CHECKED_IN ) ) );
88          assertTrue( changedFiles.contains( new ScmFile( "/BogusTestJazz/src/", ScmFileStatus.CHECKED_IN ) ) );
89          assertTrue( changedFiles.contains( new ScmFile( "/BogusTestJazz/src/main/", ScmFileStatus.CHECKED_IN ) ) );
90          assertTrue(
91              changedFiles.contains( new ScmFile( "/BogusTestJazz/src/main/resources/", ScmFileStatus.CHECKED_IN ) ) );
92          assertTrue( changedFiles.contains(
93              new ScmFile( "/BogusTestJazz/src/main/resources/AFile.txt", ScmFileStatus.CHECKED_IN ) ) );
94          assertTrue( changedFiles.contains( new ScmFile( "/BogusTestJazz/src/main/java/", ScmFileStatus.CHECKED_IN ) ) );
95          assertTrue( changedFiles.contains(
96              new ScmFile( "/BogusTestJazz/src/main/java/BogusTest.java", ScmFileStatus.CHECKED_IN ) ) );
97      }
98  
99  }