Skip to content

Commit 921bdc4

Browse files
author
rhy-jot
committed
Add Java test
1 parent b602cd3 commit 921bdc4

4 files changed

Lines changed: 62 additions & 0 deletions

File tree

‎tests/apps/java/Procfile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: java -cp target/classes:target/dependency/* HelloWorld

‎tests/apps/java/check_deploy‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env bash
2+
set -e; output="$(curl -s $1)"; echo $output; test "$output" == "Hello from Java!"

‎tests/apps/java/pom.xml‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<groupId>com.example</groupId>
7+
<version>1.0-SNAPSHOT</version>
8+
<artifactId>helloworld</artifactId>
9+
<dependencies>
10+
<dependency>
11+
<groupId>org.eclipse.jetty</groupId>
12+
<artifactId>jetty-servlet</artifactId>
13+
<version>7.6.0.v20120127</version>
14+
</dependency>
15+
<dependency>
16+
<groupId>javax.servlet</groupId>
17+
<artifactId>servlet-api</artifactId>
18+
<version>2.5</version>
19+
</dependency>
20+
</dependencies>
21+
<build>
22+
<plugins>
23+
<plugin>
24+
<groupId>org.apache.maven.plugins</groupId>
25+
<artifactId>maven-dependency-plugin</artifactId>
26+
<version>2.4</version>
27+
<executions>
28+
<execution>
29+
<id>copy-dependencies</id>
30+
<phase>package</phase>
31+
<goals><goal>copy-dependencies</goal></goals>
32+
</execution>
33+
</executions>
34+
</plugin>
35+
</plugins>
36+
</build>
37+
</project>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import java.io.IOException;
2+
import javax.servlet.ServletException;
3+
import javax.servlet.http.*;
4+
import org.eclipse.jetty.server.Server;
5+
import org.eclipse.jetty.servlet.*;
6+
7+
public class HelloWorld extends HttpServlet {
8+
@Override
9+
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
10+
throws ServletException, IOException {
11+
resp.getWriter().print("Hello from Java!\n");
12+
}
13+
public static void main(String[] args) throws Exception{
14+
Server server = new Server(Integer.valueOf(System.getenv("PORT")));
15+
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
16+
context.setContextPath("/");
17+
server.setHandler(context);
18+
context.addServlet(new ServletHolder(new HelloWorld()),"/*");
19+
server.start();
20+
server.join();
21+
}
22+
}

0 commit comments

Comments
 (0)