Skip to content

Commit 64d967e

Browse files
authored
Merge pull request #209 from OpenLiberty/staging
Merge staging to prod: Update to MP6 and JEE10
2 parents 266ea92 + 60e89f9 commit 64d967e

26 files changed

Lines changed: 418 additions & 415 deletions

File tree

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ jobs:
4646

4747
steps:
4848
- uses: actions/checkout@v2
49-
- name: Set up JDK 8
49+
- name: Set up JDK 11
5050
uses: actions/setup-java@v1
5151
with:
52-
java-version: 8
52+
java-version: 11
5353
- run: unset _JAVA_OPTIONS
5454

5555
- name: Run tests

LICENSE

Lines changed: 246 additions & 172 deletions
Large diffs are not rendered by default.

README.adoc

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2017, 2022 IBM Corporation and others.
1+
// Copyright (c) 2017, 2023 IBM Corporation and others.
22
// Licensed under Creative Commons Attribution-NoDerivatives
33
// 4.0 International (CC BY-ND 4.0)
44
// https://creativecommons.org/licenses/by-nd/4.0/
@@ -205,17 +205,15 @@ If the tests pass, you see a similar output to the following example:
205205
Running it.io.openliberty.guides.system.SystemEndpointIT
206206
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.99 sec - in it.io.openliberty.guides.system.SystemEndpointIT
207207
Running it.io.openliberty.guides.inventory.InventoryEndpointIT
208-
[WARNING ] Interceptor for {http://badhostname:9080/system/properties}WebClient has thrown exception, unwinding now
209-
Could not send Message.
210-
[err] Runtime exception: java.net.UnknownHostException: UnknownHostException invoking http://badhostname:9080/system/properties: badhostname
208+
[err] Runtime exception: RESTEASY004655: Unable to invoke request: java.net.UnknownHostException: badhostname: nodename nor servname provided, or not known
211209
Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.325 sec - in it.io.openliberty.guides.inventory.InventoryEndpointIT
212210
213211
Results :
214212
215213
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0
216214
----
217215

218-
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.
216+
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.
219217

220218
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.
221219

finish/pom.xml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
<properties>
1212
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1313
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
14-
<maven.compiler.source>1.8</maven.compiler.source>
15-
<maven.compiler.target>1.8</maven.compiler.target>
14+
<maven.compiler.source>11</maven.compiler.source>
15+
<maven.compiler.target>11</maven.compiler.target>
1616
<!-- Liberty configuration -->
1717
<liberty.var.system.http.port>9080</liberty.var.system.http.port>
1818
<liberty.var.default.http.port>9080</liberty.var.default.http.port>
@@ -25,33 +25,33 @@
2525
<dependency>
2626
<groupId>jakarta.platform</groupId>
2727
<artifactId>jakarta.jakartaee-api</artifactId>
28-
<version>9.1.0</version>
28+
<version>10.0.0</version>
2929
<scope>provided</scope>
3030
</dependency>
3131
<dependency>
3232
<groupId>org.eclipse.microprofile</groupId>
3333
<artifactId>microprofile</artifactId>
34-
<version>5.0</version>
34+
<version>6.0</version>
3535
<type>pom</type>
3636
<scope>provided</scope>
3737
</dependency>
3838
<!-- For tests -->
3939
<dependency>
4040
<groupId>org.junit.jupiter</groupId>
4141
<artifactId>junit-jupiter</artifactId>
42-
<version>5.8.2</version>
42+
<version>5.9.2</version>
4343
<scope>test</scope>
4444
</dependency>
4545
<dependency>
4646
<groupId>org.jboss.resteasy</groupId>
4747
<artifactId>resteasy-client</artifactId>
48-
<version>6.0.0.Final</version>
48+
<version>6.2.3.Final</version>
4949
<scope>test</scope>
5050
</dependency>
5151
<dependency>
5252
<groupId>org.jboss.resteasy</groupId>
5353
<artifactId>resteasy-json-binding-provider</artifactId>
54-
<version>6.0.0.Final</version>
54+
<version>6.2.3.Final</version>
5555
<scope>test</scope>
5656
</dependency>
5757
<dependency>
@@ -74,7 +74,7 @@
7474
<plugin>
7575
<groupId>org.apache.maven.plugins</groupId>
7676
<artifactId>maven-surefire-plugin</artifactId>
77-
<version>2.22.2</version>
77+
<version>3.0.0</version>
7878
</plugin>
7979
<!-- Enable liberty-maven plugin -->
8080
<plugin>
@@ -86,7 +86,7 @@
8686
<plugin>
8787
<groupId>org.apache.maven.plugins</groupId>
8888
<artifactId>maven-failsafe-plugin</artifactId>
89-
<version>2.22.2</version>
89+
<version>3.0.0</version>
9090
<configuration>
9191
<systemPropertyVariables>
9292
<http.port>${liberty.var.default.http.port}</http.port>

finish/src/main/java/io/openliberty/guides/inventory/InventoryApplication.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
/*******************************************************************************
33
* Copyright (c) 2017, 2022 IBM Corporation and others.
44
* All rights reserved. This program and the accompanying materials
5-
* are made available under the terms of the Eclipse Public License v1.0
5+
* are made available under the terms of the Eclipse Public License 2.0
66
* which accompanies this distribution, and is available at
7-
* http://www.eclipse.org/legal/epl-v10.html
7+
* http://www.eclipse.org/legal/epl-2.0/
88
*
9-
* Contributors:
10-
* IBM Corporation - Initial implementation
9+
* SPDX-License-Identifier: EPL-2.0
1110
*******************************************************************************/
1211
// end::copyright[]
1312
package io.openliberty.guides.inventory;

finish/src/main/java/io/openliberty/guides/inventory/InventoryManager.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
/*******************************************************************************
33
* Copyright (c) 2017, 2022 IBM Corporation and others.
44
* All rights reserved. This program and the accompanying materials
5-
* are made available under the terms of the Eclipse Public License v1.0
5+
* are made available under the terms of the Eclipse Public License 2.0
66
* which accompanies this distribution, and is available at
7-
* http://www.eclipse.org/legal/epl-v10.html
7+
* http://www.eclipse.org/legal/epl-2.0/
88
*
9-
* Contributors:
10-
* IBM Corporation - Initial implementation
9+
* SPDX-License-Identifier: EPL-2.0
1110
*******************************************************************************/
1211
// end::copyright[]
1312
package io.openliberty.guides.inventory;

finish/src/main/java/io/openliberty/guides/inventory/InventoryResource.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
/*******************************************************************************
33
* Copyright (c) 2017, 2022 IBM Corporation and others.
44
* All rights reserved. This program and the accompanying materials
5-
* are made available under the terms of the Eclipse Public License v1.0
5+
* are made available under the terms of the Eclipse Public License 2.0
66
* which accompanies this distribution, and is available at
7-
* http://www.eclipse.org/legal/epl-v10.html
7+
* http://www.eclipse.org/legal/epl-2.0/
88
*
9-
* Contributors:
10-
* IBM Corporation - Initial implementation
9+
* SPDX-License-Identifier: EPL-2.0
1110
*******************************************************************************/
1211
// end::copyright[]
1312
package io.openliberty.guides.inventory;
Lines changed: 42 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
// tag::copyright[]
22
/*******************************************************************************
3-
* Copyright (c) 2017, 2022 IBM Corporation and others.
3+
* Copyright (c) 2017, 2023 IBM Corporation and others.
44
* All rights reserved. This program and the accompanying materials
5-
* are made available under the terms of the Eclipse Public License v1.0
5+
* are made available under the terms of the Eclipse Public License 2.0
66
* which accompanies this distribution, and is available at
7-
* http://www.eclipse.org/legal/epl-v10.html
7+
* http://www.eclipse.org/legal/epl-2.0/
88
*
9-
* Contributors:
10-
* IBM Corporation - Initial implementation
9+
* SPDX-License-Identifier: EPL-2.0
1110
*******************************************************************************/
1211
// end::copyright[]
1312
package io.openliberty.guides.inventory.client;
@@ -28,75 +27,49 @@
2827
@ApplicationScoped
2928
public class SystemClient {
3029

31-
// Constants for building URI to the system service.
32-
private final String SYSTEM_PROPERTIES = "/system/properties";
33-
private final String PROTOCOL = "http";
30+
// Constants for building URI to the system service.
31+
private final String SYSTEM_PROPERTIES = "/system/properties";
32+
private final String PROTOCOL = "http";
3433

35-
@Inject
36-
@ConfigProperty(name = "system.http.port")
37-
String SYS_HTTP_PORT;
34+
@Inject
35+
@ConfigProperty(name = "system.http.port")
36+
String SYS_HTTP_PORT;
3837

39-
// Wrapper function that gets properties
40-
public Properties getProperties(String hostname) {
41-
String url = buildUrl(
42-
PROTOCOL, hostname, Integer.valueOf(SYS_HTTP_PORT), SYSTEM_PROPERTIES);
43-
Builder clientBuilder = buildClientBuilder(url);
44-
return getPropertiesHelper(clientBuilder);
45-
}
46-
47-
// tag::doc[]
48-
/**
49-
* Builds the URI string to the system service for a particular host.
50-
* @param protocol
51-
* - http or https.
52-
* @param host
53-
* - name of host.
54-
* @param port
55-
* - port number.
56-
* @param path
57-
* - Note that the path needs to start with a slash!!!
58-
* @return String representation of the URI to the system properties service.
59-
*/
60-
// end::doc[]
61-
protected String buildUrl(String protocol, String host, int port, String path) {
62-
try {
63-
URI uri = new URI(protocol, null, host, port, path, null, null);
64-
return uri.toString();
65-
} catch (Exception e) {
66-
System.err.println("Exception thrown while building the URL: " + e.getMessage());
67-
return null;
38+
// Wrapper function that gets properties
39+
public Properties getProperties(String hostname) {
40+
Properties properties = null;
41+
Client client = ClientBuilder.newClient();
42+
try {
43+
Builder builder = getBuilder(hostname, client);
44+
properties = getPropertiesHelper(builder);
45+
} catch (Exception e) {
46+
System.err.println(
47+
"Exception thrown while getting properties: " + e.getMessage());
48+
} finally {
49+
client.close();
50+
}
51+
return properties;
6852
}
69-
}
7053

71-
// Method that creates the client builder
72-
protected Builder buildClientBuilder(String urlString) {
73-
try {
74-
Client client = ClientBuilder.newClient();
75-
Builder builder = client.target(urlString).request();
76-
return builder.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
77-
} catch (Exception e) {
78-
System.err.println(
79-
"Exception thrown while building the client: " + e.getMessage());
80-
return null;
54+
// Method that creates the client builder
55+
private Builder getBuilder(String hostname, Client client) throws Exception {
56+
URI uri = new URI(
57+
PROTOCOL, null, hostname, Integer.valueOf(SYS_HTTP_PORT),
58+
SYSTEM_PROPERTIES, null, null);
59+
String urlString = uri.toString();
60+
Builder builder = client.target(urlString).request();
61+
builder.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
62+
return builder;
8163
}
82-
}
8364

84-
// Helper method that processes the request
85-
protected Properties getPropertiesHelper(Builder builder) {
86-
try {
87-
Response response = builder.get();
88-
if (response.getStatus() == Status.OK.getStatusCode()) {
89-
return response.readEntity(Properties.class);
90-
} else {
91-
System.err.println("Response Status is not OK.");
92-
}
93-
} catch (RuntimeException e) {
94-
System.err.println("Runtime exception: " + e.getMessage());
95-
} catch (Exception e) {
96-
System.err.println(
97-
"Exception thrown while invoking the request: " + e.getMessage());
65+
// Helper method that processes the request
66+
private Properties getPropertiesHelper(Builder builder) throws Exception {
67+
Response response = builder.get();
68+
if (response.getStatus() == Status.OK.getStatusCode()) {
69+
return response.readEntity(Properties.class);
70+
} else {
71+
System.err.println("Response Status is not OK.");
72+
return null;
73+
}
9874
}
99-
return null;
100-
}
101-
10275
}

finish/src/main/java/io/openliberty/guides/inventory/model/InventoryList.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
/*******************************************************************************
33
* Copyright (c) 2017, 2022 IBM Corporation and others.
44
* All rights reserved. This program and the accompanying materials
5-
* are made available under the terms of the Eclipse Public License v1.0
5+
* are made available under the terms of the Eclipse Public License 2.0
66
* which accompanies this distribution, and is available at
7-
* http://www.eclipse.org/legal/epl-v10.html
7+
* http://www.eclipse.org/legal/epl-2.0/
88
*
9-
* Contributors:
10-
* IBM Corporation - Initial implementation
9+
* SPDX-License-Identifier: EPL-2.0
1110
*******************************************************************************/
1211
// end::copyright[]
1312
package io.openliberty.guides.inventory.model;

finish/src/main/java/io/openliberty/guides/inventory/model/SystemData.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
/*******************************************************************************
33
* Copyright (c) 2017, 2022 IBM Corporation and others.
44
* All rights reserved. This program and the accompanying materials
5-
* are made available under the terms of the Eclipse Public License v1.0
5+
* are made available under the terms of the Eclipse Public License 2.0
66
* which accompanies this distribution, and is available at
7-
* http://www.eclipse.org/legal/epl-v10.html
7+
* http://www.eclipse.org/legal/epl-2.0/
88
*
9-
* Contributors:
10-
* IBM Corporation - Initial implementation
9+
* SPDX-License-Identifier: EPL-2.0
1110
*******************************************************************************/
1211
// end::copyright[]
1312
package io.openliberty.guides.inventory.model;

0 commit comments

Comments
 (0)