From 30f4f94d4fcc82b05f11260d945ac459ff6cbe2a Mon Sep 17 00:00:00 2001 From: John Koehler Date: Wed, 3 Feb 2021 09:07:52 -0600 Subject: [PATCH] Remove the EE9 skipped FAT tests from com.ibm.ws.jaxrs.2.0.client_fat ThirdpartyJerseyClientTest --- dev/com.ibm.ws.jaxrs.2.0.client_fat/bnd.bnd | 3 +- .../fat/test/JAXRSClientSSLDefaultTest.java | 2 +- .../fat/test/JAXRSClientSSLFiltersTest.java | 2 +- .../fat/test/JAXRSClientSSLProxyAuthTest.java | 2 +- .../JAXRSClientSSLTestNoLibertySSLCfg.java | 2 +- ...JAXRSClientSSLTestNoLibertySSLFeature.java | 2 +- .../client/fat/test/PathParamTest.java | 2 +- .../client/fat/test/ProxyClientTest.java | 2 +- .../fat/test/ThirdpartyJerseyClientTest.java | 2 - .../client/fat/test/TimeoutClientTest.java | 2 +- .../ClientTestServlet.java | 2 +- .../bnd.bnd | 3 +- .../restfulWS30/client/fat/FATSuite.java | 5 +- .../client/fat/test/AbstractTest.java | 82 +++++++++ .../client/fat/test/PathParamTest.java | 156 ++++++++++++++++++ .../PathParamTest/bootstrap.properties | 2 + .../publish/servers/PathParamTest/server.xml | 13 ++ .../pathparam/resources/WEB-INF/web.xml | 24 +++ .../fat/pathparam/PathParamApplication.java | 32 ++++ .../client/fat/pathparam/Resource.java | 47 ++++++ 20 files changed, 373 insertions(+), 14 deletions(-) create mode 100644 dev/io.openliberty.restfulWS.3.0.client_fat/fat/src/io/openliberty/restfulWS30/client/fat/test/AbstractTest.java create mode 100644 dev/io.openliberty.restfulWS.3.0.client_fat/fat/src/io/openliberty/restfulWS30/client/fat/test/PathParamTest.java create mode 100644 dev/io.openliberty.restfulWS.3.0.client_fat/publish/servers/PathParamTest/bootstrap.properties create mode 100644 dev/io.openliberty.restfulWS.3.0.client_fat/publish/servers/PathParamTest/server.xml create mode 100644 dev/io.openliberty.restfulWS.3.0.client_fat/test-applications/pathparam/resources/WEB-INF/web.xml create mode 100644 dev/io.openliberty.restfulWS.3.0.client_fat/test-applications/pathparam/src/io/openliberty/restfulWS30/client/fat/pathparam/PathParamApplication.java create mode 100644 dev/io.openliberty.restfulWS.3.0.client_fat/test-applications/pathparam/src/io/openliberty/restfulWS30/client/fat/pathparam/Resource.java diff --git a/dev/com.ibm.ws.jaxrs.2.0.client_fat/bnd.bnd b/dev/com.ibm.ws.jaxrs.2.0.client_fat/bnd.bnd index 79209f2f00e6..2e6d2bb37227 100644 --- a/dev/com.ibm.ws.jaxrs.2.0.client_fat/bnd.bnd +++ b/dev/com.ibm.ws.jaxrs.2.0.client_fat/bnd.bnd @@ -42,7 +42,8 @@ tested.features: \ jaxrs-2.1,\ restfulWS-3.0,\ appsecurity-3.0,\ - cdi-2.0 + cdi-2.0,\ + jsonb-2.0 -buildpath: \ com.ibm.websphere.javaee.annotation.1.2;version=latest,\ diff --git a/dev/com.ibm.ws.jaxrs.2.0.client_fat/fat/src/com/ibm/ws/jaxrs20/client/fat/test/JAXRSClientSSLDefaultTest.java b/dev/com.ibm.ws.jaxrs.2.0.client_fat/fat/src/com/ibm/ws/jaxrs20/client/fat/test/JAXRSClientSSLDefaultTest.java index 3b0e7cef08ba..8d15066ac1f9 100644 --- a/dev/com.ibm.ws.jaxrs.2.0.client_fat/fat/src/com/ibm/ws/jaxrs20/client/fat/test/JAXRSClientSSLDefaultTest.java +++ b/dev/com.ibm.ws.jaxrs.2.0.client_fat/fat/src/com/ibm/ws/jaxrs20/client/fat/test/JAXRSClientSSLDefaultTest.java @@ -30,7 +30,7 @@ import componenttest.custom.junit.runner.FATRunner; import componenttest.topology.impl.LibertyServer; -@SkipForRepeat("EE9_FEATURES") // currently broken due to multiple issues +@SkipForRepeat("EE9_FEATURES") // Continue to skip this test for EE9 as Default SSL is not supported yet @RunWith(FATRunner.class) public class JAXRSClientSSLDefaultTest extends AbstractTest { diff --git a/dev/com.ibm.ws.jaxrs.2.0.client_fat/fat/src/com/ibm/ws/jaxrs20/client/fat/test/JAXRSClientSSLFiltersTest.java b/dev/com.ibm.ws.jaxrs.2.0.client_fat/fat/src/com/ibm/ws/jaxrs20/client/fat/test/JAXRSClientSSLFiltersTest.java index cddf20df6568..ec425d018233 100644 --- a/dev/com.ibm.ws.jaxrs.2.0.client_fat/fat/src/com/ibm/ws/jaxrs20/client/fat/test/JAXRSClientSSLFiltersTest.java +++ b/dev/com.ibm.ws.jaxrs.2.0.client_fat/fat/src/com/ibm/ws/jaxrs20/client/fat/test/JAXRSClientSSLFiltersTest.java @@ -30,7 +30,7 @@ import componenttest.custom.junit.runner.FATRunner; import componenttest.topology.impl.LibertyServer; -@SkipForRepeat("EE9_FEATURES") // currently broken due to multiple issues +@SkipForRepeat("EE9_FEATURES") // Continue to skip this test for EE9 as Default SSL is not supported yet @RunWith(FATRunner.class) public class JAXRSClientSSLFiltersTest extends AbstractTest { diff --git a/dev/com.ibm.ws.jaxrs.2.0.client_fat/fat/src/com/ibm/ws/jaxrs20/client/fat/test/JAXRSClientSSLProxyAuthTest.java b/dev/com.ibm.ws.jaxrs.2.0.client_fat/fat/src/com/ibm/ws/jaxrs20/client/fat/test/JAXRSClientSSLProxyAuthTest.java index b17482d45b99..7ad911b77319 100644 --- a/dev/com.ibm.ws.jaxrs.2.0.client_fat/fat/src/com/ibm/ws/jaxrs20/client/fat/test/JAXRSClientSSLProxyAuthTest.java +++ b/dev/com.ibm.ws.jaxrs.2.0.client_fat/fat/src/com/ibm/ws/jaxrs20/client/fat/test/JAXRSClientSSLProxyAuthTest.java @@ -46,7 +46,7 @@ * password specified in the actual Client APIs are not logged, even when * tracing is enabled. */ -@SkipForRepeat("EE9_FEATURES") // currently broken due to multiple issues +@SkipForRepeat("EE9_FEATURES") // Continue to skip this test for EE9 as proxy authority (properties com.ibm.ws.jaxrs.client.proxy.*) is not supported yet @RunWith(FATRunner.class) public class JAXRSClientSSLProxyAuthTest extends AbstractTest { diff --git a/dev/com.ibm.ws.jaxrs.2.0.client_fat/fat/src/com/ibm/ws/jaxrs20/client/fat/test/JAXRSClientSSLTestNoLibertySSLCfg.java b/dev/com.ibm.ws.jaxrs.2.0.client_fat/fat/src/com/ibm/ws/jaxrs20/client/fat/test/JAXRSClientSSLTestNoLibertySSLCfg.java index d41df0368948..3f4ee5bbbcfd 100644 --- a/dev/com.ibm.ws.jaxrs.2.0.client_fat/fat/src/com/ibm/ws/jaxrs20/client/fat/test/JAXRSClientSSLTestNoLibertySSLCfg.java +++ b/dev/com.ibm.ws.jaxrs.2.0.client_fat/fat/src/com/ibm/ws/jaxrs20/client/fat/test/JAXRSClientSSLTestNoLibertySSLCfg.java @@ -41,7 +41,7 @@ import componenttest.topology.impl.LibertyServer; import componenttest.topology.utils.HttpUtils; -@SkipForRepeat("EE9_FEATURES") // currently broken due to multiple issues +@SkipForRepeat("EE9_FEATURES") // Continue to skip this test for EE9 as Default SSL is not supported yet @RunWith(FATRunner.class) public class JAXRSClientSSLTestNoLibertySSLCfg extends AbstractTest { diff --git a/dev/com.ibm.ws.jaxrs.2.0.client_fat/fat/src/com/ibm/ws/jaxrs20/client/fat/test/JAXRSClientSSLTestNoLibertySSLFeature.java b/dev/com.ibm.ws.jaxrs.2.0.client_fat/fat/src/com/ibm/ws/jaxrs20/client/fat/test/JAXRSClientSSLTestNoLibertySSLFeature.java index 30f3b5246356..a9cd75d96691 100644 --- a/dev/com.ibm.ws.jaxrs.2.0.client_fat/fat/src/com/ibm/ws/jaxrs20/client/fat/test/JAXRSClientSSLTestNoLibertySSLFeature.java +++ b/dev/com.ibm.ws.jaxrs.2.0.client_fat/fat/src/com/ibm/ws/jaxrs20/client/fat/test/JAXRSClientSSLTestNoLibertySSLFeature.java @@ -18,7 +18,7 @@ import componenttest.annotation.SkipForRepeat; import componenttest.custom.junit.runner.FATRunner; -@SkipForRepeat("EE9_FEATURES") // currently broken due to multiple issues +@SkipForRepeat("EE9_FEATURES") // Continue to skip this test for EE9 as Default SSL is not supported yet @RunWith(FATRunner.class) public class JAXRSClientSSLTestNoLibertySSLFeature extends JAXRSClientSSLTestNoLibertySSLCfg { diff --git a/dev/com.ibm.ws.jaxrs.2.0.client_fat/fat/src/com/ibm/ws/jaxrs20/client/fat/test/PathParamTest.java b/dev/com.ibm.ws.jaxrs.2.0.client_fat/fat/src/com/ibm/ws/jaxrs20/client/fat/test/PathParamTest.java index 69a98e59b8f8..9638e543c0b1 100644 --- a/dev/com.ibm.ws.jaxrs.2.0.client_fat/fat/src/com/ibm/ws/jaxrs20/client/fat/test/PathParamTest.java +++ b/dev/com.ibm.ws.jaxrs.2.0.client_fat/fat/src/com/ibm/ws/jaxrs20/client/fat/test/PathParamTest.java @@ -34,7 +34,7 @@ import componenttest.custom.junit.runner.FATRunner; import componenttest.topology.impl.LibertyServer; -@SkipForRepeat("EE9_FEATURES") // currently broken due to multiple issues +@SkipForRepeat("EE9_FEATURES") // Continue to skip this test for EE9 as Multiple REST servlets are defined for the web module which is not supported by RestEasy. See a new PathParamTest here io.openliberty.restfulWS.3.0.client_fat @RunWith(FATRunner.class) public class PathParamTest extends AbstractTest { diff --git a/dev/com.ibm.ws.jaxrs.2.0.client_fat/fat/src/com/ibm/ws/jaxrs20/client/fat/test/ProxyClientTest.java b/dev/com.ibm.ws.jaxrs.2.0.client_fat/fat/src/com/ibm/ws/jaxrs20/client/fat/test/ProxyClientTest.java index 27285120cc1f..fbfbde46ec00 100644 --- a/dev/com.ibm.ws.jaxrs.2.0.client_fat/fat/src/com/ibm/ws/jaxrs20/client/fat/test/ProxyClientTest.java +++ b/dev/com.ibm.ws.jaxrs.2.0.client_fat/fat/src/com/ibm/ws/jaxrs20/client/fat/test/ProxyClientTest.java @@ -30,7 +30,7 @@ import componenttest.custom.junit.runner.FATRunner; import componenttest.topology.impl.LibertyServer; -@SkipForRepeat("EE9_FEATURES") // currently broken due to multiple issues +@SkipForRepeat("EE9_FEATURES") // Continue to skip this test for EE9 as com.ibm.ws.jaxrs.client.proxy.* properties are not supported yet @RunWith(FATRunner.class) public class ProxyClientTest extends AbstractTest { diff --git a/dev/com.ibm.ws.jaxrs.2.0.client_fat/fat/src/com/ibm/ws/jaxrs20/client/fat/test/ThirdpartyJerseyClientTest.java b/dev/com.ibm.ws.jaxrs.2.0.client_fat/fat/src/com/ibm/ws/jaxrs20/client/fat/test/ThirdpartyJerseyClientTest.java index c8f7a8cb8370..2d8c07e1050c 100644 --- a/dev/com.ibm.ws.jaxrs.2.0.client_fat/fat/src/com/ibm/ws/jaxrs20/client/fat/test/ThirdpartyJerseyClientTest.java +++ b/dev/com.ibm.ws.jaxrs.2.0.client_fat/fat/src/com/ibm/ws/jaxrs20/client/fat/test/ThirdpartyJerseyClientTest.java @@ -25,11 +25,9 @@ import com.ibm.websphere.simplicity.ShrinkHelper; import componenttest.annotation.Server; -import componenttest.annotation.SkipForRepeat; import componenttest.custom.junit.runner.FATRunner; import componenttest.topology.impl.LibertyServer; -@SkipForRepeat("EE9_FEATURES") // currently broken due to multiple issues @RunWith(FATRunner.class) public class ThirdpartyJerseyClientTest extends AbstractTest { diff --git a/dev/com.ibm.ws.jaxrs.2.0.client_fat/fat/src/com/ibm/ws/jaxrs20/client/fat/test/TimeoutClientTest.java b/dev/com.ibm.ws.jaxrs.2.0.client_fat/fat/src/com/ibm/ws/jaxrs20/client/fat/test/TimeoutClientTest.java index dd88b5ebd320..f04bcf9ed961 100644 --- a/dev/com.ibm.ws.jaxrs.2.0.client_fat/fat/src/com/ibm/ws/jaxrs20/client/fat/test/TimeoutClientTest.java +++ b/dev/com.ibm.ws.jaxrs.2.0.client_fat/fat/src/com/ibm/ws/jaxrs20/client/fat/test/TimeoutClientTest.java @@ -29,7 +29,7 @@ import componenttest.custom.junit.runner.FATRunner; import componenttest.topology.impl.LibertyServer; -@SkipForRepeat("EE9_FEATURES") // currently broken due to multiple issues +@SkipForRepeat("EE9_FEATURES") // Continue to skip this test for EE9 as com.ibm.ws.jaxrs.client.*.timeout is not supported @RunWith(FATRunner.class) public class TimeoutClientTest extends AbstractTest { diff --git a/dev/com.ibm.ws.jaxrs.2.0.client_fat/test-applications/thirdpartyjerseyclient/src/com/ibm/ws/jaxrs20/client/ThirdpartyJerseyClient/ClientTestServlet.java b/dev/com.ibm.ws.jaxrs.2.0.client_fat/test-applications/thirdpartyjerseyclient/src/com/ibm/ws/jaxrs20/client/ThirdpartyJerseyClient/ClientTestServlet.java index 69591dc7cfd5..64d93cb3b3cc 100644 --- a/dev/com.ibm.ws.jaxrs.2.0.client_fat/test-applications/thirdpartyjerseyclient/src/com/ibm/ws/jaxrs20/client/ThirdpartyJerseyClient/ClientTestServlet.java +++ b/dev/com.ibm.ws.jaxrs.2.0.client_fat/test-applications/thirdpartyjerseyclient/src/com/ibm/ws/jaxrs20/client/ThirdpartyJerseyClient/ClientTestServlet.java @@ -125,7 +125,7 @@ public void testFlowProgram_ClientStandalone(Map param, StringBu Client c = cb.build(); String res = c.target("http://" + serverIP + ":" + serverPort + "/" + param.get("context") - + "/Test/BasicResource").path("echo").path(param.get("param")).request().get(String.class); + + "/Test/BasicResource").path("echo").path(param.get("param")).request().get().readEntity(String.class); c.close(); ret.append(res); } diff --git a/dev/io.openliberty.restfulWS.3.0.client_fat/bnd.bnd b/dev/io.openliberty.restfulWS.3.0.client_fat/bnd.bnd index edd36bca016e..72102e36d1a8 100644 --- a/dev/io.openliberty.restfulWS.3.0.client_fat/bnd.bnd +++ b/dev/io.openliberty.restfulWS.3.0.client_fat/bnd.bnd @@ -12,7 +12,8 @@ bVersion=1.0 src: \ - fat/src + fat/src,\ + test-applications/pathparam/src fat.project: true diff --git a/dev/io.openliberty.restfulWS.3.0.client_fat/fat/src/io/openliberty/restfulWS30/client/fat/FATSuite.java b/dev/io.openliberty.restfulWS.3.0.client_fat/fat/src/io/openliberty/restfulWS30/client/fat/FATSuite.java index 91d577031c97..1aa4ea822a59 100644 --- a/dev/io.openliberty.restfulWS.3.0.client_fat/fat/src/io/openliberty/restfulWS30/client/fat/FATSuite.java +++ b/dev/io.openliberty.restfulWS.3.0.client_fat/fat/src/io/openliberty/restfulWS30/client/fat/FATSuite.java @@ -14,10 +14,13 @@ import org.junit.runners.Suite; import org.junit.runners.Suite.SuiteClasses; +import io.openliberty.restfulWS30.client.fat.test.PathParamTest; + @RunWith(Suite.class) @SuiteClasses({ ClientFeatureTest.class, - SslTest.class + SslTest.class, + PathParamTest.class }) public class FATSuite { diff --git a/dev/io.openliberty.restfulWS.3.0.client_fat/fat/src/io/openliberty/restfulWS30/client/fat/test/AbstractTest.java b/dev/io.openliberty.restfulWS.3.0.client_fat/fat/src/io/openliberty/restfulWS30/client/fat/test/AbstractTest.java new file mode 100644 index 000000000000..02967ad541fd --- /dev/null +++ b/dev/io.openliberty.restfulWS.3.0.client_fat/fat/src/io/openliberty/restfulWS30/client/fat/test/AbstractTest.java @@ -0,0 +1,82 @@ +/******************************************************************************* + * Copyright (c) 2021 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 API and implementation + *******************************************************************************/ +package io.openliberty.restfulWS30.client.fat.test; + +import static org.junit.Assert.assertTrue; + +import java.io.BufferedReader; +import java.io.IOException; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.ProtocolException; +import java.net.URL; +import java.util.Iterator; +import java.util.Map; + +import com.ibm.websphere.simplicity.log.Log; + +import componenttest.topology.impl.LibertyServer; +import componenttest.topology.utils.FATServletClient; +import componenttest.topology.utils.HttpUtils; + +public class AbstractTest extends FATServletClient { + + private final static int REQUEST_TIMEOUT = 10; + + protected LibertyServer serverRef; + + protected void runTestOnServer(String target, String testMethod, Map params, String expectedResponse) throws ProtocolException, MalformedURLException, IOException { + + //build basic URI + StringBuilder sBuilder = new StringBuilder("http://").append(serverRef.getHostname()) + .append(":") + .append(serverRef.getHttpDefaultPort()) + .append("/") + .append(target) + .append("?test=") + .append(testMethod); + + //add params to URI + if (params != null && params.size() > 0) { + + StringBuilder paramStr = new StringBuilder(); + + Iterator itr = params.keySet().iterator(); + + while (itr.hasNext()) { + String key = itr.next(); + paramStr.append("&@" + key + "=" + params.get(key)); + } + + sBuilder.append(paramStr.toString()); + } + + sBuilder.append("&@secport=" + serverRef.getHttpDefaultSecurePort()); + sBuilder.append("&@hostname=" + serverRef.getHostname()); + + String urlStr = sBuilder.toString(); + Log.info(this.getClass(), testMethod, "Calling ClientTestApp with URL=" + urlStr); + + HttpURLConnection con; + + con = HttpUtils.getHttpConnection(new URL(urlStr), HttpURLConnection.HTTP_OK, REQUEST_TIMEOUT); + BufferedReader br = HttpUtils.getConnectionStream(con); + String line = br.readLine(); + + StringBuilder logOutput = new StringBuilder(); + for (String nextLine = line; nextLine != null; nextLine = br.readLine()) { + logOutput.append(nextLine); + } + + Log.info(this.getClass(), testMethod, "The response: " + logOutput.toString()); + assertTrue("Real response is " + line + " and the expected response is " + expectedResponse, line.contains(expectedResponse)); + } +} diff --git a/dev/io.openliberty.restfulWS.3.0.client_fat/fat/src/io/openliberty/restfulWS30/client/fat/test/PathParamTest.java b/dev/io.openliberty.restfulWS.3.0.client_fat/fat/src/io/openliberty/restfulWS30/client/fat/test/PathParamTest.java new file mode 100644 index 000000000000..6a3e4378351f --- /dev/null +++ b/dev/io.openliberty.restfulWS.3.0.client_fat/fat/src/io/openliberty/restfulWS30/client/fat/test/PathParamTest.java @@ -0,0 +1,156 @@ +/******************************************************************************* + * Copyright (c) 2021 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 API and implementation + *******************************************************************************/ +package io.openliberty.restfulWS30.client.fat.test; + +import static org.junit.Assert.fail; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.URL; + +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; + +import com.ibm.websphere.simplicity.ShrinkHelper; + +import componenttest.annotation.Server; +import componenttest.custom.junit.runner.FATRunner; +import componenttest.topology.impl.LibertyServer; + +@RunWith(FATRunner.class) +public class PathParamTest extends AbstractTest { + + @Server("PathParamTest") + public static LibertyServer server; + + public static final String moduleName = "pathparam"; + private static final String stringVariable = "abc"; + private static final short shortVariable = (short) 123; + private static final long longVariable = -9223372036L; + private static final double doubleVariable = 789.123; + + @BeforeClass + public static void setup() throws Exception { + WebArchive app = ShrinkHelper.defaultDropinApp(server, moduleName, "io.openliberty.restfulWS30.client.fat.pathparam"); + + // Make sure we don't fail because we try to start an + // already started server + try { + server.startServer(true); + } catch (Exception e) { + System.out.println(e.toString()); + } + } + + @AfterClass + public static void tearDown() throws Exception { + if (server != null) { + server.stopServer("CWWKE1102W"); //ignore server quiesce timeouts due to slow test machines + } + } + + @Before + public void preTest() { + serverRef = server; + } + + @After + public void afterTest() { + serverRef = null; + } + + private int getPort() { + return server.getHttpDefaultPort(); + } + + private StringBuilder runGetMethod(String path, int exprc, String testOut, boolean check) throws IOException { + URL url = new URL("http://localhost:" + getPort() + "/" + moduleName + path); + int retcode; + HttpURLConnection con = (HttpURLConnection) url.openConnection(); + try { + con.setDoInput(true); + con.setDoOutput(true); + con.setUseCaches(false); + con.setRequestMethod("GET"); + + retcode = con.getResponseCode(); + + InputStream is = con.getInputStream(); + InputStreamReader isr = new InputStreamReader(is); + BufferedReader br = new BufferedReader(isr); + + String sep = System.getProperty("line.separator"); + StringBuilder lines = new StringBuilder(); + for (String line = br.readLine(); line != null; line = br.readLine()) + lines.append(line).append(sep); + + if (check) { + if (lines.indexOf(testOut) < 0) + fail("Missing success message in output. " + lines); + + if (retcode != exprc) + fail("Bad return Code from Get. Expected " + exprc + "Got" + retcode); + } + + return lines; + } finally { + con.disconnect(); + } + } + + @Test + public void testStringResource() throws Exception { + runGetMethod("/pathparam/resource/string/" + stringVariable, 200, "ok", true); + } + + @Test + public void testLongResource() throws Exception { + runGetMethod("/pathparam/resource/biglong/" + longVariable, 200, "ok", true); + } + + @Test + public void testDoubleResource() throws Exception { + runGetMethod("/pathparam/resource/bigdouble/" + doubleVariable, 200, "ok", true); + } + + @Test + public void testShortResource() throws Exception { + runGetMethod("/pathparam/resource/smallshort/" + shortVariable, 200, "ok", true); + } + + @Test + public void testAllResources1() throws Exception { + server.stopServer(); + server.startServer(true); + runGetMethod("/pathparam/resource/smallshort/" + shortVariable, 200, "ok", true); + runGetMethod("/pathparam/resource/bigdouble/" + doubleVariable, 200, "ok", true); + runGetMethod("/pathparam/resource/biglong/" + longVariable, 200, "ok", true); + runGetMethod("/pathparam/resource/string/" + stringVariable, 200, "ok", true); + } + + @Test + public void testAllResources2() throws Exception { + server.stopServer(); + server.startServer(true); + runGetMethod("/pathparam/resource/bigdouble/" + doubleVariable, 200, "ok", true); + runGetMethod("/pathparam/resource/biglong/" + longVariable, 200, "ok", true); + runGetMethod("/pathparam/resource/string/" + stringVariable, 200, "ok", true); + runGetMethod("/pathparam/resource/smallshort/" + shortVariable, 200, "ok", true); + } +} diff --git a/dev/io.openliberty.restfulWS.3.0.client_fat/publish/servers/PathParamTest/bootstrap.properties b/dev/io.openliberty.restfulWS.3.0.client_fat/publish/servers/PathParamTest/bootstrap.properties new file mode 100644 index 000000000000..6aac28c4b541 --- /dev/null +++ b/dev/io.openliberty.restfulWS.3.0.client_fat/publish/servers/PathParamTest/bootstrap.properties @@ -0,0 +1,2 @@ +bootstrap.include=../testports.properties + diff --git a/dev/io.openliberty.restfulWS.3.0.client_fat/publish/servers/PathParamTest/server.xml b/dev/io.openliberty.restfulWS.3.0.client_fat/publish/servers/PathParamTest/server.xml new file mode 100644 index 000000000000..841aa5ac21e9 --- /dev/null +++ b/dev/io.openliberty.restfulWS.3.0.client_fat/publish/servers/PathParamTest/server.xml @@ -0,0 +1,13 @@ + + + restfulWS-3.0 + + + + + + + + + + diff --git a/dev/io.openliberty.restfulWS.3.0.client_fat/test-applications/pathparam/resources/WEB-INF/web.xml b/dev/io.openliberty.restfulWS.3.0.client_fat/test-applications/pathparam/resources/WEB-INF/web.xml new file mode 100644 index 000000000000..719d2caa3697 --- /dev/null +++ b/dev/io.openliberty.restfulWS.3.0.client_fat/test-applications/pathparam/resources/WEB-INF/web.xml @@ -0,0 +1,24 @@ + + + + PathParamApplicationServlet + com.ibm.websphere.jaxrs.server.IBMRestServlet + + jakarta.ws.rs.Application + io.openliberty.restfulWS30.client.fat.pathparam.PathParamApplication + + + requestProcessorAttribute + pathparamapp + + 1 + + + PathParamApplicationServlet + /pathparam/* + + + diff --git a/dev/io.openliberty.restfulWS.3.0.client_fat/test-applications/pathparam/src/io/openliberty/restfulWS30/client/fat/pathparam/PathParamApplication.java b/dev/io.openliberty.restfulWS.3.0.client_fat/test-applications/pathparam/src/io/openliberty/restfulWS30/client/fat/pathparam/PathParamApplication.java new file mode 100644 index 000000000000..45bfd2762faa --- /dev/null +++ b/dev/io.openliberty.restfulWS.3.0.client_fat/test-applications/pathparam/src/io/openliberty/restfulWS30/client/fat/pathparam/PathParamApplication.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2021 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 API and implementation + *******************************************************************************/ +package io.openliberty.restfulWS30.client.fat.pathparam; + +import java.util.HashSet; +import java.util.Set; + +import jakarta.ws.rs.ApplicationPath; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.PathParam; +import jakarta.ws.rs.core.Application; +import jakarta.ws.rs.core.Response; + +@ApplicationPath("pathparam") +public class PathParamApplication extends Application { + + @Override + public Set> getClasses() { + Set> list = new HashSet>(); + list.add(Resource.class); + return list; + } +} diff --git a/dev/io.openliberty.restfulWS.3.0.client_fat/test-applications/pathparam/src/io/openliberty/restfulWS30/client/fat/pathparam/Resource.java b/dev/io.openliberty.restfulWS.3.0.client_fat/test-applications/pathparam/src/io/openliberty/restfulWS30/client/fat/pathparam/Resource.java new file mode 100644 index 000000000000..262743ab256c --- /dev/null +++ b/dev/io.openliberty.restfulWS.3.0.client_fat/test-applications/pathparam/src/io/openliberty/restfulWS30/client/fat/pathparam/Resource.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright (c) 2021 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 API and implementation + *******************************************************************************/ +package io.openliberty.restfulWS30.client.fat.pathparam; + +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.PathParam; +import jakarta.ws.rs.core.Response; + +@Path("resource") +public class Resource { + + @GET + @Path("bigdouble/{id}") + public Response getID(@PathParam("id") double id) { + System.out.println("getID double: " + Double.toString(id)); + return Response.ok("ok").build(); + } + + @GET + @Path("biglong/{id}") + public Response getID(@PathParam("id") long id) { + System.out.println("getID long: " + Long.toString(id)); + return Response.ok("ok").build(); + } + + @GET + @Path("smallshort/{id}") + public Response getID(@PathParam("id") short id) { + System.out.println("getID short: " + Short.toString(id)); + return Response.ok("ok").build(); + } + @GET + @Path("string/{id}") + public Response getID(@PathParam("id") String id) { + System.out.println("getID String: " + id); + return Response.ok("ok").build(); + } +}