001package org.apache.maven.scm.provider.synergy.consumer;
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 org.apache.maven.scm.ScmTestCase;
023import org.apache.maven.scm.log.DefaultLog;
024
025import java.io.BufferedReader;
026import java.io.IOException;
027import java.io.InputStream;
028import java.io.InputStreamReader;
029
030/**
031 * @author <a href="mailto:jan.malcomess@steria-mummert.de">Jan Malcomess</a>
032 */
033public class SynergyShowDefaultTaskConsumerTest
034    extends ScmTestCase
035{
036    public void testShowDefaultTaskSet()
037        throws IOException
038    {
039        InputStream inputStream = getResourceAsStream( "/synergy/consumer/showDefaultTaskSet.txt" );
040
041        try
042        {
043            BufferedReader in = new BufferedReader( new InputStreamReader( inputStream ) );
044
045            String s = in.readLine();
046
047            SynergyShowDefaultTaskConsumer consumer = new SynergyShowDefaultTaskConsumer( new DefaultLog() );
048
049            while ( s != null )
050            {
051                consumer.consumeLine( s );
052
053                s = in.readLine();
054            }
055            assertEquals( 52885, consumer.getTask() );
056        }
057        finally
058        {
059            inputStream.close();
060        }
061    }
062
063    public void testShowDefaultTaskNotSet()
064        throws IOException
065    {
066        InputStream inputStream = getResourceAsStream( "/synergy/consumer/showDefaultTaskNotSet.txt" );
067
068        try
069        {
070            BufferedReader in = new BufferedReader( new InputStreamReader( inputStream ) );
071
072            String s = in.readLine();
073
074            SynergyShowDefaultTaskConsumer consumer = new SynergyShowDefaultTaskConsumer( new DefaultLog() );
075
076            while ( s != null )
077            {
078                consumer.consumeLine( s );
079
080                s = in.readLine();
081            }
082            assertEquals( 0, consumer.getTask() );
083        }
084        finally
085        {
086            inputStream.close();
087        }
088    }
089}