001package org.apache.maven.scm.provider.starteam.command.add;
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.ScmFile;
023import org.apache.maven.scm.ScmFileStatus;
024import org.apache.maven.scm.ScmTestCase;
025import org.apache.maven.scm.log.DefaultLog;
026
027import java.io.File;
028import java.util.Collection;
029import java.util.Iterator;
030
031/**
032 * @author <a href="mailto:dantran@gmail.com">Dan T. Tran</a>
033 */
034public class StarteamAddConsumerTest
035    extends ScmTestCase
036{
037    private static String[] TEST_OUTPUT = {"Folder: driver  (working dir: /usr/scm-starteam/driver)",
038        "maven.xml: added", "Folder: driver  (working dir: /usr/scm-starteam/driver/target/checkout)",
039        "maven.xml: added", "project.properties: added", "project.xml: added",
040        "Folder: bootstrap  (working dir: /usr/scm-starteam/driver/target/checkout/bootstrap)", "maven.xml: added",
041        "project.properties: added", "project.xml: added"};
042
043    public void testParse()
044        throws Exception
045    {
046
047        File basedir = new File( "/usr/scm-starteam/driver" );
048
049        StarteamAddConsumer consumer = new StarteamAddConsumer( new DefaultLog(), basedir );
050
051        for ( int i = 0; i < TEST_OUTPUT.length; ++i )
052        {
053            consumer.consumeLine( TEST_OUTPUT[i] );
054        }
055
056        Collection<ScmFile> entries = consumer.getAddedFiles();
057
058        assertEquals( "Wrong number of entries returned", 7, entries.size() );
059
060        ScmFile entry;
061
062        for ( Iterator<ScmFile> i = entries.iterator(); i.hasNext(); )
063        {
064            entry = i.next();
065
066            assertTrue( entry.getPath().startsWith( "./" ) );
067
068            assertTrue( entry.getStatus() == ScmFileStatus.ADDED );
069        }
070
071
072    }
073
074}