001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 */ 019package org.apache.maven.scm.provider.svn.svnexe.command.untag; 020 021import java.io.File; 022 023import org.apache.maven.scm.ScmFileSet; 024import org.apache.maven.scm.provider.svn.command.untag.SvnUntagCommandTckTest; 025import org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository; 026import org.apache.maven.scm.repository.ScmRepository; 027import org.codehaus.plexus.util.cli.Commandline; 028import org.junit.Test; 029 030import static org.apache.maven.scm.provider.svn.SvnScmTestUtils.SVN_COMMAND_LINE; 031 032/** 033 * This test tests the untag command for Subversion. 034 * 035 */ 036public class SvnExeUntagCommandTckTest extends SvnUntagCommandTckTest { 037 @Override 038 public String getScmProviderCommand() { 039 return SVN_COMMAND_LINE; 040 } 041 042 /** 043 * test against ssh repository with user 044 * 045 * @throws Exception in case of error 046 */ 047 @Test 048 public void testUntagSsh() throws Exception { 049 File messageFile = File.createTempFile("maven-scm", "commit"); 050 messageFile.deleteOnExit(); 051 052 ScmFileSet scmFileSet = new ScmFileSet(new File("target/svn-untag-command-test")); 053 054 testCommandLine( 055 "scm:svn:svn+ssh://foo.com/svn/trunk", 056 scmFileSet, 057 "svntag", 058 messageFile, 059 "user", 060 "svn --username user --no-auth-cache --non-interactive --file " + messageFile.getAbsolutePath() 061 + " remove svn+ssh://user@foo.com/svn/tags/svntag@"); 062 } 063 064 /** 065 * test against https repository with user 066 * 067 * @throws Exception in case of error 068 */ 069 @Test 070 public void testUntagHttps() throws Exception { 071 File messageFile = File.createTempFile("maven-scm", "commit"); 072 messageFile.deleteOnExit(); 073 074 ScmFileSet scmFileSet = new ScmFileSet(new File("target/svn-untag-command-test")); 075 076 testCommandLine( 077 "scm:svn:https://foo.com/svn/tags", 078 scmFileSet, 079 "svntag", 080 messageFile, 081 "user", 082 "svn --username user --no-auth-cache --non-interactive --file " + messageFile.getAbsolutePath() 083 + " remove https://foo.com/svn/tags/svntag@"); 084 } 085 086 /** 087 * test routine, build command line and assert 088 * 089 * @param scmUrl url to svn repo 090 * @param scmFileSet file set for local dir 091 * @param tag tag to delete 092 * @param messageFile file containing commit message 093 * @param user user to acces the repo with 094 * @param commandLine set command line for comparison 095 * @throws Exception in case of error 096 */ 097 private void testCommandLine( 098 String scmUrl, ScmFileSet scmFileSet, String tag, File messageFile, String user, String commandLine) 099 throws Exception { 100 File workingDirectory = getTestFile("target/svn-untag-command-test"); 101 102 ScmRepository repository = getScmManager().makeScmRepository(scmUrl); 103 104 SvnScmProviderRepository svnRepository = (SvnScmProviderRepository) repository.getProviderRepository(); 105 106 svnRepository.setUser(user); 107 108 Commandline cl = new SvnUntagCommand().createCommandline(svnRepository, scmFileSet, tag, messageFile); 109 110 assertCommandLine(commandLine, workingDirectory, cl); 111 } 112}