View Javadoc
1   package org.apache.maven.scm.provider.accurev.cli;
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 static org.hamcrest.Matchers.hasItem;
23  import static org.hamcrest.Matchers.is;
24  import static org.junit.Assert.assertThat;
25  
26  import java.io.File;
27  import java.util.ArrayList;
28  import java.util.Collection;
29  
30  import org.junit.Test;
31  
32  public class StatBackingConsumerTest
33  {
34  
35      @Test
36      public void testConsumeLine()
37      {
38          Collection<File> nonMemberElements = new ArrayList<File>();
39          Collection<File> memberElements = new ArrayList<File>();
40  
41          String line1 = "./hello.world  maventst/1 (2/1) (member)";
42          String line2 = "./tcktests/readme.txt  (no such elem)";
43          String line3 = "./src      maventst/1 (2/1) (member)";
44          String line4 = "./target   (no such elem)";
45  
46          StatBackingConsumer consumer = new StatBackingConsumer( memberElements, nonMemberElements );
47  
48          consumer.consumeLine( line1 );
49          consumer.consumeLine( line2 );
50          consumer.consumeLine( line3 );
51          consumer.consumeLine( line4 );
52  
53          assertThat( memberElements.size(), is( 2 ) );
54          assertThat( nonMemberElements.size(), is( 2 ) );
55          assertThat( memberElements, hasItem( new File( "./hello.world" ) ) );
56          assertThat( memberElements, hasItem( new File( "./src" ) ) );
57          assertThat( nonMemberElements, hasItem( new File( "./tcktests/readme.txt" ) ) );
58          assertThat( nonMemberElements, hasItem( new File( "./target" ) ) );
59  
60      }
61  }