View Javadoc
1   package org.apache.maven.scm.provider.clearcase.command.changelog;
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.ScmBranch;
23  import org.apache.maven.scm.ScmTestCase;
24  import org.apache.maven.scm.provider.clearcase.util.ClearCaseUtil;
25  import org.codehaus.plexus.util.cli.Commandline;
26  
27  import java.io.File;
28  import java.util.Date;
29  
30  /**
31   * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
32   * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
33   * @author <a href="mailto:m.holster@anva.nl">Mark Holster</a>
34   *
35   */
36  public class ClearCaseChangeLogCommandTest
37      extends ScmTestCase
38  {
39      public void testGetCommandLine()
40          throws Exception
41      {
42          Date startDate = null;
43  
44          Date endDate = null;
45  
46          testCommandLine( null, startDate, endDate,
47                           "cleartool lshistory -fmt \"NAME:%En\\nDATE:%Nd\\nCOMM:%-12.12o - %o - %c - Activity: %[activity]p\\nUSER:%u\\nREVI:%Ln\\n\" -recurse -nco" );
48      }
49  
50      public void testGetCommandLineWithUserPattern()
51          throws Exception
52      {
53          ClearCaseUtil.setSettingsDirectory( getTestFile( "src/test/resources/clearcase/changelog" ) );
54  
55          Date startDate = null;
56  
57          Date endDate = null;
58  
59          testCommandLine( null, startDate, endDate,
60                           "cleartool lshistory -fmt \"NAME:%En\\nDATE:%Nd\\nCOMM:%-12.12o - %o - %c - Activity: %[activity]p\\nUSER:%-8.8u\\nREVI:%Ln\\n\" -recurse -nco" );
61  
62          ClearCaseUtil.setSettingsDirectory( ClearCaseUtil.DEFAULT_SETTINGS_DIRECTORY );
63      }
64  
65      public void testGetCommandLineWithTag()
66          throws Exception
67      {
68          Date startDate = null;
69  
70          Date endDate = null;
71  
72          testCommandLine( new ScmBranch( "myBranch" ), startDate, endDate,
73                           "cleartool lshistory -fmt \"NAME:%En\\nDATE:%Nd\\nCOMM:%-12.12o - %o - %c - Activity: %[activity]p\\nUSER:%u\\nREVI:%Ln\\n\" -recurse -nco -branch myBranch" );
74      }
75  
76      public void testGetCommandLineWithStartDate()
77          throws Exception
78      {
79          Date startDate = getDate( 2003, 8, 10 );
80  
81          Date endDate = null;
82  
83          testCommandLine( null, startDate, endDate,
84                           "cleartool lshistory -fmt \"NAME:%En\\nDATE:%Nd\\nCOMM:%-12.12o - %o - %c - Activity: %[activity]p\\nUSER:%u\\nREVI:%Ln\\n\" -recurse -nco -since 10-Sep-2003" );
85      }
86  
87      public void testGetCommandLineWithTagAndStartDate()
88          throws Exception
89      {
90          Date startDate = getDate( 2003, 8, 10 );
91  
92          Date endDate = null;
93  
94          testCommandLine( new ScmBranch( "myBranch" ), startDate, endDate,
95                           "cleartool lshistory -fmt \"NAME:%En\\nDATE:%Nd\\nCOMM:%-12.12o - %o - %c - Activity: %[activity]p\\nUSER:%u\\nREVI:%Ln\\n\" -recurse -nco -since 10-Sep-2003 -branch myBranch" );
96      }
97  
98      // ----------------------------------------------------------------------
99      //
100     // ----------------------------------------------------------------------
101 
102     private void testCommandLine( ScmBranch branch, Date startDate, Date endDate, String commandLine )
103         throws Exception
104     {
105         File workingDirectory = getTestFile( "target/clearcare-changelog-command-test" );
106 
107         Commandline cl = ClearCaseChangeLogCommand.createCommandLine( workingDirectory, branch, startDate );
108         assertCommandLine( commandLine, workingDirectory, cl );
109     }
110 }