Skip to content

Commit

Permalink
refactoring, added itegration tests, moved many messages from info to…
Browse files Browse the repository at this point in the history
… debug
  • Loading branch information
chonton committed Apr 16, 2017
1 parent 8a0d7d9 commit 7c19fb0
Show file tree
Hide file tree
Showing 26 changed files with 638 additions and 422 deletions.
71 changes: 24 additions & 47 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>org.honton.chas</groupId>
<artifactId>process-exec-maven-plugin</artifactId>
<version>0.9.1</version>
<version>0.9.2-SNAPSHOT</version>
<packaging>maven-plugin</packaging>

<name>Process execution maven plugin</name>
Expand Down Expand Up @@ -40,8 +40,6 @@
</scm>

<properties>
<guava.version>15.0</guava.version>

<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<!-- use org.sonatype.plugins:nexus-staging-maven-plugin instead of org.apache.maven.plugins:maven-deploy-plugin -->
Expand All @@ -54,17 +52,6 @@
</properties>

<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${guava.version}</version>
</dependency>

<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.1</version>
</dependency>

<dependency>
<groupId>commons-net</groupId>
Expand All @@ -73,9 +60,10 @@
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-exec</artifactId>
<version>1.2</version>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>

<dependency>
Expand Down Expand Up @@ -109,19 +97,6 @@
<version>${maven.model.version}</version>
</dependency>

<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>${maven.model.version}</version>
</dependency>

<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8.7</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.honton.chas.url</groupId>
<artifactId>url-extension</artifactId>
Expand All @@ -133,6 +108,25 @@
<build>
<plugins>

<plugin>
<artifactId>maven-invoker-plugin</artifactId>
<version>2.0.0</version>
<configuration>
<postBuildHookScript>verify</postBuildHookScript>
<addTestClassPath>true</addTestClassPath>
</configuration>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>install</goal>
<goal>verify</goal>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
Expand Down Expand Up @@ -163,23 +157,6 @@
<version>2.18.1</version>
</plugin>


<plugin>
<artifactId>maven-invoker-plugin</artifactId>
<version>2.0.0</version>
<configuration>
</configuration>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>verify</goal>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>

</plugins>
</build>

Expand Down
3 changes: 3 additions & 0 deletions src/it/logFile/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
invoker.goals = clean verify
invoker.failureBehavior = fail-at-end

59 changes: 59 additions & 0 deletions src/it/logFile/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?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>

<parent>
<groupId>org.honton.chas</groupId>
<artifactId>process-it-parent</artifactId>
<version>0.9.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>process-exec-maven-plugin-logfile</artifactId>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>

<plugin>
<groupId>org.honton.chas</groupId>
<artifactId>process-exec-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>start</goal>
</goals>
<phase>pre-integration-test</phase>
<configuration>
<processLogFile>${project.build.directory}/out_err</processLogFile>
<name>logfile</name>
<waitAfterLaunch>2</waitAfterLaunch>
<arguments>
<argument>${java.home}/bin/java</argument>
<argument>-classpath</argument>
<argument>${project.build.outputDirectory}</argument>
<argument>org.honton.chas.process.logfile.Main</argument>
</arguments>
</configuration>
</execution>

<execution>
<id>stop-all</id>
<goals>
<goal>stop-all</goal>
</goals>
<phase>post-integration-test</phase>
</execution>
</executions>
</plugin>
</plugins>

</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.honton.chas.process.logfile;

import java.util.concurrent.TimeUnit;

/**
* Generate some characters on out and err.
*/
public class Main {
public static void main(String argv[]) {
System.out.println("started");

Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
System.err.println("shutdown hook");
}
});

try {
Thread.sleep(TimeUnit.SECONDS.toMillis(30));
}
catch (InterruptedException ignore) {
}
System.exit(0);
}
}
13 changes: 13 additions & 0 deletions src/it/logFile/verify.bsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import java.io.File;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
import org.junit.Assert;

File file = new File( basedir, "target/out_err" );
Assert.assertTrue("missing target/out_err", file.isFile());

List lines= Files.readAllLines(file.toPath(), StandardCharsets.UTF_8);
Assert.assertEquals("started", lines.get(0));
Assert.assertEquals("shutdown hook", lines.get(1));
2 changes: 2 additions & 0 deletions src/it/nullargs/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
invoker.goals = clean verify
invoker.failureBehavior = fail-at-end
61 changes: 61 additions & 0 deletions src/it/nullargs/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?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>

<parent>
<groupId>org.honton.chas</groupId>
<artifactId>process-it-parent</artifactId>
<version>0.9.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>process-exec-maven-plugin-null-args</artifactId>

<dependencies>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>

</dependencies>

<build>
<plugins>

<plugin>
<groupId>org.honton.chas</groupId>
<artifactId>process-exec-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>start</goal>
</goals>
<phase>pre-integration-test</phase>
<configuration>
<name>nullargs</name>
<waitAfterLaunch>2</waitAfterLaunch>
<arguments>
<argument>${java.home}/bin/java</argument>
<argument>-classpath</argument>
<argument>${runtime.classpath}${path.separator}${project.build.outputDirectory}</argument>
<argument>org.honton.chas.process.nullargs.Main</argument>
<argument></argument>
<argument>one</argument>
</arguments>
</configuration>
</execution>

<execution>
<id>stop-all</id>
<goals>
<goal>stop-all</goal>
</goals>
<phase>post-integration-test</phase>
</execution>
</executions>
</plugin>
</plugins>

</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.honton.chas.process.nullargs;

import org.junit.Assert;

/**
* Expect only non-null arguments
*/
public class Main {
public static void main(String argv[]) throws Exception {
Assert.assertEquals(1, argv.length);
Assert.assertEquals("one", argv[0]);
System.exit(0);
}
}
3 changes: 3 additions & 0 deletions src/it/order/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
invoker.goals = clean verify
invoker.failureBehavior = fail-at-end

79 changes: 79 additions & 0 deletions src/it/order/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?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>

<parent>
<groupId>org.honton.chas</groupId>
<artifactId>process-it-parent</artifactId>
<version>0.9.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>process-exec-maven-plugin-order</artifactId>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>

<plugin>
<groupId>org.honton.chas</groupId>
<artifactId>process-exec-maven-plugin</artifactId>
<executions>
<execution>
<id>one</id>
<goals>
<goal>start</goal>
</goals>
<phase>pre-integration-test</phase>
<configuration>
<name>order-one</name>
<waitAfterLaunch>2</waitAfterLaunch>
<arguments>
<argument>${java.home}/bin/java</argument>
<argument>-classpath</argument>
<argument>${project.build.outputDirectory}</argument>
<argument>org.honton.chas.process.order.Main</argument>
<argument>one</argument>
</arguments>
</configuration>
</execution>

<execution>
<id>two</id>
<goals>
<goal>start</goal>
</goals>
<phase>pre-integration-test</phase>
<configuration>
<name>order-two</name>
<waitAfterLaunch>2</waitAfterLaunch>
<arguments>
<argument>${java.home}/bin/java</argument>
<argument>-classpath</argument>
<argument>${project.build.outputDirectory}</argument>
<argument>org.honton.chas.process.order.Main</argument>
<argument>two</argument>
</arguments>
</configuration>
</execution>

<execution>
<id>stop-all</id>
<goals>
<goal>stop-all</goal>
</goals>
<phase>post-integration-test</phase>
</execution>
</executions>
</plugin>
</plugins>

</build>

</project>
Loading

0 comments on commit 7c19fb0

Please sign in to comment.