Skip to content
This repository has been archived by the owner on Oct 20, 2020. It is now read-only.

Commit

Permalink
Add shutdown hook and refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Pradeep Thomas committed Oct 5, 2016
1 parent e52a7f6 commit 512e5d8
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 33 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</parent>
<groupId>uk.gov.justice.plugin</groupId>
<artifactId>server-maven-plugin</artifactId>
<version>0.1-SNAPSHOT</version>
<version>1.0</version>
<packaging>maven-plugin</packaging>
<name>server-maven-plugin</name>
<url>http://maven.apache.org</url>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/uk/gov/justice/plugin/StartServerMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ public void execute() throws MojoExecutionException {
args.add(getServerClass());

final Process process = new ProcessBuilder(args).start();
addShutdownHook(process);
dumpStream(process.getInputStream(), System.out);
dumpStream(process.getErrorStream(), System.err);
addShutdownHook(process);
waitOnStopCommand(process);

} catch (Exception e) {
Expand Down
13 changes: 0 additions & 13 deletions src/main/java/uk/gov/justice/plugin/StopServerMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;

@Mojo(name = "stop", defaultPhase = LifecyclePhase.VERIFY, requiresOnline = false,
requiresProject = true, threadSafe = false)
Expand All @@ -17,18 +16,6 @@ public class StopServerMojo extends AbstractMojo {
@Parameter(property = "port", required = true)
protected int port;

@Parameter(defaultValue = "${project}", readonly = true)
protected MavenProject project;


public MavenProject getProject() {
return project;
}

public void setProject(MavenProject project) {
this.project = project;
}

public int getPort() {
return port;
}
Expand Down
18 changes: 0 additions & 18 deletions src/test/java/uk/gov/justice/plugin/StopServerMojoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;

import java.io.DataInputStream;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
Expand All @@ -22,20 +18,6 @@ public class StopServerMojoTest {
@InjectMocks
StopServerMojo stopServerMojo;

@Test
public void shouldGetProject() {
MavenProject mp = mock(MavenProject.class);
stopServerMojo.setProject(mp);
assertEquals(mp, stopServerMojo.getProject());
}

@Test
public void shouldSetProject() {
MavenProject mp = mock(MavenProject.class);
stopServerMojo.setProject(mp);
assertEquals(mp, stopServerMojo.getProject());
}

@Test
public void shouldGetPort() {
stopServerMojo.setPort(8000);
Expand Down

0 comments on commit 512e5d8

Please sign in to comment.