summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/com/ashardalon/maven/tomcat/TomcatMojoTest.java61
-rw-r--r--src/test/resources/project-to-test/pom.xml27
2 files changed, 88 insertions, 0 deletions
diff --git a/src/test/java/com/ashardalon/maven/tomcat/TomcatMojoTest.java b/src/test/java/com/ashardalon/maven/tomcat/TomcatMojoTest.java
new file mode 100644
index 0000000..f2ef215
--- /dev/null
+++ b/src/test/java/com/ashardalon/maven/tomcat/TomcatMojoTest.java
@@ -0,0 +1,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 );
+ }
+
+}
+
diff --git a/src/test/resources/project-to-test/pom.xml b/src/test/resources/project-to-test/pom.xml
new file mode 100644
index 0000000..e7f929d
--- /dev/null
+++ b/src/test/resources/project-to-test/pom.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>com.ashardalon</groupId>
+ <artifactId>slim-tomcat-maven-plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+ <name>Test MyMojo</name>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>com.ashardalon</groupId>
+ <artifactId>slim-tomcat-maven-plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <configuration>
+ <!-- Specify the MyMojo parameter -->
+ <serverName>ashardalon-tomcat</serverName>
+ <targetWar>stachetype.war</targetWar>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>