View Javadoc
1   package org.apache.maven.scm.provider.jazz.command.add;
2   
3   import org.apache.maven.scm.log.DefaultLog;
4   import org.apache.maven.scm.provider.jazz.JazzScmTestCase;
5   import org.apache.maven.scm.provider.jazz.repository.JazzScmProviderRepository;
6   import org.codehaus.plexus.util.cli.Commandline;
7   
8   /*
9    * Licensed to the Apache Software Foundation (ASF) under one
10   * or more contributor license agreements.  See the NOTICE file
11   * distributed with this work for additional information
12   * regarding copyright ownership.  The ASF licenses this file
13   * to you under the Apache License, Version 2.0 (the
14   * "License"); you may not use this file except in compliance
15   * with the License.  You may obtain a copy of the License at
16   *
17   * http://www.apache.org/licenses/LICENSE-2.0
18   *
19   * Unless required by applicable law or agreed to in writing,
20   * software distributed under the License is distributed on an
21   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
22   * KIND, either express or implied.  See the License for the
23   * specific language governing permissions and limitations
24   * under the License.
25   */
26  
27  /**
28   * @author <a href="mailto:ChrisGWarp@gmail.com">Chris Graham</a>
29   */
30  public class JazzAddCommandTest
31      extends JazzScmTestCase
32  {
33      private JazzScmProviderRepository repo;
34  
35      private JazzAddConsumer addConsumer;
36  
37      protected void setUp()
38          throws Exception
39      {
40          super.setUp();
41  
42          repo = getScmProviderRepository();
43  
44          addConsumer = new JazzAddConsumer( repo, new DefaultLog() );
45      }
46  
47      public void testCreateAddCommand()
48          throws Exception
49      {
50          Commandline cmd = new JazzAddCommand().createAddCommand( repo, getScmFileSet() ).getCommandline();
51          String expected = "scm checkin --username myUserName --password myPassword " + getFiles();
52          assertCommandLine( expected, getWorkingDirectory(), cmd );
53      }
54  
55      public void testCheckInConsumerWithFiles()
56          throws Exception
57      {
58          addConsumer.consumeLine( "Committing..." );
59          addConsumer.consumeLine(
60              "Workspace: (1903) \"MavenSCMTestWorkspace_1332908068770\" <-> (1903) \"MavenSCMTestWorkspace_1332908068770\"" );
61          addConsumer.consumeLine( "  Component: (1768) \"MavenSCMTestComponent\"" );
62          addConsumer.consumeLine( "    Outgoing:" );
63          addConsumer.consumeLine( "      Change sets:" );
64          addConsumer.consumeLine( "        (1907)  *--@  \"Commit message\"" );
65          addConsumer.consumeLine( "          Changes:" );
66          addConsumer.consumeLine( "            --a-- \\src\\main\\java\\Me.java" );
67          addConsumer.consumeLine( "            --a-- \\src\\main\\java\\Me1.java" );
68          addConsumer.consumeLine( "            --a-- \\src\\main\\java\\Me2.java" );
69  
70          assertEquals( "Wrong number of files parsed!", 3, addConsumer.getFiles().size() );
71          assertEquals( "Parsing error for file1!", "src\\main\\java\\Me.java",
72                        addConsumer.getFiles().get( 0 ).getPath() );
73          assertEquals( "Parsing error for file2!", "src\\main\\java\\Me1.java",
74                        addConsumer.getFiles().get( 1 ).getPath() );
75          assertEquals( "Parsing error for file3!", "src\\main\\java\\Me2.java",
76                        addConsumer.getFiles().get( 2 ).getPath() );
77      }
78  
79      public void testCheckInConsumerWithOutFiles()
80          throws Exception
81      {
82          addConsumer.consumeLine( "Committing..." );
83          addConsumer.consumeLine(
84              "Workspace: (1004) \"Release Repository Workspace\" <-> (1005) \"Maven Release Plugin Stream\"" );
85          addConsumer.consumeLine( "  Component: (1006) \"Release Component\"" );
86          addConsumer.consumeLine( "    Outgoing:" );
87          addConsumer.consumeLine( "      Change sets:" );
88          addConsumer.consumeLine( "        (1008) --@ <No comment>" );
89  
90          assertEquals( "Wrong number of files parsed!", 0, addConsumer.getFiles().size() );
91      }
92  }