001package org.apache.maven.scm.plugin; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one or more contributor license 005 * agreements. See the NOTICE file distributed with this work for additional information regarding 006 * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance with the License. You may obtain a 008 * 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, software distributed under the License 013 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 014 * or implied. See the License for the specific language governing permissions and limitations under 015 * the License. 016 */ 017 018import java.io.File; 019 020import org.apache.maven.plugin.testing.AbstractMojoTestCase; 021import org.apache.maven.scm.provider.svn.SvnScmTestUtils; 022import org.codehaus.plexus.util.FileUtils; 023 024/** 025 * @version $Id: ExportMojoTest.java 687713 2008-08-21 11:12:33Z vsiveton $ 026 */ 027public class ExportMojoTest 028 extends AbstractMojoTestCase 029{ 030 File exportDir; 031 032 File repository; 033 034 protected void setUp() 035 throws Exception 036 { 037 super.setUp(); 038 039 exportDir = getTestFile( "target/export" ); 040 041 repository = getTestFile( "target/repository" ); 042 043 FileUtils.forceDelete( exportDir ); 044 } 045 046 public void testExport() 047 throws Exception 048 { 049 SvnScmTestUtils.initializeRepository( repository ); 050 051 ExportMojo mojo = (ExportMojo) lookupMojo( "export", getTestFile( "src/test/resources/mojos/export/export.xml" ) ); 052 053 mojo.setExportDirectory( exportDir.getAbsoluteFile() ); 054 055 mojo.execute(); 056 057 assertTrue( exportDir.listFiles().length > 0 ); 058 assertFalse( new File( exportDir, ".svn" ).exists() ); 059 } 060 061 public void testSkipExportIfExists() 062 throws Exception 063 { 064 exportDir.mkdirs(); 065 066 ExportMojo mojo = (ExportMojo) lookupMojo( 067 "export", 068 getTestFile( "src/test/resources/mojos/export/exportWhenExportDirectoryExistsAndSkip.xml" ) ); 069 070 mojo.setExportDirectory( exportDir ); 071 072 mojo.execute(); 073 074 assertEquals( 0, exportDir.listFiles().length ); 075 } 076 077 public void testExcludeInclude() 078 throws Exception 079 { 080 SvnScmTestUtils.initializeRepository( repository ); 081 082 exportDir.mkdirs(); 083 084 ExportMojo mojo = (ExportMojo) lookupMojo( 085 "export", 086 getTestFile( "src/test/resources/mojos/export/exportWithExcludesIncludes.xml" ) ); 087 088 mojo.setExportDirectory( exportDir ); 089 090 mojo.execute(); 091 092 assertTrue( exportDir.listFiles().length > 0 ); 093 assertTrue( new File( exportDir, "pom.xml" ).exists() ); 094 assertFalse( new File( exportDir, "readme.txt" ).exists() ); 095 assertFalse( new File( exportDir, "src/test" ).exists() ); 096 } 097 098}