mirror of
https://github.com/dokku/dokku.git
synced 2025-12-29 08:29:56 +01:00
Add Java test
This commit is contained in:
1
tests/apps/java/Procfile
Normal file
1
tests/apps/java/Procfile
Normal file
@@ -0,0 +1 @@
|
||||
web: java -cp target/classes:target/dependency/* HelloWorld
|
||||
2
tests/apps/java/check_deploy
Executable file
2
tests/apps/java/check_deploy
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e; output="$(curl -s $1)"; echo $output; test "$output" == "Hello from Java!"
|
||||
37
tests/apps/java/pom.xml
Normal file
37
tests/apps/java/pom.xml
Normal file
@@ -0,0 +1,37 @@
|
||||
<?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/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.example</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<artifactId>helloworld</artifactId>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-servlet</artifactId>
|
||||
<version>7.6.0.v20120127</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>2.5</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<version>2.4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-dependencies</id>
|
||||
<phase>package</phase>
|
||||
<goals><goal>copy-dependencies</goal></goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
22
tests/apps/java/src/main/java/HelloWorld.java
Normal file
22
tests/apps/java/src/main/java/HelloWorld.java
Normal file
@@ -0,0 +1,22 @@
|
||||
import java.io.IOException;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.*;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.servlet.*;
|
||||
|
||||
public class HelloWorld extends HttpServlet {
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
|
||||
throws ServletException, IOException {
|
||||
resp.getWriter().print("Hello from Java!\n");
|
||||
}
|
||||
public static void main(String[] args) throws Exception{
|
||||
Server server = new Server(Integer.valueOf(System.getenv("PORT")));
|
||||
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
|
||||
context.setContextPath("/");
|
||||
server.setHandler(context);
|
||||
context.addServlet(new ServletHolder(new HelloWorld()),"/*");
|
||||
server.start();
|
||||
server.join();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user