001package org.apache.maven.scm.tck.command.untag; 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.CommandParameter; 023import org.apache.maven.scm.CommandParameters; 024import org.apache.maven.scm.ScmException; 025import org.apache.maven.scm.ScmFileSet; 026import org.apache.maven.scm.ScmTag; 027import org.apache.maven.scm.ScmTagParameters; 028import org.apache.maven.scm.ScmTckTestCase; 029import org.apache.maven.scm.command.checkout.CheckOutScmResult; 030import org.apache.maven.scm.command.tag.TagScmResult; 031import org.apache.maven.scm.command.untag.UntagScmResult; 032import org.apache.maven.scm.provider.ScmProvider; 033import org.apache.maven.scm.repository.ScmRepository; 034import org.junit.Test; 035 036import static org.junit.Assert.assertFalse; 037 038/** 039 * This test tests the untag command. 040 */ 041public abstract class UntagCommandTckTest 042 extends ScmTckTestCase 043{ 044 045 protected String getTagName() 046 { 047 return "test-untag"; 048 } 049 050 @Test 051 public void testUntagCommandTest() 052 throws Exception 053 { 054 String tag = getTagName(); 055 ScmProvider scmProvider = getScmManager().getProviderByUrl( getScmUrl() ); 056 ScmRepository scmRepository = getScmRepository(); 057 ScmFileSet files = new ScmFileSet( getWorkingCopy() ); 058 TagScmResult tagResult = scmProvider.tag( scmRepository, files, tag, new ScmTagParameters() ); 059 060 assertResultIsSuccess( tagResult ); 061 CommandParameters params = new CommandParameters(); 062 params.setString( CommandParameter.TAG_NAME, tag ); 063 064 UntagScmResult untagResult = scmProvider.untag( scmRepository, files, params ); 065 066 assertResultIsSuccess( untagResult ); 067 068 try 069 { 070 untagResult = scmProvider.untag( scmRepository, files, params ); 071 assertFalse( untagResult.isSuccess() ); // already been deleted 072 } 073 catch ( ScmException ignored ) 074 { 075 } 076 077 try 078 { 079 CheckOutScmResult checkoutResult = 080 getScmManager().checkOut( scmRepository, new ScmFileSet( getAssertionCopy() ), new ScmTag( tag ) ); 081 assertFalse( checkoutResult.isSuccess() ); // can't check out a deleted tags 082 } 083 catch ( ScmException ignored ) 084 { 085 } 086 } 087 088}