Skip to content

Commit

Permalink
get hostname and port from ArquillianResource url in TCK
Browse files Browse the repository at this point in the history
  • Loading branch information
alwin-joseph committed Mar 23, 2024
1 parent c97bac8 commit 9b4d285
Show file tree
Hide file tree
Showing 116 changed files with 986 additions and 381 deletions.
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, 2024 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
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, 2024 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
Expand Up @@ -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();
String portnum = Integer.toString(url.getPort());

assertFalse(isNullOrEmpty(hostname), "[JAXRSCommonClient] 'webServerHost' was not set.");
_hostname = hostname.trim();
assertTrue(!isNullOrEmpty(portnum),
"[JAXRSCommonClient] 'webServerPort' was not set.");
assertFalse(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();

TestUtil.logMsg("[JAXRSCommonClient] Test setup OK");

}

/**
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, 2024 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();
}

@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, 2024 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, 2024 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, 2024 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, 2024 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, 2024 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, 2024 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, 2024 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, 2024 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, 2024 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, 2024 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

0 comments on commit 9b4d285

Please sign in to comment.