Skip to content

Commit 7c19fb0

Browse files
committed
refactoring, added itegration tests, moved many messages from info to debug
1 parent 8a0d7d9 commit 7c19fb0

26 files changed

Lines changed: 638 additions & 422 deletions

File tree

pom.xml

Lines changed: 24 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>org.honton.chas</groupId>
66
<artifactId>process-exec-maven-plugin</artifactId>
7-
<version>0.9.1</version>
7+
<version>0.9.2-SNAPSHOT</version>
88
<packaging>maven-plugin</packaging>
99

1010
<name>Process execution maven plugin</name>
@@ -40,8 +40,6 @@
4040
</scm>
4141

4242
<properties>
43-
<guava.version>15.0</guava.version>
44-
4543
<maven.compiler.source>1.7</maven.compiler.source>
4644
<maven.compiler.target>1.7</maven.compiler.target>
4745
<!-- use org.sonatype.plugins:nexus-staging-maven-plugin instead of org.apache.maven.plugins:maven-deploy-plugin -->
@@ -54,17 +52,6 @@
5452
</properties>
5553

5654
<dependencies>
57-
<dependency>
58-
<groupId>com.google.guava</groupId>
59-
<artifactId>guava</artifactId>
60-
<version>${guava.version}</version>
61-
</dependency>
62-
63-
<dependency>
64-
<groupId>commons-io</groupId>
65-
<artifactId>commons-io</artifactId>
66-
<version>2.1</version>
67-
</dependency>
6855

6956
<dependency>
7057
<groupId>commons-net</groupId>
@@ -73,9 +60,10 @@
7360
</dependency>
7461

7562
<dependency>
76-
<groupId>org.apache.commons</groupId>
77-
<artifactId>commons-exec</artifactId>
78-
<version>1.2</version>
63+
<groupId>junit</groupId>
64+
<artifactId>junit</artifactId>
65+
<version>4.12</version>
66+
<scope>test</scope>
7967
</dependency>
8068

8169
<dependency>
@@ -109,19 +97,6 @@
10997
<version>${maven.model.version}</version>
11098
</dependency>
11199

112-
<dependency>
113-
<groupId>org.codehaus.plexus</groupId>
114-
<artifactId>plexus-utils</artifactId>
115-
<version>${maven.model.version}</version>
116-
</dependency>
117-
118-
<dependency>
119-
<groupId>org.testng</groupId>
120-
<artifactId>testng</artifactId>
121-
<version>6.8.7</version>
122-
<scope>test</scope>
123-
</dependency>
124-
125100
<dependency>
126101
<groupId>org.honton.chas.url</groupId>
127102
<artifactId>url-extension</artifactId>
@@ -133,6 +108,25 @@
133108
<build>
134109
<plugins>
135110

111+
<plugin>
112+
<artifactId>maven-invoker-plugin</artifactId>
113+
<version>2.0.0</version>
114+
<configuration>
115+
<postBuildHookScript>verify</postBuildHookScript>
116+
<addTestClassPath>true</addTestClassPath>
117+
</configuration>
118+
<executions>
119+
<execution>
120+
<id>integration-test</id>
121+
<goals>
122+
<goal>install</goal>
123+
<goal>verify</goal>
124+
<goal>run</goal>
125+
</goals>
126+
</execution>
127+
</executions>
128+
</plugin>
129+
136130
<plugin>
137131
<groupId>org.apache.maven.plugins</groupId>
138132
<artifactId>maven-plugin-plugin</artifactId>
@@ -163,23 +157,6 @@
163157
<version>2.18.1</version>
164158
</plugin>
165159

166-
167-
<plugin>
168-
<artifactId>maven-invoker-plugin</artifactId>
169-
<version>2.0.0</version>
170-
<configuration>
171-
</configuration>
172-
<executions>
173-
<execution>
174-
<id>integration-test</id>
175-
<goals>
176-
<goal>verify</goal>
177-
<goal>run</goal>
178-
</goals>
179-
</execution>
180-
</executions>
181-
</plugin>
182-
183160
</plugins>
184161
</build>
185162

src/it/logFile/invoker.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
invoker.goals = clean verify
2+
invoker.failureBehavior = fail-at-end
3+

src/it/logFile/pom.xml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<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">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<parent>
6+
<groupId>org.honton.chas</groupId>
7+
<artifactId>process-it-parent</artifactId>
8+
<version>0.9.2-SNAPSHOT</version>
9+
<relativePath>../pom.xml</relativePath>
10+
</parent>
11+
<artifactId>process-exec-maven-plugin-logfile</artifactId>
12+
13+
<dependencies>
14+
<dependency>
15+
<groupId>junit</groupId>
16+
<artifactId>junit</artifactId>
17+
<scope>test</scope>
18+
</dependency>
19+
</dependencies>
20+
21+
<build>
22+
<plugins>
23+
24+
<plugin>
25+
<groupId>org.honton.chas</groupId>
26+
<artifactId>process-exec-maven-plugin</artifactId>
27+
<executions>
28+
<execution>
29+
<goals>
30+
<goal>start</goal>
31+
</goals>
32+
<phase>pre-integration-test</phase>
33+
<configuration>
34+
<processLogFile>${project.build.directory}/out_err</processLogFile>
35+
<name>logfile</name>
36+
<waitAfterLaunch>2</waitAfterLaunch>
37+
<arguments>
38+
<argument>${java.home}/bin/java</argument>
39+
<argument>-classpath</argument>
40+
<argument>${project.build.outputDirectory}</argument>
41+
<argument>org.honton.chas.process.logfile.Main</argument>
42+
</arguments>
43+
</configuration>
44+
</execution>
45+
46+
<execution>
47+
<id>stop-all</id>
48+
<goals>
49+
<goal>stop-all</goal>
50+
</goals>
51+
<phase>post-integration-test</phase>
52+
</execution>
53+
</executions>
54+
</plugin>
55+
</plugins>
56+
57+
</build>
58+
59+
</project>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package org.honton.chas.process.logfile;
2+
3+
import java.util.concurrent.TimeUnit;
4+
5+
/**
6+
* Generate some characters on out and err.
7+
*/
8+
public class Main {
9+
public static void main(String argv[]) {
10+
System.out.println("started");
11+
12+
Runtime.getRuntime().addShutdownHook(new Thread() {
13+
@Override
14+
public void run() {
15+
System.err.println("shutdown hook");
16+
}
17+
});
18+
19+
try {
20+
Thread.sleep(TimeUnit.SECONDS.toMillis(30));
21+
}
22+
catch (InterruptedException ignore) {
23+
}
24+
System.exit(0);
25+
}
26+
}

src/it/logFile/verify.bsh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import java.io.File;
2+
import java.nio.charset.StandardCharsets;
3+
import java.nio.file.Files;
4+
import java.nio.file.Paths;
5+
import java.util.List;
6+
import org.junit.Assert;
7+
8+
File file = new File( basedir, "target/out_err" );
9+
Assert.assertTrue("missing target/out_err", file.isFile());
10+
11+
List lines= Files.readAllLines(file.toPath(), StandardCharsets.UTF_8);
12+
Assert.assertEquals("started", lines.get(0));
13+
Assert.assertEquals("shutdown hook", lines.get(1));

src/it/nullargs/invoker.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
invoker.goals = clean verify
2+
invoker.failureBehavior = fail-at-end

src/it/nullargs/pom.xml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<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">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<parent>
6+
<groupId>org.honton.chas</groupId>
7+
<artifactId>process-it-parent</artifactId>
8+
<version>0.9.2-SNAPSHOT</version>
9+
<relativePath>../pom.xml</relativePath>
10+
</parent>
11+
<artifactId>process-exec-maven-plugin-null-args</artifactId>
12+
13+
<dependencies>
14+
15+
<dependency>
16+
<groupId>junit</groupId>
17+
<artifactId>junit</artifactId>
18+
</dependency>
19+
20+
</dependencies>
21+
22+
<build>
23+
<plugins>
24+
25+
<plugin>
26+
<groupId>org.honton.chas</groupId>
27+
<artifactId>process-exec-maven-plugin</artifactId>
28+
<executions>
29+
<execution>
30+
<goals>
31+
<goal>start</goal>
32+
</goals>
33+
<phase>pre-integration-test</phase>
34+
<configuration>
35+
<name>nullargs</name>
36+
<waitAfterLaunch>2</waitAfterLaunch>
37+
<arguments>
38+
<argument>${java.home}/bin/java</argument>
39+
<argument>-classpath</argument>
40+
<argument>${runtime.classpath}${path.separator}${project.build.outputDirectory}</argument>
41+
<argument>org.honton.chas.process.nullargs.Main</argument>
42+
<argument></argument>
43+
<argument>one</argument>
44+
</arguments>
45+
</configuration>
46+
</execution>
47+
48+
<execution>
49+
<id>stop-all</id>
50+
<goals>
51+
<goal>stop-all</goal>
52+
</goals>
53+
<phase>post-integration-test</phase>
54+
</execution>
55+
</executions>
56+
</plugin>
57+
</plugins>
58+
59+
</build>
60+
61+
</project>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package org.honton.chas.process.nullargs;
2+
3+
import org.junit.Assert;
4+
5+
/**
6+
* Expect only non-null arguments
7+
*/
8+
public class Main {
9+
public static void main(String argv[]) throws Exception {
10+
Assert.assertEquals(1, argv.length);
11+
Assert.assertEquals("one", argv[0]);
12+
System.exit(0);
13+
}
14+
}

src/it/order/invoker.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
invoker.goals = clean verify
2+
invoker.failureBehavior = fail-at-end
3+

src/it/order/pom.xml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<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">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<parent>
6+
<groupId>org.honton.chas</groupId>
7+
<artifactId>process-it-parent</artifactId>
8+
<version>0.9.2-SNAPSHOT</version>
9+
<relativePath>../pom.xml</relativePath>
10+
</parent>
11+
<artifactId>process-exec-maven-plugin-order</artifactId>
12+
13+
<dependencies>
14+
<dependency>
15+
<groupId>junit</groupId>
16+
<artifactId>junit</artifactId>
17+
<scope>test</scope>
18+
</dependency>
19+
</dependencies>
20+
21+
<build>
22+
<plugins>
23+
24+
<plugin>
25+
<groupId>org.honton.chas</groupId>
26+
<artifactId>process-exec-maven-plugin</artifactId>
27+
<executions>
28+
<execution>
29+
<id>one</id>
30+
<goals>
31+
<goal>start</goal>
32+
</goals>
33+
<phase>pre-integration-test</phase>
34+
<configuration>
35+
<name>order-one</name>
36+
<waitAfterLaunch>2</waitAfterLaunch>
37+
<arguments>
38+
<argument>${java.home}/bin/java</argument>
39+
<argument>-classpath</argument>
40+
<argument>${project.build.outputDirectory}</argument>
41+
<argument>org.honton.chas.process.order.Main</argument>
42+
<argument>one</argument>
43+
</arguments>
44+
</configuration>
45+
</execution>
46+
47+
<execution>
48+
<id>two</id>
49+
<goals>
50+
<goal>start</goal>
51+
</goals>
52+
<phase>pre-integration-test</phase>
53+
<configuration>
54+
<name>order-two</name>
55+
<waitAfterLaunch>2</waitAfterLaunch>
56+
<arguments>
57+
<argument>${java.home}/bin/java</argument>
58+
<argument>-classpath</argument>
59+
<argument>${project.build.outputDirectory}</argument>
60+
<argument>org.honton.chas.process.order.Main</argument>
61+
<argument>two</argument>
62+
</arguments>
63+
</configuration>
64+
</execution>
65+
66+
<execution>
67+
<id>stop-all</id>
68+
<goals>
69+
<goal>stop-all</goal>
70+
</goals>
71+
<phase>post-integration-test</phase>
72+
</execution>
73+
</executions>
74+
</plugin>
75+
</plugins>
76+
77+
</build>
78+
79+
</project>

0 commit comments

Comments
 (0)