Debian Codegraph @

maven-scm-plugin/src/test/java/org/apache/maven/scm/plugin/ExportMojoTest.java

raw
1 package org.apache.maven.scm.plugin;
2
3 /*
4 * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
5 * agreements. See the NOTICE file distributed with this work for additional information regarding
6 * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance with the License. You may obtain a
8 * copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software distributed under the License
13 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14 * or implied. See the License for the specific language governing permissions and limitations under
15 * the License.
16 */
17
18 import java.io.File;
19
20 import org.apache.maven.plugin.testing.AbstractMojoTestCase;
21 import org.apache.maven.scm.provider.svn.SvnScmTestUtils;
22 import org.codehaus.plexus.util.FileUtils;
23
24 /**
25 *
26 */
27 public class ExportMojoTest
28 extends AbstractMojoTestCase
29 {
30 File exportDir;
31
32 File repository;
33
34 protected void setUp()
35 throws Exception
36 {
37 super.setUp();
38
39 exportDir = getTestFile( "target/export" );
40
41 repository = getTestFile( "target/repository" );
42
43 FileUtils.forceDelete( exportDir );
44 }
45
46 public void testExport()
47 throws Exception
48 {
49 SvnScmTestUtils.initializeRepository( repository );
50
51 ExportMojo mojo = (ExportMojo) lookupMojo( "export", getTestFile( "src/test/resources/mojos/export/export.xml" ) );
52
53 mojo.setExportDirectory( exportDir.getAbsoluteFile() );
54
55 mojo.execute();
56
57 assertTrue( exportDir.listFiles().length > 0 );
58 assertFalse( new File( exportDir, ".svn" ).exists() );
59 }
60
61 public void testSkipExportIfExists()
62 throws Exception
63 {
64 exportDir.mkdirs();
65
66 ExportMojo mojo = (ExportMojo) lookupMojo(
67 "export",
68 getTestFile( "src/test/resources/mojos/export/exportWhenExportDirectoryExistsAndSkip.xml" ) );
69
70 mojo.setExportDirectory( exportDir );
71
72 mojo.execute();
73
74 assertEquals( 0, exportDir.listFiles().length );
75 }
76
77 public void testExcludeInclude()
78 throws Exception
79 {
80 SvnScmTestUtils.initializeRepository( repository );
81
82 exportDir.mkdirs();
83
84 ExportMojo mojo = (ExportMojo) lookupMojo(
85 "export",
86 getTestFile( "src/test/resources/mojos/export/exportWithExcludesIncludes.xml" ) );
87
88 mojo.setExportDirectory( exportDir );
89
90 mojo.execute();
91
92 assertTrue( exportDir.listFiles().length > 0 );
93 assertTrue( new File( exportDir, "pom.xml" ).exists() );
94 assertFalse( new File( exportDir, "readme.txt" ).exists() );
95 assertFalse( new File( exportDir, "src/test" ).exists() );
96 }
97
98 }