-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b84b9ab
Showing
12 changed files
with
264 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
target | ||
.classpath | ||
.project | ||
.settings | ||
.idea |
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,5 @@ | ||
# Welcome to SI-SE Zurich 2018 demo repo | ||
## This repo contains basic Maven project with Hello-World WAR file | ||
<BR> Ready for Tomcat deployment | ||
<BR> now also support jetty | ||
|
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,47 @@ | ||
<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> | ||
|
||
<artifactId>helloworld-build</artifactId> | ||
<name>BUILD hello world WAR</name> | ||
<packaging>war</packaging> | ||
|
||
<parent> | ||
<groupId>org.nirkoren.maven.demo</groupId> | ||
<artifactId>helloworld-reactor</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<properties> | ||
<finalWarName>helloworld</finalWarName> | ||
<javaVersion>1.8</javaVersion> | ||
</properties> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.7.0</version> | ||
<configuration> | ||
<source>${javaVersion}</source> | ||
<target>${javaVersion}</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-war-plugin</artifactId> | ||
<version>3.2.0</version> | ||
<configuration> | ||
<warName>${finalWarName}</warName> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<dependencies> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
</dependency> | ||
</dependencies> | ||
</project> |
10 changes: 10 additions & 0 deletions
10
build-war/src/main/java/org/nirkoren/maven/demo/HelloHandler.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,10 @@ | ||
package org.nirkoren.maven.demo; | ||
|
||
public class HelloHandler { | ||
|
||
public String sayHello() { | ||
String hello = "Hello SI-SE members, What do you think about this conference?"; | ||
return hello; | ||
} | ||
|
||
} |
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 @@ | ||
<!DOCTYPE web-app PUBLIC | ||
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" | ||
"http://java.sun.com/dtd/web-app_2_3.dtd" > | ||
|
||
<web-app> | ||
<display-name>Archetype Created Web Application</display-name> | ||
</web-app> |
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,12 @@ | ||
<%@page import="org.nirkoren.maven.demo.HelloHandler"%> | ||
<html> | ||
<body style="background-color: lightgrey; font-family: arial;"> | ||
<h2>Welcome to SI-SE Zurich Demo project</h2> | ||
SI-SE Zurich Demo, Maven WAR example<P> | ||
<% | ||
String prefix = "<B>Read info from Java class:</B> "; | ||
HelloHandler handler = new HelloHandler(); | ||
out.print(prefix + handler.sayHello()); | ||
%> | ||
</body> | ||
</html> |
17 changes: 17 additions & 0 deletions
17
build-war/src/test/java/org/nirkoren/maven/demo/HelloHandlerTest.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,17 @@ | ||
package org.nirkoren.maven.demo; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.nirkoren.maven.demo.HelloHandler; | ||
|
||
public class HelloHandlerTest { | ||
|
||
@Test | ||
public void validateNameNotNull() { | ||
HelloHandler handler = new HelloHandler(); | ||
String response = handler.sayHello(); | ||
// Due to the code: This test will never fail :) | ||
Assert.assertNotNull("String got null value",response); | ||
} | ||
|
||
} |
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,14 @@ | ||
<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> | ||
<artifactId>helloworld-deploy</artifactId> | ||
<name>DEPLOY hello world WAR</name> | ||
<packaging>pom</packaging> | ||
<parent> | ||
<groupId>org.nirkoren.maven.demo</groupId> | ||
<artifactId>helloworld-reactor</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
</parent> | ||
<!-- Here you can configure the desired deployment technology like: chef, Puppet, Ansible... for traditional projects and Docker / Kubernetes for containerized technologies --> | ||
</project> |
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,38 @@ | ||
<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>org.nirkoren.maven.demo</groupId> | ||
<artifactId>helloworld-reactor</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
<packaging>pom</packaging> | ||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
<modules> | ||
<module>build-war</module> | ||
<module>deploy-war</module> | ||
<module>tests-war</module> | ||
</modules> | ||
<build> | ||
<pluginManagement> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>2.21.0</version> | ||
</plugin> | ||
</plugins> | ||
</pluginManagement> | ||
</build> | ||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.12</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
</project> |
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,58 @@ | ||
<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> | ||
<artifactId>helloworld-tests</artifactId> | ||
<name>TESTS hello world WAR</name> | ||
<packaging>jar</packaging> | ||
<parent> | ||
<groupId>org.nirkoren.maven.demo</groupId> | ||
<artifactId>helloworld-reactor</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
</parent> | ||
<properties> | ||
<appurl>http://localhost:8080/helloworld</appurl> | ||
</properties> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<configuration> | ||
<skipTests>true</skipTests> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<profiles> | ||
<profile> | ||
<id>ci_profile</id> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>runTest</id> | ||
<phase>validate</phase> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<skipTests>false</skipTests> | ||
<systemPropertyVariables> | ||
<appurl>${appurl}</appurl> | ||
</systemPropertyVariables> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
</profiles> | ||
<dependencies> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
</dependency> | ||
</dependencies> | ||
</project> |
11 changes: 11 additions & 0 deletions
11
tests-war/src/main/java/org/nirkoren/maven/demo/TomcatPropsHandler.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,11 @@ | ||
package org.nirkoren.maven.demo; | ||
|
||
public class TomcatPropsHandler { | ||
|
||
private static String appurl = System.getProperty("appurl"); | ||
|
||
public static String getAppurl() { | ||
return appurl; | ||
} | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
tests-war/src/test/java/org/nirkoren/maven/demo/HealthTest.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,40 @@ | ||
package org.nirkoren.maven.demo; | ||
|
||
import static org.junit.Assert.fail; | ||
|
||
import java.net.HttpURLConnection; | ||
import java.net.URL; | ||
|
||
import org.junit.Assert; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
import org.nirkoren.maven.demo.TomcatPropsHandler; | ||
|
||
public class HealthTest { | ||
|
||
private static String appurl; | ||
|
||
@BeforeClass | ||
public static void setUpBeforeClass() throws Exception { | ||
appurl = TomcatPropsHandler.getAppurl(); | ||
} | ||
|
||
|
||
@Test | ||
public void testResponseCode() { | ||
URL url; | ||
try { | ||
System.out.println("Pinging: " + appurl); | ||
url = new URL(appurl); | ||
HttpURLConnection connection = (HttpURLConnection) url.openConnection(); | ||
connection.setRequestMethod("GET"); | ||
connection.connect(); | ||
int code = connection.getResponseCode(); | ||
Assert.assertEquals(200, code); | ||
} catch (Exception e) { | ||
fail(); | ||
} | ||
|
||
} | ||
|
||
} |