Skip to content
This repository was archived by the owner on Jun 14, 2024. It is now read-only.

Commit fde04b7

Browse files
author
Chandra Pratap
authored
Devops starter for github: containers app for Java Spring (#274)
* initial commit * deleted readme file * placed license * modified twitter url
1 parent 529c96c commit fde04b7

39 files changed

+1018
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>Application</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.m2e.core.maven2Builder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.m2e.core.maven2Nature</nature>
16+
</natures>
17+
</projectDescription>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM tomcat:8
2+
RUN rm -rf /usr/local/tomcat/webapps/ROOT
3+
COPY sampleWebApp/target/*.war /usr/local/tomcat/webapps/ROOT.war
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
5+
<modelVersion>4.0.0</modelVersion>
6+
<groupId>com.microsoft</groupId>
7+
<artifactId>ROOT</artifactId>
8+
<version>1.0</version>
9+
<packaging>pom</packaging>
10+
<name>Sample Spring App With Tests</name>
11+
12+
13+
14+
<modules> <!-- child modules to be executed as part of this build -->
15+
<module>sampleWebApp</module>
16+
<module>sampleWebApp.FunctionalTests</module>
17+
</modules>
18+
19+
</project>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" output="target/classes" path="src/main/java">
4+
<attributes>
5+
<attribute name="optional" value="true"/>
6+
<attribute name="maven.pomderived" value="true"/>
7+
</attributes>
8+
</classpathentry>
9+
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
10+
<attributes>
11+
<attribute name="optional" value="true"/>
12+
<attribute name="maven.pomderived" value="true"/>
13+
<attribute name="test" value="true"/>
14+
</attributes>
15+
</classpathentry>
16+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
17+
<attributes>
18+
<attribute name="maven.pomderived" value="true"/>
19+
</attributes>
20+
</classpathentry>
21+
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
22+
<attributes>
23+
<attribute name="maven.pomderived" value="true"/>
24+
</attributes>
25+
</classpathentry>
26+
<classpathentry kind="output" path="target/classes"/>
27+
</classpath>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/target/
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>test</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.m2e.core.maven2Builder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
</buildSpec>
19+
<natures>
20+
<nature>org.eclipse.jdt.core.javanature</nature>
21+
<nature>org.eclipse.m2e.core.maven2Nature</nature>
22+
</natures>
23+
</projectDescription>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
3+
org.eclipse.jdt.core.compiler.compliance=1.5
4+
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
5+
org.eclipse.jdt.core.compiler.release=disabled
6+
org.eclipse.jdt.core.compiler.source=1.5
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<parent>
5+
<groupId>com.microsoft</groupId>
6+
<artifactId>ROOT</artifactId>
7+
<relativePath>..</relativePath>
8+
<version>1.0</version>
9+
</parent>
10+
<groupId>com.microsoft.test</groupId>
11+
<artifactId>sampleWebApp</artifactId>
12+
<packaging>jar</packaging>
13+
<name>Sample Spring App test</name>
14+
15+
<dependencies>
16+
<dependency>
17+
<groupId>junit</groupId>
18+
<artifactId>junit</artifactId>
19+
<version>4.10</version>
20+
</dependency>
21+
<dependency>
22+
<groupId>org.seleniumhq.selenium</groupId>
23+
<artifactId>selenium-java</artifactId>
24+
<version>3.14.0</version>
25+
</dependency>
26+
<dependency>
27+
<groupId>org.junit.vintage</groupId>
28+
<artifactId>junit-vintage-engine</artifactId>
29+
<version>5.1.0</version>
30+
</dependency>
31+
<dependency>
32+
<groupId>org.junit.platform</groupId>
33+
<artifactId>junit-platform-launcher</artifactId>
34+
<version>1.1.0</version>
35+
</dependency>
36+
<dependency>
37+
<groupId>org.junit.platform</groupId>
38+
<artifactId>junit-platform-runner</artifactId>
39+
<version>1.1.0</version>
40+
</dependency>
41+
<dependency>
42+
<groupId>org.junit.platform</groupId>
43+
<artifactId>junit-platform-surefire-provider</artifactId>
44+
<version>1.2.0</version>
45+
</dependency>
46+
<dependency>
47+
<groupId>org.junit.platform</groupId>
48+
<artifactId>junit-platform-console-standalone</artifactId>
49+
<version>1.1.0</version>
50+
</dependency>
51+
</dependencies>
52+
53+
<build>
54+
<finalName>SampleWebAppFunctionalTests</finalName>
55+
<plugins>
56+
<plugin>
57+
<artifactId>maven-assembly-plugin</artifactId>
58+
<executions>
59+
<execution>
60+
<phase>package</phase>
61+
<goals>
62+
<goal>single</goal>
63+
</goals>
64+
</execution>
65+
</executions>
66+
<configuration>
67+
<descriptorRefs>
68+
<descriptorRef>jar-with-dependencies</descriptorRef>
69+
</descriptorRefs>
70+
</configuration>
71+
</plugin>
72+
</plugins>
73+
</build>
74+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
package functional_tests;
2+
3+
import org.junit.*;
4+
5+
import org.openqa.selenium.NoAlertPresentException;
6+
import org.openqa.selenium.WebDriver;
7+
import org.openqa.selenium.chrome.ChromeDriver;
8+
import org.openqa.selenium.chrome.ChromeOptions;
9+
10+
import static org.junit.Assert.assertEquals;
11+
12+
import java.nio.file.Paths;
13+
import java.util.concurrent.TimeUnit;
14+
import java.util.Date;
15+
16+
public class SampleFunctionalTest {
17+
18+
private static WebDriver driver;
19+
20+
@Before
21+
public void startBrowser() {
22+
String path = Paths.get(System.getenv("ChromeWebDriver"), "chromedriver.exe").toString();
23+
System.setProperty("webdriver.chrome.driver", path);
24+
ChromeOptions options = new ChromeOptions();
25+
options.addArguments("--no-sandbox");
26+
driver = new ChromeDriver(options);
27+
driver.manage().timeouts().pageLoadTimeout(360, TimeUnit.SECONDS);
28+
}
29+
30+
@Test
31+
public void testAssertTitleWithSelenium() throws InterruptedException, AssertionError {
32+
if (isAlertPresent()) {
33+
System.out.println(isAlertPresent());
34+
driver.switchTo().alert().accept();
35+
}
36+
37+
long startTimestamp = (new Date()).getTime();
38+
long endTimestamp = startTimestamp + 60*10*1000;
39+
40+
while(true)
41+
{
42+
try
43+
{
44+
driver.get(System.getProperty("webAppUrl"));
45+
assertEquals("Java Spring Application", driver.getTitle());
46+
break;
47+
}
48+
catch(AssertionError e)
49+
{
50+
startTimestamp = (new Date()).getTime();
51+
if(startTimestamp > endTimestamp)
52+
{
53+
System.out.println("##vso[task.logissue type=error;]Test testAssertTitleWithSelenium failed with error: " + e.toString());
54+
throw e;
55+
}
56+
Thread.sleep(5000);
57+
}
58+
}
59+
}
60+
61+
protected boolean isAlertPresent() {
62+
try {
63+
driver.switchTo().alert();
64+
return true;
65+
} catch (NoAlertPresentException e) {
66+
return false;
67+
}
68+
}
69+
70+
@After
71+
public void tearDown() {
72+
try {
73+
driver.quit();
74+
} catch(Exception e) {
75+
76+
}
77+
}
78+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" output="target/classes" path="src/main/java">
4+
<attributes>
5+
<attribute name="optional" value="true"/>
6+
<attribute name="maven.pomderived" value="true"/>
7+
</attributes>
8+
</classpathentry>
9+
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
10+
<attributes>
11+
<attribute name="maven.pomderived" value="true"/>
12+
</attributes>
13+
</classpathentry>
14+
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
15+
<attributes>
16+
<attribute name="optional" value="true"/>
17+
<attribute name="maven.pomderived" value="true"/>
18+
<attribute name="test" value="true"/>
19+
</attributes>
20+
</classpathentry>
21+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
22+
<attributes>
23+
<attribute name="maven.pomderived" value="true"/>
24+
</attributes>
25+
</classpathentry>
26+
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
27+
<attributes>
28+
<attribute name="maven.pomderived" value="true"/>
29+
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
30+
</attributes>
31+
</classpathentry>
32+
<classpathentry kind="output" path="target/classes"/>
33+
</classpath>

0 commit comments

Comments
 (0)