blob: f2ef2157e3c058f592560b0c7eb43623e016382c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
package com.ashardalon.maven.tomcat;
import org.apache.maven.plugin.testing.MojoRule;
import org.apache.maven.plugin.testing.WithoutMojo;
import org.junit.Rule;
import static org.junit.Assert.*;
import org.junit.Test;
import java.io.File;
public class TomcatMojoTest
{
@Rule
public MojoRule rule = new MojoRule()
{
@Override
protected void before() throws Throwable
{
}
@Override
protected void after()
{
}
};
/**
* @throws Exception if any
*/
@Test
public void testSomething()
throws Exception
{
File pom = new File( "target/test-classes/project-to-test/" );
assertNotNull( pom );
assertTrue( pom.exists() );
TomcatMojo myMojo = ( TomcatMojo ) rule.lookupConfiguredMojo( pom, "deploy" );
assertNotNull( myMojo );
myMojo.execute();
File outputDirectory = ( File ) rule.getVariableValueFromObject( myMojo, "outputDirectory" );
assertNotNull( outputDirectory );
assertTrue( outputDirectory.exists() );
File touch = new File( outputDirectory, "touch.txt" );
assertTrue( touch.exists() );
}
/** Do not need the MojoRule. */
@WithoutMojo
@Test
public void testSomethingWhichDoesNotNeedTheMojoAndProbablyShouldBeExtractedIntoANewClassOfItsOwn()
{
assertTrue( true );
}
}
|