1 package org.apache.maven.plugin.dependency;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.File;
23 import java.io.IOException;
24
25 import org.apache.maven.plugin.dependency.testUtils.DependencyArtifactStubFactory;
26 import org.apache.maven.plugin.dependency.testUtils.DependencyTestUtils;
27 import org.apache.maven.plugin.testing.AbstractMojoTestCase;
28
29 public abstract class AbstractDependencyMojoTestCase
30 extends AbstractMojoTestCase
31 {
32
33 protected File testDir;
34
35 protected DependencyArtifactStubFactory stubFactory;
36
37 public AbstractDependencyMojoTestCase()
38 {
39 super();
40 }
41
42 protected void setUp( String testDirStr, boolean createFiles )
43 throws Exception
44 {
45
46 super.setUp();
47 testDir = new File( getBasedir(), "target" + File.separatorChar + "unit-tests" + File.separatorChar
48 + testDirStr + File.separatorChar );
49 DependencyTestUtils.removeDirectory( testDir );
50 assertFalse( testDir.exists() );
51
52 stubFactory = new DependencyArtifactStubFactory( this.testDir, createFiles );
53
54 }
55
56 protected void tearDown()
57 {
58 if ( testDir != null )
59 {
60 try
61 {
62 DependencyTestUtils.removeDirectory( testDir );
63 }
64 catch ( IOException e )
65 {
66
67 e.printStackTrace();
68 fail( "Trying to remove directory:" + testDir + "\r\n" + e.toString() );
69 }
70 assertFalse( testDir.exists() );
71
72 testDir = null;
73 }
74
75 stubFactory = null;
76 }
77
78 }