Skip to content

Commit

Permalink
default porting class fix.
Browse files Browse the repository at this point in the history
Signed-off-by: Gurunandan Rao <[email protected]>
  • Loading branch information
gurunrao committed Dec 4, 2023
1 parent 7a8b926 commit fa09890
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 30 deletions.
5 changes: 1 addition & 4 deletions glassfish-runner/saaj-tck/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,6 @@
<goal>verify</goal>
</goals>
<configuration>
<!--
<test>com.sun.ts.tests.saaj.api.jakarta_xml_soap.SOAPConnection.URLClient#callTest</test>
-->
<includes>
<include>**/*Client*.*</include>
</includes>
Expand All @@ -169,7 +166,7 @@
<glassfish.home>${project.build.directory}/${glassfish.toplevel.dir}</glassfish.home>
<webServerHost>localhost</webServerHost>
<webServerPort>8080</webServerPort>
<porting.ts.url.class.1>com.sun.ts.tests.saaj.lib.implementation.sun.common.SunRIURL</porting.ts.url.class.1>
<porting.ts.url.class.1>com.sun.ts.lib.porting.implementation.SunRIURL</porting.ts.url.class.1>
</systemPropertyVariables>
</configuration>
</execution>
Expand Down
44 changes: 21 additions & 23 deletions glassfishtck/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,26 @@
SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>jakartatck</groupId>
<artifactId>project</artifactId>
<version>10.0.0-SNAPSHOT</version>
</parent>

<artifactId>glassfishtck</artifactId>
<packaging>jar</packaging>

<name>glassfishtck</name>
<description>glassfishtck</description>

<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>runtime</artifactId>
</dependency>
</dependencies>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>jakartatck</groupId>
<artifactId>project</artifactId>
<version>10.0.0-SNAPSHOT</version>
</parent>

<artifactId>glassfishtck</artifactId>
<packaging>jar</packaging>

<name>glassfishtck</name>
<description>glassfishtck</description>

<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>runtime</artifactId>
</dependency>
</dependencies>

</project>
8 changes: 5 additions & 3 deletions runtime/src/main/java/com/sun/ts/lib/porting/TSURL.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public class TSURL implements TSURLInterface, Serializable {
private TSURLInterface ctsURL = null;

private String sClass = "porting.ts.url.class.1";

private String portingDefault = "com.sun.ts.lib.porting.implementation.SunRIURL";

public TSURL() {
// we'll initialize the impl when the individual method is called
Expand Down Expand Up @@ -66,7 +68,7 @@ public URL getURL(String protocol, String host, int port, String file)
if (ctsURL == null) {
try {
// create and initialize a new instance of TSURLInterface
Class c = Class.forName(TestUtil.getProperty(sClass));
Class c = Class.forName(System.getProperty(sClass, portingDefault));
ctsURL = (TSURLInterface) c.newInstance();
} catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -95,7 +97,7 @@ public String getURLString(String protocol, String host, int port,
if (ctsURL == null) {
try {
// create and initialize a new instance of TSURLInterface
Class c = Class.forName(TestUtil.getProperty(sClass));
Class c = Class.forName(System.getProperty(sClass, portingDefault));
ctsURL = (TSURLInterface) c.newInstance();
} catch (Exception e) {
e.printStackTrace();
Expand All @@ -118,7 +120,7 @@ public String getRequest(String request) {
// create and initialize a new instance of TSURLInterface
// Class c = Class.forName(TestUtil.getProperty(sClass));
// Use the system property porting.ts.url.class.1
Class c = Class.forName(System.getProperty(sClass, "com.sun.ts.tests.jaxrs.lib.implementation.sun.common.SunRIURL"));
Class c = Class.forName(System.getProperty(sClass, portingDefault));
ctsURL = (TSURLInterface) c.newInstance();
} catch (Exception e) {
e.printStackTrace();
Expand Down
92 changes: 92 additions & 0 deletions saaj/src/main/java/com/sun/ts/tests/saaj/common/Client.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package com.sun.ts.tests.saaj.common;

import java.io.IOException;
import java.io.InputStream;
import java.lang.System.Logger;
import java.net.URL;
import java.net.URLConnection;
import java.util.Properties;

import org.jboss.arquillian.junit5.ArquillianExtension;
import org.jboss.shrinkwrap.api.asset.ByteArrayAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.extension.ExtendWith;

import com.sun.ts.lib.porting.TSURL;

@ExtendWith(ArquillianExtension.class)
public class Client {

protected static final String PROTOCOL = "http";

protected static final String HOSTNAME = "localhost";

protected static final int PORTNUM = 8000;

public static final String WEBSERVERHOSTPROP = "webServerHost";

public static final String WEBSERVERPORTPROP = "webServerPort";

protected TSURL tsurl = new TSURL();

protected URL url = null;

protected URLConnection urlConn = null;

protected Properties props = new Properties();

protected String hostname = HOSTNAME;

protected int portnum = PORTNUM;

private static final Logger logger = (Logger) System.getLogger(Client.class.getName());

public static void addFilesToArchive(String contentRoot, String[] fileNames, WebArchive archive)
throws IOException {
for (String fileName : fileNames) {
InputStream inStream = Thread.currentThread().getContextClassLoader()
.getResourceAsStream(contentRoot + fileName);
ByteArrayAsset attach = new ByteArrayAsset(inStream);
archive.add(attach, fileName);
}
}

/*
* @class.setup_props: webServerHost; webServerPort;
*/
@BeforeEach
public void setup() throws Exception {
boolean pass = true;

try {
hostname = System.getProperty(WEBSERVERHOSTPROP);
if (hostname == null)
pass = false;
else if (hostname.equals(""))
pass = false;
try {
portnum = Integer.parseInt(System.getProperty(WEBSERVERPORTPROP));
} catch (Exception e) {
pass = false;
}
} catch (Exception e) {
throw new Exception("setup failed:", e);
}
props.put(WEBSERVERHOSTPROP, hostname);
props.put(WEBSERVERPORTPROP, String.valueOf(portnum));
if (!pass) {
logger.log(Logger.Level.ERROR, "Please specify host & port of web server " + "in config properties: "
+ WEBSERVERHOSTPROP + ", " + WEBSERVERPORTPROP);
throw new Exception("setup failed:");
}
logger.log(Logger.Level.INFO, "setup ok");
}

@AfterEach
public void cleanup() throws Exception {
logger.log(Logger.Level.INFO, "cleanup ok");
}

}

0 comments on commit fa09890

Please sign in to comment.