001package org.apache.maven.scm.provider.accurev.command.tag;
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 java.io.File;
023import java.io.InputStream;
024
025import org.apache.maven.scm.ScmFileSet;
026import org.apache.maven.scm.ScmTag;
027import org.apache.maven.scm.command.checkin.CheckInScmResult;
028import org.apache.maven.scm.command.checkout.CheckOutScmResult;
029import org.apache.maven.scm.command.tag.TagScmResult;
030import org.apache.maven.scm.provider.accurev.cli.AccuRevJUnitUtil;
031import org.apache.maven.scm.provider.accurev.command.AccuRevTckUtil;
032import org.apache.maven.scm.repository.ScmRepository;
033import org.apache.maven.scm.tck.command.tag.TagCommandTckTest;
034import org.junit.After;
035import org.junit.Before;
036import org.junit.Test;
037import org.junit.runner.RunWith;
038import org.junit.runners.JUnit4;
039
040@RunWith( JUnit4.class )
041public class AccuRevTagCommandTckTest
042    extends TagCommandTckTest
043{
044
045    private AccuRevTckUtil accurevTckTestUtil = new AccuRevTckUtil();
046
047    @Override
048    protected InputStream getCustomConfiguration()
049        throws Exception
050
051    {
052        return AccuRevJUnitUtil.getPlexusConfiguration();
053    }
054
055    @Override
056    @Test
057    public void testTagCommandTest()
058        throws Exception
059    {
060        super.testTagCommandTest();
061    }
062
063    @Override
064    @Before
065    public void setUp()
066        throws Exception
067    {
068        super.setUp();
069    }
070
071    @SuppressWarnings( "deprecation" )
072    @Test
073    public void testReleasePluginStyleTagThenCheckout()
074        throws Exception
075    {
076
077        String tag = "test-tag";
078
079        makeFile( getWorkingCopy(), ".acignore", "target/*\ntarget\n" );
080
081        ScmRepository scmRepository = getScmRepository();
082
083        addToWorkingTree( getWorkingCopy(), new File( ".acignore" ), scmRepository );
084
085        CheckInScmResult checkinResult =
086            getScmManager().checkIn( scmRepository, new ScmFileSet( getWorkingCopy() ), "add acignore" );
087
088        assertResultIsSuccess( checkinResult );
089
090        TagScmResult tagResult =
091            getScmManager().getProviderByUrl( getScmUrl() ).tag( scmRepository, new ScmFileSet( getWorkingCopy() ), tag );
092
093        assertResultIsSuccess( tagResult );
094
095        scmRepository.getProviderRepository().setPersistCheckout( false );
096
097        CheckOutScmResult checkoutResult =
098            getScmManager().checkOut( scmRepository, new ScmFileSet( new File( getWorkingCopy(), "target/checkout" ) ),
099                                      new ScmTag( tag ) );
100
101        assertResultIsSuccess( checkoutResult );
102
103    }
104
105    @Override
106    protected File getWorkingCopy()
107    {
108        return accurevTckTestUtil.getWorkingCopy();
109    }
110
111    @Override
112    protected File getAssertionCopy()
113    {
114        return accurevTckTestUtil.getAssertionCopy();
115    }
116
117    @Override
118    public String getScmUrl()
119        throws Exception
120    {
121        return accurevTckTestUtil.getScmUrl();
122    }
123
124    @Override
125    public void initRepo()
126        throws Exception
127    {
128        accurevTckTestUtil.initRepo( getContainer() );
129    }
130
131    @Override
132    @After
133    public void tearDown()
134        throws Exception
135    {
136        try
137        {
138            accurevTckTestUtil.tearDown();
139            accurevTckTestUtil.removeWorkSpace( getWorkingCopy() );
140            accurevTckTestUtil.removeWorkSpace( getAssertionCopy() );
141
142        }
143        finally
144        {
145            super.tearDown();
146        }
147    }
148}