Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TCK : Get hostname and port number injected using ArquillianResource url #1243

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2021 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -50,10 +50,6 @@ public class JAXRSClientIT extends ReaderClient<ContextOperation> {

private static final long serialVersionUID = -8828149277776372718L;

public JAXRSClientIT() {
setup();
}

@BeforeEach
void logStartTest(TestInfo testInfo) {
TestUtil.logMsg("STARTING TEST : "+testInfo.getDisplayName());
Expand All @@ -63,6 +59,15 @@ void logStartTest(TestInfo testInfo) {
void logFinishTest(TestInfo testInfo) {
TestUtil.logMsg("FINISHED TEST : "+testInfo.getDisplayName());
}

@BeforeEach
jansupol marked this conversation as resolved.
Show resolved Hide resolved
public void setup() {
// Only the values are verified, using verifySettings() in JaxrWebTestCase.java
// but the URL with these values is not required to work.
// TODO: remove validation of these values for the tests in this file.
_hostname = "localhost";
_port = 8080;
}

/*
* @testName: getAnnotationsTest
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2021 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -38,8 +38,18 @@ public class JAXRSClientIT extends ReaderClient<ContextOperation> {

private static final long serialVersionUID = -6962070973647934636L;

public JAXRSClientIT() {
setup();
@BeforeEach
public void setup() {

// Only the values are verified, using verifySettings() in JaxrWebTestCase.java
// but the URL with these values is not required to work.
// TODO: remove validation of these values for the tests in this file.
_hostname = "localhost";
_port = 8080;

String property = System.getProperty("cts.tmp", "/tmp");
if (property != null)
System.setProperty("java.io.tmpdir", property);
}

@BeforeEach
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2024 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand All @@ -18,6 +18,7 @@

import java.io.*;
import java.net.InetAddress;
import java.net.URL;
import java.net.UnknownHostException;
import java.util.Enumeration;
import java.util.Hashtable;
Expand All @@ -35,6 +36,9 @@
import ee.jakarta.tck.ws.rs.lib.util.TestUtil;
import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpState;
import org.jboss.arquillian.container.test.api.OperateOnDeployment;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.junit.jupiter.api.BeforeEach;

import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
Expand Down Expand Up @@ -239,36 +243,29 @@ public String getContextRoot() {
return _contextRoot;
}

@ArquillianResource
@OperateOnDeployment("_DEFAULT_")
private URL url;

/**
* <code>setup</code> is by the test harness to initialize the tests.
* <code>setup</code> is run by the test files to initialize the tests.
*
* @param args
* a <code>String[]</code> value
* @param p
* a <code>Properties</code> value
* @exception Fault
* if an error occurs
*/
//public void setup(String[] args, Properties p) {
public void setup() {
TestUtil.logTrace("setup method JAXRSCommonClient");
public void setup() {

String hostname = System.getProperty(SERVLETHOSTPROP);
String portnum = System.getProperty(SERVLETPORTPROP);
//String tshome = p.getProperty(TSHOME);
TestUtil.logTrace("setup method JAXRSCommonClient");

assertTrue(!isNullOrEmpty(hostname),
"[JAXRSCommonClient] 'webServerHost' was not set.");
assertFalse((url==null), "[JAXRSCommonClient] 'url' was not injected.");

String hostname = url.getHost();
int portnum = url.getPort();

assertFalse(isNullOrEmpty(hostname), "[JAXRSCommonClient] 'webServerHost' was not set.");
_hostname = hostname.trim();
assertTrue(!isNullOrEmpty(portnum),
"[JAXRSCommonClient] 'webServerPort' was not set.");
_port = Integer.parseInt(portnum.trim());

//assertTrue(!isNullOrEmpty(tshome),
// "[JAXRSCommonClient] 'tshome' was not set in the build.properties.");
//_tsHome = tshome.trim();

assertFalse(isPortInvalid(portnum), "[JAXRSCommonClient] 'webServerPort' was not set.");
_port = portnum;
TestUtil.logMsg("[JAXRSCommonClient] Test setup OK");

}

/**
Expand Down Expand Up @@ -926,6 +923,11 @@ protected boolean isNullOrEmpty(String val) {
return val == null || val.trim().equals("");
}

protected boolean isPortInvalid(int val) {
return val <= 0 || val > 65535 ;
}


private InetAddress[] _addrs = null;

protected String _servlet = null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2020, 2021 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -46,10 +46,14 @@ public class JAXRSClientIT extends JAXRSCommonClient {
private static final long serialVersionUID = 1L;

public JAXRSClientIT() {
setup();
setContextRoot("/jaxrs_resource_java2entity_web/resource");
}

@BeforeEach
public void setup() {
super.setup();
}

jamezp marked this conversation as resolved.
Show resolved Hide resolved
@Deployment(testable = false)
public static WebArchive createDeployment() throws IOException {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2020, 2021 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -44,10 +44,14 @@ public class JAXRSClientIT extends JAXRSCommonClient {
private static final long serialVersionUID = 1L;

public JAXRSClientIT() {
setup();
setContextRoot("/jaxrs_resource_webappexception_mapper_web/resource");
}

@BeforeEach
public void setup() {
super.setup();
}

@Deployment(testable = false)
public static WebArchive createDeployment() throws IOException {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2020, 2021 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -44,10 +44,14 @@ public class JAXRSClientIT extends JAXRSCommonClient {
private static final long serialVersionUID = 1L;

public JAXRSClientIT() {
setup();
setContextRoot("/jaxrs_resource_webappexception_nomapper_web/resource");
}

@BeforeEach
public void setup() {
super.setup();
}

@Deployment(testable = false)
public static WebArchive createDeployment() throws IOException {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -158,7 +158,7 @@ protected void checkCookie(String cookie) throws Fault {
found = true;
}
assertTrue(found, "Could not find cookie" + cookie+ "in response headers:" +
JaxrsUtil.iterableToString(";", headers));
JaxrsUtil.iterableToString(";", (Object)headers));
logMsg("Found cookie", cookie, "as expected");
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -62,10 +62,14 @@ public class JAXRSClientIT extends BeanParamCommonClient {
private static final long serialVersionUID = 201L;

public JAXRSClientIT() {
setup();
setContextRoot("/jaxrs_ee_rs_beanparam_cookie_plain_web/resource");
}

@BeforeEach
public void setup() {
super.setup();
}

@BeforeEach
void logStartTest(TestInfo testInfo) {
TestUtil.logMsg("STARTING TEST : "+testInfo.getDisplayName());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -62,10 +62,14 @@ public class JAXRSClientIT extends BeanParamCommonClient {
private static final long serialVersionUID = 201L;

public JAXRSClientIT() {
setup();
setContextRoot("/jaxrs_ee_rs_beanparam_form_plain_web/resource");
}

@BeforeEach
public void setup() {
super.setup();
}

@BeforeEach
void logStartTest(TestInfo testInfo) {
TestUtil.logMsg("STARTING TEST : "+testInfo.getDisplayName());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -62,10 +62,14 @@ public class JAXRSClientIT extends BeanParamCommonClient {
private static final long serialVersionUID = 201L;

public JAXRSClientIT() {
setup();
setContextRoot("/jaxrs_ee_rs_beanparam_header_plain_web/resource");
}

@BeforeEach
public void setup() {
super.setup();
}

@BeforeEach
void logStartTest(TestInfo testInfo) {
TestUtil.logMsg("STARTING TEST : "+testInfo.getDisplayName());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -63,10 +63,14 @@ public class JAXRSClientIT extends BeanParamCommonClient {
private static final long serialVersionUID = 201L;

public JAXRSClientIT() {
setup();
setContextRoot("/jaxrs_ee_rs_beanparam_matrix_plain_web/resource");
}

@BeforeEach
public void setup() {
super.setup();
}

@BeforeEach
void logStartTest(TestInfo testInfo) {
TestUtil.logMsg("STARTING TEST : "+testInfo.getDisplayName());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -61,10 +61,14 @@ public class JAXRSClientIT extends BeanParamCommonClient {
private static final long serialVersionUID = 201L;

public JAXRSClientIT() {
setup();
setContextRoot("/jaxrs_ee_rs_beanparam_path_plain_web/resource");
}

@BeforeEach
public void setup() {
super.setup();
}

@BeforeEach
void logStartTest(TestInfo testInfo) {
TestUtil.logMsg("STARTING TEST : "+testInfo.getDisplayName());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -81,10 +81,14 @@ public class JAXRSClientIT extends JaxrsCommonClient {
private static final String TWELVENTH = "Twelveth";

public JAXRSClientIT() {
setup();
setContextRoot("/jaxrs_ee_rs_beanparam_plain_web/resource");
}

@BeforeEach
public void setup() {
super.setup();
}

@BeforeEach
void logStartTest(TestInfo testInfo) {
TestUtil.logMsg("STARTING TEST : "+testInfo.getDisplayName());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2020 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -63,10 +63,14 @@ public class JAXRSClientIT extends BeanParamCommonClient {
private static final long serialVersionUID = 201L;

public JAXRSClientIT() {
setup();
setContextRoot("/jaxrs_ee_rs_beanparam_query_plain_web/resource");
}

@BeforeEach
public void setup() {
super.setup();
}

@BeforeEach
void logStartTest(TestInfo testInfo) {
TestUtil.logMsg("STARTING TEST : "+testInfo.getDisplayName());
Expand Down
Loading