Skip to content

Commit

Permalink
Merge pull request #209 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 266ea92 + 60e89f9 commit 64d967e
Show file tree
Hide file tree
Showing 26 changed files with 418 additions and 415 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ jobs:

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
Expand Down
418 changes: 246 additions & 172 deletions LICENSE

Large diffs are not rendered by default.

8 changes: 3 additions & 5 deletions README.adoc
Original file line number Diff line number Diff line change
@@ -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 @@ -205,17 +205,15 @@ If the tests pass, you see a similar output to the following example:
Running it.io.openliberty.guides.system.SystemEndpointIT
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.99 sec - in it.io.openliberty.guides.system.SystemEndpointIT
Running it.io.openliberty.guides.inventory.InventoryEndpointIT
[WARNING ] Interceptor for {http://badhostname:9080/system/properties}WebClient has thrown exception, unwinding now
Could not send Message.
[err] Runtime exception: java.net.UnknownHostException: UnknownHostException invoking http://badhostname:9080/system/properties: badhostname
[err] Runtime exception: RESTEASY004655: Unable to invoke request: java.net.UnknownHostException: badhostname: nodename nor servname provided, or not known
Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.325 sec - in it.io.openliberty.guides.inventory.InventoryEndpointIT
Results :
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0
----

The warning and error messages are expected and result from a request to a bad or an unknown hostname. This request is made in the `testUnknownHost()` test from the `InventoryEndpointIT` integration test.
The error messages are expected and result from a request to a bad or an unknown hostname. This request is made in the `testUnknownHost()` test from the `InventoryEndpointIT` integration test.

To see whether the tests detect a failure, change the [hotspot=endpoint file=0]`endpoint` for the `inventory` service in the [hotspot file=0]`src/main/java/io/openliberty/guides/inventory/InventoryResource.java` file to something else. Then, run the tests again to see that a test failure occurs.

Expand Down
18 changes: 9 additions & 9 deletions finish/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<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>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<!-- Liberty configuration -->
<liberty.var.system.http.port>9080</liberty.var.system.http.port>
<liberty.var.default.http.port>9080</liberty.var.default.http.port>
Expand All @@ -25,33 +25,33 @@
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-api</artifactId>
<version>9.1.0</version>
<version>10.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.microprofile</groupId>
<artifactId>microprofile</artifactId>
<version>5.0</version>
<version>6.0</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
<!-- For tests -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.8.2</version>
<version>5.9.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client</artifactId>
<version>6.0.0.Final</version>
<version>6.2.3.Final</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-json-binding-provider</artifactId>
<version>6.0.0.Final</version>
<version>6.2.3.Final</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -74,7 +74,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<version>3.0.0</version>
</plugin>
<!-- Enable liberty-maven plugin -->
<plugin>
Expand All @@ -86,7 +86,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.2</version>
<version>3.0.0</version>
<configuration>
<systemPropertyVariables>
<http.port>${liberty.var.default.http.port}</http.port>
Expand Down
Original file line number Diff line number Diff line change
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.inventory;
Expand Down
Original file line number Diff line number Diff line change
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.inventory;
Expand Down
Original file line number Diff line number Diff line change
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.inventory;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
// tag::copyright[]
/*******************************************************************************
* 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 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.inventory.client;
Expand All @@ -28,75 +27,49 @@
@ApplicationScoped
public class SystemClient {

// Constants for building URI to the system service.
private final String SYSTEM_PROPERTIES = "/system/properties";
private final String PROTOCOL = "http";
// Constants for building URI to the system service.
private final String SYSTEM_PROPERTIES = "/system/properties";
private final String PROTOCOL = "http";

@Inject
@ConfigProperty(name = "system.http.port")
String SYS_HTTP_PORT;
@Inject
@ConfigProperty(name = "system.http.port")
String SYS_HTTP_PORT;

// Wrapper function that gets properties
public Properties getProperties(String hostname) {
String url = buildUrl(
PROTOCOL, hostname, Integer.valueOf(SYS_HTTP_PORT), SYSTEM_PROPERTIES);
Builder clientBuilder = buildClientBuilder(url);
return getPropertiesHelper(clientBuilder);
}

// tag::doc[]
/**
* Builds the URI string to the system service for a particular host.
* @param protocol
* - http or https.
* @param host
* - name of host.
* @param port
* - port number.
* @param path
* - Note that the path needs to start with a slash!!!
* @return String representation of the URI to the system properties service.
*/
// end::doc[]
protected String buildUrl(String protocol, String host, int port, String path) {
try {
URI uri = new URI(protocol, null, host, port, path, null, null);
return uri.toString();
} catch (Exception e) {
System.err.println("Exception thrown while building the URL: " + e.getMessage());
return null;
// Wrapper function that gets properties
public Properties getProperties(String hostname) {
Properties properties = null;
Client client = ClientBuilder.newClient();
try {
Builder builder = getBuilder(hostname, client);
properties = getPropertiesHelper(builder);
} catch (Exception e) {
System.err.println(
"Exception thrown while getting properties: " + e.getMessage());
} finally {
client.close();
}
return properties;
}
}

// Method that creates the client builder
protected Builder buildClientBuilder(String urlString) {
try {
Client client = ClientBuilder.newClient();
Builder builder = client.target(urlString).request();
return builder.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
} catch (Exception e) {
System.err.println(
"Exception thrown while building the client: " + e.getMessage());
return null;
// Method that creates the client builder
private Builder getBuilder(String hostname, Client client) throws Exception {
URI uri = new URI(
PROTOCOL, null, hostname, Integer.valueOf(SYS_HTTP_PORT),
SYSTEM_PROPERTIES, null, null);
String urlString = uri.toString();
Builder builder = client.target(urlString).request();
builder.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
return builder;
}
}

// Helper method that processes the request
protected Properties getPropertiesHelper(Builder builder) {
try {
Response response = builder.get();
if (response.getStatus() == Status.OK.getStatusCode()) {
return response.readEntity(Properties.class);
} else {
System.err.println("Response Status is not OK.");
}
} catch (RuntimeException e) {
System.err.println("Runtime exception: " + e.getMessage());
} catch (Exception e) {
System.err.println(
"Exception thrown while invoking the request: " + e.getMessage());
// Helper method that processes the request
private Properties getPropertiesHelper(Builder builder) throws Exception {
Response response = builder.get();
if (response.getStatus() == Status.OK.getStatusCode()) {
return response.readEntity(Properties.class);
} else {
System.err.println("Response Status is not OK.");
return null;
}
}
return null;
}

}
Original file line number Diff line number Diff line change
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.inventory.model;
Expand Down
Original file line number Diff line number Diff line change
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.inventory.model;
Expand Down
Original file line number Diff line number Diff line change
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.system;
Expand Down
Original file line number Diff line number Diff line change
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.system;
Expand Down
8 changes: 4 additions & 4 deletions finish/src/main/liberty/config/server.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<server description="Sample Liberty server">

<featureManager>
<feature>restfulWS-3.0</feature>
<feature>jsonp-2.0</feature>
<feature>jsonb-2.0</feature>
<feature>cdi-3.0</feature>
<feature>restfulWS-3.1</feature>
<feature>jsonp-2.1</feature>
<feature>jsonb-3.0</feature>
<feature>cdi-4.0</feature>
<feature>mpConfig-3.0</feature>
</featureManager>

Expand Down
12 changes: 6 additions & 6 deletions finish/src/main/webapp/index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
Copyright (c) 2016, 2022 IBM Corp.
Copyright (c) 2016, 2023 IBM Corp.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -30,12 +30,12 @@ <h2>Eclipse MicroProfile</h2>
<p>
For more information about the features used in this application, see the Open Liberty documentation:
<ul>
<li><a href="https://openliberty.io/docs/ref/feature/#microProfile-5.0.html" target="_blank" rel="noopener noreferrer">MicroProfile 5.0</a></li>
<li><a href="https://openliberty.io/docs/ref/feature/#microProfile-6.0.html" target="_blank" rel="noopener noreferrer">MicroProfile 6.0</a></li>
<li><a href="https://openliberty.io/docs/ref/feature/#mpConfig-3.0.html" target="_blank" rel="noopener noreferrer">MicroProfile Config 3.0</a></li>
<li><a href="https://openliberty.io/docs/ref/feature/#cdi-3.0.html" target="_blank" rel="noopener noreferrer">Contexts and Dependency Injection 3.0</a></li>
<li><a href="https://openliberty.io/docs/ref/feature/#restfulWS-3.0.html" target="_blank" rel="noopener noreferrer">Java RESTful Services 3.0</a></li>
<li><a href="https://openliberty.io/docs/ref/feature/#jsonp-2.0.html" target="_blank" rel="noopener noreferrer">JavaScript Object Notation Processing 2.0</a></li>
<li><a href="https://openliberty.io/docs/ref/feature/#jsonb-2.0.html" target="_blank" rel="noopener noreferrer">JavaScript Object Notation Binding 2.0</a></li>
<li><a href="https://openliberty.io/docs/ref/feature/#cdi-4.0.html" target="_blank" rel="noopener noreferrer">Jakarta Contexts and Dependency Injection 4.0</a></li>
<li><a href="https://openliberty.io/docs/ref/feature/#restfulWS-3.1.html" target="_blank" rel="noopener noreferrer">Jakarta RESTful Web Services 3.1</a></li>
<li><a href="https://openliberty.io/docs/ref/feature/#jsonp-2.1.html" target="_blank" rel="noopener noreferrer">Jakarta JSON Processing 2.1</a></li>
<li><a href="https://openliberty.io/docs/ref/feature/#jsonb-3.0.html" target="_blank" rel="noopener noreferrer">Jakarta JSON Binding 3.0</a></li>
</ul>
</p>
</div>
Expand Down
Loading

0 comments on commit 64d967e

Please sign in to comment.