-
Notifications
You must be signed in to change notification settings - Fork 604
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 #15786 from jkoehler22/ThirdpartyJerseyClientTest
Remove the EE9 skipped FAT tests from com.ibm.ws.jaxrs.2.0.client_fat ThirdpartyJerseyClientTest
- Loading branch information
Showing
20 changed files
with
373 additions
and
14 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
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
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
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
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
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
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
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
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
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
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
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 |
---|---|---|
|
@@ -12,7 +12,8 @@ | |
bVersion=1.0 | ||
|
||
src: \ | ||
fat/src | ||
fat/src,\ | ||
test-applications/pathparam/src | ||
|
||
|
||
fat.project: true | ||
|
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
82 changes: 82 additions & 0 deletions
82
...fulWS.3.0.client_fat/fat/src/io/openliberty/restfulWS30/client/fat/test/AbstractTest.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,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<String, String> 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<String> 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)); | ||
} | ||
} |
156 changes: 156 additions & 0 deletions
156
...ulWS.3.0.client_fat/fat/src/io/openliberty/restfulWS30/client/fat/test/PathParamTest.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,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); | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
...o.openliberty.restfulWS.3.0.client_fat/publish/servers/PathParamTest/bootstrap.properties
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,2 @@ | ||
bootstrap.include=../testports.properties | ||
|
13 changes: 13 additions & 0 deletions
13
dev/io.openliberty.restfulWS.3.0.client_fat/publish/servers/PathParamTest/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,13 @@ | ||
<server> | ||
<featureManager> | ||
<feature>restfulWS-3.0</feature> | ||
</featureManager> | ||
|
||
<include location="../fatTestPorts.xml"/> | ||
<javaPermission className="org.osgi.framework.AdminPermission" name="*" actions="*"/> | ||
<javaPermission className="org.osgi.framework.ServicePermission" name="*" actions="get"/> | ||
<javaPermission className="java.lang.RuntimePermission" name="getClassLoader"/> | ||
<javaPermission className="java.lang.RuntimePermission" name="accessDeclaredMembers"/> | ||
<javaPermission className="java.net.SocketPermission" name="*" actions="connect,resolve"/> | ||
<javaPermission className="java.net.NetPermission" name="allowHttpTrace"/> | ||
</server> |
Oops, something went wrong.