-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1425 from kathrynkodama/1394
Improve feature generation integration tests
- Loading branch information
Showing
24 changed files
with
910 additions
and
40 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
8 changes: 8 additions & 0 deletions
8
liberty-maven-plugin/src/it/generate-features-it/resources/multi-module-project/Dockerfile
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,8 @@ | ||
FROM openliberty/open-liberty:kernel-java8-openj9-ubi | ||
|
||
# Add config | ||
COPY --chown=1001:0 pom/target/liberty/wlp/usr/servers/defaultServer/server.xml /config/ | ||
COPY --chown=1001:0 pom/target/liberty/wlp/usr/servers/defaultServer/configDropins/overrides/liberty-plugin-variable-config.xml /config/configDropins/overrides/ | ||
|
||
# Add application | ||
COPY --chown=1001:0 ear/target/guide-maven-multimodules-ear.ear /config/apps/ |
70 changes: 70 additions & 0 deletions
70
liberty-maven-plugin/src/it/generate-features-it/resources/multi-module-project/ear/pom.xml
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,70 @@ | ||
<?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/xsd/maven-4.0.0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>io.openliberty.guides</groupId> | ||
<artifactId>guide-maven-multimodules-ear</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<packaging>ear</packaging> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
</properties> | ||
|
||
<dependencies> | ||
<!-- web and jar modules as dependencies --> | ||
<dependency> | ||
<groupId>io.openliberty.guides</groupId> | ||
<artifactId>guide-maven-multimodules-jar</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<type>jar</type> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.openliberty.guides</groupId> | ||
<artifactId>guide-maven-multimodules-war</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<type>war</type> | ||
</dependency> | ||
|
||
<!-- For tests --> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter</artifactId> | ||
<version>5.6.2</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<finalName>${project.artifactId}</finalName> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-ear-plugin</artifactId> | ||
<version>3.0.2</version> | ||
<configuration> | ||
<modules> | ||
<jarModule> | ||
<groupId>io.openliberty.guides</groupId> | ||
<artifactId>guide-maven-multimodules-jar</artifactId> | ||
<uri>/guide-maven-multimodules-jar-1.0-SNAPSHOT.jar</uri> | ||
</jarModule> | ||
<webModule> | ||
<groupId>io.openliberty.guides</groupId> | ||
<artifactId>guide-maven-multimodules-war</artifactId> | ||
<uri>/guide-maven-multimodules-war-1.0-SNAPSHOT.war</uri> | ||
<!-- Set custom context root --> | ||
<contextRoot>/converter</contextRoot> | ||
</webModule> | ||
</modules> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
66 changes: 66 additions & 0 deletions
66
...odule-project/ear/src/test/java/it/io/openliberty/guides/multimodules/ConverterAppIT.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,66 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2017, 2019 IBM Corporation and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* IBM Corporation - Initial implementation | ||
*******************************************************************************/ | ||
package it.io.openliberty.guides.multimodules; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.InputStreamReader; | ||
import java.net.HttpURLConnection; | ||
import java.net.URL; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
public class ConverterAppIT { | ||
String port = System.getProperty("default.http.port"); | ||
String war = "converter"; | ||
String urlBase = "http://localhost:" + "9080" + "/" + war + "/"; | ||
|
||
@Test | ||
public void testIndexPage() throws Exception { | ||
String url = this.urlBase; | ||
HttpURLConnection con = testRequestHelper(url, "GET"); | ||
assertEquals(200, con.getResponseCode(), "Incorrect response code from " + url); | ||
assertTrue(testBufferHelper(con).contains("Enter the height in centimeters"), | ||
"Incorrect response from " + url); | ||
} | ||
|
||
@Test | ||
public void testHeightsPage() throws Exception { | ||
String url = this.urlBase + "heights.jsp?heightCm=10"; | ||
HttpURLConnection con = testRequestHelper(url, "POST"); | ||
assertTrue(testBufferHelper(con).contains("3 inches"), | ||
"Incorrect response from " + url); | ||
} | ||
|
||
private HttpURLConnection testRequestHelper(String url, String method) | ||
throws Exception { | ||
URL obj = new URL(url); | ||
HttpURLConnection con = (HttpURLConnection) obj.openConnection(); | ||
// optional default is GET | ||
con.setRequestMethod(method); | ||
return con; | ||
} | ||
|
||
private String testBufferHelper(HttpURLConnection con) throws Exception { | ||
BufferedReader in = new BufferedReader( | ||
new InputStreamReader(con.getInputStream())); | ||
String inputLine; | ||
StringBuffer response = new StringBuffer(); | ||
while ((inputLine = in.readLine()) != null) { | ||
response.append(inputLine); | ||
} | ||
in.close(); | ||
return response.toString(); | ||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
liberty-maven-plugin/src/it/generate-features-it/resources/multi-module-project/jar/pom.xml
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,30 @@ | ||
<?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/xsd/maven-4.0.0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>io.openliberty.guides</groupId> | ||
<artifactId>guide-maven-multimodules-jar</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
</properties> | ||
|
||
<dependencies> | ||
<!-- For tests --> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter</artifactId> | ||
<version>5.6.2</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
42 changes: 42 additions & 0 deletions
42
...ti-module-project/jar/src/main/java/io/openliberty/guides/multimodules/lib/Converter.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,42 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2017 IBM Corporation and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* IBM Corporation - Initial implementation | ||
*******************************************************************************/ | ||
package io.openliberty.guides.multimodules.lib; | ||
|
||
public class Converter { | ||
|
||
public static int getFeet(int cm) { | ||
int feet = (int) (cm / 30.48); | ||
return feet; | ||
} | ||
|
||
public static int getInches(int cm) { | ||
double feet = cm / 30.48; | ||
int inches = (int) (cm / 2.54) - ((int) feet * 12); | ||
return inches; | ||
} | ||
|
||
public static int sum(int a, int b) { | ||
return a + b; | ||
} | ||
|
||
public static int diff(int a, int b) { | ||
return a - b; | ||
} | ||
|
||
public static int product(int a, int b) { | ||
return a * b; | ||
} | ||
|
||
public static int quotient(int a, int b) { | ||
return a / b; | ||
} | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
...e-project/jar/src/test/java/io/openliberty/guides/multimodules/lib/ConverterUnitTest.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,15 @@ | ||
package io.openliberty.guides.multimodules.lib; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class ConverterUnitTest { | ||
|
||
@Test | ||
public void testHeightFeet() { | ||
int feet = Converter.getFeet(61); | ||
assertEquals(2, feet); | ||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
liberty-maven-plugin/src/it/generate-features-it/resources/multi-module-project/pom.xml
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,20 @@ | ||
<?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/xsd/maven-4.0.0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>io.openliberty.guides</groupId> | ||
<artifactId>guide-maven-multimodules</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<packaging>pom</packaging> | ||
|
||
<modules> | ||
<module>jar</module> | ||
<module>war</module> | ||
<module>ear</module> | ||
<module>pom</module> | ||
</modules> | ||
</project> |
104 changes: 104 additions & 0 deletions
104
liberty-maven-plugin/src/it/generate-features-it/resources/multi-module-project/pom/pom.xml
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,104 @@ | ||
<?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/xsd/maven-4.0.0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>io.openliberty.guides</groupId> | ||
<artifactId>guide-maven-multimodules-pom</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<packaging>liberty-assembly</packaging> | ||
|
||
<properties> | ||
<!-- Liberty configuration --> | ||
<liberty.var.default.http.port>9080</liberty.var.default.http.port> | ||
<liberty.var.default.https.port>9443</liberty.var.default.https.port> | ||
</properties> | ||
|
||
<repositories> | ||
<!-- Sonatype repository used to get the latest binary scanner jar --> | ||
<repository> | ||
<id>oss-sonatype</id> | ||
<name>oss-sonatype</name> | ||
<url>https://oss.sonatype.org/content/repositories/snapshots/</url> | ||
<snapshots> | ||
<enabled>true</enabled> | ||
</snapshots> | ||
<releases> | ||
<enabled>false</enabled> | ||
</releases> | ||
</repository> | ||
</repositories> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.openliberty.guides</groupId> | ||
<artifactId>guide-maven-multimodules-ear</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<type>ear</type> | ||
</dependency> | ||
|
||
<!-- For tests --> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter</artifactId> | ||
<version>5.6.2</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<finalName>${project.artifactId}</finalName> | ||
<plugins> | ||
|
||
<!-- Enable liberty-maven plugin --> | ||
<plugin> | ||
<groupId>io.openliberty.tools</groupId> | ||
<artifactId>liberty-maven-plugin</artifactId> | ||
<version>SUB_VERSION</version> | ||
<extensions>true</extensions> | ||
<configuration> | ||
<looseApplication>true</looseApplication> | ||
<deployPackages>all</deployPackages> | ||
</configuration> | ||
</plugin> | ||
|
||
<!-- Since the package type is liberty-assembly, | ||
need to run testCompile to compile the tests --> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.8.1</version> | ||
<executions> | ||
<execution> | ||
<phase>test-compile</phase> | ||
<goals> | ||
<goal>testCompile</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
|
||
<!-- Plugin to run integration tests --> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-failsafe-plugin</artifactId> | ||
<version>2.22.2</version> | ||
<configuration> | ||
<systemPropertyVariables> | ||
<default.http.port> | ||
${liberty.var.default.http.port} | ||
</default.http.port> | ||
<default.https.port> | ||
${liberty.var.default.https.port} | ||
</default.https.port> | ||
<cf.context.root>/converter</cf.context.root> | ||
</systemPropertyVariables> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
15 changes: 15 additions & 0 deletions
15
...enerate-features-it/resources/multi-module-project/pom/src/main/liberty/config/server.xml
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,15 @@ | ||
<server description="Sample Liberty server"> | ||
|
||
<!--replaceable--> | ||
|
||
<variable name="default.http.port" defaultValue="9080" /> | ||
<variable name="default.https.port" defaultValue="9443" /> | ||
|
||
<httpEndpoint host="*" httpPort="${default.http.port}" | ||
httpsPort="${default.https.port}" id="defaultHttpEndpoint" /> | ||
|
||
<enterpriseApplication id="guide-maven-multimodules-ear" | ||
location="guide-maven-multimodules-ear.ear" | ||
name="guide-maven-multimodules-ear" /> | ||
|
||
</server> |
Oops, something went wrong.