001package org.apache.maven.scm.plugin; 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.plugin.testing.AbstractMojoTestCase; 023import org.apache.maven.scm.ScmTestCase; 024import org.apache.maven.scm.provider.svn.SvnScmTestUtils; 025import org.codehaus.plexus.util.FileUtils; 026import org.codehaus.plexus.util.StringUtils; 027 028import java.io.File; 029 030/** 031 * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a> 032 * 033 */ 034public class UpdateMojoTest 035 extends AbstractMojoTestCase 036{ 037 File checkoutDir; 038 039 File repository; 040 041 protected void setUp() 042 throws Exception 043 { 044 super.setUp(); 045 046 checkoutDir = getTestFile( "target/checkout" ); 047 048 repository = getTestFile( "target/repository" ); 049 050 FileUtils.forceDelete( checkoutDir ); 051 } 052 053 public void testSkipCheckoutWithConnectionUrl() 054 throws Exception 055 { 056 if ( !ScmTestCase.isSystemCmd( SvnScmTestUtils.SVNADMIN_COMMAND_LINE ) ) 057 { 058 System.err.println( "'" + SvnScmTestUtils.SVNADMIN_COMMAND_LINE 059 + "' is not a system command. Ignored " + getName() + "." ); 060 return; 061 } 062 063 SvnScmTestUtils.initializeRepository( repository ); 064 065 CheckoutMojo checkoutMojo = (CheckoutMojo) lookupMojo( "checkout", getTestFile( 066 "src/test/resources/mojos/checkout/checkoutWithConnectionUrl.xml" ) ); 067 068 String connectionUrl = checkoutMojo.getConnectionUrl(); 069 connectionUrl = StringUtils.replace( connectionUrl, "${basedir}", getBasedir() ); 070 connectionUrl = StringUtils.replace( connectionUrl, "\\", "/" ); 071 checkoutMojo.setConnectionUrl( connectionUrl ); 072 073 checkoutMojo.execute(); 074 075 UpdateMojo updateMojo = (UpdateMojo) lookupMojo( "update", getTestFile( 076 "src/test/resources/mojos/update/updateWithConnectionUrl.xml" ) ); 077 078 connectionUrl = updateMojo.getConnectionUrl(); 079 connectionUrl = StringUtils.replace( connectionUrl, "${basedir}", getBasedir() ); 080 connectionUrl = StringUtils.replace( connectionUrl, "\\", "/" ); 081 updateMojo.setConnectionUrl( connectionUrl ); 082 083 updateMojo.execute(); 084 085 } 086 087}