Skip to content

Commit 87ae5e6

Browse files
committed
A sample Web Application
0 parents  commit 87ae5e6

17 files changed

+240
-0
lines changed

WebContent/META-INF/MANIFEST.MF

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Manifest-Version: 1.0
2+
Class-Path:
3+

WebContent/WEB-INF/lib/junit.jar

308 KB
Binary file not shown.
Binary file not shown.

WebContent/WEB-INF/web.xml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
5+
version="2.4">
6+
7+
<display-name>Sample Web Application</display-name>
8+
<description>
9+
This is a simple web application to demonstrate Jenkins build, test and deploy capabilities along with ANT.
10+
</description>
11+
12+
<servlet>
13+
<servlet-name>SampleServlet</servlet-name>
14+
<servlet-class>example.Calculator</servlet-class>
15+
</servlet>
16+
17+
<servlet-mapping>
18+
<servlet-name>SampleServlet</servlet-name>
19+
<url-pattern>/sample</url-pattern>
20+
</servlet-mapping>
21+
22+
</web-app>

WebContent/images/Arryn.png

73.8 KB
Loading

WebContent/images/Baratheon.png

50.8 KB
Loading

WebContent/images/GOT.jpg

64.3 KB
Loading

WebContent/images/Gardner.png

30.3 KB
Loading

WebContent/images/Harren_Hoare.png

471 KB
Loading

WebContent/images/HouseStark.png

77.8 KB
Loading

WebContent/images/Lannister.png

124 KB
Loading

WebContent/images/Martell.png

59.6 KB
Loading

WebContent/images/Stark.png

4.3 KB
Loading

WebContent/index.html

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
2+
<!doctype html>
3+
<html>
4+
<head>
5+
<title>Game of Thrones</title>
6+
7+
<meta charset="utf-8" />
8+
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
9+
<meta name="viewport" content="width=device-width, initial-scale=1" />
10+
11+
</head>
12+
13+
<body>
14+
<center><h1>Game of Thrones</h1></center>
15+
<hr>
16+
<div id="topOfPage">
17+
<center><img src="images/GOT.jpg" align="center"></img></center>
18+
<p>Game of Thrones is an American fantasy drama television series created by David Benioff and D. B. Weiss. It is an adaptation of A Song of Ice and Fire, George R. R. Martin's series of fantasy novels, the first of which is 'A Game of Thrones'!!!</p>
19+
20+
<p><h3>General Plot of the TV series:</h3> A story of greed, lust, thirst for power, ruthlessness, barbarity - GOT is a story of seven kingdoms vying and sparring over absolute power and control to the Iron Throne.</p>
21+
<iframe align = "right" width="400" height="200" src="https://www.youtube.com/embed/522l0YE9hRQ" frameborder="0" allowfullscreen></iframe>
22+
</div>
23+
<hr>
24+
<p><h3>Warring kingdoms:</h3>
25+
<ul>
26+
<li>Kingdom of the North!</li>
27+
<li>Kingdom of the Mountain and the Vale</li>
28+
<li>Kingdom of the Isles and Rivers</li>
29+
<li>Kingdom of the Rock</li>
30+
<li>Kingdom of the Stormlands</li>
31+
<li>Kingdom of the Reach</li>
32+
<li>Principality of Dorne</li>
33+
</ul>
34+
</p>
35+
<hr>
36+
<center>
37+
<ins><h3>Kingdoms with their Lords or rulers and their symbols</h3></ins>
38+
<table border="1">
39+
<thead>
40+
<tr>
41+
<th>Kingdom</th>
42+
<th>Lords</th>
43+
<th>Symbol</th>
44+
</tr>
45+
</thead>
46+
<tbody>
47+
<tr>
48+
<td>The North</td>
49+
<td>Stark of Winterfell</td>
50+
<td align="center"><a href="http://gameofthrones.wikia.com/wiki/Winterfell"><img src="images/HouseStark.png" height="100" width="100"></a></td>
51+
</tr>
52+
<tr>
53+
<td>Kingdom of the Isles and Rivers</td>
54+
<td>Harren Hoare</td>
55+
<td align="center"><a href="http://gameofthrones.wikia.com/wiki/Harren_Hoare"><img src="images/Harren_Hoare.png" height="100" width="100"></a></td>
56+
</tr>
57+
<tr>
58+
<td>The Vale</td>
59+
<td>Arryn of the Eyrie</td>
60+
<td align="center"><a href="http://gameofthrones.wikia.com/wiki/House_Arryn"><img src="images/Arryn.png" height="100" width="100"></a></td>
61+
</tr>
62+
<tr>
63+
<td>The Westernlands</td>
64+
<td>Lannister of Casterly Rock</td>
65+
<td align="center"><a href="http://gameofthrones.wikia.com/wiki/House_Lannister"><img src="images/Lannister.png" height="100" width="100"></a></td>
66+
</tr>
67+
<tr>
68+
<td>The Stormlands</td>
69+
<td>Baratheon of Storm's End</td>
70+
<td align="center"><a href="http://gameofthrones.wikia.com/wiki/House_Baratheon"><img src="images/Baratheon.png" height="100" width="100"></a></td>
71+
</tr>
72+
<tr>
73+
<td>The Riverlands</td>
74+
<td>Tully of Riverrun</td>
75+
<td align="center"><a href="http://gameofthrones.wikia.com/wiki/House_Gardener"><img src="images/Gardner.png" height="100" width="100"></a></td>
76+
</tr>
77+
<tr>
78+
<td>Dorne</td>
79+
<td>Martell of Sunspear</td>
80+
<td align="center"><a href="http://gameofthrones.wikia.com/wiki/House_Martell"><img src="images/Martell.png" height="100" width="100"></a></td>
81+
</tr>
82+
</tbody>
83+
</table>
84+
</center>
85+
<p>Dedicated to all <strong>Game of Thrones</strong><sup>&reg;</sup> fans</p>
86+
<p><a href="#topOfPage">top</a></p>
87+
</body>
88+
</html>

build.xml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?xml version="1.0" ?>
2+
<project name="SampleBuildWithAnt" default="war">
3+
<path id="compile.classpath">
4+
<fileset dir="WebContent/WEB-INF/lib">
5+
<include name="*.jar"/>
6+
</fileset>
7+
</path>
8+
9+
<target name="init">
10+
<mkdir dir="build/classes"/>
11+
<mkdir dir="dist" />
12+
<mkdir dir="test-reports"/>
13+
</target>
14+
15+
<target name="compile" depends="init" >
16+
<javac destdir="build/classes" debug="true" srcdir="src">
17+
<classpath refid="compile.classpath"/>
18+
</javac>
19+
</target>
20+
21+
<target name="war" depends="compile">
22+
<war destfile="dist/SampleWebApp.war" webxml="WebContent/WEB-INF/web.xml">
23+
<fileset dir="WebContent"/>
24+
<lib dir="WebContent/WEB-INF/lib"/>
25+
<classes dir="build/classes"/>
26+
</war>
27+
</target>
28+
29+
<target name="clean">
30+
<delete dir="dist" />
31+
<delete dir="build" />
32+
</target>
33+
34+
<target name="junit" depends="init">
35+
<junit haltonfailure="false" printsummary="true">
36+
<classpath>
37+
<pathelement location="build/classes"/>
38+
<pathelement location="WebContent/WEB-INF/lib/junit.jar"/>
39+
<pathelement location="WebContent/WEB-INF/lib/org.hamcrest.core_1.3.0.v201303031735.jar"/>
40+
</classpath>
41+
<test name="junit.TestCalculator" haltonfailure="no" todir="test-reports">
42+
<formatter type="plain" />
43+
</test>
44+
</junit>
45+
</target>
46+
47+
</project>

src/example/junit/TestCalculator.java

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package junit;
2+
3+
import static org.junit.Assert.*;
4+
5+
6+
import org.junit.After;
7+
import org.junit.Before;
8+
import org.junit.Test;
9+
10+
import static org.junit.Assert.*;
11+
12+
13+
public class TestCalculator {
14+
15+
private math.Calculator calc;
16+
17+
@Before
18+
public void setUp() throws Exception {
19+
calc = new math.Calculator();
20+
}
21+
22+
@After
23+
public void tearDown() throws Exception {
24+
calc = null;
25+
}
26+
27+
@Test
28+
public void testAdd() {
29+
double result = calc.add(10,20);
30+
assertEquals(30, result, 0);
31+
}
32+
33+
@Test
34+
public void testSubtract() {
35+
double result = calc.subtract(100,50);
36+
assertEquals(50, result, 0);
37+
}
38+
39+
@Test
40+
public void testMultiply() {
41+
double result = calc.multiply(2.5, 100);
42+
assertEquals(250, result, 0);
43+
}
44+
45+
@Test
46+
public void testDivide() {
47+
double result = calc.divide(100, 10);
48+
assertEquals(2, result, 0.001);
49+
}
50+
51+
@Test(expected = ArithmeticException.class)
52+
public void testDivideByZero() {
53+
calc.divide(100.5, 0);
54+
}
55+
56+
}

src/example/math/Calculator.java

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package math;
2+
3+
public class Calculator {
4+
5+
public double add(double a, double b) {
6+
return a + b;
7+
}
8+
9+
public double subtract(double a, double b) {
10+
return a - b;
11+
}
12+
13+
public double multiply(double a, double b) {
14+
return a * b;
15+
}
16+
17+
public double divide(double a, double b) {
18+
if(b == 0) {
19+
throw new ArithmeticException();
20+
}
21+
return a / b;
22+
}
23+
24+
}

0 commit comments

Comments
 (0)