Skip to content

Commit

Permalink
init commit
Browse files Browse the repository at this point in the history
  • Loading branch information
liveperson committed Jun 6, 2018
0 parents commit b84b9ab
Show file tree
Hide file tree
Showing 12 changed files with 264 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
target
.classpath
.project
.settings
.idea
5 changes: 5 additions & 0 deletions README.md
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

47 changes: 47 additions & 0 deletions build-war/pom.xml
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 build-war/src/main/java/org/nirkoren/maven/demo/HelloHandler.java
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;
}

}
7 changes: 7 additions & 0 deletions build-war/src/main/webapp/WEB-INF/web.xml
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>
12 changes: 12 additions & 0 deletions build-war/src/main/webapp/index.jsp
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>
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);
}

}
14 changes: 14 additions & 0 deletions deploy-war/pom.xml
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>
38 changes: 38 additions & 0 deletions pom.xml
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>
58 changes: 58 additions & 0 deletions tests-war/pom.xml
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>
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 tests-war/src/test/java/org/nirkoren/maven/demo/HealthTest.java
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();
}

}

}

0 comments on commit b84b9ab

Please sign in to comment.