View Javadoc
1   package org.apache.maven.scm.tck.command.untag;
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 org.apache.maven.scm.CommandParameter;
23  import org.apache.maven.scm.CommandParameters;
24  import org.apache.maven.scm.ScmException;
25  import org.apache.maven.scm.ScmFileSet;
26  import org.apache.maven.scm.ScmTag;
27  import org.apache.maven.scm.ScmTagParameters;
28  import org.apache.maven.scm.ScmTckTestCase;
29  import org.apache.maven.scm.command.checkout.CheckOutScmResult;
30  import org.apache.maven.scm.command.tag.TagScmResult;
31  import org.apache.maven.scm.command.untag.UntagScmResult;
32  import org.apache.maven.scm.provider.ScmProvider;
33  import org.apache.maven.scm.repository.ScmRepository;
34  import org.junit.Test;
35  
36  import static org.junit.Assert.assertFalse;
37  
38  /**
39   * This test tests the untag command.
40   */
41  public abstract class UntagCommandTckTest
42      extends ScmTckTestCase
43  {
44  
45      protected String getTagName()
46      {
47          return "test-untag";
48      }
49  
50      @Test
51      public void testUntagCommandTest()
52          throws Exception
53      {
54          String tag = getTagName();
55          ScmProvider scmProvider = getScmManager().getProviderByUrl( getScmUrl() );
56          ScmRepository scmRepository = getScmRepository();
57          ScmFileSet files = new ScmFileSet( getWorkingCopy() );
58          TagScmResult tagResult = scmProvider.tag( scmRepository, files, tag, new ScmTagParameters() );
59  
60          assertResultIsSuccess( tagResult );
61          CommandParameters params = new CommandParameters();
62          params.setString( CommandParameter.TAG_NAME, tag );
63  
64          UntagScmResult untagResult = scmProvider.untag( scmRepository, files, params );
65  
66          assertResultIsSuccess( untagResult );
67  
68          try
69          {
70              untagResult = scmProvider.untag( scmRepository, files, params );
71              assertFalse( untagResult.isSuccess() ); // already been deleted
72          }
73          catch ( ScmException ignored )
74          {
75          }
76  
77          try
78          {
79              CheckOutScmResult checkoutResult =
80                  getScmManager().checkOut( scmRepository, new ScmFileSet( getAssertionCopy() ), new ScmTag( tag ) );
81              assertFalse( checkoutResult.isSuccess() ); // can't check out a deleted tags
82          }
83          catch ( ScmException ignored )
84          {
85          }
86      }
87  
88  }