View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.scm.tck.command.untag;
20  
21  import org.apache.maven.scm.CommandParameter;
22  import org.apache.maven.scm.CommandParameters;
23  import org.apache.maven.scm.ScmException;
24  import org.apache.maven.scm.ScmFileSet;
25  import org.apache.maven.scm.ScmTag;
26  import org.apache.maven.scm.ScmTagParameters;
27  import org.apache.maven.scm.ScmTckTestCase;
28  import org.apache.maven.scm.command.checkout.CheckOutScmResult;
29  import org.apache.maven.scm.command.tag.TagScmResult;
30  import org.apache.maven.scm.command.untag.UntagScmResult;
31  import org.apache.maven.scm.provider.ScmProvider;
32  import org.apache.maven.scm.repository.ScmRepository;
33  import org.junit.Test;
34  
35  import static org.junit.Assert.assertFalse;
36  
37  /**
38   * This test tests the untag command.
39   */
40  public abstract class UntagCommandTckTest extends ScmTckTestCase {
41  
42      protected String getTagName() {
43          return "test-untag";
44      }
45  
46      @Test
47      public void testUntagCommandTest() throws Exception {
48          String tag = getTagName();
49          ScmProvider scmProvider = getScmManager().getProviderByUrl(getScmUrl());
50          ScmRepository scmRepository = getScmRepository();
51          ScmFileSet files = new ScmFileSet(getWorkingCopy());
52          TagScmResult tagResult = scmProvider.tag(scmRepository, files, tag, new ScmTagParameters());
53  
54          assertResultIsSuccess(tagResult);
55          CommandParameters params = new CommandParameters();
56          params.setString(CommandParameter.TAG_NAME, tag);
57  
58          UntagScmResult untagResult = scmProvider.untag(scmRepository, files, params);
59  
60          assertResultIsSuccess(untagResult);
61  
62          try {
63              untagResult = scmProvider.untag(scmRepository, files, params);
64              assertFalse(untagResult.isSuccess()); // already been deleted
65          } catch (ScmException ignored) {
66          }
67  
68          try {
69              CheckOutScmResult checkoutResult =
70                      getScmManager().checkOut(scmRepository, new ScmFileSet(getAssertionCopy()), new ScmTag(tag));
71              assertFalse(checkoutResult.isSuccess()); // can't check out a deleted tags
72          } catch (ScmException ignored) {
73          }
74      }
75  }