View Javadoc
1   package org.apache.maven.scm.provider.jazz.command.checkout;
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.ScmRevision;
25  import org.apache.maven.scm.log.DefaultLog;
26  import org.apache.maven.scm.provider.jazz.JazzScmTestCase;
27  import org.apache.maven.scm.provider.jazz.repository.JazzScmProviderRepository;
28  import org.codehaus.plexus.util.cli.Commandline;
29  
30  import java.util.List;
31  
32  /**
33   * @author <a href="mailto:ChrisGWarp@gmail.com">Chris Graham</a>
34   */
35  public class JazzCheckOutCommandTest
36      extends JazzScmTestCase
37  {
38      private JazzScmProviderRepository repo;
39  
40      private JazzCheckOutConsumer checkOutConsumer;
41  
42      protected void setUp()
43          throws Exception
44      {
45          super.setUp();
46          repo = getScmProviderRepository();
47          checkOutConsumer = new JazzCheckOutConsumer( getScmProviderRepository(), new DefaultLog() );
48      }
49  
50      public void testCreateJazzLoadCommand()
51          throws Exception
52      {
53          ScmRevision rev = new ScmRevision( "revision" );
54          // TODO figure out what Jazz SCM does in terms of branch/tag/revision
55          // TODO figure out how/when to load specific files
56          Commandline cmd =
57              new JazzCheckOutCommand().createJazzLoadCommand( repo, getScmFileSet(), rev ).getCommandline();
58          String expected =
59              "scm load --force --repository-uri https://localhost:9443/jazz --username myUserName --password myPassword --dir "
60                  + getScmFileSet().getBasedir().getAbsolutePath() + " \"Dave's Repository Workspace\"";
61          assertCommandLine( expected, getWorkingDirectory(), cmd );
62      }
63  
64      public void testConsumer()
65      {
66          checkOutConsumer.consumeLine(
67              "Downloading /maven-checkout-test/src/main/java/org/apache/maven/scm/provider/jazz/EmptyFile.txt  (0 B)" );
68          checkOutConsumer.consumeLine(
69              "Downloading /maven-checkout-test/src/main/java/org/apache/maven/scm/provider/jazz/folder with spaces/test.java  (123 KB)" );
70          checkOutConsumer.consumeLine(
71              "Downloading /maven-checkout-test/src/main/java/org/apache/maven/scm/provider/jazz/file with spaces.java  (12.34 KB)" );
72          checkOutConsumer.consumeLine(
73              "Downloading /maven-checkout-test/src/main/java/org/apache/maven/scm/provider/jazz/folder with spaces/file with spaces.txt  (12.3 B)" );
74          checkOutConsumer.consumeLine( "" );
75  
76          List<ScmFile> checkedOutFiles = checkOutConsumer.getCheckedOutFiles();
77          assertNotNull( checkedOutFiles );
78          assertEquals( 4, checkedOutFiles.size() );
79          assertTrue( checkedOutFiles.contains(
80              new ScmFile( "/maven-checkout-test/src/main/java/org/apache/maven/scm/provider/jazz/EmptyFile.txt",
81                           ScmFileStatus.CHECKED_OUT ) ) );
82          assertTrue( checkedOutFiles.contains( new ScmFile(
83              "/maven-checkout-test/src/main/java/org/apache/maven/scm/provider/jazz/folder with spaces/test.java",
84              ScmFileStatus.CHECKED_OUT ) ) );
85          assertTrue( checkedOutFiles.contains(
86              new ScmFile( "/maven-checkout-test/src/main/java/org/apache/maven/scm/provider/jazz/file with spaces.java",
87                           ScmFileStatus.CHECKED_OUT ) ) );
88          assertTrue( checkedOutFiles.contains( new ScmFile(
89              "/maven-checkout-test/src/main/java/org/apache/maven/scm/provider/jazz/folder with spaces/file with spaces.txt",
90              ScmFileStatus.CHECKED_OUT ) ) );
91      }
92  }