001package org.apache.maven.scm.provider.accurev.cli;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 *    http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022import static org.hamcrest.Matchers.is;
023import static org.hamcrest.Matchers.notNullValue;
024import static org.junit.Assert.assertThat;
025
026import java.io.IOException;
027import java.io.InputStream;
028import java.util.HashMap;
029import java.util.Map;
030
031import org.apache.maven.scm.ScmTestCase;
032import org.apache.maven.scm.log.ScmLogger;
033import org.apache.maven.scm.provider.accurev.WorkSpace;
034import org.junit.Before;
035import org.junit.Test;
036import org.junit.runner.RunWith;
037import org.junit.runners.JUnit4;
038
039@RunWith( JUnit4.class )
040public class WorkSpaceConsumerTest
041    extends ScmTestCase
042{
043
044    private ScmLogger logger;
045
046    @Override
047    protected InputStream getCustomConfiguration()
048        throws Exception
049    {
050        return AccuRevJUnitUtil.getPlexusConfiguration();
051    }
052
053    @Before
054    public void setup()
055        throws Exception
056    {
057        setUp();
058        logger = AccuRevJUnitUtil.getLogger( getContainer() );
059    }
060
061    @Test
062    public void testConsumeShowWorkSpaces()
063        throws IOException
064    {
065
066        Map<String, WorkSpace> wsMap = new HashMap<String, WorkSpace>();
067        XppStreamConsumer consumer = new WorkSpaceConsumer( logger, wsMap );
068        AccuRevJUnitUtil.consume( "/showworkspaces.xml", consumer );
069
070        WorkSpace ws = wsMap.get( "maventst_ggardner" );
071        assertThat( ws, notNullValue() );
072        assertThat( ws.getTransactionId(), is( 49L ) );
073
074    }
075
076    @Test
077    public void testConsumeShowRefTrees()
078        throws IOException
079    {
080
081        Map<String, WorkSpace> wsMap = new HashMap<String, WorkSpace>();
082        XppStreamConsumer consumer = new WorkSpaceConsumer( logger, wsMap );
083        AccuRevJUnitUtil.consume( "/showrefs.xml", consumer );
084
085        WorkSpace ws = wsMap.get( "maven-scm-INT-reftree" );
086        assertThat( ws, notNullValue() );
087        assertThat( ws.getTransactionId(), is( 12L ) );
088
089    }
090
091}