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.plugin; 020 021import java.io.File; 022 023import org.apache.maven.scm.provider.svn.SvnScmTestUtils; 024import org.codehaus.plexus.util.FileUtils; 025import org.codehaus.plexus.util.StringUtils; 026import org.junit.Before; 027import org.junit.Test; 028import org.junit.runner.RunWith; 029import org.junit.runners.JUnit4; 030 031import static org.apache.maven.scm.ScmTestCase.checkScmPresence; 032 033/** 034 * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a> 035 * 036 */ 037@RunWith(JUnit4.class) 038public class UpdateMojoTest extends AbstractJUnit4MojoTestCase { 039 File checkoutDir; 040 041 File repository; 042 043 @Before 044 public void setUp() throws Exception { 045 super.setUp(); 046 047 checkoutDir = getTestFile("target/checkout"); 048 049 repository = getTestFile("target/repository"); 050 051 FileUtils.forceDelete(checkoutDir); 052 } 053 054 @Test 055 public void testSkipCheckoutWithConnectionUrl() throws Exception { 056 checkScmPresence(SvnScmTestUtils.SVNADMIN_COMMAND_LINE); 057 058 SvnScmTestUtils.initializeRepository(repository); 059 060 checkScmPresence(SvnScmTestUtils.SVN_COMMAND_LINE); 061 062 CheckoutMojo checkoutMojo = (CheckoutMojo) 063 lookupMojo("checkout", getTestFile("src/test/resources/mojos/checkout/checkoutWithConnectionUrl.xml")); 064 065 String connectionUrl = checkoutMojo.getConnectionUrl(); 066 connectionUrl = StringUtils.replace(connectionUrl, "${basedir}", getBasedir()); 067 connectionUrl = StringUtils.replace(connectionUrl, "\\", "/"); 068 checkoutMojo.setConnectionUrl(connectionUrl); 069 070 checkoutMojo.execute(); 071 072 UpdateMojo updateMojo = (UpdateMojo) 073 lookupMojo("update", getTestFile("src/test/resources/mojos/update/updateWithConnectionUrl.xml")); 074 075 connectionUrl = updateMojo.getConnectionUrl(); 076 connectionUrl = StringUtils.replace(connectionUrl, "${basedir}", getBasedir()); 077 connectionUrl = StringUtils.replace(connectionUrl, "\\", "/"); 078 updateMojo.setConnectionUrl(connectionUrl); 079 080 updateMojo.execute(); 081 } 082}