Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: olivier lamy <olamy@webtide.com>
- Loading branch information
Showing
14 changed files
with
483 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
invoker.goals = test |
50 changes: 50 additions & 0 deletions
50
jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-base/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?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>com.webtide.jetty.its.jetty-run-mojo-it</groupId> | ||
<artifactId>jetty-simple-project</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>jetty-simple-base</artifactId> | ||
<packaging>jar</packaging> | ||
|
||
<name>Jetty :: Simple :: Base</name> | ||
|
||
<dependencies> | ||
|
||
<dependency> | ||
<groupId>javax.servlet</groupId> | ||
<artifactId>javax.servlet-api</artifactId> | ||
<type>jar</type> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>commons-io</groupId> | ||
<artifactId>commons-io</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.eclipse.jetty.toolchain</groupId> | ||
<artifactId>jetty-perf-helper</artifactId> | ||
<version>1.0.5</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-databind</artifactId> | ||
<version>2.8.1</version> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
</project> |
44 changes: 44 additions & 0 deletions
44
...jetty-simple-base/src/main/java/com/webtide/jetty/its/jetty_run_mojo_it/HelloServlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// | ||
// ======================================================================== | ||
// Copyright (c) 1995-2016 Mort Bay Consulting Pty. Ltd. | ||
// ------------------------------------------------------------------------ | ||
// All rights reserved. This program and the accompanying materials | ||
// are made available under the terms of the Eclipse Public License v1.0 | ||
// and Apache License v2.0 which accompanies this distribution. | ||
// | ||
// The Eclipse Public License is available at | ||
// http://www.eclipse.org/legal/epl-v10.html | ||
// | ||
// The Apache License v2.0 is available at | ||
// http://www.opensource.org/licenses/apache2.0.php | ||
// | ||
// You may elect to redistribute this code under either of these licenses. | ||
// ======================================================================== | ||
// | ||
|
||
package com.webtide.jetty.its.jetty_run_mojo_it; | ||
|
||
import javax.servlet.ServletException; | ||
import javax.servlet.annotation.WebServlet; | ||
import javax.servlet.http.HttpServlet; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
import java.io.IOException; | ||
|
||
/** | ||
* | ||
*/ | ||
@WebServlet("/hello") | ||
public class HelloServlet | ||
extends HttpServlet | ||
{ | ||
|
||
@Override | ||
protected void doGet( HttpServletRequest req, HttpServletResponse resp ) | ||
throws ServletException, IOException | ||
{ | ||
String who = req.getParameter( "name" ); | ||
|
||
resp.getWriter().write( "hello " + (who == null ? "unknown" : who) ); | ||
} | ||
} |
84 changes: 84 additions & 0 deletions
84
jetty-maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-webapp/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?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>com.webtide.jetty.its.jetty-run-mojo-it</groupId> | ||
<artifactId>jetty-simple-project</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>jetty-simple-webapp</artifactId> | ||
<packaging>war</packaging> | ||
|
||
<name>Jetty :: Simple :: Webapp</name> | ||
|
||
<dependencies> | ||
|
||
<dependency> | ||
<groupId>com.webtide.jetty.its.jetty-run-mojo-it</groupId> | ||
<artifactId>jetty-simple-base</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.eclipse.jetty</groupId> | ||
<artifactId>jetty-servlet</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.eclipse.jetty</groupId> | ||
<artifactId>jetty-client</artifactId> | ||
<version>@project.version@</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.12</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
|
||
<pluginManagement> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-war-plugin</artifactId> | ||
<version>${maven-war-plugin-version}</version> | ||
<configuration> | ||
<failOnMissingWebXml>false</failOnMissingWebXml> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</pluginManagement> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.eclipse.jetty</groupId> | ||
<artifactId>jetty-maven-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>start-jetty</id> | ||
<phase>test-compile</phase> | ||
<goals> | ||
<goal>run</goal> | ||
</goals> | ||
<configuration> | ||
<nonBlocking>true</nonBlocking> | ||
<propertiesPortFilePath>${project.build.directory}/jetty.properties</propertiesPortFilePath> | ||
<httpConnector> | ||
<port>0</port> | ||
</httpConnector> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
|
||
</project> |
7 changes: 7 additions & 0 deletions
7
...maven-plugin/src/it/jetty-run-mojo-it/jetty-simple-webapp/src/main/webapp/WEB-INF/web.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0"?> | ||
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" | ||
version="3.1"> | ||
<display-name>Jetty Simple Webapp run-mojo-it</display-name> | ||
</web-app> |
66 changes: 66 additions & 0 deletions
66
...simple-webapp/src/test/java/com/webtide/jetty/its/jetty_run_mojo_it/TestHelloServlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// | ||
// ======================================================================== | ||
// Copyright (c) 1995-2016 Mort Bay Consulting Pty. Ltd. | ||
// ------------------------------------------------------------------------ | ||
// All rights reserved. This program and the accompanying materials | ||
// are made available under the terms of the Eclipse Public License v1.0 | ||
// and Apache License v2.0 which accompanies this distribution. | ||
// | ||
// The Eclipse Public License is available at | ||
// http://www.eclipse.org/legal/epl-v10.html | ||
// | ||
// The Apache License v2.0 is available at | ||
// http://www.opensource.org/licenses/apache2.0.php | ||
// | ||
// You may elect to redistribute this code under either of these licenses. | ||
// ======================================================================== | ||
// | ||
|
||
package com.webtide.jetty.its.jetty_run_mojo_it; | ||
|
||
import org.eclipse.jetty.client.HttpClient; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import java.io.InputStream; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.util.Properties; | ||
|
||
/** | ||
* | ||
*/ | ||
public class TestHelloServlet | ||
{ | ||
@Test | ||
public void hello_servlet() | ||
throws Exception | ||
{ | ||
|
||
Path path = Paths.get( "target/jetty.properties" ); | ||
int port; | ||
try (InputStream inputStream = Files.newInputStream( path )) | ||
{ | ||
Properties properties = new Properties(); | ||
properties.load( inputStream ); | ||
port = Integer.parseInt( properties.getProperty( "port" ) ); | ||
} | ||
|
||
HttpClient httpClient = new HttpClient(); | ||
try | ||
{ | ||
httpClient.start(); | ||
|
||
String response = httpClient.GET( "http://localhost:" + port + "/hello?name=beer" ).getContentAsString(); | ||
|
||
System.out.println( "httpResponse:" + response ); | ||
|
||
Assert.assertEquals( "hello beer", response.trim() ); | ||
} | ||
finally | ||
{ | ||
httpClient.stop(); | ||
} | ||
} | ||
} |
Oops, something went wrong.