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.codehaus.plexus.util.FileUtils; 024 025import java.io.File; 026 027/** 028 * Unit Test for BootstrapMojo 029 * 030 * @author <a href="mailto:arne@degenring.com">Arne Degenring</a> 031 * 032 */ 033public class BootstrapMojoTest 034 extends AbstractMojoTestCase 035{ 036 File checkoutDir; 037 038 File projectDir; 039 040 File goalDir; 041 042 BootstrapMojo bootstrapMojo; 043 044 protected void setUp() 045 throws Exception 046 { 047 super.setUp(); 048 049 checkoutDir = getTestFile( "target/checkout" ); 050 FileUtils.forceDelete( checkoutDir ); 051 checkoutDir.mkdirs(); 052 053 projectDir = getTestFile( "target/checkout/my/project" ); 054 projectDir.mkdirs(); 055 056 goalDir = getTestFile( "target/checkout/my/project/modules/1" ); 057 goalDir.mkdirs(); 058 059 bootstrapMojo = new BootstrapMojo(); 060 } 061 062 public void testDetermineWorkingDirectoryPath() 063 throws Exception 064 { 065 // only checkout dir 066 assertEquals( checkoutDir.getPath(), bootstrapMojo.determineWorkingDirectoryPath( checkoutDir, "", "" ) ); 067 assertEquals( checkoutDir.getPath(), bootstrapMojo.determineWorkingDirectoryPath( checkoutDir, null, null ) ); 068 069 // checkout dir and goal dir 070 assertEquals( projectDir.getPath(), 071 bootstrapMojo.determineWorkingDirectoryPath( checkoutDir, "", "my/project" ) ); 072 073 // checkout dir and relative path project dir 074 assertEquals( projectDir.getPath(), 075 bootstrapMojo.determineWorkingDirectoryPath( checkoutDir, "my/project", null ) ); 076 assertEquals( projectDir.getPath(), 077 bootstrapMojo.determineWorkingDirectoryPath( checkoutDir, "my/project/", null ) ); 078 assertEquals( projectDir.getPath(), bootstrapMojo.determineWorkingDirectoryPath( checkoutDir, "my" + File 079 .separator + "project", null ) ); 080 081 // checkout dir, relative path project dir and goal dir have been set 082 assertEquals( goalDir.getPath(), 083 bootstrapMojo.determineWorkingDirectoryPath( checkoutDir, "my/project", "modules/1" ) ); 084 assertEquals( goalDir.getPath(), 085 bootstrapMojo.determineWorkingDirectoryPath( checkoutDir, "my/project/", "modules/1/" ) ); 086 assertEquals( goalDir.getPath(), bootstrapMojo.determineWorkingDirectoryPath( checkoutDir, 087 "my" + File.separator + "project", 088 "modules" + File.separator + 089 "1" ) ); 090 } 091 092 093}