Skip to content

Commit

Permalink
Merge pull request #159 from OpenLiberty/staging
Browse files Browse the repository at this point in the history
Merge staging to prod: Update to MP6 and JEE10
  • Loading branch information
gkwan-ibm committed May 16, 2023
2 parents 045412a + 6731b79 commit f85e65f
Show file tree
Hide file tree
Showing 12 changed files with 304 additions and 219 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Expand Up @@ -45,10 +45,10 @@ jobs:
working-directory: finish
steps:
- uses: actions/checkout@v2
- name: Set up JDK 8
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 8
java-version: 11
- run: unset _JAVA_OPTIONS
- name: Run tests
run: ../scripts/testApp.sh
Expand Down
418 changes: 246 additions & 172 deletions LICENSE

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions README.adoc
@@ -1,4 +1,4 @@
// Copyright (c) 2017, 2022 IBM Corporation and others.
// Copyright (c) 2017, 2023 IBM Corporation and others.
// Licensed under Creative Commons Attribution-NoDerivatives
// 4.0 International (CC BY-ND 4.0)
// https://creativecommons.org/licenses/by-nd/4.0/
Expand Down Expand Up @@ -260,7 +260,7 @@ In the [hotspot=link file=0]`try block` of the test method, an HTTP `GET` reques

In the [hotspot=import file=0]`import` statements of this test class, you'll notice that the test has some new dependencies. Before the test can be compiled by Maven, you need to update the [hotspot file=1]`pom.xml` to include these dependencies.

The Apache [hotspot=commons-httpclient file=1]`commons-httpclient` and [hotspot=junit file=1]`junit-jupiter-engine` dependencies are needed to compile and run the integration test [hotspot=EndpointIT file=0]`EndpointIT` class. The scope for each of the dependencies is set to [hotspot=test1 hotspot=test2 file=1]`test` because the libraries are needed only during the Maven build and do not needed to be packaged with the application.
The Apache [hotspot=commons-httpclient file=1]`httpclient` and [hotspot=junit file=1]`junit-jupiter-engine` dependencies are needed to compile and run the integration test [hotspot=EndpointIT file=0]`EndpointIT` class. The scope for each of the dependencies is set to [hotspot=test1 hotspot=test2 file=1]`test` because the libraries are needed only during the Maven build and do not needed to be packaged with the application.

Now, the created WAR file contains the web application, and development mode can run any integration test classes that it finds. Integration test classes are classes with names that end in `IT`.

Expand Down
10 changes: 5 additions & 5 deletions finish/pom.xml
Expand Up @@ -22,8 +22,8 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<!-- end::encoding[] -->
<!-- tag::java-version[] -->
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<!-- end::java-version[] -->
<!-- Liberty configuration -->
<!-- tag::default-http-port[] -->
Expand Down Expand Up @@ -53,9 +53,9 @@
<!-- For testing -->
<!-- tag::commons-httpclient[] -->
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.14</version>
<!-- tag::test1[] -->
<scope>test</scope>
<!-- end::test1[] -->
Expand Down
Expand Up @@ -2,12 +2,11 @@
/*******************************************************************************
* Copyright (c) 2017, 2022 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
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
* http://www.eclipse.org/legal/epl-2.0/
*
* Contributors:
* IBM Corporation - Initial implementation
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
// end::copyright[]
package io.openliberty.guides.hello;
Expand Down
2 changes: 1 addition & 1 deletion finish/src/main/liberty/config/server.xml
@@ -1,6 +1,6 @@
<server description="Sample Servlet server">
<featureManager>
<feature>servlet-5.0</feature>
<feature>servlet-6.0</feature>
</featureManager>

<variable name="default.http.port" defaultValue="9080"/>
Expand Down
6 changes: 3 additions & 3 deletions finish/src/main/webapp/index.html
@@ -1,10 +1,10 @@
<!-- tag::comment[] -->
<!--
Copyright (c) 2017, 2022 IBM Corporation and others.
Copyright (c) 2017, 2023 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
are made available under the terms of the Eclipse Public License v2.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v10.html
http://www.eclipse.org/legal/epl-2.0/
Contributors:
IBM Corporation - initial API and implementation
Expand Down
55 changes: 34 additions & 21 deletions finish/src/test/java/io/openliberty/guides/hello/it/EndpointIT.java
@@ -1,28 +1,31 @@
// tag::copyright[]
/*******************************************************************************
* Copyright (c) 2017, 2019 IBM Corporation and others.
* Copyright (c) 2017, 2023 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
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
* http://www.eclipse.org/legal/epl-2.0/
*
* Contributors:
* IBM Corporation - Initial implementation
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
// end::copyright[]
package io.openliberty.guides.hello.it;

// tag::import[]
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

//tag::import[]
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.methods.GetMethod;
// end::import[]
import java.io.BufferedReader;
import java.io.InputStreamReader;

import org.apache.http.HttpStatus;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
//end::import[]

// tag::EndpointIT[]
public class EndpointIT {
Expand All @@ -41,21 +44,31 @@ public static void init() {
@Test
// end::Test[]
public void testServlet() throws Exception {
HttpClient client = new HttpClient();

GetMethod method = new GetMethod(siteURL);
CloseableHttpClient client = HttpClientBuilder.create().build();
HttpGet httpGet = new HttpGet(siteURL);
CloseableHttpResponse response = null;

// tag::link[]
try {
int statusCode = client.executeMethod(method);
response = client.execute(httpGet);

int statusCode = response.getStatusLine().getStatusCode();
assertEquals(HttpStatus.SC_OK, statusCode, "HTTP GET failed");

String response = method.getResponseBodyAsString(1000);

assertTrue(response.contains("Hello! How are you today?"),
"Unexpected response body");
BufferedReader reader = new BufferedReader(new InputStreamReader(
response.getEntity().getContent()));
String line;
StringBuffer buffer = new StringBuffer();
while ((line = reader.readLine()) != null) {
buffer.append(line);
}
reader.close();
assertTrue(buffer.toString().contains("Hello! How are you today?"),
"Unexpected response body: " + buffer.toString());
} finally {
method.releaseConnection();
response.close();
httpGet.releaseConnection();
}
// end::link[]
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/dailyBuild.sh
Expand Up @@ -8,7 +8,7 @@ do
esac
done

sed -i "\#<artifactId>liberty-maven-plugin</artifactId>#,\#<configuration>#c<artifactId>liberty-maven-plugin</artifactId><version>3.5.1</version><configuration><install><runtimeUrl>https://public.dhe.ibm.com/ibmdl/export/pub/software/openliberty/runtime/nightly/$DATE/$DRIVER</runtimeUrl></install>" pom.xml
sed -i "\#<artifactId>liberty-maven-plugin</artifactId>#,\#<configuration>#c<artifactId>liberty-maven-plugin</artifactId><version>3.7.1</version><configuration><install><runtimeUrl>https://public.dhe.ibm.com/ibmdl/export/pub/software/openliberty/runtime/nightly/$DATE/$DRIVER</runtimeUrl></install>" pom.xml
cat pom.xml

../scripts/testApp.sh
Expand Up @@ -2,12 +2,11 @@
/*******************************************************************************
* Copyright (c) 2017, 2022 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
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
* http://www.eclipse.org/legal/epl-2.0/
*
* Contributors:
* IBM Corporation - Initial implementation
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
// end::copyright[]
package io.openliberty.guides.hello;
Expand Down
2 changes: 1 addition & 1 deletion start/src/main/liberty/config/server.xml
@@ -1,6 +1,6 @@
<server description="Sample Servlet server">
<featureManager>
<feature>servlet-5.0</feature>
<feature>servlet-6.0</feature>
</featureManager>

<variable name="default.http.port" defaultValue="9080"/>
Expand Down
6 changes: 3 additions & 3 deletions start/src/main/webapp/index.html
@@ -1,10 +1,10 @@
<!-- tag::comment[] -->
<!--
Copyright (c) 2017, 2022 IBM Corporation and others.
Copyright (c) 2017, 2023 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
are made available under the terms of the Eclipse Public License v2.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-v10.html
http://www.eclipse.org/legal/epl-2.0/
Contributors:
IBM Corporation - initial API and implementation
Expand Down

0 comments on commit f85e65f

Please sign in to comment.