View Javadoc
1   package org.apache.maven.scm.provider.starteam.command.checkin;
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.Collection;
24  
25  import org.apache.maven.scm.ScmFile;
26  import org.apache.maven.scm.ScmFileStatus;
27  import org.apache.maven.scm.ScmTestCase;
28  import org.apache.maven.scm.log.DefaultLog;
29  
30  /**
31   * @author <a href="mailto:dantran@gmail.com">Dan T. Tran</a>
32   */
33  public class StarteamCheckInConsumerTest
34      extends ScmTestCase
35  {
36      private static String[] TEST_OUTPUT = {"Folder: driver  (working dir: /usr/scm-starteam/driver)",
37          "maven.xml: checked in", "Folder: driver  (working dir: /usr/scm-starteam/driver/target/checkout)",
38          "maven.xml: checked in", "project.properties: skipped", "project.xml: checked in",
39          "Folder: bootstrap  (working dir: /usr/scm-starteam/driver/target/checkout/bootstrap)",
40          "Folder: dev  (working dir: /usr/scm-starteam/driver/target/checkout/dev)", "maven.xml:skipped",
41          "project.properties: skipped", "project.xml: checked in"};
42  
43      public void testParse()
44          throws Exception
45      {
46          File basedir = new File( "/usr/scm-starteam/driver" );
47  
48          StarteamCheckInConsumer consumer = new StarteamCheckInConsumer( new DefaultLog(), basedir );
49  
50          for ( int i = 0; i < TEST_OUTPUT.length; ++i )
51          {
52              consumer.consumeLine( TEST_OUTPUT[i] );
53          }
54  
55          Collection<ScmFile> entries = consumer.getCheckedInFiles();
56  
57          assertEquals( "Wrong number of entries returned", 4, entries.size() );
58  
59          ;
60  
61          for ( ScmFile entry : entries )
62          {
63              assertTrue( entry.getPath().startsWith( "./" ) );
64  
65              assertTrue( entry.getStatus() == ScmFileStatus.CHECKED_OUT );
66          }
67  
68  
69      }
70  }