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  
35  /**
36   * This test tests the untag command.
37   */
38  public abstract class UntagCommandTckTest
39      extends ScmTckTestCase
40  {
41  
42      protected String getTagName()
43      {
44          return "test-untag";
45      }
46  
47      public void testUntagCommandTest()
48          throws Exception
49      {
50          String tag = getTagName();
51          ScmProvider scmProvider = getScmManager().getProviderByUrl( getScmUrl() );
52          ScmRepository scmRepository = getScmRepository();
53          ScmFileSet files = new ScmFileSet( getWorkingCopy() );
54          TagScmResult tagResult = scmProvider.tag( scmRepository, files, tag, new ScmTagParameters() );
55  
56          assertResultIsSuccess( tagResult );
57          CommandParameters params = new CommandParameters();
58          params.setString( CommandParameter.TAG_NAME, tag );
59  
60          UntagScmResult untagResult = scmProvider.untag( scmRepository, files, params );
61  
62          assertResultIsSuccess( untagResult );
63  
64          try
65          {
66              untagResult = scmProvider.untag( scmRepository, files, params );
67              assertFalse( untagResult.isSuccess() ); // already been deleted
68          }
69          catch ( ScmException ignored )
70          {
71          }
72  
73          try
74          {
75              CheckOutScmResult checkoutResult =
76                  getScmManager().checkOut( scmRepository, new ScmFileSet( getAssertionCopy() ), new ScmTag( tag ) );
77              assertFalse( checkoutResult.isSuccess() ); // can't check out a deleted tags
78          }
79          catch ( ScmException ignored )
80          {
81          }
82      }
83  
84  }