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.is;
23  import static org.hamcrest.Matchers.notNullValue;
24  import static org.junit.Assert.assertThat;
25  
26  import java.io.IOException;
27  import java.io.InputStream;
28  import java.util.HashMap;
29  import java.util.Map;
30  
31  import org.apache.maven.scm.ScmTestCase;
32  import org.apache.maven.scm.log.ScmLogger;
33  import org.apache.maven.scm.provider.accurev.WorkSpace;
34  import org.junit.Before;
35  import org.junit.Test;
36  import org.junit.runner.RunWith;
37  import org.junit.runners.JUnit4;
38  
39  @RunWith( JUnit4.class )
40  public class WorkSpaceConsumerTest
41      extends ScmTestCase
42  {
43  
44      private ScmLogger logger;
45  
46      @Override
47      protected InputStream getCustomConfiguration()
48          throws Exception
49      {
50          return AccuRevJUnitUtil.getPlexusConfiguration();
51      }
52  
53      @Before
54      public void setup()
55          throws Exception
56      {
57          setUp();
58          logger = AccuRevJUnitUtil.getLogger( getContainer() );
59      }
60  
61      @Test
62      public void testConsumeShowWorkSpaces()
63          throws IOException
64      {
65  
66          Map<String, WorkSpace> wsMap = new HashMap<String, WorkSpace>();
67          XppStreamConsumer consumer = new WorkSpaceConsumer( logger, wsMap );
68          AccuRevJUnitUtil.consume( "/showworkspaces.xml", consumer );
69  
70          WorkSpace ws = wsMap.get( "maventst_ggardner" );
71          assertThat( ws, notNullValue() );
72          assertThat( ws.getTransactionId(), is( 49L ) );
73  
74      }
75  
76      @Test
77      public void testConsumeShowRefTrees()
78          throws IOException
79      {
80  
81          Map<String, WorkSpace> wsMap = new HashMap<String, WorkSpace>();
82          XppStreamConsumer consumer = new WorkSpaceConsumer( logger, wsMap );
83          AccuRevJUnitUtil.consume( "/showrefs.xml", consumer );
84  
85          WorkSpace ws = wsMap.get( "maven-scm-INT-reftree" );
86          assertThat( ws, notNullValue() );
87          assertThat( ws.getTransactionId(), is( 12L ) );
88  
89      }
90  
91  }