Skip to content

Commit

Permalink
Merge pull request #15786 from jkoehler22/ThirdpartyJerseyClientTest
Browse files Browse the repository at this point in the history
Remove the EE9 skipped FAT tests from com.ibm.ws.jaxrs.2.0.client_fat ThirdpartyJerseyClientTest
  • Loading branch information
jkoehler22 authored Feb 4, 2021
2 parents 0e58e30 + 30f4f94 commit 27ef158
Show file tree
Hide file tree
Showing 20 changed files with 373 additions and 14 deletions.
3 changes: 2 additions & 1 deletion dev/com.ibm.ws.jaxrs.2.0.client_fat/bnd.bnd
Original file line number Diff line number Diff line change
Expand Up @@ -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,\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public void testFlowProgram_ClientStandalone(Map<String, String> 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);
}
Expand Down
3 changes: 2 additions & 1 deletion dev/io.openliberty.restfulWS.3.0.client_fat/bnd.bnd
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
bVersion=1.0

src: \
fat/src
fat/src,\
test-applications/pathparam/src


fat.project: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
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));
}
}
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);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bootstrap.include=../testports.properties

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>
Loading

0 comments on commit 27ef158

Please sign in to comment.