diff --git a/common/src/main/java/com/sun/ts/lib/deliverable/cts/resource/Dog.java b/common/src/main/java/com/sun/ts/lib/deliverable/cts/resource/Dog.java
deleted file mode 100644
index 4c43ac30c5..0000000000
--- a/common/src/main/java/com/sun/ts/lib/deliverable/cts/resource/Dog.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (c) 2007, 2018 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.lib.deliverable.cts.resource;
-
-/**
- * A simple JavaBean class to be used as a custom resource type.
- */
-public class Dog implements java.io.Serializable {
- public static final String DOG_NAME = "wangwang";
-
- public static final int DOG_AGE = 2;
-
- private static Dog instance = new Dog();
-
- private int age = DOG_AGE;
-
- private String name = DOG_NAME;
-
- public Dog() {
- }
-
- public static Dog getInstance() {
- return instance;
- }
-
- public int getAge() {
- return age;
- }
-
- public void setAge(int age) {
- this.age = age;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- @Override
- public String toString() {
- String retValue;
- retValue = super.toString() + ", name=" + name + ", age=" + age;
- return retValue;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int PRIME = 31;
- int result = 1;
- result = PRIME * result + ((name == null) ? 0 : name.hashCode());
- result = PRIME * result + age;
- return result;
- }
-
- @Override
- public boolean equals(Object anObject) {
- if (this == anObject) {
- return true;
- }
- if (anObject instanceof Dog) {
- Dog anotherDog = (Dog) anObject;
- return (this.age == anotherDog.age && this.name.equals(anotherDog.name));
- }
- return false;
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/lib/harness/EETest.java b/common/src/main/java/com/sun/ts/lib/harness/EETest.java
deleted file mode 100644
index e4a6d9760e..0000000000
--- a/common/src/main/java/com/sun/ts/lib/harness/EETest.java
+++ /dev/null
@@ -1,985 +0,0 @@
-/*
- * Copyright (c) 2007, 2018 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.lib.harness;
-
-import com.sun.ts.lib.harness.Status;
-import com.sun.ts.lib.util.TestUtil;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.io.PrintWriter;
-import java.io.Serializable;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.Enumeration;
-import java.util.Properties;
-import java.util.Vector;
-
-/**
- * This abstract class must be extended by all clients of all J2EE-TS tests. All
- * implementations of this class must define a setup, cleanup, and
- * runtest(method names of runtest methods must match the 'testname' tag. EETest
- * uses reflection to invoke these methods which in turn, run the test(s) to
- * completion. Tests are assumed to pass, unless a Fault is thrown.
- *
- * @author Kyle Grucci
- */
-public abstract class EETest implements Serializable {
-
- /*
- * Please do NOT change this class in an incompatible manner with respect to
- * serialization. Please see the serialization specification to determine what
- * is a compatible change versus incompatible. If you do need to change this
- * class in an incompatible manner you will need to rebuild the compat tests.
- * You should also increment the serialVersionUID field to denote that this
- * class is incompatible with older versions.
- */
- static final long serialVersionUID = -4235235600918875382L;
-
- transient protected PrintStream log;
-
- transient protected PrintStream err;
-
- protected String sTestCase;
-
- transient Status sTestStatus = Status.passed("");
-
- Class testClass = this.getClass();
-
- Object testClInst;
-
- // nCl is true if the test class is different from the client class.
- boolean nCl;
-
- boolean bUtilAlreadyInitialized;
-
- Vector vLeftOverTestArgs;
-
- protected int iLogDelaySeconds;
-
- // get the props from the args
- protected Properties getTestPropsFromArgs(String[] argv) {
- Properties p = new Properties();
- Properties ap;
- String sProp;
- String sVal;
- boolean bRunIndividualTest = false;
- vLeftOverTestArgs = new Vector();
- // load a props object if used with -p
- for (int ii = 0; ii < argv.length; ii++) {
- if (argv[ii].startsWith("-p") || argv[ii].startsWith("-ap")) {
- ap = initializeProperties(argv[++ii]);
- // add additional props to "p"
- Enumeration e = ap.propertyNames();
- String key;
- while (e.hasMoreElements()) {
- key = (String) e.nextElement();
- p.put(key, ap.getProperty(key));
- }
- } else if (argv[ii].startsWith("-d")) {
- sProp = argv[ii].substring(2, argv[ii].indexOf('='));
- sVal = argv[ii].substring(argv[ii].indexOf('=') + 1);
- p.put(sProp, sVal);
- } else if (argv[ii].equalsIgnoreCase("-t")) {
- sTestCase = argv[++ii];
- bRunIndividualTest = true;
- } else {
- // there must be args that the test needs,
- // so pass these on
- vLeftOverTestArgs.addElement(argv[ii]);
- }
- }
- if (bRunIndividualTest)
- p.setProperty("testName", sTestCase);
- return p;
- }
-
- private Method getSetupMethod(Class testClass, Method runMethod) {
- String[] s = {};
- Class[] setupParameterTypes = { s.getClass(),
- (new Properties()).getClass() };
- Method setupMethod = null;
-
- // first check for @SetupMethod annotation on run method
- Annotation annotation = runMethod.getAnnotation(SetupMethod.class);
- String testSetupMethodName = null;
- if (annotation != null) {
- try {
- TestUtil
- .logTrace("getSetupMethod - getting setup method from annotation");
- SetupMethod setupAnnotation = (SetupMethod) annotation;
- testSetupMethodName = setupAnnotation.name();
- setupMethod = testClass.getMethod(setupAnnotation.name(),
- setupParameterTypes);
- TestUtil.logTrace(
- "getSetupMethod - setup method name: " + setupAnnotation.name());
- } catch (NoSuchMethodException e) {
- setTestStatus(Status.failed(
- "Could not find annotation defined test setup method (" + testSetupMethodName + ") for testcase: "
- + sTestCase),
- e);
- }
- } else {
- TestUtil.logTrace("No setupMethod annotation present");
- try {
- // get setup method
- TestUtil.logTrace(
- "getSetupMethod - checking for testcase specific setup method: "
- + sTestCase + "_setup");
- setupMethod = testClass.getMethod(sTestCase + "_setup",
- setupParameterTypes);
- } catch (NoSuchMethodException e2) {
- TestUtil.logTrace(
- "getSetupMethod - checking for default class specific setup method");
-
- // try calling the generic setup method
- try {
- setupMethod = testClass.getMethod("setup", setupParameterTypes);
-
- } catch (NoSuchMethodException e3) {
- setTestStatus(
- Status.failed(
- "Could not find setup method for" + "testcase: " + sTestCase),
- e3);
- }
- } catch (RuntimeException re) {
- setTestStatus(
- Status.failed("Could not access the test case: " + sTestCase), re);
- } catch (ThreadDeath t) {
- throw t;
- } catch (Throwable t) {
- setTestStatus(Status.failed("Unexpected Throwable: " + t), t);
- }
- }
- return setupMethod;
- }
-
- private Method getRunMethod(Class testClass) {
- Method runMethod = null;
- try {
- // get run method
- TestUtil.logTrace("** IN getRunMethod: testClass=" + testClass.getName());
- TestUtil.logTrace("** IN getRunMethod: testname=" + sTestCase);
- runMethod = testClass.getMethod(sTestCase, (java.lang.Class[]) null);
- } catch (NoSuchMethodException e) {
- setTestStatus(
- Status.failed(
- "Could not find the run method" + "for test case: " + sTestCase),
- e);
- } catch (RuntimeException e) {
- setTestStatus(
- Status.failed("Could not access the test case: " + sTestCase), e);
- } catch (ThreadDeath t) {
- throw t;
- } catch (Throwable t) {
- setTestStatus(Status.failed("Unexpected Throwable: " + t), t);
- }
- return runMethod;
- }
-
- private Method getCleanupMethod(Class testClass, Method runMethod) {
- Method cleanupMethod = null;
-
- // first check for @CleanupMethod annotation on run method
- Annotation annotation = runMethod.getAnnotation(CleanupMethod.class);
-
- if (annotation != null) {
- try {
- TestUtil.logTrace(
- "getCleanupMethod - getting cleanup method from annotation");
- CleanupMethod cleanupAnnotation = (CleanupMethod) annotation;
- cleanupMethod = testClass.getMethod(cleanupAnnotation.name(),
- (java.lang.Class[]) null);
- TestUtil.logTrace("getCleanupMethod - cleanup method name: "
- + cleanupAnnotation.name());
- } catch (NoSuchMethodException e) {
- setTestStatus(Status.failed(
- "Could not find annotation defined cleanup method for testcase: "
- + sTestCase),
- e);
- }
- } else {
- TestUtil.logTrace("No cleanupMethod annotation present");
- try {
- // get cleanup method
- TestUtil.logTrace(
- "getCleanupMethod - checking for testcase specific cleanup method: "
- + sTestCase + "_cleanup");
- cleanupMethod = testClass.getMethod(sTestCase + "_cleanup",
- (java.lang.Class[]) null);
- } catch (NoSuchMethodException e2) {
- TestUtil.logTrace(
- "getCleanupMethod - checking for default class specific cleanup method");
-
- // try calling the generic cleanup method
- try {
- cleanupMethod = testClass.getMethod("cleanup",
- (java.lang.Class[]) null);
-
- } catch (NoSuchMethodException e3) {
- setTestStatus(Status.failed(
- "Could not find cleanup method for" + "testcase: " + sTestCase),
- e3);
- }
- } catch (RuntimeException re) {
- setTestStatus(
- Status.failed("Could not access the test case: " + sTestCase), re);
- } catch (ThreadDeath t) {
- throw t;
- } catch (Throwable t) {
- setTestStatus(Status.failed("Unexpected Throwable: " + t), t);
- }
- }
- return cleanupMethod;
- }
-
- protected Properties initializeProperties(String sPropertiesFile) {
- FileInputStream propertyFileInputStream = null;
- Properties props = null;
- try {
- propertyFileInputStream = new FileInputStream(sPropertiesFile);
- props = new Properties();
- props.load(propertyFileInputStream);
- } catch (FileNotFoundException e) {
- TestUtil.logHarness("Could not find specified props file", e);
- } catch (IOException e) {
- TestUtil.logHarness("IOException while reading props file", e);
- } catch (Exception e) {
- TestUtil.logHarness("Exception while reading props file", e);
- } finally {
- try {
- if (propertyFileInputStream != null)
- propertyFileInputStream.close();
- } catch (IOException ex) {
- TestUtil.logHarness("IOException while closing props file", ex);
- }
- }
- return props;
- }
-
- /**
- *
- * This method is only called when test are run outside of JavaTest. If a
- * testcase name is passed within argv, then that testcase is run. Otherwise,
- * all testcases within this implementation of EETest are run.
- *
- *
- * @param argv
- * an array of arguments that a test may use
- * @param log
- * Stream passed to TestUtil for standard loggin
- * @param err
- * Writer passed to TestUtil for error logging
- * @return a Javatest {@link Status} object (passed or failed)
- */
- public Status run(String[] argv, PrintStream log, PrintStream err) {
- return run(argv, new PrintWriter(log, true), new PrintWriter(err, true));
- }
-
- /**
- * This method is only called when tests are run outside of JavaTest or if the
- * test is being run in the same VM as the harness. If a testcase name is
- * passed within argv, then that testcase is run. Otherwise, all testcases
- * within this implementation of EETest are run.
- *
- * @param argv
- * an array of arguments that a test may use
- * @param log
- * Writer passed to TestUtil for standard loggin
- * @param err
- * Writer passed to TestUtil for error logging
- * @return a Javatest {@link Status} object (passed or failed)
- */
- public Status run(String[] argv, PrintWriter log, PrintWriter err) {
- Properties props;
- Status retStatus = Status.failed("No status set yet");
- // assign log and reference output streams
- // this.err = err;
- // this.log = log;
- props = getTestPropsFromArgs(argv);
- // get the # of secs we should delay to allow reporting to finish
- try {
- String delayseconds = TestUtil.getProperty(props, "harness.log.delayseconds", "0");
- iLogDelaySeconds = Integer.parseInt(delayseconds) * 1000;
- } catch (NumberFormatException e) {
- // set the default if a number was not set
- iLogDelaySeconds = 0;
- }
- if (props.isEmpty())
- return Status.failed(
- "FAILED: An error occurred while trying to load the test properties");
- // copy leftover args to an array and pass them on
- int iSize = vLeftOverTestArgs.size();
- if (iSize == 0) {
- argv = null;
- } else {
- argv = new String[iSize];
- for (int ii = 0; ii < iSize; ii++) {
- argv[ii] = (String) vLeftOverTestArgs.elementAt(ii);
- }
- }
- props.put("line.separator", System.getProperty("line.separator"));
- if (sTestCase == null)
- return runAllTestCases(argv, props, log, err);
- else {
- // need to pass these streams to the Local Reporter
- TestUtil.setCurrentTest(sTestCase, log, err);
- TestUtil.initClient(props);
- retStatus = getPropsReady(argv, props);
- try {
- Thread.sleep(iLogDelaySeconds);
- } catch (InterruptedException e) {
- logErr("Exception: " + e);
- }
- return retStatus;
- }
- }
-
- protected void setTestStatus(Status s, Throwable t) {
- // only set the status for the first failure
- if (sTestStatus.getType() == Status.PASSED)
- sTestStatus = s;
- if (t != null) {
- TestUtil.logErr(s.getReason());
- TestUtil.logErr("Exception at: ", t);
- }
- }
-
- protected Status runAllTestCases(String[] argv, Properties p, PrintWriter log,
- PrintWriter err) {
- String[] sTestCases;
- int iPassedCount = 0;
- int iFailedCount = 0;
- TestUtil.initClient(p);
- try {
- sTestCases = getAllTestCases(p);
- } catch (Exception e) {
- e.printStackTrace();
- return Status
- .failed("An error occurred trying to get all" + "testcase methods.");
- }
- for (int ii = 0; ii < sTestCases.length; ii++) {
- sTestCase = sTestCases[ii];
- p.setProperty("testName", sTestCase);
- TestUtil.setCurrentTest(sTestCase, log, err);
- bUtilAlreadyInitialized = true;
- sTestStatus = Status.passed("");
- TestUtil.separator2();
- TestUtil.logMsg("Beginning Test: " + sTestCases[ii]);
- TestUtil.separator2();
- sTestStatus = getPropsReady(argv, p);
- try {
- Thread.sleep(iLogDelaySeconds);
- } catch (InterruptedException e) {
- logErr("Exception: " + e);
- }
- if (sTestStatus.getType() == Status.PASSED) {
- sTestCases[ii] += "...........PASSED";
- iPassedCount++;
- } else {
- TestUtil.logMsg(sTestStatus.getReason());
- sTestCases[ii] += "...........FAILED";
- iFailedCount++;
- }
- TestUtil.separator2();
- TestUtil.logMsg("End Test: " + sTestCases[ii]);
- TestUtil.separator2();
- }
- TestUtil.separator2();
- TestUtil.logMsg("Completed running " + sTestCases.length + " tests.");
- TestUtil.logMsg("Number of Tests Passed = " + iPassedCount);
- TestUtil.logMsg("Number of Tests Failed = " + iFailedCount);
- TestUtil.separator2();
- for (int ii = 0; ii < sTestCases.length; ii++) {
- TestUtil.logMsg(sTestCases[ii]);
- }
- if (iFailedCount > 0)
- return Status.failed("FAILED");
- else
- return Status.passed("PASSED");
- }
-
- /**
- * This method is only called from JavaTest to run a single testcase. All
- * properties are determined from the source code tags.
- *
- * @param argv
- * an array of arguments that a test may use
- * @param p
- * properties that are used by the testcase
- * @param log
- * stream passed to TestUtil for standard logging
- * @param err
- * stream passed to TestUtil for error logging
- * @return a Javatest Status object (passed or failed)
- */
- public Status run(String[] argv, Properties p, PrintWriter log,
- PrintWriter err) {
- // need to pass these streams to the Local Reporter
- sTestCase = TestUtil.getProperty(p, "testName");
- TestUtil.setCurrentTest(sTestCase, log, err);
- TestUtil.initClient(p);
- return getPropsReady(argv, p);
- }
-
- protected Status getPropsReady(String[] argv, Properties p) {
- // we only do this if we're in the Harness VM. If we're on the server,
- // that means that we're executing a service test within a generic
- // vehicle. In that case, we just invoke the setup, run, and cleanup
- // methods.
- // trim any whitespace around the property values
- Enumeration enum1 = p.propertyNames();
- String key;
- String value;
- while (enum1.hasMoreElements()) {
- key = (String) enum1.nextElement();
- value = p.getProperty(key);
- if (value != null) {
- p.put(key, value.trim());
- }
- // TestUtil.logTrace("Trimming prop: " + key + ". Value = " + value);
- }
- // set testname just to be sure
- sTestCase = TestUtil.getProperty(p, "testName");
- // The code below is to allow JCK service tests to be run from
- // ejb vehicles that have been bundled with an appclient
- // Need to get the setup(), run() and cleanup() methods in the
- // individual test classes -- not from the APIClient.class.
- // TestUtil.logTrace("**Got current testclass : " +
- // this.getClass().getName());
- // TestUtil.logTrace("*** Got testclass property : " +
- // p.getProperty("test_classname"));
- String sClass_name = TestUtil.getProperty(p, "test_classname");
- if (sClass_name != null) {
- String finder = TestUtil.getProperty(p, "finder");
- if (finder.trim().equals("jck")) {
- if (!((this.getClass().getName()).equals((sClass_name.trim())))) {
- try {
- testClInst = Class.forName(sClass_name).newInstance();
- testClass = testClInst.getClass();
- nCl = true;
- } catch (Exception te) {
- te.printStackTrace();
- }
- }
- }
- }
- // set the harness.host prop so the server can initialize the
- // the TestUtil logging
-
- if(p.getProperty("harness.host") == null ) {
- p.setProperty("harness.host", "localhost");
- // InetAddress.getLocalHost().getHostAddress());
- }
- return run(argv, p);
- }
-
- // public RemoteStatus run(String[] argv, Properties p, int iDummy)
- // {
- // return new RemoteStatus(run(argv, p));
- // }
- /**
- * This run method is the one that actually invokes reflection to figure out
- * and invoke the testcase methods.
- *
- * @param argv
- * an array of arguments that a test may use
- * @param p
- * properties that are used by the testcase
- * @return a Javatest Status object (passed or failed)
- */
- public Status run(String[] argv, Properties p) {
- sTestStatus = Status.passed("");
- // Make sure we set the testname if we're in a generic vehicle
- sTestCase = TestUtil.getProperty(p, "testName");
- // Class testClass = this.getClass();
- Method setupMethod, runMethod, cleanupMethod;
-
- // commented out as it's not currently used
- // Class testArgTypes[] = {};
- Object testArgs[] = { argv, p };
- TestUtil.logTrace("*** in EETest.run(argv,p)");
- if (sTestCase == null || sTestCase.equals("")) {
- // TestUtil.logTrace("*** in EETestrun(): testCase=null)");
- return Status.failed("Invalid test case name: " + sTestCase);
- } else {
- // The code below is to allow JCK service tests to be run from
- // ejb vehicles that have been bundled with an appclient
- // Need to get the setup(), run() and cleanup() methods in the
- // individual test classes -- not from the APIClient.class.
- // TestUtil.logTrace("**Got current testclass : " +
- // this.getClass().getName());
- // TestUtil.logTrace("*** Got testclass property : " +
- // p.getProperty("test_classname"));
- // if ( p.getProperty("test_classname") != null )
- // if (
- // !((this.getClass().getName()).equals((p.getProperty("test_classname").trim()))))
- // {
- // try {
- // testClInst=Class.forName(p.getProperty("test_classname")).newInstance();
- // testClass=testClInst.getClass();
- // nCl=true;
- // }catch ( Exception te ) {
- // te.printStackTrace();
- // }
- // }
- TestUtil.logTrace("TESTCLASS=" + testClass.getName());
- runMethod = getRunMethod(testClass);
- if (runMethod == null)
- return Status.failed("Invalid test case name as test run Method ( " + sTestCase + ") could not be found in " + testClass.getName());
- else {
- TestUtil.logTrace("** GOT RUN METHOD!");
- TestUtil.logTrace("**runmethod=" + runMethod.getName());
- }
- TestUtil.logTrace("ABOUT TO GET SETUP METHOD!");
- setupMethod = getSetupMethod(testClass, runMethod);
- if (setupMethod == null)
- return Status.failed("Invalid test case name as test setupMethod could not be found ( Test setup method: " +
- getSetupMethodName(runMethod) + ", testName:" + sTestCase + ") " +
- "in test class " + testClass.getName() + "(test class was loaded from: " + testClass.getClassLoader().getName() + ")");
- else
- TestUtil.logTrace("GOT SETUP METHOD: " + setupMethod.getName() + " for " + testClass.getName());
-
- cleanupMethod = getCleanupMethod(testClass, runMethod);
- if (cleanupMethod == null)
- return Status.failed("Invalid test case name as test cleanupMethod Method ( for " + sTestCase + ") could not be found in " + testClass.getName());
- else
- TestUtil.logTrace("GOT CLEANUP METHOD: " + cleanupMethod.getName() + " for " + testClass.getName());
- try {
- TestUtil.logTrace("ABOUT TO INVOKE SETUP METHOD!");
- // if new classname is true, use that class name instead of
- // "this" class.
- if (nCl)
- setupMethod.invoke(testClInst, testArgs);
- else
- setupMethod.invoke(this, testArgs);
- TestUtil.logTrace("INVOKED SETUP METHOD!");
- } catch (IllegalAccessException e) {
- setTestStatus(Status.failed(
- "Could not execute setup method" + "for test case: " + sTestCase),
- e);
- } catch (InvocationTargetException e) {
- setTestStatus(Status.failed(
- "Test case throws exception: " + e.getTargetException().toString()),
- e.getTargetException());
- } catch (RuntimeException e) {
- setTestStatus(
- Status.failed("Could not access the test case: " + e.toString()),
- e);
- } catch (ThreadDeath t) {
- throw t;
- } catch (Throwable t) {
- setTestStatus(Status.failed("Unexpected Throwable: " + t), t);
- }
- if (sTestStatus.getType() == Status.PASSED) {
- TestUtil.logTrace("ABOUT TO INVOKE EETEST RUN METHOD!");
- try {
- // if new classname is true, use that class name instead of
- // "this" class.
- if (nCl)
- runMethod.invoke(testClInst, (java.lang.Object[]) null);
- else
- runMethod.invoke(this, (java.lang.Object[]) null);
- } catch (IllegalAccessException e) {
- setTestStatus(Status.failed(
- "Could not execute run method" + "for test case: " + sTestCase),
- e);
- } catch (InvocationTargetException e) {
- setTestStatus(
- Status.failed("Test case throws exception: "
- + e.getTargetException().getMessage()),
- e.getTargetException());
- } catch (RuntimeException e) {
- setTestStatus(
- Status.failed("Could not access the test case: " + e.toString()),
- e);
- } catch (ThreadDeath t) {
- throw t;
- } catch (Throwable t) {
- setTestStatus(Status.failed("Unexpected Throwable: " + t), t);
- }
- }
- // call cleanup no matter what
- try {
- // if new classname is true, use that class name instead of
- // "this" class.
- if (nCl)
- cleanupMethod.invoke(testClInst, (java.lang.Object[]) null);
- else
- cleanupMethod.invoke(this, (java.lang.Object[]) null);
- } catch (IllegalAccessException e) {
- setTestStatus(
- Status.failed(
- "Could not execute cleanup method for test case: " + sTestCase),
- e);
- } catch (InvocationTargetException e) {
- setTestStatus(Status.failed("Test case throws exception: "
- + e.getTargetException().getMessage()), e.getTargetException());
- // Throwable t = e.getTargetException();
- } catch (RuntimeException e) {
- setTestStatus(
- Status.failed("Could not access the test case: " + e.toString()),
- e);
- } catch (ThreadDeath t) {
- throw t;
- } catch (Throwable t) {
- setTestStatus(Status.failed("Unexpected Throwable: " + t), t);
- }
- }
- return sTestStatus;
- }
-
- private String getSetupMethodName(Method runMethod) {
- Annotation annotation = runMethod.getAnnotation(SetupMethod.class);
- if (annotation != null) {
- SetupMethod setupAnnotation = (SetupMethod) annotation;
- return setupAnnotation.name();
- }
- return "";
- }
-
- private String[] getAllTestCases(Properties p) throws SetupException {
- Vector tests = new Vector();
- String[] testMethods;
- try {
- // read in exclude list once per VM
- ExcludeListProcessor.readExcludeList(TestUtil.getSystemProperty("exclude.list"));
- // setup a testname in a format that will macth the exclude list
- String sJavaTestName = "";
- String sVehicle;
- sVehicle = TestUtil.getProperty(p, "vehicle");
- if (sVehicle != null) {
- // tack on "_from_"
- sVehicle = "_from_" + sVehicle;
- }
- // for all tests, prepend the relative path and
- // .java file
- String sClientClassName = this.getClass().getName();
- String sClientJavaName = sClientClassName
- .substring(sClientClassName.lastIndexOf('.') + 1) + ".java";
- String sCurrentDir = TestUtil.getSystemProperty("current.dir");
- sCurrentDir = sCurrentDir.replace(File.separatorChar, '/');
- String sRelativeTestDir = sCurrentDir
- .substring(sCurrentDir.indexOf("tests/"));
- sRelativeTestDir = sRelativeTestDir
- .substring(sRelativeTestDir.indexOf("/") + 1);
- // make sure we have a trailing "/"
- if (!sRelativeTestDir.endsWith("/"))
- sRelativeTestDir += "/"; /*
- * Get public methods for this class Loop
- * through them to get methods that return
- * void, have no parameters, and contain "Test"
- * in their name.
- */
-
- Method[] methods = testClass.getMethods();
- for (int ii = 0; ii < methods.length; ii++) {
- Class[] paramTypes = methods[ii].getParameterTypes();
-
- // commented out as this is not currently used
- // Class returnType = methods[ii].getReturnType();
-
- // test that the parameter types match
- if ((paramTypes.length == 0))
- // &&
- // Void.class.isAssignableFrom(returnType))
- {
- String sName = methods[ii].getName();
- // test for our name requirements
- if ((sName.indexOf("Test") != -1 || sName.indexOf("test") != -1)
- && (sName.indexOf("Setup") == -1 && sName.indexOf("setup") == -1)
- && (sName.indexOf("Cleanup") == -1
- && sName.indexOf("cleanup") == -1)) {
- // check here for excluded tests when running
- // outside of JavaTest
- sJavaTestName = sName + sVehicle;
- // construct the JavaTest recognizable testname
- sJavaTestName = sRelativeTestDir + sClientJavaName + "#"
- + sJavaTestName;
- // for all tests, check to see if it's excluded
- if (!ExcludeListProcessor.isTestExcluded(sJavaTestName))
- tests.addElement(sName);
- else
- System.out.println(sJavaTestName + " is excluded.");
- sJavaTestName = "";
- }
- }
- }
- } catch (SecurityException e) {
- throw new SetupException("Failed while getting all test methods: ", e);
- }
- /*
- * Check size of vector, if <= 0, no methods match signature if > 0, copy
- * values into testMethods array
- */
- if (tests.size() <= 0)
- throw new SetupException(
- "No methods match signature: " + "\"public void methodName()\"");
- testMethods = new String[tests.size()];
- for (int ii = 0; ii < testMethods.length; ii++) {
- testMethods[ii] = (String) tests.elementAt(ii);
- }
- return testMethods;
- }
-
- /**
- * prints a string to the TestUtil log stream. All tests should use this
- * method for standard logging messages
- *
- * @param msg
- * string to print to the log stream
- */
- public void logMsg(String msg) {
- TestUtil.logMsg(msg);
- }
-
- /**
- * prints a debug string to the TestUtil log stream. All tests should use this
- * method for verbose logging messages. Whether or not the string is printed
- * is determined by the last call to the TestUtil setTrace method.
- *
- * @param msg
- * string to print to the log stream
- */
- public void logTrace(String msg) {
- TestUtil.logTrace(msg);
- }
-
- public void logTrace(String msg, Throwable e) {
- TestUtil.logTrace(msg, e);
- }
- /**
- * prints a string to the TestUtil error stream. All tests should use this
- * method for error messages
- *
- * @param msg
- * string to print to the error stream
- */
- public void logErr(String msg) {
- TestUtil.logErr(msg);
- }
-
- /**
- * prints a string to the TestUtil error stream. All tests should use this
- * method for error messages
- *
- * @param msg
- * string to print to the error stream
- * @param e
- * a Throwable whose stacktrace gets printed
- */
- public void logErr(String msg, Throwable e) {
- TestUtil.logErr(msg, e);
- }
-
- /**
- * This exception must be thrown by all implentations of EETest to signify a
- * test failure. Overrides 3 printStackTrace methods to preserver the original
- * stack trace. Using setStackTraceElement() would be more elegant but it is
- * not available prior to j2se 1.4.
- *
- * @author Kyle Grucci
- */
- public static class Fault extends Exception {
- private static final long serialVersionUID = -1574745208867827913L;
-
- public Throwable t;
-
- /**
- * creates a Fault with a message
- */
- public Fault(String msg) {
- super(msg);
- TestUtil.logErr(msg);
- }
-
- /**
- * creates a Fault with a message.
- *
- * @param msg
- * the message
- * @param t
- * prints this exception's stacktrace
- */
- public Fault(String msg, Throwable t) {
- super(msg);
- this.t = t;
- // TestUtil.logErr(msg, t);
- }
-
- /**
- * creates a Fault with a Throwable.
- *
- * @param t
- * the Throwable
- */
- public Fault(Throwable t) {
- super(t);
- this.t = t;
- }
-
- /**
- * Prints this Throwable and its backtrace to the standard error stream.
- *
- */
- public void printStackTrace() {
- if (this.t != null) {
- this.t.printStackTrace();
- } else {
- super.printStackTrace();
- }
- }
-
- /**
- * Prints this throwable and its backtrace to the specified print stream.
- *
- * @param s
- * PrintStream to use for output
- */
- public void printStackTrace(PrintStream s) {
- if (this.t != null) {
- this.t.printStackTrace(s);
- } else {
- super.printStackTrace(s);
- }
- }
-
- /**
- * Prints this throwable and its backtrace to the specified print writer.
- *
- * @param s
- * PrintWriter to use for output
- */
- public void printStackTrace(PrintWriter s) {
- if (this.t != null) {
- this.t.printStackTrace(s);
- } else {
- super.printStackTrace(s);
- }
- }
-
- @Override
- public Throwable getCause() {
- return t;
- }
-
- @Override
- public synchronized Throwable initCause(Throwable cause) {
- if (t != null)
- throw new IllegalStateException("Can't overwrite cause");
- if (!Exception.class.isInstance(cause))
- throw new IllegalArgumentException("Cause not permitted");
- this.t = (Exception) cause;
- return this;
- }
- }
-
- /**
- * This exception is used only by EETest. Overrides 3 printStackTrace methods
- * to preserver the original stack trace. Using setStackTraceElement() would
- * be more elegant but it is not available prior to j2se 1.4.
- *
- * @author Kyle Grucci
- */
- public static class SetupException extends Exception {
- private static final long serialVersionUID = -7616313680616499158L;
-
- public Exception e;
-
- /**
- * creates a Fault with a message
- */
- public SetupException(String msg) {
- super(msg);
- }
-
- /**
- * creates a SetupException with a message
- *
- * @param msg
- * the message
- * @param e
- * prints this exception's stacktrace
- */
- public SetupException(String msg, Exception e) {
- super(msg);
- this.e = e;
- }
-
- /**
- * Prints this Throwable and its backtrace to the standard error stream.
- *
- */
- public void printStackTrace() {
- if (this.e != null) {
- this.e.printStackTrace();
- } else {
- super.printStackTrace();
- }
- }
-
- /**
- * Prints this throwable and its backtrace to the specified print stream.
- *
- * @param s
- * PrintStream to use for output
- */
- public void printStackTrace(PrintStream s) {
- if (this.e != null) {
- this.e.printStackTrace(s);
- } else {
- super.printStackTrace(s);
- }
- }
-
- /**
- * Prints this throwable and its backtrace to the specified print writer.
- *
- * @param s
- * PrintWriter to use for output
- */
- public void printStackTrace(PrintWriter s) {
- if (this.e != null) {
- this.e.printStackTrace(s);
- } else {
- super.printStackTrace(s);
- }
- }
-
- @Override
- public Throwable getCause() {
- return e;
- }
-
- @Override
- public synchronized Throwable initCause(Throwable cause) {
- if (e != null)
- throw new IllegalStateException("Can't overwrite cause");
- if (!Exception.class.isInstance(cause))
- throw new IllegalArgumentException("Cause not permitted");
- this.e = (Exception) cause;
- return this;
- }
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/lib/harness/ExcludeListProcessor.java b/common/src/main/java/com/sun/ts/lib/harness/ExcludeListProcessor.java
deleted file mode 100644
index bfed6209b4..0000000000
--- a/common/src/main/java/com/sun/ts/lib/harness/ExcludeListProcessor.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (c) 2007, 2018 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.lib.harness;
-
-import java.util.Vector;
-import java.util.StringTokenizer;
-import java.io.File;
-import java.io.FileReader;
-import java.io.BufferedReader;
-import java.io.PrintWriter;
-import java.io.FileWriter;
-import java.io.BufferedWriter;
-import java.io.IOException;
-import java.io.FileNotFoundException;
-
-public class ExcludeListProcessor {
-
- // pass in a string which has the filename#testname
- public static boolean isTestExcluded(String fileName) {
- // check to see if it exists in the exclude list
- return fileNameList.contains(fileName);
- }
-
- public static void readExcludeList(String fileName) {
- BufferedReader d = null;
- try {
- d = new BufferedReader(new FileReader(fileName));
- String line;
- while ((line = d.readLine()) != null) {
- line = line.trim();
- if (line.length() > 0 && !line.startsWith("#")) {
- String entry = new String(line);
- fileNameList.addElement(entry.trim());
- }
- }
- d.close();
- } catch (FileNotFoundException e) {
- System.out.println(e.toString());
- e.printStackTrace();
- } catch (IOException e) {
- System.out.println(e.toString());
- e.printStackTrace();
- }
- }
-
- /*----------- Private Members of this class -------------*/
- private static Vector fileNameList = new Vector();
-
-}
diff --git a/common/src/main/java/com/sun/ts/lib/harness/ExecutionMode.java b/common/src/main/java/com/sun/ts/lib/harness/ExecutionMode.java
deleted file mode 100644
index 6af8b54868..0000000000
--- a/common/src/main/java/com/sun/ts/lib/harness/ExecutionMode.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 2007, 2018 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.lib.harness;
-
-import com.sun.ts.lib.deliverable.PropertyManagerInterface;
-import com.sun.ts.lib.util.TestUtil;
-
-public class ExecutionMode {
- public final static int DEPLOY_RUN_UNDEPLOY = 0;
-
- public final static int DEPLOY = 1;
-
- public final static int RUN = 2;
-
- public final static int UNDEPLOY = 3;
-
- public final static int DEPLOY_RUN = 4;
-
- public final static int LIST = 5;
-
- public final static int DEFAULT = DEPLOY_RUN_UNDEPLOY;
-
- private ExecutionMode() {
- }
-
- /**
- * gets the current execution mode from PropertyManagerInterface or from a
- * system property if overridden on the commandline. Note that current
- * execution mode is not cached since harness.executeMode property may change
- * between test executions.
- *
- * @param propMgr
- * an implementation of PropertyManagerInterface.
- * @return an int representing one of the 5 modes
- */
- public static int getExecutionMode(PropertyManagerInterface propMgr) {
- int mode = (Integer.getInteger("harness.executeMode", -1)).intValue();
-
- if (mode == -1) {
- if (propMgr != null) {
- String modeS = propMgr.getProperty("harness.executeMode", "");
- try {
- mode = Integer.parseInt(modeS);
- } catch (Exception e) {
- mode = DEFAULT;
- }
- } else {
- throw new Error(
- "PropertyManager is null. Please pass in a valid PropertyManager");
- }
-
- }
-
- if (mode < DEPLOY_RUN_UNDEPLOY || mode > LIST) {
- TestUtil.logHarness("harness.executeMode in ts.jte: " + mode
- + " is not valid. Will use default " + DEFAULT + ".");
- mode = DEFAULT;
- }
-
- TestUtil.logHarness("harness.executeMode is set to \"" + mode + "\"");
- return mode;
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/lib/harness/ServiceEETest.java b/common/src/main/java/com/sun/ts/lib/harness/ServiceEETest.java
deleted file mode 100644
index a0dc49cf7a..0000000000
--- a/common/src/main/java/com/sun/ts/lib/harness/ServiceEETest.java
+++ /dev/null
@@ -1,311 +0,0 @@
-/*
- * Copyright (c) 2007, 2018 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.lib.harness;
-
-import java.io.*;
-import java.rmi.Remote;
-import java.rmi.RemoteException;
-import com.sun.ts.lib.util.*;
-import java.util.*;
-import com.sun.ts.lib.harness.Status;
-import com.sun.ts.tests.common.vehicle.*;
-import com.sun.ts.lib.util.*;
-import com.sun.ts.lib.porting.*;
-import com.sun.ts.lib.deliverable.*;
-import java.net.*;
-
-/**
- * This abstract class must be extended by all clients of tests of J2EE service
- * apis; for example, JDBC, RMI-IIOP, JavaMail, JMS, etc. When a service test is
- * encountered by the JavaTest Client, the instance is passed to a J2EE server
- * component and run from that remote location. Using this model to develop
- * tests allows the same test to be run from different locations within the
- * scope of the J2EE Application Programming Model.
- *
- * @author Kyle Grucci
- */
-public abstract class ServiceEETest extends EETest {
-
- /*
- * Please do NOT change this class in an incompatible manner with respect to
- * serialization. Please see the serialization specification to determine what
- * is a compatible change versus incompatible. If you do need to change this
- * class in an incompatible manner you will need to rebuild the compat tests.
- * You should also increment the serialVersionUID field to denote that this
- * class is incompatible with older versions.
- */
- // static final long serialVersionUID = -1396452037848185296L;
-
- String[] sVehicles;
-
- private Object theSharedObject;
-
- private Object theSharedObjectArray[];
-
- /**
- * Returns any additional properties that may need to be set by a subclass of
- * ServiceEETest for use by a specific vehicle. This method was created due to
- * a need for clients of the JBIVehicle to set the name of the object to
- * lookup in the rmiregistry. By rule, this value should match the id name for
- * the component specified in the JBI installation descriptor. This impl
- * returns an empty properties object by default.
- *
- * @param p
- * user configured properties used by the test
- * @return Properties Additional properties that may need to be set by a
- * subclass of ServiceEETest for use by a specific vehicle.
- */
- public Properties getVehicleSpecificClientProps(Properties p) {
- return new Properties();
- }
-
- /**
- * When called within the harness VM, this method passes an instance of itself
- * to the appropriate J2EE server component. When called from within that
- * server component, EETest's run method is called and the test is run.
- *
- * @param argv
- * an array of arguments that a test may use
- * @param p
- * user configured properties used by this test
- * @return a Javatest Status object (passed or failed)
- */
- public Status run(String[] argv, Properties p) {
- Status status = null;
- boolean inTestHarness = TestUtil.iWhereAreWe == TestUtil.VM_HARNESS;
- TestUtil.logTrace("Check if called from within test process, inTestHarness= " + inTestHarness);
- boolean isVehicleClient = false;
- URL thisURL = getClass().getProtectionDomain().getCodeSource().getLocation();
- TestUtil.logTrace("in ServiceEETest.run(), this URL is: " + thisURL);
- try {
- Class> vcClass = getClass().getClassLoader().loadClass("com.sun.ts.tests.common.vehicle.VehicleClient");
- URL vcClassURL = vcClass.getProtectionDomain().getCodeSource().getLocation();
- TestUtil.logTrace("VehicleClient URL is: " + vcClassURL);
- isVehicleClient = vcClass.isAssignableFrom(getClass());
- TestUtil.logTrace("VehicleClient class check if is vehicle class = " +
- (isVehicleClient? "yes, is a com.sun.ts.tests.common.vehicle.VehicleClient"
- : "no, is not com.sun.ts.tests.common.vehicle.VehicleClient class"));
- if (inTestHarness && !isVehicleClient) {
- String sVehicle = TestUtil.getProperty(p, "vehicle");
- if("stateless3".equals(sVehicle) || "stateful3".equals(sVehicle)
- || "appmanaged".equals(sVehicle) || "appmanagedNoTx".equals(sVehicle)) {
- isVehicleClient = true;
- TestUtil.logTrace("Using appclient vehicle so set is vehicle client to true");
- }
- }
- } catch (ClassNotFoundException e) {
- TestUtil.logTrace("VehicleClient class not found, so not a vehicle client.");
- }
- if (inTestHarness && isVehicleClient) {
- TestUtil.logTrace("in ServiceEETest.run() method");
- String sVehicle = TestUtil.getProperty(p, "vehicle");
- String className = this.getClass().getName();
- // use this name for the context root or jndi name to eliminate
- // naming conflicts for apps deployed at the same time
- // comment out unused: String sVehicleEarName = TestUtil.getProperty(p, "vehicle_ear_name");
- TestUtil.logTrace("Vehicle to be used for this test is: " + sVehicle);
- // call to the Deliverable to run in deliverable specific vehicles
- // This should never be called on the server, so there is
- // no need to pass in the deliverable.class system property
- try {
- VehicleRunnable runner = VehicleRunnerFactory
- .getVehicleRunner(sVehicle);
- p.putAll((Map) getVehicleSpecificClientProps(p));
- status = runner.run(argv, p);
- } catch (Throwable e) {
- e.printStackTrace();
- return Status.failed("Vehicle runner failed.");
- }
-
- return status;
- } else {
- // we're on the server in a custom vehicle, so just call on EETest
- TestUtil.logTrace("in custom vehicle so call on EETest.");
- return super.run(argv, p);
- }
- }
-
- protected Properties getTestPropsFromArgs(String[] argv) {
- Properties p = new Properties();
- Properties ap = new Properties();
- String sProp = null;
- String sVal = null;
- boolean bRunIndividualTest = false;
- vLeftOverTestArgs = new Vector();
-
- if (TestUtil.harnessDebug)
- TestUtil.logHarnessDebug("ServiceEETest: " + argv.length + " args: "
- + Arrays.asList(argv).toString());
- // load a props object if used with -p
- boolean tFound = false;
- String argItem = null;
- for (int ii = 0; ii < argv.length; ii++) {
- argItem = argv[ii];
- if (argItem.equals("-p") || argItem.equals("-ap")) {
- ap = initializeProperties(argv[++ii]);
- // add additional props to "p"
- Enumeration e = ap.propertyNames();
- String key = null;
- while (e.hasMoreElements()) {
- key = (String) e.nextElement();
- p.put(key, (String) ap.getProperty(key));
- }
- } else if (argItem.startsWith("-d") && argItem.indexOf('=') != -1) {
- int equalSign = argItem.indexOf('=');
- sProp = argItem.substring(2, equalSign);
- sVal = argItem.substring(equalSign + 1);
- p.put(sProp, sVal);
- }
- // the first -t specifies test name and should be consumed by harness.
- // Any subsequent -t is to be passed along to test.
- else if (argItem.equalsIgnoreCase("-t") && !tFound) {
- sTestCase = argv[++ii];
- tFound = true;
- bRunIndividualTest = true;
- } else if (argItem.equalsIgnoreCase("-vehicle")) {
- sVehicles = new String[1];
- sVehicles[0] = argv[++ii];
- } else {
- // there must be args that the test needs,
- // so pass these on
- vLeftOverTestArgs.addElement(argItem);
- }
- }
- if (bRunIndividualTest)
- p.setProperty("testName", sTestCase);
- return p;
- }
-
- public Status run(String[] argv, PrintWriter log, PrintWriter err) {
- Status s = Status.passed("OK");
- Properties props;
- props = getTestPropsFromArgs(argv);
- // get the # of secs we should delay to allow reporting to finish
- try {
- String delayseconds = TestUtil.getProperty(props, "harness.log.delayseconds", "1");
- iLogDelaySeconds = Integer.parseInt(delayseconds) * 1000;
- } catch (NumberFormatException e) {
- // set the default if a number was not set
- iLogDelaySeconds = 1000;
- }
- if (sVehicles == null) {
- if (TestUtil.harnessDebug)
- TestUtil.logHarnessDebug("ServiceEETest.run(): vehicles = null");
- sVehicles = getVehicles(props);
- }
- if (props.isEmpty())
- return Status.failed(
- "FAILED: An error occurred while trying to load the test properties");
- // copy leftover args to an array and pass them on
- int iSize = vLeftOverTestArgs.size();
- if (iSize == 0) {
- argv = null;
- } else {
- argv = new String[iSize];
- for (int ii = 0; ii < iSize; ii++) {
- argv[ii] = (String) vLeftOverTestArgs.elementAt(ii);
- }
- }
- if (sTestCase == null)
- return runAllTestCases(argv, props, log, err);
- else {
- for (int ii = 0; ii < sVehicles.length; ii++) {
- props.put("vehicle", sVehicles[ii]);
- // need to pass these streams to the Local Reporter
- TestUtil.setCurrentTest(sTestCase, new PrintWriter(log, true),
- new PrintWriter(err, true));
- TestUtil.initClient(props);
- s = getPropsReady(argv, props);
- try {
- Thread.sleep(iLogDelaySeconds);
- TestUtil.logTrace("SLEPT FOR: " + iLogDelaySeconds);
- } catch (InterruptedException e) {
- logErr("Exception: " + e);
- }
- }
- }
- return s;
- }
-
- // overridden to allow service tests to run in standalone
- // mode outside of javatest
- protected Status runAllTestCases(String[] argv, Properties p, PrintStream log,
- PrintStream err) {
- if (sVehicles == null) {
- if (TestUtil.harnessDebug)
- TestUtil.logHarnessDebug(
- "ServiceEETest.runAllTestCases(): vehicles = null");
- sVehicles = getVehicles(p);
- }
- Status s = Status.passed("OK");
- for (int ii = 0; ii < sVehicles.length; ii++) {
- p.put("vehicle", sVehicles[ii]);
- s = super.runAllTestCases(argv, p, new PrintWriter(log, true),
- new PrintWriter(err, true));
- log.println("Completed running tests in " + sVehicles[ii] + " vehicle.");
- }
- return s;
- }
-
- private String[] getVehicles(Properties p) {
- String[] sReturn = null;
- String sVal = null;
- String sVehiclesToUse = null;
- StringTokenizer st = null;
- try {
- // get vehicles property (DEFAULT to all)
- sVal = TestUtil.getProperty(p, "service_eetest.vehicles");
- } catch (Exception e) {
- // got an exception looking up the prop, so set defaults
- sVal = "";
- sVal = "ejb servlet jsp";
- }
- if (sVal == null || sVal.equals("")) {
- sVehiclesToUse = "ejb servlet jsp";
- if (TestUtil.harnessDebug)
- TestUtil
- .logHarnessDebug("getVehicles: " + "Using default - all vehicles");
- } else {
- sVehiclesToUse = sVal;
- if (TestUtil.harnessDebug)
- TestUtil.logHarnessDebug(
- "getVehicles: using vehicle(s) - " + sVehiclesToUse);
- }
- st = new StringTokenizer(sVehiclesToUse);
- int iCount = st.countTokens();
- sReturn = new String[iCount];
- for (int ii = 0; ii < iCount; ii++) {
- // create 1 desc for each vehicle to be tested
- sReturn[ii] = st.nextToken().trim();
- }
- return sReturn;
- }
-
- /*
- * Set shared object
- */
- public void setSharedObject(Object o) {
- theSharedObject = o;
- }
-
- /*
- * Get shared object
- */
- public Object getSharedObject() {
- return theSharedObject;
- }
-}
diff --git a/common/src/main/java/com/sun/ts/lib/harness/TSKeywords.java b/common/src/main/java/com/sun/ts/lib/harness/TSKeywords.java
deleted file mode 100644
index edc3e378fd..0000000000
--- a/common/src/main/java/com/sun/ts/lib/harness/TSKeywords.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 2008, 2018 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.lib.harness;
-
-import com.sun.ts.lib.util.*;
-import java.util.*;
-import java.io.*;
-
-/**
- * This class is used by the TS harness to figure out which keywords should be
- * associated with directories of tests. Keywords are read in by the
- * TSTestFinder and written out to the test decriptions.
- *
- * A singleton class not intended for concurrent access.
- *
- *
- */
-public class TSKeywords {
- public final static String KEYWORD_PROP_FILE_NAME = "keyword.properties";
-
- private Properties mapping;
-
- private String[] keys; // sorted ascending
-
- private String relativeTestDir;
-
- private boolean loaded;
-
- // an uninitialized singleton instance
- private static TSKeywords instance = new TSKeywords();
-
- private TSKeywords() {
- }
-
- public static TSKeywords getInstance(File path) {
- if (instance == null) {
- instance = new TSKeywords();
- }
- instance.init(path);
- return instance;
- }
-
- private void init(File file) {
- if (!loaded) {
- mapping = ConfigUtil.loadPropertiesFor(KEYWORD_PROP_FILE_NAME);
- keys = ConfigUtil.loadKeysFrom(mapping);
- loaded = true;
- }
- if (mapping != null) {
- this.relativeTestDir = TestUtil.getRelativePath(file.getPath());
- }
- }
-
- /**
- * This method gets the current set of keywords to be used for a given
- * directory path.
- *
- * @return a String array of the keywords that this test should be run in
- */
- public String[] getKeywordSet() {
- if (mapping == null || keys == null) {
- return TestUtil.EMPTY_STRING_ARRAY;
- }
-
- String[] result = ConfigUtil.getMappingValue(this.mapping, this.keys,
- this.relativeTestDir);
- return result;
- }
-}
diff --git a/common/src/main/java/com/sun/ts/lib/harness/VehicleVerifier.java b/common/src/main/java/com/sun/ts/lib/harness/VehicleVerifier.java
deleted file mode 100644
index dcd110d73b..0000000000
--- a/common/src/main/java/com/sun/ts/lib/harness/VehicleVerifier.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Copyright (c) 2007, 2018 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.lib.harness;
-
-import com.sun.ts.lib.util.*;
-import java.util.*;
-import java.io.*;
-
-/**
- * This class is used by the TS harness to figure out which vehicles are to be
- * used by the Service tests in the TS. These defaults can be overridden by
- * editing appropriate properties file. However, this override mechanism is only
- * to be used for debugging purposes. When testing for J2EE certification, the
- * defaults specified in this class must be used.
- *
- * A singleton class not intended for concurrent access.
- *
- * @author Kyle Grucci
- */
-public class VehicleVerifier {
- public final static String VEHICLE_PROP_FILE_NAME = "vehicle.properties";
-
- public final static String EXCLUDE_KEY = "exclude.dir";
-
- private static Properties mapping;
-
- private static String[] keys; // sorted ascending
-
- private static String[] excludes;
-
- private String relativeTestDir;
-
- private String testName;
-
- private static boolean loaded;
-
- // an uninitialized singleton instance
- private static VehicleVerifier instance = new VehicleVerifier();
-
- private VehicleVerifier() {
- }
-
- public static VehicleVerifier getInstance(File path) {
- if (instance == null) {
- instance = new VehicleVerifier();
- }
- instance.init(path, null);
- return instance;
- }
-
- public static VehicleVerifier getInstance(File path, String sTestName) {
- if (instance == null) {
- instance = new VehicleVerifier();
- }
- instance.init(path, sTestName);
- return instance;
- }
-
- private void loadExcludes() {
- if (this.mapping == null) {
- excludes = TestUtil.EMPTY_STRING_ARRAY;
- } else {
- excludes = ConfigUtil.stringToArray((String) mapping.remove(EXCLUDE_KEY));
- }
- }
-
- private void init(File file, String sTest) {
- if (!loaded) {
- mapping = ConfigUtil.loadPropertiesFor(VEHICLE_PROP_FILE_NAME);
- loadExcludes();
- keys = ConfigUtil.loadKeysFrom(mapping);
- loaded = true;
- }
- testName = sTest;
- if (mapping != null) {
- this.relativeTestDir = TestUtil.getRelativePath(file.getPath());
- if (testName != null) {
- this.relativeTestDir += "#" + testName;
- TestUtil.logHarnessDebug(
- "VehicleVerifier.init: relative dir = " + this.relativeTestDir);
-
- }
- }
- // if mapping is null, it means this tck uses no vehicles and
- // vehicle.properties
- // does not exist. So don't bother to convert testDir to relative path.
- }
-
- private boolean isExcluded() {
- for (int i = 0; i < excludes.length; i++) {
- if (relativeTestDir.startsWith(excludes[i])) {
- TestUtil.logHarnessDebug(
- "VehicleVerifier: This test dir is excluded from those listed in vehicle.properties.");
- TestUtil.logHarnessDebug(
- "VehicleVerifier: Please check your exclude list in the vehicle.properties file.");
- return true;
- }
- }
- return false;
- }
-
- /**
- * This method gets the current set of vehicles to be used for a given
- * directory path.
- *
- * @return a String array of the vehicles that this test should be run in
- */
- public String[] getVehicleSet() {
- if (mapping == null || keys == null) {
- return TestUtil.EMPTY_STRING_ARRAY;
- }
- if (isExcluded()) {
- return TestUtil.EMPTY_STRING_ARRAY;
- }
- String[] result = ConfigUtil.getMappingValue(this.mapping, this.keys,
- this.relativeTestDir);
- return result;
- }
-
- public static void main(String args[]) {
- File testDir = null;
- if (args.length == 0) {
- testDir = new File(System.getProperty("user.dir"));
- } else {
- testDir = new File(args[0]);
- }
- VehicleVerifier ver = VehicleVerifier.getInstance(testDir);
- String[] result = ver.getVehicleSet();
- System.out
- .println(testDir.getPath() + " : " + Arrays.asList(result).toString());
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/util/ConnectorStatus.java b/common/src/main/java/com/sun/ts/tests/common/connector/util/ConnectorStatus.java
deleted file mode 100644
index f63cc936b2..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/util/ConnectorStatus.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.connector.util;
-
-import java.util.Vector;
-
-/**
- * Implementation class of Log interface, to be used as a verification mechanism
- * for connector tests. This class is implemented as a Singleton. The TS
- * whitebox resource adapter writes the log, and the TS test reads the log. The
- * whitebox will return an instance of this log to the calling test.
- */
-public class ConnectorStatus implements Log {
-
- private static ConnectorStatus status = new ConnectorStatus();
-
- private Vector log = new Vector();
-
- private Vector statelog = new Vector();
-
- private boolean logFlag = false;
-
- /**
- * Singleton constructor
- */
- private ConnectorStatus() {
- }
-
- /**
- * Singleton accessor
- */
- public static ConnectorStatus getConnectorStatus() {
- return status;
- }
-
- // --------------------------
- // Log method implementations
- // --------------------------
-
- /**
- * Adds elements to the log. This is called by the Resource Adapter.
- *
- */
- public void logAPI(String raAPI, String inParams, String outParams) {
- String logString = new String(raAPI + ":" + inParams + ":" + outParams);
- if (logFlag)
- log.addElement(logString);
- }
-
- /**
- * Adds elements to the State log. This is called by the Resource Adapter.
- *
- */
- public void logState(String state) {
- statelog.addElement(state);
- }
-
- /**
- * Purges the log store
- */
- public void purge() {
- log.clear();
- }
-
- /**
- * Purges the log store
- */
- public void purgeStateLog() {
- statelog.clear();
- }
-
- /**
- * Retrieves the entire log as a String
- */
- public Vector getLogVector() {
- return log;
- }
-
- /**
- * Retrieves the entire log as a String
- */
- public Vector getStateLogVector() {
- return statelog;
- }
-
- /**
- * Sets the logging to true/false
- */
- public void setLogFlag(boolean b) {
- logFlag = b;
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/APIAssertionTest.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/APIAssertionTest.java
deleted file mode 100644
index bf82bdf2e3..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/APIAssertionTest.java
+++ /dev/null
@@ -1,1282 +0,0 @@
-/*
- * Copyright (c) 2009, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.common.connector.whitebox;
-
-import java.beans.PropertyDescriptor;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-
-import jakarta.resource.NotSupportedException;
-import jakarta.resource.ResourceException;
-import jakarta.resource.spi.ApplicationServerInternalException;
-import jakarta.resource.spi.CommException;
-import jakarta.resource.spi.EISSystemException;
-import jakarta.resource.spi.InvalidPropertyException;
-import jakarta.resource.spi.LocalTransaction;
-import jakarta.resource.spi.LocalTransactionException;
-import jakarta.resource.spi.ManagedConnection;
-import jakarta.resource.spi.ManagedConnectionMetaData;
-import jakarta.resource.spi.ResourceAdapterInternalException;
-import jakarta.resource.spi.ResourceAllocationException;
-import jakarta.resource.spi.RetryableUnavailableException;
-import jakarta.resource.spi.SharingViolationException;
-import jakarta.resource.spi.UnavailableException;
-import jakarta.resource.spi.work.HintsContext;
-import jakarta.resource.spi.work.RetryableWorkRejectedException;
-import jakarta.resource.spi.work.WorkCompletedException;
-import jakarta.resource.spi.work.WorkException;
-import jakarta.resource.spi.work.WorkRejectedException;
-
-/*
- * This class is used to assist with testing API Assertions.
- */
-public class APIAssertionTest {
-
- public APIAssertionTest() {
- }
-
- public static void checkManagedConnectionAPI(ManagedConnection mcon) {
- if (mcon == null) {
- // should not get here
- Debug.trace(
- "Error - null MetaData passed into APIAssertionTest.checkMetaData()");
- }
-
- try {
- PrintWriter p = mcon.getLogWriter();
- logAPIPass("ManagedConnection.getLogWriter() passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying ManagedConnection.getLogWriter()");
- }
-
- try {
- ManagedConnectionMetaData dd = mcon.getMetaData();
- logAPIPass("ManagedConnection.getMetaData() passed");
- } catch (ResourceException ex) {
- // we could get this exception and still be considered passing
- logAPIPass("ManagedConnection.getMetaData() passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying ManagedConnection.getXAResource()");
- }
-
- try {
- LocalTransaction lt = mcon.getLocalTransaction();
- logAPIPass("ManagedConnection.getLocalTransaction() passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying ManagedConnection.getLocalTransaction()");
- }
- }
-
- public static void checkMetaDataAPI(ManagedConnectionMetaData mdata) {
- if (mdata == null) {
- // should not get here
- Debug.trace(
- "Error - null MetaData passed into APIAssertionTest.checkMetaData()");
- }
- logAPIPass("Connection.getMetaData() passed");
-
- try {
- String eisProdName = mdata.getEISProductName();
- logAPIPass("ManagedConnectionMetaData.getEISProductName() passed");
- } catch (Exception ex) {
- Debug.trace(
- "Error verifying ManagedConnectionMetaData.getEISProductName()");
- }
-
- try {
- String eisProdVer = mdata.getEISProductVersion();
- logAPIPass("ManagedConnectionMetaData.getEISProductVersion() passed");
- } catch (Exception ex) {
- Debug.trace(
- "Error verifying ManagedConnectionMetaData.getEISProductVersion()");
- }
-
- try {
- int maxCons = mdata.getMaxConnections();
- logAPIPass("ManagedConnectionMetaData.getMaxConnections() passed");
- } catch (Exception ex) {
- Debug.trace(
- "Error verifying ManagedConnectionMetaData.getMaxConnections()");
- }
-
- try {
- String userName = mdata.getUserName();
- logAPIPass("ManagedConnectionMetaData.getUserName() passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying ManagedConnectionMetaData.getUserName()");
- }
- }
-
- public void runTests() {
- checkNotSupportedException();
- checkResourceException();
- checkLocalTransactionException();
- checkResourceAdapterInternalException();
- checkResourceAllocationException();
- checkSecurityException();
- checkSharingViolationException();
- checkUnavailableException();
- checkWorkException();
- checkWorkCompletedException();
- checkWorkRejectedException();
- checkEISSystemException();
- checkInvalidPropertyException();
- checkApplicationServerInternalException();
- checkCommException();
- checkIllegalStateException();
- checkRetryableUnavailableException();
- checkRetryableWorkRejectedException();
- checkHintsContext();
- }
-
- /*
- * used to assist with verifying assertions:
- *
- *
- */
- private void checkHintsContext() {
-
- try {
- HintsContext hc = new HintsContext();
- logAPIPass("HintsContext() passed");
-
- hc.setName("hintName");
- String strname = hc.getName();
- if ((strname != null) && (strname.equalsIgnoreCase("hintName"))) {
- logAPIPass("HintsContext.setName() and HintsContext.getName() passed.");
- }
-
- hc.setDescription("hintDescription");
- String strDesc = hc.getDescription();
- if (strDesc != null) {
- // may not be exactly same desc that was set - though it *should* be
- logAPIPass(
- "HintsContext.setDescription() and HintsContext.getDescription() passed.");
- }
-
- hc.setHint(HintsContext.NAME_HINT, "someHintVal");
- Map m = hc.getHints();
- logAPIPass("HintsContext.setHints() and HintsContext.getHints() passed.");
-
- } catch (Exception ex) {
- Debug.trace("Error verifying InvalidPropertyException(null)");
- }
-
- }
-
- /*
- * used to assist with verifying assertions:
- *
- *
- */
- private void checkInvalidPropertyException() {
-
- try {
- InvalidPropertyException ne = new InvalidPropertyException();
- throw ne;
- } catch (InvalidPropertyException ex) {
- logAPIPass("InvalidPropertyException(null) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying InvalidPropertyException(null)");
- }
-
- try {
- InvalidPropertyException ne = new InvalidPropertyException("message1");
- throw ne;
- } catch (InvalidPropertyException ex) {
- logAPIPass("InvalidPropertyException(str) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying InvalidPropertyException(str)");
- }
-
- try {
- InvalidPropertyException ne = new InvalidPropertyException("message1",
- "ERRCODE1");
- throw ne;
- } catch (InvalidPropertyException ex) {
- logAPIPass("InvalidPropertyException(str, str) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying InvalidPropertyException(str, str)");
- }
-
- try {
- Exception someThrowable = new Exception("test");
- InvalidPropertyException ne = new InvalidPropertyException(someThrowable);
- throw ne;
- } catch (InvalidPropertyException ex) {
- logAPIPass("InvalidPropertyException(throwable) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying InvalidPropertyException(throwable)");
- }
-
- try {
- Exception someThrowable = new Exception("test");
- InvalidPropertyException ne = new InvalidPropertyException("someString",
- someThrowable);
- throw ne;
- } catch (InvalidPropertyException ex) {
- logAPIPass("InvalidPropertyException(str, throwable) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying InvalidPropertyException(str, throwable)");
- }
-
- try {
- InvalidPropertyException ne = new InvalidPropertyException("message1");
- List beanProps = new ArrayList();
- beanProps.add(new PropertyDescriptor("destinationName",
- LocalTxActivationSpec.class));
- beanProps.add(new PropertyDescriptor("destinationType",
- LocalTxActivationSpec.class));
- PropertyDescriptor[] pd = (PropertyDescriptor[]) beanProps
- .toArray(new PropertyDescriptor[beanProps.size()]);
- ne.setInvalidPropertyDescriptors(pd);
- Debug.trace("throwing setInvalidPropertyDescriptors(pd)");
- throw ne;
- } catch (InvalidPropertyException ex) {
- PropertyDescriptor[] pd = (PropertyDescriptor[]) ex
- .getInvalidPropertyDescriptors();
- logAPIPass(
- "InvalidPropertyException.setInvalidPropertyDescriptors() passed");
- logAPIPass(
- "InvalidPropertyException.getInvalidPropertyDescriptors() passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying InvalidPropertyException(str)");
- ex.printStackTrace();
- }
- }
-
- /*
- * used to assist with verifying assertions:
- *
- *
- */
- private void checkEISSystemException() {
-
- try {
- EISSystemException ne = new EISSystemException();
- throw ne;
- } catch (EISSystemException ex) {
- logAPIPass("EISSystemException(null) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying EISSystemException(null)");
- }
-
- try {
- EISSystemException ne = new EISSystemException("message1");
- throw ne;
- } catch (EISSystemException ex) {
- logAPIPass("EISSystemException(str) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying EISSystemException(str)");
- }
-
- try {
- EISSystemException ne = new EISSystemException("message1", "ERRCODE1");
- throw ne;
- } catch (EISSystemException ex) {
- logAPIPass("EISSystemException(str, str) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying EISSystemException(str, str)");
- }
-
- try {
- Exception someThrowable = new Exception("test");
- EISSystemException ne = new EISSystemException(someThrowable);
- throw ne;
- } catch (EISSystemException ex) {
- logAPIPass("EISSystemException(throwable) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying EISSystemException(throwable)");
- }
-
- try {
- Exception someThrowable = new Exception("test");
- EISSystemException ne = new EISSystemException("someString",
- someThrowable);
- throw ne;
- } catch (EISSystemException ex) {
- logAPIPass("EISSystemException(str, throwable) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying EISSystemException(str, throwable)");
- }
- }
-
- /*
- * used to assist with verifying assertions:
- *
- *
- */
- private void checkIllegalStateException() {
-
- try {
- jakarta.resource.spi.IllegalStateException ne = new jakarta.resource.spi.IllegalStateException();
- throw ne;
- } catch (jakarta.resource.spi.IllegalStateException ex) {
- logAPIPass("IllegalStateException(null) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying IllegalStateException(null)");
- }
-
- try {
- jakarta.resource.spi.IllegalStateException ne = new jakarta.resource.spi.IllegalStateException(
- "message1");
- throw ne;
- } catch (jakarta.resource.spi.IllegalStateException ex) {
- logAPIPass("IllegalStateException(str) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying IllegalStateException(str)");
- }
-
- try {
- jakarta.resource.spi.IllegalStateException ne = new jakarta.resource.spi.IllegalStateException(
- "message1", "ERRCODE1");
- throw ne;
- } catch (jakarta.resource.spi.IllegalStateException ex) {
- logAPIPass("IllegalStateException(str, str) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying IllegalStateException(str, str)");
- }
-
- try {
- Exception someThrowable = new Exception("test");
- jakarta.resource.spi.IllegalStateException ne = new jakarta.resource.spi.IllegalStateException(
- someThrowable);
- throw ne;
- } catch (jakarta.resource.spi.IllegalStateException ex) {
- logAPIPass("IllegalStateException(throwable) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying IllegalStateException(throwable)");
- }
-
- try {
- Exception someThrowable = new Exception("test");
- jakarta.resource.spi.IllegalStateException ne = new jakarta.resource.spi.IllegalStateException(
- "someString", someThrowable);
- throw ne;
- } catch (jakarta.resource.spi.IllegalStateException ex) {
- logAPIPass("IllegalStateException(str, throwable) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying IllegalStateException(str, throwable)");
- }
- }
-
- /*
- * used to assist with verifying assertions:
- *
- *
- */
- private void checkCommException() {
-
- try {
- CommException ne = new CommException();
- throw ne;
- } catch (CommException ex) {
- logAPIPass("CommException(null) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying CommException(null)");
- }
-
- try {
- CommException ne = new CommException("message1");
- throw ne;
- } catch (CommException ex) {
- logAPIPass("CommException(str) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying CommException(str)");
- }
-
- try {
- CommException ne = new CommException("message1", "ERRCODE1");
- throw ne;
- } catch (CommException ex) {
- logAPIPass("CommException(str, str) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying CommException(str, str)");
- }
-
- try {
- Exception someThrowable = new Exception("test");
- CommException ne = new CommException(someThrowable);
- throw ne;
- } catch (CommException ex) {
- logAPIPass("CommException(throwable) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying CommException(throwable)");
- }
-
- try {
- Exception someThrowable = new Exception("test");
- CommException ne = new CommException("someString", someThrowable);
- throw ne;
- } catch (CommException ex) {
- logAPIPass("CommException(str, throwable) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying CommException(str, throwable)");
- }
- }
-
- /*
- * used to assist with verifying assertions:
- *
- *
- */
- private void checkRetryableWorkRejectedException() {
-
- try {
- RetryableWorkRejectedException ne = new RetryableWorkRejectedException();
- throw ne;
- } catch (RetryableWorkRejectedException ex) {
- logAPIPass("RetryableWorkRejectedException(null) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying RetryableWorkRejectedException(null)");
- }
-
- try {
- RetryableWorkRejectedException ne = new RetryableWorkRejectedException(
- "message1");
- throw ne;
- } catch (RetryableWorkRejectedException ex) {
- logAPIPass("RetryableWorkRejectedException(str) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying RetryableWorkRejectedException(str)");
- }
-
- try {
- RetryableWorkRejectedException ne = new RetryableWorkRejectedException(
- "message1", "ERRCODE1");
- throw ne;
- } catch (RetryableWorkRejectedException ex) {
- logAPIPass("RetryableWorkRejectedException(str, str) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying RetryableWorkRejectedException(str, str)");
- }
-
- try {
- Exception someThrowable = new Exception("test");
- RetryableWorkRejectedException ne = new RetryableWorkRejectedException(
- someThrowable);
- throw ne;
- } catch (RetryableWorkRejectedException ex) {
- logAPIPass("RetryableWorkRejectedException(throwable) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying RetryableWorkRejectedException(throwable)");
- }
-
- try {
- Exception someThrowable = new Exception("test");
- RetryableWorkRejectedException ne = new RetryableWorkRejectedException(
- "someString", someThrowable);
- throw ne;
- } catch (RetryableWorkRejectedException ex) {
- logAPIPass("RetryableWorkRejectedException(str, throwable) passed");
- } catch (Exception ex) {
- Debug.trace(
- "Error verifying RetryableWorkRejectedException(str, throwable)");
- }
- }
-
- /*
- * used to assist with verifying assertions:
- *
- *
- */
- private void checkRetryableUnavailableException() {
-
- try {
- RetryableUnavailableException ne = new RetryableUnavailableException();
- throw ne;
- } catch (RetryableUnavailableException ex) {
- logAPIPass("RetryableUnavailableException(null) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying RetryableUnavailableException(null)");
- }
-
- try {
- RetryableUnavailableException ne = new RetryableUnavailableException(
- "message1");
- throw ne;
- } catch (RetryableUnavailableException ex) {
- logAPIPass("RetryableUnavailableException(str) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying RetryableUnavailableException(str)");
- }
-
- try {
- RetryableUnavailableException ne = new RetryableUnavailableException(
- "message1", "ERRCODE1");
- throw ne;
- } catch (RetryableUnavailableException ex) {
- logAPIPass("RetryableUnavailableException(str, str) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying RetryableUnavailableException(str, str)");
- }
-
- try {
- Exception someThrowable = new Exception("test");
- RetryableUnavailableException ne = new RetryableUnavailableException(
- someThrowable);
- throw ne;
- } catch (RetryableUnavailableException ex) {
- logAPIPass("RetryableUnavailableException(throwable) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying RetryableUnavailableException(throwable)");
- }
-
- try {
- Exception someThrowable = new Exception("test");
- RetryableUnavailableException ne = new RetryableUnavailableException(
- "someString", someThrowable);
- throw ne;
- } catch (RetryableUnavailableException ex) {
- logAPIPass("RetryableUnavailableException(str, throwable) passed");
- } catch (Exception ex) {
- Debug.trace(
- "Error verifying RetryableUnavailableException(str, throwable)");
- }
- }
-
- /*
- * used to assist with verifying assertions:
- *
- *
- */
- private void checkApplicationServerInternalException() {
-
- try {
- ApplicationServerInternalException ne = new ApplicationServerInternalException();
- throw ne;
- } catch (ApplicationServerInternalException ex) {
- logAPIPass("ApplicationServerInternalException(null) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying ApplicationServerInternalException(null)");
- }
-
- try {
- ApplicationServerInternalException ne = new ApplicationServerInternalException(
- "message1");
- throw ne;
- } catch (ApplicationServerInternalException ex) {
- logAPIPass("ApplicationServerInternalException(str) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying ApplicationServerInternalException(str)");
- }
-
- try {
- ApplicationServerInternalException ne = new ApplicationServerInternalException(
- "message1", "ERRCODE1");
- throw ne;
- } catch (ApplicationServerInternalException ex) {
- logAPIPass("ApplicationServerInternalException(str, str) passed");
- } catch (Exception ex) {
- Debug.trace(
- "Error verifying ApplicationServerInternalException(str, str)");
- }
-
- try {
- Exception someThrowable = new Exception("test");
- ApplicationServerInternalException ne = new ApplicationServerInternalException(
- someThrowable);
- throw ne;
- } catch (ApplicationServerInternalException ex) {
- logAPIPass("ApplicationServerInternalException(throwable) passed");
- } catch (Exception ex) {
- Debug.trace(
- "Error verifying ApplicationServerInternalException(throwable)");
- }
-
- try {
- Exception someThrowable = new Exception("test");
- ApplicationServerInternalException ne = new ApplicationServerInternalException(
- "someString", someThrowable);
- throw ne;
- } catch (ApplicationServerInternalException ex) {
- logAPIPass("ApplicationServerInternalException(str, throwable) passed");
- } catch (Exception ex) {
- Debug.trace(
- "Error verifying ApplicationServerInternalException(str, throwable)");
- }
- }
-
- /*
- * used to assist with verifying assertions:
- *
- *
- */
- private void checkWorkException() {
-
- try {
- WorkException ne = new WorkException();
- throw ne;
- } catch (WorkException ex) {
- logAPIPass("WorkException(null) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying WorkException(null)");
- }
-
- try {
- WorkException ne = new WorkException("message1");
- throw ne;
- } catch (WorkException ex) {
- logAPIPass("WorkException(str) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying WorkException(str)");
- }
-
- try {
- WorkException ne = new WorkException("message1", "ERRCODE1");
- throw ne;
- } catch (WorkException ex) {
- logAPIPass("WorkException(str, str) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying WorkException(str, str)");
- }
-
- try {
- Exception someThrowable = new Exception("test");
- WorkException ne = new WorkException(someThrowable);
- throw ne;
- } catch (WorkException ex) {
- logAPIPass("WorkException(throwable) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying WorkException(throwable)");
- }
-
- try {
- Exception someThrowable = new Exception("test");
- WorkException ne = new WorkException("someString", someThrowable);
- throw ne;
- } catch (WorkException ex) {
- logAPIPass("WorkException(str, throwable) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying WorkException(str, throwable)");
- }
- }
-
- /*
- * used to assist with verifying assertions:
- *
- *
- */
- private void checkWorkCompletedException() {
-
- try {
- WorkCompletedException ne = new WorkCompletedException();
- throw ne;
- } catch (WorkCompletedException ex) {
- logAPIPass("WorkCompletedException(null) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying WorkCompletedException(null)");
- }
-
- try {
- WorkCompletedException ne = new WorkCompletedException("message1");
- throw ne;
- } catch (WorkCompletedException ex) {
- logAPIPass("WorkCompletedException(str) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying WorkCompletedException(str)");
- }
-
- try {
- WorkCompletedException ne = new WorkCompletedException("message1",
- "ERRCODE1");
- throw ne;
- } catch (WorkCompletedException ex) {
- logAPIPass("WorkCompletedException(str, str) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying WorkCompletedException(str, str)");
- }
-
- try {
- Exception someThrowable = new Exception("test");
- WorkCompletedException ne = new WorkCompletedException(someThrowable);
- throw ne;
- } catch (WorkCompletedException ex) {
- logAPIPass("WorkCompletedException(throwable) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying WorkCompletedException(throwable)");
- }
-
- try {
- Exception someThrowable = new Exception("test");
- WorkCompletedException ne = new WorkCompletedException("someString",
- someThrowable);
- throw ne;
- } catch (WorkCompletedException ex) {
- logAPIPass("WorkCompletedException(str, throwable) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying WorkCompletedException(str, throwable)");
- }
- }
-
- /*
- * used to assist with verifying assertions:
- *
- *
- */
- private void checkWorkRejectedException() {
-
- try {
- WorkRejectedException ne = new WorkRejectedException();
- throw ne;
- } catch (WorkRejectedException ex) {
- logAPIPass("WorkRejectedException(null) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying WorkRejectedException(null)");
- }
-
- try {
- WorkRejectedException ne = new WorkRejectedException("message1");
- throw ne;
- } catch (WorkRejectedException ex) {
- logAPIPass("WorkRejectedException(str) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying WorkRejectedException(str)");
- }
-
- try {
- WorkRejectedException ne = new WorkRejectedException("message1",
- "ERRCODE1");
- throw ne;
- } catch (WorkRejectedException ex) {
- logAPIPass("WorkRejectedException(str, str) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying WorkRejectedException(str, str)");
- }
-
- try {
- Exception someThrowable = new Exception("test");
- WorkRejectedException ne = new WorkRejectedException(someThrowable);
- throw ne;
- } catch (WorkRejectedException ex) {
- logAPIPass("WorkRejectedException(throwable) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying WorkRejectedException(throwable)");
- }
-
- try {
- Exception someThrowable = new Exception("test");
- WorkRejectedException ne = new WorkRejectedException("someString",
- someThrowable);
- throw ne;
- } catch (WorkRejectedException ex) {
- logAPIPass("WorkRejectedException(str, throwable) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying WorkRejectedException(str, throwable)");
- }
- }
-
- /*
- * used to assist with verifying assertions:
- *
- *
- */
- private void checkUnavailableException() {
-
- try {
- UnavailableException ne = new UnavailableException();
- throw ne;
- } catch (UnavailableException ex) {
- logAPIPass("UnavailableException(null) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying UnavailableException(null)");
- }
-
- try {
- UnavailableException ne = new UnavailableException("message1");
- throw ne;
- } catch (UnavailableException ex) {
- logAPIPass("UnavailableException(str) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying UnavailableException(str)");
- }
-
- try {
- UnavailableException ne = new UnavailableException("message1",
- "ERRCODE1");
- throw ne;
- } catch (UnavailableException ex) {
- logAPIPass("UnavailableException(str, str) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying UnavailableException(str, str)");
- }
-
- try {
- Exception someThrowable = new Exception("test");
- UnavailableException ne = new UnavailableException(someThrowable);
- throw ne;
- } catch (UnavailableException ex) {
- logAPIPass("UnavailableException(throwable) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying UnavailableException(throwable)");
- }
-
- try {
- Exception someThrowable = new Exception("test");
- UnavailableException ne = new UnavailableException("someString",
- someThrowable);
- throw ne;
- } catch (UnavailableException ex) {
- logAPIPass("UnavailableException(str, throwable) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying UnavailableException(str, throwable)");
- }
- }
-
- /*
- * used to assist with verifying assertions:
- *
- *
- */
- private void checkSharingViolationException() {
-
- try {
- SharingViolationException ne = new SharingViolationException();
- throw ne;
- } catch (SharingViolationException ex) {
- logAPIPass("SharingViolationException(null) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying SharingViolationException(null)");
- }
-
- try {
- SharingViolationException ne = new SharingViolationException("message1");
- throw ne;
- } catch (SharingViolationException ex) {
- logAPIPass("SharingViolationException(str) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying SharingViolationException(str)");
- }
-
- try {
- SharingViolationException ne = new SharingViolationException("message1",
- "ERRCODE1");
- throw ne;
- } catch (SharingViolationException ex) {
- logAPIPass("SharingViolationException(str, str) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying SharingViolationException(str, str)");
- }
-
- try {
- Exception someThrowable = new Exception("test");
- SharingViolationException ne = new SharingViolationException(
- someThrowable);
- throw ne;
- } catch (SharingViolationException ex) {
- logAPIPass("SharingViolationException(throwable) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying SharingViolationException(throwable)");
- }
-
- try {
- Exception someThrowable = new Exception("test");
- SharingViolationException ne = new SharingViolationException("someString",
- someThrowable);
- throw ne;
- } catch (SharingViolationException ex) {
- logAPIPass("SharingViolationException(str, throwable) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying SharingViolationException(str, throwable)");
- }
- }
-
- /*
- * used to assist with verifying assertions:
- *
- *
- */
- private void checkSecurityException() {
-
- try {
- jakarta.resource.spi.SecurityException ne = new jakarta.resource.spi.SecurityException();
- throw ne;
- } catch (jakarta.resource.spi.SecurityException ex) {
- logAPIPass("SecurityException(null) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying SecurityException(null)");
- }
-
- try {
- jakarta.resource.spi.SecurityException ne = new jakarta.resource.spi.SecurityException(
- "message1");
- throw ne;
- } catch (jakarta.resource.spi.SecurityException ex) {
- logAPIPass("SecurityException(str) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying SecurityException(str)");
- }
-
- try {
- jakarta.resource.spi.SecurityException ne = new jakarta.resource.spi.SecurityException(
- "message1", "ERRCODE1");
- throw ne;
- } catch (jakarta.resource.spi.SecurityException ex) {
- logAPIPass("SecurityException(str, str) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying SecurityException(str, str)");
- }
-
- try {
- Exception someThrowable = new Exception("test");
- jakarta.resource.spi.SecurityException ne = new jakarta.resource.spi.SecurityException(
- someThrowable);
- throw ne;
- } catch (jakarta.resource.spi.SecurityException ex) {
- logAPIPass("SecurityException(throwable) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying SecurityException(throwable)");
- }
-
- try {
- Exception someThrowable = new Exception("test");
- jakarta.resource.spi.SecurityException ne = new jakarta.resource.spi.SecurityException(
- "someString", someThrowable);
- throw ne;
- } catch (jakarta.resource.spi.SecurityException ex) {
- logAPIPass("SecurityException(str, throwable) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying SecurityException(str, throwable)");
- }
- }
-
- /*
- * used to assist with verifying assertions:
- *
- *
- */
- private void checkResourceAllocationException() {
-
- try {
- ResourceAllocationException ne = new ResourceAllocationException();
- throw ne;
- } catch (ResourceAllocationException ex) {
- logAPIPass("ResourceAllocationException(null) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying ResourceAllocationException(null)");
- }
-
- try {
- ResourceAllocationException ne = new ResourceAllocationException(
- "message1");
- throw ne;
- } catch (ResourceAllocationException ex) {
- logAPIPass("ResourceAllocationException(str) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying ResourceAllocationException(str)");
- }
-
- try {
- ResourceAllocationException ne = new ResourceAllocationException(
- "message1", "ERRCODE1");
- throw ne;
- } catch (ResourceAllocationException ex) {
- logAPIPass("ResourceAllocationException(str, str) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying ResourceAllocationException(str, str)");
- }
-
- try {
- Exception someThrowable = new Exception("test");
- ResourceAllocationException ne = new ResourceAllocationException(
- someThrowable);
- throw ne;
- } catch (ResourceAllocationException ex) {
- logAPIPass("ResourceAllocationException(throwable) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying ResourceAllocationException(throwable)");
- }
-
- try {
- Exception someThrowable = new Exception("test");
- ResourceAllocationException ne = new ResourceAllocationException(
- "someString", someThrowable);
- throw ne;
- } catch (ResourceAllocationException ex) {
- logAPIPass("ResourceAllocationException(str, throwable) passed");
- } catch (Exception ex) {
- Debug
- .trace("Error verifying ResourceAllocationException(str, throwable)");
- }
- }
-
- /*
- * used to assist with verifying assertions:
- *
- *
- */
- private void checkResourceAdapterInternalException() {
-
- try {
- ResourceAdapterInternalException ne = new ResourceAdapterInternalException();
- throw ne;
- } catch (ResourceAdapterInternalException ex) {
- logAPIPass("ResourceAdapterInternalException(null) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying ResourceAdapterInternalException(null)");
- }
-
- try {
- ResourceAdapterInternalException ne = new ResourceAdapterInternalException(
- "message1");
- throw ne;
- } catch (ResourceAdapterInternalException ex) {
- logAPIPass("ResourceAdapterInternalException(str) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying ResourceAdapterInternalException(str)");
- }
-
- try {
- ResourceAdapterInternalException ne = new ResourceAdapterInternalException(
- "message1", "ERRCODE1");
- throw ne;
- } catch (ResourceAdapterInternalException ex) {
- logAPIPass("ResourceAdapterInternalException(str, str) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying ResourceAdapterInternalException(str, str)");
- }
-
- try {
- Exception someThrowable = new Exception("test");
- ResourceAdapterInternalException ne = new ResourceAdapterInternalException(
- someThrowable);
- throw ne;
- } catch (ResourceAdapterInternalException ex) {
- logAPIPass("ResourceAdapterInternalException(throwable) passed");
- } catch (Exception ex) {
- Debug
- .trace("Error verifying ResourceAdapterInternalException(throwable)");
- }
-
- try {
- Exception someThrowable = new Exception("test");
- ResourceAdapterInternalException ne = new ResourceAdapterInternalException(
- "someString", someThrowable);
- throw ne;
- } catch (ResourceAdapterInternalException ex) {
- logAPIPass("ResourceAdapterInternalException(str, throwable) passed");
- } catch (Exception ex) {
- Debug.trace(
- "Error verifying ResourceAdapterInternalException(str, throwable)");
- }
- }
-
- /*
- * used to assist with verifying assertions:
- *
- *
- */
- private void checkLocalTransactionException() {
-
- try {
- LocalTransactionException ne = new LocalTransactionException();
- throw ne;
- } catch (LocalTransactionException ex) {
- logAPIPass("LocalTransactionException(null) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying LocalTransactionException(null)");
- }
-
- try {
- LocalTransactionException ne = new LocalTransactionException("message1");
- throw ne;
- } catch (LocalTransactionException ex) {
- logAPIPass("LocalTransactionException(str) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying LocalTransactionException(str)");
- }
-
- try {
- LocalTransactionException ne = new LocalTransactionException("message1",
- "ERRCODE1");
- throw ne;
- } catch (LocalTransactionException ex) {
- logAPIPass("LocalTransactionException(str, str) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying LocalTransactionException(str, str)");
- }
-
- try {
- Exception someThrowable = new Exception("test");
- LocalTransactionException ne = new LocalTransactionException(
- someThrowable);
- throw ne;
- } catch (LocalTransactionException ex) {
- logAPIPass("LocalTransactionException(throwable) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying LocalTransactionException(throwable)");
- }
-
- try {
- Exception someThrowable = new Exception("test");
- LocalTransactionException ne = new LocalTransactionException("someString",
- someThrowable);
- throw ne;
- } catch (LocalTransactionException ex) {
- logAPIPass("LocalTransactionException(str, throwable) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying LocalTransactionException(str, throwable)");
- }
- }
-
- /*
- * used to assist with verifying assertions: Connector:JAVADOC:1,
- * Connector:JAVADOC:2, Connector:JAVADOC:3, Connector:JAVADOC:4,
- * Connector:JAVADOC:5
- */
- private void checkNotSupportedException() {
-
- try {
- NotSupportedException ne = new NotSupportedException();
- throw ne;
- } catch (NotSupportedException ex) {
- logAPIPass("NotSupportedException(null) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying NotSupportedException(null)");
- }
-
- try {
- NotSupportedException ne = new NotSupportedException("message1");
- throw ne;
- } catch (NotSupportedException ex) {
- logAPIPass("NotSupportedException(str) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying NotSupportedException(str)");
- }
-
- try {
- NotSupportedException ne = new NotSupportedException("message1",
- "ERRCODE1");
- throw ne;
- } catch (NotSupportedException ex) {
- logAPIPass("NotSupportedException(str, str) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying NotSupportedException(str, str)");
- }
-
- try {
- Exception someThrowable = new Exception("test");
- NotSupportedException ne = new NotSupportedException(someThrowable);
- throw ne;
- } catch (NotSupportedException ex) {
- logAPIPass("NotSupportedException(throwable) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying NotSupportedException(throwable)");
- }
-
- try {
- Exception someThrowable = new Exception("test");
- NotSupportedException ne = new NotSupportedException("someString",
- someThrowable);
- throw ne;
- } catch (NotSupportedException ex) {
- logAPIPass("NotSupportedException(str, throwable) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying NotSupportedException(str, throwable)");
- }
- }
-
- /*
- * used to assist with testing api assertions: Connector:JAVADOC:7,
- * Connector:JAVADOC:9, Connector:JAVADOC:10, Connector:JAVADOC:11,
- * Connector:JAVADOC:12, Connector:JAVADOC:13, Connector:JAVADOC:14,
- * Connector:JAVADOC:15
- */
- private void checkResourceException() {
-
- try {
- ResourceException ne = new ResourceException();
- throw ne;
- } catch (ResourceException ex) {
- logAPIPass("ResourceException(null) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying ResourceException(null)");
- }
-
- try {
- ResourceException ne = new ResourceException("message1");
- ne.setErrorCode("ERRCODE2");
- throw ne;
- } catch (ResourceException ex) {
- logAPIPass("ResourceException(str) passed");
- if ((ex.getErrorCode() != null)) {
- String str = ex.getErrorCode().toUpperCase();
- if (str.indexOf("ERRCODE2") != -1) {
- logAPIPass("ResourceException.setErrorCode(str) passed");
- }
- } else {
- Debug.trace("Error verifying ResourceException(str, str)");
- }
-
- } catch (Exception ex) {
- Debug.trace("Error verifying ResourceException(str)");
- }
-
- try {
- ResourceException ne = new ResourceException("message1", "ERRCODE1");
- throw ne;
- } catch (ResourceException ex) {
- logAPIPass("ResourceException(str, str) passed");
- if ((ex.getErrorCode() != null)) {
- String str = ex.getErrorCode().toUpperCase();
- if (str.indexOf("ERRCODE1") != -1) {
- logAPIPass("ResourceException.getErrorCode() passed");
- }
- } else {
- Debug.trace("Error verifying ResourceException(str, str)");
- }
- } catch (Exception ex) {
- Debug.trace("Error verifying ResourceException(str, str)");
- }
-
- try {
- Exception someThrowable = new Exception("test");
- ResourceException ne = new ResourceException(someThrowable);
- throw ne;
- } catch (ResourceException ex) {
- logAPIPass("ResourceException(throwable) passed");
- } catch (Exception ex) {
- Debug.trace("Error verifying ResourceException(throwable)");
- }
-
- try {
- Exception someThrowable = new Exception("test");
- ResourceException ne = new ResourceException("someString", someThrowable);
- throw ne;
- } catch (ResourceException ex) {
- logAPIPass("ResourceException(str, someThrowable) passed");
- if (ex.getMessage() != null) {
- logAPIPass("ResourceException.getMessage() passed");
- } else {
- Debug.trace("Error verifying ResourceException(str, someThrowable)");
- }
-
- } catch (Exception ex) {
- Debug.trace("Error verifying ResourceException(str, throwable)");
- }
- }
-
- private static void logAPIPass(String outStr) {
- ConnectorStatus.getConnectorStatus().logState(outStr);
- Debug.trace(outStr);
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/ContextWork.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/ContextWork.java
deleted file mode 100755
index 39e25497ae..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/ContextWork.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright (c) 2008, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.common.connector.whitebox;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-
-import jakarta.resource.spi.work.Work;
-import jakarta.resource.spi.work.WorkContext;
-import jakarta.resource.spi.work.WorkContextProvider;
-import jakarta.resource.spi.work.WorkException;
-import jakarta.resource.spi.work.WorkManager;
-
-/*
- * this class is used to help facilitate the testing of both nested
- * work objects/instances as well as nested (work) contexts. In
- * order to properly use this class to test nested work and contexts,
- * you should create an instance of this class, add a context to it
- * by using the addWorkContext() method, then add a NestedWork
- * instance to it - where the NestedWork instance will need to
- * have its own context assigned to it BEFOR it gets added into
- * this class.
- *
- */
-public class ContextWork implements Work, WorkContextProvider {
-
- private List contextsList = new ArrayList();
-
- private WorkManager wm;
-
- private NestWork nw = null;
-
- private String name = "ContextWork.name";
-
- private String description = "ContextWork.description";
-
- public ContextWork(WorkManager wm) {
- this.wm = wm;
- Debug.trace("WorkImpl.constructor");
- }
-
- public void addNestedWork(NestWork val) {
- nw = val;
- }
-
- public NestWork getNestWork() {
- return nw;
- }
-
- public WorkManager getWorkManager() {
- return wm;
- }
-
- @Override
- public List getWorkContexts() {
- return contextsList;
- }
-
- public void setWorkContexts(List val) {
- contextsList = val;
- }
-
- public void addWorkContext(WorkContext ic) {
- contextsList.add(ic);
- }
-
- @Override
- public void release() {
- Debug.trace("WorkImpl.release");
- }
-
- public String getName() {
- return name;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void run() {
- try {
- Debug.trace("ContextWork.run");
- if (nw != null) {
- wm.doWork(nw);
- }
-
- // we expect nw to be executed with no SIC and thus an unauthenticated
- // user...but what the work manager chooses to do with that is not
- // defined.
- Debug.trace(
- "ContextWork.run: just executed wm.doWork(nw) where nw has no SIC");
- if ((nw != null) && (nw.hasContextEntry())) {
- String str = "(ContextWork) ";
- str += "It appears that Security context is being inherited from parent SIC.";
- Debug.trace(str);
- }
-
- } catch (WorkException we) {
- Debug.trace(
- "ContextWork.run: got WorkException - which is fine since child had no SIC");
- if ((nw != null) && (!nw.hasContextEntry())) {
- // excellant - this is what we expected (for Connector:SPEC:305)
- // this verifies that nw did not inherit the SIC from
- // this (ie its parent) work class.
- String str = "Security Context info not inherited from parent Work";
- ConnectorStatus.getConnectorStatus().logState(str);
- Debug.trace(str);
- } else if ((nw != null) && (nw.hasContextEntry())) {
- // this verified Connector:SPEC:210 becaue we should have
- // a SIC with invalid creds that could not be authenticated
- String str = "Security Context info had invalid creds.";
- ConnectorStatus.getConnectorStatus().logState(str);
- Debug.trace(str);
- }
- }
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/Counter.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/Counter.java
deleted file mode 100644
index e0c99eb381..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/Counter.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (c) 2007, 2018 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.common.connector.whitebox;
-
-/*
- * This class is used to assist with testing of work context notifications
- * and the calling order. There is a static counter in this class that will
- * get incremented everytime someone creates an instance of this class.
- * The idea is to print the call order out during notifications of work
- * context releated calls of: workAccepted(), workStarted(), workCompleted(),
- * and contextSetupComplete().
- *
- * This class should NOT be used by other tests as it could throw the
- * count off. So unless you are sure you know what you're doing, refrain
- * from using this class.
- *
- * @see com.sun.ts.tests.com.sun.common.connector.whitebox.WorkListenerImpl2
- * @see com.sun.ts.tests.com.sun.common.connector.whitebox.TSSICWithListener
- *
- */
-public class Counter {
-
- public enum Action {
- INCREMENT, DECREMENT, DO_NOTHING
- };
-
- private static int count = 0;
-
- private static Action action = Action.DO_NOTHING;
-
- public Counter() {
- }
-
- /*
- * We are forcing the users to explicitly indicate if they want to increment,
- * decrement, or do nothing. The reasoning is to ensure that the user knows
- * exactly what they are doing when using this class/method.
- *
- * Since the primary use of this class/method is to record the current count
- * (usually during a work context notification call) we expect the users to
- * call this as: getCount(Counter.INCREMENT) so that the count is incremented
- * each time its called/used. The other Action types are only there for
- * completeness but no current use of them is expected.
- *
- */
- public int getCount(Action val) {
-
- Counter.action = val;
-
- if (action == Action.INCREMENT) {
- count++;
- } else if (action == Action.DECREMENT) {
- // this is allowed - but not likely so offer caution
- debug(
- "CAUTION: user invoked Counter(Action.DECREMENT) - verify this is correct.");
- count--;
- } else if (action == Action.DO_NOTHING) {
- // this is allowed - but not likely so offer caution
- debug(
- "CAUTION: user invoked Counter(Action.NOTHING) - verify this is correct.");
- }
-
- return count;
- }
-
- public void setCount(int val) {
- count = val;
- }
-
- public int increment() {
- return count++;
- }
-
- public int decrement() {
- return count--;
- }
-
- public static void resetCount() {
- count = 0;
- action = Action.DO_NOTHING;
- }
-
- private void debug(String str) {
- Debug.trace(str);
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/DataElement.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/DataElement.java
deleted file mode 100644
index 0785c3ecfa..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/DataElement.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-/*
- * @(#)DataElement.java 1.0 06/06/02
- */
-
-package com.sun.ts.tests.common.connector.whitebox;
-
-import javax.transaction.xa.Xid;
-
-/**
- * A DataElement in the Enterprise Information System(TSeis).
- *
- * @version 1.0, 06/06/02
- * @author Binod P.G
- */
-public class DataElement {
-
- /** Status indicating that the DataElement object is committed **/
- static final int COMMITTED = 1;
-
- /** Status indicating that the DataElement object prepared for 2PC **/
- static final int PREPARED = 2;
-
- /** Status indicating that the DataElement object is deleted **/
- static final int DELETED = 3;
-
- /**
- * Status indicating that the DataElement object is in the uncommitted state
- **/
- static final int INSERTED = 4;
-
- /**
- * Status indicating that the DataElement object is in the uncommitted state
- **/
- static final int UPDATED = 5;
-
- /** Current status of DataElement **/
- private int status;
-
- /** Key of this DataElement **/
- private String key;
-
- /** Actual Data of this DataElement **/
- private String data;
-
- /** Prepared Data of this DataElement **/
- private DataElement preparedData;
-
- /** Xid used to prepare this element **/
- private Xid xid;
-
- /** Version of this DataElement **/
- private int version;
-
- /**
- * If key and value is inserted, this constructor will be used to construct
- * the DataElement object.
- *
- * @param key
- * Key of the DataElement object.
- * @param data
- * Value of the DataElement object.
- */
- public DataElement(String key, String data) {
- this.key = key;
- this.data = data;
- version = 1;
- }
-
- /**
- * If only key is inserted, this constructor will be used to construct the
- * DataElement object.
- *
- * @param key
- * Key of the DataElement object.
- */
- public DataElement(String key) {
- this.key = key;
- version = 1;
- }
-
- /**
- * Sets the status of the object to the value provided.
- *
- * @param status
- * Status to be set.
- */
- public void setStatus(int status) {
- this.status = status;
- }
-
- /**
- * Get the status of the element.
- *
- * @return Current status of the DataElement object.
- */
- public int getStatus() {
- return status;
- }
-
- /**
- * Get the key of the DataElement object.
- *
- * @retrun Key of the DataElement object.
- */
- public String getKey() {
- return key;
- }
-
- /**
- * Get the data in the DataElement object.
- *
- * @retrun Value of the DataElement object.
- */
- public String getValue() {
- return data;
- }
-
- /**
- * Set the value of DataElement object.
- *
- * @param value
- * Value.
- */
- public void setValue(String value) {
- this.data = value;
- }
-
- /**
- * Prepare the value for 2PC commit.
- *
- * @param value
- * Value to be prepared.
- */
- public void prepare(DataElement value, Xid xid) {
- this.preparedData = value;
- this.xid = xid;
- this.status = PREPARED;
- }
-
- /**
- * Get the prepared data in the DataElement object.
- *
- * @retrun Prepared of the DataElement object.
- */
- public DataElement getPreparedValue() {
- return preparedData;
- }
-
- /**
- * Get the version of the data.
- *
- * @return version.
- */
- public int getVersion() {
- return version;
- }
-
- /**
- * Updates the version of the element.
- */
- public void updateVersion() {
- version++;
- }
-
- /**
- * Get the xid used to do the prepare.
- *
- * @return Xid.
- */
- public Xid getXid() {
- return xid;
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/Debug.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/Debug.java
deleted file mode 100644
index cdd9edb748..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/Debug.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (c) 2009, 2018 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.common.connector.whitebox;
-
-import com.sun.ts.lib.util.TestUtil;
-
-public class Debug {
-
- private static String debuggingProp = null;
-
- private static boolean bDebug = true; // debugging on by default
-
- private static int iDebugLevel = 0; // no debugging by default
-
- /**
- * Constructor
- */
- public Debug(String str) {
- debuggingProp = TestUtil.getSystemProperty(str);
- if ((debuggingProp != null) && (debuggingProp.equals("ON"))) {
- setDebugStatus(true); // turn tracing on
- trace("Debugging enabled");
- } else if ((debuggingProp != null) && (debuggingProp.equals("OFF"))) {
- trace("Debugging messages being disabled");
- setDebugStatus(false);
- }
- }
-
- public static void trace(String str) {
- if (getDebugStatus()) {
- // debugging is enabled so print info out
- System.out.println(str);
- }
- }
-
- /**
- * This is used to turn debugging off or on. This is off by default and must
- * be explicitly set to true in order to turn on debugging.
- *
- * @param bVal:
- * True means turn debugging on.
- */
- public static void setDebugStatus(boolean bVal) {
- bDebug = bVal;
- }
-
- /*
- * This is a convenience method used to test if we are running in debug mode.
- * If so, we will print the strack trace. If not, we do nothing.
- *
- * @exception none.
- *
- * @param none
- *
- * @version 1.32 07/31/00
- *
- * @return void
- */
- public static void printDebugStack(Exception ex) {
- if (getDebugStatus() == true) {
- ex.printStackTrace();
- }
- }
-
- /**
- * This gets the status of the debugging functionality. false means that
- * debugging is disabled, true means it is enabled.
- *
- * @return boolean: True means turn debugging on.
- */
- public static boolean getDebugStatus() {
- return bDebug;
- }
-
- /**
- * This gets the current level of debugging we are using.
- *
- * @return int: 0=none, 1=errors, 2=errors+warnings, 3=all
- */
-
- public static int getDebugLevel() {
- return iDebugLevel;
- }
-
- /**
- * This sets the current level of debugging we are using.
- *
- * @param val:
- * 0=none, 1=errors, 2=errors+warnings, 3=all
- * @return none.
- */
- public static void setDebugLevel(int val) {
- iDebugLevel = val;
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/LocalTransactionImpl.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/LocalTransactionImpl.java
deleted file mode 100644
index bac10eb29c..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/LocalTransactionImpl.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.connector.whitebox;
-
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-
-import jakarta.resource.ResourceException;
-import jakarta.resource.spi.EISSystemException;
-import jakarta.resource.spi.LocalTransaction;
-
-public class LocalTransactionImpl implements LocalTransaction {
-
- private TSManagedConnection mc;
-
- /*
- * @name LocalTransactionImpl
- *
- * @desc LocalTransactionImpl constructor
- *
- * @param TSManagedConnection
- */
- public LocalTransactionImpl(TSManagedConnection mc) {
- this.mc = mc;
- }
-
- /*
- * @name begin
- *
- * @desc sends the event that local transaction has started
- *
- * @exception ResourceException
- *
- */
- @Override
- public void begin() throws ResourceException {
- try {
- TSConnection con = mc.getTSConnection();
- ConnectorStatus.getConnectorStatus().logAPI("LocalTransaction.begin", "",
- "");
- con.setAutoCommit(false);
- System.out.println("LocalTransaction.begin");
- } catch (Exception ex) {
- ResourceException re = new EISSystemException(ex.getMessage());
- re.initCause(ex);
- throw re;
- }
- }
-
- /*
- * @name commit
- *
- * @desc Sends an event that local transaction has been commited.
- *
- * @exception ResourceException
- */
- @Override
- public void commit() throws ResourceException {
- TSConnection con = null;
- try {
- con = mc.getTSConnection();
- ConnectorStatus.getConnectorStatus().logAPI("LocalTransaction.commit", "",
- "");
- System.out.println("LocalTransaction.commit");
- con.commit();
- } catch (Exception ex) {
- ResourceException re = new EISSystemException(ex.getMessage());
- re.initCause(ex);
- throw re;
- } finally {
- try {
- if (con != null) {
- con.setAutoCommit(true);
- }
- } catch (Exception ex) {
- ex.getMessage();
- }
- }
- }
-
- /*
- * @name rollback
- *
- * @desc Sends an event to rollback the transaction
- *
- * @exception ResourceException
- */
- @Override
- public void rollback() throws ResourceException {
- TSConnection con = null;
- try {
- con = mc.getTSConnection();
- ConnectorStatus.getConnectorStatus().logAPI("LocalTransaction.rollback",
- "", "");
- con.rollback();
- } catch (Exception ex) {
- ResourceException re = new EISSystemException(ex.getMessage());
- re.initCause(ex);
- throw re;
- } finally {
- try {
- if (con != null) {
- con.setAutoCommit(true);
- }
- } catch (Exception ex) {
- }
- }
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/LocalTxActivationSpec.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/LocalTxActivationSpec.java
deleted file mode 100644
index 74adea7232..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/LocalTxActivationSpec.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.connector.whitebox;
-
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-
-import jakarta.resource.spi.ActivationSpec;
-import jakarta.resource.spi.ResourceAdapter;
-
-public class LocalTxActivationSpec
- implements ActivationSpec, java.io.Serializable {
-
- private String destinationName;
-
- private String destinationType;
-
- private ResourceAdapter resourceAdapter;
-
- private int counter = 0;
-
- /**
- * Default constructor.
- */
- public LocalTxActivationSpec() {
-
- }
-
- public String getDestinationName() {
- System.out.println(
- "LocalTxActivationSpec.getDestinationName :" + this.destinationName);
- return this.destinationName;
- }
-
- public void setDestinationName(String name) {
- this.destinationName = name;
- System.out.println("LocalTxActivationSpec.setDestinationName :" + name);
- }
-
- public String getDestinationType() {
- System.out.println(
- "LocalTxActivationSpec.getDestinationType :" + this.destinationType);
- return this.destinationType;
- }
-
- public void setDestinationType(String type) {
- System.out.println("LocalTxActivationSpec.setDestinationType :" + type);
- this.destinationType = type;
- }
-
- @Override
- public ResourceAdapter getResourceAdapter() {
- return this.resourceAdapter;
- }
-
- @Override
- public void setResourceAdapter(ResourceAdapter ra) {
- counter++;
- ConnectorStatus.getConnectorStatus()
- .logState("LocalTxActivationSpec setResourceAdapter " + counter);
- System.out.println("LocalTxActivationSpec.setResourceAdatper called");
- this.resourceAdapter = ra;
- }
-
- @Override
- public void validate() {
- throw new UnsupportedOperationException();
- }
-
- public void setCounter(int val) {
- this.counter = val;
- }
-
- public int getCounter() {
- return this.counter;
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/LocalTxManagedConnectionFactory.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/LocalTxManagedConnectionFactory.java
deleted file mode 100644
index dc5bf3faf5..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/LocalTxManagedConnectionFactory.java
+++ /dev/null
@@ -1,395 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.connector.whitebox;
-
-import java.io.PrintWriter;
-import java.io.Serializable;
-import java.util.Iterator;
-import java.util.Set;
-
-import javax.security.auth.Subject;
-
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-
-import jakarta.resource.ResourceException;
-import jakarta.resource.spi.ConnectionManager;
-import jakarta.resource.spi.ConnectionRequestInfo;
-import jakarta.resource.spi.EISSystemException;
-import jakarta.resource.spi.ManagedConnection;
-import jakarta.resource.spi.ManagedConnectionFactory;
-import jakarta.resource.spi.ResourceAdapter;
-import jakarta.resource.spi.ResourceAdapterAssociation;
-import jakarta.resource.spi.security.PasswordCredential;
-
-@SuppressWarnings("unused")
-public class LocalTxManagedConnectionFactory
- implements ManagedConnectionFactory, ResourceAdapterAssociation,
- Serializable, jakarta.resource.Referenceable {
-
- private javax.naming.Reference reference;
-
- private ResourceAdapter resourceAdapter;
-
- private int count;
-
- private String password;
-
- private String user;
-
- private String userName;
-
- private String TSRValue;
-
- /*
- * @name LocalTxManagedConnectionFactory
- *
- * @desc Default conctructor
- */
- public LocalTxManagedConnectionFactory() {
- }
-
- public String getUser() {
- return user;
- }
-
- public void setUser(String val) {
- user = val;
- }
-
- public String getUserName() {
- return userName;
- }
-
- public void setUserName(String val) {
- userName = val;
- }
-
- public String getPassword() {
- return password;
- }
-
- public void setPassword(String val) {
- password = val;
- }
-
- /*
- * @name createConnectionFactory
- *
- * @desc Creates a new connection factory instance
- *
- * @param ConnectionManager
- *
- * @return Object
- *
- * @exception ResourceException
- */
-
- @Override
- public Object createConnectionFactory(ConnectionManager cxManager)
- throws ResourceException {
- ConnectorStatus.getConnectorStatus().logAPI(
- "LocalTxManagedConnectionFactory.createConnectionFactory", "cxManager",
- "TSEISDataSource");
- return new TSEISDataSource(this, cxManager);
- }
-
- /*
- * @name createConnectionFactory
- *
- * @desc Creates a new connection factory instance
- *
- * @return Object
- *
- * @exception ResourceException
- */
-
- @Override
- public Object createConnectionFactory() throws ResourceException {
- ConnectorStatus.getConnectorStatus().logAPI(
- "LocalTxManagedConnectionFactory.createConnectionFactory", "",
- "TSEISDataSource");
- return new TSEISDataSource(this, null);
- }
-
- /*
- * @name setResourceAdapter
- *
- * @desc sets the Resource Adapter for this ManagedConnectionFactory
- *
- * @return
- *
- * @exception ResourceException
- */
- @Override
- public void setResourceAdapter(ResourceAdapter ra) throws ResourceException {
- count++;
- String newStr1 = "LocalTxManagedConnectionFactory setResourceAdapter "
- + count;
- System.out.println(newStr1);
- ConnectorStatus.getConnectorStatus().logState(newStr1);
- this.resourceAdapter = ra;
- }
-
- /*
- * @name getResourceAdapter
- *
- * @desc gets the Resource Adapter for this ManagedConnectionFactory
- *
- * @return Object
- *
- * @exception ResourceException
- */
- @Override
- public ResourceAdapter getResourceAdapter() {
- return resourceAdapter;
- }
-
- /*
- * @name createManagedConnection
- *
- * @desc Creates a new managed connection to the underlying EIS
- *
- * @param Subject, ConnectionRequestInfo
- *
- * @return ManagedConnection
- *
- * @exception ResourceException
- */
- @Override
- public ManagedConnection createManagedConnection(Subject subject,
- ConnectionRequestInfo info) throws ResourceException {
-
- try {
-
- ConnectorStatus.getConnectorStatus().logAPI(
- "LocalTxManagedConnectionFactory.createManagedConnection",
- "subject|info", "TSManagedConnection");
- TSConnection con = null;
- PasswordCredential pc = Util.getPasswordCredential(this, subject, info);
- if (pc == null) {
- System.out.println(
- "LocalTxManagedConnectionFactory.createManagedConnection(): pc == null");
- System.out.println("TSConnectionImpl.getConnection()");
- con = new TSConnectionImpl().getConnection();
- } else {
- System.out.println(
- "LocalTxManagedConnectionFactory.createManagedConnection(): pc != null");
- setUser(pc.getUserName());
- setUserName(pc.getUserName());
- setPassword(new String(pc.getPassword()));
- System.out.println(
- "LocalTxManagedConnectionFactory.createManagedConnection() with pc.getUserName()="
- + pc.getUserName() + " pc.getPassword()="
- + new String(pc.getPassword()));
- con = new TSConnectionImpl().getConnection(pc.getUserName(),
- pc.getPassword());
- }
- TSManagedConnection tcon = new TSManagedConnection(this, pc, null, con,
- false, true);
-
- // just send some info to the log to assist with API assertion checks
- APIAssertionTest.checkMetaDataAPI(tcon.getMetaData());
- APIAssertionTest.checkManagedConnectionAPI(tcon);
- return tcon;
- } catch (Exception ex) {
- ResourceException re = new EISSystemException(
- "Exception: " + ex.getMessage());
- re.initCause(ex);
- throw re;
- }
-
- }
-
- /*
- * @name matchManagedConnection
- *
- * @desc Return the existing connection from the connection pool
- *
- * @param Set, Subject, ConnectionRequestInfo
- *
- * @return ManagedConnection
- *
- * @exception ResourceException
- */
- @Override
- public ManagedConnection matchManagedConnections(Set connectionSet,
- Subject subject, ConnectionRequestInfo info) throws ResourceException {
- ConnectorStatus.getConnectorStatus().logAPI(
- "LocalTxManagedConnectionFactory.matchManagedConnection",
- "connectionSet|subject|info", "TSEISDataSource");
- PasswordCredential pc = Util.getPasswordCredential(this, subject, info);
- Iterator it = connectionSet.iterator();
- while (it.hasNext()) {
- Object obj = it.next();
- if (obj instanceof TSManagedConnection) {
- TSManagedConnection mc = (TSManagedConnection) obj;
- ManagedConnectionFactory mcf = mc.getManagedConnectionFactory();
- if (Util.isPasswordCredentialEqual(mc.getPasswordCredential(), pc)
- && mcf.equals(this)) {
- return mc;
- }
- }
- }
- return null;
- }
-
- /*
- * @name setLogWriter
- *
- * @desc Sets the Print Writer
- *
- * @param PrintWriter
- *
- * @exception ResourceException
- */
- @Override
- public void setLogWriter(PrintWriter out) throws ResourceException {
- ConnectorStatus.getConnectorStatus()
- .logAPI("LocalTxManagedConnectionFactory.setLogWriter", "out", "");
- }
-
- /*
- * @name getLogWriter
- *
- * @desc Gets the Print Writer
- *
- * @return PrintWriter
- *
- * @exception ResourceException
- */
- @Override
- public PrintWriter getLogWriter() throws ResourceException {
- ConnectorStatus.getConnectorStatus()
- .logAPI("LocalTxManagedConnectionFactory.getLogWriter", "", "");
- return null;
- }
-
- /*
- * @name equals
- *
- * @desc Compares the given object to the ManagedConnectionFactory instance.
- *
- * @param Object
- *
- * @return boolean
- */
- @Override
- public boolean equals(Object obj) {
- if ((obj == null) || !(obj instanceof LocalTxManagedConnectionFactory)) {
- return false;
- }
- if (obj == this) {
- return true;
- }
-
- LocalTxManagedConnectionFactory that = (LocalTxManagedConnectionFactory) obj;
-
- if ((this.reference != null)
- && !(this.reference.equals(that.getReference()))) {
- return false;
- } else if ((this.reference == null) && !(that.getReference() == null)) {
- return false;
- }
-
- if ((this.resourceAdapter != null)
- && !(this.resourceAdapter.equals(that.getResourceAdapter()))) {
- return false;
- } else if ((this.resourceAdapter == null)
- && !(that.getResourceAdapter() == null)) {
- return false;
- }
-
- if (this.count != that.getCount()) {
- return false;
- }
-
- if (!Util.isEqual(this.password, that.getPassword()))
- return false;
-
- if (!Util.isEqual(this.user, that.getUser()))
- return false;
-
- if (!Util.isEqual(this.userName, that.getUserName()))
- return false;
-
- if (!Util.isEqual(this.TSRValue, that.getTSRValue()))
- return false;
-
- return true;
- }
-
- /*
- * @name hashCode
- *
- * @desc Gives a hash value to a ManagedConnectionFactory Obejct.
- *
- * @return int
- */
-
- @Override
- public int hashCode() {
- return this.getClass().getName().hashCode();
- }
-
- /*
- * @name getReference
- *
- * @desc Gives the reference of the class
- *
- * @return javax.naming.Reference
- */
- @Override
- public javax.naming.Reference getReference() {
- javax.naming.Reference ref;
-
- ref = this.reference;
- return ref;
- }
-
- /*
- * @name setReference
- *
- * @desc sets the reference of the class
- *
- * @param javax.naming.Reference
- */
- @Override
- public void setReference(javax.naming.Reference ref) {
- this.reference = ref;
- }
-
- public void setTSRValue(String name) {
- this.TSRValue = name;
- }
-
- public String getTSRValue() {
- return TSRValue;
- }
-
- public int getCount() {
- return this.count;
- }
-
- public void setCount(int val) {
- this.count = val;
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/LocalTxMessageListener.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/LocalTxMessageListener.java
deleted file mode 100644
index 4bfe93d4fd..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/LocalTxMessageListener.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.connector.whitebox;
-
-import javax.transaction.xa.XAException;
-
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-
-import jakarta.resource.spi.BootstrapContext;
-import jakarta.resource.spi.XATerminator;
-import jakarta.resource.spi.work.WorkEvent;
-import jakarta.resource.spi.work.WorkListener;
-
-public class LocalTxMessageListener implements WorkListener {
-
- private XidImpl xid;
-
- private BootstrapContext bsc;
-
- public LocalTxMessageListener(XidImpl xid, BootstrapContext bsc) {
- this.xid = xid;
- this.bsc = bsc;
- }
-
- @Override
- public void workAccepted(WorkEvent e) {
- ConnectorStatus.getConnectorStatus()
- .logState("LocalTxMessageListener.workAccepted");
- System.out.println("LocalTxMessageListener.workAccepted");
- }
-
- @Override
- public void workRejected(WorkEvent e) {
- ConnectorStatus.getConnectorStatus()
- .logState("LocalTxMessageListener.workRejected");
- System.out.println("LocalTxMessageListener.workRejected");
- }
-
- @Override
- public void workStarted(WorkEvent e) {
- ConnectorStatus.getConnectorStatus()
- .logState("LocalTxMessageListener.workStarted");
- System.out.println("LocalTxMessageListener.workStarted");
- }
-
- @Override
- public void workCompleted(WorkEvent e) {
- try {
- XATerminator xt = bsc.getXATerminator();
- xt.commit(this.xid, true);
- System.out.println("LocalTxMessageListener.workCompleted");
- System.out.println(
- "XID getting used in XATerminator [ " + xid.getFormatId() + " ]");
- ConnectorStatus.getConnectorStatus()
- .logState("LocalTxMessageListener committed Xid");
- } catch (XAException ex) {
- ex.printStackTrace();
- }
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/LocalTxMessageWork.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/LocalTxMessageWork.java
deleted file mode 100644
index 5bf5a676d8..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/LocalTxMessageWork.java
+++ /dev/null
@@ -1,325 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.connector.whitebox;
-
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
-
-import com.sun.ts.tests.common.connector.util.AppException;
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-import com.sun.ts.tests.common.connector.util.TSMessageListenerInterface;
-
-import jakarta.resource.ResourceException;
-import jakarta.resource.spi.BootstrapContext;
-import jakarta.resource.spi.UnavailableException;
-import jakarta.resource.spi.endpoint.MessageEndpoint;
-import jakarta.resource.spi.endpoint.MessageEndpointFactory;
-import jakarta.resource.spi.work.Work;
-import jakarta.resource.spi.work.WorkContext;
-import jakarta.resource.spi.work.WorkContextProvider;
-
-public class LocalTxMessageWork implements Work, WorkContextProvider {
-
- private String name;
-
- private boolean stop = false;
-
- private MessageEndpointFactory factory;
-
- private LocalTxMessageXAResource msgxa = new LocalTxMessageXAResource(
- "LocalTxMessageXAResource");
-
- private MessageEndpoint ep2;
-
- private List contextsList = new ArrayList();
-
- private BootstrapContext ctx = null;
-
- /*
- * XXXX private WorkManager wm = null; private XATerminator xa; private String
- * sicUser = ""; // this should correspond to ts.jte's 'user' property private
- * String sicPwd = ""; // this should correspond to ts.jte's 'password'
- * property private String eisUser = ""; // this should correspond to ts.jte's
- * 'user1' property private String eisPwd = ""; // this should correspond to
- * ts.jte's 'password' property
- */
- private final String SICFAIL = "mdb not executed with proper SIC principal";
-
- private final String SICPASS = "mdb executed with proper SIC principal";
-
- public LocalTxMessageWork(String name, MessageEndpointFactory factory) {
- this.factory = factory;
- this.name = name;
-
- /*
- * XXXX this.sicUser = System.getProperty("j2eelogin.name"); this.sicPwd =
- * System.getProperty("j2eelogin.password"); this.eisUser =
- * System.getProperty("eislogin.name"); this.eisPwd =
- * System.getProperty("eislogin.password");
- */
- debug("LocalTxMessageWork.constructor");
- }
-
- public void setBootstrapContext(BootstrapContext bsc) {
- this.ctx = bsc;
- /*
- * XXXX this.wm = bsc.getWorkManager(); this.xa = ctx.getXATerminator();
- */
- }
-
- /*
- * This is a privaet convenience method that is use for sending a message that
- * contains some role information to the mdb. The mdb will be looking for a
- * msg that begins with the string "ROLE". Once the mdb encounters this msg,
- * it will perform a specific test and then send back a response to us via a
- * AppException that we will want to log. This method is used to assist with
- * checking assertions Connector:SPEC:232 and Connector:SPEC:233. (This is
- * used in conjunction with connector/mdb/MessageBean.java)
- */
- private void doSICMsgCheck(MessageEndpoint ep, Method onMessage) {
-
- try {
-
- ep.beforeDelivery(onMessage);
- String message = "ROLE: ADM";
-
- ((TSMessageListenerInterface) ep).onMessage(message);
- } catch (AppException ex) {
- String str = ex.getMessage();
- debug("str = " + str);
- if ((str != null) && (str.equals("MDB-SIC SUCCESS"))) {
- debug(SICPASS);
- ConnectorStatus.getConnectorStatus().logState(SICPASS);
- } else {
- debug(
- "MDB-SIC FAILED due to AppException with msg: " + ex.getMessage());
- debug(SICFAIL);
- ex.printStackTrace();
- ConnectorStatus.getConnectorStatus().logState(SICFAIL);
- }
- } catch (Exception e) {
- // problem if here - we had some problem with msg exchange with MDB.
- debug("MDB-SIC FAILED due to Exception with msg: " + e.getMessage());
- debug(SICFAIL);
- e.printStackTrace();
- ConnectorStatus.getConnectorStatus().logState(SICFAIL);
- } finally {
- try {
- ep.afterDelivery();
- } catch (ResourceException re2) {
- re2.printStackTrace();
- }
- }
- }
-
- public void run() {
-
- while (!stop) {
- try {
- debug("Inside the LocalTxMessageWork run ");
- // Createing ep and ep1 for comparison
-
- MessageEndpoint ep = factory.createEndpoint(null);
- MessageEndpoint ep1 = factory.createEndpoint(null);
-
- ep2 = factory.createEndpoint(null);
- // creating xaep to check if the message delivery is transacted.
- MessageEndpoint xaep = factory.createEndpoint(msgxa);
-
- if ((ep != null) && (!ep.equals(ep1))) {
- ConnectorStatus.getConnectorStatus()
- .logState("LocalTx Unique MessageEndpoint returned");
- }
-
- chkMessageEndpointImpl(ep);
-
- Method onMessage = getOnMessageMethod();
- ep.beforeDelivery(onMessage);
- ((TSMessageListenerInterface) ep).onMessage("LocalTx Message To MDB");
- ep.afterDelivery();
- ConnectorStatus.getConnectorStatus().logState("LocalTx Message To MDB");
-
- doSICMsgCheck(ep, onMessage);
-
- Method onMessagexa = getOnMessageMethod();
- xaep.beforeDelivery(onMessagexa);
- ((TSMessageListenerInterface) xaep)
- .onMessage("LocalTx Non Transacted Message To MDB1");
- xaep.afterDelivery();
-
- ConnectorStatus.getConnectorStatus()
- .logState("LocalTx Non Transacted Message To MDB1");
-
- System.out.println("Calling sysExp()");
-
- callSysExp();
- callAppExp();
-
- boolean de = factory.isDeliveryTransacted(onMessagexa);
-
- if (!de) {
- System.out.println("MDB1 delivery is not transacted");
- ConnectorStatus.getConnectorStatus()
- .logState("LocalTx MDB1 delivery is not transacted");
- }
-
- break;
- } catch (AppException ex) {
-
- ex.printStackTrace();
- } catch (UnavailableException ex) {
- try {
- Thread.currentThread().sleep(3000);
- } catch (Exception e) {
- e.printStackTrace();
- }
- } catch (NoSuchMethodException nse) {
- nse.printStackTrace();
- } catch (ResourceException re) {
- re.printStackTrace();
- }
-
- }
-
- }
-
- public void callSysExp() {
-
- try {
- Method onMessage = getOnMessageMethod();
- ep2.beforeDelivery(onMessage);
- ((TSMessageListenerInterface) ep2)
- .onMessage("Throw EJBException from NotSupported");
- // this has been moved to finally clause to ensure that before and
- // after delivery calls are properly matched.
- // ep2.afterDelivery();
- } catch (NoSuchMethodException e) {
- debug("LocalTxMessageWork: NoSuchMethodException");
- e.getMessage();
- e.printStackTrace();
- } catch (UnavailableException e) {
- debug("LocalTxMessageWork: UnavailableException");
- e.printStackTrace();
- } catch (ResourceException re) {
- debug("LocalTxMessageWork: ResourceException");
- re.printStackTrace();
- } catch (AppException ae) {
- debug("LocalTxMessageWork: AppException");
- ae.printStackTrace();
- } catch (Exception e) {
- // if we are in here, we assume our exception is expected and is of type
- // ejb
- // but it could also be from a non-ejb POJO - thus we use this Exception
- // type.
- debug("EJBException thrown by NotSupported MDB");
- ConnectorStatus.getConnectorStatus()
- .logState("EJBException thrown by NotSupported");
- } finally {
- try {
- ep2.afterDelivery();
- } catch (ResourceException re2) {
- re2.printStackTrace();
- }
- }
-
- }
-
- public void callAppExp() {
-
- try {
- Method onMessage = getOnMessageMethod();
- ep2.beforeDelivery(onMessage);
- ((TSMessageListenerInterface) ep2)
- .onMessage("Throw AppException from NotSupported");
- // this has been moved to finally clause to ensure that before and
- // after delivery calls are properly matched.
- // ep2.afterDelivery();
- } catch (AppException ejbe) {
- debug("AppException thrown by NotSupported MDB");
- ConnectorStatus.getConnectorStatus()
- .logState("AppException thrown by NotSupported");
- } catch (NoSuchMethodException ns) {
- ns.printStackTrace();
- } catch (ResourceException re) {
- re.printStackTrace();
- } finally {
- try {
- ep2.afterDelivery();
- } catch (ResourceException re2) {
- re2.printStackTrace();
- }
- }
- }
-
- public Method getOnMessageMethod() {
-
- Method onMessageMethod = null;
- try {
- Class msgListenerClass = TSMessageListenerInterface.class;
- Class[] paramTypes = { java.lang.String.class };
- onMessageMethod = msgListenerClass.getMethod("onMessage", paramTypes);
-
- } catch (NoSuchMethodException ex) {
- ex.printStackTrace();
- }
- return onMessageMethod;
- }
-
- private void chkMessageEndpointImpl(MessageEndpoint ep) {
- if (ep instanceof MessageEndpoint
- && ep instanceof TSMessageListenerInterface) {
- ConnectorStatus.getConnectorStatus()
- .logState("LocalTx MessageEndpoint interface implemented");
- ConnectorStatus.getConnectorStatus()
- .logState("LocalTx TSMessageListener interface implemented");
- } else {
- ConnectorStatus.getConnectorStatus().logState(
- "MessageEndpoint and TSMessageListenerInterface not implemented");
- }
- }
-
- @Override
- public List getWorkContexts() {
- return contextsList;
- }
-
- public void addWorkContext(WorkContext ic) {
- contextsList.add(ic);
- }
-
- @Override
- public void release() {
- }
-
- public void stop() {
- this.stop = true;
- }
-
- public String toString() {
- return name;
- }
-
- private void debug(String val) {
- Debug.trace(val);
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/LocalTxMessageWork1.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/LocalTxMessageWork1.java
deleted file mode 100644
index 27f02fb209..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/LocalTxMessageWork1.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.connector.whitebox;
-
-import java.lang.reflect.Method;
-
-import com.sun.ts.tests.common.connector.util.AppException;
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-import com.sun.ts.tests.common.connector.util.TSMessageListenerInterface;
-
-import jakarta.resource.ResourceException;
-import jakarta.resource.spi.UnavailableException;
-import jakarta.resource.spi.endpoint.MessageEndpoint;
-import jakarta.resource.spi.endpoint.MessageEndpointFactory;
-import jakarta.resource.spi.work.Work;
-
-public class LocalTxMessageWork1 implements Work {
-
- private String name;
-
- private boolean stop = false;
-
- private MessageEndpointFactory factory;
-
- private LocalTxMessageXAResource msgxa = new LocalTxMessageXAResource(
- "LocalTxMessageXAResource1");
-
- private MessageEndpoint xaep;
-
- private MessageEndpoint ep2;
-
- public LocalTxMessageWork1(String name, MessageEndpointFactory factory) {
- this.factory = factory;
- this.name = name;
- System.out.println("LocalTxMessageWork1.constructor");
-
- }
-
- public void run() {
-
- while (!stop) {
- try {
- System.out.println("Inside the LocalTxMessageWork1 run ");
- // creating xaep to check if the message delivery is transacted.
- xaep = factory.createEndpoint(msgxa);
-
- ep2 = factory.createEndpoint(null);
-
- Method onMessagexa = getOnMessageMethod();
- xaep.beforeDelivery(onMessagexa);
- ((TSMessageListenerInterface) xaep)
- .onMessage("LocalTx MDB2 Transacted Message To MDB");
- xaep.afterDelivery();
- ConnectorStatus.getConnectorStatus()
- .logState("LocalTx MDB2 Transacted Message To MDB");
-
- callSysExp();
- callAppExp();
-
- System.out.println("LocalTx MDB2 Transacted Message To MDB");
-
- boolean de = factory.isDeliveryTransacted(onMessagexa);
-
- if (de) {
- ConnectorStatus.getConnectorStatus()
- .logState("LocalTx MDB2 delivery is transacted");
- System.out.println("LocalTx MDB2 delivery is transacted");
- }
- break;
- } catch (AppException ex) {
- ex.printStackTrace();
- }
-
- catch (NoSuchMethodException e) {
- e.printStackTrace();
- }
-
- catch (UnavailableException ex) {
- try {
- Thread.currentThread().sleep(3000);
- } catch (Exception e) {
- e.printStackTrace();
- }
- } catch (ResourceException re) {
- re.printStackTrace();
- }
-
- }
-
- }
-
- public void callSysExp() {
-
- try {
- Method onMessage = getOnMessageMethod();
- ep2.beforeDelivery(onMessage);
- ((TSMessageListenerInterface) ep2)
- .onMessage("Throw EJBException from Required");
- // this has been moved to finally clause to ensure that before and
- // after delivery calls are properly matched.
- // ep2.afterDelivery();
- } catch (NoSuchMethodException e) {
- System.out.println("LocalTxMessageWork1: NoSuchMethodException");
- e.getMessage();
- e.printStackTrace();
- } catch (UnavailableException e) {
- System.out.println("LocalTxMessageWork1: UnavailableException");
- e.printStackTrace();
- } catch (ResourceException re) {
- System.out.println("LocalTxMessageWork1: ResourceException");
- re.printStackTrace();
- } catch (AppException ae) {
- System.out.println("LocalTxMessageWork1: AppException");
- ae.printStackTrace();
- } catch (Exception e) {
- // if we are in here, we will assume that our exception was of type ejb
- // but it
- // could also be from a non-ejb POJO - thus we use this Exception type.
- System.out.println("EJBException thrown by Required");
- ConnectorStatus.getConnectorStatus()
- .logState("EJBException thrown by Required");
- e.printStackTrace();
- } finally {
- try {
- ep2.afterDelivery();
- } catch (ResourceException re2) {
- re2.printStackTrace();
- }
- }
-
- }
-
- public void callAppExp() {
-
- try {
- Method onMessage = getOnMessageMethod();
- ep2.beforeDelivery(onMessage);
- ((TSMessageListenerInterface) ep2)
- .onMessage("Throw AppException from Required");
- // this has been moved to finally clause to ensure that before and
- // after delivery calls are properly matched.
- // ep2.afterDelivery();
- } catch (AppException ejbe) {
- System.out.println("AppException thrown by Required MDB");
- ConnectorStatus.getConnectorStatus()
- .logState("AppException thrown by Required");
- } catch (NoSuchMethodException ns) {
- ns.printStackTrace();
- } catch (ResourceException re) {
- re.printStackTrace();
- } finally {
- try {
- ep2.afterDelivery();
- } catch (ResourceException re2) {
- re2.printStackTrace();
- }
- }
-
- }
-
- public Method getOnMessageMethod() {
-
- Method onMessageMethod = null;
- try {
- Class msgListenerClass = TSMessageListenerInterface.class;
- Class[] paramTypes = { java.lang.String.class };
- onMessageMethod = msgListenerClass.getMethod("onMessage", paramTypes);
-
- } catch (NoSuchMethodException ex) {
- ex.printStackTrace();
- }
- return onMessageMethod;
- }
-
- @Override
- public void release() {
- }
-
- public void stop() {
- this.stop = true;
- }
-
- public String toString() {
- return name;
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/LocalTxMessageWork2.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/LocalTxMessageWork2.java
deleted file mode 100644
index f39d368780..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/LocalTxMessageWork2.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.connector.whitebox;
-
-import java.lang.reflect.Method;
-
-import com.sun.ts.tests.common.connector.util.AppException;
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-import com.sun.ts.tests.common.connector.util.TSMessageListenerInterface;
-
-import jakarta.resource.spi.UnavailableException;
-import jakarta.resource.spi.endpoint.MessageEndpoint;
-import jakarta.resource.spi.endpoint.MessageEndpointFactory;
-import jakarta.resource.spi.work.Work;
-
-public class LocalTxMessageWork2 implements Work {
-
- private String name;
-
- private boolean stop = false;
-
- private MessageEndpointFactory factory;
-
- private LocalTxMessageXAResource msgxa = new LocalTxMessageXAResource(
- "LocalTxMessageXAResource2");
-
- public LocalTxMessageWork2(String name, MessageEndpointFactory factory) {
- this.factory = factory;
- this.name = name;
- System.out.println("LocalTxMessageWork2.constructor");
- }
-
- public void run() {
-
- while (!stop) {
- try {
-
- // creating xaep to check if the message delivery is transacted.
- MessageEndpoint xaep = factory.createEndpoint(msgxa);
- MessageEndpoint xaep1 = factory.createEndpoint(msgxa);
- MessageEndpoint xaep2 = factory.createEndpoint(msgxa);
-
- Method onMessagexa = getOnMessageMethod();
- ((TSMessageListenerInterface) xaep)
- .onMessage("LocalTx MDB2 Transacted Message1");
- ((TSMessageListenerInterface) xaep1)
- .onMessage("LocalTx MDB2 Transacted Message2");
- ((TSMessageListenerInterface) xaep2)
- .onMessage("LocalTx MDB2 Transacted Message3");
-
- ConnectorStatus.getConnectorStatus()
- .logState("LocalTx MDB2 Transacted Message1");
- ConnectorStatus.getConnectorStatus()
- .logState("LocalTx MDB2 Transacted Message2");
- ConnectorStatus.getConnectorStatus()
- .logState("LocalTx MDB2 Transacted Message3");
-
- break;
- } catch (AppException ex) {
- ex.printStackTrace();
- } catch (UnavailableException ex) {
- try {
- Thread.currentThread().sleep(3000);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
-
- }
-
- public Method getOnMessageMethod() {
-
- Method onMessageMethod = null;
- try {
- Class msgListenerClass = TSMessageListenerInterface.class;
- Class[] paramTypes = { java.lang.String.class };
- onMessageMethod = msgListenerClass.getMethod("onMessage", paramTypes);
-
- } catch (NoSuchMethodException ex) {
- ex.printStackTrace();
- }
- return onMessageMethod;
- }
-
- @Override
- public void release() {
- }
-
- public void stop() {
- this.stop = true;
- }
-
- public String toString() {
- return name;
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/LocalTxMessageXAResource.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/LocalTxMessageXAResource.java
deleted file mode 100644
index 50d4cfaef9..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/LocalTxMessageXAResource.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.connector.whitebox;
-
-import javax.transaction.xa.XAException;
-import javax.transaction.xa.XAResource;
-import javax.transaction.xa.Xid;
-
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-
-/**
- * Be careful..... This class will log a variety of message strings that will be
- * used by client side tests. If you change any strings in this class, it is
- * likely to result in test failures unless you are sure you know what tests you
- * are affecting.
- */
-public class LocalTxMessageXAResource implements XAResource {
- String sHeader = "SomeDefault";
-
- public LocalTxMessageXAResource() {
- Debug.trace("LocalTxMessageXAResource constructor");
- }
-
- /*
- * This constructor takes a string val. The passed in string is a unique
- * string that will be used in client side test verifications. Making changes
- * to the passed in string val is likely to result in test failures - so don't
- * muck with the value unless you know exactly what tests you are affecting..
- */
- public LocalTxMessageXAResource(String val) {
- sHeader = val;
- Debug.trace(sHeader + " constructor");
- }
-
- private void handleResourceException(Exception ex) throws XAException {
-
- XAException xae = new XAException(ex.toString());
- xae.errorCode = XAException.XAER_RMERR;
- throw xae;
- }
-
- @Override
- public void commit(Xid xid, boolean onePhase) throws XAException {
- try {
- String str1 = sHeader + ".commit";
- ConnectorStatus.getConnectorStatus().logState(str1);
- Debug.trace(str1);
- } catch (Exception ex) {
- handleResourceException(ex);
- }
- }
-
- @Override
- public void start(Xid xid, int flags) throws XAException {
- try {
- String str1 = sHeader + ".start"; // e.g. "LocalTxMessageXAResource.start"
- Debug.trace(str1);
- ConnectorStatus.getConnectorStatus().logState(str1);
- } catch (Exception ex) {
- handleResourceException(ex);
- }
- }
-
- @Override
- public void end(Xid xid, int flags) throws XAException {
- try {
- String str1 = sHeader + ".end"; // e.g. "LocalTxMessageXAResource.end"
- Debug.trace(str1);
- ConnectorStatus.getConnectorStatus().logState(str1);
- } catch (Exception ex) {
- handleResourceException(ex);
- }
- }
-
- @Override
- public void forget(Xid xid) throws XAException {
- String str1 = sHeader + ".forget"; // e.g. "LocalTxMessageXAResource.forget"
- Debug.trace(str1);
- }
-
- @Override
- public int getTransactionTimeout() throws XAException {
- return 1;
- }
-
- @Override
- public boolean isSameRM(XAResource other) throws XAException {
- String str1 = sHeader + ".isSameRM"; // e.g.
- // "LocalTxMessageXAResource.isSameRM"
- Debug.trace(str1);
- return false;
- }
-
- @Override
- public int prepare(Xid xid) throws XAException {
- String str1 = sHeader + ".prepare"; // e.g.
- // "LocalTxMessageXAResource.prepare"
- ConnectorStatus.getConnectorStatus().logAPI(str1, "", "");
- Debug.trace(str1);
- try {
- return XAResource.XA_OK;
- } catch (Exception ex) {
- handleResourceException(ex);
- return XAException.XAER_RMERR;
- }
- }
-
- @Override
- public Xid[] recover(int flag) throws XAException {
- String str1 = sHeader + ".recover"; // e.g.
- // "LocalTxMessageXAResource.recover"
- Debug.trace(str1);
- return null;
- }
-
- @Override
- public void rollback(Xid xid) throws XAException {
- try {
- Debug.trace(sHeader + ".rollback");
- } catch (Exception ex) {
- handleResourceException(ex);
- }
- }
-
- @Override
- public boolean setTransactionTimeout(int seconds) throws XAException {
- return true;
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/LocalTxResourceAdapterImpl.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/LocalTxResourceAdapterImpl.java
deleted file mode 100644
index da39d9b5ce..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/LocalTxResourceAdapterImpl.java
+++ /dev/null
@@ -1,454 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.connector.whitebox;
-
-import java.io.Serializable;
-import java.lang.reflect.Method;
-
-import javax.transaction.xa.XAResource;
-
-import com.sun.ts.lib.util.TestUtil;
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-import com.sun.ts.tests.common.connector.util.TSMessageListenerInterface;
-
-import jakarta.resource.spi.ActivationSpec;
-import jakarta.resource.spi.BootstrapContext;
-import jakarta.resource.spi.ResourceAdapter;
-import jakarta.resource.spi.ResourceAdapterInternalException;
-import jakarta.resource.spi.endpoint.MessageEndpointFactory;
-import jakarta.resource.spi.work.DistributableWorkManager;
-import jakarta.resource.spi.work.ExecutionContext;
-import jakarta.resource.spi.work.Work;
-import jakarta.resource.spi.work.WorkManager;
-
-public class LocalTxResourceAdapterImpl
- implements ResourceAdapter, Serializable {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- // IMPORTANT: for compliance, if you add non-transient member data
- // here, be sure to add respective entry to equals() method below.
-
- private transient TestWorkManager twm;
-
- private transient TestBootstrapContext tbs;
-
- private transient LocalTxMessageListener ml;
-
- private String RAName; // value from ra's xml file
-
- private Boolean useSecurityMapping = null; // value from ra's xml file
-
- private int counter = 0;
-
- private transient LocalTxMessageWork work1;
-
- private transient LocalTxMessageWork1 work2;
-
- private transient LocalTxMessageWork2 work3;
-
- private transient WorkManager wm;
-
- private int mefcount = 0;
-
- private transient MessageEndpointFactory mef1;
-
- private transient MessageEndpointFactory mef2;
-
- private transient BootstrapContext bsc;
-
- private String sicUser = ""; // this should correspond to ts.jte's 'user'
- // property
-
- private String sicPwd = ""; // this should correspond to ts.jte's 'password'
- // property
-
- private String eisUser = ""; // this should correspond to ts.jte's 'user1'
- // property
-
- private String eisPwd = ""; // this should correspond to ts.jte's 'password'
- // property
-
- public LocalTxResourceAdapterImpl() {
- ConnectorStatus.getConnectorStatus()
- .logState("LocalTxResourceAdapterImpl Constructor ");
- Debug.trace("LocalTxResourceAdapterImpl Constructor ");
-
- this.sicUser = TestUtil.getSystemProperty("j2eelogin.name");
- this.sicPwd = TestUtil.getSystemProperty("j2eelogin.password");
- this.eisUser = TestUtil.getSystemProperty("eislogin.name");
- this.eisPwd = TestUtil.getSystemProperty("eislogin.password");
- }
-
- @Override
- public void start(final BootstrapContext bsc)
- throws ResourceAdapterInternalException {
- // setup network endpoints
- counter++;
- this.bsc = bsc;
- Debug.trace("LocalTxResourceAdapter Started " + counter);
- String str1 = "LocalTxResourceAdapter Started " + counter;
- ConnectorStatus.getConnectorStatus().logState(str1);
-
- // get WorkManager reference
-
- wm = bsc.getWorkManager();
-
- if (bsc != null) {
- ConnectorStatus.getConnectorStatus()
- .logState("LocalTxResourceAdapter BootstrapContext Not Null ");
- }
-
- if (wm != null) {
- ConnectorStatus.getConnectorStatus()
- .logState("LocalTxResourceAdapter WorkManager Not Null ");
-
- if (wm instanceof DistributableWorkManager) {
- Debug.trace("wm supports DistributableWorkManager");
- ConnectorStatus.getConnectorStatus()
- .logState("wm supports DistributableWorkManager");
- } else {
- Debug.trace("wm Does NOT support DistributableWorkManager");
- ConnectorStatus.getConnectorStatus()
- .logState("wm Does NOT support DistributableWorkManager");
- }
-
- }
- try {
- bsc.getWorkManager().startWork(new Work() {
- public void run() {
- myStart(bsc);
- }
-
- public void release() {
- }
-
- });
- } catch (jakarta.resource.spi.work.WorkException we) {
- throw new ResourceAdapterInternalException();
- }
-
- }
-
- private void myStart(final BootstrapContext ctx) {
- wm = ctx.getWorkManager();
- // Create TestWorkManager object
- twm = new TestWorkManager(ctx);
- if (this.useSecurityMapping.booleanValue() == true) {
- // values from our RA xml file indicate we want to establish Case 2
- // security for the RA. This means we need security mappings.
- Debug.trace(
- " LocalTxResourceAdapterImpl ; calling setUseSecurityMapping(true)");
- ConnectorStatus.getConnectorStatus().logState(
- " LocalTxResourceAdapterImpl ; calling setUseSecurityMapping(true)");
- twm.setUseSecurityMapping(true);
- } else {
- // use Case 1 security thus do NO mapping of identities
- Debug.trace(
- " LocalTxResourceAdapterImpl ; calling setUseSecurityMapping(false)");
- ConnectorStatus.getConnectorStatus().logState(
- " LocalTxResourceAdapterImpl ; calling setUseSecurityMapping(false)");
- twm.setUseSecurityMapping(false);
- }
- twm.runTests();
-
- // Create TestBootstrap object
- tbs = new TestBootstrapContext(ctx);
- tbs.runTests();
- }
-
- @Override
- public void stop() {
- // Set the TestWorkManager to null upon resource adapter shutdown.
-
- if (work1 != null) {
- work1.stop();
- }
- if (work2 != null) {
- work2.stop();
- }
-
- if (work3 != null) {
- work3.stop();
- }
- }
-
- @Override
- public void endpointActivation(MessageEndpointFactory mef,
- ActivationSpec as) {
- try {
- mefcount++;
-
- // check if endpointActivation has been called
- Debug.trace("LocalTxResourceAdapter.endpointActivation called");
- Method onMessagexa = getOnMessageMethod();
- boolean de = mef.isDeliveryTransacted(onMessagexa);
-
- // For MDB with Not Supported transaction attribute
- if (!de) {
- mef1 = mef;
- String destinationName = ((LocalTxActivationSpec) as)
- .getDestinationName();
- Debug.trace("LocalTxResourceAdapter preparing work1");
-
- if (mef1 != null) {
- Debug.trace("mef1 is not null");
- }
-
- work1 = new LocalTxMessageWork(destinationName, mef1);
- work1.setBootstrapContext(bsc);
-
- // perform some msging to test SIC
- TSSecurityContext sic = new TSSecurityContextWithListener(sicUser,
- sicPwd, eisUser, this.useSecurityMapping.booleanValue());
- work1.addWorkContext(sic);
-
- Debug.trace("LocalTxResourceAdapter work1 created");
- wm.scheduleWork(work1, WorkManager.INDEFINITE, null, null);
- Debug.trace("LocalTxResourceAdapter work1 scheduled");
- } else // For MDB with Required transaction attribute
- {
- // Endpoint requires a tranaction but no incoming transaction
- mef2 = mef;
- Debug.trace("LocalTxResourceAdapter preparing work2");
- String destinationName = ((LocalTxActivationSpec) as)
- .getDestinationName();
- Debug.trace("Before Destination name");
- Debug.trace("Destination name is " + destinationName);
-
- if (mef2 != null) {
- Debug.trace("mef2 is not null");
- }
-
- work2 = new LocalTxMessageWork1(destinationName, mef2);
-
- Debug.trace("LocalTxResourceAdapter work2 created");
- wm.scheduleWork(work2, WorkManager.INDEFINITE, null, null);
- Debug.trace("LocalTxResourceAdapter work2 scheduled");
-
- // Endpoint requires a tranaction and there is an incoming transaction
- work3 = new LocalTxMessageWork2(destinationName, mef2);
- XidImpl myid = new XidImpl();
- ExecutionContext ec = new ExecutionContext();
- int idcount = myid.getFormatId();
- Debug.trace("XID getting used [ " + idcount + " ]");
- ec.setXid(myid);
- ml = new LocalTxMessageListener(myid, this.bsc);
- wm.scheduleWork(work3, WorkManager.INDEFINITE, ec, ml);
- }
-
- if (mefcount == 2) {
- chkUniqueMessageEndpointFactory();
- }
-
- } catch (Throwable ex) {
- ex.printStackTrace();
- }
-
- }
-
- @Override
- public XAResource[] getXAResources(ActivationSpec[] as) {
- return null;
- }
-
- private Method getOnMessageMethod() {
-
- Method onMessageMethod = null;
- try {
- Class msgListenerClass = TSMessageListenerInterface.class;
- Class[] paramTypes = { java.lang.String.class };
- onMessageMethod = msgListenerClass.getMethod("onMessage", paramTypes);
-
- } catch (NoSuchMethodException ex) {
- ex.printStackTrace();
- }
- return onMessageMethod;
- }
-
- private void chkUniqueMessageEndpointFactory() {
- if ((mef1 != null) && (!mef1.equals(mef2))) {
- ConnectorStatus.getConnectorStatus()
- .logState("LocalTx MessageEndpointFactory is Unique");
-
- // Also checking if the equals on the MEF is implemented correctly.
- // Normally MEF equals should not be over ridden but if it is
- // it should be implemented correctly.
- ConnectorStatus.getConnectorStatus().logState(
- "LocalTx MessageEndpointFactory equals implemented correctly");
- }
- }
-
- @Override
- public void endpointDeactivation(MessageEndpointFactory mef,
- ActivationSpec as) {
- mefcount--;
-
- if ((mef1 != null) && (mef1.equals(mef))) {
- mef1 = null;
-
- } else if ((mef2 != null) && (mef2.equals(mef))) {
- mef2 = null;
-
- } else {
- // possible issue so dump some debugging/trace info
- String str = "WARNING: LocalTxResourceAdapterImpl.endpointDeactivation(): ";
- str += "unexpected MEF passed in";
- Debug.trace(str);
- if (mef == null) {
- Debug.trace("NULL MEF passed into endpointDeactivation()");
- } else {
- Debug.trace("Unrecognize mef passed into endpointDeactivation()");
- }
- }
- }
-
- /*
- * @name equals
- *
- * @desc compares this object with the given object.
- *
- * @param Object obj
- *
- * @return boolean
- */
- public boolean equals(Object obj) {
-
- if ((obj == null) || !(obj instanceof LocalTxResourceAdapterImpl)) {
- return false;
- }
- if (obj == this) {
- return true;
- }
-
- LocalTxResourceAdapterImpl that = (LocalTxResourceAdapterImpl) obj;
-
- if (this.counter != that.getCounter()) {
- return false;
- }
-
- if (this.mefcount != that.getMefcount()) {
- return false;
- }
-
- if (!Util.isEqual(this.sicUser, that.getSicUser()))
- return false;
-
- if (!Util.isEqual(this.sicPwd, that.getSicPwd()))
- return false;
-
- if (!Util.isEqual(this.eisUser, that.getEisUser()))
- return false;
-
- if (!Util.isEqual(this.eisPwd, that.getEisPwd()))
- return false;
-
- if (!Util.isEqual(this.RAName, that.getRAName()))
- return false;
-
- if (this.getUseSecurityMapping().booleanValue() != that
- .getUseSecurityMapping().booleanValue()) {
- return false;
- }
-
- return true;
- }
-
- /*
- * @name hashCode
- *
- * @desc gets the hashcode for this object.
- *
- * @return int
- */
- public int hashCode() {
- return this.getClass().getName().hashCode();
- }
-
- public void setRAName(String name) {
- ConnectorStatus.getConnectorStatus()
- .logState("LocalTxResourceAdapter.setRAName");
- this.RAName = name;
- }
-
- public String getRAName() {
- Debug.trace("LocalTxResourceAdapter.getRAName");
- return RAName;
- }
-
- public void setUseSecurityMapping(Boolean val) {
- this.useSecurityMapping = val;
- }
-
- public Boolean getUseSecurityMapping() {
- return this.useSecurityMapping;
- }
-
- public void setCounter(int val) {
- this.counter = val;
- }
-
- public int getCounter() {
- return this.counter;
- }
-
- public void setMefcount(int val) {
- this.mefcount = val;
- }
-
- public int getMefcount() {
- return this.mefcount;
- }
-
- public void setSicUser(String val) {
- this.sicUser = val;
- }
-
- public String getSicUser() {
- return this.sicUser;
- }
-
- public void setSicPwd(String val) {
- this.sicPwd = val;
- }
-
- public String getSicPwd() {
- return this.sicPwd;
- }
-
- public void setEisUser(String val) {
- this.eisUser = val;
- }
-
- public String getEisUser() {
- return this.eisUser;
- }
-
- public void setEisPwd(String val) {
- this.eisPwd = val;
- }
-
- public String getEisPwd() {
- return this.eisPwd;
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/MetaDataImpl.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/MetaDataImpl.java
deleted file mode 100644
index da24f2a32c..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/MetaDataImpl.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.connector.whitebox;
-
-import jakarta.resource.ResourceException;
-import jakarta.resource.spi.EISSystemException;
-import jakarta.resource.spi.IllegalStateException;
-import jakarta.resource.spi.ManagedConnectionMetaData;
-import jakarta.resource.spi.security.PasswordCredential;
-
-public class MetaDataImpl implements ManagedConnectionMetaData {
-
- private TSManagedConnection mc;
-
- public MetaDataImpl(TSManagedConnection mc) {
- this.mc = mc;
- }
-
- /*
- * @name getEISProductName
- *
- * @desc Gets product name of underlying EIS.
- *
- * @return String
- *
- * @exception ResourceException
- */
- @Override
- public String getEISProductName() throws ResourceException {
- try {
- String str = "Simple TS EIS";
- return str;
- } catch (Exception ex) {
- ResourceException re = new EISSystemException(ex.getMessage());
- re.initCause(ex);
- throw re;
- }
- }
-
- /*
- * @name getEISProductVersion
- *
- * @desc Gets product version of underlying EIS.
- *
- * @return String
- *
- * @exception ResourceException
- */
- @Override
- public String getEISProductVersion() throws ResourceException {
- try {
- String str = "1.0";
- return str;
- } catch (Exception ex) {
- ResourceException re = new EISSystemException(ex.getMessage());
- re.initCause(ex);
- throw re;
- }
- }
-
- /*
- * @name getMaxConnections
- *
- * @desc Returns maximum limit on number of active concurrent connections that
- * an EIS instance can support across client processes.
- *
- * @return int
- *
- * @exception ResourceException
- */
- @Override
- public int getMaxConnections() throws ResourceException {
- try {
- int i = 0;
- return i;
- } catch (Exception ex) {
- ResourceException re = new EISSystemException(ex.getMessage());
- re.initCause(ex);
- throw re;
- }
- }
-
- /*
- * @name getUserName
- *
- * @desc Return name of the user currently associated with ManagedConnection
- * instance. The returned username corresponds to the resource principal under
- * whose security context the connection to the EIS instance has been
- * established.
- *
- * @return String
- *
- * @exception ResourceException
- */
- @Override
- public String getUserName() throws ResourceException {
- if (mc.isDestroyed()) {
- throw new IllegalStateException("ManagedConnection has been destroyed");
- }
-
- PasswordCredential pc = null;
- String str = null;
-
- pc = mc.getPasswordCredential();
- if (pc != null) {
- str = pc.getUserName();
- }
-
- if (pc != null && str != null && !str.equals(""))
- return str;
- else
- return null;
-
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/NoTxManagedConnectionFactory.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/NoTxManagedConnectionFactory.java
deleted file mode 100644
index 5a30db518b..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/NoTxManagedConnectionFactory.java
+++ /dev/null
@@ -1,371 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.connector.whitebox;
-
-import java.io.PrintWriter;
-import java.io.Serializable;
-import java.util.Iterator;
-import java.util.Set;
-
-import javax.security.auth.Subject;
-
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-
-import jakarta.resource.ResourceException;
-import jakarta.resource.spi.ConnectionManager;
-import jakarta.resource.spi.ConnectionRequestInfo;
-import jakarta.resource.spi.EISSystemException;
-import jakarta.resource.spi.ManagedConnection;
-import jakarta.resource.spi.ManagedConnectionFactory;
-import jakarta.resource.spi.ResourceAdapter;
-import jakarta.resource.spi.ResourceAdapterAssociation;
-import jakarta.resource.spi.security.PasswordCredential;
-
-public class NoTxManagedConnectionFactory implements ManagedConnectionFactory,
- ResourceAdapterAssociation, Serializable, jakarta.resource.Referenceable {
-
- private ResourceAdapter resourceAdapter;
-
- private javax.naming.Reference reference;
-
- private int count;
-
- private String password;
-
- private String user;
-
- private String userName;
-
- /*
- * @name NoTxManagedConnectionFactory
- *
- * @desc Default conctructor
- */
- public NoTxManagedConnectionFactory() {
- }
-
- public String getUser() {
- System.out
- .println("NoTxManagedConnectionFactory.getUser() returning: " + user);
- return user;
- }
-
- public void setUser(String val) {
- System.out
- .println("NoTxManagedConnectionFactory.setUser() with val = " + val);
- user = val;
- }
-
- public String getUserName() {
- System.out.println(
- "NoTxManagedConnectionFactory.getUserName() returning: " + userName);
- return userName;
- }
-
- public void setUserName(String val) {
- System.out.println(
- "NoTxManagedConnectionFactory.setUserName() with val = " + val);
- userName = val;
- }
-
- public String getPassword() {
- System.out.println(
- "NoTxManagedConnectionFactory.getPassword() returning: " + password);
- return password;
- }
-
- public void setPassword(String val) {
- System.out.println(
- "NoTxManagedConnectionFactory.setPassword() with val = " + val);
- password = val;
- }
-
- /*
- * @name createConnectionFactory
- *
- * @desc Creates a new connection factory instance
- *
- * @param ConnectionManager
- *
- * @return Object
- *
- * @exception ResourceException
- */
- @Override
- public Object createConnectionFactory(ConnectionManager cxManager)
- throws ResourceException {
- ConnectorStatus.getConnectorStatus().logAPI(
- "NoTxManagedConnectionFactory.createConnectionFactory", "cxManager",
- "TSEISDataSource");
- return new TSEISDataSource(this, cxManager);
- }
-
- /*
- * @name setResourceAdapter
- *
- * @desc sets the Resource Adapter for this ManagedConnectionFactory
- *
- * @return
- *
- * @exception ResourceException
- */
-
- @Override
- public void setResourceAdapter(ResourceAdapter ra) throws ResourceException {
- count++;
- String newStr1 = "NoTxManagedConnectionFactory setResourceAdapter " + count;
- System.out.println(newStr1);
- ConnectorStatus.getConnectorStatus().logState(newStr1);
- this.resourceAdapter = ra;
- }
-
- /*
- * @name getResourceAdapter
- *
- * @desc gets the Resource Adapter for this ManagedConnectionFactory
- *
- * @return Object
- *
- * @exception ResourceException
- */
-
- @Override
- public ResourceAdapter getResourceAdapter() {
- return resourceAdapter;
- }
-
- /*
- * @name createConnectionFactory
- *
- * @desc Creates a new connection factory instance
- *
- * @return Object
- *
- * @exception ResourceException
- */
-
- @Override
- public Object createConnectionFactory() throws ResourceException {
- ConnectorStatus.getConnectorStatus().logAPI(
- "NoTxManagedConnectionFactory.createConnectionFactory", "",
- "TSEISDataSource");
- return new TSEISDataSource(this, null);
- }
-
- /*
- * @name createManagedConnection
- *
- * @desc Creates a new managed connection to the underlying EIS
- *
- * @param Subject, ConnectionRequestInfo
- *
- * @return ManagedConnection
- *
- * @exception ResourceException
- */
-
- @Override
- public ManagedConnection createManagedConnection(Subject subject,
- ConnectionRequestInfo info) throws ResourceException {
-
- try {
- TSConnection con = null;
- String userName = null;
- ConnectorStatus.getConnectorStatus().logAPI(
- "NoTxManagedConnectionFactory.createManagedConnection", "",
- "TSManagedConnection");
- PasswordCredential pc = Util.getPasswordCredential(this, subject, info);
- if (pc == null) {
- con = new TSConnectionImpl().getConnection();
- } else {
- con = new TSConnectionImpl().getConnection(pc.getUserName(),
- pc.getPassword());
- }
- return new TSManagedConnection(this, pc, null, con, false, false);
- } catch (Exception ex) {
- ResourceException re = new EISSystemException(
- "Exception: " + ex.getMessage());
- re.initCause(ex);
- throw re;
- }
-
- }
-
- /*
- * @name matchManagedConnection
- *
- * @desc Return the existing connection from the connection pool
- *
- * @param Set, Subject, ConnectionRequestInfo
- *
- * @return ManagedConnection
- *
- * @exception ResourceException
- */
- @Override
- public ManagedConnection matchManagedConnections(Set connectionSet,
- Subject subject, ConnectionRequestInfo info) throws ResourceException {
- ConnectorStatus.getConnectorStatus().logAPI(
- "NoTxManagedConnecitonFactory.matchManagedConnection",
- "connectionSet|subject|info", "TSEISDataSource");
- PasswordCredential pc = Util.getPasswordCredential(this, subject, info);
- Iterator it = connectionSet.iterator();
- while (it.hasNext()) {
- Object obj = it.next();
- if (obj instanceof TSManagedConnection) {
- TSManagedConnection mc = (TSManagedConnection) obj;
- ManagedConnectionFactory mcf = mc.getManagedConnectionFactory();
- if (Util.isPasswordCredentialEqual(mc.getPasswordCredential(), pc)
- && (mcf != null) && mcf.equals(this)) {
- return mc;
- }
- }
- }
- return null;
- }
-
- /*
- * @name setLogWriter
- *
- * @desc sets the log writer
- *
- * @param PrinterWriter out
- *
- * @exception ResourceException
- */
- @Override
- public void setLogWriter(PrintWriter out) throws ResourceException {
-
- }
-
- /*
- * @name getLogWriter
- *
- * @desc gets the log writer
- *
- * @return PrinterWriter out
- *
- * @exception ResourceException
- */
- @Override
- public PrintWriter getLogWriter() throws ResourceException {
- return null;
- }
-
- /*
- * @name equals
- *
- * @desc compares this object with the given object.
- *
- * @param Object obj
- *
- * @return boolean
- */
- @Override
- public boolean equals(Object obj) {
-
- if ((obj == null) || !(obj instanceof NoTxManagedConnectionFactory)) {
- return false;
- }
- if (obj == this) {
- return true;
- }
-
- NoTxManagedConnectionFactory that = (NoTxManagedConnectionFactory) obj;
-
- if ((this.reference != null)
- && !(this.reference.equals(that.getReference()))) {
- return false;
- } else if ((this.reference == null) && !(that.getReference() == null)) {
- return false;
- }
-
- if ((this.resourceAdapter != null)
- && !(this.resourceAdapter.equals(that.getResourceAdapter()))) {
- return false;
- } else if ((this.resourceAdapter == null)
- && !(that.getResourceAdapter() == null)) {
- return false;
- }
-
- if (this.count != that.getCount()) {
- return false;
- }
-
- if (!Util.isEqual(this.password, that.getPassword()))
- return false;
-
- if (!Util.isEqual(this.user, that.getUser()))
- return false;
-
- if (!Util.isEqual(this.userName, that.getUserName()))
- return false;
-
- return true;
- }
-
- /*
- * @name hashCode
- *
- * @desc gets the hashcode for this object.
- *
- * @return int
- */
- @Override
- public int hashCode() {
- return this.getClass().getName().hashCode();
- }
-
- /*
- * @name getReference
- *
- * @desc Gives the reference of the class
- *
- * @return javax.naming.Reference
- */
- @Override
- public javax.naming.Reference getReference() {
- javax.naming.Reference ref;
-
- ref = this.reference;
- return ref;
- }
-
- /*
- * @name setReference
- *
- * @desc sets the reference of the class
- *
- * @param javax.naming.Reference
- */
- @Override
- public void setReference(javax.naming.Reference ref) {
- this.reference = ref;
- }
-
- public int getCount() {
- return this.count;
- }
-
- public void setCount(int val) {
- this.count = val;
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/NoTxResourceAdapterImpl.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/NoTxResourceAdapterImpl.java
deleted file mode 100644
index 58b9011ed4..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/NoTxResourceAdapterImpl.java
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.connector.whitebox;
-
-import java.io.Serializable;
-import java.lang.reflect.Method;
-import java.util.Vector;
-
-import javax.transaction.xa.XAResource;
-
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-import com.sun.ts.tests.common.connector.util.TSMessageListenerInterface;
-
-import jakarta.resource.spi.ActivationSpec;
-import jakarta.resource.spi.BootstrapContext;
-import jakarta.resource.spi.ResourceAdapter;
-import jakarta.resource.spi.ResourceAdapterInternalException;
-import jakarta.resource.spi.endpoint.MessageEndpointFactory;
-import jakarta.resource.spi.work.Work;
-import jakarta.resource.spi.work.WorkManager;
-
-public class NoTxResourceAdapterImpl implements ResourceAdapter, Serializable {
- // IMPORTANT: for compliance, if you add non-transient member data
- // here, be sure to add respective entry to equals() method below.
-
- private transient TestWorkManager twm;
-
- private transient TestBootstrapContext tbs;
-
- private transient LocalTxMessageListener ml;
-
- private String RAName; // value from ra's xml file
-
- private Boolean useSecurityMapping = null; // value from ra's xml file
-
- private int counter = 0;
-
- private transient javax.transaction.xa.XAResource xaresource;
-
- private transient WorkManager wm;
-
- private int mefcount = 0;
-
- private transient MessageEndpointFactory mef1;
-
- private transient MessageEndpointFactory mef2;
-
- private transient BootstrapContext bsc;
-
- public NoTxResourceAdapterImpl() {
- ConnectorStatus.getConnectorStatus()
- .logState("NoTxResourceAdapterImpl Constructor");
- System.out.println("NoTxResourceAdapterImpl Constructor");
- }
-
- @Override
- public void start(final BootstrapContext bsc)
- throws ResourceAdapterInternalException {
- // setup network endpoints
- counter++;
- this.bsc = bsc;
- System.out.println("NoTxResourceAdapter Started " + counter);
- String str1 = "NoTxResourceAdapter Started " + counter;
- ConnectorStatus.getConnectorStatus().logState(str1);
-
- // get WorkManager reference
-
- WorkManager wm = bsc.getWorkManager();
-
- if (bsc != null) {
- ConnectorStatus.getConnectorStatus()
- .logState("NoTxResourceAdapter BootstrapContext Not Null ");
- }
-
- if (wm != null) {
- ConnectorStatus.getConnectorStatus()
- .logState("NoTxResourceAdapter WorkManager Not Null ");
- }
-
- try {
- checkAssociation();
- bsc.getWorkManager().startWork(new Work() {
- public void run() {
- myStart(bsc);
- }
-
- public void release() {
- }
-
- });
- } catch (jakarta.resource.spi.work.WorkException we) {
- throw new ResourceAdapterInternalException();
- }
-
- }
-
- private void myStart(final BootstrapContext ctx) {
- wm = ctx.getWorkManager();
- // Create TestWorkManager object
- twm = new TestWorkManager(ctx);
- if (this.useSecurityMapping.booleanValue() == true) {
- // values from our RA xml file indicate we want to establish Case 2
- // security for the RA. This means we need security mappings.
- Debug.trace(
- "NoTxResourceAdapterImpl ; calling setUseSecurityMapping(true)");
- twm.setUseSecurityMapping(true);
- } else {
- // use Case 1 security thus do NO mapping of identities
- Debug.trace(
- "NoTxResourceAdapterImpl ; calling setUseSecurityMapping(false)");
- twm.setUseSecurityMapping(false);
- }
- twm.runTests();
-
- // Create TestBootstrap object
- tbs = new TestBootstrapContext(ctx);
- tbs.runTests();
- }
-
- @Override
- public void endpointActivation(MessageEndpointFactory mef,
- ActivationSpec as) {
- }
-
- @Override
- public void stop() {
- // Set the TestWorkManager to null upon resource adapter shutdown.
- // twm = null;
- }
-
- @Override
- public void endpointDeactivation(MessageEndpointFactory mef,
- ActivationSpec as) {
-
- }
-
- @Override
- public XAResource[] getXAResources(ActivationSpec[] as) {
- return null;
- }
-
- private Method getOnMessageMethod() {
-
- Method onMessageMethod = null;
- try {
- Class msgListenerClass = TSMessageListenerInterface.class;
- Class[] paramTypes = { java.lang.String.class };
- onMessageMethod = msgListenerClass.getMethod("onMessage", paramTypes);
-
- } catch (NoSuchMethodException ex) {
- ex.printStackTrace();
- }
- return onMessageMethod;
- }
-
- private void chkUniqueMessageEndpointFactory() {
- if ((mef1 != null) && (!mef1.equals(mef2))) {
- Debug.trace("NoTx MessageEndpointFactory is Unique");
- Debug.trace("NoTx MessageEndpointFactory equals implemented correctly");
- }
- }
-
- /*
- * This method is used to assist in the verification process of assertion
- * Connector:SPEC:245 This method must be called befor the work instances
- * 'run' method is called. This method checks if the setResourceAdapter()
- * method was called and if so, then this method logs a message to indicate
- * that it was called prior to the 'run' method of the run method.
- */
- public void checkAssociation() {
- Vector vLog = ConnectorStatus.getConnectorStatus().getStateLogVector();
- String toCheck1 = "NoTxManagedConnectionFactory setResourceAdapter 1";
-
- for (int i = 0; i < vLog.size(); i++) {
- String str = (String) vLog.elementAt(i);
- if (str.startsWith(toCheck1)) {
- ConnectorStatus.getConnectorStatus().logState(
- "NoTxResourceAdapter - association exists between RA and work");
- break;
- }
- }
-
- }
-
- public void setRAName(String name) {
- ConnectorStatus.getConnectorStatus()
- .logState("NoTxResourceAdapter.setRAName");
- this.RAName = name;
- }
-
- public String getRAName() {
- Debug.trace("NoTxResourceAdapter.getRAName");
- return RAName;
- }
-
- public void setUseSecurityMapping(Boolean val) {
- this.useSecurityMapping = val;
- }
-
- public Boolean getUseSecurityMapping() {
- return this.useSecurityMapping;
- }
-
- public void setCounter(int val) {
- this.counter = val;
- }
-
- public int getCounter() {
- return this.counter;
- }
-
- public void setMefcount(int val) {
- this.mefcount = val;
- }
-
- public int getMefcount() {
- return this.mefcount;
- }
-
- /*
- * @name equals
- *
- * @desc compares this object with the given object.
- *
- * @param Object obj
- *
- * @return boolean
- */
- public boolean equals(Object obj) {
-
- if ((obj == null) || !(obj instanceof NoTxResourceAdapterImpl)) {
- return false;
- }
- if (obj == this) {
- return true;
- }
-
- NoTxResourceAdapterImpl that = (NoTxResourceAdapterImpl) obj;
-
- if (this.counter != that.getCounter()) {
- return false;
- }
-
- if (this.mefcount != that.getMefcount()) {
- return false;
- }
-
- if (!Util.isEqual(this.RAName, that.getRAName()))
- return false;
-
- if (this.getUseSecurityMapping().booleanValue() != that
- .getUseSecurityMapping().booleanValue()) {
- return false;
- }
-
- return true;
- }
-
- /*
- * @name hashCode
- *
- * @desc gets the hashcode for this object.
- *
- * @return int
- */
- public int hashCode() {
- return this.getClass().getName().hashCode();
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/SimplePrincipal.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/SimplePrincipal.java
deleted file mode 100644
index 23972aad04..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/SimplePrincipal.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (c) 2008, 2018 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.common.connector.whitebox;
-
-import java.security.Principal;
-
-/**
- * @author Raja Perumal
- */
-public class SimplePrincipal implements Principal, java.io.Serializable {
- private String name = null; // username
-
- private String password = null; // password
-
- public SimplePrincipal(String val) {
- name = val;
- }
-
- public SimplePrincipal(String val, String pwd) {
- name = val;
- password = pwd;
- }
-
- // required to satisfy Principal interface
- @Override
- public boolean equals(Object obj) {
-
- if ((obj == null) || !(obj instanceof SimplePrincipal)) {
- return false;
- }
- if (obj == this) {
- return true;
- }
-
- SimplePrincipal that = (SimplePrincipal) obj;
-
- if (!Util.isEqual(this.password, that.getPassword()))
- return false;
-
- if (!Util.isEqual(this.name, that.getName()))
- return false;
-
- return true;
- }
-
- // required to satisfy Principal interface
- @Override
- public String getName() {
- return name;
- }
-
- public void setName(String val) {
- name = val;
- }
-
- public void setPassword(String val) {
- password = val;
- }
-
- // required to satisfy Principal interface
- @Override
- public String toString() {
- return name;
- }
-
- // required to satisfy Principal interface
- @Override
- public int hashCode() {
- return this.getClass().getName().hashCode();
- }
-
- // may want to change this later if tests call for it
- // this is normally bad but for testing purposes we dont care
- public String getPassword() {
- return password;
- }
-} // end of class SimulateRuntime
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/TSConnection.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/TSConnection.java
deleted file mode 100644
index d63d3caf0f..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/TSConnection.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.connector.whitebox;
-
-import java.util.Hashtable;
-import java.util.Vector;
-
-/**
- * A Pooled object interface.
- *
- * @version 2.0, 06/06/02
- * @author Gursharan Singh/Binod P.G
- */
-public interface TSConnection {
-
- /**
- * Insert a key and value in Test Information System (TSEIS).
- *
- * @param key
- * Key to insert.
- * @param value
- * value to insert.
- * @throws Exception
- * If the key is already present in the EIS.
- */
- public void insert(String key, String value) throws Exception;
-
- /**
- * Delete the key and value from Test Information System (TSEIS).
- *
- * @param key
- * Key to delete.
- * @throws Exception
- * If the key is not present in the EIS.
- */
- public void delete(String key) throws Exception;
-
- /**
- * Update the key and value in Test Information System (TSEIS).
- *
- * @param key
- * Key to update.
- * @param value
- * value to update.
- * @throws Exception
- * If the key is not present in the EIS.
- */
- public void update(String key, String value) throws Exception;
-
- /**
- * Read the value for the key.
- *
- * @param key
- * Key to read.
- * @return String value.
- * @throws Exception
- * If the key is not present in the EIS.
- */
- public String readValue(String key) throws Exception;
-
- /**
- * Drops all data in the EIS.
- *
- * @throws Exception
- * If there is any exception while droppping.
- */
- public void dropTable() throws Exception;
-
- /**
- * Rolls back all the operations.
- */
- public void rollback();
-
- /**
- * Commits all the operations.
- *
- * @throws Exception
- * If commit fails.
- */
- public void commit() throws Exception;
-
- public void begin() throws Exception;
-
- /**
- * Closes this connection.
- *
- * @throws Exception
- * If close fails.
- */
- public void close() throws Exception;
-
- /**
- * Sets the auto-commit flag to the value passed in. True indicates that all
- * the operation will be committed. If a false is passed, EIS will wait until
- * an explicit commit is executed.
- *
- * @param flag
- * True or False
- */
- public void setAutoCommit(boolean flag);
-
- /**
- * Get the auto-commt flag value.
- *
- * @return the boolean value indicating auto-commit.
- */
- public boolean getAutoCommit();
-
- /**
- * Get all the data in the TSEis. Only Data is returned. Keys are not.
- *
- * @return Vector containing all the data values.
- * @throws Exception
- * If read fails.
- */
- public Vector readData() throws Exception;
-
- /**
- * Get the data cache of the connection accumulated during a transaction.
- *
- * @returns Data cache of operations on the connection.
- */
- public Hashtable getTempTable();
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/TSConnectionEventListener.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/TSConnectionEventListener.java
deleted file mode 100644
index 830e4950b2..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/TSConnectionEventListener.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.connector.whitebox;
-
-import java.util.Vector;
-
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-
-import jakarta.resource.spi.ConnectionEvent;
-import jakarta.resource.spi.ConnectionEventListener;
-import jakarta.resource.spi.ManagedConnection;
-
-public class TSConnectionEventListener implements ConnectionEventListener {
-
- private Vector listeners;
-
- private ManagedConnection mcon;
-
- /*
- * @name TSConnectionEventListener
- *
- * @desc TSConnectionEventListener constructor
- *
- * @param ManagedConnection mcon
- */
-
- public TSConnectionEventListener(ManagedConnection mcon) {
- listeners = new Vector();
- ConnectorStatus.getConnectorStatus()
- .logAPI("TSConnectionEventListener.constructor", "mcon", "");
- this.mcon = mcon;
- }
-
- /*
- * @name sendEvent
- *
- * @desc send event notifications
- *
- * @param int eventType, Exception ex, Object connectionHandle
- */
- public void sendEvent(int eventType, Exception ex, Object connectionHandle) {
- Vector list = (Vector) listeners.clone();
- ConnectionEvent ce = null;
- if (ex == null) {
- ce = new ConnectionEvent(mcon, eventType);
- } else {
- ce = new ConnectionEvent(mcon, eventType, ex);
- }
- if (connectionHandle != null) {
- ce.setConnectionHandle(connectionHandle);
- }
- int size = list.size();
- for (int i = 0; i < size; i++) {
- ConnectionEventListener l = (ConnectionEventListener) list.elementAt(i);
- switch (eventType) {
- case ConnectionEvent.CONNECTION_CLOSED:
- l.connectionClosed(ce);
- ConnectorStatus.getConnectorStatus().logAPI(
- "TSConnectionEventListener.sendEvent", "CONNECTION_CLOSED", "");
- System.out
- .println("TSConnectionEventListener.sendEvent:CONNECTION_CLOSED");
- break;
- case ConnectionEvent.LOCAL_TRANSACTION_STARTED:
- l.localTransactionStarted(ce);
- ConnectorStatus.getConnectorStatus().logAPI(
- "TSConnectionEventListener.sendEvent", "LOCAL_TRANSACTION_STARTED",
- "");
- break;
- case ConnectionEvent.LOCAL_TRANSACTION_COMMITTED:
- l.localTransactionCommitted(ce);
- ConnectorStatus.getConnectorStatus().logAPI(
- "TSConnectionEventListener.sendEvent", "LOCAL_TRANSACTION_COMMITED",
- "");
- break;
- case ConnectionEvent.LOCAL_TRANSACTION_ROLLEDBACK:
- l.localTransactionRolledback(ce);
- ConnectorStatus.getConnectorStatus().logAPI(
- "TSConnectionEventListener.sendEvent",
- "LOCAL_TRANSACTION_ROLLEDBACK", "");
- break;
- case ConnectionEvent.CONNECTION_ERROR_OCCURRED:
- l.connectionErrorOccurred(ce);
- ConnectorStatus.getConnectorStatus().logAPI(
- "TSConnectionEventListener.sendEvent", "CONNECTION_ERROR_OCCURED",
- "");
- break;
- default:
- throw new IllegalArgumentException("Illegal eventType: " + eventType);
- }
- }
- }
-
- public void localTransactionRolledback(ConnectionEvent event) {
-
- ConnectorStatus.getConnectorStatus()
- .logAPI("TSConnectionEventListener.localTransactionRolledBack", "", "");
- System.out.println("TSConnectionEventListener.localTransactionRolledback");
- }
-
- public void localTransactionCommitted(ConnectionEvent event) {
-
- ConnectorStatus.getConnectorStatus()
- .logAPI("TSConnectionEventListener.localTransactionCommitted", "", "");
- System.out.println("TSConnectionEventListener.localTransactionCommited");
- }
-
- public void localTransactionStarted(ConnectionEvent event) {
-
- ConnectorStatus.getConnectorStatus()
- .logAPI("TSConnectionEventListener.localTransactionStarted", "", "");
- System.out.println("TSConnectionEventListener.localTransactionStarted");
- }
-
- /*
- * @name addConnectorListener
- *
- * @desc add a connector event listener
- *
- * @param ConnectionEventListener
- */
- public void addConnectorListener(ConnectionEventListener l) {
- ConnectorStatus.getConnectorStatus().logAPI(
- "TSConnectionEventListener.addConnectorListener",
- "connectionEventListener", "");
- listeners.addElement(l);
- }
-
- /*
- * @name removeConnectorListener
- *
- * @desc remove a connector event listener
- *
- * @param ConnectionEventListener
- */
- public void removeConnectorListener(ConnectionEventListener l) {
- ConnectorStatus.getConnectorStatus().logAPI(
- "TSConnectionEventListener.removeConnectorListener",
- "connectionEventListener", "");
- listeners.removeElement(l);
- }
-
- /*
- * @name connectionClosed
- *
- * @desc
- *
- * @param ConnectionEvent
- */
- public void connectionClosed(ConnectionEvent event) {
- // do nothing. The event is sent by the TSEISConnection wrapper
- }
-
- /*
- * @name connectionErrorOccured
- *
- * @desc add a connector event listener
- *
- * @param ConnectionEvent
- */
- public void connectionErrorOccurred(ConnectionEvent event) {
- ConnectorStatus.getConnectorStatus().logAPI(
- "TSEISConnectionEventListener.connectionErrorOccured",
- "connectionEvent", "");
- sendEvent(ConnectionEvent.CONNECTION_ERROR_OCCURRED, event.getException(),
- null);
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/TSConnectionImpl.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/TSConnectionImpl.java
deleted file mode 100644
index d8d614829c..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/TSConnectionImpl.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.connector.whitebox;
-
-import java.util.Hashtable;
-import java.util.Vector;
-
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-
-public class TSConnectionImpl implements TSConnection {
-
- private boolean inuse = false;
-
- private boolean autocommit = true;
-
- private Hashtable tempTable = new Hashtable();
-
- public TSConnectionImpl() {
-
- }
-
- public TSConnection getConnection() throws Exception {
- try {
-
- TSConnection ctscon = TSeis.getTSeis().getConnection();
- ConnectorStatus.getConnectorStatus()
- .logAPI("TSConnectionImpl.getConnection", "", "");
- return ctscon;
- } catch (Exception ex) {
- ex.printStackTrace();
- ex.getMessage();
- return null;
- }
- }
-
- public TSConnection getConnection(String user, char[] passwd)
- throws Exception {
- try {
-
- System.out.println("TSConnectionImpl.getConnection(u,p): user=" + user
- + " passwd = " + passwd);
-
- TSConnection ctscon = TSeis.getTSeis().getConnection(user, passwd);
- ConnectorStatus.getConnectorStatus()
- .logAPI("TSConnectionImpl.getConnection", "", "");
- return ctscon;
- } catch (Exception ex) {
- ex.printStackTrace();
- ex.getMessage();
- return null;
- }
- }
-
- public synchronized boolean lease() {
- if (inuse) {
- return false;
- } else {
- inuse = true;
- return true;
- }
- }
-
- protected void expireLease() {
- inuse = false;
- }
-
- @Override
- public void insert(String key, String value) throws Exception {
- try {
- ConnectorStatus.getConnectorStatus().logAPI("TSConnectionImpl.insert", "",
- "");
- TSeis.getTSeis().insert(key, value, this);
- System.out.println("TSConnectionImpl.insert");
- } catch (Exception ex) {
- throw ex;
- }
- }
-
- @Override
- public void delete(String str) throws Exception {
- try {
- ConnectorStatus.getConnectorStatus().logAPI("TSConnectionImpl.delete", "",
- "");
- TSeis.getTSeis().delete(str, this);
- System.out.println("TSConnectionImpl.delete");
- } catch (Exception ex) {
- throw ex;
- }
- }
-
- @Override
- public void update(String key, String value) throws Exception {
- try {
- ConnectorStatus.getConnectorStatus().logAPI("TSConnectionImpl.update", "",
- "");
- TSeis.getTSeis().update(key, value, this);
- System.out.println("TSConnectionImpl.update");
- } catch (Exception ex) {
- throw ex;
- }
- }
-
- @Override
- public Hashtable getTempTable() {
- return tempTable;
- }
-
- public boolean inUse() throws Exception {
- return inuse;
- }
-
- @Override
- public void setAutoCommit(boolean flag) {
- autocommit = flag;
- }
-
- @Override
- public boolean getAutoCommit() {
- return autocommit;
- }
-
- @Override
- public void dropTable() throws Exception {
-
- ConnectorStatus.getConnectorStatus().logAPI("TSConnectionImpl.dropTable",
- "", "");
- TSeis.getTSeis().dropTable();
- tempTable.clear();
- }
-
- @Override
- public void begin() throws Exception {
-
- ConnectorStatus.getConnectorStatus().logAPI("TSConnectionImpl.begin", "",
- "");
- TSeis.getTSeis().begin();
- }
-
- @Override
- public void rollback() {
-
- ConnectorStatus.getConnectorStatus().logAPI("TSConnectionImpl.rollback", "",
- "");
- tempTable.clear();
- }
-
- @Override
- public void commit() throws Exception {
- ConnectorStatus.getConnectorStatus().logAPI("TSConnectionImpl.commit", "",
- "");
- TSeis.getTSeis().commit(this);
- tempTable.clear();
- }
-
- @Override
- public void close() throws Exception {
- TSeis.getTSeis().returnConnection(this);
- System.out.println("TSConnectionImpl.close");
- }
-
- @Override
- public Vector readData() throws Exception {
- Vector table = TSeis.getTSeis().readData();
- ConnectorStatus.getConnectorStatus().logAPI("TSConnectionImpl.readData", "",
- "");
- return table;
- }
-
- @Override
- public String readValue(String key) throws Exception {
- String value = TSeis.getTSeis().readValue(key, this);
- ConnectorStatus.getConnectorStatus().logAPI("TSConnectionImpl.readValue",
- "", "");
- return value;
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/TSConnectionRequestInfo.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/TSConnectionRequestInfo.java
deleted file mode 100644
index 05e54dc9a7..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/TSConnectionRequestInfo.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.connector.whitebox;
-
-import jakarta.resource.spi.ConnectionRequestInfo;
-
-public class TSConnectionRequestInfo implements ConnectionRequestInfo {
-
- private String user;
-
- private String password;
-
- /*
- * @name TSConnectionRequestInfo
- *
- * @desc TSConnectionRequestInfo constructor
- *
- * @param String, String
- */
- public TSConnectionRequestInfo(String user, String password) {
- this.user = user;
- this.password = password;
- }
-
- /*
- * @name getUser
- *
- * @desc Gets the user name
- *
- * @return String
- */
- public String getUser() {
- return user;
- }
-
- /*
- * @name getPassword
- *
- * @desc Gets the Password
- *
- * @return String
- */
- public String getPassword() {
- return password;
- }
-
- /*
- * @name equals
- *
- * @desc Compares the given object with ConnectionRequestInfo.
- *
- * @param Object
- *
- * @return boolean
- */
- @Override
- public boolean equals(Object obj) {
-
- if ((obj == null) || !(obj instanceof TSConnectionRequestInfo)) {
- return false;
- }
- if (obj == this) {
- return true;
- }
-
- TSConnectionRequestInfo that = (TSConnectionRequestInfo) obj;
-
- if (!Util.isEqual(this.password, that.getPassword()))
- return false;
-
- if (!Util.isEqual(this.user, that.getUser()))
- return false;
-
- return true;
- }
-
- /*
- * @name hashCode
- *
- * @desc Returns the Object hashcode.
- *
- * @return int
- */
- @Override
- public int hashCode() {
- return this.getClass().getName().hashCode();
- }
-
- /*
- * @name isEqual
- *
- * @desc Compares two Objects.
- *
- * @return boolean
- */
- private boolean isEqual(Object o1, Object o2) {
- if (o1 == null) {
- return (o2 == null);
- } else {
- return o1.equals(o2);
- }
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/TSEISConnection.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/TSEISConnection.java
deleted file mode 100644
index a12fea9afc..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/TSEISConnection.java
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-/*
- * @(#)TSEISConnection.java 1.5 02/06/06
- */
-
-package com.sun.ts.tests.common.connector.whitebox;
-
-import java.util.Hashtable;
-import java.util.Vector;
-
-import jakarta.resource.spi.ConnectionEvent;
-
-public class TSEISConnection implements TSConnection {
-
- private TSManagedConnection mc;
-
- private boolean supportsLocalTx;
-
- /*
- * @name TSEISConnection
- *
- * @desc TSEISConnection constructor
- *
- * @param TSManagedConnection
- */
- public TSEISConnection(TSManagedConnection mc, boolean supportsLocalTx) {
- this.mc = mc;
- this.supportsLocalTx = supportsLocalTx;
- }
-
- public void insert(String key, String value) throws Exception {
- try {
- TSConnection con = getTSEISConnection();
- con.insert(key, value);
- } catch (Exception ex) {
- throw ex;
- }
- }
-
- public void delete(String key) throws Exception {
- try {
- TSConnection con = getTSEISConnection();
- con.delete(key);
- } catch (Exception ex) {
- throw ex;
- }
-
- }
-
- public void update(String key, String value) throws Exception {
- try {
- TSConnection con = getTSEISConnection();
- con.update(key, value);
- } catch (Exception ex) {
- throw ex;
- }
-
- }
-
- public Vector readData() throws Exception {
- TSConnection con = getTSEISConnection();
- return con.readData();
-
- }
-
- public String readValue(String key) throws Exception {
- TSConnection con = getTSEISConnection();
- return con.readValue(key);
-
- }
-
- public void setAutoCommit(boolean flag) {
- TSConnection con = getTSEISConnection();
- con.setAutoCommit(flag);
- }
-
- public boolean getAutoCommit() {
- TSConnection con = getTSEISConnection();
- return con.getAutoCommit();
-
- }
-
- /*
- * @name commit
- *
- * @desc Commit a transaction.
- */
- public void commit() throws Exception {
- TSConnection con = getTSEISConnection();
- con.commit();
- }
-
- /*
- * @name dropTable
- *
- * @desc drop a table.
- */
- public void dropTable() throws Exception {
- TSConnection con = getTSEISConnection();
- System.out.println("TSEISConnectin.dropTable." + con);
- con.dropTable();
- }
-
- /*
- * @name begin
- *
- * @desc begin a transaction.
- */
- public void begin() throws Exception {
- TSConnection con = getTSEISConnection();
- con.begin();
- }
-
- /*
- * @name rollback
- *
- * @desc rollback a transaction
- */
- public void rollback() {
- TSConnection con = getTSEISConnection();
- con.rollback();
- }
-
- /*
- * @name close
- *
- * @desc close a connection to the EIS.
- */
- public void close() throws Exception {
- if (mc == null)
- return; // already be closed
- mc.removeTSConnection(this);
- mc.sendEvent(ConnectionEvent.CONNECTION_CLOSED, null, this);
- mc = null;
- }
-
- /*
- * @name isClosed
- *
- * @desc checks if the connection is close.
- */
- public boolean isClosed() {
- return (mc == null);
- }
-
- /*
- * @name associateConnection
- *
- * @desc associate connection
- *
- * @param TSManagedConnection newMc
- */
- void associateConnection(TSManagedConnection newMc) {
-
- if (checkIfValid()) {
- mc.removeTSConnection(this);
- }
- newMc.addTSConnection(this);
- mc = newMc;
- }
-
- public boolean checkIfValid() {
- if (mc == null) {
- return false;
- }
- return true;
- }
-
- /*
- * @name getTSEISConnection
- *
- * @desc get a Jdbc connection
- *
- * @return Connection
- */
- TSConnection getTSEISConnection() {
- try {
- if (checkIfValid()) {
- return mc.getTSConnection();
- } else {
- return null;
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- return null;
- }
- }
-
- void invalidate() {
- mc = null;
- }
-
- public Hashtable getTempTable() {
- return getTSEISConnection().getTempTable();
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/TSEISDataSource.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/TSEISDataSource.java
deleted file mode 100644
index 655fb8772d..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/TSEISDataSource.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.connector.whitebox;
-
-import java.io.Serializable;
-import java.util.Vector;
-
-import javax.naming.Reference;
-
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-
-import jakarta.resource.Referenceable;
-import jakarta.resource.ResourceException;
-import jakarta.resource.spi.ConnectionManager;
-import jakarta.resource.spi.ConnectionRequestInfo;
-import jakarta.resource.spi.ManagedConnectionFactory;
-
-public class TSEISDataSource
- implements TSDataSource, Serializable, Referenceable {
-
- private String desc;
-
- private ManagedConnectionFactory mcf;
-
- private ConnectionManager cm;
-
- private Reference reference;
-
- /*
- * @name createTSConnectionFactory
- *
- * @desc TSConnectionFactory constructor
- *
- * @param ManagedConnectionFactor, ConnectionManager
- */
- public TSEISDataSource(ManagedConnectionFactory mcf, ConnectionManager cm) {
- this.mcf = mcf;
- if (cm == null) {
-
- } else {
- this.cm = cm;
- }
- }
-
- /*
- * @name getConnection
- *
- * @desc Gets a connection to the EIS.
- *
- * @return Connection
- *
- * @exception Exception
- */
- public TSConnection getConnection() throws Exception {
- try {
- return (TSConnection) cm.allocateConnection(mcf, null);
- } catch (Exception ex) {
- throw new Exception(ex.getMessage());
- }
- }
-
- /*
- * @name getConnection
- *
- * @desc Gets a connection to the EIS.
- *
- * @return Connection
- *
- * @exception Exception
- */
- public TSConnection getConnection(String username, String password)
- throws Exception {
- try {
- ConnectionRequestInfo info = new TSConnectionRequestInfo(username,
- password);
- return (TSConnection) cm.allocateConnection(mcf, info);
- } catch (ResourceException ex) {
- throw new Exception(ex.getMessage());
- }
- }
-
- /*
- * @name getLog
- *
- * @desc Returns Log to client. Used for verification of callbacks.
- *
- * @return Log
- */
- @Override
- public Vector getLog() {
- return (ConnectorStatus.getConnectorStatus().getLogVector());
- }
-
- /*
- * @name getStateLog
- *
- * @desc Returns Log to client. Used for verification of callbacks.
- *
- * @return Log
- */
- @Override
- public Vector getStateLog() {
- return (ConnectorStatus.getConnectorStatus().getStateLogVector());
- }
-
- /*
- * @name checkConnectionManager
- *
- * @desc return true if ConnectionManager is Serializable
- *
- * @return boolean
- */
- public boolean checkConnectionManager() {
-
- if (cm instanceof Serializable)
- return true;
- else
- return false;
- }
-
- /*
- * @name clearLog
- *
- * @desc Empties the Log
- */
- @Override
- public void clearLog() {
- // In order to support the case where we want to be able to deploy one
- // time and then run through all tests, we want to ensure that the log is
- // not accidentally deleted by a client side test. (In the past, it was
- // acceptable to delete this log at the end of a client tests run because
- // rars would be undeployed and then re-deployed, thus re-creating this
- // log.)
- // but this may not be true for case of standalone connector.
- // ConnectorStatus.getConnectorStatus().purge();
- }
-
- /*
- * @name setLogFlag
- *
- * @desc Turns logging on/off
- */
- @Override
- public void setLogFlag(boolean b) {
- ConnectorStatus.getConnectorStatus().setLogFlag(b);
- }
-
- /*
- * @name setReference
- *
- * @desc
- */
- public void setReference(Reference reference) {
- this.reference = reference;
- }
-
- /*
- * @name getReference
- *
- * @desc
- */
- public Reference getReference() {
- return reference;
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/TSManagedConnection.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/TSManagedConnection.java
deleted file mode 100644
index cb7e81e8c5..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/TSManagedConnection.java
+++ /dev/null
@@ -1,443 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.connector.whitebox;
-
-import java.io.PrintWriter;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import javax.security.auth.Subject;
-import javax.transaction.xa.XAResource;
-
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-
-import jakarta.resource.NotSupportedException;
-import jakarta.resource.ResourceException;
-import jakarta.resource.spi.ConnectionEventListener;
-import jakarta.resource.spi.ConnectionRequestInfo;
-import jakarta.resource.spi.IllegalStateException;
-import jakarta.resource.spi.LocalTransaction;
-import jakarta.resource.spi.ManagedConnection;
-import jakarta.resource.spi.ManagedConnectionFactory;
-import jakarta.resource.spi.ManagedConnectionMetaData;
-import jakarta.resource.spi.SecurityException;
-import jakarta.resource.spi.security.PasswordCredential;
-
-public class TSManagedConnection implements ManagedConnection {
-
- private TSXAConnection xacon;
-
- private TSConnection con;
-
- private TSConnectionEventListener jdbcListener;
-
- private PasswordCredential passCred;
-
- private ManagedConnectionFactory mcf;
-
- private PrintWriter logWriter;
-
- private boolean supportsXA;
-
- private boolean supportsLocalTx;
-
- private boolean destroyed;
-
- private Set connectionSet; // set of TSEISConnection
-
- public TSManagedConnection(ManagedConnectionFactory mcf,
- PasswordCredential passCred, TSXAConnection xacon, TSConnection con,
- boolean supportsXA, boolean supportsLocalTx) {
- this.mcf = mcf;
- this.passCred = passCred;
- this.xacon = xacon;
- this.con = con;
- this.supportsXA = supportsXA;
- this.supportsLocalTx = supportsLocalTx;
- connectionSet = new HashSet();
- jdbcListener = new TSConnectionEventListener(this);
- if (xacon != null) {
- xacon.addConnectionEventListener(jdbcListener);
- }
-
- }
-
- // XXX should throw better exception
- private void throwResourceException(Exception ex) throws ResourceException {
-
- ResourceException re = new ResourceException(
- "Exception: " + ex.getMessage());
- re.initCause(ex);
- throw re;
- }
-
- /*
- * @name getConnection
- *
- * @desc Gets a connection to the underlying EIS.
- *
- * @param Subject, ConnectionRequestInfo
- *
- * @return Object
- *
- * @exception ResourceException
- *
- * @see
- */
- @Override
- public Object getConnection(Subject subject,
- ConnectionRequestInfo connectionRequestInfo) throws ResourceException {
-
- PasswordCredential pc = Util.getPasswordCredential(mcf, subject,
- connectionRequestInfo);
- if (!Util.isPasswordCredentialEqual(pc, passCred)) {
- throw new SecurityException(
- "Principal does not match. Reauthentication not supported");
- }
- checkIfDestroyed();
- TSEISConnection jdbcCon = new TSEISConnection(this, this.supportsLocalTx);
- addTSConnection(jdbcCon);
- return jdbcCon;
- }
-
- /*
- * @name destroy
- *
- * @desc destroys connection to the underlying EIS.
- *
- * @exception ResourceException
- */
- @Override
- public void destroy() throws ResourceException {
- try {
- if (destroyed)
- return;
- destroyed = true;
- Iterator it = connectionSet.iterator();
- while (it.hasNext()) {
- TSEISConnection jdbcCon = (TSEISConnection) it.next();
- jdbcCon.invalidate();
- ConnectorStatus.getConnectorStatus()
- .logAPI("TSManagedConnection.destroy", "", "");
- }
- connectionSet.clear();
- con.close();
- if (xacon != null)
- xacon.close();
- } catch (Exception ex) {
- throwResourceException(ex);
- }
- }
-
- /*
- * @name cleanup
- *
- * @desc recycles the connection from the connection pool which is being
- * handed over to the new client.
- *
- * @exception ResourceException
- */
- public void cleanup() throws ResourceException {
- try {
- checkIfDestroyed();
- Iterator it = connectionSet.iterator();
- while (it.hasNext()) {
- TSEISConnection jdbcCon = (TSEISConnection) it.next();
- jdbcCon.invalidate();
- ConnectorStatus.getConnectorStatus()
- .logAPI("TSManagedConnection.cleanup", "", "");
- }
- connectionSet.clear();
- if (xacon != null) {
- con.close();
- con = xacon.getConnection();
- } else if (con != null) {
- con.setAutoCommit(true);
- }
- } catch (Exception ex) {
- throwResourceException(ex);
- }
- }
-
- /*
- * @name associateConnection
- *
- * @desc Used by the container to change the association of an
- * application-level connection handle with a ManagedConneciton instance.
- *
- * @param Object
- *
- * @exception ResourceException
- */
- @Override
- public void associateConnection(Object connection) throws ResourceException {
-
- checkIfDestroyed();
- if (connection instanceof TSEISConnection) {
- TSEISConnection jdbcCon = (TSEISConnection) connection;
- jdbcCon.associateConnection(this);
- ConnectorStatus.getConnectorStatus()
- .logAPI("TSManagedConnection.associateConnection", "connection", "");
- } else {
- throw new IllegalStateException(
- "Invalid connection object: " + connection);
- }
- }
-
- /*
- * @name addConnectionEventListener
- *
- * @desc Used by the container to change the association of an
- * application-level connection handle with a ManagedConneciton instance.
- *
- * @param ConnectionEventListener
- */
- @Override
- public void addConnectionEventListener(ConnectionEventListener listener) {
- ConnectorStatus.getConnectorStatus().logAPI(
- "TSManagedConnection.addConnectionEventListener", "listener", "");
- jdbcListener.addConnectorListener(listener);
- }
-
- /*
- * @name removeConnectionEventListener
- *
- * @desc Removes an already registered connection event listener from the
- * ManagedConnection instance.
- *
- * @param ConnectionEventListener
- */
- @Override
- public void removeConnectionEventListener(ConnectionEventListener listener) {
- ConnectorStatus.getConnectorStatus().logAPI(
- "TSManagedConnection.removeConnectionEventListener", "listener", "");
- jdbcListener.removeConnectorListener(listener);
- }
-
- /*
- * @name getXAResource
- *
- * @desc Returns an javax.transaction.xa.XAresource instance.
- *
- * @return XAResource
- *
- * @exception ResourceException
- */
- @Override
- public XAResource getXAResource() throws ResourceException {
- if (!supportsXA) {
- throw new NotSupportedException("XA transaction not supported");
- }
- try {
- checkIfDestroyed();
- ConnectorStatus.getConnectorStatus().logAPI(
- "TSManagedConnection.getXAResource", "", "xacon.getXAResource");
- return xacon.getXAResource(this);
- } catch (Exception ex) {
- throwResourceException(ex);
- return null;
- }
- }
-
- /*
- * @name getLocalTransaction
- *
- * @desc Returns an jakarta.resource.spi.LocalTransaction instance.
- *
- * @return LocalTransaction
- *
- * @exception ResourceException
- */
- @Override
- public LocalTransaction getLocalTransaction() throws ResourceException {
- if (!supportsLocalTx) {
- throw new NotSupportedException("Local transaction not supported");
- } else {
- checkIfDestroyed();
- ConnectorStatus.getConnectorStatus().logAPI(
- "TSManagedConnection.getLocalTransaction", "",
- "LocalTransactionImpl");
- return new LocalTransactionImpl(this);
- }
- }
-
- /*
- * @name getMetaData
- *
- * @desc Gets the metadata information for this connection's underlying EIS
- * resource manager instance.
- *
- * @return ManagedConnectionMetaData
- *
- * @exception ResourceException
- */
- @Override
- public ManagedConnectionMetaData getMetaData() throws ResourceException {
- checkIfDestroyed();
- return new MetaDataImpl(this);
- }
-
- /*
- * @name setLogWriter
- *
- * @desc Sets the log writer for this ManagedConnection instance.
- *
- * @param PrintWriter
- *
- * @exception ResourceException
- */
- @Override
- public void setLogWriter(PrintWriter out) throws ResourceException {
- this.logWriter = out;
- }
-
- /*
- * @name getLogWriter
- *
- * @desc Gets the log writer for this ManagedConnection instance.
- *
- * @return PrintWriter
- *
- * @exception ResourceException
- */
- @Override
- public PrintWriter getLogWriter() throws ResourceException {
- return logWriter;
- }
-
- /*
- * @name getTSConnection
- *
- * @desc Returns the Jdbc Connection.
- *
- * @return PrintWriter
- *
- * @exception ResourceException
- */
- public TSConnection getTSConnection() throws ResourceException {
- checkIfDestroyed();
- return con;
- }
-
- /*
- * @name isDestroyed
- *
- * @desc Checks if the connection is destroyed.
- *
- * @return boolean
- */
-
- boolean isDestroyed() {
- return destroyed;
- }
-
- /*
- * @name getPasswordCredential
- *
- * @desc Gets the PasswordCredential.
- *
- * @return String
- */
- public PasswordCredential getPasswordCredential() {
- return passCred;
-
- }
-
- /*
- * @name sendEvent
- *
- * @desc Send an Event .
- *
- * @param int, Exception
- */
- void sendEvent(int eventType, Exception ex) {
- ConnectorStatus.getConnectorStatus().logAPI("TSManagedConnection.sendEvent",
- "eventType|ex", "");
- jdbcListener.sendEvent(eventType, ex, null);
- }
-
- /*
- * @name sendEvent
- *
- * @desc Send an Event .
- *
- * @param int, Exception, Object
- */
- void sendEvent(int eventType, Exception ex, Object connectionHandle) {
- ConnectorStatus.getConnectorStatus().logAPI("TSManagedConnection.sendEvent",
- "eventType|ex|connectionHandle", "");
- jdbcListener.sendEvent(eventType, ex, connectionHandle);
- }
-
- /*
- * @name removeTSConnection
- *
- * @desc Removes a connection from the connection pool.
- *
- * @param TSEISConnection
- */
- public void removeTSConnection(TSEISConnection jdbcCon) {
- ConnectorStatus.getConnectorStatus()
- .logAPI("TSManagedConnection.removeTSConnection", "jdbcCon", "");
- connectionSet.remove(jdbcCon);
- }
-
- /*
- * @name addTSConnection
- *
- * @desc Add a connection to the connection pool.
- *
- * @param TSEISConnection
- */
- public void addTSConnection(TSEISConnection jdbcCon) {
- ConnectorStatus.getConnectorStatus()
- .logAPI("TSManagedConnection.addTSConnection", "jdbcCon", "");
- connectionSet.add(jdbcCon);
- }
-
- /*
- * @name checkIfDestroyed
- *
- * @desc Checks if the connection is destroyed.
- *
- * @param TSEISConnection
- */
- private void checkIfDestroyed() throws ResourceException {
- if (destroyed) {
- throw new IllegalStateException("Managed connection is closed");
- }
- }
-
- /*
- * @name getManagedConnectionFactory
- *
- * @desc Gets a managed connection factory instance.
- *
- * @return ManagedConnectionFactory
- */
- public ManagedConnectionFactory getManagedConnectionFactory() {
- ConnectorStatus.getConnectorStatus().logAPI(
- "TSManagedConnection.getManagedConnectionFactory", "",
- "ManagedConnectionFactory");
- return mcf;
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/TSResourceManager.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/TSResourceManager.java
deleted file mode 100644
index 0ac23b3a80..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/TSResourceManager.java
+++ /dev/null
@@ -1,388 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-/*
- * @(#)TSResourceManager.java 1.0 06/06/02
- */
-
-package com.sun.ts.tests.common.connector.whitebox;
-
-import java.util.Enumeration;
-import java.util.Hashtable;
-
-import javax.transaction.xa.XAException;
-import javax.transaction.xa.XAResource;
-import javax.transaction.xa.Xid;
-
-/**
- * Resource Manager for the TSeis. Completely based on JTS.
- *
- * @version 1.0, 06/06/02
- * @author Binod P.G
- */
-public class TSResourceManager {
-
- private boolean opened = false;
-
- private Hashtable association = new Hashtable();
-
- /**
- * Creates the Resource Manager.
- */
- public TSResourceManager() {
- openRM();
- }
-
- /**
- * Opens the Resource Manager.
- */
- public void openRM() {
- if (!opened) {
- opened = true;
- }
- }
-
- /**
- * Closes the Resource Manager.
- */
- public void closeRM() {
- opened = false;
- association.clear();
- }
-
- /**
- * Starts the new Global Transaction branch. transaction can be started in
- * three ways.
- *
- * 1. With no flags (TMNOFLAGS) : This is starting a new transaction
- *
- *
- * 2. With join flag(TMJOIN) : This is joining new transaction
- *
- *
- * 3. With resume flag(TRESUME) : This is resuming a suspended transaction
- *
- *
- * @param xid
- * Global Id for the transaction.
- * @param flags
- * Flags used for Transaction. For more details see JTA spec.
- * @param con
- * Connection involved in the Global Transaction.
- * @throws XAExcpetion
- * In case of a failure / Invalid flag / Invalid XA protocol.
- */
- public void start(Xid xid, int flags, TSConnection con) throws XAException {
- System.out.println("start." + flags + "." + xid + "..." + con);
- sanityCheck(xid, flags, "start");
-
- if (flags == XAResource.TMNOFLAGS) {
- TSXaTransaction txn = new TSXaTransaction(xid);
- txn.setStatus(TSXaTransaction.STARTED);
- if (con != null)
- txn.addConnection(con);
- association.put(xid, txn);
- } else if (flags == XAResource.TMJOIN) {
- TSXaTransaction txn = (TSXaTransaction) association.get(xid);
- if (con != null)
- txn.addConnection(con);
- association.put(xid, txn);
- } else if (flags == XAResource.TMRESUME) {
- TSXaTransaction txn = (TSXaTransaction) association.get(xid);
- txn.setStatus(TSXaTransaction.STARTED);
- association.put(xid, txn);
- }
- }
-
- /**
- * Ends the Global Transaction branch.
- *
- * @param xid
- * Global Id for the transaction.
- * @param flags
- * Flags used for Transaction. For more details see JTA spec.
- * @throws XAExcpetion
- * In case of a failure / Invalid flag / Invalid XA protocol.
- */
- public void end(Xid xid, int flags) throws XAException {
- sanityCheck(xid, flags, "end");
-
- int status = 0;
- if (flags == XAResource.TMFAIL)
- status = TSXaTransaction.ENDFAILED;
- if (flags == XAResource.TMSUSPEND)
- status = TSXaTransaction.SUSPENDED;
- if (flags == XAResource.TMSUCCESS)
- status = TSXaTransaction.ENDSUCCESSFUL;
-
- TSXaTransaction txn = (TSXaTransaction) association.get(xid);
- txn.setStatus(status);
- association.put(xid, txn);
- }
-
- /**
- * Prepare the Global Transaction branch.
- *
- * @param xid
- * Global Id for the transaction.
- * @throws XAExcpetion
- * In case of a failure / Invalid XA protocol.
- */
- public int prepare(Xid xid) throws XAException {
- sanityCheck(xid, XAResource.TMNOFLAGS, "prepare");
-
- TSXaTransaction txn = (TSXaTransaction) association.get(xid);
- int ret;
- try {
- ret = txn.prepare();
- } catch (XAException xe) {
- // If an prepare fails, Transaction Manager doesnt need to rollback
- // the transaction explicitely. So remove the particular xid.
- System.out.println("Self.rollbak");
- txn.rollback();
- association.remove(xid);
- throw xe;
- }
- txn.setStatus(TSXaTransaction.PREPARED);
- association.put(xid, txn);
- return ret;
- }
-
- /**
- * Commits the Global Transaction branch.
- *
- * @param xid
- * Global Id for the transaction.
- * @throws XAExcpetion
- * In case of a failure / Invalid XA protocol.
- */
- public void commit(Xid xid, boolean onePhase) throws XAException {
-
- if (onePhase) {
- sanityCheck(xid, XAResource.TMNOFLAGS, "1pccommit");
- } else {
- sanityCheck(xid, XAResource.TMNOFLAGS, "2pccommit");
- }
-
- TSXaTransaction txn = (TSXaTransaction) association.get(xid);
-
- if (txn != null) {
- try {
- txn.commit(onePhase);
- } catch (XAException eb) {
- throw new XAException(XAException.XA_RBROLLBACK);
- } catch (Exception e) {
- throw new XAException(XAException.XAER_RMERR);
- } finally {
- association.remove(xid);
- }
- }
- }
-
- /**
- * Rolls back the Global Transaction branch.
- *
- * @param xid
- * Global Id for the transaction.
- * @throws XAExcpetion
- * In case of a failure / Invalid XA protocol.
- */
- public void rollback(Xid xid) throws XAException {
-
- sanityCheck(xid, XAResource.TMNOFLAGS, "rollback");
-
- TSXaTransaction txn = (TSXaTransaction) association.get(xid);
- if (txn != null) {
- try {
- txn.rollback();
- } catch (Exception e) {
- throw new XAException(XAException.XAER_RMERR);
- } finally {
- association.remove(xid);
- }
- }
- }
-
- /**
- * Get the Transaction status of a Connection.
- *
- * @param con
- * Connection involved.
- */
- int getTransactionStatus(TSConnection con) {
- Enumeration e = association.keys();
- while (e.hasMoreElements()) {
- Xid id = (Xid) e.nextElement();
- TSXaTransaction txn = (TSXaTransaction) association.get(id);
- Hashtable connections = txn.getConnections();
- Enumeration e1 = connections.keys();
- while (e1.hasMoreElements()) {
- TSConnection temp = (TSConnection) e1.nextElement();
- if (con == temp) {
- return txn.getStatus();
- }
- }
- }
- return TSXaTransaction.NOTRANSACTION;
- }
-
- /**
- * Reads a particular key in a distributed transaction.
- *
- * @param key
- * Key to be read.
- * @param con
- * Connection involved.
- * @throws TSEIExcpetion
- * If an error occurs.
- */
- DataElement read(String key, TSConnection con) throws TSEISException {
- System.out.println("ResourceManager.read");
- Enumeration e = association.keys();
- while (e.hasMoreElements()) {
- Xid xid = (Xid) e.nextElement();
- TSXaTransaction txn = (TSXaTransaction) association.get(xid);
- Hashtable connections = txn.getConnections();
- if (connections.containsKey(con)) {
- return txn.read(key);
- }
- }
- return null;
- }
-
- /**
- * Do the sanity check.
- *
- * @param xid
- * Global Id for the transaction branch.
- * @param flags
- * Flag sent by the Transaction Manager.
- * @throws XAExcpetion
- * In case of an invalid XA protocol.
- */
- private void sanityCheck(Xid xid, int flags, String operation)
- throws XAException {
- // Sanity checks for the xa_start operation.
- if ((operation != null) && (operation.equals("start"))) {
-
- if (!(flags == XAResource.TMNOFLAGS || flags == XAResource.TMJOIN
- || flags == XAResource.TMRESUME)) {
- throw new XAException(XAException.XAER_INVAL);
- }
-
- // For TMNOFLAGS xid should not be known to RM.
- if (flags == XAResource.TMNOFLAGS) {
- if (association.containsKey(xid)) {
- throw new XAException(XAException.XAER_DUPID);
- }
- }
-
- // For TMJOIN xid should be known to RM.
- if (flags == XAResource.TMJOIN) {
- if (!association.containsKey(xid)) {
- throw new XAException(XAException.XAER_INVAL);
- }
-
- TSXaTransaction txn = (TSXaTransaction) association.get(xid);
- if (!(txn.getStatus() == TSXaTransaction.STARTED
- || txn.getStatus() == TSXaTransaction.ENDSUCCESSFUL)) {
- throw new XAException(XAException.XAER_PROTO);
- }
- }
-
- if (flags == XAResource.TMRESUME) {
- if (!association.containsKey(xid)) {
- throw new XAException(XAException.XAER_INVAL);
- }
-
- TSXaTransaction txn = (TSXaTransaction) association.get(xid);
- if (txn.getStatus() != TSXaTransaction.SUSPENDED) {
- throw new XAException(XAException.XAER_PROTO);
- }
- }
- }
-
- // End operation.
- if ((operation != null) && (operation.equals("end"))) {
-
- if (!(flags == XAResource.TMSUSPEND || flags == XAResource.TMFAIL
- || flags == XAResource.TMSUCCESS)) {
- throw new XAException(XAException.XAER_INVAL);
- }
-
- if (!association.containsKey(xid)) {
- throw new XAException(XAException.XAER_INVAL);
- }
-
- TSXaTransaction txn = (TSXaTransaction) association.get(xid);
- if (!(txn.getStatus() == TSXaTransaction.STARTED
- || txn.getStatus() == TSXaTransaction.ENDSUCCESSFUL)) {
- throw new XAException(XAException.XAER_PROTO);
- }
-
- }
-
- // Prepare operation.
- if ((operation != null) && (operation.equals("prepare"))) {
-
- TSXaTransaction txn = (TSXaTransaction) association.get(xid);
- if (txn.getStatus() != TSXaTransaction.ENDFAILED
- && txn.getStatus() != TSXaTransaction.ENDSUCCESSFUL) {
- throw new XAException(XAException.XAER_PROTO);
- }
-
- }
-
- // 2PC Commit operation.
- if ((operation != null) && (operation.equals("2pccommit"))) {
-
- TSXaTransaction txn = (TSXaTransaction) association.get(xid);
- if (txn.getStatus() != TSXaTransaction.PREPARED) {
- throw new XAException(XAException.XAER_PROTO);
- }
-
- }
-
- // 1PC Commit operation.
- if ((operation != null) && (operation.equals("1pccommit"))) {
-
- TSXaTransaction txn = (TSXaTransaction) association.get(xid);
- if (txn.getStatus() != TSXaTransaction.ENDSUCCESSFUL
- && txn.getStatus() != TSXaTransaction.ENDFAILED) {
- throw new XAException(XAException.XAER_PROTO);
- }
-
- }
-
- // Rollback operation.
- if ((operation != null) && (operation.equals("rollback"))) {
-
- TSXaTransaction txn = (TSXaTransaction) association.get(xid);
- if (txn != null) {
- if (txn.getStatus() != TSXaTransaction.PREPARED
- && txn.getStatus() != TSXaTransaction.ENDSUCCESSFUL
- && txn.getStatus() != TSXaTransaction.ENDFAILED) {
- throw new XAException(XAException.XAER_PROTO);
- }
- }
- }
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/TSSecurityContext.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/TSSecurityContext.java
deleted file mode 100755
index e3d1f27f86..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/TSSecurityContext.java
+++ /dev/null
@@ -1,424 +0,0 @@
-/*
- * Copyright (c) 2008, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.common.connector.whitebox;
-
-import java.security.Principal;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.security.auth.Subject;
-import javax.security.auth.callback.Callback;
-import javax.security.auth.callback.CallbackHandler;
-import javax.security.auth.callback.UnsupportedCallbackException;
-
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-
-import jakarta.resource.spi.work.SecurityContext;
-import jakarta.security.auth.message.callback.CallerPrincipalCallback;
-import jakarta.security.auth.message.callback.GroupPrincipalCallback;
-import jakarta.security.auth.message.callback.PasswordValidationCallback;
-
-/*
- * This is used to facilitate testing of the SecurityContext class.
- * The things to note/remember about this class are:
- * - there are two types of security scenarios RA's utilize for
- * passing creds: Case-1 and Case-2 security.
- * Case-1: use creds that are expected to exist on the Appserver
- * Case-2: set up mappings in appserver (to map EIS creds to AS creds)
- * then the RA can flow EIS creds to AS and let AS handle mappings.
- * - a RA can NOT do case-1 and case-2 at the same time. a RA must be
- * configured to do only ONE case at a time. (the configuration is usually
- * done by AS ina proprietary way. For RI(GFv3), Case-1 is default, and
- * Case-2 is done by specifying mapping in domain.xml.
- * - CPC *must* be called after GPC and PVC
- * - PVC *should* have same creds as CPC
- * - due to spec optimization, GPC can be called without CPC but this
- * is somewhat controversial and not recommended.
- *
- */
-public class TSSecurityContext extends SecurityContext {
-
- private String userName = null; // server side username
-
- private String password = null; // server side pwd
-
- private String eisPrincipalName = null; // eis principal name
-
- private String description = null;
-
- private String logOutString = null;
-
- private boolean translationRequired; // true if case 2 security where we need
- // to map identities
-
- private boolean useCPC = true;
-
- private boolean useGPC = false;
-
- private boolean usePVC = false;
-
- private boolean addPrinToExecSubject = false;
-
- private boolean expectFailure = false;
-
- public TSSecurityContext(String userName, String password,
- String eisPrincipalName, boolean translationRequired) {
- this.userName = userName;
- this.password = password;
- this.eisPrincipalName = eisPrincipalName;
- this.translationRequired = translationRequired;
-
- this.description = super.getDescription();
-
- debug("TSSecurityContext: userName=" + userName + " password=" + password
- + " eisPrincipalName=" + eisPrincipalName + " translationRequired="
- + translationRequired);
- }
-
- public void setCallbacks(boolean bCPC, boolean bGPC, boolean bPVC) {
- this.useCPC = bCPC;
- this.useGPC = bGPC;
- this.usePVC = bPVC;
- }
-
- public void setUserName(String val) {
- this.userName = val;
- }
-
- public String getUserName() {
- return this.userName;
- }
-
- public void setPassword(String val) {
- this.password = val;
- }
-
- public String getPassword() {
- return this.password;
- }
-
- public void setUseCPC(boolean val) {
- this.useCPC = val;
- }
-
- public boolean getUseCPC() {
- return this.useCPC;
- }
-
- public void setUseGPC(boolean val) {
- this.useGPC = val;
- }
-
- public boolean getUseGPC() {
- return this.useGPC;
- }
-
- public void setUsePVC(boolean val) {
- this.usePVC = val;
- }
-
- public boolean getUsePVC() {
- return this.usePVC;
- }
-
- public void setAddPrinToExecSubject(boolean val) {
- this.addPrinToExecSubject = val;
- }
-
- public boolean getAddPrinToExecSubject() {
- return this.addPrinToExecSubject;
- }
-
- public void setDescription(String val) {
- this.description = val;
- }
-
- public String getDescription() {
- return this.description;
- }
-
- public void setLogOutString(String val) {
- this.logOutString = val;
- }
-
- public String getLogOutString() {
- return this.logOutString;
- }
-
- public boolean isTranslationRequired() {
- return translationRequired;
- }
-
- public void setExpectFailure(boolean val) {
- this.expectFailure = val;
- }
-
- public boolean getExpectFailure() {
- return this.expectFailure;
- }
-
- /*
- * This is used to help verify assertion Connector:SPEC:229, which states a
- * couple requirements with the following being focused on within this method:
- * "The following conditions are applicable to the application server provider
- * while calling the setupSecurityContext method: the CallbackHandler
- * implementation passed as the argument handler to setupSecurityContext must
- * support the following JSR-196 Callbacks: CallerPrincipalCallback,
- * GroupPrincipalCallback, and PasswordValidationCallback"
- *
- * Mostly, this is here to verify that the 3 main callbacks are supported by
- * the vendors app server and that they can be used with a a couple different
- * scenarios (eg. calling some but not all callbacks, or using null
- * principals, etc)
- *
- * Related notes on testing callbacks: 1. must call CPC after PVC (CPC and PVC
- * should use same user identities) 2. PVC is for case-1 security only (not
- * case-2 of mapping) 3. It's not spec required but recommended we call CPC
- * after GPC though there is allowance for a spec optimization which would
- * allow calling GPC without CPC but its a somewhat controversial optimization
- * so for now, if you have a GPC, you should follow with a CPC 4. CPC can be
- * alone 5. if CPC is called, it basically trumps PVC/GPC so it shouldnt even
- * matter what is in PVC/GPC.
- *
- */
- public void doCallbackVerification(CallbackHandler callbackHandler,
- Subject execSubject, Subject serviceSubject) {
-
- List callbacks = new ArrayList();
- PasswordValidationCallback pvc = null;
- GroupPrincipalCallback gpc = null;
- CallerPrincipalCallback cpc = null;
- String[] gpcGroups = { "phakegrp1", "phakegrp2" };
-
- debug("doCallbackVerification(): translationRequired = "
- + translationRequired);
-
- if (addPrinToExecSubject && (userName != null)) {
- debug("doCallbackVerification(): adding principal: " + userName
- + " to execSubject.");
- execSubject.getPrincipals().add(new SimplePrincipal(userName, password));
- }
-
- if (useGPC) {
- // we are passing invalid grps to the GPC but it should not
- // matter if the CPC is specified after the GPC.
- gpc = new GroupPrincipalCallback(execSubject, gpcGroups);
- debug(
- "doCallbackVerification(): - GPC with groups={phakegrp1, phakegrp2}");
- callbacks.add(gpc);
- }
-
- if (usePVC && !translationRequired) {
- // per JCA 1.6 spec (16.4.2) PVC can be used in Case-1 only.
- // NOTE: PVC user should match that of CPC
- debug("doCallbackVerification(): initializing PVC");
- char[] pwd = null;
- if (password != null) {
- // if password is supplied - use that first
- pwd = password.toCharArray();
- }
-
- if (userName != null) {
- // if userName is supplied - use that first
- pvc = new PasswordValidationCallback(execSubject, userName, pwd);
- debug("setting PVC with user [ " + userName + " ] + password [ "
- + password + " ]");
- } else {
- // the spec is unclear about initializating a PasswordValidationCallback
- // with a null
- // username so we should probably use something like a fake user name.
- // worth noting that the javadoc allows for null pwd.
- pvc = new PasswordValidationCallback(execSubject, "fk_usr", null);
- debug("setting PVC with user=fk_usr and password=null");
- }
- callbacks.add(pvc);
- }
-
- if (usePVC || useCPC) {
- if (translationRequired && (eisPrincipalName != null)) {
- // lets translate/map EIS to server domain prins
- debug("translationRequired, setting CPC with principal : "
- + eisPrincipalName);
- cpc = new CallerPrincipalCallback(execSubject,
- new SimplePrincipal(eisPrincipalName));
- } else if (!translationRequired && (userName != null)) {
- debug(
- "No translationRequired, setting CPC with userName : " + userName);
- cpc = new CallerPrincipalCallback(execSubject, userName);
- } else {
- debug("setting CPC with null Principal");
- cpc = new CallerPrincipalCallback(execSubject, (Principal) null);
- }
-
- callbacks.add(cpc);
- }
-
- Callback callbackArray[] = new Callback[callbacks.size()];
- try {
- callbackHandler.handle(callbacks.toArray(callbackArray));
-
- // if we made it here, then no exceptions - we can assume success since
- // we got no unsupported callback exceptions.
- String sval = "";
- if (this.logOutString != null) {
- sval = this.logOutString;
- } else {
- sval = "setupSecurityContext callbackhandler supports required callback types.";
- }
- ConnectorStatus.getConnectorStatus().logState(sval);
- debug(sval);
-
- // we shouldn't need to check if authentication succeeded - but for debug
- // purposes we will keep this here?
- if (!translationRequired && usePVC && (pvc != null)
- && (!pvc.getResult())) {
- debug("doCallbackVerification(): PVC failed");
- // ConnectorStatus.getConnectorStatus().logState("PVC failed");
- } else if (!translationRequired && usePVC && (pvc != null)) {
- debug("doCallbackVerification(): PVC succeeded");
- // ConnectorStatus.getConnectorStatus().logState("PVC succeeded");
- }
-
- } catch (UnsupportedCallbackException e) {
- String sval = "";
- if (this.expectFailure && (this.logOutString != null)) {
- sval = "Expected Exception: " + this.logOutString;
- } else {
- sval = "doCallbackVerification(): callbackhandler does not support a required callback type!";
- }
- ConnectorStatus.getConnectorStatus().logState(sval);
- debug(sval);
- debug("UnsupportedCallbackException message is : " + e.getMessage());
- e.printStackTrace();
-
- } catch (Exception e) {
- String sval = "";
- if (this.expectFailure && (this.logOutString != null)) {
- sval = "Expected Exception: " + this.logOutString;
- } else {
- sval = "doCallbackVerification(): callbackhandler threw unexpected exception!";
- }
- ConnectorStatus.getConnectorStatus().logState(sval);
- debug(sval);
- e.printStackTrace();
- debug("doCallbackVerification(): exception occured : " + e.getMessage());
- }
-
- }
-
- /*
- *
- * The executionSubject arg must be non-null and it must not be read-only. It
- * is expected that this method will populate this executionSubject with
- * principals and credentials that would be flown into the application server.
- *
- * The serviceSubject argument may be null. If it is not null, it must not be
- * read-only. (from ee spec, section 16.4.1) Note: this differs from javadoc
- * comments and insuch case, spec takes precedence. The serviceSubject
- * represents the application server and it may be used by the Work
- * implementation to retrieve Principals and credentials necessary to
- * establish a connection to the EIS (in the cause of mutual-auth like
- * scenarios). If the Subject is not null, the Work implementation may collect
- * the server cred as necessary, by using the callback handler passed to them
- * .
- */
- @Override
- public void setupSecurityContext(CallbackHandler callbackHandler,
- Subject execSubject, Subject serviceSubject) {
-
- // validate args are spec compliant
- validateCallbackHandler(callbackHandler);
- validateExecSubject(execSubject);
- validateServiceSubject(serviceSubject);
-
- // now make sure the 3 callback types are supported by the App Server
- doCallbackVerification(callbackHandler, execSubject, serviceSubject);
-
- }
-
- /*
- * this method is used to perform a simple validation that the callbackHandler
- * is spec compliant per assertion Connector:SPEC:229
- */
- private void validateCallbackHandler(CallbackHandler callbackHandler) {
- String str = "";
-
- // assist with assertion Connector:SPEC:229
- if (callbackHandler != null) {
- str = "setupSecurityContext() called with non-null callbackHandler";
- } else {
- str = "setupSecurityContext() called with invalid (null) callbackHandler";
- }
- debug(str);
- ConnectorStatus.getConnectorStatus().logState(str);
-
- }
-
- /*
- * this method is used to perform a simple validation that the execSubject is
- * spec compliant per assertion Connector:SPEC:230
- */
- private void validateExecSubject(Subject execSubject) {
- String str = "";
-
- if ((execSubject != null) && (!execSubject.isReadOnly())) {
- str = "setupSecurityContext() called with valid executionSubject";
- } else {
- str = "ERROR: setupSecurityContext() called with invalid executionSubject";
- }
- debug(str);
- ConnectorStatus.getConnectorStatus().logState(str);
-
- }
-
- /*
- * this method is used to perform a simple validation that the serviceSubject
- * is spec compliant per assertion Connector:SPEC:231
- */
- private void validateServiceSubject(Subject serviceSubject) {
- String str = "";
-
- if (serviceSubject == null) {
- // this is allowed according to jca spec setion 16.4.1
- str = "setupSecurityContext() called with valid serviceSubject";
- } else if ((serviceSubject != null) && (!serviceSubject.isReadOnly())) {
- // this is good: if serviceSubject != null, then it must not be readonly
- str = "setupSecurityContext() called with valid serviceSubject";
- } else if ((serviceSubject != null) && (serviceSubject.isReadOnly())) {
- // ohoh, serviceSubject !=null but it is readonly and this is not valid!
- str = "setupSecurityContext() called with invalid executionSubject";
- }
- debug(str);
- ConnectorStatus.getConnectorStatus().logState(str);
-
- }
-
- public String toString() {
- StringBuffer toString = new StringBuffer("{");
- toString.append("userName : " + userName);
- toString.append(", password : " + password);
- toString.append(", eisPrincipalName : " + eisPrincipalName);
- toString.append(", translationRequired : " + translationRequired);
- toString.append("}");
- return toString.toString();
- }
-
- public void debug(String message) {
- Debug.trace(message);
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/TSXAConnectionImpl.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/TSXAConnectionImpl.java
deleted file mode 100644
index c958330646..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/TSXAConnectionImpl.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.connector.whitebox;
-
-import javax.transaction.xa.XAResource;
-
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-
-import jakarta.resource.spi.ConnectionEventListener;
-
-public class TSXAConnectionImpl implements TSXAConnection {
-
- public TSXAConnectionImpl() {
-
- }
-
- public XAResource getXAResource(TSManagedConnection mc) throws Exception {
- System.out.println("TSXAConnectionImpl.getXAResource");
- XAResourceImpl xaimpl = new XAResourceImpl(mc);
- return xaimpl;
- }
-
- public TSConnection getConnection() throws Exception {
- try {
-
- TSConnection ctscon = TSeis.getTSeis().getConnection();
- System.out.println("TSXAConnectionImpl.getConnection");
- ConnectorStatus.getConnectorStatus()
- .logAPI("TSConnectionImpl.getConnection", "", "");
- return ctscon;
- } catch (Exception ex) {
- ex.getMessage();
- return null;
- }
- }
-
- public TSConnection getConnection(String user, char[] password)
- throws Exception {
- try {
-
- TSConnection ctscon = TSeis.getTSeis().getConnection(user, password);
- ConnectorStatus.getConnectorStatus()
- .logAPI("TSConnectionImpl.getConnection", "", "");
- return ctscon;
- } catch (Exception ex) {
- ex.getMessage();
- return null;
- }
- }
-
- public void close() throws Exception {
-
- }
-
- public void addConnectionEventListener(ConnectionEventListener listener) {
-
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/TSXaTransaction.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/TSXaTransaction.java
deleted file mode 100644
index b66031bacf..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/TSXaTransaction.java
+++ /dev/null
@@ -1,294 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-/*
- * @(#)TSXaTransaction.java 1.0 06/06/02
- */
-
-package com.sun.ts.tests.common.connector.whitebox;
-
-import java.util.Enumeration;
-import java.util.Hashtable;
-
-import javax.transaction.xa.XAException;
-import javax.transaction.xa.XAResource;
-import javax.transaction.xa.Xid;
-
-/**
- * Class representing one Global Transaction.
- *
- * @version 1.0, 06/06/02
- * @author Binod P.G
- */
-public class TSXaTransaction {
-
- /** No Transaction . Default status **/
- static final int NOTRANSACTION = 0;
-
- /** Status indicating that Transaction has started **/
- static final int STARTED = 1;
-
- /** Status indicating that Transaction has been suspended **/
- static final int SUSPENDED = 2;
-
- /** Status indicating that Transaction has been ended with a failure **/
- static final int ENDFAILED = 3;
-
- /** Status indicating that Transaction has been ended with a success **/
- static final int ENDSUCCESSFUL = 4;
-
- /** Status indicating that Transaction has been prepared **/
- static final int PREPARED = 5;
-
- /** Field storing the status values **/
- private int status = 0;
-
- /** Connections involved in one transaction branch. Specifications doesnt **/
- /** stop from having more than one connection in global transaction **/
- private Hashtable connections = new Hashtable();
-
- /** Id of the transaction **/
- private Xid xid;
-
- /**
- * Creates a new Global Transaction object.
- *
- * @param id
- * Global Transaction Identifier.
- */
- public TSXaTransaction(Xid id) {
- this.xid = id;
- }
-
- /**
- * Adds the connection to this transaction.
- *
- * @param con
- * Connection involved in the transaction branch.
- */
- public void addConnection(TSConnection con) {
- connections.put(con, "");
- }
-
- /**
- * Return the connections involved as a hashtable.
- *
- * @return Connections.
- */
- Hashtable getConnections() {
- return connections;
- }
-
- /**
- * Sets the Status of the transaction.
- *
- * @param Status
- * of the transaction
- */
- public void setStatus(int status) {
- this.status = status;
- }
-
- /**
- * Get the status of the transaction.
- *
- * @return Status of the transaction.
- */
- public int getStatus() {
- return this.status;
- }
-
- /**
- * Prepare the transaction.
- *
- * @return The Vote of this branch in this transaction.
- * @throws XAException
- * If prepare fails.
- */
- public int prepare() throws XAException {
- System.out.println("TsXaTransaction.prepare");
- Hashtable ht = prepareTempTable();
-
- Enumeration e = ht.keys();
- while (e.hasMoreElements()) {
- System.out.println("TSXaTransaction.prepare.inTheLoop");
- String key = (String) e.nextElement();
- DataElement de = (DataElement) ht.get(key);
-
- if (de.getStatus() == DataElement.INSERTED) {
- try {
- TSeis.getTSeis().prepareInsert(de, xid);
- } catch (TSEISException ex) {
- throw new XAException(XAException.XA_RBROLLBACK);
- }
- }
- if (de.getStatus() == DataElement.UPDATED
- || de.getStatus() == DataElement.DELETED) {
- System.out.println("TSXaTransaction.prepare.updatePrepare");
- try {
- TSeis.getTSeis().prepareChange(de, xid);
- } catch (TSEISException ex) {
- throw new XAException(XAException.XA_RBROLLBACK);
- }
- }
- }
- return XAResource.XA_OK;
- }
-
- // Creates one temp table for the transaction.
- private Hashtable prepareTempTable() {
- System.out.println("TSXaTransaction.prepareTempTable");
- Hashtable temptable = new Hashtable();
-
- Enumeration e = connections.keys();
-
- while (e.hasMoreElements()) {
- System.out.println("TSXaTransaction.prepareTempTable.inTheLoop");
- TSConnection con = (TSConnection) e.nextElement();
- Hashtable temp = con.getTempTable();
-
- Enumeration e1 = temp.keys();
- while (e1.hasMoreElements()) {
- String key = (String) e1.nextElement();
- DataElement de = (DataElement) temp.get(key);
-
- if (temptable.containsKey(key)) {
- DataElement de1 = (DataElement) temptable.get(key);
- // Latest version should be used
- if (de.getVersion() >= de1.getVersion()) {
- temptable.put(key, de);
- }
- } else {
- temptable.put(key, de);
- }
- }
- con.rollback();
- }
-
- return temptable;
- }
-
- /**
- * Commits this Transaction.
- *
- * @param Boolean
- * indicating, whether it is a single-phase or 2-phase commit.
- * @throws XAException
- * If commit fails.
- */
- public void commit(boolean onePhase) throws XAException {
- System.out.println("TsXaTransaction.commit." + onePhase);
- if (onePhase) {
- Hashtable ht = prepareTempTable();
-
- Enumeration e = ht.keys();
- while (e.hasMoreElements()) {
- String key = (String) e.nextElement();
- DataElement de = (DataElement) ht.get(key);
-
- if (de.getStatus() == DataElement.INSERTED) {
- try {
- TSeis.getTSeis().actualInsert(de);
- } catch (TSEISException ex) {
- throw new XAException(XAException.XA_RBROLLBACK);
- }
- }
- if (de.getStatus() == DataElement.UPDATED) {
- try {
- TSeis.getTSeis().actualUpdate(de);
- } catch (TSEISException ex) {
- throw new XAException(XAException.XA_RBROLLBACK);
- }
- }
- if (de.getStatus() == DataElement.DELETED) {
- try {
- TSeis.getTSeis().actualDelete(de.getKey());
- } catch (TSEISException ex) {
- throw new XAException(XAException.XA_RBROLLBACK);
- }
- }
- }
- } else {
- TSeis.getTSeis().commit(xid);
- }
- }
-
- /**
- * Rolls back the transaction
- */
- public void rollback() {
- if (status == PREPARED) {
- TSeis.getTSeis().rollback(xid);
- } else {
- Enumeration e = connections.keys();
-
- while (e.hasMoreElements()) {
- TSConnection con = (TSConnection) e.nextElement();
- con.rollback();
- }
- }
- }
-
- /**
- * Check for the key in the transaction. If it is not readable return null.
- *
- * @param elementkey
- * Key to be read.
- * @return DataElement object.
- * @throws TSEISException
- * In case, read fails.
- */
- public DataElement read(String elementkey) throws TSEISException {
- Hashtable temptable = new Hashtable();
- Enumeration e = connections.keys();
-
- while (e.hasMoreElements()) {
- TSConnection con = (TSConnection) e.nextElement();
- Hashtable temp = con.getTempTable();
-
- Enumeration e1 = temp.keys();
- while (e1.hasMoreElements()) {
- String key = (String) e1.nextElement();
- DataElement de = (DataElement) temp.get(key);
-
- if (temptable.containsKey(key)) {
- DataElement de1 = (DataElement) temptable.get(key);
- // Latest version should be used
- if (de.getVersion() >= de1.getVersion()) {
- temptable.put(key, de);
- }
- } else {
- temptable.put(key, de);
- }
- }
- }
-
- if (temptable.containsKey(elementkey)) {
- DataElement de = (DataElement) temptable.get(elementkey);
- if (de.getStatus() == DataElement.DELETED) {
- throw new TSEISException("Data deleted");
- } else {
- return de;
- }
- } else {
- return null;
- }
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/TSeis.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/TSeis.java
deleted file mode 100644
index 8156363599..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/TSeis.java
+++ /dev/null
@@ -1,386 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.connector.whitebox;
-
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Vector;
-
-import javax.transaction.xa.Xid;
-
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-
-public class TSeis {
-
- private static TSeis eis;
-
- private Hashtable permtable = new Hashtable();
-
- private boolean commitflag = true;
-
- private TSConnectionImpl con1 = null;
-
- private TSConnectionImpl con2 = null;
-
- private TSConnectionImpl con3 = null;
-
- private TSConnectionImpl con4 = null;
-
- private TSConnectionImpl con5 = null;
-
- private Vector conset = null;
-
- public TSResourceManager rm = new TSResourceManager();
-
- /**
- * Singleton constructor
- */
- private TSeis() {
- conset = new Vector();
- con1 = new TSConnectionImpl();
- con2 = new TSConnectionImpl();
- con3 = new TSConnectionImpl();
- con4 = new TSConnectionImpl();
- con5 = new TSConnectionImpl();
- conset.addElement(con1);
- conset.addElement(con2);
- conset.addElement(con3);
- conset.addElement(con4);
- conset.addElement(con5);
- }
-
- /**
- * Singleton accessor
- */
- public static TSeis getTSeis() {
- if (eis == null) {
- eis = new TSeis();
- }
- return eis;
- }
-
- public synchronized TSConnection getConnection() {
- ConnectorStatus.getConnectorStatus().logAPI("TSeis.getConnection", "", "");
- TSConnectionImpl con;
-
- for (int i = 0; i < conset.size(); i++) {
- con = (TSConnectionImpl) conset.elementAt(i);
- if (con.lease()) {
- return con;
- }
- }
-
- con = new TSConnectionImpl();
- con.lease();
- conset.addElement(con);
- return con;
- }
-
- public synchronized TSConnection getConnection(String usr, char[] passwd) {
- ConnectorStatus.getConnectorStatus().logAPI("TSeis.getConnection",
- "usr,passwd", "");
- System.out.println("User is " + usr);
- if ((usr.equals("cts1") && passwd[0] == 'c' && passwd[1] == 't'
- && passwd[2] == 's' && passwd[3] == '1')
- || (usr.equals("cts2") && passwd[0] == 'c' && passwd[1] == 't'
- && passwd[2] == 's' && passwd[3] == '2')) {
- System.out.println("Passwd lenght is " + passwd.length);
-
- for (int in = 0; in < passwd.length; in++) {
- System.out.println("Password 3 is " + passwd[in]);
- }
- TSConnectionImpl con;
-
- for (int i = 0; i < conset.size(); i++) {
- con = (TSConnectionImpl) conset.elementAt(i);
- if (con.lease()) {
- return con;
- }
- }
-
- con = new TSConnectionImpl();
- con.lease();
- conset.addElement(con);
- return con;
- } else {
- System.out.println("Connection null returned");
- return null;
- }
- }
-
- public DataElement read(String key, TSConnection con) throws TSEISException {
-
- DataElement de = null;
- if (permtable.containsKey(key)) {
- de = (DataElement) permtable.get(key);
- }
-
- // Lets see if resource manager can read from a distributed transaction?
- DataElement element = rm.read(key, con);
-
- // May be connection is only in a local transaction. So read from
- // the connection cache.
- DataElement localElement = null;
- Hashtable tempTable = con.getTempTable();
- if (tempTable.containsKey(key)) {
- localElement = (DataElement) tempTable.get(key);
- }
-
- if (de == null && element == null && localElement == null) {
- throw new TSEISException("Data not found.");
- }
- if (element != null) {
- return element;
- } else if (localElement != null) {
- return localElement;
- } else {
- return de;
- }
- }
-
- public String readValue(String key, TSConnection con) throws TSEISException {
-
- DataElement de = read(key, con);
- return de.getValue();
- }
-
- public void insert(String key, String value, TSConnection con)
- throws TSEISException {
-
- boolean datapresent = false;
-
- try {
- read(key, con);
- datapresent = true;
- } catch (TSEISException tse) {
- }
-
- if (datapresent)
- throw new TSEISException("Duplicate Key");
-
- DataElement de = new DataElement(key, value);
-
- if ((getResourceManager()
- .getTransactionStatus(con) == TSXaTransaction.NOTRANSACTION)
- && con.getAutoCommit()) {
- de.setStatus(DataElement.COMMITTED);
- System.out.println("TSeis.insert.permtable");
- permtable.put(key, de);
- } else { // if (getResourceManager().getTransactionStatus(con) ==
- // TSResourceManager.INTRANSACTION)
- System.out.println("TSeis.insert.temptable");
- de.setStatus(DataElement.INSERTED);
- con.getTempTable().put(key, de);
- }
- }
-
- public void update(String key, String value, TSConnection con)
- throws TSEISException {
- DataElement de = read(key, con);
- de.updateVersion();
- de.setValue(value);
- if ((getResourceManager()
- .getTransactionStatus(con) == TSXaTransaction.NOTRANSACTION)
- && con.getAutoCommit()) {
- de.setStatus(DataElement.COMMITTED);
- System.out.println("TSeis.update.permtable");
- permtable.put(key, de);
- } else { // if (getResourceManager().getTransactionStatus(con) ==
- // TSResourceManager.INTRANSACTION)
- System.out.println("TSeis.update.temptable");
- if (de.getStatus() != DataElement.INSERTED) {
- de.setStatus(DataElement.UPDATED);
- }
- System.out.println("TSeis.update." + de.getKey() + de.getValue());
- con.getTempTable().put(key, de);
- }
- }
-
- public void delete(String key, TSConnection con) throws TSEISException {
- DataElement de = read(key, con);
- if ((getResourceManager()
- .getTransactionStatus(con) == TSXaTransaction.NOTRANSACTION)
- && con.getAutoCommit()) {
- System.out.println("TSeis.delete.permtable");
- permtable.remove(key);
- } else { // if (getResourceManager().getTransactionStatus(con) ==
- // TSResourceManager.INTRANSACTION)
- System.out.println("TSeis.delete.temptable");
- de.setStatus(DataElement.DELETED);
- con.getTempTable().put(key, de);
- }
- }
-
- public void returnConnection(TSConnectionImpl con) {
- con.expireLease();
- }
-
- public void dropTable() {
- ConnectorStatus.getConnectorStatus().logAPI("TSeis.dropTable", "", "");
- permtable.clear();
- ConnectorStatus.getConnectorStatus().logAPI("Table Dropped ", "", "");
- }
-
- public void setAutoCommit(boolean flag) {
- commitflag = flag;
- }
-
- public boolean getAutoCommit() {
- return commitflag;
- }
-
- public Vector readData() {
- System.out.println("TSeis.readData");
- Vector v = new Vector();
- Enumeration e = permtable.keys();
- while (e.hasMoreElements()) {
- DataElement de = (DataElement) permtable.get((String) e.nextElement());
- System.out.println("TSeis.readData." + de.getValue());
- v.add(de.getValue());
- }
- return v;
- }
-
- private void copyVector(Vector v1, Vector v2) {
- int size = v1.size();
-
- v2.clear();
- for (int i = 0; i < size; i++) {
- String str1 = (String) v1.get(i);
- v2.add(i, new String(str1));
- }
- }
-
- // **** Implementing Resource Manager for Local Transaction **********//
-
- public void begin() {
- ConnectorStatus.getConnectorStatus().logAPI("TSeis.begin", "", "");
- }
-
- public void commit(TSConnection con) throws TSEISException {
- Hashtable ht = con.getTempTable();
- Enumeration e = ht.keys();
- while (e.hasMoreElements()) {
- String key = (String) e.nextElement();
- DataElement de = (DataElement) ht.get(key);
- if (de.getStatus() == DataElement.INSERTED) {
- actualInsert(de);
- }
- if (de.getStatus() == DataElement.UPDATED) {
- actualUpdate(de);
- }
- if (de.getStatus() == DataElement.DELETED) {
- actualDelete(de.getKey());
- }
- }
- }
-
- void actualInsert(DataElement de) throws TSEISException {
- if (permtable.containsKey(de.getKey())) {
- throw new TSEISException("Duplicate Key");
- }
- de.setStatus(DataElement.COMMITTED);
- permtable.put(de.getKey(), de);
- }
-
- void actualUpdate(DataElement de) throws TSEISException {
- DataElement element = (DataElement) permtable.get(de.getKey());
- if (element.getStatus() == DataElement.PREPARED) {
- throw new TSEISException("Cannot update now. 2PC in progress");
- }
- de.setStatus(DataElement.COMMITTED);
- permtable.put(de.getKey(), de);
- }
-
- void actualDelete(String key) throws TSEISException {
- if (permtable.containsKey(key)) {
- DataElement element = (DataElement) permtable.get(key);
- if (element.getStatus() == DataElement.PREPARED) {
- throw new TSEISException("Cannot update now. 2PC in progress");
- }
- permtable.remove(key);
- }
- }
-
- void prepareInsert(DataElement de, Xid xid) throws TSEISException {
- if (permtable.containsKey(de.getKey())) {
- throw new TSEISException("Duplicate Key");
- }
- DataElement element = new DataElement(de.getKey(), de.getValue());
- element.prepare(de, xid);
- permtable.put(element.getKey(), element);
- }
-
- void prepareChange(DataElement de, Xid xid) throws TSEISException {
- DataElement element = (DataElement) permtable.get(de.getKey());
- DataElement prepElement = new DataElement(de.getKey());
- prepElement.prepare(de, xid);
- permtable.put(element.getKey(), prepElement);
- }
-
- // ****** Ending implementation for Resource Manager for Local Transaction
- // *****//
-
- // ******Implementating Resource Manager for XA Transaction *****//
-
- public void commit(Xid xid) {
- System.out.println("Tseis.commit.xid");
- Enumeration e = permtable.keys();
- while (e.hasMoreElements()) {
- System.out.println("commit.inTheLoop");
- String key = (String) e.nextElement();
- DataElement de = (DataElement) permtable.get(key);
- if (de.getStatus() == DataElement.PREPARED && de.getXid() == xid) {
- DataElement element = de.getPreparedValue();
- if (element.getStatus() == DataElement.DELETED) {
- System.out.println("commit.delete");
- permtable.remove(element.getKey());
- } else {
- System.out.println("commit.update");
- element.setStatus(DataElement.COMMITTED);
- permtable.put(element.getKey(), element);
- }
- }
- }
- }
-
- public void rollback(Xid xid) {
- System.out.println("Tseis.rollback.xid");
- Enumeration e = permtable.keys();
- while (e.hasMoreElements()) {
- String key = (String) e.nextElement();
- DataElement de = (DataElement) permtable.get(key);
- if (de.getStatus() == DataElement.PREPARED && de.getXid() == xid) {
- // Revert the state to commit so that, prepared value becomes unusable
- de.setStatus(DataElement.COMMITTED);
- permtable.put(de.getKey(), de);
- }
- }
- }
-
- public TSResourceManager getResourceManager() {
- return rm;
- }
-
- // ****** Ending implementation for Resource Manager for XA Transaction
- // *****//
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/TestBootstrapContext.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/TestBootstrapContext.java
deleted file mode 100644
index 91dbe99a76..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/TestBootstrapContext.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.connector.whitebox;
-
-import java.util.Timer;
-
-import javax.transaction.xa.Xid;
-
-import com.sun.ts.lib.util.TSNamingContext;
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-
-import jakarta.resource.spi.BootstrapContext;
-import jakarta.resource.spi.UnavailableException;
-import jakarta.resource.spi.XATerminator;
-import jakarta.resource.spi.work.WorkManager;
-import jakarta.transaction.TransactionSynchronizationRegistry;
-
-public class TestBootstrapContext {
-
- private BootstrapContext bsc;
-
- private WorkManager wrkmgr;
-
- private Timer timer1;
-
- private Timer timer2;
-
- public TestBootstrapContext(BootstrapContext bsc) {
- this.bsc = bsc;
- }
-
- public void runTests() {
- Debug.trace("Inside TestBootStrapContext.runTests");
- testTimer();
- testXATerminator();
- testIsContextSupported();
- testTransactionSynchronizationRegistry();
- testTSRLookup();
- }
-
- public void testTSRLookup() {
- try {
- // This lookup must work for JavaEE but is not guaranteed to
- // be supported in JCA standalone environment.
- // the only test that actually checks for this is in the
- // src/com/sun/ts/tests/xa/ee/tsr code which is NOT part of
- // standalone JCA tck.
- TSNamingContext ncxt = new TSNamingContext();
- String tsrStr = "java:comp/TransactionSynchronizationRegistry";
- Object obj = (Object) ncxt.lookup(tsrStr);
- if (obj != null) {
- ConnectorStatus.getConnectorStatus().logState("TSR Lookup Successful");
- Debug.trace("TSR Lookup Successful");
- } else {
- Debug.trace("TSR Null");
- }
- } catch (Throwable ex) {
- Debug.trace("Exception when calling testTSRLookup()");
- Debug.trace(
- "This is okay if JNDI lookup of tsr is not supported in standalone JCA");
- ex.getMessage();
- }
- }
-
- public void testTransactionSynchronizationRegistry() {
- try {
- // verify server supports TransactionSynchronizationRegistry
- // per spec assertion Connector:SPEC:291
- TransactionSynchronizationRegistry tr = bsc
- .getTransactionSynchronizationRegistry();
- if (tr != null) {
- String str = "getTransactionSynchronizationRegistry supported by Server";
- Debug.trace(str);
- ConnectorStatus.getConnectorStatus().logState(str);
- } else {
- Debug.trace(
- "getTransactionSynchronizationRegistry not supported by Server.");
- }
-
- } catch (Throwable ex) {
- Debug.trace(
- "Exception when calling getTransactionSynchronizationRegistry()");
- ex.getMessage();
- }
- }
-
- private void testTimer() {
- try {
- timer1 = bsc.createTimer();
- timer2 = bsc.createTimer();
-
- Debug.trace("Inside TestBootStrapContext.testTimer()");
-
- if (timer1 == null || timer2 == null) {
- ConnectorStatus.getConnectorStatus().logState("Timer is Null");
- } else {
- if (timer1.equals(timer2)) {
- ConnectorStatus.getConnectorStatus()
- .logState("Shared Timer Provided by BootstrapContext");
- Debug.trace("Timer is shared or returned the same instance");
- } else {
- ConnectorStatus.getConnectorStatus()
- .logState("New Timer Provided by BootstrapContext");
- Debug.trace("New Timer Provided by BootstrapContext");
- }
- }
-
- } catch (UnavailableException ex) {
-
- ConnectorStatus.getConnectorStatus()
- .logState("Timer UnavailableException");
- } catch (java.lang.UnsupportedOperationException uex) {
-
- ConnectorStatus.getConnectorStatus()
- .logState("Timer UnsupportedOperationException");
- }
- }
-
- private void testXATerminator() {
- try {
- XATerminator xt = bsc.getXATerminator();
- wrkmgr = bsc.getWorkManager();
-
- TestWorkManager twm = new TestWorkManager(bsc);
-
- Xid myid = twm.getXid();
- Xid nestxid = twm.getNestXid();
-
- if (xt != null) {
- ConnectorStatus.getConnectorStatus()
- .logState("XATerminator is not null");
- Debug.trace("TestBootStrapContext.testXATerminator XID is "
- + myid.getFormatId());
- Debug.trace("TestBootStrapContext.testXATerminator XID is "
- + nestxid.getFormatId());
- xt.commit(myid, true);
- xt.commit(nestxid, true);
- ConnectorStatus.getConnectorStatus().logState("Xid Committed");
- Debug.trace("XATerminator committed xid");
- }
- } catch (Throwable ex) {
- ex.getMessage();
- }
- }
-
- /*
- * This is used to assist in the verification of assertion Connector:SPEC:208
- * this will check that the server supports all 3 types of inflow context of:
- * TransactionContext, SecurityContext, and HintsContext. This is verified by
- * invoking the servers method of:
- * BootstrapContext.isContextSupported(TIC/SIC/HIC).
- *
- */
- private void testIsContextSupported() {
- try {
- // verify server supports TransactionContext
- Class tic = jakarta.resource.spi.work.TransactionContext.class;
- boolean b1 = bsc.isContextSupported(tic);
- if (b1) {
- Debug.trace("TransactionContext supported by Server.");
- ConnectorStatus.getConnectorStatus()
- .logState("TransactionContext supported by Server.");
- }
-
- Class sic = jakarta.resource.spi.work.SecurityContext.class;
- boolean b2 = bsc.isContextSupported(sic);
- if (b2) {
- Debug.trace("SecurityContext supported by Server.");
- ConnectorStatus.getConnectorStatus()
- .logState("SecurityContext supported by Server.");
- }
-
- Class hic = jakarta.resource.spi.work.HintsContext.class;
- boolean b3 = bsc.isContextSupported(hic);
- if (b3) {
- ConnectorStatus.getConnectorStatus()
- .logState("HintsContext supported by Server.");
- }
-
- } catch (Throwable ex) {
- ex.getMessage();
- }
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/TestWorkManager.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/TestWorkManager.java
deleted file mode 100644
index eff1c9f23d..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/TestWorkManager.java
+++ /dev/null
@@ -1,783 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.connector.whitebox;
-
-import javax.transaction.xa.Xid;
-
-import com.sun.ts.lib.util.TestUtil;
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-
-import jakarta.resource.spi.BootstrapContext;
-import jakarta.resource.spi.XATerminator;
-import jakarta.resource.spi.work.ExecutionContext;
-import jakarta.resource.spi.work.HintsContext;
-import jakarta.resource.spi.work.SecurityContext;
-import jakarta.resource.spi.work.TransactionContext;
-import jakarta.resource.spi.work.WorkCompletedException;
-import jakarta.resource.spi.work.WorkException;
-import jakarta.resource.spi.work.WorkManager;
-import jakarta.resource.spi.work.WorkRejectedException;
-
-public class TestWorkManager {
-
- private WorkManager wmgr;
-
- private static Xid myxid;
-
- private static Xid mynestxid;
-
- private XATerminator xa;
-
- private String sicUser = "";
-
- private String sicPwd = "";
-
- private String eisUser = "";
-
- private LocalTxMessageListener ml;
-
- private BootstrapContext bsc = null;
-
- // by default assume Case 1 security where identity is flown-in
- // from RA and exists within AppServer security domain
- // the alternative is case 2 which requires mapping EIS identity to
- // an identity which exists within the AppServer security domain.
- private boolean useSecurityMapping = false;
-
- public TestWorkManager(BootstrapContext val) {
- this.bsc = val;
- this.wmgr = bsc.getWorkManager();
- this.xa = bsc.getXATerminator();
-
- this.sicUser = TestUtil.getSystemProperty("j2eelogin.name");
- this.sicPwd = TestUtil.getSystemProperty("j2eelogin.password");
- this.eisUser = TestUtil.getSystemProperty("eislogin.name");
-
- verifyConfigSettings();
- }
-
- public void runTests() {
-
- doWork();
- startWork();
- rogueWork();
- distributableWork();
- scheduleWorkListener();
- scheduleWork();
- submitXidWork();
- submitNestedXidWork();
-
- submitSecurityContextWork();
- submitSICWork();
-
- testWorkContextProvider();
- testWorkContextLifecycleListener();
- doWorkAndAssoc();
-
- doAPITests();
- }
-
- /*
- * There are 2 choices related to establishing Caller identity which need to
- * considered when using TSSecurityContextWithListener/TSSecurityContext:
- * choice 1: RA flows in an identity to the AppServers security domain. (eg no
- * mapping/transalation done the identity is used as-is when passed into the
- * App Servers security domain) choice 2: RA flows in an identity that belongs
- * to the EIS domain only and a mapping of that identity to an AppServer
- * identity then needs to be done to map the EIS id to an id that exists
- * within the AppServers security domain.
- */
- public void submitSecurityContextWork() {
-
- if (!useSecurityMapping) {
- // case 1: no mappings, identities must exist in security domain.
- // PVC is for case 1 only, so do PVC tests in here.
- cbTestCPCandNullPrin();
- cbTestAllCallbacksAndPrin();
- cbTestAllCallbacksNullPrin();
- cbTestCPCandPVC();
- cbTestCPCandGPC();
- cbTestCPCandPrin();
- } else {
- // case-2: only call this for security mappings tests.
- cbTestGPCandCPCFail();
- cbTestEISCPCandPrin();
- }
- }
-
- /*
- * Test handling of a CPC - where no principals will be added to the CPC
- * subject and the CPC has a non-null principal. This is testing the CPC being
- * handled in a case-2 scenario with security-mapping on such that the EIS
- * creds need to be used and mapped.
- *
- */
- public void cbTestEISCPCandPrin() {
- String str = "Enterred cbEISTestCPCandPrin() and Testing that A CPC ";
- str += "that has nothing added to subject and has a non-null principal is handled";
- debug(str);
-
- debug("cbTestEISCPCandPrin(): useSecurityMapping SHOULD be true");
- debug(
- "cbTestEISCPCandPrin(): useSecurityMapping IS " + useSecurityMapping);
-
- TSSecurityContext tsic = new TSSecurityContextWithListener(sicUser, sicPwd,
- eisUser, useSecurityMapping);
- tsic.setCallbacks(true, false, false); // CPC=true, GPC=false, PVC=false
- tsic.setAddPrinToExecSubject(false);
- tsic.setLogOutString("cbEISTestCPCandPrin: callbacks handled.");
-
- SecurityContext sic = (SecurityContext) tsic;
-
- testSecurityInflow(sic, true);
-
- debug("done testing cbEISTestCPCandPrin()");
- }
-
- /*
- * Test handling of a CPC - where no principals will be added to the CPC
- * subject and the CPC has a non-null principal. (This tests it using Case-1
- * security creds)
- */
- public void cbTestCPCandPrin() {
- String str = "Enterred cbTestCPCandPrin() and Testing that A CPC ";
- str += "that has nothing added to subject and has a null principal is handled";
- debug(str);
-
- debug("cbTestCPCandPrin(): useSecurityMapping SHOULD be false");
- debug("cbTestCPCandPrin(): useSecurityMapping IS " + useSecurityMapping);
-
- TSSecurityContext tsic = new TSSecurityContextWithListener(sicUser, sicPwd,
- null, useSecurityMapping);
- tsic.setCallbacks(true, false, false); // CPC=true, GPC=false, PVC=false
- tsic.setAddPrinToExecSubject(false);
- tsic.setLogOutString("cbTestCPCandPrin: callbacks handled.");
-
- SecurityContext sic = (SecurityContext) tsic;
-
- testSecurityInflow(sic, true);
-
- debug("done testing cbTestCPCandPrin()");
- }
-
- /*
- * Test handling of a CPC - where no principals will be added to the CPC
- * execSubject and the CPC has a null principal. Also, this CPC follows a GPC
- * and PVC.
- */
- public void cbTestAllCallbacksNullPrin() {
-
- String str = "Enterred cbTestAllCallbacksNullPrin() and Testing a GPC, PVC, and CPC ";
- str += "that have nothing added to subject and a null principal are handled";
- debug(str);
-
- debug("cbTestAllCallbacksNullPrin(): useSecurityMapping SHOULD be false");
- debug("cbTestAllCallbacksNullPrin(): useSecurityMapping IS "
- + useSecurityMapping);
-
- TSSecurityContext tsic = new TSSecurityContextWithListener(null, null, null,
- useSecurityMapping);
- tsic.setCallbacks(true, true, true); // CPC=true, GPC=true, PVC=true
- tsic.setAddPrinToExecSubject(false);
- tsic.setLogOutString("cbTestAllCallbacksNullPrin: callbacks handled.");
-
- SecurityContext sic = (SecurityContext) tsic;
-
- testSecurityInflow(sic, true);
-
- debug("done testing cbTestAllCallbacksNullPrin()");
- }
-
- /*
- * Test handling of a CPC - where no principals will be added to the CPC
- * execSubject and the CPC has a non-null principal. Also, the CPC is done
- * after a GPC and PVC.
- *
- */
- public void cbTestAllCallbacksAndPrin() {
-
- String str = "Enterred cbTestAllCallbacksAndPrin() and Testing a GPC, PVC, and CPC ";
- str += "that have nothing added to subject and a non-null principal are handled";
- debug(str);
-
- debug("cbTestAllCallbacksAndPrin(): useSecurityMapping SHOULD be false");
- debug("cbTestAllCallbacksAndPrin(): useSecurityMapping IS "
- + useSecurityMapping);
-
- TSSecurityContext tsic = new TSSecurityContextWithListener(sicUser, sicPwd,
- eisUser, useSecurityMapping);
- tsic.setCallbacks(true, true, true); // CPC=true, GPC=true, PVC=true
- tsic.setAddPrinToExecSubject(false);
- tsic.setLogOutString("cbTestAllCallbacksAndPrin: callbacks handled.");
-
- debug(
- "TestWorkManager.cbTestAllCallbacksAndPrin - done calling tsic.setLogOutString()");
-
- SecurityContext sic = (SecurityContext) tsic;
-
- testSecurityInflow(sic, true);
-
- debug("done testing cbTestAllCallbacksAndPrin()");
- }
-
- /*
- * Test handling of a CPC - where no principals will be added to the CPC
- * subject and the CPC has a null principal.
- *
- */
- public void cbTestCPCandNullPrin() {
- String str = "Enterred cbTestCPCandNullPrin() and Testing that A CPC ";
- str += "that has nothing added to subject and has a null principal is handled";
- debug(str);
-
- debug("cbTestCPCandNullPrin(): useSecurityMapping SHOULD be false");
- debug(
- "cbTestCPCandNullPrin(): useSecurityMapping IS " + useSecurityMapping);
-
- TSSecurityContext tsic = new TSSecurityContextWithListener(null, null, null,
- useSecurityMapping);
- tsic.setCallbacks(true, false, false); // CPC=true, GPC=false, PVC=false
- tsic.setAddPrinToExecSubject(false);
- tsic.setLogOutString(
- "cbTestCPCandNullPrin: Case-1 security callbacks handled.");
- SecurityContext sic = (SecurityContext) tsic;
-
- testSecurityInflow(sic, true);
-
- debug("done testing cbTestCPCandNullPrin()");
- }
-
- /*
- * Test case where GPC is followed by CPC - no principals are added to the
- * execSubject, the CPC (with a non-null principal), and one or more GPC's
- * (each non-null group) are handled.
- */
- public void cbTestCPCandGPC() {
- String str = "Enterred cbTestCPCandGPC() and Testing that ";
- str += "GPC (w non-null group) followed by a CPC that has non-null princiapl) is handled";
- debug(str);
-
- debug("cbTestCPCandPrin(): useSecurityMapping SHOULD be false");
- debug("cbTestCPCandPrin(): useSecurityMapping IS " + useSecurityMapping);
-
- TSSecurityContext tsic = new TSSecurityContextWithListener(sicUser, sicPwd,
- eisUser, useSecurityMapping);
- tsic.setCallbacks(true, true, false); // CPC=true, GPC=true, PVC=false
- tsic.setAddPrinToExecSubject(false);
- tsic.setLogOutString("cbTestCPCandGPC: callbacks handled.");
-
- SecurityContext sic = (SecurityContext) tsic;
-
- testSecurityInflow(sic, true);
-
- debug("done testing cbTestCPCandGPC()");
- }
-
- /*
- * Test case where PVC is followed by CPC - no principals are added to the
- * execSubject.
- */
- public void cbTestCPCandPVC() {
- String str = "Enterred cbTestCPCandPVC() and Testing that ";
- str += "PVC followed by a CPC that has non-null principal) is handled";
- debug(str);
-
- debug("cbTestCPCandPVC(): useSecurityMapping SHOULD be false");
- debug("cbTestCPCandPVC(): useSecurityMapping IS " + useSecurityMapping);
-
- TSSecurityContext tsic = new TSSecurityContextWithListener(sicUser, sicPwd,
- eisUser, useSecurityMapping);
- tsic.setCallbacks(true, false, true); // CPC=true, GPC=false, PVC=true
- tsic.setLogOutString("cbTestCPCandPVC: callbacks handled.");
- tsic.setAddPrinToExecSubject(false);
- SecurityContext sic = (SecurityContext) tsic;
-
- testSecurityInflow(sic, true);
-
- debug("done testing cbTestCPCandPVC()");
- }
-
- /*
- * Test that a single (presumably non-group) principal was added to the
- * execSubject and the CPC is NOT handled. This uses invalid creds that are
- * used in a case-2 scenario (with security mappings). The assumption is that
- * this is only called for case-2 security.
- */
- public void cbTestGPCandCPCFail() {
- String str = "Enterred cbTestGPCandCPCFail() and Testing a GPC, and CPC fail";
- str += "where principal is added to execSubject and CPC is not handled";
- debug(str);
-
- debug("cbTestGPCandCPCFail(): useSecurityMapping SHOULD be true");
- debug(
- "cbTestGPCandCPCFail(): useSecurityMapping IS " + useSecurityMapping);
-
- TSSecurityContext tsic = new TSSecurityContextWithListener("fakeusr",
- "fakepwd", "fakepwd", true);
- tsic.setCallbacks(true, true, false); // CPC=true, GPC=true, PVC=false
- tsic.setAddPrinToExecSubject(true);
- tsic.setExpectFailure(true);
- tsic.setLogOutString(
- "cbTestGPCandCPCFail: callbacks are NOT handled - as expected.");
-
- SecurityContext sic = (SecurityContext) tsic;
-
- testSecurityInflow(sic, true);
-
- debug("done testing cbTestGPCandCPCFail()");
- }
-
- /*
- * This will need to submit a work object that has SIC set on it and then we
- * will need to verify that the work object was recieved by the AppServer (via
- * MDB) and we will want to verify the values that got set within the SIC
- * setting to confirm the subject info is correct. (note that invoking
- * MDB.isCallerInRole() is one thing we can use to assist with credential
- * validation.
- *
- */
- public void submitSICWork() {
-
- try {
- ConnectorStatus.getConnectorStatus().logState("enterred submitSICWork()");
- debug("enterred submitSICWork()");
-
- ContextWork w1 = new ContextWork(wmgr);
-
- debug("creating SIC with user=" + sicUser + " pwd=" + sicPwd
- + " eisUser = " + eisUser);
-
- SecurityContext sic = new TSSecurityContextWithListener(sicUser, sicPwd,
- eisUser, this.useSecurityMapping);
-
- w1.addWorkContext(sic);
-
- wmgr.doWork(w1, WorkManager.INDEFINITE, null, null);
-
- ConnectorStatus.getConnectorStatus()
- .logState("submitted work with SIC Listener");
-
- } catch (WorkCompletedException e) {
- // everything seemed to work okay
- debug("WorkCompleted calling submitSICWork()");
-
- } catch (Exception e) {
- debug("got exception in submitSICWork() with user = " + sicUser
- + " pwd = " + sicPwd + " principal=" + eisUser);
- debug(e.toString());
- Debug.printDebugStack(e);
- }
-
- }
-
- /*
- * This method is testing the order in which notifications occur. (see JCA
- * spec assertions 224, 225, 262) This method makes use of a counter and some
- * dedicated classes that will use the counter to record the calling order
- * order of notifications for workAccepted, workStarted,
- * contextSetupCompleted, and workAccepted.
- *
- */
- public void testWorkContextLifecycleListener() {
-
- try {
- debug("enterred testWorkContextLifecycleListener()");
-
- ContextWork workimpl = new ContextWork(wmgr);
-
- // we want to ensure that WorkListenerImpl notifications
- // occur BEFOR the workcontext setup related notifications
- // so create new counter obj, and ensure it is set to zero
- Counter.resetCount(); // set counter to 0
- WorkListenerImpl2 wl = new WorkListenerImpl2();
-
- debug("Submitting Work Object testWorkContextLifecycleListener().");
-
- // as part of assert 261, set hint context - which should be unknown
- // to the appserver and thus ignored...if its not ignored and any
- // contextSetupFailed notification occurs - assert 261 will be flagged
- // and detected as failing later on
- HintsContext hic = new HintsContext();
- hic.setName("someReallyLongAndUncommonName");
- hic.setHint(HintsContext.NAME_HINT, "someReallyLongAndUncommonHintValue");
- workimpl.addWorkContext(hic);
-
- SecurityContext sic = new TSSICWithListener(eisUser, eisUser, sicUser,
- true);
- workimpl.addWorkContext(sic);
- wmgr.doWork(workimpl, WorkManager.INDEFINITE, null, wl);
- debug("done submitting work obj in testWorkContextLifecycleListener()");
-
- } catch (WorkRejectedException ex) {
- // we should not get here
- debug(
- "Problem: testWorkContextLifecycleListener WorkException thrown is "
- + ex.getMessage());
- ex.printStackTrace();
-
- } catch (WorkException ex) {
- // we should not get here (unless WorkCompleted Exception)
- debug("testWorkContextLifecycleListener WorkException thrown is "
- + ex.getMessage());
- ex.printStackTrace();
-
- } catch (Exception ex) {
- // we should not get here
- debug("Problem: testWorkContextLifecycleListener Exception thrown is "
- + ex.getMessage());
- ex.printStackTrace();
- }
-
- }
-
- public void testWorkContextProvider() {
-
- try {
- debug("enterred testWorkContextProvider()");
-
- // this helps test assertion 221
- ContextWork workimpl = new ContextWork(wmgr);
- ExecutionContext ec = new ExecutionContext();
- WorkListenerImpl wl = new WorkListenerImpl();
-
- debug(
- "Submitting Work Object - which should genetate WorkRejectedException.");
- wmgr.doWork(workimpl, 5000, ec, wl);
-
- } catch (WorkRejectedException we) {
- // we expect to get here!!!
- String str = "SUCCESS: WorkContextProvider causes expected WorkRejectedException";
- debug(str);
- ConnectorStatus.getConnectorStatus().logState(str);
-
- } catch (WorkException we) {
- // we should not get here
- debug("FAILURE: testWorkContextProvider() WorkException thrown is "
- + we.getMessage());
-
- } catch (Exception ex) {
- // we should not get here
- debug("FAILURE: testWorkContextProvider() Exception thrown is "
- + ex.getMessage());
- }
-
- debug("leaving testWorkContextProvider()");
- }
-
- /*
- * This is used to help verify assertion Connector:SPEC:209
- *
- * ARGS:
- *
- * SecurityContext: this is the sic that is passed in. It must be constructed
- * befor being passed in. writeToDB: this is used to indicate if we want to
- * commit/write our transaction to the db or roll it back.
- *
- * There are 2 choices related to establishing Caller identity: choice 1: RA
- * flows in an identify to the AppServers security domain. (eg no transalation
- * is done as the identity is used as is) choice 2: RA flows in an identity
- * that belongs to the EIS domain only and a mapping of that identity to an
- * AppServer identity then needs to be done to map the EIS id to an id that
- * exists within the AppServers security domain.
- *
- */
- public void testSecurityInflow(SecurityContext sic, boolean writeToDB) {
-
- try {
- ConnectorStatus.getConnectorStatus()
- .logState("enterred testSecurityInflow()");
- debug("enterred testSecurityInflow()");
-
- ExecutionContext ec = startTx();
-
- ContextWork w1 = new ContextWork(wmgr);
-
- // adding the worklistener along with securityContextWithListener allows
- // us to test assertion 223
- WorkListenerImpl wl = new WorkListenerImpl();
- wl.setUidStr("notifications test"); // assists w/ assertion
- // Connector:SPEC:223
-
- TransactionContext tic = new TransactionContext();
- tic.setXid(ec.getXid());
- w1.addWorkContext(tic);
-
- w1.addWorkContext(sic);
-
- wmgr.doWork(w1, WorkManager.INDEFINITE, null, wl);
-
- if (writeToDB) {
- // commit write to DB - with TIC and SIC with Listener. For this, a
- // Translation is Required
- xa.commit(ec.getXid(), true);
- } else {
- // rollback a write to DB - with TIC and SIC
- xa.rollback(tic.getXid());
- }
-
- } catch (WorkCompletedException e) {
- // everything seemed to work okay
- debug("WorkCompleted calling testSecurityInflow()");
-
- } catch (Exception e) {
- debug(
- "got exception in testSecurityInflow() with user = " + sic.getName());
- debug(e.toString());
- Debug.printDebugStack(e);
- }
-
- }
-
- private ExecutionContext startTx() {
- ExecutionContext ec = new ExecutionContext();
- try {
- Xid xid = new XidImpl();
- ec.setXid(xid);
- ec.setTransactionTimeout(5 * 1000); // 5 seconds
- } catch (Exception ex) {
- Debug.printDebugStack(ex);
- }
- return ec;
- }
-
- public void scheduleWork() {
- try {
- ScheduleWork sw = new ScheduleWork();
- wmgr.scheduleWork(sw);
- debug("Schedule work called");
- ConnectorStatus.getConnectorStatus().logState("Schedule Work Called");
- } catch (WorkException we) {
- debug("TestWorkManager Exception thrown is " + we.getMessage());
- }
- }
-
- public void scheduleWorkListener() {
- try {
- ScheduleWork sw = new ScheduleWork();
- ExecutionContext ec = new ExecutionContext();
- wmgr.scheduleWork(sw, 5000, ec, null);
- debug("Schedule work listener called");
- ConnectorStatus.getConnectorStatus()
- .logState("Schedule Work Listener Called");
- } catch (WorkException we) {
- debug("TestWorkManager Exception thrown is " + we.getMessage());
- }
- }
-
- /*
- * this will try to test API assertions which basically means we are testing
- * the API.
- */
- public void doAPITests() {
- APIAssertionTest apiTest = new APIAssertionTest();
- apiTest.runTests();
- }
-
- public void doWork() {
- try {
- WorkImpl workimpl = new WorkImpl(wmgr);
- ExecutionContext ec = new ExecutionContext();
- debug("doWork(): Creating WorkListener");
- WorkListenerImpl wl = new WorkListenerImpl();
- ConnectorStatus.getConnectorStatus().logState("Work Object Submitted");
- wmgr.doWork(workimpl, WorkManager.INDEFINITE, ec, wl);
- } catch (WorkException we) {
- debug("TestWorkManager WorkException thrown is " + we.getMessage());
- }
- }
-
- // this is used to test Connector:spec:245
- public void doWorkAndAssoc() {
- try {
- // using WorkAndAssocImpl allows us to test Connector:spec:245
- WorkAndAssocImpl workimpl = new WorkAndAssocImpl(wmgr);
- ExecutionContext ec = new ExecutionContext();
- debug("doWorkAndAssoc(): Creating WorkListener");
- WorkListenerImpl wl = new WorkListenerImpl();
- ConnectorStatus.getConnectorStatus().logState("Work Object Submitted");
- wmgr.doWork(workimpl, wmgr.INDEFINITE, ec, wl);
-
- } catch (WorkException we) {
- debug("TestWorkManager WorkException thrown is " + we.getMessage());
- we.printStackTrace();
- }
- }
-
- public void startWork() {
- try {
- WorkImpl workimpl = new WorkImpl(wmgr);
- ExecutionContext ec = new ExecutionContext();
- debug("startWork: Creating WorkListener");
- WorkListenerImpl wl = new WorkListenerImpl();
- long value = wmgr.startWork(workimpl, 1000, ec, wl);
-
- debug("startWork: WorkManager value = " + value);
-
- ConnectorStatus.getConnectorStatus()
- .logState("WorkManager value returned " + value);
- debug("WorkManager value returned " + value);
-
- } catch (WorkException we) {
- debug(
- "TestWorkManager.startWork() Exception thrown is " + we.getMessage());
- }
- }
-
- public void rogueWork() {
- try {
- RogueWorkImpl rwi = new RogueWorkImpl();
- wmgr.doWork(rwi);
- } catch (WorkCompletedException wx) {
- ConnectorStatus.getConnectorStatus()
- .logState("Rogue work throws WorkCompletedException");
- } catch (WorkException we) {
- debug("TestWorkManager Exception thrown is " + we.getMessage());
- }
- }
-
- public void distributableWork() {
- try {
- DistributedWorkImpl dwi = new DistributedWorkImpl(wmgr);
- // wmgr.doWork(dwi);
- ExecutionContext ec = new ExecutionContext();
- debug("distributableWork(): Creating WorkListener");
- WorkListenerImpl wl = new WorkListenerImpl();
- long value = wmgr.startWork(dwi, 1000, ec, wl);
- ConnectorStatus.getConnectorStatus()
- .logState("DistributedWork Object Submitted");
-
- if (value >= -1) {
- ConnectorStatus.getConnectorStatus()
- .logState("WorkManagers DistributedWork value returned " + value);
- debug("WorkManagers DistributedWork value returned " + value);
- }
- } catch (WorkCompletedException wx) {
- ConnectorStatus.getConnectorStatus()
- .logState("Rogue work throws WorkCompletedException");
- } catch (WorkException we) {
- debug("TestWorkManager Exception thrown is " + we.getMessage());
- }
- }
-
- public void setXid(Xid xid) {
- this.myxid = xid;
- }
-
- public Xid getXid() {
- return this.myxid;
- }
-
- public void setNestXid(Xid xid) {
- this.mynestxid = xid;
- }
-
- public Xid getNestXid() {
- return this.mynestxid;
- }
-
- /*
- * JCA 1.6 spec 9section 16.3 and 16.4 state there are two types of security a
- * RA can use: "Case 1" and "Case 2". Case 1 is when the RA passes in an
- * identity and that identity is assumed to exist within the app server
- * security domain. "Case 2" takes and EIS identity, which will not exist in
- * AppServer domain, so this case requires a mapping/translation from and
- * EIS-Identity to an i AppServer-Identity.
- *
- * set useSecurityMapping to true to specify we want Case 2 security mapping
- * use. set useSecurityMapping to false to indicate Case 1 security.
- */
- public void setUseSecurityMapping(boolean val) {
- this.useSecurityMapping = val;
- }
-
- public boolean getUseSecurityMapping() {
- return this.useSecurityMapping;
- }
-
- public void submitXidWork() {
- try {
- XidImpl myid = new XidImpl();
-
- // setting up the xid so that it can be retrieved by the TestBootstrap to
- // commit the xid work object.
- setXid(myid);
-
- WorkXid workid = new WorkXid();
- ExecutionContext ec = new ExecutionContext();
- ec.setXid(myid);
- debug("TestWorkManager.submitXidWork XID IS " + myid.getFormatId());
- wmgr.doWork(workid, wmgr.INDEFINITE, ec, null);
- debug("WorkXid Submitted");
- ConnectorStatus.getConnectorStatus().logState("WorkXid Submitted");
- } catch (WorkException we) {
- Debug.printDebugStack(we);
- }
- }
-
- public void submitNestedXidWork() {
- try {
- XidImpl myid = new XidImpl();
- WorkXid1 workid = new WorkXid1(wmgr, myid);
- // setting up the xid so it can be commited later.
- setNestXid(myid);
-
- debug("TestWorkManager.submitNestedXidWork XID IS " + myid.getFormatId());
-
- ExecutionContext ec = new ExecutionContext();
- ec.setXid(myid);
- wmgr.doWork(workid, wmgr.INDEFINITE, ec, null);
- debug("WorkXid1 submitted");
-
- } catch (WorkException we) {
- Debug.printDebugStack(we);
- }
- }
-
- /*
- * verify we can find config properties that should be set as part of our
- * configuration process. (See ts.jte prop for values.)
- */
- private void verifyConfigSettings() {
- String err = "WARNING - TestWorkManager could not find required system property: ";
-
- if (sicUser == null) {
- err += "j2eelogin.name";
- debug(err);
- sicUser = "j2ee"; // try to set to a default
- }
-
- if (sicPwd == null) {
- err += "j2eelogin.password";
- debug(err);
- sicUser = "j2ee"; // try to set to a default
- }
-
- if (eisUser == null) {
- err += "j2eelogin.password";
- debug(err);
- sicUser = "cts1"; // try to set to a default
- }
- }
-
- private void debug(String str) {
- Debug.trace(str);
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/Util.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/Util.java
deleted file mode 100644
index 0652e9158e..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/Util.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.connector.whitebox;
-
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.Iterator;
-import java.util.Set;
-
-import javax.security.auth.Subject;
-
-import jakarta.resource.ResourceException;
-import jakarta.resource.spi.ConnectionRequestInfo;
-import jakarta.resource.spi.ManagedConnectionFactory;
-import jakarta.resource.spi.SecurityException;
-import jakarta.resource.spi.security.PasswordCredential;
-
-public class Util {
- static public PasswordCredential getPasswordCredential(
- final ManagedConnectionFactory mcf, final Subject subject,
- ConnectionRequestInfo info) throws ResourceException {
-
- if (subject == null) {
- if (info == null) {
- return null;
- } else {
- TSConnectionRequestInfo myinfo = (TSConnectionRequestInfo) info;
- PasswordCredential pc = new PasswordCredential(myinfo.getUser(),
- myinfo.getPassword().toCharArray());
- pc.setManagedConnectionFactory(mcf);
- return pc;
- }
- } else {
- PasswordCredential pc = (PasswordCredential) AccessController
- .doPrivileged(new PrivilegedAction() {
- public Object run() {
- Set creds = subject
- .getPrivateCredentials(PasswordCredential.class);
- Iterator iter = creds.iterator();
- while (iter.hasNext()) {
- PasswordCredential temp = (PasswordCredential) iter.next();
- if (temp.getManagedConnectionFactory().equals(mcf)) {
- return temp;
- }
- }
- return null;
- }
- });
- if (pc == null) {
- throw new SecurityException("No PasswordCredential found");
- } else {
- return pc;
- }
- }
- }
-
- static public boolean isEqual(String a, String b) {
- if (a == null) {
- return (b == null);
- } else {
- return a.equals(b);
- }
- }
-
- static public boolean isPasswordCredentialEqual(PasswordCredential a,
- PasswordCredential b) {
- if (a == b)
- return true;
- if ((a == null) && (b != null))
- return false;
- if ((a != null) && (b == null))
- return false;
- if (!isEqual(a.getUserName(), b.getUserName()))
- return false;
- String p1 = null;
- String p2 = null;
- if (a.getPassword() != null) {
- p1 = new String(a.getPassword());
- }
- if (b.getPassword() != null) {
- p2 = new String(b.getPassword());
- }
- return (isEqual(p1, p2));
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/WorkAndAssocImpl.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/WorkAndAssocImpl.java
deleted file mode 100644
index 57f74518ee..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/WorkAndAssocImpl.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright (c) 2010, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.common.connector.whitebox;
-
-import java.util.Vector;
-
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-
-import jakarta.resource.ResourceException;
-import jakarta.resource.spi.ResourceAdapter;
-import jakarta.resource.spi.ResourceAdapterAssociation;
-import jakarta.resource.spi.work.WorkManager;
-
-/*
- * This class is used to assist in testing with assertion Connector:SPEC:245.
- * This tests the association between the resource adapter instance and the
- * Work instance before the exection of the Work instance has been started
- */
-public class WorkAndAssocImpl extends WorkImpl
- implements ResourceAdapterAssociation {
- private int count = 0;
-
- protected String callingClassName = "WorkAndAssocImpl";
-
- private ResourceAdapter resourceAdapter;
-
- public WorkAndAssocImpl(WorkManager wm) {
- super(wm, "WorkAndAssocImpl");
- }
-
- public void run() {
-
- // do check for setResourceAdapter call
- checkAssociation();
-
- try {
- ConnectorStatus.getConnectorStatus().logState("WorkAndAssocImpl.run");
- debug("WorkAndAssocImpl.run");
- } catch (Exception ex) {
- }
-
- }
-
- /*
- * @name setResourceAdapter
- *
- * @desc sets the Resource Adapter for this work instance
- *
- * @return
- *
- * @exception ResourceException
- */
- public void setResourceAdapter(ResourceAdapter ra) throws ResourceException {
- count++;
- String newStr1 = "WorkAndAssocImpl setResourceAdapter " + count;
- debug(newStr1);
- ConnectorStatus.getConnectorStatus().logState(newStr1);
- this.resourceAdapter = ra;
- }
-
- /*
- * @name getResourceAdapter
- *
- * @desc gets the Resource Adapter for this work instance
- *
- * @return Object
- *
- * @exception ResourceException
- */
- public ResourceAdapter getResourceAdapter() {
- return resourceAdapter;
- }
-
- /*
- * This method is used to assist in the verification process of assertion
- * Connector:SPEC:245 This method must be called befor the work instances
- * 'run' method is called. This method checks if the setResourceAdapter()
- * method was called and if so, then this method logs a message to indicate
- * that it was called prior to the 'run' method of the run method.
- */
- public void checkAssociation() {
- Vector vLog = ConnectorStatus.getConnectorStatus().getStateLogVector();
- String toCheck1 = "WorkAndAssocImpl setResourceAdapter 1";
-
- for (int i = 0; i < vLog.size(); i++) {
- String str = (String) vLog.elementAt(i);
- if (str.startsWith(toCheck1)) {
- String str2 = "LocalTx - association exists between RA and work";
- ConnectorStatus.getConnectorStatus().logState(str2);
- break;
- }
- }
- }
-
- private void debug(String str) {
- Debug.trace(str);
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/WorkImpl.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/WorkImpl.java
deleted file mode 100644
index 956cc5e031..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/WorkImpl.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.connector.whitebox;
-
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-
-import jakarta.resource.spi.work.Work;
-import jakarta.resource.spi.work.WorkException;
-import jakarta.resource.spi.work.WorkManager;
-
-public class WorkImpl implements Work {
- protected WorkManager wm;
-
- protected String callingClassName = "WorkImpl";
-
- public WorkImpl(WorkManager wm) {
- this.wm = wm;
-
- String str = callingClassName + ".constructor";
- ConnectorStatus.getConnectorStatus().logAPI(str, "", "");
- debug(str);
- }
-
- public WorkImpl(WorkManager wm, String strCallingClassName) {
- this.wm = wm;
- callingClassName = strCallingClassName;
-
- String str = callingClassName + ".constructor";
- ConnectorStatus.getConnectorStatus().logAPI(str, "", "");
- debug(str);
- }
-
- public void release() {
- String str = callingClassName + ".release";
- ConnectorStatus.getConnectorStatus().logAPI(str, "", "");
- debug(str);
- }
-
- public void run() {
- try {
- String str = callingClassName + ".run";
- ConnectorStatus.getConnectorStatus().logAPI(str, "", "");
- debug(str);
- NestWork nw = new NestWork();
- wm.doWork(nw);
- } catch (WorkException we) {
- debug("got WorkException in WorkImpl.run(): " + we.getMessage());
- }
- }
-
- /*
- * this sets the name of the calling class so that we can be sure proper
- * logging info is dumped out.
- *
- */
- public void setCallingClassName(String str) {
- this.callingClassName = str;
- }
-
- public String getCallingClassName() {
- return this.callingClassName;
- }
-
- private void debug(String str) {
- Debug.trace(str);
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/WorkListenerImpl.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/WorkListenerImpl.java
deleted file mode 100644
index c7844ab4ed..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/WorkListenerImpl.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.connector.whitebox;
-
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-
-import jakarta.resource.spi.work.WorkEvent;
-import jakarta.resource.spi.work.WorkListener;
-
-public class WorkListenerImpl implements WorkListener {
- private String uidStr = null;
-
- public void workAccepted(WorkEvent e) {
- if (uidStr == null) {
- ConnectorStatus.getConnectorStatus()
- .logState("WorkListenerImpl.workAccepted");
- } else {
- ConnectorStatus.getConnectorStatus()
- .logState("WorkListenerImpl.workAccepted for:" + uidStr);
- }
- debug("WorkListenerImpl.workAccepted");
- }
-
- public void workRejected(WorkEvent e) {
- ConnectorStatus.getConnectorStatus()
- .logState("WorkListenerImpl.workRejected");
- debug("WorkListenerImpl.workRejected");
- }
-
- public void workStarted(WorkEvent e) {
- ConnectorStatus.getConnectorStatus()
- .logState("WorkListenerImpl.workStarted");
- debug("WorkListenerImpl.workStarted");
- }
-
- public void workCompleted(WorkEvent e) {
- ConnectorStatus.getConnectorStatus()
- .logState("WorkListenerImpl.workCompleted");
- debug("WorkListenerImpl.workCompleted");
- }
-
- public void setUidStr(String val) {
- this.uidStr = val;
- }
-
- public String getUidStr() {
- return this.uidStr;
- }
-
- private void debug(String str) {
- Debug.trace(str);
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/WorkXid1.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/WorkXid1.java
deleted file mode 100644
index ae894036cf..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/WorkXid1.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.connector.whitebox;
-
-import javax.transaction.xa.Xid;
-
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-
-import jakarta.resource.spi.work.ExecutionContext;
-import jakarta.resource.spi.work.Work;
-import jakarta.resource.spi.work.WorkException;
-import jakarta.resource.spi.work.WorkManager;
-
-public class WorkXid1 implements Work {
-
- private WorkManager wm;
-
- private Xid xid;
-
- public WorkXid1(WorkManager wm, Xid xid) {
- this.wm = wm;
- this.xid = xid;
- ConnectorStatus.getConnectorStatus().logAPI("WorkXid.constructor", "", "");
- Debug.trace("WorkXid1.constructor");
- }
-
- public void release() {
- ConnectorStatus.getConnectorStatus().logAPI("WorkXid.release", "", "");
- Debug.trace("WorkXid1.release() called.");
-
- if ((xid != null) && (xid.getGlobalTransactionId() != null)) {
- Debug.trace("WorkXid1.release() xid was: "
- + new String(xid.getGlobalTransactionId()));
- } else if (xid != null) {
- Debug.trace(
- "WorkXid1.release() xid was NOT null but xid.getGlobalTransactionId() was null.");
- } else {
- Debug.trace("WorkXid1.release() xid was: null");
- }
- Debug.trace("WorkXid1.release() xid being set == null");
-
- this.xid = null;
- }
-
- public void run() {
- try {
- ConnectorStatus.getConnectorStatus().logAPI("WorkXid.run", "", "");
- Debug.trace("WorkXid1.run");
- ConnectorStatus.getConnectorStatus().logAPI("WorkXid1.run", "", "");
- NestedWorkXid workid = new NestedWorkXid();
-
- ExecutionContext ec = new ExecutionContext();
- ec.setXid(this.xid);
- Debug.trace("set the xid in ec");
- wm.doWork(workid, wm.INDEFINITE, ec, null);
- Debug.trace("submitted the nested xid work");
- ConnectorStatus.getConnectorStatus().logState("WorkXid Submitted");
-
- } catch (WorkException we) {
- if (we.TX_CONCURRENT_WORK_DISALLOWED == WorkException.TX_CONCURRENT_WORK_DISALLOWED) {
- Debug.trace("In the WorkException of Concurrent xid");
- ConnectorStatus.getConnectorStatus()
- .logState("WorkException.TX_CONCURRENT_WORK_DISALLOWED caught");
- }
- }
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/XAManagedConnectionFactory.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/XAManagedConnectionFactory.java
deleted file mode 100644
index bb31982852..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/XAManagedConnectionFactory.java
+++ /dev/null
@@ -1,407 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.connector.whitebox;
-
-import java.io.PrintWriter;
-import java.io.Serializable;
-import java.util.Iterator;
-import java.util.Set;
-
-import javax.security.auth.Subject;
-
-import com.sun.ts.lib.util.TSNamingContext;
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-
-import jakarta.resource.ResourceException;
-import jakarta.resource.spi.ConnectionManager;
-import jakarta.resource.spi.ConnectionRequestInfo;
-import jakarta.resource.spi.EISSystemException;
-import jakarta.resource.spi.ManagedConnection;
-import jakarta.resource.spi.ManagedConnectionFactory;
-import jakarta.resource.spi.ResourceAdapter;
-import jakarta.resource.spi.ResourceAdapterAssociation;
-import jakarta.resource.spi.security.PasswordCredential;
-
-public class XAManagedConnectionFactory implements ManagedConnectionFactory,
- ResourceAdapterAssociation, Serializable, jakarta.resource.Referenceable {
-
- private javax.naming.Reference reference;
-
- private ResourceAdapter resourceAdapter;
-
- private String TSRValue;
-
- private int count;
-
- private String password;
-
- private String user;
-
- private String userName;
-
- /*
- * @name XAManagedConnectionFactory
- *
- * @desc Default conctructor
- */
- public XAManagedConnectionFactory() {
- }
-
- public String getUser() {
- System.out
- .println("XAManagedConnectionFactory.getUser() returning: " + user);
- return user;
- }
-
- public void setUser(String val) {
- System.out
- .println("XAManagedConnectionFactory.setUser() with val = " + val);
- user = val;
- }
-
- public String getUserName() {
- System.out.println(
- "XAManagedConnectionFactory.getUserName() returning: " + userName);
- return userName;
- }
-
- public void setUserName(String val) {
- System.out
- .println("XAManagedConnectionFactory.setUserName() with val = " + val);
- userName = val;
- }
-
- public String getPassword() {
- System.out.println(
- "XAManagedConnectionFactory.getPassword() returning: " + password);
- return password;
- }
-
- public void setPassword(String val) {
- System.out
- .println("XAManagedConnectionFactory.setPassword() with val = " + val);
- password = val;
- }
-
- /*
- * @name createConnectionFactory
- *
- * @desc Creates a new connection factory instance
- *
- * @param ConnectionManager
- *
- * @return Object
- *
- * @exception ResourceException
- */
- public Object createConnectionFactory(ConnectionManager cxManager)
- throws ResourceException {
- return new TSEISDataSource(this, cxManager);
- }
-
- /*
- * @name setResourceAdapter
- *
- * @desc sets the Resource Adapter for this ManagedConnectionFactory
- *
- * @return
- *
- * @exception ResourceException
- */
-
- public void setResourceAdapter(ResourceAdapter ra) throws ResourceException {
- count++;
- String newStr1 = "XAManagedConnectionFactory setResourceAdapter " + count;
- System.out.println(newStr1);
- ConnectorStatus.getConnectorStatus().logState(newStr1);
-
- this.resourceAdapter = ra;
- }
-
- /*
- * @name getResourceAdapter
- *
- * @desc gets the Resource Adapter for this ManagedConnectionFactory
- *
- * @return Object
- *
- * @exception ResourceException
- */
-
- public ResourceAdapter getResourceAdapter() {
- return resourceAdapter;
- }
-
- /*
- * @name createConnectionFactory
- *
- * @desc Creates a new connection factory instance
- *
- * @return Object
- *
- * @exception ResourceException
- */
- public Object createConnectionFactory() throws ResourceException {
- return new TSEISDataSource(this, null);
- }
-
- /*
- * @name createManagedConnection
- *
- * @desc Creates a new managed connection to the underlying EIS
- *
- * @param Subject, ConnectionRequestInfo
- *
- * @return ManagedConnection
- *
- * @exception ResourceException
- */
- public ManagedConnection createManagedConnection(Subject subject,
- ConnectionRequestInfo info) throws ResourceException {
-
- try {
- TSXAConnection xacon = null;
- TSConnection con = null;
- String userName = null;
- PasswordCredential pc = Util.getPasswordCredential(this, subject, info);
- if (pc == null) {
- xacon = new TSXAConnectionImpl();
- con = xacon.getConnection();
- System.out.println("xacon.getConnection");
- } else {
- xacon = new TSXAConnectionImpl();
- System.out.println("xacon.getConnection(u,p)");
- con = xacon.getConnection(pc.getUserName(), pc.getPassword());
- }
- if (con == null) {
- System.out.println("Connection is null");
- }
- return new TSManagedConnection(this, pc, xacon, con, true, true);
- } catch (Exception ex) {
- ResourceException re = new EISSystemException(
- "Exception: " + ex.getMessage());
- re.initCause(ex);
- throw re;
- }
-
- }
-
- /*
- * @name matchManagedConnection
- *
- * @desc Return the existing connection from the connection pool
- *
- * @param Set, Subject, ConnectionRequestInfo
- *
- * @return ManagedConnection
- *
- * @exception ResourceException
- */
- public ManagedConnection matchManagedConnections(Set connectionSet,
- Subject subject, ConnectionRequestInfo info) throws ResourceException {
- PasswordCredential pc = Util.getPasswordCredential(this, subject, info);
- Iterator it = connectionSet.iterator();
- while (it.hasNext()) {
- Object obj = it.next();
- if (obj instanceof TSManagedConnection) {
- TSManagedConnection mc = (TSManagedConnection) obj;
- ManagedConnectionFactory mcf = mc.getManagedConnectionFactory();
- if (Util.isPasswordCredentialEqual(mc.getPasswordCredential(), pc)
- && mcf.equals(this)) {
- return mc;
- }
- }
- }
- return null;
- }
-
- /*
- * @name setLogWriter
- *
- * @desc Sets the Print Writer
- *
- * @param PrintWriter
- *
- * @exception ResourceException
- */
- public void setLogWriter(PrintWriter out) throws ResourceException {
-
- try {
- // getXADataSource().setLogWriter(out);
- } catch (Exception ex) {
- ResourceException rex = new ResourceException("Exception");
- rex.initCause(ex);
- throw rex;
- }
- }
-
- /*
- * @name getLogWriter
- *
- * @desc Gets the Print Writer
- *
- * @return PrintWriter
- *
- * @exception ResourceException
- */
- public PrintWriter getLogWriter() throws ResourceException {
- try {
- return null;
- } catch (Exception ex) {
- ResourceException rex = new ResourceException("Exception");
- rex.initCause(ex);
- throw rex;
- }
- }
-
- /*
- * @name equals
- *
- * @desc compares the given object with this object.
- *
- * @return boolean
- */
- public boolean equals(Object obj) {
-
- if ((obj == null) || !(obj instanceof XAManagedConnectionFactory)) {
- return false;
- }
- if (obj == this) {
- return true;
- }
-
- XAManagedConnectionFactory that = (XAManagedConnectionFactory) obj;
-
- if ((this.reference != null)
- && !(this.reference.equals(that.getReference()))) {
- return false;
- } else if ((this.reference == null) && !(that.getReference() == null)) {
- return false;
- }
-
- if ((this.resourceAdapter != null)
- && !(this.resourceAdapter.equals(that.getResourceAdapter()))) {
- return false;
- } else if ((this.resourceAdapter == null)
- && !(that.getResourceAdapter() == null)) {
- return false;
- }
-
- if (this.count != that.getCount()) {
- return false;
- }
-
- if (!Util.isEqual(this.password, that.getPassword()))
- return false;
-
- if (!Util.isEqual(this.user, that.getUser()))
- return false;
-
- if (!Util.isEqual(this.userName, that.getUserName()))
- return false;
-
- if (!Util.isEqual(this.TSRValue, that.getTSRValue()))
- return false;
-
- return true;
- }
-
- /*
- * @name hashCode
- *
- * @desc gets the hashcode for this object.
- *
- * @return int
- */
- public int hashCode() {
-
- return this.getClass().getName().hashCode();
- }
-
- /*
- * @name getReference
- *
- * @desc Gives the reference of the class
- *
- * @return javax.naming.Reference
- */
- public javax.naming.Reference getReference() {
- javax.naming.Reference ref;
-
- ref = this.reference;
- return ref;
- }
-
- /*
- * @name setReference
- *
- * @desc sets the reference of the class
- *
- * @param javax.naming.Reference
- */
- public void setReference(javax.naming.Reference ref) {
- this.reference = ref;
- }
-
- public void setTSRValue(String name) {
- ConnectorStatus.getConnectorStatus()
- .logState("XAManagedConnectionFactory.setTSRValue");
- Debug.trace(
- "XAManagedConnectionFactory.setTSRValue called with value = " + name);
- this.TSRValue = name;
- }
-
- public String getTSRValue() {
- ConnectorStatus.getConnectorStatus()
- .logState("XAManagedConnectionFactory.getTSRValue");
- Debug.trace("XAManagedConnectionFactory.getTSRValue");
- return TSRValue;
- }
-
- public void lookupTSR(String lookup) {
- ConnectorStatus.getConnectorStatus()
- .logState("XAManagedConnectionFactory.lookupTSR");
- try {
- Debug.trace("lookupTSR() called with lookup name = " + lookup);
- TSNamingContext ncxt = new TSNamingContext();
- String newStr = "java:".concat(lookup);
- Object obj = (Object) ncxt.lookup(newStr);
- if (obj != null) {
- ConnectorStatus.getConnectorStatus().logState("TSR Lookup Successful");
- Debug.trace("TSR Lookup Successful");
- } else {
- Debug.trace("TSR Null");
- }
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- public int getCount() {
- return this.count;
- }
-
- public void setCount(int val) {
- this.count = val;
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/XAMessageXAResource.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/XAMessageXAResource.java
deleted file mode 100644
index a5dd2b1ac9..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/XAMessageXAResource.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.connector.whitebox;
-
-import javax.transaction.xa.XAException;
-import javax.transaction.xa.XAResource;
-import javax.transaction.xa.Xid;
-
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-
-public class XAMessageXAResource implements XAResource {
-
- public XAMessageXAResource() {
- System.out.println("XAMessageXAResource constructor");
- }
-
- private void handleResourceException(Exception ex) throws XAException {
-
- XAException xae = new XAException(ex.toString());
- xae.errorCode = XAException.XAER_RMERR;
- throw xae;
- }
-
- public void commit(Xid xid, boolean onePhase) throws XAException {
- try {
- System.out.println("XAMessageXAResource.commit");
- } catch (Exception ex) {
- handleResourceException(ex);
- }
- }
-
- public void start(Xid xid, int flags) throws XAException {
- try {
- System.out.println("XAMessageXAResource.start");
- } catch (Exception ex) {
- handleResourceException(ex);
- }
- }
-
- public void end(Xid xid, int flags) throws XAException {
- try {
- System.out.println("XAMessageXAResource.end");
- // ConnectorStatus.getConnectorStatus().logAPI("MessageXAResource.end" ,
- // "", "");
- } catch (Exception ex) {
- handleResourceException(ex);
- }
- }
-
- public void forget(Xid xid) throws XAException {
- System.out.println("XAMessageXAResource.forget");
- }
-
- public int getTransactionTimeout() throws XAException {
- return 1;
- }
-
- public boolean isSameRM(XAResource other) throws XAException {
- System.out.println("XAMessageXAResource.isSameRM");
- return false;
- }
-
- public int prepare(Xid xid) throws XAException {
- ConnectorStatus.getConnectorStatus().logAPI("XAMessageXAResource.prepare",
- "", "");
- System.out.println("XAMessageXAResource.prepare");
- try {
- return XAResource.XA_OK;
- } catch (Exception ex) {
- handleResourceException(ex);
- return XAException.XAER_RMERR;
- }
- }
-
- public Xid[] recover(int flag) throws XAException {
- System.out.println("XAMessageXAResource.recover");
- return null;
- }
-
- public void rollback(Xid xid) throws XAException {
- try {
- System.out.println("XAMessageXAResource.rollback");
- } catch (Exception ex) {
- handleResourceException(ex);
- }
- }
-
- public boolean setTransactionTimeout(int seconds) throws XAException {
- return true;
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/XAResourceAdapterImpl.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/XAResourceAdapterImpl.java
deleted file mode 100644
index 1e514e62ab..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/XAResourceAdapterImpl.java
+++ /dev/null
@@ -1,295 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.connector.whitebox;
-
-import java.io.Serializable;
-import java.lang.reflect.Method;
-import java.util.Vector;
-
-import javax.transaction.xa.XAResource;
-
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-import com.sun.ts.tests.common.connector.util.TSMessageListenerInterface;
-
-import jakarta.resource.spi.ActivationSpec;
-import jakarta.resource.spi.BootstrapContext;
-import jakarta.resource.spi.ResourceAdapter;
-import jakarta.resource.spi.ResourceAdapterInternalException;
-import jakarta.resource.spi.endpoint.MessageEndpointFactory;
-import jakarta.resource.spi.work.Work;
-import jakarta.resource.spi.work.WorkManager;
-
-public class XAResourceAdapterImpl implements ResourceAdapter, Serializable {
- // IMPORTANT: for compliance, if you add non-transient member data
- // here, be sure to add respective entry to equals() method below.
-
- private transient TestWorkManager twm;
-
- private transient TestBootstrapContext tbs;
-
- private transient LocalTxMessageListener ml;
-
- private String RAName; // value from ra's xml file
-
- private Boolean useSecurityMapping = null; // value from ra's xml file
-
- private int counter = 0;
-
- private transient javax.transaction.xa.XAResource xaresource;
-
- private transient LocalTxMessageWork2 work3;
-
- private transient WorkManager wm;
-
- private int mefcount = 0;
-
- private transient MessageEndpointFactory mef1;
-
- private transient MessageEndpointFactory mef2;
-
- private transient BootstrapContext bsc;
-
- public XAResourceAdapterImpl() {
- ConnectorStatus.getConnectorStatus()
- .logState("XAResourceAdapterImpl Constructor ");
- System.out.println("XAResourceAdapterImpl Constructor ");
- }
-
- public void start(final BootstrapContext bsc)
- throws ResourceAdapterInternalException {
- // setup network endpoints
- counter++;
- this.bsc = bsc;
- System.out.println("XAResourceAdapter Started " + counter);
- String str1 = new String("XAResourceAdapter Started " + counter);
- ConnectorStatus.getConnectorStatus().logState(str1);
-
- // get WorkManager reference
-
- WorkManager wm = null;
-
- if (bsc != null) {
- ConnectorStatus.getConnectorStatus()
- .logState("XAResourceAdapter BootstrapContext Not Null ");
- wm = bsc.getWorkManager();
- } else {
- ConnectorStatus.getConnectorStatus()
- .logState("ERROR - XAResourceAdapter BootstrapContext is Null ");
- }
-
- if (wm != null) {
- ConnectorStatus.getConnectorStatus()
- .logState("XAResourceAdapter WorkManager Not Null ");
- } else {
- ConnectorStatus.getConnectorStatus()
- .logState("WARNING XAResourceAdapter WorkManager is Null ");
- }
-
- try {
- checkAssociation();
- bsc.getWorkManager().startWork(new Work() {
- public void run() {
- myStart(bsc);
- }
-
- public void release() {
- }
-
- });
- } catch (jakarta.resource.spi.work.WorkException we) {
- throw new ResourceAdapterInternalException();
- }
-
- }
-
- private void myStart(final BootstrapContext ctx) {
- wm = ctx.getWorkManager();
- // Create TestWorkManager object
- twm = new TestWorkManager(ctx);
- if (this.useSecurityMapping.booleanValue() == true) {
- // values from our RA xml file indicate we want to establish Case 2
- // security for the RA. This means we need security mappings.
- Debug.trace(
- " XAResourceAdapterImpl ; calling setUseSecurityMapping(true)");
- twm.setUseSecurityMapping(true);
- } else {
- // use Case 1 security thus do NO mapping of identities
- Debug.trace(
- " XAResourceAdapterImpl ; calling setUseSecurityMapping(false)");
- twm.setUseSecurityMapping(false);
- }
- twm.runTests();
-
- // Create TestBootstrap object
- tbs = new TestBootstrapContext(ctx);
- tbs.runTests();
- }
-
- public void stop() {
- // Set the TestWorkManager to null upon resource adapter shutdown.
- // twm = null;
- if (work3 != null) {
- work3.stop();
- }
-
- }
-
- public void endpointActivation(MessageEndpointFactory mef,
- ActivationSpec as) {
- }
-
- public void endpointDeactivation(MessageEndpointFactory mef,
- ActivationSpec as) {
-
- }
-
- public XAResource[] getXAResources(ActivationSpec[] as) {
- return null;
- }
-
- private Method getOnMessageMethod() {
-
- Method onMessageMethod = null;
- try {
- Class msgListenerClass = TSMessageListenerInterface.class;
- Class[] paramTypes = { java.lang.String.class };
- onMessageMethod = msgListenerClass.getMethod("onMessage", paramTypes);
-
- } catch (NoSuchMethodException ex) {
- ex.printStackTrace();
- }
- return onMessageMethod;
- }
-
- private void chkUniqueMessageEndpointFactory() {
- if ((mef1 != null) && (!mef1.equals(mef2))) {
- Debug.trace("XA MessageEndpointFactory is Unique");
- Debug.trace("XA MessageEndpointFactory equals implemented correctly");
- }
- }
-
- /*
- * This method is used to assist in the verification process of assertion
- * Connector:SPEC:245 This method must be called befor the work instances
- * 'run' method is called. This method checks if the setResourceAdapter()
- * method was called and if so, then this method logs a message to indicate
- * that it was called prior to the 'run' method of the run method.
- */
- public void checkAssociation() {
- Vector vLog = ConnectorStatus.getConnectorStatus().getStateLogVector();
- String toCheck1 = "XAManagedConnectionFactory setResourceAdapter 1";
-
- for (int i = 0; i < vLog.size(); i++) {
- String str = (String) vLog.elementAt(i);
- if (str.startsWith(toCheck1)) {
- ConnectorStatus.getConnectorStatus().logState(
- "XAResourceAdapter - association exists between RA and work");
- break;
- }
- }
-
- }
-
- /*
- * @name equals
- *
- * @desc compares this object with the given object.
- *
- * @param Object obj
- *
- * @return boolean
- */
- public boolean equals(Object obj) {
-
- if ((obj == null) || !(obj instanceof XAResourceAdapterImpl)) {
- return false;
- }
- if (obj == this) {
- return true;
- }
-
- XAResourceAdapterImpl that = (XAResourceAdapterImpl) obj;
-
- if (this.counter != that.getCounter()) {
- return false;
- }
-
- if (this.mefcount != that.getMefcount()) {
- return false;
- }
-
- if (!Util.isEqual(this.RAName, that.getRAName()))
- return false;
-
- if (this.getUseSecurityMapping().booleanValue() != that
- .getUseSecurityMapping().booleanValue()) {
- return false;
- }
-
- return true;
- }
-
- /*
- * @name hashCode
- *
- * @desc gets the hashcode for this object.
- *
- * @return int
- */
- public int hashCode() {
- return this.getClass().getName().hashCode();
- }
-
- public void setRAName(String name) {
- ConnectorStatus.getConnectorStatus()
- .logState("XAResourceAdapter.setRAName");
- this.RAName = name;
- }
-
- public String getRAName() {
- Debug.trace("XAResourceAdapter.getRAName");
- return RAName;
- }
-
- public void setUseSecurityMapping(Boolean val) {
- this.useSecurityMapping = val;
- }
-
- public Boolean getUseSecurityMapping() {
- return this.useSecurityMapping;
- }
-
- public void setCounter(int val) {
- this.counter = val;
- }
-
- public int getCounter() {
- return this.counter;
- }
-
- public void setMefcount(int val) {
- this.mefcount = val;
- }
-
- public int getMefcount() {
- return this.mefcount;
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/XAResourceImpl.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/XAResourceImpl.java
deleted file mode 100644
index a1b2995af6..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/XAResourceImpl.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.connector.whitebox;
-
-import java.util.Hashtable;
-
-import javax.transaction.xa.XAException;
-import javax.transaction.xa.XAResource;
-import javax.transaction.xa.Xid;
-
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-
-public class XAResourceImpl implements XAResource {
-
- private TSManagedConnection mc;
-
- private int seconds = 0;
-
- private Hashtable xidset = null;
-
- public XAResourceImpl(TSManagedConnection mc) {
- this.mc = mc;
- xidset = new Hashtable();
- if (mc == null) {
- System.out.println("TSManagedConnection is null in XAResourceImpl");
- }
-
- }
-
- private void handleResourceException(Exception ex) throws XAException {
-
- XAException xae = new XAException(ex.toString());
- xae.errorCode = XAException.XAER_RMERR;
- throw xae;
- }
-
- public void commit(Xid xid, boolean onePhase) throws XAException {
- try {
- System.out.println("XAResourceImpl.commit");
- // To detect two phase commit and see if the
- // prepare method was called or not.
- ConnectorStatus.getConnectorStatus().logAPI("XAResourceImpl.commit", "",
- "");
- TSeis.getTSeis().getResourceManager().commit(xid, onePhase);
- } catch (XAException xe) {
- throw xe;
- } catch (Exception ex) {
- handleResourceException(ex);
- }
- }
-
- public void start(Xid xid, int flags) throws XAException {
- try {
- System.out.println("XAResourceImpl.start");
- TSeis.getTSeis().getResourceManager().start(xid, flags,
- mc.getTSConnection());
- ConnectorStatus.getConnectorStatus().logAPI("XAResourceImpl.start", "",
- "");
- } catch (XAException xe) {
- throw xe;
- } catch (Exception ex) {
- handleResourceException(ex);
- }
- }
-
- public void end(Xid xid, int flags) throws XAException {
- try {
- System.out.println("XAResourceImpl.end");
- TSeis.getTSeis().getResourceManager().end(xid, flags);
- ConnectorStatus.getConnectorStatus().logAPI("XAResourceImpl.end", "", "");
- } catch (XAException xe) {
- throw xe;
- } catch (Exception ex) {
- handleResourceException(ex);
- }
- }
-
- public void forget(Xid xid) throws XAException {
- System.out.println("XAResourceImpl.forget");
- }
-
- public int getTransactionTimeout() throws XAException {
- return this.seconds;
- }
-
- public boolean isSameRM(XAResource other) throws XAException {
- System.out.println("XAResourceImpl.isSameRM");
- if (this == other)
- return true;
- if (other == null)
- return false;
- if ((other instanceof XAResourceImpl) && (this.mc != null)) {
- XAResourceImpl obj = (XAResourceImpl) other;
- return (this.mc.equals(obj.mc));
- } else {
- return false;
- }
- }
-
- public int prepare(Xid xid) throws XAException {
- ConnectorStatus.getConnectorStatus().logAPI("XAResourceImpl.prepare", "",
- "");
- System.out.println("XAResourceImpl.prepare");
- try {
- return TSeis.getTSeis().getResourceManager().prepare(xid);
- } catch (XAException xe) {
- throw xe;
- } catch (Exception ex) {
- handleResourceException(ex);
- return XAException.XAER_RMERR;
- }
- }
-
- public Xid[] recover(int flag) throws XAException {
- System.out.println("XAResourceImpl.recover");
- return null;
- }
-
- public void rollback(Xid xid) throws XAException {
- try {
- System.out.println("XAResourceImpl.rollback");
- TSeis.getTSeis().getResourceManager().rollback(xid);
- ConnectorStatus.getConnectorStatus().logAPI("XAResourceImpl.rollback", "",
- "");
- } catch (XAException xe) {
- throw xe;
- } catch (Exception ex) {
- handleResourceException(ex);
- }
- }
-
- public boolean setTransactionTimeout(int seconds) throws XAException {
- this.seconds = seconds;
- return true;
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/XidImpl.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/XidImpl.java
deleted file mode 100644
index 02bdc84655..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/XidImpl.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.common.connector.whitebox;
-
-import javax.transaction.xa.Xid;
-
-public class XidImpl implements Xid {
-
- private static int ID = 0;
-
- public int formatID; // Format identifier
- // (-1) means that the XidImpl is null
-
- public int branchQualifier;
-
- public int globalTxID;
-
- static public final int MAXGTRIDSIZE = 64;
-
- static public final int MAXBQUALSIZE = 64;
-
- public XidImpl() {
- int foo = ++ID;
- formatID = foo;
- branchQualifier = foo;
- globalTxID = foo;
- }
-
- public boolean equals(Object o) {
- XidImpl other; // The "other" XidImpl
- int L; // Combined gtrid_length + bqual_length
- int i;
-
- if (!(o instanceof XidImpl)) // If the other XidImpl isn't an XidImpl
- {
- return false; // It can't be equal
- }
-
- other = (XidImpl) o; // The other XidImpl, now properly cast
-
- if (this.formatID == other.formatID
- && this.branchQualifier == other.branchQualifier
- && this.globalTxID == other.globalTxID) {
- return true;
- }
-
- return false;
- }
-
- /**
- * Compute the hash code.
- *
- * @return the computed hashcode
- */
- public int hashCode() {
- if (formatID == (-1)) {
- return (-1);
- }
-
- return formatID + branchQualifier + globalTxID;
-
- }
-
- /*
- * Convert to String
- *
- *
This is normally used to display the XidImpl when debugging.
- */
-
- /**
- * Return a string representing this XidImpl.
- *
- * @return the string representation of this XidImpl
- */
- public String toString() {
-
- String s = new String(
- "{XidImpl: " + "formatID(" + formatID + "), " + "branchQualifier ("
- + branchQualifier + "), " + "globalTxID(" + globalTxID + ")}");
-
- return s;
- }
-
- /*
- * Return branch qualifier
- */
-
- /**
- * Returns the branch qualifier for this XidImpl.
- *
- * @return the branch qualifier
- */
- public byte[] getBranchQualifier() {
- String foo = (new Integer(branchQualifier)).toString();
- return foo.getBytes();
- }
-
- public int getFormatId() {
- return formatID;
- }
-
- public byte[] getGlobalTransactionId() {
- String foo = (new Integer(globalTxID)).toString();
- return foo.getBytes();
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/annotated/AnnoManagedConnectionFactory.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/annotated/AnnoManagedConnectionFactory.java
deleted file mode 100644
index 38aa5fe428..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/annotated/AnnoManagedConnectionFactory.java
+++ /dev/null
@@ -1,502 +0,0 @@
-/*
- * Copyright (c) 2009, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.common.connector.whitebox.annotated;
-
-import java.io.PrintWriter;
-import java.io.Serializable;
-import java.util.Iterator;
-import java.util.Set;
-
-import javax.security.auth.Subject;
-
-import com.sun.ts.lib.util.TSNamingContext;
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-import com.sun.ts.tests.common.connector.whitebox.Debug;
-import com.sun.ts.tests.common.connector.whitebox.TSConnection;
-import com.sun.ts.tests.common.connector.whitebox.TSConnectionImpl;
-import com.sun.ts.tests.common.connector.whitebox.TSEISDataSource;
-import com.sun.ts.tests.common.connector.whitebox.TSManagedConnection;
-import com.sun.ts.tests.common.connector.whitebox.Util;
-
-import jakarta.resource.ResourceException;
-import jakarta.resource.spi.ConfigProperty;
-import jakarta.resource.spi.ConnectionDefinition;
-import jakarta.resource.spi.ConnectionDefinitions;
-import jakarta.resource.spi.ConnectionManager;
-import jakarta.resource.spi.ConnectionRequestInfo;
-import jakarta.resource.spi.EISSystemException;
-import jakarta.resource.spi.ManagedConnection;
-import jakarta.resource.spi.ManagedConnectionFactory;
-import jakarta.resource.spi.ManagedConnectionMetaData;
-import jakarta.resource.spi.ResourceAdapter;
-import jakarta.resource.spi.ResourceAdapterAssociation;
-import jakarta.resource.spi.security.PasswordCredential;
-
-@ConnectionDefinitions({
- @ConnectionDefinition(connectionFactory = com.sun.ts.tests.common.connector.whitebox.TSConnectionFactory.class, connectionFactoryImpl = com.sun.ts.tests.common.connector.whitebox.TSEISDataSource.class, connection = com.sun.ts.tests.common.connector.whitebox.TSConnection.class, connectionImpl = com.sun.ts.tests.common.connector.whitebox.TSEISConnection.class) })
-public class AnnoManagedConnectionFactory implements ManagedConnectionFactory,
- ResourceAdapterAssociation, jakarta.resource.Referenceable, Serializable {
- private javax.naming.Reference reference;
-
- private ResourceAdapter resourceAdapter;
-
- private int count;
-
- private String tsrValue;
-
- private String password;
-
- private String user;
-
- private String userName;
-
- private String setterMethodVal = "DEFAULT";
-
- @ConfigProperty(defaultValue = "10", type = Integer.class, description = "Integer value", ignore = false)
- private Integer integer;
-
- @ConfigProperty()
- private String factoryName = "AnnoManagedConnectionFactory";
-
- /*
- * @name AnnoManagedConnectionFactory
- *
- * @desc Default conctructor
- */
- public AnnoManagedConnectionFactory() {
- // this helps verify assertion Connector:SPEC:279 and Connector:SPEC:277
- String str = "AnnoManagedConnectionFactory factoryName=" + factoryName;
- ConnectorStatus.getConnectorStatus().logState(str);
-
- // lets make sure we can call and set setSetterMethodVal()
- setSetterMethodVal("NONDEFAULT");
-
- debug(str);
- }
-
- /*
- * used to help test assertion Connector:SPEC:278
- */
- @ConfigProperty()
- public void setSetterMethodVal(String val) {
- setterMethodVal = val;
- String str = "AnnotatedResourceAdapterImpl.setSetterMethodVal="
- + setterMethodVal;
- ConnectorStatus.getConnectorStatus().logState(str);
- }
-
- public String getSetterMethodVal() {
- return setterMethodVal;
- }
-
- public void setFactoryName(String name) {
- this.factoryName = name;
- }
-
- public String getFactoryName() {
- return factoryName;
- }
-
- public Integer getInteger() {
- return this.integer;
- }
-
- public void setInteger(Integer val) {
- this.integer = val;
- }
-
- public String getUser() {
- debug("AnnoManagedConnectionFactory.getUser() returning: " + user);
- return user;
- }
-
- public void setUser(String val) {
- debug("AnnoManagedConnectionFactory.setUser() with val = " + val);
- user = val;
- }
-
- public String getUserName() {
- debug("AnnoManagedConnectionFactory.getUserName() returning: " + userName);
- return userName;
- }
-
- public void setUserName(String val) {
- debug("AnnoManagedConnectionFactory.setUserName() with val = " + val);
- userName = val;
- }
-
- public String getPassword() {
- debug("AnnoManagedConnectionFactory.getPassword() returning: " + password);
- return password;
- }
-
- public void setPassword(String val) {
- debug("AnnoManagedConnectionFactory.setPassword() with val = " + val);
- password = val;
- }
-
- public String getTsrValue() {
- debug("AnnoManagedConnectionFactory getTsrValue called" + tsrValue);
- return tsrValue;
- }
-
- public void setTsrValue(String name) {
- debug("AnnoManagedConnectionFactory setTsrValue called" + name);
- this.tsrValue = name;
- }
-
- public void lookupTSR(String lookup) {
- try {
- TSNamingContext ncxt = new TSNamingContext();
- String newStr = "java:".concat(lookup);
- Object obj = (Object) ncxt.lookup(newStr);
- if (obj != null) {
- debug("TSR NOT Null");
- } else {
- debug("TSR Null");
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- /*
- * @name createConnectionFactory
- *
- * @desc Creates a new connection factory instance
- *
- * @param ConnectionManager
- *
- * @return Object
- *
- * @exception ResourceException
- */
- public Object createConnectionFactory(ConnectionManager cxManager)
- throws ResourceException {
- return new TSEISDataSource(this, cxManager);
- }
-
- /*
- * @name createConnectionFactory
- *
- * @desc Creates a new connection factory instance
- *
- * @return Object
- *
- * @exception ResourceException
- */
- public Object createConnectionFactory() throws ResourceException {
- return new TSEISDataSource(this, null);
- }
-
- /*
- * @name setResourceAdapter
- *
- * @desc sets the Resource Adapter for this ManagedConnectionFactory
- *
- * @return
- *
- * @exception ResourceException
- */
- public void setResourceAdapter(ResourceAdapter ra) throws ResourceException {
- count++;
- String newStr1 = "AnnoManagedConnectionFactory setResourceAdapter " + count;
- debug(newStr1);
- this.resourceAdapter = ra;
- }
-
- /*
- * @name getResourceAdapter
- *
- * @desc gets the Resource Adapter for this ManagedConnectionFactory
- *
- * @return Object
- *
- * @exception ResourceException
- */
- public ResourceAdapter getResourceAdapter() {
- debug("AnnoManagedConnectionFactory.getResource");
- return resourceAdapter;
- }
-
- /*
- * @name createManagedConnection
- *
- * @desc Creates a new managed connection to the underlying EIS
- *
- * @param Subject, ConnectionRequestInfo
- *
- * @return ManagedConnection
- *
- * @exception ResourceException
- */
- public ManagedConnection createManagedConnection(Subject subject,
- ConnectionRequestInfo info) throws ResourceException {
-
- try {
-
- TSConnection con = null;
- PasswordCredential pc = Util.getPasswordCredential(this, subject, info);
- if (pc == null) {
- debug(
- "AnnoManagedConnectionFactory.createManagedConnection(): pc == null");
- debug("TSConnectionImpl.getConnection()");
- con = new TSConnectionImpl().getConnection();
- } else {
- debug(
- "AnnoManagedConnectionFactory.createManagedConnection(): pc != null");
- setUser(pc.getUserName());
- setUserName(pc.getUserName());
- setPassword(new String(pc.getPassword()));
- debug("TSConnectionImpl.getConnection(u,p)");
- con = new TSConnectionImpl().getConnection(pc.getUserName(),
- pc.getPassword());
- }
-
- ManagedConnection mcon = new TSManagedConnection(this, pc, null, con,
- false, true);
- dumpConnectionMetaData(mcon);
-
- return mcon;
- } catch (Exception ex) {
- ResourceException re = new EISSystemException(
- "Exception: " + ex.getMessage());
- re.initCause(ex);
- throw re;
- }
-
- }
-
- public void dumpConnectionMetaData(ManagedConnection mcon) {
-
- String hdr = "AnnoManagedConnectionFactory: ";
- String out;
- boolean bLocal = false;
- boolean bXA = false;
-
- try {
- ManagedConnectionMetaData mdata = mcon.getMetaData();
-
- out = hdr + "displayName=" + mdata.getEISProductName();
- debug(out);
-
- out = hdr + "version=" + mdata.getEISProductVersion();
- debug(out);
-
- // get transaction type
- try {
- mcon.getLocalTransaction();
- bLocal = true;
- } catch (ResourceException ex) {
- System.out.println(hdr + "not a localTransaction type");
- }
- try {
- mcon.getXAResource();
- bXA = true;
- } catch (ResourceException ex) {
- System.out.println(hdr + "not a XAResource type");
- }
-
- out = hdr + "transactionSupport=";
- if (bLocal) {
- out = out + "LocalTransaction";
- } else if (bXA) {
- out = out + "XATransaction";
- } else {
- // assume default case of noTx
- out = out + "NoTransaction";
- }
- debug(out);
- } catch (ResourceException ex) {
- System.out.println(ex.getMessage());
- ex.printStackTrace();
- }
- }
-
- /*
- * @name matchManagedConnection
- *
- * @desc Return the existing connection from the connection pool
- *
- * @param Set, Subject, ConnectionRequestInfo
- *
- * @return ManagedConnection
- *
- * @exception ResourceException
- */
- public ManagedConnection matchManagedConnections(Set connectionSet,
- Subject subject, ConnectionRequestInfo info) throws ResourceException {
-
- PasswordCredential pc = Util.getPasswordCredential(this, subject, info);
- Iterator it = connectionSet.iterator();
-
- while (it.hasNext()) {
- Object obj = it.next();
- if (obj instanceof TSManagedConnection) {
- TSManagedConnection mc = (TSManagedConnection) obj;
- ManagedConnectionFactory mcf = mc.getManagedConnectionFactory();
- if (Util.isPasswordCredentialEqual(mc.getPasswordCredential(), pc)
- && (mcf != null) && mcf.equals(this)) {
- return mc;
- }
- }
- }
-
- System.out.println("matchManagedConnections: couldnt find match");
- return null;
- }
-
- /*
- * @name setLogWriter
- *
- * @desc Sets the Print Writer
- *
- * @param PrintWriter
- *
- * @exception ResourceException
- */
- public void setLogWriter(PrintWriter out) throws ResourceException {
- }
-
- /*
- * @name getLogWriter
- *
- * @desc Gets the Print Writer
- *
- * @return PrintWriter
- *
- * @exception ResourceException
- */
- public PrintWriter getLogWriter() throws ResourceException {
- return null;
- }
-
- /*
- * @name equals
- *
- * @desc Compares the given object to the ManagedConnectionFactory instance.
- *
- * @param Object
- *
- * @return boolean
- */
- public boolean equals(Object obj) {
-
- if ((obj == null) || !(obj instanceof AnnoManagedConnectionFactory)) {
- return false;
- }
- if (obj == this) {
- return true;
- }
-
- AnnoManagedConnectionFactory that = (AnnoManagedConnectionFactory) obj;
-
- if ((this.reference != null)
- && !(this.reference.equals(that.getReference()))) {
- return false;
- } else if ((this.reference == null) && !(that.getReference() == null)) {
- return false;
- }
-
- if ((this.resourceAdapter != null)
- && !(this.resourceAdapter.equals(that.getResourceAdapter()))) {
- return false;
- } else if ((this.resourceAdapter == null)
- && !(that.getResourceAdapter() == null)) {
- return false;
- }
-
- if (this.count != that.getCount()) {
- return false;
- }
-
- if ((this.integer != null) && (!this.integer.equals(that.getInteger()))) {
- return false;
- } else if ((this.integer == null) && !(that.getInteger() == null)) {
- return false;
- }
-
- if (!Util.isEqual(this.password, that.getPassword()))
- return false;
-
- if (!Util.isEqual(this.user, that.getUser()))
- return false;
-
- if (!Util.isEqual(this.userName, that.getUserName()))
- return false;
-
- if (!Util.isEqual(this.tsrValue, that.getTsrValue()))
- return false;
-
- if (!Util.isEqual(this.setterMethodVal, that.getSetterMethodVal()))
- return false;
-
- if (!Util.isEqual(this.factoryName, that.getFactoryName()))
- return false;
-
- return true;
- }
-
- /*
- * @name hashCode
- *
- * @desc Gives a hash value to a ManagedConnectionFactory Obejct.
- *
- * @return int
- */
- public int hashCode() {
- return this.getClass().getName().hashCode();
- }
-
- /*
- * @name getReference
- *
- * @desc Gives the reference of the class
- *
- * @return javax.naming.Reference
- */
- public javax.naming.Reference getReference() {
- javax.naming.Reference ref;
-
- ref = this.reference;
- return ref;
- }
-
- /*
- * @name setReference
- *
- * @desc sets the reference of the class
- *
- * @param javax.naming.Reference
- */
- public void setReference(javax.naming.Reference ref) {
- this.reference = ref;
- }
-
- public void debug(String out) {
- Debug.trace("AnnoManagedConnectionFactory: " + out);
- }
-
- public int getCount() {
- return this.count;
- }
-
- public void setCount(int val) {
- this.count = val;
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/annotated/AnnoWorkManager.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/annotated/AnnoWorkManager.java
deleted file mode 100644
index b8b1ea7cc4..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/annotated/AnnoWorkManager.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * Copyright (c) 2009, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.common.connector.whitebox.annotated;
-
-import javax.transaction.xa.XAException;
-import javax.transaction.xa.Xid;
-
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-import com.sun.ts.tests.common.connector.whitebox.Debug;
-import com.sun.ts.tests.common.connector.whitebox.WorkImpl;
-import com.sun.ts.tests.common.connector.whitebox.WorkListenerImpl;
-import com.sun.ts.tests.common.connector.whitebox.XidImpl;
-
-import jakarta.resource.spi.BootstrapContext;
-import jakarta.resource.spi.XATerminator;
-import jakarta.resource.spi.work.ExecutionContext;
-import jakarta.resource.spi.work.TransactionContext;
-import jakarta.resource.spi.work.WorkException;
-import jakarta.resource.spi.work.WorkManager;
-
-public class AnnoWorkManager {
- private BootstrapContext bsc = null;
-
- private WorkManager wmgr;
-
- private Xid myxid;
-
- private Xid mynestxid;
-
- private XATerminator xa;
-
- public AnnoWorkManager(BootstrapContext val) {
- debug("enterred constructor");
- this.bsc = val;
- this.wmgr = bsc.getWorkManager();
- this.xa = bsc.getXATerminator();
-
- debug("leaving constructor");
- }
-
- public void runTests() {
- debug("enterred runTests");
- doWork();
- doTCWork();
- submitNestedXidWork();
- debug("leaving runTests");
- }
-
- public void doWork() {
- debug("enterred doWork");
-
- try {
- WorkImpl workimpl = new WorkImpl(wmgr);
-
- ExecutionContext ec = new ExecutionContext();
- WorkListenerImpl wl = new WorkListenerImpl();
- wmgr.doWork(workimpl, 5000, ec, wl);
- ConnectorStatus.getConnectorStatus()
- .logState("AnnoWorkManager Work Object Submitted");
- debug("AnnoWorkManager Work Object Submitted");
- } catch (WorkException we) {
- System.out.println(
- "AnnoWorkManager WorkException thrown is " + we.getMessage());
- } catch (Exception ex) {
- System.out
- .println("AnnoWorkManager Exception thrown is " + ex.getMessage());
- }
-
- debug("leaving doWork");
- }
-
- private TransactionContext startTx() {
- TransactionContext tc = new TransactionContext();
- try {
- Xid xid = new XidImpl();
- tc.setXid(xid);
- tc.setTransactionTimeout(5 * 1000); // 5 seconds
- } catch (Exception ex) {
- Debug.printDebugStack(ex);
- }
- return tc;
- }
-
- /*
- * This will be used to help verify assertion Connector:SPEC:55 from the
- * annotation point of view.
- */
- public void doTCWork() {
- try {
- XidImpl myid = new XidImpl();
- WorkImpl workimpl = new WorkImpl(wmgr);
- TransactionContext tc = startTx();
- tc.setXid(myid);
-
- Debug.trace("Creating WorkListener");
- WorkListenerImpl wl = new WorkListenerImpl();
- wmgr.doWork(workimpl, 5000, tc, wl);
- ConnectorStatus.getConnectorStatus()
- .logState("TransactionContext Work Object Submitted");
-
- xa.commit(tc.getXid(), true);
- } catch (XAException xe) {
- Debug.trace("AnnoWorkManager.doTCWork(): XAException" + xe.getMessage());
- Debug.trace("AnnoWorkManager XAException.toString() = " + xe.toString());
- Debug.printDebugStack(xe);
- } catch (WorkException we) {
- Debug.trace("TestWorkManager Exception thrown is " + we.getMessage());
- }
- }
-
- public void setXid(Xid xid) {
- this.myxid = xid;
- }
-
- public Xid getXid() {
- return this.myxid;
- }
-
- public void setNestXid(Xid xid) {
- this.mynestxid = xid;
- }
-
- public Xid getNestXid() {
- return this.mynestxid;
- }
-
- /*
- * This is used to help verify assertion: Connector:SPEC:210 While the spec is
- * clear to state that nested work contexts are to be supported, it appears
- * there may be some grey area wrt nested work objects with transaction
- * contexts. It may be the case that nested transaction contexts may not be
- * clearly defined in the connector 1.6 spec - so we will test nested work
- * objs where only 1 of the work objs has transactioncontext.
- */
- public void submitNestedXidWork() {
- try {
- XidImpl myid = new XidImpl();
- NestedWorkXid1 workid = new NestedWorkXid1(wmgr, myid,
- NestedWorkXid1.ContextType.EXECUTION_CONTEXT);
-
- // setting up the xid so it can be commited later.
- setNestXid(myid);
-
- TransactionContext tc = startTx();
- tc.setXid(myid);
- wmgr.doWork(workid, wmgr.INDEFINITE, tc, null);
-
- Debug.trace("Anno based NestedWorkXid1 Submitted");
- ConnectorStatus.getConnectorStatus()
- .logState("anno based NestedWorkXid1 parent context submitted");
- xa.commit(tc.getXid(), true);
-
- } catch (XAException xe) {
- Debug.trace("AnnoWorkManager.submitNestedXidWork(): XAException"
- + xe.getMessage());
- Debug.trace("AnnoWorkManager XAException.toString() = " + xe.toString());
- Debug.printDebugStack(xe);
- } catch (WorkException we) {
- Debug.printDebugStack(we);
- } catch (Exception ex) {
- Debug.printDebugStack(ex);
- }
- }
-
- public void debug(String out) {
- Debug.trace("AnnoWorkManager: " + out);
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/annotated/AnnotatedResourceAdapterImpl.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/annotated/AnnotatedResourceAdapterImpl.java
deleted file mode 100755
index f980ce86a1..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/annotated/AnnotatedResourceAdapterImpl.java
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * Copyright (c) 2009, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.common.connector.whitebox.annotated;
-
-import javax.transaction.xa.XAResource;
-
-import com.sun.ts.lib.util.TestUtil;
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-import com.sun.ts.tests.common.connector.whitebox.Debug;
-import com.sun.ts.tests.common.connector.whitebox.Util;
-
-import jakarta.resource.NotSupportedException;
-import jakarta.resource.ResourceException;
-import jakarta.resource.spi.ActivationSpec;
-import jakarta.resource.spi.AuthenticationMechanism;
-import jakarta.resource.spi.BootstrapContext;
-import jakarta.resource.spi.ConfigProperty;
-import jakarta.resource.spi.Connector;
-import jakarta.resource.spi.ResourceAdapter;
-import jakarta.resource.spi.ResourceAdapterInternalException;
-import jakarta.resource.spi.SecurityPermission;
-import jakarta.resource.spi.TransactionSupport;
-import jakarta.resource.spi.endpoint.MessageEndpointFactory;
-import jakarta.resource.spi.work.HintsContext;
-import jakarta.resource.spi.work.SecurityContext;
-import jakarta.resource.spi.work.Work;
-import jakarta.resource.spi.work.WorkManager;
-
-/**
- * This is a sample resource adapter that will use no ra.xml info. This RA is
- * used to assist with verifying the server supports annotations when there is
- * no ra.xml (Assertion 268) and the transaction support is Local.
- *
- */
-
-@Connector(description = "CTS Test Resource Adapter with No DD", displayName = "whitebox-anno_no_md.rar", vendorName = "Java Software", eisType = "TS EIS", version = "1.6", licenseDescription = "CTS License Required", licenseRequired = true, authMechanisms = @AuthenticationMechanism(credentialInterface = AuthenticationMechanism.CredentialInterface.PasswordCredential, authMechanism = "BasicPassword", description = "Basic Password Authentication"), reauthenticationSupport = false, securityPermissions = @SecurityPermission(description = "Security Perm description"), transactionSupport = TransactionSupport.TransactionSupportLevel.LocalTransaction, requiredWorkContexts = {
- HintsContext.class, SecurityContext.class })
-public class AnnotatedResourceAdapterImpl
- implements ResourceAdapter, java.io.Serializable {
-
- private transient BootstrapContext bsc;
-
- private transient AnnoWorkManager awm;
-
- private transient WorkManager wm;
-
- private transient Work work;
-
- private String serverSideUser = ""; // corresponds to ts.jte's 'user' property
-
- private String serverSidePwd = ""; // corresponds to ts.jte's 'password'
- // property
-
- private String eisUser = ""; // corresponds to ts.jte's 'user1' property
-
- private String eisPwd = ""; // corresponds to ts.jte's 'password' property
-
- @ConfigProperty(defaultValue = "AnnotatedResourceAdapterImpl")
- private String raName;
-
- /**
- * constructor
- **/
- public AnnotatedResourceAdapterImpl() {
- debug("enterred constructor...");
-
- this.serverSideUser = TestUtil.getSystemProperty("j2eelogin.name");
- this.serverSidePwd = TestUtil.getSystemProperty("j2eelogin.password");
- this.eisUser = TestUtil.getSystemProperty("eislogin.name");
- this.eisPwd = TestUtil.getSystemProperty("eislogin.password");
-
- debug("leaving constructor...");
- }
-
- //
- // Begin ResourceAdapter interface requirements
- //
-
- /* must implement for ResourceAdapter interface requirement */
- public void start(BootstrapContext bsc)
- throws ResourceAdapterInternalException {
- debug("enterred start");
-
- ConnectorStatus.getConnectorStatus()
- .logState("AnnotatedResourceAdapterImpl.start called");
-
- this.bsc = bsc;
- this.wm = bsc.getWorkManager();
-
- this.awm = new AnnoWorkManager(bsc);
- awm.runTests();
-
- debug("leaving start");
- }
-
- /* must implement for ResourceAdapter interface requirement */
- public void stop() {
- debug("entered stop");
- debug("leaving stop");
- }
-
- /* must implement for ResourceAdapter interface requirement */
- public void endpointActivation(MessageEndpointFactory factory,
- ActivationSpec spec) throws NotSupportedException {
-
- debug("enterred endpointActivation");
- debug("leaving endpointActivation");
- }
-
- /* must implement for ResourceAdapter interface requirement */
- public void endpointDeactivation(MessageEndpointFactory ep,
- ActivationSpec spec) {
- debug("enterred endpointDeactivation");
- debug("leaving endpointDeactivation");
- }
-
- /* must implement for ResourceAdapter interface requirement */
- public XAResource[] getXAResources(ActivationSpec[] specs)
- throws ResourceException {
-
- debug("enterred getXAResources");
- debug("leaving getXAResources");
-
- throw new UnsupportedOperationException();
- }
-
- //
- // END ResourceAdapter interface requirements
- //
-
- /*
- * @name equals
- *
- * @desc compares this object with the given object.
- *
- * @param Object obj
- *
- * @return boolean
- */
- public boolean equals(Object obj) {
-
- if ((obj == null) || !(obj instanceof AnnotatedResourceAdapterImpl)) {
- return false;
- }
- if (obj == this) {
- return true;
- }
-
- AnnotatedResourceAdapterImpl that = (AnnotatedResourceAdapterImpl) obj;
-
- if (!Util.isEqual(this.serverSideUser, that.getServerSideUser()))
- return false;
-
- if (!Util.isEqual(this.serverSidePwd, that.getServerSidePwd()))
- return false;
-
- if (!Util.isEqual(this.eisUser, that.getEisUser()))
- return false;
-
- if (!Util.isEqual(this.eisPwd, that.getEisPwd()))
- return false;
-
- if (!Util.isEqual(this.raName, that.getRaName()))
- return false;
-
- return true;
- }
-
- /*
- * @name hashCode
- *
- * @desc gets the hashcode for this object.
- *
- * @return int
- */
- public int hashCode() {
- return this.getClass().getName().hashCode();
- }
-
- public void setRaName(String name) {
- this.raName = name;
-
- // this helps verify assertion Connector:SPEC:279
- String str = "setRAName called with raname=" + raName;
- ConnectorStatus.getConnectorStatus().logState(str);
- debug(str);
- }
-
- public String getRaName() {
- debug("AnnotatedResourceAdapterImpl.getRAName");
- return raName;
- }
-
- public void debug(String out) {
- Debug.trace("AnnotatedResourceAdapterImpl: " + out);
- }
-
- public void setServerSideUser(String val) {
- this.serverSideUser = val;
- }
-
- public String getServerSideUser() {
- return this.serverSideUser;
- }
-
- public void setServerSidePwd(String val) {
- this.serverSidePwd = val;
- }
-
- public String getServerSidePwd() {
- return this.serverSidePwd;
- }
-
- public void setEisUser(String val) {
- this.eisUser = val;
- }
-
- public String getEisUser() {
- return this.eisUser;
- }
-
- public void setEisPwd(String val) {
- this.eisUser = val;
- }
-
- public String getEisPwd() {
- return this.eisPwd;
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/annotated/NestedWorkXid1.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/annotated/NestedWorkXid1.java
deleted file mode 100644
index 5153ea8080..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/annotated/NestedWorkXid1.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (c) 2009, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.common.connector.whitebox.annotated;
-
-import javax.transaction.xa.Xid;
-
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-import com.sun.ts.tests.common.connector.whitebox.Debug;
-import com.sun.ts.tests.common.connector.whitebox.NestedWorkXid;
-
-import jakarta.resource.spi.work.ExecutionContext;
-import jakarta.resource.spi.work.TransactionContext;
-import jakarta.resource.spi.work.Work;
-import jakarta.resource.spi.work.WorkCompletedException;
-import jakarta.resource.spi.work.WorkException;
-import jakarta.resource.spi.work.WorkManager;
-import jakarta.resource.spi.work.WorkRejectedException;
-
-public class NestedWorkXid1 implements Work {
-
- public enum ContextType {
- EXECUTION_CONTEXT, TRANSACTION_CONTEXT, SECURITY_CONTEXT
- };
-
- private WorkManager wm;
-
- private Xid xid;
-
- private ContextType contxtType;
-
- public NestedWorkXid1(WorkManager wm, Xid xid, ContextType contxt) {
- this.wm = wm;
- this.xid = xid;
- this.contxtType = contxt;
-
- ConnectorStatus.getConnectorStatus().logAPI("NestedWorkXid1.constructor",
- "", "");
- Debug.trace("NestedWorkXid1.constructor");
- }
-
- public void release() {
- ConnectorStatus.getConnectorStatus().logAPI("NestedWorkXid1.release", "",
- "");
- Debug.trace("NestedWorkXid1.release");
- }
-
- public void run() {
- String strPass = "anno based NestedWorkXid1 child context submitted";
- try {
- Debug.trace("NestedWorkXid1.run");
- ConnectorStatus.getConnectorStatus().logAPI("NestedWorkXid1.run", "", "");
- Debug.trace("Got the xid");
- NestedWorkXid workid = new NestedWorkXid();
-
- if (contxtType == ContextType.TRANSACTION_CONTEXT) {
- Debug.trace("Using TRANSACTION_CONTEXT to set the xid in tc");
- TransactionContext tc = new TransactionContext();
- tc.setXid(this.xid);
- wm.doWork(workid, wm.INDEFINITE, tc, null);
- } else {
- // assume ExecutionContext - no need for SecurityContext yet
- Debug.trace("Using EXECUTION_CONTEXT to set the xid in ec");
- ExecutionContext ec = new ExecutionContext();
- ec.setXid(this.xid);
- wm.doWork(workid, wm.INDEFINITE, ec, null);
- }
-
- // flow could make it here or could throw WorkCompletedException
- Debug.trace(strPass);
- ConnectorStatus.getConnectorStatus().logState(strPass);
-
- } catch (WorkCompletedException we) {
- // could make it here upon successful completion of work
- Debug.trace(strPass);
- ConnectorStatus.getConnectorStatus().logState(strPass);
- } catch (WorkRejectedException we) {
- // should not make it here
- Debug.trace("WorkRejectedException in NestedWorkXid1");
- } catch (WorkException we) {
- // should not make it here
- Debug.trace("WorkException in NestedWorkXid1");
- } catch (Exception ex) {
- // should not make it here
- Debug.trace("Exception in NestedWorkXid1");
- }
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/ibanno/IBAnnoActivationSpecChild.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/ibanno/IBAnnoActivationSpecChild.java
deleted file mode 100644
index cc82c262d0..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/ibanno/IBAnnoActivationSpecChild.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (c) 2009, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.common.connector.whitebox.ibanno;
-
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-import com.sun.ts.tests.common.connector.whitebox.Debug;
-
-import jakarta.resource.spi.Activation;
-import jakarta.resource.spi.ActivationSpec;
-import jakarta.resource.spi.InvalidPropertyException;
-import jakarta.resource.spi.ResourceAdapter;
-import jakarta.resource.spi.ResourceAdapterAssociation;
-
-/*
- * This extends the parent class and MUST have a different listener than the parent.
- * This must inherit any configProperty annotations from parent.
- * This will implement ResourceAdaperAssociation as part of test for
- * Connector:SPEC:282. Since this implements ResourceAdaperAssociation, we should
- * see that the setResourceAdapter() class gets called.
- */
-@Activation(messageListeners = {
- com.sun.ts.tests.common.connector.util.TSMessageListenerInterface.class })
-public class IBAnnoActivationSpecChild extends IBAnnoActivationSpecParent
- implements ResourceAdapterAssociation, ActivationSpec {
-
- private String annoDestinationName;
-
- private String annoDestinationType;
-
- private ResourceAdapter resourceAdapter;
-
- /**
- * Default constructor.
- */
- public IBAnnoActivationSpecChild() {
- Debug.trace("IBAnnoActivationSpecChild.constructor");
- }
-
- public String getAnnoDestinationName() {
- Debug.trace("IBAnnoActivationSpecChild.getAnnoDestinationName :"
- + this.annoDestinationName);
- return this.annoDestinationName;
- }
-
- public void setAnnoDestinationName(String name) {
- this.annoDestinationName = name;
- Debug.trace("IBAnnoActivationSpecChild.setAnnoDestinationName :" + name);
- }
-
- public String getAnnoDestinationType() {
- Debug.trace("IBAnnoActivationSpecChild.getDestinationType :"
- + this.annoDestinationType);
- return this.annoDestinationType;
- }
-
- public void setAnnoDestinationType(String type) {
- Debug.trace("IBAnnoActivationSpecChild.setAnnoDestinationType :" + type);
- this.annoDestinationType = type;
- }
-
- public ResourceAdapter getResourceAdapter() {
- return this.resourceAdapter;
- }
-
- public void setResourceAdapter(ResourceAdapter ra) {
- String str = "IBAnnoActivationSpecChild.setResourceAdatper called";
- ConnectorStatus.getConnectorStatus().logState(str);
- Debug.trace(str);
- this.resourceAdapter = ra;
- }
-
- public void validate() throws InvalidPropertyException {
- Debug.trace("IBAnnoActivationSpecChild.validate called");
- }
-
- public void setPropName(String name) {
- propName = name;
- }
-
- public String getPropName() {
- return propName;
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/ibanno/IBAnnoActivationSpecParent.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/ibanno/IBAnnoActivationSpecParent.java
deleted file mode 100644
index cc361bc8d1..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/ibanno/IBAnnoActivationSpecParent.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (c) 2009, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.common.connector.whitebox.ibanno;
-
-import com.sun.ts.tests.common.connector.whitebox.Debug;
-
-import jakarta.resource.spi.Activation;
-import jakarta.resource.spi.ActivationSpec;
-import jakarta.resource.spi.ConfigProperty;
-import jakarta.resource.spi.InvalidPropertyException;
-import jakarta.resource.spi.ResourceAdapter;
-
-/*
- * This class shouldnt really be used for anything. This will be extended
- * by the child activation class and checks will be done to ensure that
- * proper annotation processing, inheritance, etc are occurring.
- * In this parent, we set a dummy listener of WorkListener, and in our
- * subclass, we will have a different, more speciif listener.
- *
- * Also, we expect that the ConfigProperty annotation in this parent
- * will/must be inherited by any child/sub classes.
- *
- */
-@Activation(messageListeners = { jakarta.resource.spi.work.WorkListener.class })
-public class IBAnnoActivationSpecParent
- implements ActivationSpec, java.io.Serializable {
-
- private String annoDestinationName;
-
- private String annoDestinationType;
-
- @ConfigProperty()
- protected String propName = "IBAnnoConfigPropVal";
-
- private ResourceAdapter resourceAdapter;
-
- /**
- * Default constructor.
- */
- public IBAnnoActivationSpecParent() {
- Debug.trace("IBAnnoActivationSpecParent.constructor");
- }
-
- public String getAnnoDestinationName() {
- Debug.trace("IBAnnoActivationSpecParent.getAnnoDestinationName :"
- + this.annoDestinationName);
- return this.annoDestinationName;
- }
-
- public void setAnnoDestinationName(String name) {
- this.annoDestinationName = name;
- Debug.trace("IBAnnoActivationSpecParent.setAnnoDestinationName :" + name);
- }
-
- public String getAnnoDestinationType() {
- Debug.trace("IBAnnoActivationSpecParent.getDestinationType :"
- + this.annoDestinationType);
- return this.annoDestinationType;
- }
-
- public void setAnnoDestinationType(String type) {
- Debug.trace("IBAnnoActivationSpecParent.setAnnoDestinationType :" + type);
- this.annoDestinationType = type;
- }
-
- public ResourceAdapter getResourceAdapter() {
- return this.resourceAdapter;
- }
-
- public void setResourceAdapter(ResourceAdapter ra) {
- Debug.trace("IBAnnoActivationSpecParent.setResourceAdatper called");
- this.resourceAdapter = ra;
- }
-
- public void validate() throws InvalidPropertyException {
- Debug.trace("IBAnnoActivationSpecParent.validate called");
- }
-
- public void setPropName(String name) {
- propName = name;
- }
-
- public String getPropName() {
- return propName;
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/ibanno/IBAnnoManagedConnectionFactory.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/ibanno/IBAnnoManagedConnectionFactory.java
deleted file mode 100644
index 36246be128..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/ibanno/IBAnnoManagedConnectionFactory.java
+++ /dev/null
@@ -1,519 +0,0 @@
-/*
- * Copyright (c) 2009, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.common.connector.whitebox.ibanno;
-
-import java.io.PrintWriter;
-import java.io.Serializable;
-import java.util.Iterator;
-import java.util.Set;
-
-import javax.security.auth.Subject;
-
-import com.sun.ts.lib.util.TSNamingContext;
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-import com.sun.ts.tests.common.connector.whitebox.Debug;
-import com.sun.ts.tests.common.connector.whitebox.TSConnection;
-import com.sun.ts.tests.common.connector.whitebox.TSConnectionImpl;
-import com.sun.ts.tests.common.connector.whitebox.TSEISDataSource;
-import com.sun.ts.tests.common.connector.whitebox.TSManagedConnection;
-import com.sun.ts.tests.common.connector.whitebox.Util;
-
-import jakarta.resource.ResourceException;
-import jakarta.resource.spi.ConfigProperty;
-import jakarta.resource.spi.ConnectionDefinition;
-import jakarta.resource.spi.ConnectionDefinitions;
-import jakarta.resource.spi.ConnectionManager;
-import jakarta.resource.spi.ConnectionRequestInfo;
-import jakarta.resource.spi.EISSystemException;
-import jakarta.resource.spi.ManagedConnection;
-import jakarta.resource.spi.ManagedConnectionFactory;
-import jakarta.resource.spi.ManagedConnectionMetaData;
-import jakarta.resource.spi.ResourceAdapter;
-import jakarta.resource.spi.ResourceAdapterAssociation;
-import jakarta.resource.spi.security.PasswordCredential;
-
-@ConnectionDefinitions({
- @ConnectionDefinition(connectionFactory = com.sun.ts.tests.common.connector.whitebox.TSConnectionFactory.class, connectionFactoryImpl = com.sun.ts.tests.common.connector.whitebox.TSEISDataSource.class, connection = com.sun.ts.tests.common.connector.whitebox.TSConnection.class, connectionImpl = com.sun.ts.tests.common.connector.whitebox.TSEISConnection.class) })
-public class IBAnnoManagedConnectionFactory implements ManagedConnectionFactory,
- ResourceAdapterAssociation, jakarta.resource.Referenceable, Serializable {
- private javax.naming.Reference reference;
-
- private ResourceAdapter resourceAdapter;
-
- private int count;
-
- private String TSRValue;
-
- private String password;
-
- private String user;
-
- private String userName;
-
- private String setterMethodVal = "DEFAULT";
-
- @ConfigProperty(defaultValue = "10", type = Integer.class, description = "Integer value", ignore = false)
- private Integer integer;
-
- @ConfigProperty()
- private String factoryName = "IBAnnoManagedConnectionFactory";
-
- /*
- * @name IBAnnoManagedConnectionFactory
- *
- * @desc Default conctructor
- */
- public IBAnnoManagedConnectionFactory() {
-
- // this helps verify assertion Connector:SPEC:279 and Connector:SPEC:277
- String str = "IBAnnoManagedConnectionFactory factoryName=" + factoryName;
- debug(str);
-
- // lets make sure we can call and set setSetterMethodVal()
- setSetterMethodVal("NONDEFAULT");
-
- debug(str);
- }
-
- /*
- * used to help test assertion Connector:SPEC:278
- */
- @ConfigProperty()
- public void setSetterMethodVal(String val) {
- setterMethodVal = val;
- String str = "AnnotatedResourceAdapterImpl.setSetterMethodVal="
- + setterMethodVal;
- ConnectorStatus.getConnectorStatus().logState(str);
- }
-
- public String getSetterMethodVal() {
- return setterMethodVal;
- }
-
- public void setFactoryName(String name) {
- debug("IBAnnoManagedConnectionFactory.setFactoryName");
- this.factoryName = name;
- }
-
- public String getFactoryName() {
- debug("IBAnnoManagedConnectionFactory.getFactoryName");
- return factoryName;
- }
-
- public Integer getInteger() {
- return this.integer;
- }
-
- public void setInteger(Integer val) {
- this.integer = val;
- }
-
- public String getUser() {
- debug("IBAnnoManagedConnectionFactory.getUser() returning: " + user);
- return user;
- }
-
- public void setUser(String val) {
- debug("IBAnnoManagedConnectionFactory.setUser() with val = " + val);
- user = val;
- }
-
- public String getUserName() {
- debug(
- "IBAnnoManagedConnectionFactory.getUserName() returning: " + userName);
- return userName;
- }
-
- public void setUserName(String val) {
- debug("IBAnnoManagedConnectionFactory.setUserName() with val = " + val);
- userName = val;
- }
-
- public String getPassword() {
- debug(
- "IBAnnoManagedConnectionFactory.getPassword() returning: " + password);
- return password;
- }
-
- public void setPassword(String val) {
- debug("IBAnnoManagedConnectionFactory.setPassword() with val = " + val);
- password = val;
- }
-
- public String getTSRValue() {
- debug("IBAnnoManagedConnectionFactory getTSRValue called" + TSRValue);
- return TSRValue;
- }
-
- public void setTSRValue(String name) {
- debug("IBAnnoManagedConnectionFactory.setTSRValue called with: " + name);
- this.TSRValue = name;
- }
-
- public void lookupTSR(String lookup) {
- debug("IBAnnoManagedConnectionFactory.lookupTSR");
- try {
- TSNamingContext ncxt = new TSNamingContext();
- String newStr = "java:".concat(lookup);
- Object obj = (Object) ncxt.lookup(newStr);
- if (obj != null) {
- debug("TSR Lookup Successful");
- } else {
- debug("TSR Null");
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- /*
- * @name createConnectionFactory
- *
- * @desc Creates a new connection factory instance
- *
- * @param ConnectionManager
- *
- * @return Object
- *
- * @exception ResourceException
- */
- public Object createConnectionFactory(ConnectionManager cxManager)
- throws ResourceException {
- ConnectorStatus.getConnectorStatus().logAPI(
- "IBAnnoManagedConnectionFactory.createConnectionFactory", "cxManager",
- "TSEISDataSource");
- return new TSEISDataSource(this, cxManager);
- }
-
- /*
- * @name createConnectionFactory
- *
- * @desc Creates a new connection factory instance
- *
- * @return Object
- *
- * @exception ResourceException
- */
- public Object createConnectionFactory() throws ResourceException {
- ConnectorStatus.getConnectorStatus().logAPI(
- "IBAnnoManagedConnectionFactory.createConnectionFactory", "",
- "TSEISDataSource");
- return new TSEISDataSource(this, null);
- }
-
- /*
- * @name setResourceAdapter
- *
- * @desc sets the Resource Adapter for this ManagedConnectionFactory
- *
- * @return
- *
- * @exception ResourceException
- */
- public void setResourceAdapter(ResourceAdapter ra) throws ResourceException {
- count++;
- String newStr1 = "IBAnnoManagedConnectionFactory setResourceAdapter "
- + count;
- debug(newStr1);
- this.resourceAdapter = ra;
- }
-
- /*
- * @name getResourceAdapter
- *
- * @desc gets the Resource Adapter for this ManagedConnectionFactory
- *
- * @return Object
- *
- * @exception ResourceException
- */
- public ResourceAdapter getResourceAdapter() {
- debug("IBAnnoManagedConnectionFactory.getResource");
- return resourceAdapter;
- }
-
- /*
- * @name createManagedConnection
- *
- * @desc Creates a new managed connection to the underlying EIS
- *
- * @param Subject, ConnectionRequestInfo
- *
- * @return ManagedConnection
- *
- * @exception ResourceException
- */
- public ManagedConnection createManagedConnection(Subject subject,
- ConnectionRequestInfo info) throws ResourceException {
-
- try {
-
- ConnectorStatus.getConnectorStatus().logAPI(
- "IBAnnoManagedConnectionFactory.createManagedConnection",
- "subject|info", "TSManagedConnection");
- TSConnection con = null;
- PasswordCredential pc = Util.getPasswordCredential(this, subject, info);
- if (pc == null) {
- debug(
- "IBAnnoManagedConnectionFactory.createManagedConnection(): pc == null");
- debug("TSConnectionImpl.getConnection()");
- con = new TSConnectionImpl().getConnection();
- } else {
- debug(
- "IBAnnoManagedConnectionFactory.createManagedConnection(): pc != null");
- setUser(pc.getUserName());
- setUserName(pc.getUserName());
- setPassword(new String(pc.getPassword()));
- debug("TSConnectionImpl.getConnection(u,p)");
- con = new TSConnectionImpl().getConnection(pc.getUserName(),
- pc.getPassword());
- }
-
- ManagedConnection mcon = new TSManagedConnection(this, pc, null, con,
- false, true);
- dumpConnectionMetaData(mcon);
-
- return mcon;
- } catch (Exception ex) {
- ResourceException re = new EISSystemException(
- "Exception: " + ex.getMessage());
- re.initCause(ex);
- throw re;
- }
-
- }
-
- public void dumpConnectionMetaData(ManagedConnection mcon) {
-
- String hdr = "IBAnnoManagedConnectionFactory: ";
- String out;
- boolean bLocal = false;
- boolean bXA = false;
-
- try {
- ManagedConnectionMetaData mdata = mcon.getMetaData();
-
- out = hdr + "displayName=" + mdata.getEISProductName();
- debug(out);
-
- out = hdr + "version=" + mdata.getEISProductVersion();
- debug(out);
-
- // get transaction type
- try {
- mcon.getLocalTransaction();
- bLocal = true;
- } catch (ResourceException ex) {
- System.out.println(hdr + "not a localTransaction type");
- }
- try {
- mcon.getXAResource();
- bXA = true;
- } catch (ResourceException ex) {
- System.out.println(hdr + "not a XAResource type");
- }
-
- out = hdr + "transactionSupport=";
- if (bLocal) {
- out = out + "LocalTransaction";
- } else if (bXA) {
- out = out + "XATransaction";
- } else {
- // assume default case of noTx
- out = out + "NoTransaction";
- }
- debug(out);
- } catch (ResourceException ex) {
- System.out.println(ex.getMessage());
- ex.printStackTrace();
- }
- }
-
- /*
- * @name matchManagedConnection
- *
- * @desc Return the existing connection from the connection pool
- *
- * @param Set, Subject, ConnectionRequestInfo
- *
- * @return ManagedConnection
- *
- * @exception ResourceException
- */
- public ManagedConnection matchManagedConnections(Set connectionSet,
- Subject subject, ConnectionRequestInfo info) throws ResourceException {
- ConnectorStatus.getConnectorStatus().logAPI(
- "IBAnnoManagedConnectionFactory.matchManagedConnection",
- "connectionSet|subject|info", "TSEISDataSource");
-
- PasswordCredential pc = Util.getPasswordCredential(this, subject, info);
- Iterator it = connectionSet.iterator();
-
- while (it.hasNext()) {
- Object obj = it.next();
- if (obj instanceof TSManagedConnection) {
- TSManagedConnection mc = (TSManagedConnection) obj;
- ManagedConnectionFactory mcf = mc.getManagedConnectionFactory();
- if (Util.isPasswordCredentialEqual(mc.getPasswordCredential(), pc)
- && (mcf != null) && mcf.equals(this)) {
- return mc;
- }
- }
- }
-
- System.out.println("matchManagedConnections: couldnt find match");
- return null;
- }
-
- /*
- * @name setLogWriter
- *
- * @desc Sets the Print Writer
- *
- * @param PrintWriter
- *
- * @exception ResourceException
- */
- public void setLogWriter(PrintWriter out) throws ResourceException {
- }
-
- /*
- * @name getLogWriter
- *
- * @desc Gets the Print Writer
- *
- * @return PrintWriter
- *
- * @exception ResourceException
- */
- public PrintWriter getLogWriter() throws ResourceException {
- return null;
- }
-
- /*
- * @name equals
- *
- * @desc Compares the given object to the ManagedConnectionFactory instance.
- *
- * @param Object
- *
- * @return boolean
- */
- public boolean equals(Object obj) {
- if ((obj == null) || !(obj instanceof IBAnnoManagedConnectionFactory)) {
- return false;
- }
- if (obj == this) {
- return true;
- }
-
- IBAnnoManagedConnectionFactory that = (IBAnnoManagedConnectionFactory) obj;
-
- if ((this.reference != null)
- && !(this.reference.equals(that.getReference()))) {
- return false;
- } else if ((this.reference == null) && !(that.getReference() == null)) {
- return false;
- }
-
- if ((this.resourceAdapter != null)
- && !(this.resourceAdapter.equals(that.getResourceAdapter()))) {
- return false;
- } else if ((this.resourceAdapter == null)
- && !(that.getResourceAdapter() == null)) {
- return false;
- }
-
- if (this.count != that.getCount()) {
- return false;
- }
-
- if ((this.integer != null) && (!this.integer.equals(that.getInteger()))) {
- return false;
- } else if ((this.integer == null) && !(that.getInteger() == null)) {
- return false;
- }
-
- if (!Util.isEqual(this.password, that.getPassword()))
- return false;
-
- if (!Util.isEqual(this.user, that.getUser()))
- return false;
-
- if (!Util.isEqual(this.userName, that.getUserName()))
- return false;
-
- if (!Util.isEqual(this.TSRValue, that.getTSRValue()))
- return false;
-
- if (!Util.isEqual(this.setterMethodVal, that.getSetterMethodVal()))
- return false;
-
- if (!Util.isEqual(this.factoryName, that.getFactoryName()))
- return false;
-
- return true;
- }
-
- /*
- * @name hashCode
- *
- * @desc Gives a hash value to a ManagedConnectionFactory Obejct.
- *
- * @return int
- */
- public int hashCode() {
- return this.getClass().getName().hashCode();
- }
-
- /*
- * @name getReference
- *
- * @desc Gives the reference of the class
- *
- * @return javax.naming.Reference
- */
- public javax.naming.Reference getReference() {
- javax.naming.Reference ref;
-
- ref = this.reference;
- return ref;
- }
-
- /*
- * @name setReference
- *
- * @desc sets the reference of the class
- *
- * @param javax.naming.Reference
- */
- public void setReference(javax.naming.Reference ref) {
- this.reference = ref;
- }
-
- public void debug(String out) {
- Debug.trace("IBAnnoManagedConnectionFactory: " + out);
- }
-
- public int getCount() {
- return this.count;
- }
-
- public void setCount(int val) {
- this.count = val;
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/ibanno/IBAnnoMessageListener.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/ibanno/IBAnnoMessageListener.java
deleted file mode 100644
index 2b4c6e8598..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/ibanno/IBAnnoMessageListener.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (c) 2009, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.common.connector.whitebox.ibanno;
-
-import javax.transaction.xa.XAException;
-
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-import com.sun.ts.tests.common.connector.whitebox.Debug;
-import com.sun.ts.tests.common.connector.whitebox.XidImpl;
-
-import jakarta.resource.spi.BootstrapContext;
-import jakarta.resource.spi.XATerminator;
-import jakarta.resource.spi.work.WorkEvent;
-import jakarta.resource.spi.work.WorkListener;
-
-public class IBAnnoMessageListener implements WorkListener {
-
- private XidImpl xid;
-
- private BootstrapContext bsc;
-
- public IBAnnoMessageListener(XidImpl xid, BootstrapContext bsc) {
- this.xid = xid;
- this.bsc = bsc;
- }
-
- public void workAccepted(WorkEvent e) {
- ConnectorStatus.getConnectorStatus()
- .logState("IBAnnoMessageListener.workAccepted");
- if (xid != null) {
- System.out.println("IBAnnoMessageListener.workAccepted() for XID = "
- + xid.getFormatId());
- } else {
- // should not get here but just in case...
- System.out.println("IBAnnoMessageListener.workAccepted() for XID = null");
- }
- }
-
- public void workRejected(WorkEvent e) {
- ConnectorStatus.getConnectorStatus()
- .logState("IBAnnoMessageListener.workRejected");
- if (xid != null) {
- System.out.println("IBAnnoMessageListener.workRejected() for XID = "
- + xid.getFormatId());
- } else {
- // should not get here but just in case...
- System.out.println("IBAnnoMessageListener.workRejected() for XID = null");
- }
- }
-
- public void workStarted(WorkEvent e) {
- ConnectorStatus.getConnectorStatus()
- .logState("IBAnnoMessageListener.workStarted");
- System.out.println("IBAnnoMessageListener.workStarted");
- }
-
- public void workCompleted(WorkEvent e) {
- try {
- XATerminator xt = bsc.getXATerminator();
- System.out.println(
- "IBAnnoMessageListener.workCompleted and about to call XATerminator.commit()");
- System.out.println(
- "XID getting used in XATerminator [ " + xid.getFormatId() + " ]");
- xt.commit(this.xid, true);
- ConnectorStatus.getConnectorStatus()
- .logState("IBAnnoMessageListener committed Xid");
- } catch (XAException ex) {
- Debug.trace("IBAnnoMessageListener.workCompleted() got XAException");
- Debug.trace("XAException.toString() = " + ex.toString());
- ex.printStackTrace();
- }
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/ibanno/IBAnnoMessageWork.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/ibanno/IBAnnoMessageWork.java
deleted file mode 100644
index 3e953065e5..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/ibanno/IBAnnoMessageWork.java
+++ /dev/null
@@ -1,238 +0,0 @@
-/*
- * Copyright (c) 2009, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.common.connector.whitebox.ibanno;
-
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
-
-import com.sun.ts.tests.common.connector.util.AppException;
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-import com.sun.ts.tests.common.connector.util.TSMessageListenerInterface;
-import com.sun.ts.tests.common.connector.whitebox.Debug;
-import com.sun.ts.tests.common.connector.whitebox.XAMessageXAResource;
-
-import jakarta.resource.ResourceException;
-import jakarta.resource.spi.UnavailableException;
-import jakarta.resource.spi.endpoint.MessageEndpoint;
-import jakarta.resource.spi.endpoint.MessageEndpointFactory;
-import jakarta.resource.spi.work.Work;
-import jakarta.resource.spi.work.WorkContext;
-import jakarta.resource.spi.work.WorkContextProvider;
-
-public class IBAnnoMessageWork implements Work, WorkContextProvider {
-
- private String name;
-
- private boolean stop = false;
-
- private MessageEndpointFactory factory;
-
- private XAMessageXAResource msgxa = new XAMessageXAResource();
-
- private MessageEndpoint ep2;
-
- private List contextsList = new ArrayList();
-
- public IBAnnoMessageWork(String name, MessageEndpointFactory factory) {
- this.factory = factory;
- this.name = name;
-
- Debug.trace("IBAnnoMessageWork constructor");
- }
-
- public void run() {
-
- while (!stop) {
- try {
-
- // Createing ep and ep1 for comparison
- MessageEndpoint ep1 = factory.createEndpoint(null);
- ep2 = factory.createEndpoint(null);
-
- // creating xaep to check if the message delivery is transacted.
- MessageEndpoint xaep = factory.createEndpoint(msgxa);
-
- if (!ep2.equals(ep1)) {
- Debug.trace("IBAnnoMessageWork XA Unique MessageEndpoint returned");
- }
-
- chkMessageEndpointImpl(ep1);
-
- Method onMessage = getOnMessageMethod();
- ep1.beforeDelivery(onMessage);
- ((TSMessageListenerInterface) ep1)
- .onMessage("IBAnnoMessageWork XA Message To MDB");
- ep1.afterDelivery();
-
- Method onMessagexa = getOnMessageMethod();
- xaep.beforeDelivery(onMessagexa);
- ((TSMessageListenerInterface) xaep)
- .onMessage("IBAnnoMessageWork XA Non Transacted Message To MDB1");
- xaep.afterDelivery();
-
- boolean de = factory.isDeliveryTransacted(onMessagexa);
-
- callSysExp();
- callAppExp();
-
- if (!de) {
- Debug.trace("IBAnnoMessageWork XA MDB1 delivery is not transacted");
- } else {
- Debug.trace("IBAnnoMessageWork XA MDB1 delivery is transacted");
- }
-
- break;
-
- } catch (AppException ex) {
- ex.printStackTrace();
-
- } catch (UnavailableException ex) {
- try {
- Thread.currentThread().sleep(3000);
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- } catch (NoSuchMethodException ns) {
- ns.printStackTrace();
-
- } catch (ResourceException re) {
- re.printStackTrace();
- }
- }
-
- }
-
- public void callSysExp() {
-
- try {
- Debug.trace(" in IBAnnoMessageWork.callSysExp()");
- Method onMessage = getOnMessageMethod();
- ep2.beforeDelivery(onMessage);
- ((TSMessageListenerInterface) ep2)
- .onMessage("Throw SysException from IBAnnoMessageWork");
-
- } catch (NoSuchMethodException e) {
- System.out.println("IBAnnoMessageWork: NoSuchMethodException");
- e.getMessage();
- e.printStackTrace();
- } catch (UnavailableException e) {
- System.out.println("IBAnnoMessageWork: UnavailableException");
- e.printStackTrace();
- } catch (ResourceException re) {
- System.out.println("IBAnnoMessageWork: ResourceException");
- re.printStackTrace();
- } catch (AppException ae) {
- System.out.println("IBAnnoMessageWork: AppException");
- ae.printStackTrace();
- } catch (Exception e) {
- // if we are in here, we will assume that our exception was of type ejb
- // but we
- // should not code only to ejb as the messaging could be POJO's and not
- // ejb....
- System.out.println("EJBException thrown by NotSupported MDB");
- ConnectorStatus.getConnectorStatus()
- .logState("EJBException thrown by NotSupported");
- e.printStackTrace();
- } finally {
- try {
- // this ensures that before and
- // after delivery calls are properly matched.
- ep2.afterDelivery();
- } catch (ResourceException re2) {
- re2.printStackTrace();
- }
- }
- }
-
- public void callAppExp() {
-
- try {
- Debug.trace(" in IBAnnoMessageWork.callAppExp()");
- Method onMessage = getOnMessageMethod();
- ep2.beforeDelivery(onMessage);
- ((TSMessageListenerInterface) ep2)
- .onMessage("Throw AppException from IBAnnoMessageWork");
-
- } catch (AppException ejbe) {
- System.out.println("AppException thrown by NotSupported MDB");
- ConnectorStatus.getConnectorStatus()
- .logState("AppException thrown by NotSupported");
-
- } catch (NoSuchMethodException ns) {
- ns.printStackTrace();
-
- } catch (ResourceException re) {
- re.printStackTrace();
-
- } finally {
- try {
- // this ensures that before and
- // after delivery calls are properly matched.
- ep2.afterDelivery();
- } catch (ResourceException re2) {
- re2.printStackTrace();
- }
- }
- }
-
- public Method getOnMessageMethod() {
-
- Method onMessageMethod = null;
- try {
- Class msgListenerClass = TSMessageListenerInterface.class;
- Class[] paramTypes = { java.lang.String.class };
- onMessageMethod = msgListenerClass.getMethod("onMessage", paramTypes);
- } catch (NoSuchMethodException ex) {
- ex.printStackTrace();
- }
- return onMessageMethod;
- }
-
- private void chkMessageEndpointImpl(MessageEndpoint ep) {
- if ((ep instanceof MessageEndpoint)
- && (ep instanceof TSMessageListenerInterface)) {
- Debug.trace("IBANNO XA MessageEndpoint interface implemented");
- Debug.trace("IBANNO XA TSMessageListener interface implemented");
- } else {
- Debug.trace(
- "IBANNO XA MessageEndpoint and TSMessageListenerInterface not implemented");
- }
-
- }
-
- public List getWorkContexts() {
- return contextsList;
- }
-
- public void addWorkContext(WorkContext ic) {
- contextsList.add(ic);
- }
-
- public void release() {
- }
-
- public void stop() {
- this.stop = true;
- }
-
- public String toString() {
- return name;
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/ibanno/IBAnnoMessageWork1.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/ibanno/IBAnnoMessageWork1.java
deleted file mode 100644
index 6dae6708db..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/ibanno/IBAnnoMessageWork1.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * Copyright (c) 2009, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.common.connector.whitebox.ibanno;
-
-import java.lang.reflect.Method;
-
-import com.sun.ts.tests.common.connector.util.AppException;
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-import com.sun.ts.tests.common.connector.util.TSMessageListenerInterface;
-import com.sun.ts.tests.common.connector.whitebox.Debug;
-
-import jakarta.resource.ResourceException;
-import jakarta.resource.spi.UnavailableException;
-import jakarta.resource.spi.endpoint.MessageEndpoint;
-import jakarta.resource.spi.endpoint.MessageEndpointFactory;
-import jakarta.resource.spi.work.Work;
-
-public class IBAnnoMessageWork1 implements Work {
-
- private String name;
-
- private boolean stop = false;
-
- private MessageEndpointFactory factory;
-
- private IBAnnoMessageXAResource1 msgxa = new IBAnnoMessageXAResource1();
-
- private MessageEndpoint xaep;
-
- private MessageEndpoint ep2;
-
- public IBAnnoMessageWork1(String name, MessageEndpointFactory factory) {
- this.factory = factory;
- this.name = name;
- System.out.println("IBAnnoMessageWork1.constructor");
- }
-
- public void run() {
-
- while (!stop) {
- try {
- System.out.println("Inside the IBAnnoMessageWork1 run ");
- // creating xaep to check if the message delivery is transacted.
- xaep = factory.createEndpoint(msgxa);
-
- ep2 = factory.createEndpoint(null);
-
- Method onMessagexa = getOnMessageMethod();
- xaep.beforeDelivery(onMessagexa);
- ((TSMessageListenerInterface) xaep)
- .onMessage("IBAnno MDB2 Transacted Message To MDB");
- xaep.afterDelivery();
- Debug.trace("IBAnno MDB2 Transacted Message To MDB");
-
- callSysExp();
- callAppExp();
-
- boolean de = factory.isDeliveryTransacted(onMessagexa);
-
- if (de) {
- Debug.trace("IBAnno MDB2 delivery is transacted");
- }
- break;
- } catch (AppException ex) {
- ex.printStackTrace();
- }
-
- catch (NoSuchMethodException e) {
- e.printStackTrace();
- }
-
- catch (UnavailableException ex) {
- try {
- Thread.currentThread().sleep(3000);
- } catch (Exception e) {
- e.printStackTrace();
- }
- } catch (ResourceException re) {
- re.printStackTrace();
- }
-
- }
-
- }
-
- public void callSysExp() {
-
- try {
- Method onMessage = getOnMessageMethod();
- ep2.beforeDelivery(onMessage);
- ((TSMessageListenerInterface) ep2)
- .onMessage("Throw IBAnnoSysException from Required");
- // this has been moved to finally clause to ensure that before and
- // after delivery calls are properly matched.
- // ep2.afterDelivery();
- } catch (NoSuchMethodException e) {
- System.out.println("IBAnnoMessageWork1: NoSuchMethodException");
- e.getMessage();
- e.printStackTrace();
- } catch (UnavailableException e) {
- System.out.println("IBAnnoMessageWork1: UnavailableException");
- e.printStackTrace();
- } catch (ResourceException re) {
- System.out.println("IBAnnoMessageWork1: ResourceException");
- re.printStackTrace();
- } catch (AppException ae) {
- System.out.println("IBAnnoMessageWork1: AppException");
- ae.printStackTrace();
- } catch (Exception e) {
- // if we are in here, we will assume that our exception was of type ejb
- // but it
- // could also be from a non-ejb POJO - thus we use this Exception type.
- Debug.trace("IBAnnoEJBException thrown but Required");
- } finally {
- try {
- ep2.afterDelivery();
- } catch (ResourceException re2) {
- re2.printStackTrace();
- }
- }
-
- }
-
- public void callAppExp() {
-
- try {
- Method onMessage = getOnMessageMethod();
- ep2.beforeDelivery(onMessage);
- ((TSMessageListenerInterface) ep2)
- .onMessage("Throw IBAnnoAppException from Required");
- // this has been moved to finally clause to ensure that before and
- // after delivery calls are properly matched.
- // ep2.afterDelivery();
- } catch (AppException ejbe) {
- System.out.println("AppException thrown by Required MDB");
- ConnectorStatus.getConnectorStatus()
- .logState("AppException thrown by Required");
- } catch (NoSuchMethodException ns) {
- ns.printStackTrace();
- } catch (ResourceException re) {
- re.printStackTrace();
- } finally {
- try {
- ep2.afterDelivery();
- } catch (ResourceException re2) {
- re2.printStackTrace();
- }
- }
-
- }
-
- public Method getOnMessageMethod() {
-
- Method onMessageMethod = null;
- try {
- Class msgListenerClass = TSMessageListenerInterface.class;
- Class[] paramTypes = { java.lang.String.class };
- onMessageMethod = msgListenerClass.getMethod("onMessage", paramTypes);
-
- } catch (NoSuchMethodException ex) {
- ex.printStackTrace();
- }
- return onMessageMethod;
- }
-
- public void release() {
- }
-
- public void stop() {
- this.stop = true;
- }
-
- public String toString() {
- return name;
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/ibanno/IBAnnoMessageWork2.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/ibanno/IBAnnoMessageWork2.java
deleted file mode 100644
index 5fe625bc20..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/ibanno/IBAnnoMessageWork2.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (c) 2009, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.common.connector.whitebox.ibanno;
-
-import java.lang.reflect.Method;
-
-import com.sun.ts.tests.common.connector.util.AppException;
-import com.sun.ts.tests.common.connector.util.TSMessageListenerInterface;
-import com.sun.ts.tests.common.connector.whitebox.Debug;
-import com.sun.ts.tests.common.connector.whitebox.LocalTxMessageXAResource;
-
-import jakarta.resource.spi.UnavailableException;
-import jakarta.resource.spi.endpoint.MessageEndpoint;
-import jakarta.resource.spi.endpoint.MessageEndpointFactory;
-import jakarta.resource.spi.work.Work;
-
-public class IBAnnoMessageWork2 implements Work {
-
- private String name;
-
- private boolean stop = false;
-
- private MessageEndpointFactory factory;
-
- private LocalTxMessageXAResource msgxa = new LocalTxMessageXAResource(
- "LocalTxMessageXAResource2");
-
- public IBAnnoMessageWork2(String name, MessageEndpointFactory factory) {
- this.factory = factory;
- this.name = name;
- System.out.println("IBAnnoMessageWork2.constructor");
- }
-
- public void run() {
-
- while (!stop) {
- try {
-
- // creating xaep to check if the message delivery is transacted.
- MessageEndpoint xaep = factory.createEndpoint(msgxa);
- MessageEndpoint xaep1 = factory.createEndpoint(msgxa);
- MessageEndpoint xaep2 = factory.createEndpoint(msgxa);
-
- Method onMessagexa = getOnMessageMethod();
- ((TSMessageListenerInterface) xaep)
- .onMessage("IBAnnoMessageWork2 MDB2 Transacted Message1");
- ((TSMessageListenerInterface) xaep1)
- .onMessage("IBAnnoMessageWork2 MDB2 Transacted Message2");
- ((TSMessageListenerInterface) xaep2)
- .onMessage("IBAnnoMessageWork2 MDB2 Transacted Message3");
-
- Debug.trace("IBAnnoMessageWork2 MDB2 Transacted Message1");
- Debug.trace("IBAnnoMessageWork2 MDB2 Transacted Message2");
- Debug.trace("IBAnnoMessageWork2 MDB2 Transacted Message3");
-
- break;
- } catch (AppException ex) {
- ex.printStackTrace();
- } catch (UnavailableException ex) {
- try {
- Thread.currentThread().sleep(3000);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
-
- }
-
- public Method getOnMessageMethod() {
-
- Method onMessageMethod = null;
- try {
- Class msgListenerClass = TSMessageListenerInterface.class;
- Class[] paramTypes = { java.lang.String.class };
- onMessageMethod = msgListenerClass.getMethod("onMessage", paramTypes);
-
- } catch (NoSuchMethodException ex) {
- ex.printStackTrace();
- }
- return onMessageMethod;
- }
-
- public void release() {
- }
-
- public void stop() {
- this.stop = true;
- }
-
- public String toString() {
- return name;
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/ibanno/IBAnnoMessageXAResource1.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/ibanno/IBAnnoMessageXAResource1.java
deleted file mode 100644
index 5c063f14a9..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/ibanno/IBAnnoMessageXAResource1.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright (c) 2009, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.common.connector.whitebox.ibanno;
-
-import javax.transaction.xa.XAException;
-import javax.transaction.xa.XAResource;
-import javax.transaction.xa.Xid;
-
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-import com.sun.ts.tests.common.connector.whitebox.Debug;
-
-public class IBAnnoMessageXAResource1 implements XAResource {
-
- public IBAnnoMessageXAResource1() {
- Debug.trace("IBAnnoMessageXAResource1 constructor");
- }
-
- private void handleResourceException(Exception ex) throws XAException {
-
- XAException xae = new XAException(ex.toString());
- xae.errorCode = XAException.XAER_RMERR;
- throw xae;
- }
-
- public void commit(Xid xid, boolean onePhase) throws XAException {
- try {
- Debug.trace("IBAnnoMessageXAResource1.commit");
- } catch (Exception ex) {
- handleResourceException(ex);
- }
- }
-
- public void start(Xid xid, int flags) throws XAException {
- try {
- Debug.trace("IBAnnoMessageXAResource1.start");
- } catch (Exception ex) {
- handleResourceException(ex);
- }
- }
-
- public void end(Xid xid, int flags) throws XAException {
- try {
- Debug.trace("IBAnnoMessageXAResource1.end");
- } catch (Exception ex) {
- handleResourceException(ex);
- }
- }
-
- public void forget(Xid xid) throws XAException {
- Debug.trace("IBAnnoMessageXAResource1.forget");
- }
-
- public int getTransactionTimeout() throws XAException {
- return 1;
- }
-
- public boolean isSameRM(XAResource other) throws XAException {
- Debug.trace("IBAnnoMessageXAResource1.isSameRM");
- return false;
- }
-
- public int prepare(Xid xid) throws XAException {
- ConnectorStatus.getConnectorStatus()
- .logAPI("IBAnnoMessageXAResource1.prepare", "", "");
- Debug.trace("IBAnnoMessageXAResource1.prepare");
- try {
- return XAResource.XA_OK;
- } catch (Exception ex) {
- handleResourceException(ex);
- return XAException.XAER_RMERR;
- }
- }
-
- public Xid[] recover(int flag) throws XAException {
- Debug.trace("IBAnnoMessageXAResource1.recover");
- return null;
- }
-
- public void rollback(Xid xid) throws XAException {
- try {
- Debug.trace("IBAnnoMessageXAResource1.rollback");
- } catch (Exception ex) {
- handleResourceException(ex);
- }
- }
-
- public boolean setTransactionTimeout(int seconds) throws XAException {
- return true;
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/ibanno/IBAnnoWorkManager.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/ibanno/IBAnnoWorkManager.java
deleted file mode 100644
index 37b1e1acb1..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/ibanno/IBAnnoWorkManager.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright (c) 2009, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.common.connector.whitebox.ibanno;
-
-import javax.transaction.xa.Xid;
-
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-import com.sun.ts.tests.common.connector.whitebox.Debug;
-import com.sun.ts.tests.common.connector.whitebox.WorkImpl;
-import com.sun.ts.tests.common.connector.whitebox.WorkListenerImpl;
-import com.sun.ts.tests.common.connector.whitebox.XidImpl;
-
-import jakarta.resource.spi.BootstrapContext;
-import jakarta.resource.spi.work.ExecutionContext;
-import jakarta.resource.spi.work.TransactionContext;
-import jakarta.resource.spi.work.WorkException;
-import jakarta.resource.spi.work.WorkManager;
-
-public class IBAnnoWorkManager {
- private BootstrapContext bsc = null;
-
- private WorkManager wmgr;
-
- private Xid myxid;
-
- private Xid mynestxid;
-
- public IBAnnoWorkManager(BootstrapContext val) {
- debug("enterred constructor");
- this.bsc = val;
- this.wmgr = bsc.getWorkManager();
-
- debug("leaving constructor");
- }
-
- public void runTests() {
- debug("enterred runTests");
- doWork();
- doTCWork();
- debug("leaving runTests");
- }
-
- public void doWork() {
- debug("enterred doWork");
-
- try {
- WorkImpl workimpl = new WorkImpl(wmgr);
-
- ExecutionContext ec = new ExecutionContext();
- WorkListenerImpl wl = new WorkListenerImpl();
- wmgr.doWork(workimpl, 5000, ec, wl);
- ConnectorStatus.getConnectorStatus()
- .logState("IBAnnoWorkManager Work Object Submitted");
- debug("IBAnnoWorkManager Work Object Submitted");
- } catch (WorkException we) {
- System.out.println(
- "IBAnnoWorkManager WorkException thrown is " + we.getMessage());
- } catch (Exception ex) {
- System.out
- .println("IBAnnoWorkManager Exception thrown is " + ex.getMessage());
- }
-
- debug("leaving doWork");
- }
-
- private TransactionContext startTx() {
- TransactionContext tc = new TransactionContext();
- try {
- Xid xid = new XidImpl();
- tc.setXid(xid);
- tc.setTransactionTimeout(5 * 1000); // 5 seconds
- } catch (Exception ex) {
- Debug.printDebugStack(ex);
- }
- return tc;
- }
-
- /*
- * This will be used to help verify assertion Connector:SPEC:55 from the
- * annotation point of view.
- */
- public void doTCWork() {
- try {
- WorkImpl workimpl = new WorkImpl(wmgr);
- TransactionContext tc = startTx();
-
- Debug.trace("Creating IBAnnoMessageListener");
- XidImpl myid = new XidImpl();
- IBAnnoMessageListener wl = new IBAnnoMessageListener(myid, this.bsc);
- wmgr.doWork(workimpl, 5000, tc, wl);
- ConnectorStatus.getConnectorStatus()
- .logState("TransactionContext Work Object Submitted");
- } catch (WorkException we) {
- Debug.trace("TestWorkManager Exception thrown is " + we.getMessage());
- }
- }
-
- public void setXid(Xid xid) {
- this.myxid = xid;
- }
-
- public Xid getXid() {
- return this.myxid;
- }
-
- public void setNestXid(Xid xid) {
- this.mynestxid = xid;
- }
-
- public Xid getNestXid() {
- return this.mynestxid;
- }
-
- public void debug(String out) {
- Debug.trace("IBAnnoWorkManager: " + out);
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/ibanno/IBAnnotatedResourceAdapterImpl.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/ibanno/IBAnnotatedResourceAdapterImpl.java
deleted file mode 100755
index 0d43b48ea2..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/ibanno/IBAnnotatedResourceAdapterImpl.java
+++ /dev/null
@@ -1,306 +0,0 @@
-/*
- * Copyright (c) 2009, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.common.connector.whitebox.ibanno;
-
-import java.lang.reflect.Method;
-
-import javax.transaction.xa.XAResource;
-
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-import com.sun.ts.tests.common.connector.util.TSMessageListenerInterface;
-import com.sun.ts.tests.common.connector.whitebox.Debug;
-import com.sun.ts.tests.common.connector.whitebox.Util;
-import com.sun.ts.tests.common.connector.whitebox.XidImpl;
-
-import jakarta.resource.ResourceException;
-import jakarta.resource.spi.ActivationSpec;
-import jakarta.resource.spi.AuthenticationMechanism;
-import jakarta.resource.spi.BootstrapContext;
-import jakarta.resource.spi.ConfigProperty;
-import jakarta.resource.spi.Connector;
-import jakarta.resource.spi.ResourceAdapter;
-import jakarta.resource.spi.ResourceAdapterInternalException;
-import jakarta.resource.spi.SecurityPermission;
-import jakarta.resource.spi.TransactionSupport;
-import jakarta.resource.spi.endpoint.MessageEndpointFactory;
-import jakarta.resource.spi.work.ExecutionContext;
-import jakarta.resource.spi.work.TransactionContext;
-import jakarta.resource.spi.work.Work;
-import jakarta.resource.spi.work.WorkManager;
-
-/**
- * This is a sample resource adapter that will use no ra.xml info. This RA is
- * used to assist with verifying the server supports annotations when there is
- * no ra.xml (Assertion 268) and the transaction support is Local. It is also
- * testing inbound messaging support.
- *
- */
-
-@Connector(description = "CTS Test Resource Adapter with No DD", displayName = "whitebox-anno_no_md.rar", vendorName = "Java Software", eisType = "TS EIS", version = "1.6", licenseDescription = "CTS License Required", licenseRequired = true, authMechanisms = @AuthenticationMechanism(credentialInterface = AuthenticationMechanism.CredentialInterface.PasswordCredential, authMechanism = "BasicPassword", description = "Basic Password Authentication"), reauthenticationSupport = false, securityPermissions = @SecurityPermission(), transactionSupport = TransactionSupport.TransactionSupportLevel.XATransaction, requiredWorkContexts = {
- TransactionContext.class })
-public class IBAnnotatedResourceAdapterImpl
- implements ResourceAdapter, java.io.Serializable {
-
- private transient BootstrapContext bsc;
-
- private transient IBAnnoWorkManager awm;
-
- private transient WorkManager wm;
-
- private transient Work work;
-
- private transient MessageEndpointFactory mef2;
-
- private transient IBAnnoMessageWork1 work1;
-
- private transient IBAnnoMessageWork2 work2;
-
- private transient IBAnnoMessageListener ml;
-
- @ConfigProperty(defaultValue = "IBAnnotatedResourceAdapterImpl")
- private String raName;
-
- /**
- * constructor
- **/
- public IBAnnotatedResourceAdapterImpl() {
- debug("enterred IBAnnotatedResourceAdapterImpl() constructor...");
- }
-
- //
- // Begin ResourceAdapter interface requirements
- //
-
- /* must implement for ResourceAdapter interface requirement */
- public void start(BootstrapContext bsc)
- throws ResourceAdapterInternalException {
- debug("enterred start");
-
- this.bsc = bsc;
- this.wm = bsc.getWorkManager();
- this.awm = new IBAnnoWorkManager(bsc);
- awm.runTests();
-
- debug("leaving start");
- }
-
- /* must implement for ResourceAdapter interface requirement */
- public void stop() {
- debug("entered stop");
- }
-
- /* must implement for ResourceAdapter interface requirement */
- public void endpointActivation(MessageEndpointFactory mef,
- ActivationSpec as) {
- try {
- debug("IBAnnotatedResourceAdapterImpl.endpointActivation()");
-
- // check if endpointActivation has been called
- Method onMessagexa = getOnMessageMethod();
- boolean de = mef.isDeliveryTransacted(onMessagexa);
-
- if (!de) {
- // For MDB with Not Supported transaction attribute
- // we should not get here since our mdb is msginflow_mdb2.ear which
- // has transaction set to required in the dd.
- debug(
- "should NOT have found mdb with unsupported transaction attribute!");
- } else {
- // For MDB with Required transaction attribute
- // Endpoint requires a tranaction but no incoming transaction
- String str2 = "IBAnnotatedResourceAdapterImpl Required transaction";
- ConnectorStatus.getConnectorStatus().logState(str2);
- mef2 = mef;
- debug("IBAnnoResourceAdapter preparing work1");
- String destinationName = ((IBAnnoActivationSpecChild) as)
- .getAnnoDestinationName();
- debug("Destination name is " + destinationName);
-
- logMEFActivationInfo(mef);
-
- // help verify assertion Connector:SPEC:282
- ResourceAdapter ra = ((IBAnnoActivationSpecChild) as)
- .getResourceAdapter();
- if (ra != null) {
- ConnectorStatus.getConnectorStatus().logState(
- "IBAnnoActivationSpecChild.getResourceAdapter() not null.");
- } else {
- debug(
- "IBAnnoActivationSpecChild.getResourceAdapter() = null, failed assertion Connector:SPEC:282");
- }
-
- // lets verify the child activation spec inherits @configProp info from
- // parent
- String childPropname = ((IBAnnoActivationSpecChild) as).getPropName();
- String strp = "IBAnnoActivationSpecChild.propName = " + childPropname;
- debug(strp);
- ConnectorStatus.getConnectorStatus().logState(strp);
-
- // now setup work inst
- work1 = new IBAnnoMessageWork1(destinationName, mef2);
- debug("IBAnnoResourceAdapter work1 created");
- wm.scheduleWork(work1, wm.INDEFINITE, null, null);
- debug("IBAnnoResourceAdapter work1 scheduled");
-
- // Endpoint requires a tranaction and there is an incoming transaction
- work2 = new IBAnnoMessageWork2(destinationName, mef2);
- XidImpl myid = new XidImpl();
- ExecutionContext ec = new ExecutionContext();
- int idcount = myid.getFormatId();
- debug("XID getting used [ " + idcount + " ]");
- ec.setXid(myid);
- ml = new IBAnnoMessageListener(myid, this.bsc);
- wm.scheduleWork(work2, wm.INDEFINITE, ec, ml);
-
- }
-
- } catch (Throwable ex) {
- ex.printStackTrace();
- }
-
- }
-
- /* must implement for ResourceAdapter interface requirement */
- public void endpointDeactivation(MessageEndpointFactory ep,
- ActivationSpec spec) {
- debug("enterred endpointDeactivation");
-
- if ((mef2 != null) && (mef2.equals(ep))) {
- mef2 = null;
- } else {
- // print some warnings - may or may not be issue
- if (mef2 == null) {
- debug("WARNING: endpointDeactivation() mef2 == null");
- } else {
- debug("WARNING: endpointDeactivation() mef2 != ep!");
- }
- }
-
- debug("leaving endpointDeactivation");
- }
-
- private void logMEFActivationInfo(MessageEndpointFactory mef) {
- try {
- Debug.trace("enterred logMEFActivationInfo()");
- if (mef != null) {
- String str = "IBAnnotatedResourceAdapterImpl.endpointActivation() getEndpointClass() returned: ";
- Class clazz = mef.getEndpointClass();
- if (clazz != null) {
- // should be getting class name of
- // com.sun.ts.tests.connector.mdb.JCAMessageBean
- str = str + clazz.getName();
- } else {
- // should not get here
- str = str + "null from class.getName()";
- }
- Debug.trace(str);
- ConnectorStatus.getConnectorStatus().logState(str);
-
- String activationName = mef.getActivationName();
- str = "IBAnnotatedResourceAdapterImpl.endpointActivation() getActivationName() returned ";
- if (activationName != null) {
- // should get here...this could be any unique name
- str = str + "nonNull name " + activationName;
- } else {
- // should not get here
- str = str + "null from mef.getActivationName()";
- }
- Debug.trace(str);
- ConnectorStatus.getConnectorStatus().logState(str);
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
-
- private Method getOnMessageMethod() {
-
- Method onMessageMethod = null;
- try {
- Class msgListenerClass = TSMessageListenerInterface.class;
- Class[] paramTypes = { java.lang.String.class };
- onMessageMethod = msgListenerClass.getMethod("onMessage", paramTypes);
-
- } catch (NoSuchMethodException ex) {
- ex.printStackTrace();
- }
- return onMessageMethod;
- }
-
- /*
- * @name equals
- *
- * @desc compares this object with the given object.
- *
- * @param Object obj
- *
- * @return boolean
- */
- public boolean equals(Object obj) {
-
- if ((obj == null) || !(obj instanceof IBAnnotatedResourceAdapterImpl)) {
- return false;
- }
- if (obj == this) {
- return true;
- }
-
- IBAnnotatedResourceAdapterImpl that = (IBAnnotatedResourceAdapterImpl) obj;
-
- if (!Util.isEqual(this.raName, that.getRaName()))
- return false;
-
- return true;
- }
-
- /*
- * @name hashCode
- *
- * @desc gets the hashcode for this object.
- *
- * @return int
- */
- public int hashCode() {
- return this.getClass().getName().hashCode();
- }
-
- /* must implement for ResourceAdapter interface requirement */
- public XAResource[] getXAResources(ActivationSpec[] specs)
- throws ResourceException {
-
- debug("IBAnno getXAResources called");
-
- return null;
- }
-
- //
- // END ResourceAdapter interface requirements
- //
-
- public void setRaName(String name) {
- this.raName = name;
- }
-
- public String getRaName() {
- return raName;
- }
-
- public void debug(String out) {
- Debug.trace("IBAnnotatedResourceAdapterImpl: " + out);
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/mdcomplete/MDAnnotatedMCF.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/mdcomplete/MDAnnotatedMCF.java
deleted file mode 100644
index 239a6f1d30..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/mdcomplete/MDAnnotatedMCF.java
+++ /dev/null
@@ -1,432 +0,0 @@
-/*
- * Copyright (c) 2009, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.common.connector.whitebox.mdcomplete;
-
-import java.io.PrintWriter;
-import java.io.Serializable;
-import java.util.Iterator;
-import java.util.Set;
-
-import javax.security.auth.Subject;
-
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-import com.sun.ts.tests.common.connector.whitebox.Debug;
-import com.sun.ts.tests.common.connector.whitebox.TSConnection;
-import com.sun.ts.tests.common.connector.whitebox.TSConnectionImpl;
-import com.sun.ts.tests.common.connector.whitebox.TSEISDataSource;
-import com.sun.ts.tests.common.connector.whitebox.TSManagedConnection;
-import com.sun.ts.tests.common.connector.whitebox.Util;
-
-import jakarta.resource.ResourceException;
-import jakarta.resource.spi.ConfigProperty;
-import jakarta.resource.spi.ConnectionDefinition;
-import jakarta.resource.spi.ConnectionDefinitions;
-import jakarta.resource.spi.ConnectionManager;
-import jakarta.resource.spi.ConnectionRequestInfo;
-import jakarta.resource.spi.EISSystemException;
-import jakarta.resource.spi.ManagedConnection;
-import jakarta.resource.spi.ManagedConnectionFactory;
-import jakarta.resource.spi.ResourceAdapter;
-import jakarta.resource.spi.ResourceAdapterAssociation;
-import jakarta.resource.spi.security.PasswordCredential;
-
-/*
- * This is an annotated ManagedConenctionFactory class. This class should NOT get
- * used. The ra.xml in this directory (eg ra-md-complete.xml) has metadata-complete="true"
- * and specifies a different MCF than this one be used. So this is assisting with the
- * testing of assertion: Connector:SPEC:266.
- *
- */
-@ConnectionDefinitions({
- @ConnectionDefinition(connectionFactory = com.sun.ts.tests.common.connector.whitebox.TSConnectionFactory.class, connectionFactoryImpl = com.sun.ts.tests.common.connector.whitebox.TSEISDataSource.class, connection = com.sun.ts.tests.common.connector.whitebox.TSConnection.class, connectionImpl = com.sun.ts.tests.common.connector.whitebox.TSEISConnection.class) })
-public class MDAnnotatedMCF implements ManagedConnectionFactory,
- ResourceAdapterAssociation, jakarta.resource.Referenceable, Serializable {
- private javax.naming.Reference reference;
-
- private ResourceAdapter resourceAdapter;
-
- private int count;
-
- private String TSRValue;
-
- private String password;
-
- private String user;
-
- private String userName;
-
- @ConfigProperty(defaultValue = "10", type = Integer.class, description = "Integer value", ignore = false, supportsDynamicUpdates = false, confidential = false)
- private Integer integer;
-
- private String factoryName = "MDAnnotatedMCF";
-
- /*
- * @name MDAnnotatedMCF
- *
- * @desc Default conctructor
- */
- public MDAnnotatedMCF() {
- ConnectorStatus.getConnectorStatus().logState("MDAnnotatedMCF constructor");
- }
-
- public void setFactoryName(String name) {
- debug("MDAnnotatedMCF.setFactoryName");
- this.factoryName = name;
- }
-
- public String getFactoryName() {
- debug("MDAnnotatedMCF.getFactoryName");
- return factoryName;
- }
-
- public Integer getInteger() {
- debug("MDAnnotatedMCF.getInteger");
- return this.integer;
- }
-
- public void setInteger(Integer val) {
- debug("MDAnnotatedMCF.setInteger");
- this.integer = val;
- }
-
- public String getUser() {
- debug("MDAnnotatedMCF.getUser");
- return user;
- }
-
- public void setUser(String val) {
- debug("MDAnnotatedMCF.setUser");
- user = val;
- }
-
- public String getUserName() {
- debug("MDAnnotatedMCF.getUserName");
- return userName;
- }
-
- public void setUserName(String val) {
- debug("MDAnnotatedMCF.setUserName");
- userName = val;
- }
-
- public String getPassword() {
- debug("MDAnnotatedMCF.getPassword");
- return password;
- }
-
- public void setPassword(String val) {
- debug("MDAnnotatedMCF.setPassword");
- password = val;
- }
-
- public String getTSRValue() {
- debug("MDAnnotatedMCF.getTSRValue");
- return TSRValue;
- }
-
- public void setTSRValue(String name) {
- debug("MDAnnotatedMCF.setTSRValue");
- this.TSRValue = name;
- }
-
- /*
- * @name createConnectionFactory
- *
- * @desc Creates a new connection factory instance
- *
- * @param ConnectionManager
- *
- * @return Object
- *
- * @exception ResourceException
- */
- public Object createConnectionFactory(ConnectionManager cxManager)
- throws ResourceException {
- ConnectorStatus.getConnectorStatus().logAPI(
- "MDAnnotatedMCF.createConnectionFactory", "cxManager",
- "TSEISDataSource");
- return new TSEISDataSource(this, cxManager);
- }
-
- /*
- * @name createConnectionFactory
- *
- * @desc Creates a new connection factory instance
- *
- * @return Object
- *
- * @exception ResourceException
- */
- public Object createConnectionFactory() throws ResourceException {
- ConnectorStatus.getConnectorStatus().logAPI(
- "MDAnnotatedMCF.createConnectionFactory", "", "TSEISDataSource");
- return new TSEISDataSource(this, null);
- }
-
- /*
- * @name setResourceAdapter
- *
- * @desc sets the Resource Adapter for this ManagedConnectionFactory
- *
- * @return
- *
- * @exception ResourceException
- */
- public void setResourceAdapter(ResourceAdapter ra) throws ResourceException {
- count++;
- String newStr1 = new String("MDAnnotatedMCF setResourceAdapter " + count);
- debug(newStr1);
- this.resourceAdapter = ra;
- }
-
- /*
- * @name getResourceAdapter
- *
- * @desc gets the Resource Adapter for this ManagedConnectionFactory
- *
- * @return Object
- *
- * @exception ResourceException
- */
- public ResourceAdapter getResourceAdapter() {
- debug("MDAnnotatedMCF getResourceAdapter");
- return resourceAdapter;
- }
-
- /*
- * @name createManagedConnection
- *
- * @desc Creates a new managed connection to the underlying EIS
- *
- * @param Subject, ConnectionRequestInfo
- *
- * @return ManagedConnection
- *
- * @exception ResourceException
- */
- public ManagedConnection createManagedConnection(Subject subject,
- ConnectionRequestInfo info) throws ResourceException {
-
- try {
-
- ConnectorStatus.getConnectorStatus().logAPI(
- "MDAnnotatedMCF.createManagedConnection", "subject|info",
- "TSManagedConnection");
- TSConnection con = null;
- PasswordCredential pc = Util.getPasswordCredential(this, subject, info);
- if (pc == null) {
- debug("MDAnnotatedMCF.createManagedConnection(): pc == null");
- con = new TSConnectionImpl().getConnection();
- } else {
- debug("MDAnnotatedMCF.createManagedConnection(): pc != null");
- setUser(pc.getUserName());
- setUserName(pc.getUserName());
- setPassword(new String(pc.getPassword()));
- con = new TSConnectionImpl().getConnection(pc.getUserName(),
- pc.getPassword());
- }
-
- ManagedConnection mcon = new TSManagedConnection(this, pc, null, con,
- false, true);
-
- return mcon;
- } catch (Exception ex) {
- ResourceException re = new EISSystemException(
- "Exception: " + ex.getMessage());
- re.initCause(ex);
- throw re;
- }
-
- }
-
- /*
- * @name matchManagedConnection
- *
- * @desc Return the existing connection from the connection pool
- *
- * @param Set, Subject, ConnectionRequestInfo
- *
- * @return ManagedConnection
- *
- * @exception ResourceException
- */
- public ManagedConnection matchManagedConnections(Set connectionSet,
- Subject subject, ConnectionRequestInfo info) throws ResourceException {
- ConnectorStatus.getConnectorStatus().logAPI(
- "MDAnnotatedMCF.matchManagedConnection", "connectionSet|subject|info",
- "TSEISDataSource");
-
- PasswordCredential pc = Util.getPasswordCredential(this, subject, info);
- Iterator it = connectionSet.iterator();
-
- while (it.hasNext()) {
- Object obj = it.next();
- if (obj instanceof TSManagedConnection) {
- TSManagedConnection mc = (TSManagedConnection) obj;
- ManagedConnectionFactory mcf = mc.getManagedConnectionFactory();
- if (Util.isPasswordCredentialEqual(mc.getPasswordCredential(), pc)
- && (mcf != null) && mcf.equals(this)) {
- return mc;
- }
- }
- }
-
- debug("matchManagedConnections: couldnt find match");
- return null;
- }
-
- /*
- * @name setLogWriter
- *
- * @desc Sets the Print Writer
- *
- * @param PrintWriter
- *
- * @exception ResourceException
- */
- public void setLogWriter(PrintWriter out) throws ResourceException {
- ConnectorStatus.getConnectorStatus().logAPI("MDAnnotatedMCF.setLogWriter",
- "out", "");
- }
-
- /*
- * @name getLogWriter
- *
- * @desc Gets the Print Writer
- *
- * @return PrintWriter
- *
- * @exception ResourceException
- */
- public PrintWriter getLogWriter() throws ResourceException {
- ConnectorStatus.getConnectorStatus().logAPI("MDAnnotatedMCF.getLogWriter",
- "", "");
- return null;
- }
-
- /*
- * @name equals
- *
- * @desc Compares the given object to the ManagedConnectionFactory instance.
- *
- * @param Object
- *
- * @return boolean
- */
- public boolean equals(Object obj) {
-
- if ((obj == null) || !(obj instanceof MDAnnotatedMCF)) {
- return false;
- }
- if (obj == this) {
- return true;
- }
-
- MDAnnotatedMCF that = (MDAnnotatedMCF) obj;
-
- if ((this.reference != null)
- && !(this.reference.equals(that.getReference()))) {
- return false;
- } else if ((this.reference == null) && !(that.getReference() == null)) {
- return false;
- }
-
- if ((this.resourceAdapter != null)
- && !(this.resourceAdapter.equals(that.getResourceAdapter()))) {
- return false;
- } else if ((this.resourceAdapter == null)
- && !(that.getResourceAdapter() == null)) {
- return false;
- }
-
- if (this.count != that.getCount()) {
- return false;
- }
-
- if ((this.integer != null) && (!this.integer.equals(that.getInteger()))) {
- return false;
- } else if ((this.integer == null) && !(that.getInteger() == null)) {
- return false;
- }
-
- if (!Util.isEqual(this.password, that.getPassword()))
- return false;
-
- if (!Util.isEqual(this.user, that.getUser()))
- return false;
-
- if (!Util.isEqual(this.userName, that.getUserName()))
- return false;
-
- if (!Util.isEqual(this.TSRValue, that.getTSRValue()))
- return false;
-
- if (!Util.isEqual(this.factoryName, that.getFactoryName()))
- return false;
-
- return true;
- }
-
- /*
- * @name hashCode
- *
- * @desc Gives a hash value to a ManagedConnectionFactory Obejct.
- *
- * @return int
- */
- public int hashCode() {
- return this.getClass().getName().hashCode();
- }
-
- /*
- * @name getReference
- *
- * @desc Gives the reference of the class
- *
- * @return javax.naming.Reference
- */
- public javax.naming.Reference getReference() {
- javax.naming.Reference ref;
-
- ref = this.reference;
- return ref;
- }
-
- /*
- * @name setReference
- *
- * @desc sets the reference of the class
- *
- * @param javax.naming.Reference
- */
- public void setReference(javax.naming.Reference ref) {
- this.reference = ref;
- }
-
- public void debug(String out) {
- Debug.trace("MDAnnotatedMCF: " + out);
- }
-
- public int getCount() {
- return this.count;
- }
-
- public void setCount(int val) {
- this.count = val;
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/mdcomplete/MDCompleteMCF.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/mdcomplete/MDCompleteMCF.java
deleted file mode 100644
index 1dfc9a3055..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/mdcomplete/MDCompleteMCF.java
+++ /dev/null
@@ -1,446 +0,0 @@
-/*
- * Copyright (c) 2009, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.common.connector.whitebox.mdcomplete;
-
-import java.io.PrintWriter;
-import java.io.Serializable;
-import java.util.Iterator;
-import java.util.Set;
-
-import javax.security.auth.Subject;
-
-import com.sun.ts.lib.util.TSNamingContext;
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-import com.sun.ts.tests.common.connector.whitebox.Debug;
-import com.sun.ts.tests.common.connector.whitebox.TSConnection;
-import com.sun.ts.tests.common.connector.whitebox.TSConnectionImpl;
-import com.sun.ts.tests.common.connector.whitebox.TSEISDataSource;
-import com.sun.ts.tests.common.connector.whitebox.TSManagedConnection;
-import com.sun.ts.tests.common.connector.whitebox.Util;
-
-import jakarta.resource.ResourceException;
-import jakarta.resource.spi.ConfigProperty;
-import jakarta.resource.spi.ConnectionManager;
-import jakarta.resource.spi.ConnectionRequestInfo;
-import jakarta.resource.spi.EISSystemException;
-import jakarta.resource.spi.ManagedConnection;
-import jakarta.resource.spi.ManagedConnectionFactory;
-import jakarta.resource.spi.ResourceAdapter;
-import jakarta.resource.spi.ResourceAdapterAssociation;
-import jakarta.resource.spi.TransactionSupport;
-import jakarta.resource.spi.security.PasswordCredential;
-
-public class MDCompleteMCF
- implements ManagedConnectionFactory, ResourceAdapterAssociation,
- TransactionSupport, Serializable, jakarta.resource.Referenceable {
- private javax.naming.Reference reference;
-
- private ResourceAdapter resourceAdapter;
-
- private int count;
-
- private String TSRValue;
-
- private String password;
-
- private String user;
-
- private String userName;
-
- @ConfigProperty(description = "String value", ignore = false)
- String factoryName = "MDCompleteMCF";
-
- /*
- * @name MDCompleteMCF
- *
- * @desc Default conctructor
- */
- public MDCompleteMCF() {
- ConnectorStatus.getConnectorStatus().logState("MDCompleteMCF constructor");
- }
-
- /*
- * @name getTransactionSupport
- *
- * @desc this is required for interface TransacationSupport
- */
- public TransactionSupportLevel getTransactionSupport() {
-
- // this is used to assist with assertion: Connector:SPEC:206 and
- // Connector:SPEC:316.
- String str = "MDCompleteMCF.getTransactionSupport called";
- ConnectorStatus.getConnectorStatus().logState(str);
- debug(str);
- return TransactionSupport.TransactionSupportLevel.NoTransaction;
- }
-
- public void setFactoryName(String name) {
- debug("MDCompleteMCF.setFactoryName");
-
- // this helps verify assertion Connector:SPEC:307 and Connector:SPEC:277
- // and this behavior is described in connector 1.6 spec section 18.5
- String str = "MDCompleteMCF factoryname=" + name;
- debug(str);
-
- this.factoryName = name;
- }
-
- public String getFactoryName() {
- debug("MDCompleteMCF.getFactoryName");
- return factoryName;
- }
-
- public String getUser() {
- debug("MDCompleteMCF.getUser() returning: " + user);
- return user;
- }
-
- public void setUser(String val) {
- debug("MDCompleteMCF.setUser() with val = " + val);
- user = val;
- }
-
- public String getUserName() {
- debug("MDCompleteMCF.getUserName() returning: " + userName);
- return userName;
- }
-
- public void setUserName(String val) {
- debug("MDCompleteMCF.setUserName() with val = " + val);
- userName = val;
- }
-
- public String getPassword() {
- debug("MDCompleteMCF.getPassword() returning: " + password);
- return password;
- }
-
- public void setPassword(String val) {
- debug("MDCompleteMCF.setPassword() with val = " + val);
- password = val;
- }
-
- public String getTSRValue() {
- debug("MDCompleteMCF.getTSRValue");
- return TSRValue;
- }
-
- public void setTSRValue(String name) {
- debug("MDCompleteMCF.setTSRValue");
- this.TSRValue = name;
- }
-
- public void lookupTSR(String lookup) {
- debug("MDCompleteMCF.lookupTSR");
- try {
- TSNamingContext ncxt = new TSNamingContext();
- String newStr = "java:".concat(lookup);
- Object obj = (Object) ncxt.lookup(newStr);
- if (obj != null) {
- debug("TSR Lookup Successful");
- } else {
- debug("TSR Null");
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- /*
- * @name createConnectionFactory
- *
- * @desc Creates a new connection factory instance
- *
- * @param ConnectionManager
- *
- * @return Object
- *
- * @exception ResourceException
- */
- public Object createConnectionFactory(ConnectionManager cxManager)
- throws ResourceException {
- ConnectorStatus.getConnectorStatus().logAPI(
- "MDCompleteMCF.createConnectionFactory", "cxManager",
- "TSEISDataSource");
- return new TSEISDataSource(this, cxManager);
- }
-
- /*
- * @name createConnectionFactory
- *
- * @desc Creates a new connection factory instance
- *
- * @return Object
- *
- * @exception ResourceException
- */
- public Object createConnectionFactory() throws ResourceException {
- ConnectorStatus.getConnectorStatus()
- .logAPI("MDCompleteMCF.createConnectionFactory", "", "TSEISDataSource");
- return new TSEISDataSource(this, null);
- }
-
- /*
- * @name setResourceAdapter
- *
- * @desc sets the Resource Adapter for this ManagedConnectionFactory
- *
- * @return
- *
- * @exception ResourceException
- */
- public void setResourceAdapter(ResourceAdapter ra) throws ResourceException {
- count++;
- String newStr1 = new String("MDCompleteMCF setResourceAdapter " + count);
- debug(newStr1);
- this.resourceAdapter = ra;
-
- // if we made it here, we assume no exceptions thrown thus validating
- // Connector:SPEC:226
- ConnectorStatus.getConnectorStatus().logState(newStr1);
- }
-
- /*
- * @name getResourceAdapter
- *
- * @desc gets the Resource Adapter for this ManagedConnectionFactory
- *
- * @return Object
- *
- * @exception ResourceException
- */
- public ResourceAdapter getResourceAdapter() {
- debug("MDCompleteMCF.getResource");
- return resourceAdapter;
- }
-
- /*
- * @name createManagedConnection
- *
- * @desc Creates a new managed connection to the underlying EIS
- *
- * @param Subject, ConnectionRequestInfo
- *
- * @return ManagedConnection
- *
- * @exception ResourceException
- */
- public ManagedConnection createManagedConnection(Subject subject,
- ConnectionRequestInfo info) throws ResourceException {
-
- try {
-
- ConnectorStatus.getConnectorStatus().logAPI(
- "MDCompleteMCF.createManagedConnection", "subject|info",
- "TSManagedConnection");
- TSConnection con = null;
- PasswordCredential pc = Util.getPasswordCredential(this, subject, info);
- if (pc == null) {
- debug("MDCompleteMCF.createManagedConnection(): pc == null");
- con = new TSConnectionImpl().getConnection();
- } else {
- debug("MDCompleteMCF.createManagedConnection(): pc != null");
- setUser(pc.getUserName());
- setUserName(pc.getUserName());
- setPassword(new String(pc.getPassword()));
- con = new TSConnectionImpl().getConnection(pc.getUserName(),
- pc.getPassword());
- }
-
- ManagedConnection mcon = new TSManagedConnection(this, pc, null, con,
- false, true);
-
- return mcon;
- } catch (Exception ex) {
- ResourceException re = new EISSystemException(
- "Exception: " + ex.getMessage());
- re.initCause(ex);
- throw re;
- }
-
- }
-
- /*
- * @name matchManagedConnection
- *
- * @desc Return the existing connection from the connection pool
- *
- * @param Set, Subject, ConnectionRequestInfo
- *
- * @return ManagedConnection
- *
- * @exception ResourceException
- */
- public ManagedConnection matchManagedConnections(Set connectionSet,
- Subject subject, ConnectionRequestInfo info) throws ResourceException {
- ConnectorStatus.getConnectorStatus().logAPI(
- "MDCompleteMCF.matchManagedConnection", "connectionSet|subject|info",
- "TSEISDataSource");
-
- PasswordCredential pc = Util.getPasswordCredential(this, subject, info);
- Iterator it = connectionSet.iterator();
-
- while (it.hasNext()) {
- Object obj = it.next();
- if (obj instanceof TSManagedConnection) {
- TSManagedConnection mc = (TSManagedConnection) obj;
- ManagedConnectionFactory mcf = mc.getManagedConnectionFactory();
- if (Util.isPasswordCredentialEqual(mc.getPasswordCredential(), pc)
- && mcf.equals(this)) {
- return mc;
- }
- }
- }
-
- return null;
- }
-
- /*
- * @name setLogWriter
- *
- * @desc Sets the Print Writer
- *
- * @param PrintWriter
- *
- * @exception ResourceException
- */
- public void setLogWriter(PrintWriter out) throws ResourceException {
- ConnectorStatus.getConnectorStatus().logAPI("MDCompleteMCF.setLogWriter",
- "out", "");
- }
-
- /*
- * @name getLogWriter
- *
- * @desc Gets the Print Writer
- *
- * @return PrintWriter
- *
- * @exception ResourceException
- */
- public PrintWriter getLogWriter() throws ResourceException {
- ConnectorStatus.getConnectorStatus().logAPI("MDCompleteMCF.getLogWriter",
- "", "");
- return null;
- }
-
- /*
- * @name equals
- *
- * @desc Compares the given object to the ManagedConnectionFactory instance.
- *
- * @param Object
- *
- * @return boolean
- */
- public boolean equals(Object obj) {
-
- if ((obj == null) || !(obj instanceof MDCompleteMCF)) {
- return false;
- }
- if (obj == this) {
- return true;
- }
-
- MDCompleteMCF that = (MDCompleteMCF) obj;
-
- if ((this.reference != null)
- && !(this.reference.equals(that.getReference()))) {
- return false;
- } else if ((this.reference == null) && !(that.getReference() == null)) {
- return false;
- }
-
- if ((this.resourceAdapter != null)
- && !(this.resourceAdapter.equals(that.getResourceAdapter()))) {
- return false;
- } else if ((this.resourceAdapter == null)
- && !(that.getResourceAdapter() == null)) {
- return false;
- }
-
- if (this.count != that.getCount()) {
- return false;
- }
-
- if (!Util.isEqual(this.password, that.getPassword()))
- return false;
-
- if (!Util.isEqual(this.user, that.getUser()))
- return false;
-
- if (!Util.isEqual(this.userName, that.getUserName()))
- return false;
-
- if (!Util.isEqual(this.TSRValue, that.getTSRValue()))
- return false;
-
- if (!Util.isEqual(this.factoryName, that.getFactoryName()))
- return false;
-
- return true;
- }
-
- /*
- * @name hashCode
- *
- * @desc Gives a hash value to a ManagedConnectionFactory Obejct.
- *
- * @return int
- */
- public int hashCode() {
- return this.getClass().getName().hashCode();
- }
-
- /*
- * @name getReference
- *
- * @desc Gives the reference of the class
- *
- * @return javax.naming.Reference
- */
- public javax.naming.Reference getReference() {
- javax.naming.Reference ref;
-
- ref = this.reference;
- return ref;
- }
-
- /*
- * @name setReference
- *
- * @desc sets the reference of the class
- *
- * @param javax.naming.Reference
- */
- public void setReference(javax.naming.Reference ref) {
- this.reference = ref;
- }
-
- public void debug(String out) {
- Debug.trace("MDCompleteMCF: " + out);
- }
-
- public int getCount() {
- return this.count;
- }
-
- public void setCount(int val) {
- this.count = val;
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/mdcomplete/MDCompleteRAImpl.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/mdcomplete/MDCompleteRAImpl.java
deleted file mode 100755
index 5b48e0ab6d..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/mdcomplete/MDCompleteRAImpl.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * Copyright (c) 2009, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.common.connector.whitebox.mdcomplete;
-
-import javax.transaction.xa.XAResource;
-
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-import com.sun.ts.tests.common.connector.whitebox.Debug;
-import com.sun.ts.tests.common.connector.whitebox.Util;
-
-import jakarta.resource.NotSupportedException;
-import jakarta.resource.ResourceException;
-import jakarta.resource.spi.ActivationSpec;
-import jakarta.resource.spi.AuthenticationMechanism;
-import jakarta.resource.spi.BootstrapContext;
-import jakarta.resource.spi.ConfigProperty;
-import jakarta.resource.spi.Connector;
-import jakarta.resource.spi.ResourceAdapter;
-import jakarta.resource.spi.ResourceAdapterInternalException;
-import jakarta.resource.spi.SecurityPermission;
-import jakarta.resource.spi.TransactionSupport;
-import jakarta.resource.spi.endpoint.MessageEndpointFactory;
-import jakarta.resource.spi.work.HintsContext;
-import jakarta.resource.spi.work.SecurityContext;
-import jakarta.resource.spi.work.TransactionContext;
-import jakarta.resource.spi.work.Work;
-import jakarta.resource.spi.work.WorkManager;
-
-/**
- * This is a sample resource adapter that will use some ra.xml info. This RA is
- * used to assist with verifying the server supports annotations when there is
- * no ra.xml (Assertion 268) and the transaction support is Local.
- *
- */
-
-@Connector(description = "CTS Test Resource Adapter with No DD", licenseDescription = "CTS License Required", licenseRequired = true, authMechanisms = @AuthenticationMechanism(credentialInterface = AuthenticationMechanism.CredentialInterface.PasswordCredential, authMechanism = "BasicPassword", description = "Basic Password Authentication"), reauthenticationSupport = false, securityPermissions = @SecurityPermission(), transactionSupport = TransactionSupport.TransactionSupportLevel.NoTransaction, requiredWorkContexts = {
- HintsContext.class, TransactionContext.class, SecurityContext.class })
-public class MDCompleteRAImpl implements ResourceAdapter, java.io.Serializable {
-
- private transient BootstrapContext bsc;
-
- private transient MDCompleteWorkManager mdwm;
-
- private transient WorkManager wm;
-
- private transient Work work;
-
- // this should cause the setter to get invoked
- @ConfigProperty(defaultValue = "BAD_RAName_value", description = "String value", ignore = false)
- String RAName;
-
- /**
- * constructor
- **/
- public MDCompleteRAImpl() {
- debug("enterred constructor...");
-
- debug("leaving constructor...");
- }
-
- //
- // Begin ResourceAdapter interface requirements
- //
-
- /* must implement for ResourceAdapter interface requirement */
- public void start(BootstrapContext bsc)
- throws ResourceAdapterInternalException {
- debug("enterred start");
-
- debug("MDCompleteRAImpl.start called");
-
- this.bsc = bsc;
- this.wm = bsc.getWorkManager();
-
- this.mdwm = new MDCompleteWorkManager(bsc);
- mdwm.runTests();
-
- debug("leaving start");
- }
-
- /* must implement for ResourceAdapter interface requirement */
- public void stop() {
- debug("entered stop");
- debug("leaving stop");
- }
-
- /* must implement for ResourceAdapter interface requirement */
- public void endpointActivation(MessageEndpointFactory factory,
- ActivationSpec spec) throws NotSupportedException {
-
- debug("enterred endpointActivation");
- debug("leaving endpointActivation");
- }
-
- /* must implement for ResourceAdapter interface requirement */
- public void endpointDeactivation(MessageEndpointFactory ep,
- ActivationSpec spec) {
- debug("enterred endpointDeactivation");
- debug("leaving endpointDeactivation");
- }
-
- /* must implement for ResourceAdapter interface requirement */
- public XAResource[] getXAResources(ActivationSpec[] specs)
- throws ResourceException {
-
- debug("enterred getXAResources");
- debug("leaving getXAResources");
-
- throw new UnsupportedOperationException();
- }
-
- //
- // END ResourceAdapter interface requirements
- //
-
- /*
- * @name equals
- *
- * @desc compares this object with the given object.
- *
- * @param Object obj
- *
- * @return boolean
- */
- public boolean equals(Object obj) {
-
- if ((obj == null) || !(obj instanceof MDCompleteRAImpl)) {
- return false;
- }
- if (obj == this) {
- return true;
- }
-
- MDCompleteRAImpl that = (MDCompleteRAImpl) obj;
-
- if (!Util.isEqual(this.RAName, that.getRAName()))
- return false;
-
- return true;
- }
-
- /*
- * @name hashCode
- *
- * @desc gets the hashcode for this object.
- *
- * @return int
- */
- public int hashCode() {
- return this.getClass().getName().hashCode();
- }
-
- /*
- * this is the setter for the ConfigProperty annotation = RAName. According to
- * onnector 1.6 spec, section 18.5, this setter must be invoked since it
- * belongs to a ConfigProperty annotation for the ResourceAdapter JavaBean.
- */
- public void setRAName(String name) {
- this.RAName = name;
-
- // this helps verify assertion Connector:SPEC:279
- String str = "setRAName called with raname=" + RAName;
- debug(str);
- ConnectorStatus.getConnectorStatus().logState(str);
- }
-
- public String getRAName() {
- debug("MDCompleteRAImpl.getRAName");
- return RAName;
- }
-
- public void debug(String out) {
- Debug.trace("MDCompleteRAImpl: " + out);
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/mdcomplete/MDCompleteWorkManager.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/mdcomplete/MDCompleteWorkManager.java
deleted file mode 100644
index 1782092758..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/mdcomplete/MDCompleteWorkManager.java
+++ /dev/null
@@ -1,347 +0,0 @@
-/*
- * Copyright (c) 2009, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.common.connector.whitebox.mdcomplete;
-
-import javax.transaction.xa.Xid;
-
-import com.sun.ts.lib.util.TestUtil;
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-import com.sun.ts.tests.common.connector.whitebox.ContextWork;
-import com.sun.ts.tests.common.connector.whitebox.Debug;
-import com.sun.ts.tests.common.connector.whitebox.NestWork;
-import com.sun.ts.tests.common.connector.whitebox.TSSecurityContext;
-import com.sun.ts.tests.common.connector.whitebox.TSSecurityContextWithListener;
-import com.sun.ts.tests.common.connector.whitebox.WorkImpl;
-import com.sun.ts.tests.common.connector.whitebox.XidImpl;
-
-import jakarta.resource.spi.BootstrapContext;
-import jakarta.resource.spi.work.ExecutionContext;
-import jakarta.resource.spi.work.SecurityContext;
-import jakarta.resource.spi.work.TransactionContext;
-import jakarta.resource.spi.work.WorkCompletedException;
-import jakarta.resource.spi.work.WorkContextErrorCodes;
-import jakarta.resource.spi.work.WorkException;
-import jakarta.resource.spi.work.WorkManager;
-
-public class MDCompleteWorkManager {
- private BootstrapContext bsc = null;
-
- private WorkManager wmgr;
-
- private String sicUser = "";
-
- private String sicPwd = "";
-
- private String eisUser = "";
-
- private String eisPwd = "";
-
- public MDCompleteWorkManager(BootstrapContext val) {
- debug("enterred constructor");
- this.bsc = val;
- this.wmgr = bsc.getWorkManager();
-
- this.sicUser = TestUtil.getSystemProperty("j2eelogin.name");
- this.sicPwd = TestUtil.getSystemProperty("j2eelogin.password");
- this.eisUser = TestUtil.getSystemProperty("eislogin.name");
- this.eisPwd = TestUtil.getSystemProperty("eislogin.password");
- debug("leaving constructor");
- }
-
- public void runTests() {
- debug("enterred runTests");
- doWork();
- testNestedContext();
- testNestedContext2();
- testNestedContext3();
- submitTICWork();
- debug("leaving runTests");
- }
-
- public void doWork() {
- debug("MDCompleteWorkManager enterred doWork");
-
- try {
- WorkImpl workimpl = new WorkImpl(wmgr);
- ExecutionContext ec = startTx();
- ContextWork w1 = new ContextWork(wmgr);
-
- // helps test: Connector:SPEC:72, Connector:SPEC:73, Connector:SPEC:214
- // this better generate an end result of a WorkCompletedException with
- // an error code == WorkContextErrorCodes.UNSUPPORTED_CONTEXT_TYPE
- debug(
- "MDCompleteWorkManager.doWork() submitting UnknownWorkContext generate error code.");
-
- UnknownWorkContext uwc = new UnknownWorkContext();
- uwc.setXid(ec.getXid());
- w1.addWorkContext(uwc);
-
- // submitting work inst w/ an unknown work context shoudl throw
- // proper error code...
- wmgr.doWork(w1);
-
- } catch (WorkCompletedException e) {
- // this must throw exception ==
- // WorkContextErrorCodes.UNSUPPORTED_CONTEXT_TYPE
- debug("MDCompleteWorkManager WorkCompletedException thrown is "
- + e.getMessage());
-
- // this helps verify assertion Connector:SPEC:214
- // get error code and make sure we get one that makes sense
- String strErrorCode = e.getErrorCode();
- if (WorkContextErrorCodes.UNSUPPORTED_CONTEXT_TYPE.equals(strErrorCode)) {
- // excellant - this is what we expect
- ConnectorStatus.getConnectorStatus().logState(
- "MDCompleteWorkManager threw WorkContextErrorCodes.UNSUPPORTED_CONTEXT_TYPE");
- debug(
- "MDCompleteWorkManager threw WorkContextErrorCodes.UNSUPPORTED_CONTEXT_TYPE");
- } else {
- // doh! we got incorrect error code
- debug("MDCompleteWorkManager threw WorkContextErrorCodes = "
- + strErrorCode);
- }
- } catch (WorkException we) {
- debug("MDCompleteWorkManager WorkException thrown is " + we.getMessage());
- Debug.printDebugStack(we);
- } catch (Exception ex) {
- debug("MDCompleteWorkManager Exception thrown is " + ex.getMessage());
- Debug.printDebugStack(ex);
- }
-
- debug("MDCompleteWorkManager leaving doWork");
- }
-
- /*
- * this method is used to facilitate testing assertion Connector:SPEC:305 the
- * idea here is to test as follows: - create parent work obj - add valid SIC
- * to parent work obj - create 2nd work obj to be child and get nested within
- * parent work obj - assign NO SIC to child work obj - add child work obj into
- * parent - execute parent work obj - parent has valid SIC so should be okay
- * but child has NO SIC and should NOT inherit the parents SIC so the child
- * workobj XXXX: how to verify the workInst with no SIC did not inherit!
- */
- public void testNestedContext2() {
-
- try {
- debug("enterred testNestedWork2()");
-
- // to properly test assert Connector:SPEC:305 we need to have nested
- // work objects where each work has a context set.
- ContextWork parent = new ContextWork(wmgr);
- NestWork nw = new NestWork();
-
- // create valid sic / creds for parent work obj
- SecurityContext psic = new TSSecurityContextWithListener(sicUser, sicPwd,
- eisUser, false);
-
- // lets add SIC to our parent work obj only
- parent.addWorkContext(psic); // add SIC w/ valid creds
-
- // add our child workobj(ie nw) into our parent work obj
- parent.addNestedWork(nw);
-
- wmgr.doWork(parent);
-
- } catch (WorkException e) {
- debug("testNestedWork2() - got WorkException()");
- } catch (Exception e) {
- // flow should not go here
- debug("got exception in testNestedContext2() with user = " + sicUser
- + " pwd = " + sicPwd + " principal=" + eisUser);
- debug(e.toString());
- Debug.printDebugStack(e);
- }
- debug("leaving testNestedContext2()");
- }
-
- /*
- * This method is used to facilitate testing assertion Connector:SPEC:210 The
- * following steps are needed to validate assertion 210. - create parent work
- * obj - add valid SIC to parent work obj - create 2nd work obj to be child
- * and get nested within parent work obj - assign another valid
- * (authenticatable) SIC to child work obj - add child work obj into parent
- * work obj - execute parent work obj (which, in turn, attempts to execute
- * child ) - parent has valid SIC so should be okay - but child does not
- *
- * The goal here is to show that the AS supports nested contexts by supplying
- * 2 different SIC contexts (one valid and one invalid).
- *
- */
- public void testNestedContext3() {
-
- try {
- debug("enterred testNestedWork3()");
-
- // to properly test assert Connector:SPEC:305 we need to have nested
- // work objects where each work has a context set.
- ContextWork parent = new ContextWork(wmgr);
- NestWork nw = new NestWork();
-
- // create valid sic / creds for parent work obj
- TSSecurityContext psic = new TSSecurityContext(sicUser, sicPwd, eisUser,
- false);
-
- // create invalid sic / creds for child work obj
- // note we pass 'false' as we expect it should fail to authenticate
- // with teh bogus creds we are passing in...if it fails to authenticate,
- // it should log appropriate msg stating so which menas that our
- // child/nested work context did not inherit security from parent.
- TSNestedSecurityContext csic = new TSNestedSecurityContext("phakeUsr",
- "phakePwd", "phakeEis", false, false);
- nw.addWorkContext(csic); // add SIC w/ invalid creds
-
- // lets add SIC to our parent work obj only
- parent.addWorkContext(psic); // add SIC w/ valid creds
-
- // add our child workobj(ie nw) into our parent work obj
- parent.addNestedWork(nw);
-
- wmgr.doWork(parent);
-
- } catch (WorkException e) {
- debug("testNestedWork3() - got WorkException()");
- } catch (Exception e) {
- // flow should not go here
- debug("got exception in testSecurityInflow() with user = " + sicUser
- + " pwd = " + sicPwd + " principal=" + eisUser);
- debug(e.toString());
- Debug.printDebugStack(e);
- }
-
- debug("leaving testNestedContext3()");
- }
-
- /*
- * This method is used to facilitate testing assertion Connector:SPEC:210 The
- * following steps are needed to validate assertion 210. - create parent work
- * obj - add valid SIC to parent work obj - create 2nd work obj to be child
- * and get nested within parent work obj - assign another valid
- * (authenticatable) SIC to child work obj - add child work obj into parent
- * work obj - execute parent work obj (which, in turn, attempts to execute
- * child ) - parent has valid SIC so should be okay - same with child
- *
- * The goal here is to show that the AS supports nested contexts by supplying
- * 2 different SIC contexts (both valid).
- *
- */
- public void testNestedContext() {
-
- String strPass = "Nested Work and Nested Security Context worked.";
-
- try {
- debug("enterred testNestedContext()");
-
- // to properly test assert Connector:SPEC:210 we need to have nested
- // work objects where each work has a context set.
- ContextWork parent = new ContextWork(wmgr);
- NestWork nw = new NestWork();
- SecurityContext sic = new TSSecurityContextWithListener(sicUser, sicPwd,
- eisUser, false);
-
- // add SIC that should not be able to authenticate
- SecurityContext sic2 = new TSSecurityContextWithListener(sicUser, sicPwd,
- eisUser, false);
-
- // lets add two different SICs to our work objs
- parent.addWorkContext(sic); // valid creds
- nw.addWorkContext(sic2); // valid creds
-
- // add our child workobj(ie nw) into our parent work obj
- parent.addNestedWork(nw);
-
- // this may or may not throw WorkCompletedException upon
- // successful execution of work.
- wmgr.doWork(parent);
-
- // note: flow should make it here and NOT yeild any exceptions.
- ConnectorStatus.getConnectorStatus().logState(strPass);
- debug(strPass);
-
- } catch (WorkCompletedException e) {
- // could get here upon success work completion
- ConnectorStatus.getConnectorStatus().logState(strPass);
- debug(strPass);
- } catch (Exception e) {
- // should not get here
- debug("got exception in testSecurityInflow() with user = " + sicUser
- + " pwd = " + sicPwd + " principal=" + eisUser);
- debug(e.toString());
- Debug.printDebugStack(e);
- }
- debug("leaving testNestedContext()");
- }
-
- public void submitTICWork() {
-
- try {
- debug("enterred submitTICWork()");
-
- ExecutionContext ec = startTx();
- ContextWork w1 = new ContextWork(wmgr);
- TransactionContext tic = new TransactionContext();
- tic.setXid(ec.getXid());
-
- // add same tic twice and AS should throw
- // WorkContextErrorCodes.DUPLICATE_CONTEXTS
- debug(
- "adding Duplicate WorkContext (with dup TIC Listener) should throw WorkContextErrorCodes.DUPLICATE_CONTEXTS.");
- w1.addWorkContext(tic);
- w1.addWorkContext(tic);
- wmgr.doWork(w1);
-
- debug("submitted Duplicate WorkContext with dup TIC Listener");
-
- } catch (WorkCompletedException e) {
- String strErrorCode = e.getErrorCode();
- if (WorkContextErrorCodes.DUPLICATE_CONTEXTS.equals(strErrorCode)) {
- // excellant - this is what we expect
- ConnectorStatus.getConnectorStatus().logState(
- "MDCompleteWorkManager threw WorkContextErrorCodes.DUPLICATE_CONTEXTS");
- debug(
- "MDCompleteWorkManager correctly threw WorkContextErrorCodes.DUPLICATE_CONTEXTS");
- } else {
- // doh! we got incorrect error code
- debug("MDCompleteWorkManager threw improper WorkContextErrorCodes = "
- + strErrorCode);
- }
- debug("MDCompleteWorkManager threw WorkContextErrorCodes = "
- + strErrorCode);
- } catch (Exception e) {
- debug(
- "got bad exception when testing for WorkContextErrorCodes.DUPLICATE_CONTEXTS");
- Debug.printDebugStack(e);
- }
- debug("leaving submitTICWork()");
- }
-
- private ExecutionContext startTx() {
- ExecutionContext ec = new ExecutionContext();
- try {
- Xid xid = new XidImpl();
- ec.setXid(xid);
- ec.setTransactionTimeout(5 * 1000); // 5 seconds
- } catch (Exception ex) {
- Debug.printDebugStack(ex);
- }
- return ec;
- }
-
- public void debug(String out) {
- Debug.trace("MDCompleteWorkManager: " + out);
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/mdcomplete/TSNestedSecurityContext.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/mdcomplete/TSNestedSecurityContext.java
deleted file mode 100755
index 65cf5197b2..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/mdcomplete/TSNestedSecurityContext.java
+++ /dev/null
@@ -1,388 +0,0 @@
-/*
- * Copyright (c) 2008, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.common.connector.whitebox.mdcomplete;
-
-import java.io.IOException;
-import java.security.Principal;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.security.auth.Subject;
-import javax.security.auth.callback.Callback;
-import javax.security.auth.callback.CallbackHandler;
-import javax.security.auth.callback.UnsupportedCallbackException;
-
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-import com.sun.ts.tests.common.connector.whitebox.Debug;
-import com.sun.ts.tests.common.connector.whitebox.SimplePrincipal;
-
-import jakarta.resource.spi.work.SecurityContext;
-import jakarta.security.auth.message.callback.CallerPrincipalCallback;
-import jakarta.security.auth.message.callback.GroupPrincipalCallback;
-import jakarta.security.auth.message.callback.PasswordValidationCallback;
-
-/*
- * This is used to facilitate testing of the SecurityContext class.
- * The things to note/remember about this class are:
- * - there are two types of security scenarios RA's utilize for
- * passing creds: Case-1 and Case-2 security.
- * Case-1: use creds that are expected to exist on the Appserver
- * Case-2: set up mappings in appserver (to map EIS creds to AS creds)
- * then the RA can flow EIS creds to AS and let AS handle mappings.
- * - a RA can NOT do case-1 and case-2 at the same time. a RA must be
- * configured to do only ONE case at a time. (the configuration is usually
- * done by AS ina proprietary way. For RI(GFv3), Case-1 is default, and
- * Case-2 is done by specifying mapping in domain.xml.
- * - CPC *must* be called after GPC and PVC
- * - PVC *should* have same creds as CPC
- * - due to spec optimization, GPC can be called without CPC but this
- * is somewhat controversial and not recommended.
- *
- */
-public class TSNestedSecurityContext extends SecurityContext {
-
- private String userName; // server side username
-
- private String password; // server side pwd
-
- private String eisPrincipalName; // eis principal name
-
- private boolean translationRequired;
-
- private Subject subject;
-
- private String description;
-
- private String sicName;
-
- protected boolean expectPVCSuccess = true;
-
- // unlike TSSecurityContext, we want these all enabled by default
- private boolean useCPC = true;
-
- private boolean useGPC = true;
-
- private boolean usePVC = true;
-
- public TSNestedSecurityContext(String userName, String password,
- String eisPrincipalName, boolean translationRequired) {
- this(userName, password, eisPrincipalName, translationRequired, true);
- }
-
- public TSNestedSecurityContext(String userName, String password,
- String eisPrincipalName, boolean translationRequired,
- boolean expectSuccess) {
- this.userName = userName;
- this.password = password;
- this.eisPrincipalName = eisPrincipalName;
- this.translationRequired = translationRequired;
-
- this.sicName = super.getName();
- this.description = super.getDescription();
- this.expectPVCSuccess = expectSuccess;
- }
-
- public void setCallbacks(boolean bCPC, boolean bGPC, boolean bPVC) {
- this.useCPC = bCPC;
- this.useGPC = bGPC;
- this.usePVC = bPVC;
- }
-
- public void setUserName(String val) {
- this.userName = val;
- }
-
- public String getUserName() {
- return this.userName;
- }
-
- public void setDescription(String val) {
- this.description = val;
- }
-
- public String getDescription() {
- return this.description;
- }
-
- public void setName(String val) {
- this.sicName = val;
- }
-
- public String getName() {
- return this.sicName;
- }
-
- public void setUseCPC(boolean val) {
- this.useCPC = val;
- }
-
- public boolean getUseCPC() {
- return this.useCPC;
- }
-
- public void setUseGPC(boolean val) {
- this.useGPC = val;
- }
-
- public boolean getUseGPC() {
- return this.useGPC;
- }
-
- public void setUsePVC(boolean val) {
- this.usePVC = val;
- }
-
- public boolean getUsePVC() {
- return this.usePVC;
- }
-
- public boolean isTranslationRequired() {
- return translationRequired;
- }
-
- /*
- * This is used to help verify assertion Connector:SPEC:229, which states a
- * couple requirements with the following being focused on within this method:
- * "The following conditions are applicable to the application server provider
- * while calling the setupSecurityContext method: the CallbackHandler
- * implementation passed as the argument handler to setupSecurityContext must
- * support the following JSR-196 Callbacks: CallerPrincipalCallback,
- * GroupPrincipalCallback, and PasswordValidationCallback"
- *
- */
- public void doCallbackVerification(CallbackHandler callbackHandler,
- Subject execSubject, Subject serviceSubject, Principal principal) {
- List callbacks = new ArrayList();
-
- debug("in doCallbackVerification() " + " translationRequired="
- + translationRequired + " expectPVCSuccess=" + expectPVCSuccess);
-
- GroupPrincipalCallback gpc = null;
- String[] gpcGroups = { "phakegrp1", "phakegrp2" };
- if (useGPC) {
- // we are passing invalid grps to the GPC but it should not
- // matter if the CPC is specified after the GPC.
- debug("doCallbackVerification(): initializing PVC");
- gpc = new GroupPrincipalCallback(execSubject, gpcGroups);
- debug("GPC with groups={phakegrp1, phakegrp2} ");
- callbacks.add(gpc);
- }
-
- PasswordValidationCallback pvc = null;
- if (usePVC && !translationRequired) {
- // per JCA 1.6 spec (16.4.2) PVC can be used in Case-1 only.
- // NOTE: PVC user should match that of CPC
- debug("doCallbackVerification(): initializing PVC");
- char[] pwd = null;
- if (password != null) {
- // if password is supplied - use that first
- pwd = password.toCharArray();
- }
-
- if (userName != null) {
- // if userName is supplied - use that first
- pvc = new PasswordValidationCallback(execSubject, userName, pwd);
- debug("setting PVC with user [ " + userName + " ] + password [ "
- + password + " ]");
- } else {
- // null username - likely a problem if here.
- pvc = new PasswordValidationCallback(execSubject, null, pwd);
- debug("setting PVC with user=null + password [ " + password + " ]");
- }
- callbacks.add(pvc);
- }
-
- CallerPrincipalCallback cpc = null;
- if (usePVC || useCPC) {
- execSubject.getPrincipals().add(new SimplePrincipal(userName, password));
- debug("setting CPC with userName : " + userName + " pwd = " + password);
- cpc = new CallerPrincipalCallback(execSubject, userName);
-
- callbacks.add(cpc);
- }
-
- Callback callbackArray[] = new Callback[callbacks.size()];
- try {
- callbackHandler.handle(callbacks.toArray(callbackArray));
-
- // if we made it here, then no exceptions - we can assume success since
- // we got no unsupported callback exceptions.
- String sval = "setupSecurityContext callbackhandler supports required callback types.";
- debug(sval);
-
- if ((pvc != null) && (!pvc.getResult())) {
- sval = "Password validation callback failure for userName = "
- + userName;
- debug(sval);
- if (this.expectPVCSuccess) {
- String str = "ERROR: got unexpected PVC failed for user " + userName;
- debug(str);
- throw new Error(str);
- } else {
- // NOTE: if here - we expected to fail and it happened - this is good!
- String str = "TSNestedSecurityContext expected PVC failure and got it.";
- ConnectorStatus.getConnectorStatus().logState(str);
- debug(str);
- }
- } else {
- // this file is designed so that we *should* be getting a pvc failure
- // back but
- // if we are in here, it implies we had something go wrong.
- if (pvc == null) {
- debug("ERROR : pvc = null but should have be non-null");
- debug("usePVC = " + usePVC);
- } else {
- debug("ERROR : pvc.getResult()=" + pvc.getResult());
- debug("usePVC = " + usePVC);
- }
- }
-
- } catch (UnsupportedCallbackException e) {
- String sval = "setupSecurityContext() callbackhandler does not support a required callback type!";
- debug("doCallbackVerification(): " + sval);
- debug("UnsupportedCallbackException message is : " + e.getMessage());
- e.printStackTrace();
-
- } catch (IOException e) {
- e.printStackTrace();
- debug("doCallbackVerification(): exception occured : " + e.getMessage());
- }
-
- }
-
- public void setupSecurityContext(CallbackHandler callbackHandler,
- Subject execSubject, Subject serviceSubject) {
-
- // validate args are spec compliant
- validateCallbackHandler(callbackHandler);
- validateExecSubject(execSubject);
- validateServiceSubject(serviceSubject);
-
- Principal principal = null;
- if (translationRequired && (eisPrincipalName != null)) {
- // add eis principal that needs a security mapping in app server domain
- principal = new SimplePrincipal(eisPrincipalName);
- debug(
- "setupSecurityContext(): translationRequired && (eisPrincipalName != null)");
- } else if (!translationRequired && (userName != null)) {
- // add principal that exists in App Server Security domain
- principal = new SimplePrincipal(userName);
- debug(
- "setupSecurityContext(): !translationRequired && (userName != null)");
- }
-
- // assist with assertion Connector:SPEC:229
- if (callbackHandler != null) {
- String str = "setupSecurityContext() called with non-null callbackHandler";
- debug(str);
-
- // now make sure the 3 callback types are supported by the App Server
- doCallbackVerification(callbackHandler, execSubject, serviceSubject,
- principal);
-
- } else {
- debug(
- "setupSecurityContext() called with invalid (null) callbackHandler");
- }
-
- }
-
- /*
- * this method is used to perform a simple validation that the callbackHandler
- * is spec compliant per assertion Connector:SPEC:229
- */
- private void validateCallbackHandler(CallbackHandler callbackHandler) {
-
- // assist with assertion Connector:SPEC:229
- if (callbackHandler != null) {
- String str = "setupSecurityContext() called with non-null callbackHandler";
- debug(str);
- } else {
- String str = "setupSecurityContext() called with invalid (null) callbackHandler";
- debug(str);
- }
- }
-
- /*
- * this method is used to perform a simple validation that the execSubject is
- * spec compliant per assertion Connector:SPEC:230
- */
- private void validateExecSubject(Subject execSubject) {
-
- if ((execSubject != null) && (!execSubject.isReadOnly())) {
- String str = "setupSecurityContext() called with valid executionSubject";
- debug(str);
- } else {
- String str = "ERROR: setupSecurityContext() called with invalid executionSubject";
- debug(str);
- }
-
- }
-
- /*
- * this method is used to perform a simple validation that the serviceSubject
- * is spec compliant per assertion Connector:SPEC:231
- */
- private void validateServiceSubject(Subject serviceSubject) {
-
- if ((serviceSubject != null) && (!serviceSubject.isReadOnly())) {
- // this is good: if serviceSubject != null, then it must not be readonly
- String str = "setupSecurityContext() called with valid serviceSubject";
- debug(str);
- } else if ((serviceSubject != null) && (serviceSubject.isReadOnly())) {
- // ohoh, serviceSubject !=null but it is readonly and this is not valid!
- String str = "setupSecurityContext() called with invalid executionSubject";
- debug(str);
- } else if (serviceSubject == null) {
- // invalid serviceSubject called - according to API doc -it cant be null
- String str = "ERROR - setupSecurityContext() called with null serviceSubject.";
- } else {
- // this is also a valid serviceSubject for our setupSecurityContext()
- String str = "setupSecurityContext() called with valid serviceSubject";
- debug(str);
- }
-
- }
-
- public Subject getSubject() {
- if (translationRequired) {
- if (subject == null) {
- // setting translation required for principal
- subject = new Subject();
- subject.getPrincipals().add(new SimplePrincipal(eisPrincipalName));
- }
- return subject;
- } else {
- return null;
- }
- }
-
- public String toString() {
- StringBuffer toString = new StringBuffer("{");
- toString.append("userName : " + userName);
- toString.append(", password : " + password);
- toString.append(", eisPrincipalName : " + eisPrincipalName);
- toString.append(", translationRequired : " + translationRequired);
- toString.append("}");
- return toString.toString();
- }
-
- public void debug(String message) {
- Debug.trace(" in TSNestedSecurityContext: " + message);
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/mixedmode/PMDManagedConnectionFactory.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/mixedmode/PMDManagedConnectionFactory.java
deleted file mode 100644
index d2e7befac7..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/mixedmode/PMDManagedConnectionFactory.java
+++ /dev/null
@@ -1,413 +0,0 @@
-/*
- * Copyright (c) 2009, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.common.connector.whitebox.mixedmode;
-
-import java.io.PrintWriter;
-import java.io.Serializable;
-import java.util.Iterator;
-import java.util.Set;
-
-import javax.security.auth.Subject;
-
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-import com.sun.ts.tests.common.connector.whitebox.Debug;
-import com.sun.ts.tests.common.connector.whitebox.TSConnection;
-import com.sun.ts.tests.common.connector.whitebox.TSConnectionImpl;
-import com.sun.ts.tests.common.connector.whitebox.TSEISDataSource;
-import com.sun.ts.tests.common.connector.whitebox.TSManagedConnection;
-import com.sun.ts.tests.common.connector.whitebox.Util;
-
-import jakarta.resource.ResourceException;
-import jakarta.resource.spi.ConfigProperty;
-import jakarta.resource.spi.ConnectionDefinition;
-import jakarta.resource.spi.ConnectionManager;
-import jakarta.resource.spi.ConnectionRequestInfo;
-import jakarta.resource.spi.EISSystemException;
-import jakarta.resource.spi.ManagedConnection;
-import jakarta.resource.spi.ManagedConnectionFactory;
-import jakarta.resource.spi.ResourceAdapter;
-import jakarta.resource.spi.ResourceAdapterAssociation;
-import jakarta.resource.spi.security.PasswordCredential;
-
-@ConnectionDefinition(connectionFactory = com.sun.ts.tests.common.connector.whitebox.TSConnectionFactory.class, connectionFactoryImpl = com.sun.ts.tests.common.connector.whitebox.TSEISDataSource.class, connection = com.sun.ts.tests.common.connector.whitebox.TSConnection.class, connectionImpl = com.sun.ts.tests.common.connector.whitebox.TSEISConnection.class)
-
-public class PMDManagedConnectionFactory implements ManagedConnectionFactory,
- ResourceAdapterAssociation, Serializable, jakarta.resource.Referenceable {
- private javax.naming.Reference reference;
-
- private ResourceAdapter resourceAdapter;
-
- private int count;
-
- private String password;
-
- private String user;
-
- private String userName;
-
- @ConfigProperty(defaultValue = "PMDManagedConnectionFactory", description = "String value", ignore = false, supportsDynamicUpdates = false, confidential = false)
- String factoryName;
-
- @ConfigProperty(description = "String value", ignore = false)
- String noDefaultValue = "NO_DEFAULT_VAL";
-
- /*
- * @name PMDManagedConnectionFactory
- *
- * @desc Default conctructor
- */
- public PMDManagedConnectionFactory() {
- }
-
- public void setFactoryName(String name) {
- // this helps verify assertion Connector:SPEC:307 and Connector:SPEC:267
- // and this behavior is described in connector 1.6 spec section 18.5
- String str = "PMDManagedConnectionFactory factoryname=" + name;
- ConnectorStatus.getConnectorStatus().logState(str);
- debug(str);
-
- this.factoryName = name;
-
- // this helps verify assertion Connector:SPEC:277
- // and this behavior is described in connector 1.6 spec section 18.5
- str = "PMDManagedConnectionFactory noDefaultValue=" + this.noDefaultValue;
- ConnectorStatus.getConnectorStatus().logState(str);
- debug(str);
- }
-
- public String getFactoryName() {
- return factoryName;
- }
-
- public void setNoDefaultValue(String val) {
- this.noDefaultValue = val;
- }
-
- public String getNoDefaultValue() {
- return noDefaultValue;
- }
-
- public String getUser() {
- debug("PMDManagedConnectionFactory.getUser() returning: " + user);
- return user;
- }
-
- public void setUser(String val) {
- debug("PMDManagedConnectionFactory.setUser() with val = " + val);
- user = val;
- }
-
- public String getUserName() {
- debug("PMDManagedConnectionFactory.getUserName() returning: " + userName);
- return userName;
- }
-
- public void setUserName(String val) {
- debug("PMDManagedConnectionFactory.setUserName() with val = " + val);
- userName = val;
- }
-
- public String getPassword() {
- debug("PMDManagedConnectionFactory.getPassword() returning: " + password);
- return password;
- }
-
- public void setPassword(String val) {
- debug("PMDManagedConnectionFactory.setPassword() with val = " + val);
- password = val;
- }
-
- /*
- * @name createConnectionFactory
- *
- * @desc Creates a new connection factory instance
- *
- * @param ConnectionManager
- *
- * @return Object
- *
- * @exception ResourceException
- */
- public Object createConnectionFactory(ConnectionManager cxManager)
- throws ResourceException {
- ConnectorStatus.getConnectorStatus().logAPI(
- "PMDManagedConnectionFactory.createConnectionFactory", "cxManager",
- "TSEISDataSource");
- return new TSEISDataSource(this, cxManager);
- }
-
- /*
- * @name createConnectionFactory
- *
- * @desc Creates a new connection factory instance
- *
- * @return Object
- *
- * @exception ResourceException
- */
- public Object createConnectionFactory() throws ResourceException {
- ConnectorStatus.getConnectorStatus().logAPI(
- "PMDManagedConnectionFactory.createConnectionFactory", "",
- "TSEISDataSource");
- return new TSEISDataSource(this, null);
- }
-
- /*
- * @name setResourceAdapter
- *
- * @desc sets the Resource Adapter for this ManagedConnectionFactory
- *
- * @return
- *
- * @exception ResourceException
- */
- public void setResourceAdapter(ResourceAdapter ra) throws ResourceException {
- count++;
- String newStr1 = new String(
- "PMDManagedConnectionFactory setResourceAdapter " + count);
- debug(newStr1);
- this.resourceAdapter = ra;
- }
-
- /*
- * @name getResourceAdapter
- *
- * @desc gets the Resource Adapter for this ManagedConnectionFactory
- *
- * @return Object
- *
- * @exception ResourceException
- */
- public ResourceAdapter getResourceAdapter() {
- debug("PMDManagedConnectionFactory.getResource");
- return resourceAdapter;
- }
-
- /*
- * @name createManagedConnection
- *
- * @desc Creates a new managed connection to the underlying EIS
- *
- * @param Subject, ConnectionRequestInfo
- *
- * @return ManagedConnection
- *
- * @exception ResourceException
- */
- public ManagedConnection createManagedConnection(Subject subject,
- ConnectionRequestInfo info) throws ResourceException {
-
- try {
-
- ConnectorStatus.getConnectorStatus().logAPI(
- "PMDManagedConnectionFactory.createManagedConnection", "subject|info",
- "TSManagedConnection");
- TSConnection con = null;
- PasswordCredential pc = Util.getPasswordCredential(this, subject, info);
- if (pc == null) {
- debug(
- "PMDManagedConnectionFactory.createManagedConnection(): pc == null");
- debug("TSConnectionImpl.getConnection()");
- con = new TSConnectionImpl().getConnection();
- } else {
- debug(
- "PMDManagedConnectionFactory.createManagedConnection(): pc != null");
- setUser(pc.getUserName());
- setUserName(pc.getUserName());
- setPassword(new String(pc.getPassword()));
- debug("TSConnectionImpl.getConnection(u,p)");
- con = new TSConnectionImpl().getConnection(pc.getUserName(),
- pc.getPassword());
- }
- ManagedConnection mcon = new TSManagedConnection(this, pc, null, con,
- false, true);
-
- return mcon;
- } catch (Exception ex) {
- ResourceException re = new EISSystemException(
- "Exception: " + ex.getMessage());
- re.initCause(ex);
- throw re;
- }
-
- }
-
- /*
- * @name matchManagedConnection
- *
- * @desc Return the existing connection from the connection pool
- *
- * @param Set, Subject, ConnectionRequestInfo
- *
- * @return ManagedConnection
- *
- * @exception ResourceException
- */
- public ManagedConnection matchManagedConnections(Set connectionSet,
- Subject subject, ConnectionRequestInfo info) throws ResourceException {
- ConnectorStatus.getConnectorStatus().logAPI(
- "PMDManagedConnectionFactory.matchManagedConnection",
- "connectionSet|subject|info", "TSEISDataSource");
-
- PasswordCredential pc = Util.getPasswordCredential(this, subject, info);
- Iterator it = connectionSet.iterator();
-
- while (it.hasNext()) {
- Object obj = it.next();
- if (obj instanceof TSManagedConnection) {
- TSManagedConnection mc = (TSManagedConnection) obj;
- ManagedConnectionFactory mcf = mc.getManagedConnectionFactory();
- if (Util.isPasswordCredentialEqual(mc.getPasswordCredential(), pc)
- && (mcf != null) && mcf.equals(this)) {
- return mc;
- }
- }
- }
-
- return null;
- }
-
- /*
- * @name setLogWriter
- *
- * @desc Sets the Print Writer
- *
- * @param PrintWriter
- *
- * @exception ResourceException
- */
- public void setLogWriter(PrintWriter out) throws ResourceException {
- }
-
- /*
- * @name getLogWriter
- *
- * @desc Gets the Print Writer
- *
- * @return PrintWriter
- *
- * @exception ResourceException
- */
- public PrintWriter getLogWriter() throws ResourceException {
- return null;
- }
-
- /*
- * @name equals
- *
- * @desc Compares the given object to the ManagedConnectionFactory instance.
- *
- * @param Object
- *
- * @return boolean
- */
- public boolean equals(Object obj) {
-
- if ((obj == null) || !(obj instanceof PMDManagedConnectionFactory)) {
- return false;
- }
- if (obj == this) {
- return true;
- }
-
- PMDManagedConnectionFactory that = (PMDManagedConnectionFactory) obj;
-
- if ((this.reference != null)
- && !(this.reference.equals(that.getReference()))) {
- return false;
- } else if ((this.reference == null) && !(that.getReference() == null)) {
- return false;
- }
-
- if ((this.resourceAdapter != null)
- && !(this.resourceAdapter.equals(that.getResourceAdapter()))) {
- return false;
- } else if ((this.resourceAdapter == null)
- && !(that.getResourceAdapter() == null)) {
- return false;
- }
-
- if (this.count != that.getCount()) {
- return false;
- }
-
- if (!Util.isEqual(this.password, that.getPassword()))
- return false;
-
- if (!Util.isEqual(this.user, that.getUser()))
- return false;
-
- if (!Util.isEqual(this.userName, that.getUserName()))
- return false;
-
- if (!Util.isEqual(this.factoryName, that.getFactoryName()))
- return false;
-
- if (!Util.isEqual(this.noDefaultValue, that.getNoDefaultValue()))
- return false;
-
- return true;
- }
-
- /*
- * @name hashCode
- *
- * @desc Gives a hash value to a ManagedConnectionFactory Obejct.
- *
- * @return int
- */
- public int hashCode() {
- return this.getClass().getName().hashCode();
- }
-
- /*
- * @name getReference
- *
- * @desc Gives the reference of the class
- *
- * @return javax.naming.Reference
- */
- public javax.naming.Reference getReference() {
- javax.naming.Reference ref;
-
- ref = this.reference;
- return ref;
- }
-
- /*
- * @name setReference
- *
- * @desc sets the reference of the class
- *
- * @param javax.naming.Reference
- */
- public void setReference(javax.naming.Reference ref) {
- this.reference = ref;
- }
-
- public void debug(String out) {
- Debug.trace("PMDManagedConnectionFactory: " + out);
- }
-
- public int getCount() {
- return this.count;
- }
-
- public void setCount(int val) {
- this.count = val;
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/mixedmode/PMDResourceAdapterImpl.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/mixedmode/PMDResourceAdapterImpl.java
deleted file mode 100755
index aaaa0f454d..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/mixedmode/PMDResourceAdapterImpl.java
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * Copyright (c) 2009, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.common.connector.whitebox.mixedmode;
-
-import javax.transaction.xa.XAResource;
-
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-import com.sun.ts.tests.common.connector.whitebox.Debug;
-import com.sun.ts.tests.common.connector.whitebox.Util;
-
-import jakarta.resource.NotSupportedException;
-import jakarta.resource.ResourceException;
-import jakarta.resource.spi.ActivationSpec;
-import jakarta.resource.spi.AuthenticationMechanism;
-import jakarta.resource.spi.BootstrapContext;
-import jakarta.resource.spi.ConfigProperty;
-import jakarta.resource.spi.Connector;
-import jakarta.resource.spi.ResourceAdapter;
-import jakarta.resource.spi.ResourceAdapterInternalException;
-import jakarta.resource.spi.SecurityPermission;
-import jakarta.resource.spi.TransactionSupport;
-import jakarta.resource.spi.endpoint.MessageEndpointFactory;
-import jakarta.resource.spi.work.HintsContext;
-import jakarta.resource.spi.work.SecurityContext;
-import jakarta.resource.spi.work.Work;
-import jakarta.resource.spi.work.WorkManager;
-
-/**
- * This is a sample resource adapter that will use some ra.xml info. This RA is
- * used to assist with verifying the server supports annotations when there is
- * no ra.xml (Assertion 268) and the transaction support is Local.
- *
- */
-
-@Connector(description = "CTS Test Resource Adapter with No DD", licenseDescription = "CTS License Required", licenseRequired = true, authMechanisms = @AuthenticationMechanism(credentialInterface = AuthenticationMechanism.CredentialInterface.PasswordCredential, authMechanism = "BasicPassword", description = "Basic Password Authentication"), reauthenticationSupport = false, securityPermissions = @SecurityPermission(), transactionSupport = TransactionSupport.TransactionSupportLevel.NoTransaction, requiredWorkContexts = {
- HintsContext.class, SecurityContext.class })
-public class PMDResourceAdapterImpl
- implements ResourceAdapter, java.io.Serializable {
-
- private transient BootstrapContext bsc;
-
- private transient PMDWorkManager pwm;
-
- private transient WorkManager wm;
-
- private transient Work work;
-
- // this should cause the setter to get invoked
- @ConfigProperty(defaultValue = "PartialMDResourceAdapter", description = "String value", ignore = false)
- String raName;
-
- @ConfigProperty(defaultValue = "VAL_FROM_ANNOTATION", description = "String value", ignore = false)
- String overRide;
-
- String mdPropOnly;
-
- /**
- * constructor
- **/
- public PMDResourceAdapterImpl() {
- debug("enterred constructor...");
-
- debug("leaving constructor...");
- }
-
- //
- // Begin ResourceAdapter interface requirements
- //
-
- /* must implement for ResourceAdapter interface requirement */
- public void start(BootstrapContext bsc)
- throws ResourceAdapterInternalException {
- debug("enterred start");
- debug("PMDResourceAdapterImpl.start called");
-
- this.bsc = bsc;
- this.wm = bsc.getWorkManager();
-
- this.pwm = new PMDWorkManager(bsc);
- pwm.runTests();
-
- debug("leaving start");
- }
-
- /* must implement for ResourceAdapter interface requirement */
- public void stop() {
- debug("entered stop");
- debug("leaving stop");
- }
-
- /* must implement for ResourceAdapter interface requirement */
- public void endpointActivation(MessageEndpointFactory factory,
- ActivationSpec spec) throws NotSupportedException {
-
- debug("enterred endpointActivation");
- debug("leaving endpointActivation");
- }
-
- /* must implement for ResourceAdapter interface requirement */
- public void endpointDeactivation(MessageEndpointFactory ep,
- ActivationSpec spec) {
- debug("enterred endpointDeactivation");
- debug("leaving endpointDeactivation");
- }
-
- /* must implement for ResourceAdapter interface requirement */
- public XAResource[] getXAResources(ActivationSpec[] specs)
- throws ResourceException {
-
- debug("enterred getXAResources");
- debug("leaving getXAResources");
-
- throw new UnsupportedOperationException();
- }
-
- //
- // END ResourceAdapter interface requirements
- //
-
- /*
- * this is the setter for the ConfigProperty annotation = raName. According to
- * onnector 1.6 spec, section 18.5, this setter must be invoked since it
- * belongs to a ConfigProperty annotation for the ResourceAdapter JavaBean.
- */
- public void setRaName(String name) {
- this.raName = name;
-
- // this helps verify assertion Connector:SPEC:279
- String str = "setRAName called with raname=" + raName;
- debug(str);
- ConnectorStatus.getConnectorStatus().logState(str);
- }
-
- public String getRaName() {
- return raName;
- }
-
- public void setOverRide(String name) {
-
- // this is used to help test behavior is described in connector1.6
- // spec in section 18.3.2 - where the ConfigProperty specified in the DD
- // file
- // should override the ConfigProperty in this file.
- String str = "PMDResourceAdapterImpl overRide=" + name;
- ConnectorStatus.getConnectorStatus().logState(str);
- debug(str);
-
- this.overRide = name;
- }
-
- public String getOverRide() {
- return overRide;
- }
-
- public void setMdPropOnly(String name) {
-
- // this is used to help test assertion Connector:SPEC:273
- String str = "PMDResourceAdapterImpl mdPropOnly=" + name;
- debug(str);
-
- this.mdPropOnly = name;
- }
-
- public String getMdPropOnly() {
- return mdPropOnly;
- }
-
- /*
- * @name equals
- *
- * @desc Compares the given object to the ManagedConnectionFactory instance.
- *
- * @param Object
- *
- * @return boolean
- */
- public boolean equals(Object obj) {
-
- if ((obj == null) || !(obj instanceof PMDResourceAdapterImpl)) {
- return false;
- }
- if (obj == this) {
- return true;
- }
-
- PMDResourceAdapterImpl that = (PMDResourceAdapterImpl) obj;
-
- if (!Util.isEqual(this.mdPropOnly, that.getMdPropOnly()))
- return false;
-
- if (!Util.isEqual(this.overRide, that.getOverRide()))
- return false;
-
- if (!Util.isEqual(this.raName, that.getRaName()))
- return false;
-
- return true;
- }
-
- /*
- * @name hashCode
- *
- * @desc Gives a hash value to a ManagedConnectionFactory Obejct.
- *
- * @return int
- */
- public int hashCode() {
- return this.getClass().getName().hashCode();
- }
-
- public void debug(String out) {
- Debug.trace("PMDResourceAdapterImpl: " + out);
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/mixedmode/PMDWorkManager.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/mixedmode/PMDWorkManager.java
deleted file mode 100644
index 968cde370d..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/mixedmode/PMDWorkManager.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 2009, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.common.connector.whitebox.mixedmode;
-
-import com.sun.ts.lib.util.TestUtil;
-import com.sun.ts.tests.common.connector.whitebox.Debug;
-import com.sun.ts.tests.common.connector.whitebox.WorkImpl;
-import com.sun.ts.tests.common.connector.whitebox.WorkListenerImpl;
-
-import jakarta.resource.spi.BootstrapContext;
-import jakarta.resource.spi.work.ExecutionContext;
-import jakarta.resource.spi.work.WorkException;
-import jakarta.resource.spi.work.WorkManager;
-
-public class PMDWorkManager {
- private BootstrapContext bsc = null;
-
- private WorkManager wmgr;
-
- private String sicUser = "";
-
- private String sicPwd = "";
-
- private String eisUser = "";
-
- public PMDWorkManager(BootstrapContext val) {
- debug("enterred constructor");
- this.bsc = val;
- this.wmgr = bsc.getWorkManager();
-
- this.sicUser = TestUtil.getSystemProperty("j2eelogin.name");
- this.sicPwd = TestUtil.getSystemProperty("j2eelogin.password");
- this.eisUser = TestUtil.getSystemProperty("eislogin.name");
- debug("leaving constructor");
- }
-
- public void runTests() {
- debug("enterred runTests");
- doWork();
- debug("leaving runTests");
- }
-
- public void doWork() {
- debug("enterred doWork");
-
- try {
- WorkImpl workimpl = new WorkImpl(wmgr);
-
- ExecutionContext ec = new ExecutionContext();
- WorkListenerImpl wl = new WorkListenerImpl();
- wmgr.doWork(workimpl, 5000, ec, wl);
- debug("PMDWorkManager Work Object Submitted");
- } catch (WorkException we) {
- System.out
- .println("PMDWorkManager WorkException thrown is " + we.getMessage());
- } catch (Exception ex) {
- System.out
- .println("PMDWorkManager Exception thrown is " + ex.getMessage());
- }
-
- debug("leaving doWork");
- }
-
- public void debug(String out) {
- Debug.trace("PMDWorkManager: " + out);
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/multianno/MAManagedConnectionFactory.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/multianno/MAManagedConnectionFactory.java
deleted file mode 100644
index 923bd0cee9..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/multianno/MAManagedConnectionFactory.java
+++ /dev/null
@@ -1,356 +0,0 @@
-/*
- * Copyright (c) 2009, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.common.connector.whitebox.multianno;
-
-import java.io.PrintWriter;
-import java.io.Serializable;
-import java.util.Iterator;
-import java.util.Set;
-
-import javax.security.auth.Subject;
-
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-import com.sun.ts.tests.common.connector.whitebox.Debug;
-import com.sun.ts.tests.common.connector.whitebox.TSConnection;
-import com.sun.ts.tests.common.connector.whitebox.TSConnectionImpl;
-import com.sun.ts.tests.common.connector.whitebox.TSEISDataSource;
-import com.sun.ts.tests.common.connector.whitebox.TSManagedConnection;
-import com.sun.ts.tests.common.connector.whitebox.Util;
-
-import jakarta.resource.ResourceException;
-import jakarta.resource.spi.ConnectionManager;
-import jakarta.resource.spi.ConnectionRequestInfo;
-import jakarta.resource.spi.EISSystemException;
-import jakarta.resource.spi.ManagedConnection;
-import jakarta.resource.spi.ManagedConnectionFactory;
-import jakarta.resource.spi.ResourceAdapter;
-import jakarta.resource.spi.ResourceAdapterAssociation;
-import jakarta.resource.spi.security.PasswordCredential;
-
-public class MAManagedConnectionFactory implements ManagedConnectionFactory,
- ResourceAdapterAssociation, Serializable, jakarta.resource.Referenceable {
- private javax.naming.Reference reference;
-
- private ResourceAdapter resourceAdapter;
-
- private int count;
-
- private String password;
-
- private String user;
-
- private String userName;
-
- /*
- * @name MAManagedConnectionFactory
- *
- * @desc Default conctructor
- */
- public MAManagedConnectionFactory() {
-
- }
-
- public String getUser() {
- return user;
- }
-
- public void setUser(String val) {
- user = val;
- }
-
- public String getUserName() {
- return userName;
- }
-
- public void setUserName(String val) {
- userName = val;
- }
-
- public String getPassword() {
- return password;
- }
-
- public void setPassword(String val) {
- password = val;
- }
-
- /*
- * @name createConnectionFactory
- *
- * @desc Creates a new connection factory instance
- *
- * @param ConnectionManager
- *
- * @return Object
- *
- * @exception ResourceException
- */
- public Object createConnectionFactory(ConnectionManager cxManager)
- throws ResourceException {
- ConnectorStatus.getConnectorStatus().logAPI(
- "MAManagedConnectionFactory.createConnectionFactory", "cxManager",
- "TSEISDataSource");
- return new TSEISDataSource(this, cxManager);
- }
-
- /*
- * @name createConnectionFactory
- *
- * @desc Creates a new connection factory instance
- *
- * @return Object
- *
- * @exception ResourceException
- */
- public Object createConnectionFactory() throws ResourceException {
- ConnectorStatus.getConnectorStatus().logAPI(
- "MAManagedConnectionFactory.createConnectionFactory", "",
- "TSEISDataSource");
- return new TSEISDataSource(this, null);
- }
-
- /*
- * @name setResourceAdapter
- *
- * @desc sets the Resource Adapter for this ManagedConnectionFactory
- *
- * @return
- *
- * @exception ResourceException
- */
- public void setResourceAdapter(ResourceAdapter ra) throws ResourceException {
- count++;
- String newStr1 = new String(
- "MAManagedConnectionFactory setResourceAdapter " + count);
- debug(newStr1);
- this.resourceAdapter = ra;
- }
-
- /*
- * @name getResourceAdapter
- *
- * @desc gets the Resource Adapter for this ManagedConnectionFactory
- *
- * @return Object
- *
- * @exception ResourceException
- */
- public ResourceAdapter getResourceAdapter() {
- debug("MAManagedConnectionFactory.getResource");
- return resourceAdapter;
- }
-
- /*
- * @name createManagedConnection
- *
- * @desc Creates a new managed connection to the underlying EIS
- *
- * @param Subject, ConnectionRequestInfo
- *
- * @return ManagedConnection
- *
- * @exception ResourceException
- */
- public ManagedConnection createManagedConnection(Subject subject,
- ConnectionRequestInfo info) throws ResourceException {
-
- try {
-
- ConnectorStatus.getConnectorStatus().logAPI(
- "MAManagedConnectionFactory.createManagedConnection", "subject|info",
- "TSManagedConnection");
- TSConnection con = null;
- PasswordCredential pc = Util.getPasswordCredential(this, subject, info);
- if (pc == null) {
- debug(
- "MAManagedConnectionFactory.createManagedConnection(): pc == null");
- debug("TSConnectionImpl.getConnection()");
- con = new TSConnectionImpl().getConnection();
- } else {
- debug(
- "MAManagedConnectionFactory.createManagedConnection(): pc != null");
- setUser(pc.getUserName());
- setUserName(pc.getUserName());
- setPassword(new String(pc.getPassword()));
- debug("TSConnectionImpl.getConnection(u,p)");
- con = new TSConnectionImpl().getConnection(pc.getUserName(),
- pc.getPassword());
- }
- return new TSManagedConnection(this, pc, null, con, false, true);
- } catch (Exception ex) {
- ResourceException re = new EISSystemException(
- "Exception: " + ex.getMessage());
- re.initCause(ex);
- throw re;
- }
- }
-
- /*
- * @name matchManagedConnection
- *
- * @desc Return the existing connection from the connection pool
- *
- * @param Set, Subject, ConnectionRequestInfo
- *
- * @return ManagedConnection
- *
- * @exception ResourceException
- */
- public ManagedConnection matchManagedConnections(Set connectionSet,
- Subject subject, ConnectionRequestInfo info) throws ResourceException {
- ConnectorStatus.getConnectorStatus().logAPI(
- "MAManagedConnectionFactory.matchManagedConnection",
- "connectionSet|subject|info", "TSEISDataSource");
- PasswordCredential pc = Util.getPasswordCredential(this, subject, info);
- Iterator it = connectionSet.iterator();
- while (it.hasNext()) {
- Object obj = it.next();
- if (obj instanceof TSManagedConnection) {
- TSManagedConnection mc = (TSManagedConnection) obj;
- ManagedConnectionFactory mcf = mc.getManagedConnectionFactory();
- if (Util.isPasswordCredentialEqual(mc.getPasswordCredential(), pc)
- && (mcf != null) && mcf.equals(this)) {
- return mc;
- }
- }
- }
- return null;
- }
-
- /*
- * @name setLogWriter
- *
- * @desc Sets the Print Writer
- *
- * @param PrintWriter
- *
- * @exception ResourceException
- */
- public void setLogWriter(PrintWriter out) throws ResourceException {
- }
-
- /*
- * @name getLogWriter
- *
- * @desc Gets the Print Writer
- *
- * @return PrintWriter
- *
- * @exception ResourceException
- */
- public PrintWriter getLogWriter() throws ResourceException {
- return null;
- }
-
- /*
- * @name equals
- *
- * @desc Compares the given object to the ManagedConnectionFactory instance.
- *
- * @param Object
- *
- * @return boolean
- */
- public boolean equals(Object obj) {
-
- if ((obj == null) || !(obj instanceof MAManagedConnectionFactory)) {
- return false;
- }
- if (obj == this) {
- return true;
- }
-
- MAManagedConnectionFactory that = (MAManagedConnectionFactory) obj;
-
- if ((this.reference != null)
- && !(this.reference.equals(that.getReference()))) {
- return false;
- } else if ((this.reference == null) && !(that.getReference() == null)) {
- return false;
- }
-
- if ((this.resourceAdapter != null)
- && !(this.resourceAdapter.equals(that.getResourceAdapter()))) {
- return false;
- } else if ((this.resourceAdapter == null)
- && !(that.getResourceAdapter() == null)) {
- return false;
- }
-
- if (this.count != that.getCount()) {
- return false;
- }
-
- if (!Util.isEqual(this.password, that.getPassword()))
- return false;
-
- if (!Util.isEqual(this.user, that.getUser()))
- return false;
-
- if (!Util.isEqual(this.userName, that.getUserName()))
- return false;
-
- return true;
- }
-
- /*
- * @name hashCode
- *
- * @desc Gives a hash value to a ManagedConnectionFactory Obejct.
- *
- * @return int
- */
- public int hashCode() {
- return this.getClass().getName().hashCode();
- }
-
- /*
- * @name getReference
- *
- * @desc Gives the reference of the class
- *
- * @return javax.naming.Reference
- */
- public javax.naming.Reference getReference() {
- javax.naming.Reference ref;
- ref = this.reference;
- return ref;
- }
-
- /*
- * @name setReference
- *
- * @desc sets the reference of the class
- *
- * @param javax.naming.Reference
- */
- public void setReference(javax.naming.Reference ref) {
- this.reference = ref;
- }
-
- public int getCount() {
- return this.count;
- }
-
- public void setCount(int val) {
- this.count = val;
- }
-
- private void debug(String str) {
- Debug.trace(str);
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/multianno/MAResourceAdapterImpl.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/multianno/MAResourceAdapterImpl.java
deleted file mode 100644
index c4bf37d149..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/multianno/MAResourceAdapterImpl.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * Copyright (c) 2009, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.common.connector.whitebox.multianno;
-
-import java.io.Serializable;
-import java.lang.reflect.Method;
-
-import javax.transaction.xa.XAResource;
-
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-import com.sun.ts.tests.common.connector.whitebox.Debug;
-import com.sun.ts.tests.common.connector.whitebox.Util;
-
-import jakarta.resource.spi.ActivationSpec;
-import jakarta.resource.spi.BootstrapContext;
-import jakarta.resource.spi.ResourceAdapter;
-import jakarta.resource.spi.ResourceAdapterInternalException;
-import jakarta.resource.spi.endpoint.MessageEndpointFactory;
-import jakarta.resource.spi.work.Work;
-import jakarta.resource.spi.work.WorkManager;
-
-public class MAResourceAdapterImpl implements ResourceAdapter, Serializable {
- private String overRide = "default";
-
- private String raName;
-
- private int counter = 0;
-
- private transient WorkManager wm;
-
- private transient BootstrapContext bsc;
-
- public MAResourceAdapterImpl() {
- Debug.trace("MAResourceAdapterImpl Constructor ");
- }
-
- public void start(final BootstrapContext bsc)
- throws ResourceAdapterInternalException {
- // setup network endpoints
- counter++;
- this.bsc = bsc;
- String str1 = new String("MAResourceAdapterImpl Started " + counter);
- ConnectorStatus.getConnectorStatus().logState(str1);
-
- // get WorkManager reference
- wm = bsc.getWorkManager();
-
- try {
- checkAssociation();
- bsc.getWorkManager().startWork(new Work() {
- public void run() {
- myStart(bsc);
- }
-
- public void release() {
- }
-
- });
- } catch (jakarta.resource.spi.work.WorkException we) {
- throw new ResourceAdapterInternalException();
- }
-
- }
-
- private void myStart(final BootstrapContext ctx) {
- Debug.trace("MAResourceAdapterImpl.myStart ");
- }
-
- public void stop() {
- Debug.trace("MAResourceAdapterImpl.stop ");
- }
-
- public void endpointActivation(MessageEndpointFactory mef,
- ActivationSpec as) {
- Debug.trace("MAResourceAdapterImpl.endpointActivation ");
- }
-
- public XAResource[] getXAResources(ActivationSpec[] as) {
- Debug.trace("MAResourceAdapterImpl.getXAResources ");
- return null;
- }
-
- private Method getOnMessageMethod() {
- Debug.trace("MAResourceAdapterImpl.getOnMessageMethod ");
- Method onMessageMethod = null;
- return onMessageMethod;
- }
-
- private void chkUniqueMessageEndpointFactory() {
- Debug.trace("MAResourceAdapterImpl.chkUniqueMessageEndpointFactory");
- }
-
- public void checkAssociation() {
- Debug.trace("MAResourceAdapterImpl.checkAssociation");
- }
-
- public void endpointDeactivation(MessageEndpointFactory mef,
- ActivationSpec as) {
- Debug.trace("MAResourceAdapterImpl.endpointDeactivation ");
- }
-
- public void setRaName(String name) {
- Debug.trace("MAResourceAdapterImpl.setRAName");
- this.raName = name;
- }
-
- public String getRaName() {
- Debug.trace("MAResourceAdapterImpl.getRAName");
- return raName;
- }
-
- public void setOverRide(String val) {
- Debug.trace("MAResourceAdapterImpl.setOverRide = " + val);
- this.overRide = val;
- }
-
- public String getOverRide() {
- Debug.trace("MAResourceAdapterImpl.getOverRide");
- return overRide;
- }
-
- public void setCounter(int val) {
- this.counter = val;
- }
-
- public int getCounter() {
- return this.counter;
- }
-
- /*
- * @name equals
- *
- * @desc Compares the given object to the ManagedConnectionFactory instance.
- *
- * @param Object
- *
- * @return boolean
- */
- public boolean equals(Object obj) {
-
- if ((obj == null) || !(obj instanceof MAResourceAdapterImpl)) {
- return false;
- }
- if (obj == this) {
- return true;
- }
-
- MAResourceAdapterImpl that = (MAResourceAdapterImpl) obj;
-
- if (this.counter != that.getCounter()) {
- return false;
- }
-
- if (!Util.isEqual(this.raName, that.getRaName()))
- return false;
-
- if (!Util.isEqual(this.overRide, that.getOverRide()))
- return false;
-
- return true;
- }
-
- /*
- * @name hashCode
- *
- * @desc Gives a hash value to a ManagedConnectionFactory Obejct.
- *
- * @return int
- */
- public int hashCode() {
- return this.getClass().getName().hashCode();
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/multianno/OtherMCF.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/multianno/OtherMCF.java
deleted file mode 100644
index 6f545e5078..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/multianno/OtherMCF.java
+++ /dev/null
@@ -1,355 +0,0 @@
-/*
- * Copyright (c) 2009, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.common.connector.whitebox.multianno;
-
-import java.io.PrintWriter;
-import java.io.Serializable;
-import java.util.Iterator;
-import java.util.Set;
-
-import javax.security.auth.Subject;
-
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-import com.sun.ts.tests.common.connector.whitebox.Debug;
-import com.sun.ts.tests.common.connector.whitebox.TSConnection;
-import com.sun.ts.tests.common.connector.whitebox.TSConnectionImpl;
-import com.sun.ts.tests.common.connector.whitebox.TSEISDataSource;
-import com.sun.ts.tests.common.connector.whitebox.TSManagedConnection;
-import com.sun.ts.tests.common.connector.whitebox.Util;
-
-import jakarta.resource.ResourceException;
-import jakarta.resource.spi.ConnectionManager;
-import jakarta.resource.spi.ConnectionRequestInfo;
-import jakarta.resource.spi.EISSystemException;
-import jakarta.resource.spi.ManagedConnection;
-import jakarta.resource.spi.ManagedConnectionFactory;
-import jakarta.resource.spi.ResourceAdapter;
-import jakarta.resource.spi.ResourceAdapterAssociation;
-import jakarta.resource.spi.security.PasswordCredential;
-
-/*
- * This class shouldnt really get used. The ra.xml should be specifying to
- * use an MCF other than this one. (This is in order to assist with validating
- * assertions Connector:SPEC:272, Connector:SPEC:310, and Connector:SPEC:312.
- *
- */
-public class OtherMCF implements ManagedConnectionFactory,
- ResourceAdapterAssociation, Serializable, jakarta.resource.Referenceable {
- private javax.naming.Reference reference;
-
- private ResourceAdapter resourceAdapter;
-
- private int count;
-
- private String password;
-
- private String user;
-
- private String userName;
-
- /*
- * @name OtherMCF
- *
- * @desc Default conctructor
- */
- public OtherMCF() {
-
- }
-
- public String getUser() {
- return user;
- }
-
- public void setUser(String val) {
- user = val;
- }
-
- public String getUserName() {
- return userName;
- }
-
- public void setUserName(String val) {
- userName = val;
- }
-
- public String getPassword() {
- return password;
- }
-
- public void setPassword(String val) {
- password = val;
- }
-
- /*
- * @name createConnectionFactory
- *
- * @desc Creates a new connection factory instance
- *
- * @param ConnectionManager
- *
- * @return Object
- *
- * @exception ResourceException
- */
- public Object createConnectionFactory(ConnectionManager cxManager)
- throws ResourceException {
- ConnectorStatus.getConnectorStatus().logAPI(
- "OtherMCF.createConnectionFactory", "cxManager", "TSEISDataSource");
- return new TSEISDataSource(this, cxManager);
- }
-
- /*
- * @name createConnectionFactory
- *
- * @desc Creates a new connection factory instance
- *
- * @return Object
- *
- * @exception ResourceException
- */
- public Object createConnectionFactory() throws ResourceException {
- ConnectorStatus.getConnectorStatus()
- .logAPI("OtherMCF.createConnectionFactory", "", "TSEISDataSource");
- return new TSEISDataSource(this, null);
- }
-
- /*
- * @name setResourceAdapter
- *
- * @desc sets the Resource Adapter for this ManagedConnectionFactory
- *
- * @return
- *
- * @exception ResourceException
- */
- public void setResourceAdapter(ResourceAdapter ra) throws ResourceException {
- count++;
- String newStr1 = new String("OtherMCF setResourceAdapter " + count);
- Debug.trace(newStr1);
- this.resourceAdapter = ra;
- }
-
- /*
- * @name getResourceAdapter
- *
- * @desc gets the Resource Adapter for this ManagedConnectionFactory
- *
- * @return Object
- *
- * @exception ResourceException
- */
- public ResourceAdapter getResourceAdapter() {
- return resourceAdapter;
- }
-
- /*
- * @name createManagedConnection
- *
- * @desc Creates a new managed connection to the underlying EIS
- *
- * @param Subject, ConnectionRequestInfo
- *
- * @return ManagedConnection
- *
- * @exception ResourceException
- */
- public ManagedConnection createManagedConnection(Subject subject,
- ConnectionRequestInfo info) throws ResourceException {
-
- try {
-
- ConnectorStatus.getConnectorStatus().logAPI(
- "OtherMCF.createManagedConnection", "subject|info",
- "TSManagedConnection");
- TSConnection con = null;
- PasswordCredential pc = Util.getPasswordCredential(this, subject, info);
- if (pc == null) {
- Debug.trace("OtherMCF.createManagedConnection(): pc == null");
- Debug.trace("TSConnectionImpl.getConnection()");
- con = new TSConnectionImpl().getConnection();
- } else {
- Debug.trace("OtherMCF.createManagedConnection(): pc != null");
- setUser(pc.getUserName());
- setUserName(pc.getUserName());
- setPassword(new String(pc.getPassword()));
- Debug.trace("TSConnectionImpl.getConnection(u,p)");
- con = new TSConnectionImpl().getConnection(pc.getUserName(),
- pc.getPassword());
- }
- return new TSManagedConnection(this, pc, null, con, false, true);
- } catch (Exception ex) {
- ResourceException re = new EISSystemException(
- "Exception: " + ex.getMessage());
- re.initCause(ex);
- throw re;
- }
- }
-
- /*
- * @name matchManagedConnection
- *
- * @desc Return the existing connection from the connection pool
- *
- * @param Set, Subject, ConnectionRequestInfo
- *
- * @return ManagedConnection
- *
- * @exception ResourceException
- */
- public ManagedConnection matchManagedConnections(Set connectionSet,
- Subject subject, ConnectionRequestInfo info) throws ResourceException {
- ConnectorStatus.getConnectorStatus().logAPI(
- "OtherMCF.matchManagedConnection", "connectionSet|subject|info",
- "TSEISDataSource");
- PasswordCredential pc = Util.getPasswordCredential(this, subject, info);
- Iterator it = connectionSet.iterator();
- while (it.hasNext()) {
- Object obj = it.next();
- if (obj instanceof TSManagedConnection) {
- TSManagedConnection mc = (TSManagedConnection) obj;
- ManagedConnectionFactory mcf = mc.getManagedConnectionFactory();
- if (Util.isPasswordCredentialEqual(mc.getPasswordCredential(), pc)
- && mcf.equals(this)) {
- return mc;
- }
- }
- }
- return null;
- }
-
- /*
- * @name setLogWriter
- *
- * @desc Sets the Print Writer
- *
- * @param PrintWriter
- *
- * @exception ResourceException
- */
- public void setLogWriter(PrintWriter out) throws ResourceException {
- ConnectorStatus.getConnectorStatus().logAPI("setLogWriter", "out", "");
- }
-
- /*
- * @name getLogWriter
- *
- * @desc Gets the Print Writer
- *
- * @return PrintWriter
- *
- * @exception ResourceException
- */
- public PrintWriter getLogWriter() throws ResourceException {
- ConnectorStatus.getConnectorStatus().logAPI("getLogWriter", "", "");
- return null;
- }
-
- /*
- * @name equals
- *
- * @desc Compares the given object to the ManagedConnectionFactory instance.
- *
- * @param Object
- *
- * @return boolean
- */
- public boolean equals(Object obj) {
-
- if ((obj == null) || !(obj instanceof OtherMCF)) {
- return false;
- }
- if (obj == this) {
- return true;
- }
-
- OtherMCF that = (OtherMCF) obj;
-
- if ((this.reference != null)
- && !(this.reference.equals(that.getReference()))) {
- return false;
- } else if ((this.reference == null) && !(that.getReference() == null)) {
- return false;
- }
-
- if ((this.resourceAdapter != null)
- && !(this.resourceAdapter.equals(that.getResourceAdapter()))) {
- return false;
- } else if ((this.resourceAdapter == null)
- && !(that.getResourceAdapter() == null)) {
- return false;
- }
-
- if (this.count != that.getCount()) {
- return false;
- }
-
- if (!Util.isEqual(this.password, that.getPassword()))
- return false;
-
- if (!Util.isEqual(this.user, that.getUser()))
- return false;
-
- if (!Util.isEqual(this.userName, that.getUserName()))
- return false;
-
- return true;
- }
-
- /*
- * @name hashCode
- *
- * @desc Gives a hash value to a ManagedConnectionFactory Obejct.
- *
- * @return int
- */
- public int hashCode() {
- return this.getClass().getName().hashCode();
- }
-
- /*
- * @name getReference
- *
- * @desc Gives the reference of the class
- *
- * @return javax.naming.Reference
- */
- public javax.naming.Reference getReference() {
- javax.naming.Reference ref;
- ref = this.reference;
- return ref;
- }
-
- /*
- * @name setReference
- *
- * @desc sets the reference of the class
- *
- * @param javax.naming.Reference
- */
- public void setReference(javax.naming.Reference ref) {
- this.reference = ref;
- }
-
- public int getCount() {
- return this.count;
- }
-
- public void setCount(int val) {
- this.count = val;
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/multianno/OtherRAImpl.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/multianno/OtherRAImpl.java
deleted file mode 100644
index 70fe3dbc4c..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/multianno/OtherRAImpl.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * Copyright (c) 2009, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.common.connector.whitebox.multianno;
-
-import java.io.Serializable;
-import java.lang.reflect.Method;
-
-import javax.transaction.xa.XAResource;
-
-import com.sun.ts.tests.common.connector.whitebox.Debug;
-import com.sun.ts.tests.common.connector.whitebox.Util;
-
-import jakarta.resource.spi.ActivationSpec;
-import jakarta.resource.spi.BootstrapContext;
-import jakarta.resource.spi.Connector;
-import jakarta.resource.spi.ResourceAdapter;
-import jakarta.resource.spi.ResourceAdapterInternalException;
-import jakarta.resource.spi.TransactionSupport;
-import jakarta.resource.spi.endpoint.MessageEndpointFactory;
-import jakarta.resource.spi.work.HintsContext;
-import jakarta.resource.spi.work.SecurityContext;
-import jakarta.resource.spi.work.Work;
-import jakarta.resource.spi.work.WorkManager;
-
-/*
- * This class shouldnt really get used. The ra.xml should be specifying to
- * use a RAImple other than this one. (This is in order to assist with validating
- * assertions Connector:SPEC:272, Connector:SPEC:310, and Connector:SPEC:312.
- *
- */
-@Connector(description = "CTS test RA specified in DD is used", displayName = "OtherRAImpl", vendorName = "Java Software", eisType = "TS EIS", version = "1.0", licenseDescription = "CTS License Required", licenseRequired = true, reauthenticationSupport = false, transactionSupport = TransactionSupport.TransactionSupportLevel.NoTransaction, requiredWorkContexts = {
- HintsContext.class, SecurityContext.class })
-
-public class OtherRAImpl implements ResourceAdapter, Serializable {
- private String raName;
-
- private int counter = 0;
-
- private transient WorkManager wm;
-
- private transient BootstrapContext bsc;
-
- public OtherRAImpl() {
- Debug.trace("OtherRAImpl Constructor ");
- }
-
- public void start(final BootstrapContext bsc)
- throws ResourceAdapterInternalException {
- // setup network endpoints
- counter++;
- this.bsc = bsc;
- String str1 = new String("OtherRAImpl Started " + counter);
- Debug.trace(str1);
-
- // get WorkManager reference
-
- wm = bsc.getWorkManager();
-
- try {
- checkAssociation();
- bsc.getWorkManager().startWork(new Work() {
- public void run() {
- myStart(bsc);
- }
-
- public void release() {
- }
-
- });
- } catch (jakarta.resource.spi.work.WorkException we) {
- throw new ResourceAdapterInternalException();
- }
-
- }
-
- private void myStart(final BootstrapContext ctx) {
- Debug.trace("OtherRAImpl.myStart ");
- }
-
- public void stop() {
- Debug.trace("OtherRAImpl.stop ");
- }
-
- public void endpointActivation(MessageEndpointFactory mef,
- ActivationSpec as) {
- }
-
- public XAResource[] getXAResources(ActivationSpec[] as) {
- Debug.trace("OtherRAImpl.getXAResources ");
- return null;
- }
-
- private Method getOnMessageMethod() {
- Method onMessageMethod = null;
- return onMessageMethod;
- }
-
- private void chkUniqueMessageEndpointFactory() {
- }
-
- public void checkAssociation() {
- }
-
- public void endpointDeactivation(MessageEndpointFactory mef,
- ActivationSpec as) {
- }
-
- /*
- * @name equals
- *
- * @desc compares this object with the given object.
- *
- * @param Object obj
- *
- * @return boolean
- */
- public boolean equals(Object obj) {
-
- if ((obj == null) || !(obj instanceof OtherRAImpl)) {
- return false;
- }
- if (obj == this) {
- return true;
- }
-
- OtherRAImpl that = (OtherRAImpl) obj;
-
- if (this.counter != that.getCounter()) {
- return false;
- }
-
- if (!Util.isEqual(this.raName, that.getRaName()))
- return false;
-
- return true;
- }
-
- /*
- * @name hashCode
- *
- * @desc gets the hashcode for this object.
- *
- * @return int
- */
- public int hashCode() {
- return this.getClass().getName().hashCode();
- }
-
- public void setRaName(String name) {
- this.raName = name;
- }
-
- public String getRaName() {
- return raName;
- }
-
- public void setCounter(int val) {
- this.counter = val;
- }
-
- public int getCounter() {
- return this.counter;
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/multianno/ThirdMCF.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/multianno/ThirdMCF.java
deleted file mode 100644
index 357a4c046b..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/multianno/ThirdMCF.java
+++ /dev/null
@@ -1,355 +0,0 @@
-/*
- * Copyright (c) 2009, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.common.connector.whitebox.multianno;
-
-import java.io.PrintWriter;
-import java.io.Serializable;
-import java.util.Iterator;
-import java.util.Set;
-
-import javax.security.auth.Subject;
-
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-import com.sun.ts.tests.common.connector.whitebox.Debug;
-import com.sun.ts.tests.common.connector.whitebox.TSConnection;
-import com.sun.ts.tests.common.connector.whitebox.TSConnectionImpl;
-import com.sun.ts.tests.common.connector.whitebox.TSEISDataSource;
-import com.sun.ts.tests.common.connector.whitebox.TSManagedConnection;
-import com.sun.ts.tests.common.connector.whitebox.Util;
-
-import jakarta.resource.ResourceException;
-import jakarta.resource.spi.ConnectionManager;
-import jakarta.resource.spi.ConnectionRequestInfo;
-import jakarta.resource.spi.EISSystemException;
-import jakarta.resource.spi.ManagedConnection;
-import jakarta.resource.spi.ManagedConnectionFactory;
-import jakarta.resource.spi.ResourceAdapter;
-import jakarta.resource.spi.ResourceAdapterAssociation;
-import jakarta.resource.spi.security.PasswordCredential;
-
-/*
- * This class shouldnt really get used. The ra.xml should be specifying to
- * use an MCF other than this one. (This is in order to assist with validating
- * assertions Connector:SPEC:272, Connector:SPEC:310, and Connector:SPEC:312,
- * Connector:SPEC:274.
- *
- */
-public class ThirdMCF implements ManagedConnectionFactory,
- ResourceAdapterAssociation, Serializable, jakarta.resource.Referenceable {
- private javax.naming.Reference reference;
-
- private ResourceAdapter resourceAdapter;
-
- private int count;
-
- private String password;
-
- private String user;
-
- private String userName;
-
- /*
- * @name ThirdMCF
- *
- * @desc Default conctructor
- */
- public ThirdMCF() {
- }
-
- public String getUser() {
- return user;
- }
-
- public void setUser(String val) {
- user = val;
- }
-
- public String getUserName() {
- return userName;
- }
-
- public void setUserName(String val) {
- userName = val;
- }
-
- public String getPassword() {
- return password;
- }
-
- public void setPassword(String val) {
- password = val;
- }
-
- /*
- * @name createConnectionFactory
- *
- * @desc Creates a new connection factory instance
- *
- * @param ConnectionManager
- *
- * @return Object
- *
- * @exception ResourceException
- */
- public Object createConnectionFactory(ConnectionManager cxManager)
- throws ResourceException {
- ConnectorStatus.getConnectorStatus().logAPI(
- "ThirdMCF.createConnectionFactory", "cxManager", "TSEISDataSource");
- return new TSEISDataSource(this, cxManager);
- }
-
- /*
- * @name createConnectionFactory
- *
- * @desc Creates a new connection factory instance
- *
- * @return Object
- *
- * @exception ResourceException
- */
- public Object createConnectionFactory() throws ResourceException {
- ConnectorStatus.getConnectorStatus()
- .logAPI("ThirdMCF.createConnectionFactory", "", "TSEISDataSource");
- return new TSEISDataSource(this, null);
- }
-
- /*
- * @name setResourceAdapter
- *
- * @desc sets the Resource Adapter for this ManagedConnectionFactory
- *
- * @return
- *
- * @exception ResourceException
- */
- public void setResourceAdapter(ResourceAdapter ra) throws ResourceException {
- count++;
- String newStr1 = new String("ThirdMCF setResourceAdapter " + count);
- Debug.trace(newStr1);
- this.resourceAdapter = ra;
- }
-
- /*
- * @name getResourceAdapter
- *
- * @desc gets the Resource Adapter for this ManagedConnectionFactory
- *
- * @return Object
- *
- * @exception ResourceException
- */
- public ResourceAdapter getResourceAdapter() {
- return resourceAdapter;
- }
-
- /*
- * @name createManagedConnection
- *
- * @desc Creates a new managed connection to the underlying EIS
- *
- * @param Subject, ConnectionRequestInfo
- *
- * @return ManagedConnection
- *
- * @exception ResourceException
- */
- public ManagedConnection createManagedConnection(Subject subject,
- ConnectionRequestInfo info) throws ResourceException {
-
- try {
-
- ConnectorStatus.getConnectorStatus().logAPI(
- "ThirdMCF.createManagedConnection", "subject|info",
- "TSManagedConnection");
- TSConnection con = null;
- PasswordCredential pc = Util.getPasswordCredential(this, subject, info);
- if (pc == null) {
- Debug.trace("ThirdMCF.createManagedConnection(): pc == null");
- Debug.trace("TSConnectionImpl.getConnection()");
- con = new TSConnectionImpl().getConnection();
- } else {
- Debug.trace("ThirdMCF.createManagedConnection(): pc != null");
- setUser(pc.getUserName());
- setUserName(pc.getUserName());
- setPassword(new String(pc.getPassword()));
- Debug.trace("TSConnectionImpl.getConnection(u,p)");
- con = new TSConnectionImpl().getConnection(pc.getUserName(),
- pc.getPassword());
- }
- return new TSManagedConnection(this, pc, null, con, false, true);
- } catch (Exception ex) {
- ResourceException re = new EISSystemException(
- "Exception: " + ex.getMessage());
- re.initCause(ex);
- throw re;
- }
- }
-
- /*
- * @name matchManagedConnection
- *
- * @desc Return the existing connection from the connection pool
- *
- * @param Set, Subject, ConnectionRequestInfo
- *
- * @return ManagedConnection
- *
- * @exception ResourceException
- */
- public ManagedConnection matchManagedConnections(Set connectionSet,
- Subject subject, ConnectionRequestInfo info) throws ResourceException {
- ConnectorStatus.getConnectorStatus().logAPI(
- "ThirdMCF.matchManagedConnection", "connectionSet|subject|info",
- "TSEISDataSource");
- PasswordCredential pc = Util.getPasswordCredential(this, subject, info);
- Iterator it = connectionSet.iterator();
- while (it.hasNext()) {
- Object obj = it.next();
- if (obj instanceof TSManagedConnection) {
- TSManagedConnection mc = (TSManagedConnection) obj;
- ManagedConnectionFactory mcf = mc.getManagedConnectionFactory();
- if (Util.isPasswordCredentialEqual(mc.getPasswordCredential(), pc)
- && mcf.equals(this)) {
- return mc;
- }
- }
- }
- return null;
- }
-
- /*
- * @name setLogWriter
- *
- * @desc Sets the Print Writer
- *
- * @param PrintWriter
- *
- * @exception ResourceException
- */
- public void setLogWriter(PrintWriter out) throws ResourceException {
- ConnectorStatus.getConnectorStatus().logAPI("setLogWriter", "out", "");
- }
-
- /*
- * @name getLogWriter
- *
- * @desc Gets the Print Writer
- *
- * @return PrintWriter
- *
- * @exception ResourceException
- */
- public PrintWriter getLogWriter() throws ResourceException {
- ConnectorStatus.getConnectorStatus().logAPI("getLogWriter", "", "");
- return null;
- }
-
- /*
- * @name equals
- *
- * @desc Compares the given object to the ManagedConnectionFactory instance.
- *
- * @param Object
- *
- * @return boolean
- */
- public boolean equals(Object obj) {
-
- if ((obj == null) || !(obj instanceof ThirdMCF)) {
- return false;
- }
- if (obj == this) {
- return true;
- }
-
- ThirdMCF that = (ThirdMCF) obj;
-
- if ((this.reference != null)
- && !(this.reference.equals(that.getReference()))) {
- return false;
- } else if ((this.reference == null) && !(that.getReference() == null)) {
- return false;
- }
-
- if ((this.resourceAdapter != null)
- && !(this.resourceAdapter.equals(that.getResourceAdapter()))) {
- return false;
- } else if ((this.resourceAdapter == null)
- && !(that.getResourceAdapter() == null)) {
- return false;
- }
-
- if (this.count != that.getCount()) {
- return false;
- }
-
- if (!Util.isEqual(this.password, that.getPassword()))
- return false;
-
- if (!Util.isEqual(this.user, that.getUser()))
- return false;
-
- if (!Util.isEqual(this.userName, that.getUserName()))
- return false;
-
- return true;
- }
-
- /*
- * @name hashCode
- *
- * @desc Gives a hash value to a ManagedConnectionFactory Obejct.
- *
- * @return int
- */
- public int hashCode() {
- return this.getClass().getName().hashCode();
- }
-
- /*
- * @name getReference
- *
- * @desc Gives the reference of the class
- *
- * @return javax.naming.Reference
- */
- public javax.naming.Reference getReference() {
- javax.naming.Reference ref;
- ref = this.reference;
- return ref;
- }
-
- /*
- * @name setReference
- *
- * @desc sets the reference of the class
- *
- * @param javax.naming.Reference
- */
- public void setReference(javax.naming.Reference ref) {
- this.reference = ref;
- }
-
- public int getCount() {
- return this.count;
- }
-
- public void setCount(int val) {
- this.count = val;
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/multianno/ThirdRAImpl.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/multianno/ThirdRAImpl.java
deleted file mode 100644
index e74385be08..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/multianno/ThirdRAImpl.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * Copyright (c) 2009, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.common.connector.whitebox.multianno;
-
-import java.io.Serializable;
-import java.lang.reflect.Method;
-
-import javax.transaction.xa.XAResource;
-
-import com.sun.ts.tests.common.connector.whitebox.Debug;
-import com.sun.ts.tests.common.connector.whitebox.Util;
-
-import jakarta.resource.spi.ActivationSpec;
-import jakarta.resource.spi.BootstrapContext;
-import jakarta.resource.spi.Connector;
-import jakarta.resource.spi.ResourceAdapter;
-import jakarta.resource.spi.ResourceAdapterInternalException;
-import jakarta.resource.spi.TransactionSupport;
-import jakarta.resource.spi.endpoint.MessageEndpointFactory;
-import jakarta.resource.spi.work.HintsContext;
-import jakarta.resource.spi.work.SecurityContext;
-import jakarta.resource.spi.work.Work;
-import jakarta.resource.spi.work.WorkManager;
-
-/*
- * This class shouldnt really get used. The ra.xml should be specifying to
- * use a RAImple other than this one. (This is in order to assist with validating
- * assertions Connector:SPEC:272, Connector:SPEC:310, and Connector:SPEC:312,
- * Connector:SPEC:274.
- *
- */
-@Connector(description = "CTS test RA specified in DD is used", displayName = "ThirdRAImpl", vendorName = "Java Software", eisType = "TS EIS", version = "1.0", licenseDescription = "CTS License Required", licenseRequired = true, reauthenticationSupport = false, transactionSupport = TransactionSupport.TransactionSupportLevel.NoTransaction, requiredWorkContexts = {
- HintsContext.class, SecurityContext.class })
-
-public class ThirdRAImpl implements ResourceAdapter, Serializable {
- private String raName;
-
- private int counter = 0;
-
- private transient WorkManager wm;
-
- private transient BootstrapContext bsc;
-
- public ThirdRAImpl() {
- Debug.trace("ThirdRAImpl Constructor ");
- }
-
- public void start(final BootstrapContext bsc)
- throws ResourceAdapterInternalException {
- // setup network endpoints
- counter++;
- this.bsc = bsc;
- String str1 = new String("ThirdRAImpl Started " + counter);
- Debug.trace(str1);
-
- // get WorkManager reference
- wm = bsc.getWorkManager();
-
- try {
- checkAssociation();
- bsc.getWorkManager().startWork(new Work() {
- public void run() {
- myStart(bsc);
- }
-
- public void release() {
- }
-
- });
- } catch (jakarta.resource.spi.work.WorkException we) {
- throw new ResourceAdapterInternalException();
- }
-
- }
-
- private void myStart(final BootstrapContext ctx) {
- Debug.trace("ThirdRAImpl.myStart ");
- }
-
- public void stop() {
- Debug.trace("ThirdRAImpl.stop ");
- }
-
- public void endpointActivation(MessageEndpointFactory mef,
- ActivationSpec as) {
- }
-
- public XAResource[] getXAResources(ActivationSpec[] as) {
- Debug.trace("ThirdRAImpl.getXAResources ");
- return null;
- }
-
- private Method getOnMessageMethod() {
- Method onMessageMethod = null;
- return onMessageMethod;
- }
-
- private void chkUniqueMessageEndpointFactory() {
- }
-
- public void checkAssociation() {
- }
-
- public void endpointDeactivation(MessageEndpointFactory mef,
- ActivationSpec as) {
- }
-
- /*
- * @name equals
- *
- * @desc compares this object with the given object.
- *
- * @param Object obj
- *
- * @return boolean
- */
- public boolean equals(Object obj) {
-
- if ((obj == null) || !(obj instanceof ThirdRAImpl)) {
- return false;
- }
- if (obj == this) {
- return true;
- }
-
- ThirdRAImpl that = (ThirdRAImpl) obj;
-
- if (this.counter != that.getCounter()) {
- return false;
- }
-
- if (!Util.isEqual(this.raName, that.getRaName()))
- return false;
-
- return true;
- }
-
- /*
- * @name hashCode
- *
- * @desc gets the hashcode for this object.
- *
- * @return int
- */
- public int hashCode() {
- return this.getClass().getName().hashCode();
- }
-
- public void setRaName(String name) {
- this.raName = name;
- }
-
- public String getRaName() {
- return raName;
- }
-
- public void setCounter(int val) {
- this.counter = val;
- }
-
- public int getCounter() {
- return this.counter;
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/permissiondd/PermissionDDMCF.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/permissiondd/PermissionDDMCF.java
deleted file mode 100644
index 1ade7ac9b3..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/permissiondd/PermissionDDMCF.java
+++ /dev/null
@@ -1,500 +0,0 @@
-/*
- * Copyright (c) 2014, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.common.connector.whitebox.permissiondd;
-
-import java.io.PrintWriter;
-import java.io.Serializable;
-import java.util.Iterator;
-import java.util.Set;
-
-import javax.security.auth.Subject;
-
-import com.sun.ts.lib.util.TSNamingContext;
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-import com.sun.ts.tests.common.connector.whitebox.Debug;
-import com.sun.ts.tests.common.connector.whitebox.TSConnection;
-import com.sun.ts.tests.common.connector.whitebox.TSConnectionImpl;
-import com.sun.ts.tests.common.connector.whitebox.TSEISDataSource;
-import com.sun.ts.tests.common.connector.whitebox.TSManagedConnection;
-import com.sun.ts.tests.common.connector.whitebox.Util;
-
-import jakarta.resource.ResourceException;
-import jakarta.resource.spi.ConfigProperty;
-import jakarta.resource.spi.ConnectionDefinition;
-import jakarta.resource.spi.ConnectionDefinitions;
-import jakarta.resource.spi.ConnectionManager;
-import jakarta.resource.spi.ConnectionRequestInfo;
-import jakarta.resource.spi.EISSystemException;
-import jakarta.resource.spi.ManagedConnection;
-import jakarta.resource.spi.ManagedConnectionFactory;
-import jakarta.resource.spi.ManagedConnectionMetaData;
-import jakarta.resource.spi.ResourceAdapter;
-import jakarta.resource.spi.ResourceAdapterAssociation;
-import jakarta.resource.spi.security.PasswordCredential;
-
-@ConnectionDefinitions({
- @ConnectionDefinition(connectionFactory = com.sun.ts.tests.common.connector.whitebox.TSConnectionFactory.class, connectionFactoryImpl = com.sun.ts.tests.common.connector.whitebox.TSEISDataSource.class, connection = com.sun.ts.tests.common.connector.whitebox.TSConnection.class, connectionImpl = com.sun.ts.tests.common.connector.whitebox.TSEISConnection.class) })
-public class PermissionDDMCF implements ManagedConnectionFactory,
- ResourceAdapterAssociation, jakarta.resource.Referenceable, Serializable {
- private javax.naming.Reference reference;
-
- private ResourceAdapter resourceAdapter;
-
- private int count;
-
- private String tsrValue;
-
- private String password;
-
- private String user;
-
- private String userName;
-
- private String setterMethodVal = "DEFAULT";
-
- @ConfigProperty(defaultValue = "10", type = Integer.class, description = "Integer value", ignore = false)
- private Integer integer;
-
- @ConfigProperty()
- private String factoryName = "PermissionDDMCF";
-
- /*
- * @name PermissionDDMCF
- *
- * @desc Default conctructor
- */
- public PermissionDDMCF() {
- // this helps verify assertion Connector:SPEC:279 and Connector:SPEC:277
- String str = "PermissionDDMCF factoryName=" + factoryName;
- ConnectorStatus.getConnectorStatus().logState(str);
-
- // lets make sure we can call and set setSetterMethodVal()
- setSetterMethodVal("NONDEFAULT");
-
- debug(str);
- }
-
- /*
- * used to help test assertion Connector:SPEC:278
- */
- @ConfigProperty()
- public void setSetterMethodVal(String val) {
- setterMethodVal = val;
- String str = "PermissionDDResourceAdapterImpl.setSetterMethodVal="
- + setterMethodVal;
- ConnectorStatus.getConnectorStatus().logState(str);
- }
-
- public String getSetterMethodVal() {
- return setterMethodVal;
- }
-
- public void setFactoryName(String name) {
- this.factoryName = name;
- }
-
- public String getFactoryName() {
- return factoryName;
- }
-
- public Integer getInteger() {
- return this.integer;
- }
-
- public void setInteger(Integer val) {
- this.integer = val;
- }
-
- public String getUser() {
- debug("PermissionDDMCF.getUser() returning: " + user);
- return user;
- }
-
- public void setUser(String val) {
- debug("PermissionDDMCF.setUser() with val = " + val);
- user = val;
- }
-
- public String getUserName() {
- debug("PermissionDDMCF.getUserName() returning: " + userName);
- return userName;
- }
-
- public void setUserName(String val) {
- debug("PermissionDDMCF.setUserName() with val = " + val);
- userName = val;
- }
-
- public String getPassword() {
- debug("PermissionDDMCF.getPassword() returning: " + password);
- return password;
- }
-
- public void setPassword(String val) {
- debug("PermissionDDMCF.setPassword() with val = " + val);
- password = val;
- }
-
- public String getTsrValue() {
- debug("PermissionDDMCF getTsrValue called" + tsrValue);
- return tsrValue;
- }
-
- public void setTsrValue(String name) {
- debug("PermissionDDMCF setTsrValue called" + name);
- this.tsrValue = name;
- }
-
- public void lookupTSR(String lookup) {
- try {
- TSNamingContext ncxt = new TSNamingContext();
- String newStr = "java:".concat(lookup);
- Object obj = (Object) ncxt.lookup(newStr);
- if (obj != null) {
- debug("TSR NOT Null");
- } else {
- debug("TSR Null");
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- /*
- * @name createConnectionFactory
- *
- * @desc Creates a new connection factory instance
- *
- * @param ConnectionManager
- *
- * @return Object
- *
- * @exception ResourceException
- */
- public Object createConnectionFactory(ConnectionManager cxManager)
- throws ResourceException {
- return new TSEISDataSource(this, cxManager);
- }
-
- /*
- * @name createConnectionFactory
- *
- * @desc Creates a new connection factory instance
- *
- * @return Object
- *
- * @exception ResourceException
- */
- public Object createConnectionFactory() throws ResourceException {
- return new TSEISDataSource(this, null);
- }
-
- /*
- * @name setResourceAdapter
- *
- * @desc sets the Resource Adapter for this ManagedConnectionFactory
- *
- * @return
- *
- * @exception ResourceException
- */
- public void setResourceAdapter(ResourceAdapter ra) throws ResourceException {
- count++;
- String newStr1 = "PermissionDDMCF setResourceAdapter " + count;
- debug(newStr1);
- this.resourceAdapter = ra;
- }
-
- /*
- * @name getResourceAdapter
- *
- * @desc gets the Resource Adapter for this ManagedConnectionFactory
- *
- * @return Object
- *
- * @exception ResourceException
- */
- public ResourceAdapter getResourceAdapter() {
- debug("PermissionDDMCF.getResource");
- return resourceAdapter;
- }
-
- /*
- * @name createManagedConnection
- *
- * @desc Creates a new managed connection to the underlying EIS
- *
- * @param Subject, ConnectionRequestInfo
- *
- * @return ManagedConnection
- *
- * @exception ResourceException
- */
- public ManagedConnection createManagedConnection(Subject subject,
- ConnectionRequestInfo info) throws ResourceException {
-
- try {
-
- TSConnection con = null;
- PasswordCredential pc = Util.getPasswordCredential(this, subject, info);
- if (pc == null) {
- debug("PermissionDDMCF.createManagedConnection(): pc == null");
- debug("TSConnectionImpl.getConnection()");
- con = new TSConnectionImpl().getConnection();
- } else {
- debug("PermissionDDMCF.createManagedConnection(): pc != null");
- setUser(pc.getUserName());
- setUserName(pc.getUserName());
- setPassword(new String(pc.getPassword()));
- debug("TSConnectionImpl.getConnection(u,p)");
- con = new TSConnectionImpl().getConnection(pc.getUserName(),
- pc.getPassword());
- }
-
- ManagedConnection mcon = new TSManagedConnection(this, pc, null, con,
- false, true);
- dumpConnectionMetaData(mcon);
-
- return mcon;
- } catch (Exception ex) {
- ResourceException re = new EISSystemException(
- "Exception: " + ex.getMessage());
- re.initCause(ex);
- throw re;
- }
-
- }
-
- public void dumpConnectionMetaData(ManagedConnection mcon) {
-
- String hdr = "PermissionDDMCF: ";
- String out;
- boolean bLocal = false;
- boolean bXA = false;
-
- try {
- ManagedConnectionMetaData mdata = mcon.getMetaData();
-
- out = hdr + "displayName=" + mdata.getEISProductName();
- debug(out);
-
- out = hdr + "version=" + mdata.getEISProductVersion();
- debug(out);
-
- // get transaction type
- try {
- mcon.getLocalTransaction();
- bLocal = true;
- } catch (ResourceException ex) {
- System.out.println(hdr + "not a localTransaction type");
- }
- try {
- mcon.getXAResource();
- bXA = true;
- } catch (ResourceException ex) {
- System.out.println(hdr + "not a XAResource type");
- }
-
- out = hdr + "transactionSupport=";
- if (bLocal) {
- out = out + "LocalTransaction";
- } else if (bXA) {
- out = out + "XATransaction";
- } else {
- // assume default case of noTx
- out = out + "NoTransaction";
- }
- debug(out);
- } catch (ResourceException ex) {
- System.out.println(ex.getMessage());
- ex.printStackTrace();
- }
- }
-
- /*
- * @name matchManagedConnection
- *
- * @desc Return the existing connection from the connection pool
- *
- * @param Set, Subject, ConnectionRequestInfo
- *
- * @return ManagedConnection
- *
- * @exception ResourceException
- */
- public ManagedConnection matchManagedConnections(Set connectionSet,
- Subject subject, ConnectionRequestInfo info) throws ResourceException {
-
- PasswordCredential pc = Util.getPasswordCredential(this, subject, info);
- Iterator it = connectionSet.iterator();
-
- while (it.hasNext()) {
- Object obj = it.next();
- if (obj instanceof TSManagedConnection) {
- TSManagedConnection mc = (TSManagedConnection) obj;
- ManagedConnectionFactory mcf = mc.getManagedConnectionFactory();
- if (Util.isPasswordCredentialEqual(mc.getPasswordCredential(), pc)
- && (mcf != null) && mcf.equals(this)) {
- return mc;
- }
- }
- }
-
- System.out.println("matchManagedConnections: couldnt find match");
- return null;
- }
-
- /*
- * @name setLogWriter
- *
- * @desc Sets the Print Writer
- *
- * @param PrintWriter
- *
- * @exception ResourceException
- */
- public void setLogWriter(PrintWriter out) throws ResourceException {
- }
-
- /*
- * @name getLogWriter
- *
- * @desc Gets the Print Writer
- *
- * @return PrintWriter
- *
- * @exception ResourceException
- */
- public PrintWriter getLogWriter() throws ResourceException {
- return null;
- }
-
- /*
- * @name equals
- *
- * @desc Compares the given object to the ManagedConnectionFactory instance.
- *
- * @param Object
- *
- * @return boolean
- */
- public boolean equals(Object obj) {
-
- if ((obj == null) || !(obj instanceof PermissionDDMCF)) {
- return false;
- }
- if (obj == this) {
- return true;
- }
-
- PermissionDDMCF that = (PermissionDDMCF) obj;
-
- if ((this.reference != null)
- && !(this.reference.equals(that.getReference()))) {
- return false;
- } else if ((this.reference == null) && !(that.getReference() == null)) {
- return false;
- }
-
- if ((this.resourceAdapter != null)
- && !(this.resourceAdapter.equals(that.getResourceAdapter()))) {
- return false;
- } else if ((this.resourceAdapter == null)
- && !(that.getResourceAdapter() == null)) {
- return false;
- }
-
- if (this.count != that.getCount()) {
- return false;
- }
-
- if ((this.integer != null) && (!this.integer.equals(that.getInteger()))) {
- return false;
- } else if ((this.integer == null) && !(that.getInteger() == null)) {
- return false;
- }
-
- if (!Util.isEqual(this.password, that.getPassword()))
- return false;
-
- if (!Util.isEqual(this.user, that.getUser()))
- return false;
-
- if (!Util.isEqual(this.userName, that.getUserName()))
- return false;
-
- if (!Util.isEqual(this.tsrValue, that.getTsrValue()))
- return false;
-
- if (!Util.isEqual(this.setterMethodVal, that.getSetterMethodVal()))
- return false;
-
- if (!Util.isEqual(this.factoryName, that.getFactoryName()))
- return false;
-
- return true;
- }
-
- /*
- * @name hashCode
- *
- * @desc Gives a hash value to a ManagedConnectionFactory Obejct.
- *
- * @return int
- */
- public int hashCode() {
- return this.getClass().getName().hashCode();
- }
-
- /*
- * @name getReference
- *
- * @desc Gives the reference of the class
- *
- * @return javax.naming.Reference
- */
- public javax.naming.Reference getReference() {
- javax.naming.Reference ref;
-
- ref = this.reference;
- return ref;
- }
-
- /*
- * @name setReference
- *
- * @desc sets the reference of the class
- *
- * @param javax.naming.Reference
- */
- public void setReference(javax.naming.Reference ref) {
- this.reference = ref;
- }
-
- public void debug(String out) {
- Debug.trace("PermissionDDMCF: " + out);
- }
-
- public int getCount() {
- return this.count;
- }
-
- public void setCount(int val) {
- this.count = val;
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/permissiondd/PermissionDDResourceAdapterImpl.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/permissiondd/PermissionDDResourceAdapterImpl.java
deleted file mode 100755
index e9d4268ca9..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/permissiondd/PermissionDDResourceAdapterImpl.java
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * Copyright (c) 2014, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.common.connector.whitebox.permissiondd;
-
-import javax.transaction.xa.XAResource;
-
-import com.sun.ts.lib.util.TestUtil;
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-import com.sun.ts.tests.common.connector.whitebox.Debug;
-import com.sun.ts.tests.common.connector.whitebox.Util;
-
-import jakarta.resource.NotSupportedException;
-import jakarta.resource.ResourceException;
-import jakarta.resource.spi.ActivationSpec;
-import jakarta.resource.spi.AuthenticationMechanism;
-import jakarta.resource.spi.BootstrapContext;
-import jakarta.resource.spi.ConfigProperty;
-import jakarta.resource.spi.Connector;
-import jakarta.resource.spi.ResourceAdapter;
-import jakarta.resource.spi.ResourceAdapterInternalException;
-import jakarta.resource.spi.SecurityPermission;
-import jakarta.resource.spi.TransactionSupport;
-import jakarta.resource.spi.endpoint.MessageEndpointFactory;
-import jakarta.resource.spi.work.HintsContext;
-import jakarta.resource.spi.work.SecurityContext;
-import jakarta.resource.spi.work.Work;
-import jakarta.resource.spi.work.WorkManager;
-
-/**
- * This RA is used to assist with verifying the server supports permissions.xml
- * security enforcement within a rar file.
- */
-
-@Connector(description = "CTS Test Resource Adapter with No DD", displayName = "whitebox-permissiondd.rar", vendorName = "Java Software", eisType = "TS EIS", version = "1.6", licenseDescription = "CTS License Required", licenseRequired = true, authMechanisms = @AuthenticationMechanism(credentialInterface = AuthenticationMechanism.CredentialInterface.PasswordCredential, authMechanism = "BasicPassword", description = "Basic Password Authentication"), reauthenticationSupport = false, securityPermissions = @SecurityPermission(description = "Security Perm description", permissionSpec = ""), transactionSupport = TransactionSupport.TransactionSupportLevel.NoTransaction, requiredWorkContexts = {
- HintsContext.class, SecurityContext.class })
-public class PermissionDDResourceAdapterImpl
- implements ResourceAdapter, java.io.Serializable {
-
- private transient BootstrapContext bsc;
-
- private transient PermissionDDWorkManager awm;
-
- private transient WorkManager wm;
-
- private transient Work work;
-
- private String serverSideUser = ""; // corresponds to ts.jte's 'user' property
-
- private String serverSidePwd = ""; // corresponds to ts.jte's 'password'
- // property
-
- private String eisUser = ""; // corresponds to ts.jte's 'user1' property
-
- private String eisPwd = ""; // corresponds to ts.jte's 'password' property
-
- @ConfigProperty(defaultValue = "PermissionDDResourceAdapterImpl")
- private String raName;
-
- /**
- * constructor
- **/
- public PermissionDDResourceAdapterImpl() {
- debug("enterred constructor...");
-
- this.serverSideUser = TestUtil.getSystemProperty("j2eelogin.name");
- this.serverSidePwd = TestUtil.getSystemProperty("j2eelogin.password");
- this.eisUser = TestUtil.getSystemProperty("eislogin.name");
- this.eisPwd = TestUtil.getSystemProperty("eislogin.password");
-
- debug("leaving constructor...");
- }
-
- //
- // Begin ResourceAdapter interface requirements
- //
-
- /* must implement for ResourceAdapter interface requirement */
- public void start(BootstrapContext bsc)
- throws ResourceAdapterInternalException {
- debug("enterred start");
-
- ConnectorStatus.getConnectorStatus()
- .logState("PermissionDDResourceAdapterImpl.start called");
-
- this.bsc = bsc;
- this.wm = bsc.getWorkManager();
-
- this.awm = new PermissionDDWorkManager(bsc);
- awm.runTests();
-
- debug("leaving start");
- }
-
- /* must implement for ResourceAdapter interface requirement */
- public void stop() {
- debug("entered stop");
- debug("leaving stop");
- }
-
- /* must implement for ResourceAdapter interface requirement */
- public void endpointActivation(MessageEndpointFactory factory,
- ActivationSpec spec) throws NotSupportedException {
-
- debug("enterred endpointActivation");
- debug("leaving endpointActivation");
- }
-
- /* must implement for ResourceAdapter interface requirement */
- public void endpointDeactivation(MessageEndpointFactory ep,
- ActivationSpec spec) {
- debug("enterred endpointDeactivation");
- debug("leaving endpointDeactivation");
- }
-
- /* must implement for ResourceAdapter interface requirement */
- public XAResource[] getXAResources(ActivationSpec[] specs)
- throws ResourceException {
-
- debug("enterred getXAResources");
- debug("leaving getXAResources");
-
- throw new UnsupportedOperationException();
- }
-
- //
- // END ResourceAdapter interface requirements
- //
-
- /*
- * @name equals
- *
- * @desc compares this object with the given object.
- *
- * @param Object obj
- *
- * @return boolean
- */
- public boolean equals(Object obj) {
-
- if ((obj == null) || !(obj instanceof PermissionDDResourceAdapterImpl)) {
- return false;
- }
- if (obj == this) {
- return true;
- }
-
- PermissionDDResourceAdapterImpl that = (PermissionDDResourceAdapterImpl) obj;
-
- if (!Util.isEqual(this.serverSideUser, that.getServerSideUser()))
- return false;
-
- if (!Util.isEqual(this.serverSidePwd, that.getServerSidePwd()))
- return false;
-
- if (!Util.isEqual(this.eisUser, that.getEisUser()))
- return false;
-
- if (!Util.isEqual(this.eisPwd, that.getEisPwd()))
- return false;
-
- if (!Util.isEqual(this.raName, that.getRaName()))
- return false;
-
- return true;
- }
-
- /*
- * @name hashCode
- *
- * @desc gets the hashcode for this object.
- *
- * @return int
- */
- public int hashCode() {
- return this.getClass().getName().hashCode();
- }
-
- public void setRaName(String name) {
- this.raName = name;
-
- // this helps verify assertion Connector:SPEC:279
- String str = "setRAName called with raname=" + raName;
- ConnectorStatus.getConnectorStatus().logState(str);
- debug(str);
- }
-
- public String getRaName() {
- debug("PermissionDDResourceAdapterImpl.getRAName");
- return raName;
- }
-
- public void debug(String out) {
- Debug.trace("PermissionDDResourceAdapterImpl: " + out);
- }
-
- public void setServerSideUser(String val) {
- this.serverSideUser = val;
- }
-
- public String getServerSideUser() {
- return this.serverSideUser;
- }
-
- public void setServerSidePwd(String val) {
- this.serverSidePwd = val;
- }
-
- public String getServerSidePwd() {
- return this.serverSidePwd;
- }
-
- public void setEisUser(String val) {
- this.eisUser = val;
- }
-
- public String getEisUser() {
- return this.eisUser;
- }
-
- public void setEisPwd(String val) {
- this.eisUser = val;
- }
-
- public String getEisPwd() {
- return this.eisPwd;
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/permissiondd/PermissionDDWorkManager.java b/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/permissiondd/PermissionDDWorkManager.java
deleted file mode 100644
index dfaa49c6c5..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/connector/whitebox/permissiondd/PermissionDDWorkManager.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Copyright (c) 2014, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.common.connector.whitebox.permissiondd;
-
-import java.io.FilePermission;
-import java.net.SocketPermission;
-import java.security.AccessControlException;
-import java.security.AccessController;
-import java.security.Permission;
-import java.security.PrivilegedExceptionAction;
-import java.util.PropertyPermission;
-
-import javax.transaction.xa.Xid;
-
-import com.sun.ts.tests.common.connector.util.ConnectorStatus;
-import com.sun.ts.tests.common.connector.whitebox.Debug;
-
-import jakarta.resource.spi.BootstrapContext;
-import jakarta.resource.spi.work.WorkManager;
-
-public class PermissionDDWorkManager {
- private BootstrapContext bsc = null;
-
- private WorkManager wmgr;
-
- private Xid myxid;
-
- private Xid mynestxid;
-
- public PermissionDDWorkManager(BootstrapContext val) {
- debug("enterred constructor");
- this.bsc = val;
- this.wmgr = bsc.getWorkManager();
-
- debug("leaving constructor");
- }
-
- public void runTests() {
- debug("enterred runTests");
-
- validateRequiredPermSet();
- validateRestrictedLocalPerm();
-
- // doWork();
- // doTCWork();
- // submitNestedXidWork();
- debug("leaving runTests");
- }
-
- public void validateRequiredPermSet() {
- try {
- RuntimePermission rtperm = new RuntimePermission("loadLibrary.*");
- doCheckPermission(rtperm);
- debug("validateRequiredPermSet(): valid perm for: " + rtperm.toString());
-
- RuntimePermission rtperm2 = new RuntimePermission("queuePrintJob");
- doCheckPermission(rtperm2);
- debug(
- "validateRequiredPermSet(): valid perm for: " + rtperm2.toString());
-
- SocketPermission socperm = new SocketPermission("*", "connect");
- doCheckPermission(socperm);
- debug(
- "validateRequiredPermSet(): valid perm for: " + socperm.toString());
-
- FilePermission fperm = new FilePermission("*", "read");
- doCheckPermission(fperm);
- debug("validateRequiredPermSet(): valid perm for: " + fperm.toString());
-
- PropertyPermission pperm = new PropertyPermission("*", "read");
- doCheckPermission(pperm);
- debug("validateRequiredPermSet(): valid perm for: " + pperm.toString());
-
- // if we have perms we should get here
- debug("SUCCESS: validateRequiredPermSet passed.");
- ConnectorStatus.getConnectorStatus()
- .logState("SUCCESS: validateRequiredPermSet passed.");
- } catch (AccessControlException ex) {
- debug(
- "FAILURE: validateRequiredPermSet throwing AccessControlException.");
- ConnectorStatus.getConnectorStatus().logState(
- "FAILURE: validateRequiredPermSet throwing AccessControlException.");
- Debug.printDebugStack(ex);
- } catch (Exception ex) {
- debug("FAILURE: validateRequiredPermSet had unexpected Exception.");
- ConnectorStatus.getConnectorStatus().logState(
- "FAILURE: validateRequiredPermSet had unexpected Exception.");
- Debug.printDebugStack(ex);
- }
-
- debug("returning from validateRequiredPermSet()");
- return;
- }
-
- public void validateRestrictedLocalPerm() {
- try {
- // call a priviledged method
- PropertyPermission readPropertyPerm = new PropertyPermission(
- "TestPropertyPerm", "read");
-
- try {
- doCheckPermission(readPropertyPerm);
- // should get here
- debug(
- "SUCCESS: validateRestrictedLocalPerm() has grant for read of TestPropertyPerm");
- } catch (AccessControlException ex) {
- // should not get here.
- debug(
- "FAILURE: validateRestrictedLocalPerm() threw unexpected exception for read of TestPropertyPerm.");
- ConnectorStatus.getConnectorStatus().logState(
- "FAILURE: validateRestrictedLocalPerm() threw AccessControlException.");
- Debug.printDebugStack(ex);
- return;
- }
- debug("SUCCESS: validateRestrictedLocalPerm passed.");
- ConnectorStatus.getConnectorStatus()
- .logState("SUCCESS: validateRestrictedLocalPerm passed.");
-
- } catch (Exception ex) {
- debug("FAILURE: validateRestrictedLocalPerm had unexpected exception.");
- ConnectorStatus.getConnectorStatus().logState(
- "FAILURE: validateRestrictedLocalPerm had unexpected exception.");
- Debug.printDebugStack(ex);
- }
-
- debug("returning from validateRestrictedLocalPerm()");
- return;
- }
-
- public void doCheckPermission(Permission pp) throws Exception {
- final Permission perm = pp;
- AccessController.doPrivileged(new PrivilegedExceptionAction() {
- public Void run() throws AccessControlException {
- AccessController.checkPermission(perm);
- return null;
- }
- });
- }
-
- public void setXid(Xid xid) {
- this.myxid = xid;
- }
-
- public Xid getXid() {
- return this.myxid;
- }
-
- public void setNestXid(Xid xid) {
- this.mynestxid = xid;
- }
-
- public Xid getNestXid() {
- return this.mynestxid;
- }
-
- public void debug(String out) {
- Debug.trace("PermissionDDWorkManager: " + out);
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/ejb/calleebeans/StatefulCalleeEJB.java b/common/src/main/java/com/sun/ts/tests/common/ejb/calleebeans/StatefulCalleeEJB.java
deleted file mode 100644
index 26c361ea95..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/ejb/calleebeans/StatefulCalleeEJB.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.ejb.calleebeans;
-
-import java.util.Properties;
-
-import com.sun.ts.lib.util.TestUtil;
-import com.sun.ts.tests.common.ejb.wrappers.StatefulWrapper;
-
-import jakarta.ejb.CreateException;
-
-public class StatefulCalleeEJB extends StatefulWrapper {
-
- /** Modify arg and call StatefulWrapper create method */
- public void ejbCreate(Properties p, SimpleArgument arg)
- throws CreateException {
-
- try {
- TestUtil.init(p);
- TestUtil.logTrace("[StatefulCallee] ejbCreate()");
- super.ejbCreate(p);
- logArgStatus("create input", arg);
- arg.modify();
- logArgStatus("create output", arg);
- } catch (Exception e) {
- TestUtil.logErr("[StatefulCallee] Caught exception: ", e);
- throw new CreateException(e.getMessage());
- }
- }
-
- public void ejbPostCreate(Properties p, SimpleArgument arg)
- throws CreateException {
- TestUtil.logTrace("[StatefulCallee] ejbPostCreate()");
- }
-
- public void call(Properties props, SimpleArgument arg) {
- logArgStatus("input", arg);
- arg.modify();
- logArgStatus("output", arg);
- }
-
- public void logArgStatus(String msg, SimpleArgument arg) {
- TestUtil.logTrace("[StatefulCallee] " + msg + " arg = " + arg.getValue());
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/ejb/dba/CompoundDBSupport.java b/common/src/main/java/com/sun/ts/tests/common/ejb/dba/CompoundDBSupport.java
deleted file mode 100644
index dc2c6a5ce0..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/ejb/dba/CompoundDBSupport.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.ejb.dba;
-
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.Properties;
-
-import com.sun.ts.lib.util.TestUtil;
-
-import jakarta.ejb.CreateException;
-
-/**
- * DB Support object for DB table using whose primary key is an 'float'.
- */
-public class CompoundDBSupport extends DBSupport
- implements java.io.Serializable {
-
- /** Name of the property whose value is the DB table name */
- protected static final String compoundTablePrefix = "compoundPKTable";
-
- PreparedStatement pStmt = null;
-
- ResultSet result = null;
-
- /*
- * Cached data
- */
- protected CompoundPK cofID = null; /* Coffee ID (Primary Key) */
-
- protected String cofName = null; /* Coffee Name */
-
- protected float cofPrice = 0; /* Coffee Price */
-
- /**
- * Create a new DBSupport object. If called from an EJB or a Web component,
- * you must make sure to call TestUtil.init() before creating a new DBSupport
- * object.
- */
- public CompoundDBSupport() throws Exception {
- super(compoundTablePrefix);
- }
-
- public static void initTable(Properties props) throws Exception {
- DBSupport.initTable(compoundTablePrefix, props);
- }
-
- public boolean keyExists(CompoundPK pkey) throws SQLException {
- try {
- TestUtil.logTrace("[CompoundDBSupport] keyExists(" + pkey + ")");
-
- getDBConnection();
- pStmt = getStmt("Select_PK");
- pStmt.setInt(1, pkey.pmIDInteger.intValue());
- pStmt.setString(2, pkey.pmIDString);
- pStmt.setFloat(3, pkey.pmIDFloat.floatValue());
- result = pStmt.executeQuery();
-
- return result.next();
- } catch (SQLException e) {
- throw new SQLException("SQL Exception in keyExists:" + e);
- } finally {
- closeStmt(pStmt, result);
- }
- }
-
- public void createNewRow(CompoundPK cofID, String cofName, float cofPrice)
- throws CreateException, SQLException {
-
- try {
- TestUtil.logTrace("[CompoundDBSupport] createNewRow(" + cofID + ", "
- + cofName + ", " + cofPrice + ")");
-
- pStmt = getStmt("Insert");
- pStmt.setInt(1, cofID.pmIDInteger.intValue());
- pStmt.setString(2, cofID.pmIDString);
- pStmt.setFloat(3, cofID.pmIDFloat.floatValue());
- pStmt.setString(4, cofName);
- pStmt.setFloat(5, cofPrice);
- TestUtil.logTrace("[CompoundDBSupport] Execute stmt" + pStmt);
- if (1 != pStmt.executeUpdate()) {
- throw new CreateException("INSERT failed in createNewRow");
- } else {
- /* Keep cached state */
- this.cofID = cofID;
- this.cofName = cofName;
- this.cofPrice = cofPrice;
- }
- } catch (SQLException e) {
- TestUtil.printStackTrace(e);
- throw new SQLException("SQL Exception in createNewRow" + e);
- } finally {
- closeStmt(pStmt, null);
- }
-
- TestUtil.logTrace("[CompoundDBSupport] New row created !");
- }
-
- public float loadPrice(CompoundPK pkey) throws SQLException {
-
- try {
- TestUtil.logTrace("[CompoundDBSupport] loadPrice(" + pkey + ")");
-
- pStmt = getStmt("Select_Price");
- pStmt.setInt(1, pkey.pmIDInteger.intValue());
- pStmt.setString(2, pkey.pmIDString);
- pStmt.setFloat(3, pkey.pmIDFloat.floatValue());
- result = pStmt.executeQuery();
- if (!result.next()) {
- throw new SQLException("No record for PK = " + pkey);
- }
-
- return result.getFloat(1);
- } catch (SQLException e) {
- throw new SQLException("SQLException in loadPrice(): " + e);
- } finally {
- closeStmt(pStmt, result);
- }
- }
-
- public void storePrice(CompoundPK pkey, float cofPrice) throws SQLException {
-
- try {
- TestUtil.logTrace("[CompoundDBSupport] storePrice()");
- pStmt = getStmt("Update");
- pStmt.setFloat(1, cofPrice);
- pStmt.setInt(2, pkey.pmIDInteger.intValue());
- pStmt.setString(3, pkey.pmIDString);
- pStmt.setFloat(4, pkey.pmIDFloat.floatValue());
- if (1 != pStmt.executeUpdate()) {
- throw new SQLException("SQL UPDATE failed in storePrice");
- }
-
- this.cofPrice = cofPrice;
- } catch (SQLException e) {
- throw new SQLException("SQL Exception in storePrice(): " + e);
- } finally {
- closeStmt(pStmt, null);
- }
- }
-
- public void removeRow(CompoundPK pkey) throws SQLException {
-
- try {
- TestUtil.logTrace("[CompoundDBSupport] removeRow()");
- pStmt = getStmt("Delete");
- pStmt.setInt(1, pkey.pmIDInteger.intValue());
- pStmt.setString(2, pkey.pmIDString);
- pStmt.setFloat(3, pkey.pmIDFloat.floatValue());
- if (1 != pStmt.executeUpdate()) {
- throw new SQLException("DELETE failed in removeRow");
- }
- } catch (SQLException e) {
- throw new SQLException("SQL Exception in removeRow(): " + e);
- } finally {
- closeStmt(pStmt, null);
- }
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/ejb/dba/CompoundPK.java b/common/src/main/java/com/sun/ts/tests/common/ejb/dba/CompoundPK.java
deleted file mode 100644
index 62c5a2ba10..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/ejb/dba/CompoundPK.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 2007, 2018 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.ejb.dba;
-
-/*
- * Class used to define a compound primary key for Entity beans.
- */
-public class CompoundPK implements java.io.Serializable {
- /* Fields */
- public Integer pmIDInteger;
-
- public String pmIDString;
-
- public Float pmIDFloat;
-
- /** Standard Constructor */
- public CompoundPK(int intID, String strID, float floatID) {
- this.pmIDInteger = new Integer(intID);
- this.pmIDString = strID;
- this.pmIDFloat = new Float(floatID);
- }
-
- /** Public constructor with no parameters */
- public CompoundPK() {
- this.pmIDInteger = new Integer(0);
- this.pmIDString = "Limbo";
- this.pmIDFloat = new Float(0.0);
- }
-
- /** Override java.lang.Object method */
- public int hashCode() {
- int myHash;
-
- myHash = this.pmIDInteger.hashCode() + this.pmIDString.hashCode()
- + this.pmIDFloat.hashCode();
-
- return myHash;
- }
-
- /** Override java.lang.Object method */
- public boolean equals(Object o) {
- CompoundPK other;
- boolean same = true;
-
- if (!(o instanceof CompoundPK)) {
- return false;
- }
- other = (CompoundPK) o;
-
- same &= this.pmIDInteger.equals(other.pmIDInteger);
- same &= this.pmIDString.equals(other.pmIDString);
- same &= this.pmIDFloat.equals(other.pmIDFloat);
-
- return same;
- }
-
- /** Override java.lang.Object method */
- public String toString() {
- return "CompoundPK [ " + pmIDInteger + ", " + pmIDString + ", " + pmIDFloat
- + " ]";
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/ejb/dba/DBSupport.java b/common/src/main/java/com/sun/ts/tests/common/ejb/dba/DBSupport.java
deleted file mode 100644
index d1eaa0e99a..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/ejb/dba/DBSupport.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.ejb.dba;
-
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.Properties;
-
-import javax.sql.DataSource;
-
-import com.sun.ts.lib.util.TSNamingContext;
-import com.sun.ts.lib.util.TestUtil;
-
-/**
- * Provide basic DB support for TS deployment tests, using The Datasource
- * referenced as 'jdbc/DB1' in the component environment.
- *
- * This class is not intended to be used "as is", but rather to be sub-classed
- * by other DB support classes focusing on a particular DB schema (and in
- * particular on a type of primary key).
- */
-public class DBSupport implements java.io.Serializable {
-
- /** Prefix used for JNDI lookups */
- protected static final String prefix = "java:comp/env/";
-
- /** JNDI name used to lookup the DataSource */
- protected static final String DBLookupName = prefix + "jdbc/DB1";
-
- /** DB table prefix. Used to get the appropriate SQL properties */
- protected String tablePrefix = null;
-
- protected DataSource ds = null;
-
- protected transient Connection dbConnection = null;
-
- protected TSNamingContext nctx = null;
-
- /*
- * Cached data
- */
- protected int cofID = 0; // Coffee ID (Primary Key)
-
- protected String cofName = null; // Coffee Name
-
- protected float cofPrice = 0; // Coffee Price
-
- /**
- * Create a new DBSupport object. If called from an EJB or a Web component,
- * you must make sure to call TestUtil.init() before creating a new DBSupport
- * object (so that you can safely use TestUtil.getProperty).
- *
- * @param tablePrefix
- * Prefix to use for SQL properties lookups.
- */
- public DBSupport(String tablePrefix) throws Exception {
-
- this.tablePrefix = tablePrefix;
- TestUtil.logTrace("[DBSupport] Getting naming context...");
- this.nctx = new TSNamingContext();
-
- TestUtil.logTrace("[DBSupport] Lookup DataSource " + DBLookupName);
- ds = (DataSource) nctx.lookup(DBLookupName);
- }
-
- /**
- * Initialize DB table (remove all existing rows).
- *
- * Method is static so that it can be easily called from the Application
- * Client setup method.
- */
- public static void initTable(String tablePrefix, Properties props)
- throws Exception {
-
- String cleanupPropName = "DEPLOY_" + tablePrefix + "_Cleanup";
- DataSource ds = null;
- Connection conn = null;
- Statement stmt = null;
- TSNamingContext nctx;
- String sqlStr;
-
- TestUtil.logTrace("[DBSupport] initTable()");
- try {
- if (null == tablePrefix) { /* Sanity check */
- throw new Exception("tablePrefix cannot be null!");
- }
-
- TestUtil.logTrace("[DBSupport] Getting naming context...");
- nctx = new TSNamingContext();
-
- TestUtil.logTrace("[DBSupport] Lookup DataSource " + DBLookupName);
- ds = (DataSource) nctx.lookup(DBLookupName);
-
- TestUtil.logTrace("[DBSupport] Getting DB connection...");
- conn = ds.getConnection();
-
- TestUtil.logTrace("[DBSupport] Cleanup table");
- stmt = conn.createStatement();
- TestUtil.logTrace("[DBSupport] Use SQL prop " + cleanupPropName);
- sqlStr = TestUtil.getProperty(cleanupPropName);
- TestUtil.logTrace("[DBSupport] SQL = '" + sqlStr + "'");
- stmt.executeUpdate(sqlStr);
- TestUtil.logTrace("[DBSupport] Table cleaned up!");
-
- } catch (SQLException e) {
- TestUtil.logErr("[DBSupport] Cannot init table :" + e);
- throw new SQLException("SQL Exception in initTable: " + e);
- } finally {
- try {
- if (null != stmt) {
- stmt.close();
- }
- if (null != conn) {
- conn.close();
- }
- } catch (SQLException e) {
- TestUtil.logTrace("[DBSupport] Ignoring Exception (cleanup): " + e);
- }
- }
- }
-
- /** Make sure we have a valid DB connection handy */
- public void getDBConnection() throws SQLException {
- TestUtil.logTrace("[DBSupport] getDBConnection()");
- if (null == dbConnection) {
- dbConnection = ds.getConnection();
- }
- }
-
- /** Close current DB connection, if applicable */
- public void closeDBConnection() throws SQLException {
- TestUtil.logTrace("[DBSupport] closeDBConnection()");
- if (null != dbConnection) {
- dbConnection.close();
- dbConnection = null; /* Detect later we closed it */
- }
- }
-
- /**
- * Generic method to get a SQL statement for current table.
- *
- * We get the SQL code associated with the DEPLOY__ TS
- * property.
- */
- public PreparedStatement getStmt(String suffix) throws SQLException {
- PreparedStatement pStmt;
- String sqlPropName;
- String sqlStr;
-
- TestUtil.logTrace("getStmt()");
- getDBConnection();
- TestUtil.logMsg("connection = " + dbConnection);
- sqlPropName = "DEPLOY_" + tablePrefix + "_" + suffix;
- TestUtil.logTrace("[DBSupport] Get SQL for " + sqlPropName);
- sqlStr = TestUtil.getProperty(sqlPropName);
- TestUtil.logMsg("[DBSupport] SQL = " + sqlStr);
- TestUtil.logMsg("[DBSupport] getStatement: " + dbConnection);
- pStmt = dbConnection.prepareStatement(sqlStr);
-
- return pStmt;
- }
-
- /**
- * Close the ResultSet and the PreparedStatement in a safely manner and
- * ignoring any SQLException that could be thrown. This method is designed to
- * be called from a finally block to ensure the release of associated
- * resources.
- */
- public void closeStmt(PreparedStatement pStmt, ResultSet result) {
- try {
- if (null != result) {
- result.close();
- }
- } catch (SQLException e) {
- TestUtil.logTrace(
- "[DBSupport] Ignoring Exception while " + "closing ResultSet: " + e);
- }
-
- try {
- if (null != pStmt) {
- pStmt.close();
- }
- } catch (SQLException e) {
- TestUtil.logTrace("[DBSupport] Ignoring Exception while "
- + "closing PreparedStatement: " + e);
- }
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/ejb/dba/FloatDBSupport.java b/common/src/main/java/com/sun/ts/tests/common/ejb/dba/FloatDBSupport.java
deleted file mode 100644
index fedc205f06..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/ejb/dba/FloatDBSupport.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.ejb.dba;
-
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.Properties;
-
-import com.sun.ts.lib.util.TestUtil;
-
-import jakarta.ejb.CreateException;
-
-/**
- * DB Support object for DB table using whose primary key is an 'float'.
- */
-public class FloatDBSupport extends DBSupport implements java.io.Serializable {
-
- /** Name of the property whose value is the DB table name */
- protected static final String floatTablePrefix = "floatPKTable";
-
- PreparedStatement pStmt = null;
-
- ResultSet result = null;
-
- /*
- * Cached data
- */
- protected float cofID = 0; /* Coffee ID (Primary Key) */
-
- protected String cofName = null; /* Coffee Name */
-
- protected float cofPrice = 0; /* Coffee Price */
-
- /**
- * Create a new DBSupport object. If called from an EJB or a Web component,
- * you must make sure to call TestUtil.init() before creating a new DBSupport
- * object.
- */
- public FloatDBSupport() throws Exception {
- super(floatTablePrefix);
- }
-
- public static void initTable(Properties props) throws Exception {
- DBSupport.initTable(floatTablePrefix, props);
- }
-
- public boolean keyExists(float pkey) throws SQLException {
- try {
- TestUtil.logTrace("[FloatDBSupport] keyExists(" + pkey + ")");
-
- getDBConnection();
- pStmt = getStmt("Select_PK");
- pStmt.setFloat(1, pkey);
- result = pStmt.executeQuery();
-
- return result.next();
- } catch (SQLException e) {
- throw new SQLException("SQL Exception in keyExists: " + e);
- } finally {
- closeStmt(pStmt, result);
- }
- }
-
- public void createNewRow(float cofID, String cofName, float cofPrice)
- throws CreateException, SQLException {
-
- try {
- TestUtil.logTrace("[FloatDBSupport] createNewRow(" + cofID + ", "
- + cofName + ", " + cofPrice + ")");
-
- pStmt = getStmt("Insert");
- pStmt.setFloat(1, cofID);
- pStmt.setString(2, cofName);
- pStmt.setFloat(3, cofPrice);
- TestUtil.logTrace("[FloatDBSupport] Execute stmt" + pStmt);
- if (1 != pStmt.executeUpdate()) {
- throw new CreateException("INSERT failed in createNewRow");
- } else {
- /* Keep cached state */
- this.cofID = cofID;
- this.cofName = cofName;
- this.cofPrice = cofPrice;
- }
- } catch (SQLException e) {
- TestUtil.printStackTrace(e);
- throw new SQLException("SQL Exception in createNewRow" + e);
- } finally {
- closeStmt(pStmt, null);
- }
-
- TestUtil.logTrace("[FloatDBSupport] New row created !");
- }
-
- public float loadPrice(float pkey) throws SQLException {
-
- try {
- TestUtil.logTrace("[FloatDBSupport] loadPrice(" + pkey + ")");
-
- pStmt = getStmt("Select_Price");
- pStmt.setFloat(1, pkey);
- result = pStmt.executeQuery();
- if (!result.next()) {
- throw new SQLException("No record for PK = " + pkey);
- }
-
- return result.getFloat(1);
- } catch (SQLException e) {
- throw new SQLException("SQLException in loadPrice(): " + e);
- } finally {
- closeStmt(pStmt, result);
- }
- }
-
- public void storePrice(float pkey, float cofPrice) throws SQLException {
-
- try {
- TestUtil.logTrace("[FloatDBSupport] storePrice()");
- pStmt = getStmt("Update");
- pStmt.setFloat(1, cofPrice);
- pStmt.setFloat(2, pkey);
- if (1 != pStmt.executeUpdate()) {
- throw new SQLException("SQL UPDATE failed in storePrice");
- }
-
- this.cofPrice = cofPrice;
- } catch (SQLException e) {
- throw new SQLException("SQLException in storePrice(): " + e);
- } finally {
- closeStmt(pStmt, null);
- }
- }
-
- public void removeRow(float pkey) throws SQLException {
-
- try {
- TestUtil.logTrace("[FloatDBSupport] removeRow()");
- pStmt = getStmt("Delete");
- pStmt.setFloat(1, pkey);
- if (1 != pStmt.executeUpdate()) {
- throw new SQLException("DELETE failed in removeRow");
- }
- } catch (SQLException e) {
- throw new SQLException("SQLException in removeRow(): " + e);
- } finally {
- closeStmt(pStmt, null);
- }
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/ejb/dba/IntegerDBSupport.java b/common/src/main/java/com/sun/ts/tests/common/ejb/dba/IntegerDBSupport.java
deleted file mode 100644
index c1eb1c2ecf..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/ejb/dba/IntegerDBSupport.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.ejb.dba;
-
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.Properties;
-
-import com.sun.ts.lib.util.TestUtil;
-
-import jakarta.ejb.CreateException;
-
-/**
- * DB Support object for DB table using whose primary key is an 'int'.
- */
-public class IntegerDBSupport extends DBSupport
- implements java.io.Serializable {
-
- /** Name of the property whose value is the DB table name */
- protected static final String intTablePrefix = "intPKTable";
-
- PreparedStatement pStmt = null;
-
- ResultSet result = null;
-
- /*
- * Cached data
- */
- protected int cofID = 0; /* Coffee ID (Primary Key) */
-
- protected String cofName = null; /* Coffee Name */
-
- protected float cofPrice = 0; /* Coffee Price */
-
- /**
- * Create a new DBSupport object. If called from an EJB or a Web component,
- * you must make sure to call TestUtil.init() before creating a new DBSupport
- * object.
- */
- public IntegerDBSupport() throws Exception {
- super(intTablePrefix);
- }
-
- public static void initTable(Properties props) throws Exception {
- DBSupport.initTable(intTablePrefix, props);
- }
-
- public boolean keyExists(int pkey) throws SQLException {
- try {
- TestUtil.logTrace("[IntegerDBSupport] keyExists(" + pkey + ")");
-
- getDBConnection();
- pStmt = getStmt("Select_PK");
- pStmt.setInt(1, pkey);
- result = pStmt.executeQuery();
-
- return result.next();
- } catch (SQLException e) {
- throw new SQLException("SQLException in keyExists: " + e);
- } finally {
- closeStmt(pStmt, result);
- }
- }
-
- public void createNewRow(int cofID, String cofName, float cofPrice)
- throws CreateException, SQLException {
-
- try {
- TestUtil.logTrace("[IntegerDBSupport] createNewRow(" + cofID + ", "
- + cofName + ", " + cofPrice + ")");
-
- pStmt = getStmt("Insert");
- pStmt.setInt(1, cofID);
- pStmt.setString(2, cofName);
- pStmt.setFloat(3, cofPrice);
- TestUtil.logTrace("[IntegerDBSupport] Execute stmt" + pStmt);
- if (1 != pStmt.executeUpdate()) {
- throw new CreateException("INSERT failed in createNewRow");
- } else {
- /* Keep cached state */
- this.cofID = cofID;
- this.cofName = cofName;
- this.cofPrice = cofPrice;
- }
- } catch (SQLException e) {
- TestUtil.printStackTrace(e);
- throw new SQLException("SQLException in createNewRow" + e);
- } finally {
- closeStmt(pStmt, null);
- }
-
- TestUtil.logTrace("[IntegerDBSupport] New row created !");
- }
-
- public float loadPrice(int pkey) throws SQLException {
-
- try {
- TestUtil.logTrace("[IntegerDBSupport] loadPrice(" + pkey + ")");
-
- pStmt = getStmt("Select_Price");
- pStmt.setInt(1, pkey);
- result = pStmt.executeQuery();
- if (!result.next()) {
- throw new SQLException("No record for PK = " + pkey);
- }
-
- return result.getFloat(1);
- } catch (SQLException e) {
- throw new SQLException("SQLException in loadPrice(): " + e);
- } finally {
- closeStmt(pStmt, result);
- }
- }
-
- public void storePrice(int pkey, float cofPrice) throws SQLException {
-
- try {
- TestUtil.logTrace("[IntegerDBSupport] storePrice()");
- pStmt = getStmt("Update");
- pStmt.setFloat(1, cofPrice);
- pStmt.setInt(2, pkey);
- if (1 != pStmt.executeUpdate()) {
- throw new SQLException("UPDATE failed in storePrice");
- }
-
- this.cofPrice = cofPrice;
- } catch (SQLException e) {
- throw new SQLException("SQLException in storePrice(): " + e);
- } finally {
- closeStmt(pStmt, null);
- }
- }
-
- public void removeRow(int pkey) throws SQLException {
-
- try {
- TestUtil.logTrace("[IntegerDBSupport] removeRow()");
- pStmt = getStmt("Delete");
- pStmt.setInt(1, pkey);
- if (1 != pStmt.executeUpdate()) {
- throw new SQLException("DELETE failed in removeRow");
- }
- } catch (SQLException e) {
- throw new SQLException("SQLException in removeRow(): " + e);
- } finally {
- closeStmt(pStmt, null);
- }
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/ejb/dba/LongDBSupport.java b/common/src/main/java/com/sun/ts/tests/common/ejb/dba/LongDBSupport.java
deleted file mode 100644
index 8ce554d38a..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/ejb/dba/LongDBSupport.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.ejb.dba;
-
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.Properties;
-
-import com.sun.ts.lib.util.TestUtil;
-
-import jakarta.ejb.CreateException;
-
-/**
- * DB Support object for DB table using whose primary key is an 'long'.
- */
-public class LongDBSupport extends DBSupport implements java.io.Serializable {
-
- /** Name of the property whose value is the DB table name */
- protected static final String longTablePrefix = "longPKTable";
-
- PreparedStatement pStmt = null;
-
- ResultSet result = null;
-
- /*
- * Cached data
- */
- protected long cofID = 0; /* Coffee ID (Primary Key) */
-
- protected String cofName = null; /* Coffee Name */
-
- protected float cofPrice = 0; /* Coffee Price */
-
- /**
- * Create a new DBSupport object. If called from an EJB or a Web component,
- * you must make sure to call TestUtil.init() before creating a new DBSupport
- * object.
- */
- public LongDBSupport() throws Exception {
- super(longTablePrefix);
- }
-
- public static void initTable(Properties props) throws Exception {
- DBSupport.initTable(longTablePrefix, props);
- }
-
- public boolean keyExists(long pkey) throws SQLException {
- try {
- TestUtil.logTrace("[LongDBSupport] keyExists(" + pkey + ")");
-
- getDBConnection();
- pStmt = getStmt("Select_PK");
- pStmt.setLong(1, pkey);
- result = pStmt.executeQuery();
-
- return result.next();
- } catch (SQLException e) {
- throw new SQLException("SQLException in keyExists: " + e);
- } finally {
- closeStmt(pStmt, result);
- }
- }
-
- public void createNewRow(long cofID, String cofName, float cofPrice)
- throws CreateException, SQLException {
-
- try {
- TestUtil.logTrace("[LongDBSupport] createNewRow(" + cofID + ", " + cofName
- + ", " + cofPrice + ")");
-
- pStmt = getStmt("Insert");
- pStmt.setLong(1, cofID);
- pStmt.setString(2, cofName);
- pStmt.setFloat(3, cofPrice);
- TestUtil.logTrace("[LongDBSupport] Execute stmt" + pStmt);
- if (1 != pStmt.executeUpdate()) {
- throw new CreateException("INSERT failed in createNewRow");
- } else {
- /* Keep cached state */
- this.cofID = cofID;
- this.cofName = cofName;
- this.cofPrice = cofPrice;
- }
- } catch (SQLException e) {
- TestUtil.printStackTrace(e);
- throw new SQLException("SQLException in createNewRow" + e);
- } finally {
- closeStmt(pStmt, null);
- }
-
- TestUtil.logTrace("[LongDBSupport] New row created !");
- }
-
- public float loadPrice(long pkey) throws SQLException {
-
- try {
- TestUtil.logTrace("[LongDBSupport] loadPrice(" + pkey + ")");
-
- pStmt = getStmt("Select_Price");
- pStmt.setLong(1, pkey);
- result = pStmt.executeQuery();
- if (!result.next()) {
- throw new SQLException("No record for PK = " + pkey);
- }
-
- return result.getFloat(1);
- } catch (SQLException e) {
- throw new SQLException("SQLException in loadPrice(): " + e);
- } finally {
- closeStmt(pStmt, result);
- }
- }
-
- public void storePrice(long pkey, float cofPrice) throws SQLException {
-
- try {
- TestUtil.logTrace("[LongDBSupport] storePrice()");
- pStmt = getStmt("Update");
- pStmt.setFloat(1, cofPrice);
- pStmt.setLong(2, pkey);
- if (1 != pStmt.executeUpdate()) {
- throw new SQLException("UPDATE failed in storePrice");
- }
-
- this.cofPrice = cofPrice;
- } catch (SQLException e) {
- throw new SQLException("SQLException in storePrice(): " + e);
- } finally {
- closeStmt(pStmt, null);
- }
- }
-
- public void removeRow(long pkey) throws SQLException {
-
- try {
- TestUtil.logTrace("[LongDBSupport] removeRow()");
- pStmt = getStmt("Delete");
- pStmt.setLong(1, pkey);
- if (1 != pStmt.executeUpdate()) {
- throw new SQLException("DELETE failed in removeRow");
- }
- } catch (SQLException e) {
- throw new SQLException("SQLException in removeRow(): " + e);
- } finally {
- closeStmt(pStmt, null);
- }
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/ejb/dba/StringDBSupport.java b/common/src/main/java/com/sun/ts/tests/common/ejb/dba/StringDBSupport.java
deleted file mode 100644
index 0d37abeac1..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/ejb/dba/StringDBSupport.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.ejb.dba;
-
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.Properties;
-
-import com.sun.ts.lib.util.TestUtil;
-
-import jakarta.ejb.CreateException;
-
-/**
- * DB Support object for DB table using whose primary key is an 'int'.
- */
-public class StringDBSupport extends DBSupport implements java.io.Serializable {
-
- /** Name of the property whose value is the DB table name */
- protected static final String strTablePrefix = "strPKTable";
-
- PreparedStatement pStmt = null;
-
- ResultSet result = null;
-
- /*
- * Cached data
- */
- protected String cofID = null; /* Coffee ID (Primary Key) */
-
- protected String cofName = null; /* Coffee Name */
-
- protected float cofPrice = 0; /* Coffee Price */
-
- /**
- * Create a new DBSupport object. If called from an EJB or a Web component,
- * you must make sure to call TestUtil.init() before creating a new DBSupport
- * object.
- */
- public StringDBSupport() throws Exception {
- super(strTablePrefix);
- }
-
- public static void initTable(Properties props) throws Exception {
- DBSupport.initTable(strTablePrefix, props);
- }
-
- public boolean keyExists(String pkey) throws SQLException {
- try {
- TestUtil.logTrace("[StringDBSupport] keyExists(" + pkey + ")");
-
- getDBConnection();
- pStmt = getStmt("Select_PK");
- pStmt.setString(1, pkey);
- result = pStmt.executeQuery();
-
- return result.next();
- } catch (SQLException e) {
- throw new SQLException("SQLException in keyExists: " + e);
- } finally {
- closeStmt(pStmt, result);
- }
- }
-
- public void createNewRow(String cofID, String cofName, float cofPrice)
- throws CreateException, SQLException {
-
- try {
- TestUtil.logTrace("[StringDBSupport] createNewRow(" + cofID + ", "
- + cofName + ", " + cofPrice + ")");
-
- pStmt = getStmt("Insert");
- pStmt.setString(1, cofID);
- pStmt.setString(2, cofName);
- pStmt.setFloat(3, cofPrice);
- TestUtil.logTrace("[StringDBSupport] Execute stmt" + pStmt);
- if (1 != pStmt.executeUpdate()) {
- throw new CreateException("INSERT failed in createNewRow");
- } else {
- /* Keep cached state */
- this.cofID = cofID;
- this.cofName = cofName;
- this.cofPrice = cofPrice;
- }
- } catch (SQLException e) {
- TestUtil.printStackTrace(e);
- throw new SQLException("SQLException in createNewRow" + e);
- } finally {
- closeStmt(pStmt, null);
- }
-
- TestUtil.logTrace("[StringDBSupport] New row created !");
- }
-
- public float loadPrice(String pkey) throws SQLException {
-
- try {
- TestUtil.logTrace("[StringDBSupport] loadPrice(" + pkey + ")");
-
- pStmt = getStmt("Select_Price");
- pStmt.setString(1, pkey);
- result = pStmt.executeQuery();
- if (!result.next()) {
- throw new SQLException("No record for PK = " + pkey);
- }
-
- return result.getFloat(1);
- } catch (SQLException e) {
- throw new SQLException("SQLException in loadPrice(): " + e);
- } finally {
- closeStmt(pStmt, result);
- }
- }
-
- public void storePrice(String pkey, float cofPrice) throws SQLException {
-
- try {
- TestUtil.logTrace("[StringDBSupport] storePrice()");
- pStmt = getStmt("Update");
- pStmt.setFloat(1, cofPrice);
- pStmt.setString(2, pkey);
- if (1 != pStmt.executeUpdate()) {
- throw new SQLException("UPDATE failed in storePrice");
- }
-
- this.cofPrice = cofPrice;
- } catch (SQLException e) {
- throw new SQLException("SQLException in storePrice(): " + e);
- } finally {
- closeStmt(pStmt, null);
- }
- }
-
- public void removeRow(String pkey) throws SQLException {
-
- try {
- TestUtil.logTrace("[StringDBSupport] removeRow()");
- pStmt = getStmt("Delete");
- pStmt.setString(1, pkey);
- if (1 != pStmt.executeUpdate()) {
- throw new SQLException("DELETE failed in removeRow");
- }
- } catch (SQLException e) {
- throw new SQLException("SQLException in removeRow(): " + e);
- } finally {
- closeStmt(pStmt, null);
- }
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/ejb/wrappers/MDBWrapper.java b/common/src/main/java/com/sun/ts/tests/common/ejb/wrappers/MDBWrapper.java
deleted file mode 100644
index 4b37dd3d21..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/ejb/wrappers/MDBWrapper.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.ejb.wrappers;
-
-import java.lang.reflect.Method;
-import java.util.Enumeration;
-import java.util.Properties;
-
-import com.sun.ts.lib.util.TSNamingContext;
-import com.sun.ts.lib.util.TestUtil;
-
-import com.sun.ts.tests.jms.common.JmsUtil;
-import jakarta.ejb.EJBException;
-import jakarta.ejb.MessageDrivenBean;
-import jakarta.ejb.MessageDrivenContext;
-import jakarta.jms.JMSException;
-import jakarta.jms.Message;
-import jakarta.jms.MessageListener;
-import jakarta.jms.Queue;
-import jakarta.jms.QueueConnection;
-import jakarta.jms.QueueConnectionFactory;
-import jakarta.jms.QueueSender;
-import jakarta.jms.QueueSession;
-import jakarta.jms.TextMessage;
-
-/**
- * Life cyle and test invocation methods for MDB. Actual test methods are
- * defined in subclasses of this class.
- *
- * WARNING: We assume the MDB is CMT. Do not use this wrapper for a BMT MDB!
- */
-public class MDBWrapper implements MessageDrivenBean, MessageListener {
-
- protected static final String prefix = "java:comp/env/jms/";
-
- protected static final String qFactoryLookup = prefix
- + "myQueueConnectionFactory";
-
- protected static final String replyQueueLookup = prefix + "replyQueue";
-
- public TSNamingContext nctx = null;
-
- protected MessageDrivenContext mctx = null;
-
- protected QueueConnectionFactory qFactory;
-
- protected QueueConnection conn = null;
-
- protected Queue replyQueue = null;
-
- protected QueueSender mSender = null;
-
- protected boolean result = false;
-
- public void ejbCreate() {
- try {
- TestUtil.logTrace("[MDBWrapper] ejbCreate()");
- nctx = new TSNamingContext();
- TestUtil.logTrace("[MDBWrapper] Looking up " + qFactoryLookup);
- qFactory = (QueueConnectionFactory) nctx.lookup(qFactoryLookup);
- TestUtil.logTrace("[MDBWrapper] Looking up " + replyQueueLookup);
- replyQueue = (Queue) nctx.lookup(replyQueueLookup);
- } catch (Exception e) {
- TestUtil.logErr("[MDBWrapper] Exception in ejbCreate()", e);
- /* Send instance to "does not exist" state */
- throw new EJBException("Exception in ejbCreate()", e);
- }
- }
-
- public void setMessageDrivenContext(MessageDrivenContext mctx) {
- TestUtil.logTrace("[MDBWrapper] setMessageDrivenContext()");
- this.mctx = mctx;
- }
-
- public void ejbRemove() {
- TestUtil.logTrace("[MDBWrapper] ejbRemove()");
- }
-
- public void onMessage(Message msg) {
- QueueSession session = null;
- TextMessage messageSent = null;
- String testName = "Undefined";
- Properties props = null;
- boolean pass = false;
-
- try {
- props = getProperties(msg);
- TestUtil.init(props);
- testName = msg.getStringProperty("COM_SUN_JMS_TESTNAME");
-
- // if we're cleaning up, no need to report test results
- if (testName.equals("cleanUpBean")) {
- TestUtil.logTrace("[MDBWrapper] Removing stateful session bean");
- runTest(testName, msg, session, props);
- return;
- }
- pass = runTest(testName, msg, session, props);
-
- conn = qFactory.createQueueConnection();
- session = conn.createQueueSession(true, 0);
- JmsUtil.sendTestResults(testName, pass, session, replyQueue);
- } catch (Exception e) {
- TestUtil.logErr("[MDBWrapper] Exception in onMessage(): ", e);
- } finally {
- cleanup(conn);
- }
-
- }
-
- /**
- * Run corresponding test by invoking test method on the current instance
- * (also used for cleanup of stateful session beans).
- */
- protected boolean runTest(String testName, Message msg, QueueSession session,
- Properties props) {
-
- Boolean pass = Boolean.FALSE;
- Class testDriverClass;
- Method testMethod;
- Class params[] = { Properties.class };
- Object args[] = new Object[1];
-
- TestUtil.logTrace("[MDBWrapper] runTest()");
-
- try {
- TestUtil.logTrace("[MDBWrapper] run test '" + testName + "'");
- testDriverClass = this.getClass();
- testMethod = testDriverClass.getMethod(testName, params);
- args[0] = props;
- pass = (Boolean) testMethod.invoke(this, args);
- } catch (NoSuchMethodException e) {
- TestUtil.logErr("[MDBWrapper] Cannot find method '" + testName
- + "' make sure it is defined " + "in sub-class", e);
- pass = Boolean.FALSE;
- } catch (Exception e) {
- TestUtil.logErr("[MDBWrapper] Unexpected exception", e);
- pass = Boolean.FALSE;
- }
-
- return pass.booleanValue();
- }
-
- /**
- * Construct a property object needed by TS harness for logging. We retrieve
- * the properties from the Message object passed into the MDB onMessage()
- * method
- */
- protected Properties getProperties(Message msg) throws JMSException {
- Properties props;
- String hostname = null;
- String traceflag = null;
- String logport = null;
- Enumeration propNames;
-
- props = new Properties();
-
- /*
- * Because a JMS property name cannot contain '.' the following properties
- * are a special case
- */
- hostname = msg.getStringProperty("harnesshost");
- props.put("harness.host", hostname);
- traceflag = msg.getStringProperty("harnesslogtraceflag");
- props.put("harness.log.traceflag", traceflag);
- logport = msg.getStringProperty("harnesslogport");
- props.put("harness.log.port", logport);
-
- /*
- * now pull out the rest of the properties from the message
- */
- propNames = msg.getPropertyNames();
- for (String name = null; propNames.hasMoreElements();) {
- name = (String) propNames.nextElement();
- props.put(name, msg.getStringProperty(name));
- }
-
- return props;
- }
-
- /** Cleanup method designed to be called within a finally block */
- protected void cleanup(QueueConnection conn) {
- try {
- if (null != conn) {
- conn.close();
- }
- } catch (Exception e) {
- TestUtil.logErr(
- "[MDBWrapper] Ignoring Exception on " + "QueueConnection cleanup: ",
- e);
- }
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/ejb/wrappers/Stateful3xWrapper.java b/common/src/main/java/com/sun/ts/tests/common/ejb/wrappers/Stateful3xWrapper.java
deleted file mode 100644
index 846e71096c..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/ejb/wrappers/Stateful3xWrapper.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2007, 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.ejb.wrappers;
-
-import java.util.Properties;
-
-import com.sun.ts.lib.util.RemoteLoggingInitException;
-import com.sun.ts.lib.util.TSNamingContext;
-import com.sun.ts.lib.util.TestUtil;
-
-import jakarta.ejb.EJBException;
-
-/**
- * Stateful wrapper that provides common methods for a Stateful
- * Session bean. This class is intended to be subclassed by the final
- * bean class that will provide the test logic (business methods).
- */
-public class Stateful3xWrapper {
-
- protected TSNamingContext nctx = null;
-
- protected Properties props;
-
- /*
- * Business methods.
- */
-
- /**
- * Initialize TS logging.
- *
- * @param props
- * TS properties need by TestUtil
- *
- */
- public void initLogging(Properties props) {
- try {
- this.props = props;
- TestUtil.logTrace("[Stateful3xWrapper] initLogging()");
- TestUtil.init(props);
- TestUtil.logTrace("[Stateful3xWrapper] initLogging OK");
- } catch (RemoteLoggingInitException e) {
- TestUtil.logMsg("initLogging failed.");
- throw new EJBException(e.getMessage());
- }
- }
-
- public void createNamingContext() {
- TestUtil.logTrace("[Stateful3xWrapper] createNamingContext()");
-
- try {
- nctx = new TSNamingContext();
- } catch (Exception e) {
- TestUtil.logErr("[Stateful3xWrapper] Cannot create Naming Context: " + e);
- }
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/ejb/wrappers/StatefulWrapper.java b/common/src/main/java/com/sun/ts/tests/common/ejb/wrappers/StatefulWrapper.java
deleted file mode 100644
index d5bf83f401..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/ejb/wrappers/StatefulWrapper.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.ejb.wrappers;
-
-import java.util.Properties;
-
-import com.sun.ts.lib.util.RemoteLoggingInitException;
-import com.sun.ts.lib.util.TSNamingContext;
-import com.sun.ts.lib.util.TestUtil;
-
-import jakarta.ejb.CreateException;
-import jakarta.ejb.SessionBean;
-import jakarta.ejb.SessionContext;
-
-/**
- * Stateful wrapper that provide the bean life cycle methods for a Stateful
- * Session bean. This class is intended to be subclassed by the final entity
- * bean class that will provide the test logic (business methods).
- */
-public class StatefulWrapper implements SessionBean {
-
- protected TSNamingContext nctx = null;
-
- protected SessionContext sctx = null;
-
- protected Properties props;
-
- /*
- * Bean life cycle
- */
-
- public void ejbCreate(Properties props) throws CreateException {
- try {
- this.props = props;
- TestUtil.init(props);
- TestUtil.logTrace("[StatefulWrapper] ejbCreate()");
- } catch (RemoteLoggingInitException e) {
- throw new CreateException(e.getMessage());
- }
- TestUtil.logTrace("[StatefulWrapper] ejbCreate OK");
- }
-
- public void ejbPostCreate(Properties props) throws CreateException {
- TestUtil.logTrace("[StatefulWrapper] ejbPostCreate()");
- }
-
- public void setSessionContext(SessionContext sc) {
- TestUtil.logTrace("[StatefulWrapper] setSessionContext()");
- sctx = sc;
- try {
- nctx = new TSNamingContext();
- } catch (Exception e) {
- TestUtil.logErr("[StatefulWrapper] Cannot create Naming Context: " + e);
- }
- }
-
- public void ejbRemove() {
- TestUtil.logTrace("[StatefulWrapper] ejbRemove()");
- }
-
- public void ejbActivate() {
- TestUtil.logTrace("[StatefulWrapper] ejbActivate()");
- }
-
- public void ejbPassivate() {
- TestUtil.logTrace("[StatefulWrapper] ejbPassivate()");
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/ejb/wrappers/StatelessWrapper.java b/common/src/main/java/com/sun/ts/tests/common/ejb/wrappers/StatelessWrapper.java
deleted file mode 100644
index 25ce5e4138..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/ejb/wrappers/StatelessWrapper.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.ejb.wrappers;
-
-import java.util.Properties;
-
-import com.sun.ts.lib.util.RemoteLoggingInitException;
-import com.sun.ts.lib.util.TSNamingContext;
-import com.sun.ts.lib.util.TestUtil;
-
-import jakarta.ejb.CreateException;
-import jakarta.ejb.EJBException;
-import jakarta.ejb.SessionBean;
-import jakarta.ejb.SessionContext;
-
-/**
- * Stateless wrapper that provide the bean life cycle methods for a Stateless
- * Session bean. This class is intended to be subclassed by the final entity
- * bean class that will provide the test logic (business methods).
- */
-public class StatelessWrapper implements SessionBean {
-
- protected TSNamingContext nctx = null;
-
- protected SessionContext sctx = null;
-
- /*
- * Business methods.
- */
-
- /**
- * Initialize TS logging.
- *
- * @param props
- * TS properties need by TestUtil
- *
- */
- public void initLogging(Properties props) {
-
- try {
- TestUtil.logTrace("[StatelessWrapper] initLogging()");
- TestUtil.init(props);
- TestUtil.logTrace("[StatelessWrapper] initLogging OK.");
- } catch (RemoteLoggingInitException e) {
- TestUtil.logMsg("initLogging failed.");
- throw new EJBException(e.getMessage());
- }
- }
-
- /*
- * Bean life cycle
- */
-
- public void ejbCreate() throws CreateException {
- TestUtil.logTrace("[StatelessWrapper] ejbCreate()");
- }
-
- public void ejbPostCreate() throws CreateException {
- TestUtil.logTrace("[StatelessWrapper] ejbPostCreate()");
- }
-
- public void setSessionContext(SessionContext sc) {
- TestUtil.logTrace("[StatelessWrapper] setSessionContext()");
- sctx = sc;
- try {
- nctx = new TSNamingContext();
- } catch (Exception e) {
- TestUtil.logErr("[StatelessWrapper] Cannot create Naming Context: " + e);
- }
- }
-
- public void ejbRemove() {
- TestUtil.logTrace("[StatelessWrapper] ejbRemove()");
- }
-
- public void ejbActivate() {
- TestUtil.logTrace("[StatelessWrapper] ejbActivate()");
- }
-
- public void ejbPassivate() {
- TestUtil.logTrace("[StatelessWrapper] ejbPassivate()");
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/el/api/expression/ExpressionTest.java b/common/src/main/java/com/sun/ts/tests/common/el/api/expression/ExpressionTest.java
deleted file mode 100644
index 65846f69dd..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/el/api/expression/ExpressionTest.java
+++ /dev/null
@@ -1,407 +0,0 @@
-/*
- * Copyright (c) 2009, 2021 Oracle and/or its affiliates and others.
- * 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.el.api.expression;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.lang.annotation.Annotation;
-
-import jakarta.el.ELContext;
-import jakarta.el.Expression;
-import jakarta.el.MethodExpression;
-import jakarta.el.MethodInfo;
-import jakarta.el.MethodReference;
-import jakarta.el.PropertyNotWritableException;
-import jakarta.el.ValueExpression;
-
-public class ExpressionTest {
-
- // Set New Line from system prop, if not defined used "\n as default."
- private static final String NLINE = System.getProperty("line.separator",
- "\n");
-
- private ExpressionTest() {
- }
-
- public static boolean testMethodInfo(MethodInfo minfo, String expectedName,
- Class expectedReturnType, int expectedNumParams,
- Class[] expectedParamTypes, StringBuffer buf) {
-
- boolean pass = true;
- String name = minfo.getName();
- Class returnType = minfo.getReturnType();
- Class[] paramTypes = minfo.getParamTypes();
- int numParams = paramTypes.length;
-
- if (!name.equals(expectedName)) {
- buf.append("Did not get expected method name." + NLINE);
- buf.append("Expected name = " + expectedName + NLINE);
- buf.append("Computed name = " + name + NLINE);
- pass = false;
- }
- if (!returnType.equals(expectedReturnType)) {
- buf.append("Did not get expected return type." + NLINE);
- buf.append(
- "Expected return type = " + expectedReturnType.getName() + NLINE);
- buf.append("Computed return type = " + returnType.getName() + NLINE);
- pass = false;
- }
- if (numParams != expectedNumParams) {
- buf.append("Did not get expected number of parameters." + NLINE);
- buf.append(
- "Expected number of parameters = " + expectedNumParams + NLINE);
- buf.append("Computed number of parameters = " + numParams + NLINE);
- pass = false;
- } else {
- for (int i = 0; i < numParams; ++i) {
- if (!(paramTypes[i].equals(expectedParamTypes[i]))) {
- buf.append("Did not get expected parameter type." + NLINE);
- buf.append("Expected parameter type = "
- + expectedParamTypes[i].getName() + NLINE);
- buf.append(
- "Computed parameter type = " + paramTypes[i].getName() + NLINE);
- pass = false;
- }
- }
- }
- return pass;
- }
-
- public static boolean testMethodReference(MethodReference mref,
- Object expectedBase, MethodInfo expectedMethodInfo,
- Class>[] expectedAnnotationTypes,
- Object[] expectedParamValues, StringBuffer buf) {
-
- boolean pass = true;
-
- Object base = mref.getBase();
- MethodInfo minfo = mref.getMethodInfo();
- Annotation[] annotations = mref.getAnnotations();
- Object[] parameterValues = mref.getEvaluatedParameters();
-
- if (base == null) {
- buf.append("Did not get expected base object." + NLINE);
- buf.append("Expected base = " + expectedBase + NLINE);
- buf.append("Computed name = null" + NLINE);
- pass = false;
- } else if (!base.equals(expectedBase)) {
- buf.append("Did not get expected base object." + NLINE);
- buf.append("Expected base = " + expectedBase + NLINE);
- buf.append("Computed base = " + base + NLINE);
- pass = false;
- }
-
- if (minfo == null) {
- buf.append("Did not get expected MethodInfo object." + NLINE);
- buf.append("Expected MethodInfo = " + expectedMethodInfo + NLINE);
- buf.append("Computed MethodInfo = null" + NLINE);
- pass = false;
- } else if (!minfo.equals(expectedMethodInfo)) {
- buf.append("Did not get expected base object." + NLINE);
- buf.append("Expected MethodInfo = " + expectedMethodInfo + NLINE);
- buf.append("Computed MethodInfo = " + minfo + NLINE);
- pass = false;
- }
-
- if (annotations == null) {
- buf.append("Did not get expected annotation array." + NLINE);
- buf.append("Computed array was null" + NLINE);
- pass = false;
- } else if (annotations.length != expectedAnnotationTypes.length) {
- buf.append("Did not get expected number of annotations." + NLINE);
- buf.append("Expected annotation array length = " + expectedAnnotationTypes.length + NLINE);
- buf.append("Computed annotation array length = " + annotations.length + NLINE);
- pass = false;
- } else {
- for (int i = 0; i < annotations.length; i++) {
- if (!annotations[i].annotationType().equals(expectedAnnotationTypes[i])) {
- buf.append("Did not get expected annotation type for array index = " + i + NLINE);
- buf.append("Expected type = " + expectedAnnotationTypes[i] + NLINE);
- buf.append("Computed type = " + annotations[i].getClass() + NLINE);
- pass = false;
- }
- }
- }
-
- if (parameterValues == null) {
- buf.append("Did not get expected parameter value array." + NLINE);
- buf.append("Computed array was null" + NLINE);
- pass = false;
- } else if (parameterValues.length != expectedParamValues.length) {
- buf.append("Did not get expected number of parameter values." + NLINE);
- buf.append("Expected annotation array length = " + expectedParamValues.length + NLINE);
- buf.append("Computed annotation array length = " + parameterValues.length + NLINE);
- pass = false;
- } else {
- for (int i = 0; i < parameterValues.length; i++) {
- if (!parameterValues[i].equals(expectedParamValues[i])) {
- buf.append("Did not get expected parameter value for array index = " + i + NLINE);
- buf.append("Expected type = " + expectedParamValues[i] + NLINE);
- buf.append("Computed type = " + parameterValues[i] + NLINE);
- pass = false;
- }
- }
- }
-
- return pass;
- }
-
- public static boolean testValueExpression(ValueExpression vexp,
- ELContext context, String exprStr, Class expectedType,
- Object expectedValue, boolean expectedReadOnly,
- boolean expectedLiteralText, StringBuffer buf) {
-
- boolean pass = true;
-
- // getValue()
- Object retrievedValue = vexp.getValue(context);
- if (!retrievedValue.equals(expectedValue)) {
- pass = false;
- buf.append("getValue() does not return expected value" + NLINE);
- buf.append("Expected value = " + expectedValue.toString() + NLINE);
- buf.append("Computed value = " + retrievedValue.toString() + NLINE);
- }
-
- // setValue()
- try {
- vexp.setValue(context, "blue");
- String newValue = (String) vexp.getValue(context);
- if (expectedReadOnly) {
- pass = false;
- buf.append("setValue() succeeded on a read-only value" + NLINE);
- } else if (!newValue.equals("blue")) {
- pass = false;
- buf.append(
- "Did not get correct set value for " + "ValueExpression." + NLINE);
- buf.append("Expected value = " + "blue" + NLINE);
- buf.append("Computed value = " + newValue + NLINE);
- }
- } catch (PropertyNotWritableException pnwe) {
- if (!expectedReadOnly) {
- pass = false;
- buf.append(
- "setValue() threw " + "PropertyNotWritableException" + NLINE);
- buf.append("on a writable value" + NLINE);
- } else {
- buf.append(
- "PropertyNotWritableException caught as " + "expected." + NLINE);
- }
- }
-
- // getType()
- Class type = vexp.getType(context);
- String typeName = (type == null) ? "null" : type.getName();
- buf.append("Type retrieved is " + typeName + NLINE);
-
- // getExpectedType()
- Class retrievedType = vexp.getExpectedType();
- if (!(retrievedType.equals(expectedType))) {
- pass = false;
- buf.append(
- "getExpectedType() does not return expected " + "type" + NLINE);
- buf.append("Expected type = " + expectedType.toString() + NLINE);
- buf.append("Computed type = " + retrievedType.toString() + NLINE);
- }
-
- // isReadOnly()
- if ((vexp.isReadOnly(context)) != expectedReadOnly) {
- pass = false;
- buf.append("isReadOnly() did not return " + expectedReadOnly + NLINE);
- }
-
- // isLiteralText()
- if ((vexp.isLiteralText()) != expectedLiteralText) {
- pass = false;
- buf.append(
- "isLiteralText() did not return " + expectedLiteralText + NLINE);
- }
-
- // getExpressionString()
- String retrievedStr = vexp.getExpressionString();
- if (!retrievedStr.equals(exprStr)) {
- pass = false;
- buf.append(
- "getExpressionString() does not return expected " + "string" + NLINE);
- buf.append("Expected string = " + exprStr + NLINE);
- buf.append("Computed string = " + retrievedStr + NLINE);
- }
-
- return pass;
- }
-
- public static boolean testMethodExpression(MethodExpression mexp,
- ELContext context, String exprStr, Object[] params,
- Object expectedReturnValue, boolean expectedLiteralText,
- StringBuffer buf) {
-
- boolean pass = true;
-
- // getMethodInfo()
- try {
- MethodInfo minfo = mexp.getMethodInfo(context);
- } catch (Exception e) {
- pass = false;
- buf.append("getMethodInfo() threw an unexpected exception" + NLINE);
- buf.append(e.getMessage() + NLINE);
- }
-
- // invoke()
- try {
- Object returnValue = mexp.invoke(context, params);
- if (returnValue == null) {
- if (expectedReturnValue != null) {
- pass = false;
- buf.append("invoke() unexpectedly returned null" + NLINE);
- }
- } else if (expectedReturnValue == null) {
- pass = false;
- buf.append(
- "invoke() unexpectedly returned non-null " + "value" + NLINE);
- } else if (!returnValue.equals(expectedReturnValue)) {
- pass = false;
- buf.append(
- "invoke() returned an object of wrong type or " + "value" + NLINE);
- buf.append(
- "Expected return value: " + expectedReturnValue.toString() + NLINE);
- buf.append("Computed return value: " + returnValue.toString() + NLINE);
- }
- } catch (Exception e) {
- pass = false;
- buf.append("invoke() threw an unexpected exception" + NLINE);
- buf.append(e.getMessage() + NLINE);
- }
-
- // isLiteralText()
- if ((mexp.isLiteralText()) != expectedLiteralText) {
- pass = false;
- buf.append(
- "isLiteralText() did not return " + expectedLiteralText + NLINE);
- }
-
- // getExpressionString()
- String retrievedStr = mexp.getExpressionString();
- if (!retrievedStr.equals(exprStr)) {
- pass = false;
- buf.append(
- "getExpressionString() does not return expected " + "string" + NLINE);
- buf.append("Expected string = " + exprStr + NLINE);
- buf.append("Computed string = " + retrievedStr + NLINE);
- }
-
- return pass;
- }
-
- public static boolean equalsTest(Expression exp1, Expression exp2,
- StringBuffer buf) {
-
- String e1str = exp1.getExpressionString();
- String e2str = (exp2 == null) ? null : exp2.getExpressionString();
-
- buf.append("Testing equality: " + e1str + " and " + e2str + NLINE);
-
- if (!exp1.equals(exp2)) {
- if (exp2 != null) {
- buf.append("Expression " + e1str + " is not equal to " + "Expression "
- + e2str + NLINE);
- }
- return false;
- } else {
- int hcode1 = exp1.hashCode();
- int hcode2 = exp2.hashCode();
-
- if (hcode1 != hcode2) {
- buf.append("Expressions " + e1str + " and " + e2str + " are "
- + "equal, but their" + NLINE);
- buf.append("hashcodes aren't the same." + NLINE);
- buf.append("Hashcode for " + e1str + ": " + hcode1 + NLINE);
- buf.append("Hashcode for " + e2str + ": " + hcode2 + NLINE);
- return false;
- }
- }
-
- return true;
- }
-
- public static boolean expressionSerializableTest(Expression exp,
- StringBuffer buf) {
-
- ObjectOutputStream out = null;
- ObjectInputStream in = null;
- Expression desexp = null;
- ByteArrayOutputStream bos = null;
-
- // Serialize the Expression.
- try {
- bos = new ByteArrayOutputStream();
- out = new ObjectOutputStream(bos);
- out.writeObject(exp);
- } catch (IOException ioe) {
- buf.append(
- "Failed to serialize the Expression!" + NLINE + ioe.toString());
- return false;
- } finally {
- if (out != null) {
- try {
- out.close();
- } catch (Exception close) {
- // Do not fail the test if close does not happen.
- }
- }
- }
-
- // Deserialize the Expression.
- try {
- byte[] byteBuf = bos.toByteArray();
- in = new ObjectInputStream(new ByteArrayInputStream(byteBuf));
- desexp = (Expression) in.readObject();
- } catch (IOException ioe) {
- buf.append(
- "Failed to deserialize the Expression!" + NLINE + ioe.toString());
- return false;
- } catch (ClassNotFoundException cnfe) {
- buf.append("Could not find class of serialized Expression" + NLINE
- + cnfe.toString());
- return false;
- } finally {
- if (in != null) {
- try {
- in.close();
- } catch (Exception close) {
- // Do not fail the test if close does not happen.
- }
- }
- }
-
- // Test Expression After Serialization
- if (!equalsTest(desexp, exp, buf)) {
- buf.append("'getExpressionString' after serialization took " + "place."
- + NLINE + "Expected: " + exp.getExpressionString() + NLINE
- + "Received: " + desexp.getExpressionString() + NLINE);
- return false;
- }
-
- return true;
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/el/api/resolver/BarELResolver.java b/common/src/main/java/com/sun/ts/tests/common/el/api/resolver/BarELResolver.java
deleted file mode 100644
index bbe24594e6..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/el/api/resolver/BarELResolver.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (c) 2018, 2020 Oracle and/or its affiliates and others.
- * 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.common.el.api.resolver;
-
-import java.util.Iterator;
-
-import jakarta.el.ELContext;
-import jakarta.el.ELException;
-import jakarta.el.ELResolver;
-import jakarta.el.PropertyNotWritableException;
-
-public class BarELResolver extends ELResolver {
-
- public Object getValue(ELContext context, Object base, Object property)
- throws ELException {
- Object result = null;
- if (context == null)
- throw new NullPointerException();
-
- if (base == null) {
- // Resolving first variable (e.g. ${Bar}).
- // We only handle "Bar"
- String propertyName = (String) property;
- if (propertyName.equals("Bar")) {
- result = "Foo";
- context.setPropertyResolved(true);
- }
- }
- return result;
- }
-
- public Class getType(ELContext context, Object base, Object property)
- throws ELException {
- if (context == null)
- throw new NullPointerException();
-
- if (base == null && property instanceof String
- && property.toString().equals("Bar")) {
- context.setPropertyResolved(true);
- }
-
- // we never set a value
- return null;
- }
-
- public void setValue(ELContext context, Object base, Object property,
-
- Object value) throws ELException {
- if (context == null)
- throw new NullPointerException();
-
- if (base == null && property instanceof String
- && property.toString().equals("Bar")) {
- context.setPropertyResolved(true);
- throw new PropertyNotWritableException();
- }
- }
-
- public boolean isReadOnly(ELContext context, Object base, Object property)
- throws ELException {
- if (context == null)
- throw new NullPointerException();
-
- if (base == null && property instanceof String
- && property.toString().equals("Bar")) {
- context.setPropertyResolved(true);
- }
-
- return true;
- }
-
- public Iterator getFeatureDescriptors(ELContext context, Object base) {
- if (context == null)
- throw new NullPointerException();
- return null;
- }
-
- public Class getCommonPropertyType(ELContext context, Object base) {
- if (context == null)
- throw new NullPointerException();
-
- if (base == null)
- return String.class;
- return null;
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/el/api/resolver/ResolverTest.java b/common/src/main/java/com/sun/ts/tests/common/el/api/resolver/ResolverTest.java
deleted file mode 100644
index 60c14596d5..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/el/api/resolver/ResolverTest.java
+++ /dev/null
@@ -1,542 +0,0 @@
-/*
- * Copyright (c) 2009, 2024 Oracle and/or its affiliates and others.
- * 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-package com.sun.ts.tests.common.el.api.resolver;
-
-import java.util.Objects;
-
-import jakarta.el.BeanELResolver;
-import jakarta.el.CompositeELResolver;
-import jakarta.el.ELContext;
-import jakarta.el.ELResolver;
-import jakarta.el.MethodNotFoundException;
-import jakarta.el.PropertyNotFoundException;
-import jakarta.el.PropertyNotWritableException;
-
-public class ResolverTest {
- private static final String NL = System.getProperty("line.separator", "\n");
-
- /**
- * Private as this class will only have static methods and members.
- */
- private ResolverTest() {
- }
-
- public static boolean testCompositeELResolver(ELContext elContext,
- CompositeELResolver compResolver, StringBuffer buf) {
-
- boolean pass = true;
-
- // add()
- BarELResolver barResolver = new BarELResolver();
- try {
- compResolver.add(barResolver);
- buf.append("add() tested successfully" + NL);
-
- } catch (Exception e) {
- buf.append("add() method Test Failed");
- pass = false;
- }
-
- // setValue()
- elContext.setPropertyResolved(false);
- compResolver.setValue(elContext, null, "Nothing", "rien");
- if (!elContext.isPropertyResolved()) {
- buf.append(
- "setValue() tested successfully on non-existent " + "property" + NL);
- } else {
- buf.append("setValue() set property resolved on non-existent "
- + "property" + NL);
- pass = false;
- }
-
- elContext.setPropertyResolved(false);
- try {
- compResolver.setValue(elContext, null, "Bar", "rien");
- pass = false;
- } catch (PropertyNotWritableException pnwe) {
- buf.append(
- "setValue() tested successfully on non-writable " + "property" + NL);
- buf.append("PropertyNotWritableException caught as expected" + NL);
- }
-
- // getValue()
- elContext.setPropertyResolved(false);
- String result = (String) compResolver.getValue(elContext, null, "Bar");
- if (!elContext.isPropertyResolved()) {
- buf.append("getValue() did not resolve" + NL);
- pass = false;
- } else if (!result.equals("Foo")) {
- buf.append("Invalid value from BarELResolver: " + result + NL);
- pass = false;
- } else {
- buf.append("getValue() tested successfully" + NL);
- }
-
- // getType()
- elContext.setPropertyResolved(false);
- Class> type = compResolver.getType(elContext, null, "Bar");
- if (!elContext.isPropertyResolved()) {
- buf.append("getType() did not resolve" + NL);
- pass = false;
- } else if (type != null) {
- buf.append("getType() returns " + type.getName() + NL);
- buf.append("not expected result for non-writable property" + NL);
- pass = false;
- } else {
- buf.append("getType() returns null as expected for non-writable "
- + "property" + NL);
- }
-
- // isReadOnly
- elContext.setPropertyResolved(false);
- boolean nonWritable = compResolver.isReadOnly(elContext, null, "Bar");
- if (!elContext.isPropertyResolved()) {
- buf.append("isReadOnly() did not resolve" + NL);
- pass = false;
- } else if (!nonWritable) {
- buf.append("isReadOnly() did not return true" + NL);
- pass = false;
- } else {
- buf.append("isReadOnly() returns true as expected" + NL);
- }
-
- // getCommonPropertyType()
- elContext.setPropertyResolved(false);
- Class> commonPropertyType = (compResolver.getCommonPropertyType(elContext, null));
- buf.append("getCommonPropertyType() returns ");
- buf.append(commonPropertyType.getName() + NL);
-
- return pass;
- }
-
- public static boolean testELResolver(ELContext elContext, ELResolver resolver,
- Object base, Object property, Object value, StringBuffer buf,
- boolean readOnly) {
-
- boolean pass = true;
-
- // setValue()
- elContext.setPropertyResolved(false);
- try {
- resolver.setValue(elContext, base, property, value);
- if (readOnly) {
- buf.append("setValue() failed on non-writable property");
- pass = false;
- } else {
- buf.append(
- "setValue() tested successfully on writable " + "property" + NL);
- }
-
- } catch (PropertyNotWritableException pnwe) {
- if (readOnly) {
- buf.append("setValue() tested successfully on non-writable "
- + "property" + NL);
- buf.append("PropertyNotWritableException caught as expected" + NL);
- } else {
- buf.append("setValue() failed on non-writable property" + NL);
- buf.append("Unexpected PropertyNotWritableException caught" + NL);
- pass = false;
- }
- }
-
- // getValue()
- elContext.setPropertyResolved(false);
- Object valueRetrieved = resolver.getValue(elContext, base, property);
- if (!elContext.isPropertyResolved()) {
- buf.append("getValue() did not resolve" + NL);
- pass = false;
- }
-
- if (!readOnly && !Objects.equals(valueRetrieved, value)) {
- if (valueRetrieved == null) {
- buf.append("null value returned from getValue() method call!" + NL);
- pass = false;
- } else {
- buf.append("Invalid value from getValue():" + NL);
- buf.append("Value expected: " + value.toString() + NL);
- buf.append("Value retrieved: " + valueRetrieved.toString() + NL);
- pass = false;
- }
- } else {
- buf.append("getValue() tested successfully" + NL);
- if (!readOnly) {
- buf.append("Value expected: " + value.toString() + NL);
- buf.append("Value retrieved: " + valueRetrieved.toString() + NL);
- }
- }
-
- // getType()
- elContext.setPropertyResolved(false);
- Class> type = resolver.getType(elContext, base, property);
- if (!elContext.isPropertyResolved()) {
- buf.append("getType() did not resolve" + NL);
- pass = false;
- } else if (type != null) {
- buf.append("getType() returns " + type.getName() + NL);
- if (readOnly) {
- buf.append("result not expected!" + NL);
- pass = false;
- } else {
- buf.append("non-null as expected" + NL);
- }
- } else {
- buf.append("getType() returns null " + NL);
- if (!readOnly) {
- buf.append("result not expected!" + NL);
- pass = false;
- } else {
- buf.append("as expected" + NL);
- }
- }
-
- // isReadOnly
- elContext.setPropertyResolved(false);
- boolean nonWritable = resolver.isReadOnly(elContext, base, property);
- if (!elContext.isPropertyResolved()) {
- buf.append("isReadOnly() did not resolve" + NL);
- pass = false;
- } else if (nonWritable != readOnly) {
- buf.append("isReadOnly() returned unexpected value: " + nonWritable + NL);
- pass = false;
- } else {
- buf.append("isReadOnly() returns " + readOnly + " as expected" + NL);
- }
-
- // getCommonPropertyType()
- elContext.setPropertyResolved(false);
- Class> commonPropertyType = (resolver.getCommonPropertyType(elContext, base));
- buf.append("getCommonPropertyType() returns ");
- buf.append(commonPropertyType.getName() + "" + NL);
-
- return pass;
- }
-
- /**
- * Test the ELResolver.invoke() mthod.
- *
- * @param elContext
- * - elContext
- * @param resolver
- * - el Resolver to be tested.
- * @param beanName
- * - The javabean to be used.
- * @param methodName
- * - The method in the javabean to call.
- * @param types
- * - The @class types of the aurgs for the method.
- * @param values
- * - The args that you want to pass into the method.
- * @param negTest
- * - Is this a negetive test or not(true, false).
- * @param buf
- * - String buffer used to capture loggig info.
- * @return
- */
- public static boolean testELResolverInvoke(ELContext elContext,
- ELResolver resolver, Object beanName, Object methodName, Class>[] types,
- Object[] values, Boolean negTest, StringBuffer buf) {
-
- boolean pass = true;
-
- // invoke
- elContext.setPropertyResolved(false);
- try {
- Boolean nameMatch = (Boolean) resolver.invoke(elContext, beanName,
- methodName, types, values);
-
- if (!nameMatch.booleanValue()) {
- buf.append("invoke() did not Run properly." + NL);
- pass = false;
- }
-
- } catch (MethodNotFoundException mnfe) {
- if (negTest.booleanValue()) {
- buf.append("Test Passed invoke() threw MethodNotFoundException");
- } else {
- pass = false;
- mnfe.printStackTrace();
- }
- } catch (Exception e) {
- pass = false;
- e.printStackTrace();
- }
-
- return pass;
- }
-
-
- // --- Start Negative Method Tests ---
- public static boolean testELResolverNPE(ELResolver resolver, Object base,
- Object property, Object value, StringBuffer buf) {
-
- boolean pass = true;
-
- // getType()
- try {
- resolver.getType(null, base, property);
- pass = false;
- buf.append("getType test failed with: " + NL
- + "EXPECTED: NullPointerException to be thrown " + NL
- + "RECEIVED: NO EXCEPTION THROWN AT ALL! " + NL);
- } catch (Exception e) {
- if (!(e instanceof NullPointerException)) {
- buf.append("getType test failed with: " + NL + "EXPECTED: "
- + "NullPointerException to be thrown " + NL + "RECEIVED: "
- + e.toString() + NL);
- pass = false;
-
- } else {
- buf.append("getType() test Passed: throws "
- + "NullPointerException as expected " + NL);
- }
- }
-
- // getValue
- try {
- resolver.getValue(null, base, property);
- buf.append("Test Failed getValue() did not throw any exception." + NL
- + "Expected: NullPointerException " + NL);
-
- pass = false;
- } catch (Exception e) {
- if (!(e instanceof NullPointerException)) {
- buf.append("Test Failed getValue() threw the wrong exception " + NL
- + "Expected: NullPointerException " + NL + "Received: "
- + e.toString());
-
- pass = false;
- } else {
- buf.append("Test Passed getValue() threw NullPointerException " + NL);
- }
- }
-
- // setValue()
- try {
- resolver.setValue(null, base, property, value);
- buf.append("Test Failed setValue() did not throw any exception." + NL
- + "Expected: NullPointerException " + NL);
-
- pass = false;
- } catch (Exception e) {
- if (!(e instanceof NullPointerException)) {
- buf.append("Test Failed setValue() threw the wrong exception " + NL
- + "Expected: NullPointerException " + NL + "Received: "
- + e.toString());
-
- pass = false;
- } else {
- buf.append("Test Passed setValue() threw NullPointerException " + NL);
- }
- }
-
- // isReadOnly()
- try {
- resolver.isReadOnly(null, base, property);
- buf.append("Test Failed isReadOnly() did not throw any exception." + NL
- + "Expected: NullPointerException " + NL);
-
- pass = false;
- } catch (Exception e) {
- if (!(e instanceof NullPointerException)) {
- buf.append("Test Failed isReadOnly() threw the wrong exception " + NL
- + "Expected: NullPointerException " + NL + "Received: "
- + e.toString());
-
- pass = false;
- } else {
- buf.append(
- "Test Passed isReadOnly() NullPointerException " + "thrown " + NL);
- }
- }
-
- return pass;
- }
-
- public static boolean testELResolverPNFE(ELContext elcontext,
- ELResolver resolver, Object base, Object property, StringBuffer buf) {
-
- boolean pass = true;
-
- // getType()
- try {
- resolver.getType(elcontext, base, property);
- buf.append("Test Failed getType() did not throw any exception." + NL
- + "Expected: PropertyNotFoundException " + NL);
-
- pass = false;
- } catch (Exception e) {
- if (!(e instanceof PropertyNotFoundException)) {
- buf.append("Test Failed getType() threw the wrong exception " + NL
- + "Expected: PropertyNotFoundException " + NL + "Received: "
- + e.toString());
-
- pass = false;
- } else {
- buf.append("Test Passed getType() threw "
- + "PropertyNotFoundException " + NL);
- }
- }
-
- // isReadOnly()
- try {
- resolver.isReadOnly(elcontext, base, property);
- buf.append("Test Failed isReadOnly() did not throw any exception." + NL
- + "Expected: PropertyNotFoundException " + NL);
-
- pass = false;
- } catch (Exception e) {
- if (!(e instanceof PropertyNotFoundException)) {
- buf.append("Test Failed isReadOnly() threw the wrong exception " + NL
- + "Expected: PropertyNotFoundException " + NL + "Received: "
- + e.toString());
-
- pass = false;
- } else {
- buf.append("Test Passed isReadOnly() threw "
- + "PropertyNotFoundException " + NL);
- }
- }
-
- // setValue()
- try {
- resolver.setValue(elcontext, base, property, "arbitrary value");
- buf.append("Test Failed setValue() did not throw any exception." + NL
- + "Expected: PropertyNotFoundException " + NL);
-
- pass = false;
- } catch (Exception e) {
- if (!(e instanceof PropertyNotFoundException)) {
- buf.append("Test Failed setValue() threw the wrong exception " + NL
- + "Expected: PropertyNotFoundException " + NL + "Received: "
- + e.toString());
-
- pass = false;
- } else {
- buf.append("Test Passed setValue() threw "
- + "PropertyNotFoundException " + NL);
- }
- }
-
- if (!(resolver instanceof BeanELResolver)) {
- return pass;
- }
-
- // getValue()
- try {
- resolver.getValue(elcontext, base, property);
- buf.append("Test Failed getValue() did not throw any exception." + NL
- + "Expected: PropertyNotFoundException " + NL);
-
- pass = false;
- } catch (Exception e) {
- if (!(e instanceof PropertyNotFoundException)) {
- buf.append("Test Failed getValue() threw the wrong exception " + NL
- + "Expected: PropertyNotFoundException " + NL + "Received: "
- + e.toString());
-
- pass = false;
- } else {
- buf.append("Test Passed getValue() threw "
- + "PropertyNotFoundException " + NL);
- }
- }
-
- return pass;
- }
-
- public static boolean testELResolverIAE(ELContext elcontext,
- ELResolver resolver, Object base, Object property, Object value,
- StringBuffer buf) {
-
- boolean pass = true;
-
- // getValue()
- try {
- resolver.getValue(elcontext, base, value);
- buf.append("Test Failed getValue() did not throw any exception." + NL
- + "Expected: IllegalArgumentException " + NL);
-
- pass = false;
- } catch (Exception e) {
- if (!(e instanceof IllegalArgumentException)) {
- buf.append("Test Failed getValue() threw the wrong exception " + NL
- + "Expected: IllegalArgumentException " + NL + "Received: "
- + e.toString());
-
- pass = false;
- } else {
- buf.append("Test Passed getValue() threw "
- + "IllegalArgumentException " + NL);
- }
- }
-
- // setValue()
- try {
- resolver.setValue(elcontext, base, property, value);
- buf.append("Test Failed setValue() did not throw any exception." + NL
- + "Expected: IllegalArgumentException " + NL);
-
- pass = false;
- } catch (Exception e) {
- if (!(e instanceof IllegalArgumentException)) {
- buf.append("Test Failed setValue() threw the wrong exception "
- + "Expected: IllegalArgumentException " + NL + "Received: "
- + e.toString());
-
- pass = false;
- } else {
- buf.append("Test Passed setValue() threw "
- + "IllegalArgumentException " + NL);
- }
- }
-
- return pass;
- }
-
- public static boolean testELResolverPNWE(ELContext elcontext,
- ELResolver resolver, Object base, Object property, Object value,
- StringBuffer buf) {
-
- boolean pass = true;
-
- // setValue()
- try {
- resolver.setValue(elcontext, base, property, value);
- buf.append("Test Failed setValue() did not throw any exception." + NL
- + "Expected: PropertyNotWritableException " + NL);
- pass = false;
-
- } catch (Exception e) {
- if (!(e instanceof PropertyNotWritableException)) {
- buf.append("Test Failed setValue() threw the wrong exception " + NL
- + "Expected: PropertyNotWritableException " + NL + "Received: "
- + e.toString());
- pass = false;
-
- } else {
- buf.append("Test Passed setValue() threw "
- + "PropertyNotWritableException " + NL);
- }
- }
-
- return pass;
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/jspservletsec/SecBasicClient.java b/common/src/main/java/com/sun/ts/tests/common/jspservletsec/SecBasicClient.java
deleted file mode 100644
index e192893527..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/jspservletsec/SecBasicClient.java
+++ /dev/null
@@ -1,446 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 Oracle and/or its affiliates and others.
- * 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.common.jspservletsec;
-
-import java.util.Properties;
-
-import com.sun.ts.lib.util.TestUtil;
-import com.sun.ts.tests.common.webclient.BaseUrlClient;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class SecBasicClient extends BaseUrlClient {
-
- private static final Logger lOGGER = LoggerFactory.getLogger(SecBasicClient.class);
-
- // Constants:
- private static final String USERNAME = "user";
-
- private static final String PASSWORD = "password";
-
- private static final String UNAUTH_USERNAME = "authuser";
-
- private static final String UNAUTH_PASSWORD = "authpassword";
-
- private static final String CLASS_TRACE_HEADER = "[SecBasicClient]: ";
-
- private static final String USER_PRINCIPAL_SEARCH = "The user principal is: "; // (+username)
-
- private static final String REMOTE_USER_SEARCH = "getRemoteUser(): "; // (+username)
-
- // fields:
- protected String pageSec = null;
-
- protected String pageGuest = null;
-
- protected String pageUnprotected = null;
-
- protected String pageRoleReverse = null;
-
- private String pageJspBase = "/jsp_sec_secbasic_web";
-
- private String pageJspSec = pageJspBase + "/jspSec.jsp";
-
- private String pageJspGuest = pageJspBase + "/guestPage.jsp";
-
- private String pageJspUnprotected = pageJspBase + "/unprotected.jsp";
-
- private String pageJspRoleReverse = pageJspBase + "/rolereverse.jsp";
-
- private String pageServletBase = "/servlet_sec_secbasic_web";
-
- private String pageServletSec = pageServletBase + "/ServletSecTest";
-
- private String pageServletGuest = pageServletBase + "/GuestPageTest";
-
- private String pageServletUnprotected = pageServletBase + "/UnProtectedTest";
-
- private String pageServletRoleReverse = pageServletBase + "/RoleReverseTest";
-
- private String username = null;
-
- private String password = null;
-
- private String unauthUsername = null;
-
- private String unauthPassword = null;
-
- /*
- * @class.setup_props: webServerHost; webServerPort; user; password; authuser;
- * authpassword; ts_home;
- *
- *
- */
- // Note:Based on the input argument setup will intialize JSP or servlet pages
-
- public void setup(String[] args, Properties p) throws Exception {
- super.setup(args, p);
-
- try {
- username = TestUtil.getProperty(p, USERNAME);
- password = TestUtil.getProperty(p, PASSWORD);
- unauthUsername = TestUtil.getProperty(p, UNAUTH_USERNAME);
- unauthPassword = TestUtil.getProperty(p, UNAUTH_PASSWORD);
-
- if (args[0].equals("jsp")) {
- pageSec = pageJspSec;
- pageGuest = pageJspGuest;
- pageUnprotected = pageJspUnprotected;
- pageRoleReverse = pageJspRoleReverse;
-
- } else {
- pageSec = pageServletSec;
- pageGuest = pageServletGuest;
- pageUnprotected = pageServletUnprotected;
- pageRoleReverse = pageServletRoleReverse;
-
- }
- } catch (Exception e) {
- lOGGER.error("Error: got exception: ", e);
- }
- }
-
- /*
- * testName: test1
- *
- * @assertion: Test BASIC authentication, specified in the Java Servlet
- * Specification v2.2, Sec 11.5.1.
- *
- * 1. If user has not been authenticated and user attempts to access a
- * protected web resource, the web server requests authentication.
- *
- * @test_Strategy: 1. Send request to access jspSec.jsp 2. Receive
- * authentication request.
- */
-
- public void test1() throws Exception {
- logMessage(
- "Sending request to validate presence of www-authenticate header...");
- TEST_PROPS.setProperty(TEST_NAME, "SecBasic/Test1");
- TEST_PROPS.setProperty(REQUEST, getRequestLine("GET", pageSec));
- TEST_PROPS.setProperty(EXPECTED_HEADERS, "www-authenticate:");
- TEST_PROPS.setProperty(STATUS_CODE, UNAUTHORIZED);
- invoke();
-
- dumpResponse(); // debug aid
-
- logMessage("Authentication requested");
- }
-
- /*
- * testName: test2
- *
- * @assertion: Test BASIC authentication, specified in the Java Servlet
- * Specification v2.2, Sec 11.5.1. Also tests API assertions in section 11.3.
- *
- * 1. If user has not been authenticated and user attempts to access a
- * protected web resource, and user enters a valid username and password, the
- * original web resource is returned and user is authenticated. 2.
- * getRemoteUser() returns the user name that the client authenticated with.
- *
- * @test_Strategy: 1. Send request with correct authentication. 2. Receive
- * page (ensure principal is correct, and ensure that getRemoteUser() returns
- * the correct name)
- */
-
- public void test2() throws Exception {
- logMessage("Sending request with Authroization header...");
-
- StringBuffer sb = new StringBuffer(100);
- sb.append(USER_PRINCIPAL_SEARCH).append(username).append("|");
- sb.append(REMOTE_USER_SEARCH).append(username).append("|");
- sb.append("isUserInRole(\"ADM\"): !true!").append("|");
- sb.append("isUserInRole(\"MGR\"): !false!").append("|");
- sb.append("isUserInRole(\"VP\"): !false!").append("|");
- sb.append("isUserInRole(\"EMP\"): !true!").append("|");
-
- TEST_PROPS.setProperty(TEST_NAME, "SecBasic/Test2");
- TEST_PROPS.setProperty(REQUEST, getRequestLine("GET", pageSec));
- TEST_PROPS.setProperty(BASIC_AUTH_USER, username);
- TEST_PROPS.setProperty(BASIC_AUTH_PASSWD, password);
- TEST_PROPS.setProperty(SEARCH_STRING, sb.toString());
- invoke();
-
- dumpResponse(); // debug aid
-
- logMessage("isUserInRole() and getRemoteUser() returned expected results");
- }
-
- /*
- * testName: test3
- *
- * @assertion: Test BASIC authentication, specified in the Java Servlet
- * Specification v2.2, Sec 11.5.1.
- *
- * 1. If user has not been authenticated and user attempts to access a
- * protected web resource, and user enters an invalid username and password,
- * the container denies access to the web resource.
- *
- * @test_Strategy: 1. Re-send request with incorrect authentication. 2.
- * Receive authentication request.
- */
-
- public void test3() throws Exception {
- logMessage(
- "Sending an request for a protected resource with invalid username/password...");
-
- TEST_PROPS.setProperty(TEST_NAME, "SecBasic/Test3");
- TEST_PROPS.setProperty(REQUEST, getRequestLine("GET", pageSec));
- TEST_PROPS.setProperty(BASIC_AUTH_USER, "invalid");
- TEST_PROPS.setProperty(BASIC_AUTH_PASSWD, password);
- TEST_PROPS.setProperty(STATUS_CODE, UNAUTHORIZED);
- invoke();
-
- dumpResponse(); // debug aid
-
- logMessage("Access Denied");
- }
-
- /*
- * testName: test4
- *
- * @assertion: Test BASIC authentication, specified in the Java Servlet
- * Specification v2.2, Sec 11.5.1.
- *
- * 1. If user has not been authenticated and user attempts to access a
- * protected web resource, and user enters an valid username and password, but
- * for a role that is not authorized to access the resource, the container
- * denies access to the web resource.
- *
- * @test_Strategy: 1. Send request with correct authentication for user
- * javajoe for a page javajoe is allowed to access. 2. Receive page (this
- * verifies that the javajoe user is set up properly). 3. Send request with
- * correct authentication, but incorrect authorization to access resource 4.
- * Receive error
- */
-
- public void test4() throws Exception {
-
- StringBuffer sb = new StringBuffer(100);
- sb.append(USER_PRINCIPAL_SEARCH).append(unauthUsername);
-
- logMessage("Sending request to resource the user has access to...");
- TEST_PROPS.setProperty(TEST_NAME, "SecBasic/Test4");
- TEST_PROPS.setProperty(REQUEST, getRequestLine("GET", pageGuest));
- TEST_PROPS.setProperty(BASIC_AUTH_USER, unauthUsername);
- TEST_PROPS.setProperty(BASIC_AUTH_PASSWD, unauthPassword);
- TEST_PROPS.setProperty(SEARCH_STRING, sb.toString());
- invoke();
-
- dumpResponse(); // debug aid
-
- logMessage("User successfully accessed the resource");
-
- logMessage(
- "Sending request to resource with valid username/password, but not the right roles...");
- TEST_PROPS.setProperty(TEST_NAME, "SecBasic/Test4");
- TEST_PROPS.setProperty(REQUEST, getRequestLine("GET", pageSec));
- TEST_PROPS.setProperty(BASIC_AUTH_USER, unauthUsername);
- TEST_PROPS.setProperty(BASIC_AUTH_PASSWD, unauthPassword);
- TEST_PROPS.setProperty(STATUS_CODE, FORBIDDEN);
- invoke();
-
- dumpResponse(); // debug aid
-
- logMessage("Access Forbidden");
- }
-
- /*
- * testName: test5
- *
- * @assertion: Test BASIC authentication, specified in the Java Servlet
- * Specification v2.2, Sec 11.5.1. Also tests assertions in section 11.3.
- *
- * 1. If user has not been authenticated and user attempts to access an
- * unprotected web resource, the web resource is returned without need to
- * authenticate. 2. isUserInRole() must return false for any valid or invalid
- * role reference. 3. getRemoteUser() must return false
- *
- * @test_Strategy: 1. Send request for unprotected.jsp with no authentication.
- * 2. Receive page 3. Search the returned page for "!true!", which would
- * indicate that at least one call to isUserInRole attempted by
- * unprotected.jsp returned true. 4. check that getRemoteUser() returns null.
- */
-
- public void test5() throws Exception {
- StringBuffer sb = new StringBuffer(100);
- sb.append(USER_PRINCIPAL_SEARCH).append("|");
- sb.append(REMOTE_USER_SEARCH).append("null");
-
- logMessage("Sending request to unprotected resource....");
- TEST_PROPS.setProperty(TEST_NAME, "BasicSec/Test5");
- TEST_PROPS.setProperty(REQUEST, getRequestLine("GET", pageUnprotected));
- TEST_PROPS.setProperty(SEARCH_STRING, sb.toString());
- TEST_PROPS.setProperty(UNEXPECTED_RESPONSE_MATCH, "!true!");
- invoke();
-
- dumpResponse(); // debug aid
-
- logMessage("isUserInRole() and getRemoteUser() returned expected results");
- }
-
- /*
- * testName: test6
- *
- * @assertion: Test HTTP-Basic authentication, specified in the Java Servlet
- * Specification v2.2, Sec 11.5.1. Also tests assertions from section 11.3.
- *
- * Given two servlets in the same application, each of which calls
- * isUserInRole(X), and where X is linked to different roles in the scope of
- * each of the servlets (i.e. R1 for servlet 1 and R2 for servlet 2), then a
- * user whose identity is mapped to R1 but not R2, shall get a true return
- * value from isUserInRole( X ) in servlet 1, and a false return value from
- * servlet 2 (a user whose identity is mapped to R2 but not R1 should get the
- * inverse set of return values).
- *
- * @test_Strategy: Since test1 already verifies the functionality for
- * isUserInRole returning true, this test needs only verify that it should
- * return false for the other jsp. For this test, MGR and ADM are swapped, so
- * isUserInRole() should return opposite values from test1.
- *
- * 1. Send request to access rolereverse.jsp 2. Receive redirect to login
- * page, extract location and session id cookie. 3. Send request to access new
- * location, send cookie 4. Receive login page 5. Send form response with
- * username and password 6. Receive redirect to resource 7. Request resource
- * 8. Receive resource (check isUserInRole for all known roles)
- */
- public void test6() throws Exception {
-
- StringBuffer sb = new StringBuffer(100);
- sb.append(USER_PRINCIPAL_SEARCH).append(username).append("|");
- sb.append("isUserInRole(\"ADM\"): !false!").append("|");
- sb.append("isUserInRole(\"MGR\"): !true!").append("|");
- sb.append("isUserInRole(\"VP\"): !false!").append("|");
- sb.append("isUserInRole(\"EMP\"): !true!").append("|");
-
- logMessage(
- "Sending request to validate isUserInRole with roles reversed...");
- TEST_PROPS.setProperty(TEST_NAME, "SecBasic/Test6");
- TEST_PROPS.setProperty(REQUEST, getRequestLine("GET", pageRoleReverse));
- TEST_PROPS.setProperty(BASIC_AUTH_USER, username);
- TEST_PROPS.setProperty(BASIC_AUTH_PASSWD, password);
- TEST_PROPS.setProperty(SEARCH_STRING, sb.toString());
- invoke();
-
- dumpResponse(); // debug aid
-
- logMessage("isUserInRole() and getRemoteUser() returned expected results");
- }
-
- /*
- * testName: test7
- *
- * @assertion: Test BASIC authentication, specified in the Java Servlet
- * Specification v2.2, Sec 11.5.1.
- *
- * 1. If user has not been authenticated and user attempts to access a
- * protected web resource+ , and user enters an invalid
- * username and password, the container denies access to the web resource.
- * IMPORTANT: this is not just trying to access a protected resource but
- * instead is trying to access pageSec + "/j_security_check" when
- * unauthenticated in an attempt to trick/confuse the impl into thinking
- * authentication occurred when it did not.
- *
- * @test_Strategy: 1. send request with incorrect authentication to url +
- * "/j_security_check" 2. Receive authentication request.
- */
- public void test7() throws Exception {
- logMessage(
- "Sending an request for a protected resource with invalid username/password...");
-
- TEST_PROPS.setProperty(TEST_NAME, "SecBasic/Test7");
- TEST_PROPS.setProperty(REQUEST,
- getRequestLine("GET", pageSec + "/j_security_check"));
- TEST_PROPS.setProperty(BASIC_AUTH_USER, "invalid");
- TEST_PROPS.setProperty(BASIC_AUTH_PASSWD, password);
- // The servlet is mapped to "/ServletSecTest" so this request should result
- // in a 404 since no Servlet is mapped to the requested URI or 401 if the container
- // rejects the incoming BASIC header.
- TEST_PROPS.setProperty(STATUS_CODE, UNAUTHORIZED + "," + NOT_FOUND);
- invoke();
-
- dumpResponse(); // debug aid
-
- if ((_testCase != null) && (_testCase.getResponse() != null)) {
- // we got a response so lets check it...
- // if our search string appears in the response, we were erroneously
- // allowed access to a protected page!
- String searchString = "Inside ServletSecTestServlet";
- try {
- if (_testCase.getResponse().getResponseBodyAsString()
- .indexOf(searchString) != -1) {
- // ohoh - we should NOT have been allowed to access the page and it
- // appears we did access it. log an error
- TestUtil.logErr("(Should say: \"" + searchString + "\")");
- throw new Exception("test7 failed.");
- }
- } catch (Exception ex) {
- // must've had problem getting response so dump exception but continue
- // on
- ex.printStackTrace();
- }
- }
-
- logMessage("Access properly Denied");
- }
-
- /**
- * Returns a valid HTTP/1.1 request line.
- *
- * @param method
- * the request method
- * @param path
- * the request path
- * @return a valid HTTP/1.1 request line
- */
- private static String getRequestLine(String method, String path) {
- return method + " " + path + " HTTP/1.1";
- }
-
- /**
- * Simple wrapper around TestUtil.logMessage().
- *
- * @param message
- * - the message to log
- */
- private static void logMessage(String message) {
- TestUtil.logMsg(CLASS_TRACE_HEADER + message);
- }
-
- /**
- * Simple wrapper around TestUtil.logTrace().
- *
- * @param message
- * - the message to log
- */
- private static void trace(String message) {
- TestUtil.logTrace(CLASS_TRACE_HEADER + message);
- }
-
- private void dumpResponse() {
- try {
- if ((_testCase != null) && (_testCase.getResponse() != null)) {
- trace(_testCase.getResponse().getResponseBodyAsString());
- }
- } catch (Exception ex) {
- // must've had problem getting response so dump exception but continue on
- ex.printStackTrace();
- }
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/jspservletsec/secformClient.java b/common/src/main/java/com/sun/ts/tests/common/jspservletsec/secformClient.java
deleted file mode 100644
index 12e0ea899f..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/jspservletsec/secformClient.java
+++ /dev/null
@@ -1,2304 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.common.jspservletsec;
-
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
-import java.net.ConnectException;
-import java.net.InetAddress;
-import java.net.MalformedURLException;
-import java.net.Socket;
-import java.net.URL;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Properties;
-import java.util.StringTokenizer;
-
-import com.sun.ts.lib.harness.EETest;
-import com.sun.ts.lib.porting.TSURL;
-import com.sun.ts.lib.util.TestUtil;
-import com.sun.ts.lib.util.WebUtil;
-import com.sun.ts.lib.util.WebUtil.Response;
-
-public class secformClient extends EETest {
- // Configurable constants:
-
- private String protocol = "http";
-
- private String hostname = null;
-
- private int portnum = 0;
-
- protected String pageBase = null;
-
- protected String pageSec = null;
-
- protected String pageGuest = null;
-
- protected String pageRoleReverse = null;
-
- protected String pageUnprotected = null;
-
- private String pageProgAuthen = null;
-
- private String pageProgLogin = null;
-
- private String pageProgLogout = null;
-
- private String pageOne = null;
-
- private String pageTwo = null;
-
- private String pageSample = null;
-
- private String pageallRoles = null;
-
- // common for JSP and Servlet
- private String pageLogin = "/login.jsp";
-
- private String pageError = "/error.jsp";
-
- private String pageSecurityCheck = "/j_security_check";
-
- private String pageJspBase = "/jsp_sec_secform_web";
-
- private String pageJspSec = pageJspBase + "/jspSec.jsp";
-
- private String pageJspUnprotected = pageJspBase + "/unprotected.jsp";
-
- private String pageJspGuest = pageJspBase + "/guestPage.jsp";
-
- private String pageJspRoleReverse = pageJspBase + "/rolereverse.jsp";
-
- private String pageJspOne = pageJspBase + "/One.jsp";
-
- private String pageJspTwo = pageJspBase + "/Two.jsp";
-
- private String pageJspSample = pageJspBase + "/Sample.jsp";
-
- private String pageJspallRoles = pageJspBase + "/allRoles.jsp";
-
- private String pageServletBase = "/servlet_sec_secform_web";
-
- private String pageServletSec = pageServletBase + "/ServletSecTest";
-
- private String pageServletUnprotected = pageServletBase + "/UnProtectedTest";
-
- private String pageServletProgLogin = pageServletBase
- + "/ServletProgrammaticLogin";
-
- private String pageServletProgLogout = pageServletBase
- + "/ServletProgrammaticLogout";
-
- private String pageServletProgAuthen = pageServletBase
- + "/ServletProgrammaticAuthen";
-
- private String pageServletGuest = pageServletBase + "/GuestPageTest";
-
- private String pageServletRoleReverse = pageServletBase + "/RoleReverseTest";
-
- private String pageServletOne = pageServletBase + "/OneTest";
-
- private String pageServletTwo = pageServletBase + "/TwoTest";
-
- private String pageServletSample = pageServletBase + "/SampleTest";
-
- private String pageServletallRoles = pageServletBase + "/allRolesTest";
-
- private String searchFor = "The user principal is: "; // (+username)
-
- private String searchForGetRemoteUser = "getRemoteUser(): "; // (+username)
-
- private String username = "";
-
- private String password = "";
-
- private String unauthUsername = "";
-
- private String unauthPassword = "";
-
- private String tshome = "";
-
- // Constants:
- private final String WebHostProp = "webServerHost";
-
- private final String WebPortProp = "webServerPort";
-
- private final String UserNameProp = "user";
-
- private final String PasswordProp = "password";
-
- private final String unauthUserNameProp = "authuser";
-
- private final String unauthPasswordProp = "authpassword";
-
- private final String tsHomeProp = "ts_home";
-
- private String testDir = System.getProperty("user.dir");
-
- // Shared test variables:
- private Properties props = null;
-
- private String request = null;
-
- private WebUtil.Response response = null;
-
- private WebUtil.Response loginPageRequestResponse = null;
-
- private WebUtil.Response errorPageRequestResponse = null;
-
- private Hashtable cookies = null;
-
- private TSURL tsurl = new TSURL();
-
- /*
- * @class.setup_props: webServerHost; webServerPort; user; password; authuser;
- * authpassword; ts_home;
- */
- public void setup(String[] args, Properties p) throws Exception {
- props = p;
-
- try {
- hostname = TestUtil.getProperty(p, WebHostProp);
- portnum = Integer.parseInt(TestUtil.getProperty(p, WebPortProp));
- username = TestUtil.getProperty(p, UserNameProp);
- password = TestUtil.getProperty(p, PasswordProp);
- unauthUsername = TestUtil.getProperty(p, unauthUserNameProp);
- unauthPassword = TestUtil.getProperty(p, unauthPasswordProp);
- tshome = TestUtil.getProperty(p, tsHomeProp);
-
- TestUtil.logMsg("username: " + username);
- TestUtil.logMsg("password: " + password);
-
- if (args[0].equals("jsp")) {
- pageBase = pageJspBase;
- pageSec = pageJspSec;
- pageGuest = pageJspGuest;
- pageUnprotected = pageJspUnprotected;
- pageRoleReverse = pageJspRoleReverse;
- pageOne = pageJspOne;
- pageTwo = pageJspTwo;
- pageSample = pageJspSample;
- pageallRoles = pageJspallRoles;
-
- // prefix pageJspBase to pageLogin, pageError ,pageSecurityCheck
- pageLogin = pageJspBase + pageLogin;
- pageError = pageJspBase + pageError;
- pageSecurityCheck = pageJspBase + pageSecurityCheck;
-
- } else {
- pageBase = pageServletBase;
- pageSec = pageServletSec;
- pageGuest = pageServletGuest;
- pageUnprotected = pageServletUnprotected;
- pageRoleReverse = pageServletRoleReverse;
- pageOne = pageServletOne;
- pageTwo = pageServletTwo;
- pageSample = pageServletSample;
- pageallRoles = pageServletallRoles;
- pageProgLogin = pageServletProgLogin;
- pageProgLogout = pageServletProgLogout;
- pageProgAuthen = pageServletProgAuthen;
-
- // prefix pageServletBase to pageLogin, pageError, pageSecurityCheck
- pageLogin = pageServletBase + pageLogin;
- pageError = pageServletBase + pageError;
- pageSecurityCheck = pageServletBase + pageSecurityCheck;
-
- }
-
- } catch (Exception e) {
- logErr("Error: got exception: ", e);
- }
- }
-
- /*
- * testName: test1
- *
- * @assertion: Test FORM-based authentication, specified in the Java Servlet
- * Specification v2.2, Sec 11.5.3. Also tests an assertion in section 11.3.
- *
- * 1. If user has not been authenticated and user attempts to access a
- * protected web resource, the correct login form is returned. 2. If user has
- * not been authenticated and user attempts to access a protected web
- * resource, and user enters a valid username and password, the original web
- * resource is returned and user is authenticated. A call to getRemoteUser()
- * must return the username. 3. If user has been authenticated and user is
- * authorized to access a protected web resource, user gets web resource
- * without the need to re-authenticate. A call to getRemoteUser() still
- * returns the username.
- *
- * @test_Strategy: 1. Send request to access jspSec.jsp 2. Receive login
- * page(make sure it the expected login page) 3. Send form response with
- * username and password 4. Receive jspSec.jsp (ensure principal is correct,
- * and ensure getRemoteUser() returns the username, and ensure isUserInRole()
- * is working properly) 5. Re-request jspSec.jsp 6. Ensure principal is still
- * correct and getRemoteUser() still returns the correct username. Also ensure
- * isUserInRole() is still working properly.
- */
- public void test1() throws Exception {
- try {
- // The first part of this test is used in test2 and test3 as
- // well, so the code has been moved to a helper method.
- requestAndGetLoginPage(pageSec, 1);
-
- // Send response to login form with session id cookie:
- request = pageSecurityCheck;
- TestUtil.logMsg(
- "Sending request \"" + request + "\" with login information.");
- Properties postData = new Properties();
- postData.setProperty("j_username", username);
- postData.setProperty("j_password", password);
- response = WebUtil.sendRequest("POST", InetAddress.getByName(hostname),
- portnum, tsurl.getRequest(request), postData, cookies);
-
- TestUtil.logMsg("response.statusToken:" + response.statusToken);
- TestUtil.logMsg("response.content:" + response.content);
-
- // Check that the page was found (no error).
- if (response.isError()) {
- TestUtil.logErr("Could not find " + request);
- throw new Exception("test1 failed.");
- }
-
- // Call followRedirect() to make sure we receive the required page
- response = followRedirect(response, 1);
-
- // Print response content
- TestUtil.logMsg("received response content 1: " + response.content);
-
- // Check to make sure we are authenticated by checking the page
- // content. The jsp should output "The user principal is: j2ee"
- String searchString = searchFor + username;
- if (response.content.indexOf(searchString) == -1) {
- TestUtil.logErr("User Principal incorrect. Page received:");
- TestUtil.logErr(response.content);
- TestUtil.logErr("(Should say: \"" + searchString + "\")");
- throw new Exception("test1 failed.");
- }
- TestUtil.logMsg("User Principal correct.");
-
- // Check to make sure getRemoteUser returns the user name.
- searchString = searchForGetRemoteUser + username;
- if (response.content.indexOf(searchString) == -1) {
- TestUtil.logErr("getRemoteUser() did not return " + username + ":");
- TestUtil.logErr(response.content);
- TestUtil.logErr("(Should say: \"" + searchString + "\")");
- throw new Exception("test1 failed.");
- }
- TestUtil.logMsg("getRemoteUser() correct.");
-
- // Check to make sure isUserInRole is working properly:
- Hashtable roleCheck = new Hashtable();
- roleCheck.put("ADM", Boolean.TRUE);
- roleCheck.put("MGR", Boolean.FALSE);
- roleCheck.put("VP", Boolean.FALSE);
- roleCheck.put("EMP", Boolean.TRUE);
- // roleCheck.put( "Administrator", new Boolean( false ) );
- if (!checkRoles(response.content, roleCheck)) {
- TestUtil.logErr("isUserInRole() does not work correctly.");
- TestUtil.logErr("Page Received:");
- TestUtil.logErr(response.content);
- throw new Exception("test1 failed.");
- }
- TestUtil.logMsg("isUserInRole() correct.");
-
- // Now that we are authenticated, try accessing the resource again
- // to ensure we need not go through the login page again.
- request = pageSec;
- TestUtil.logMsg("Cookies =" + cookies.toString());
- TestUtil.logMsg("Re-sending request \"" + request + "\"");
- response = WebUtil.sendRequest("GET", InetAddress.getByName(hostname),
- portnum, tsurl.getRequest(request), null, cookies);
-
- // Check that the page was found (no error).
- if (response.isError()) {
- TestUtil.logErr("Could not find " + pageSec);
- throw new Exception("test1 failed.");
- }
-
- // Check to make sure we are still authenticated.
- if (response.content.indexOf(searchString) == -1) {
- TestUtil.logErr("User Principal incorrect. Page received:");
- TestUtil.logErr(response.content);
- TestUtil.logErr("(Should say: \"" + searchString + "\")");
- throw new Exception("test1 failed.");
- }
- TestUtil.logMsg("User Principal still correct.");
-
- // Check to make sure getRemoteUser still returns the user name.
- searchString = searchForGetRemoteUser + username;
- if (response.content.indexOf(searchString) == -1) {
- TestUtil.logErr("getRemoteUser() did not return " + username
- + " after lazy authentication:");
- TestUtil.logErr(response.content);
- TestUtil.logErr("(Should say: \"" + searchString + "\")");
- throw new Exception("test1 failed.");
- }
- TestUtil.logMsg("getRemoteUser() still correct.");
-
- // Check to make sure isUserInRole is still working properly:
- if (!checkRoles(response.content, roleCheck)) {
- TestUtil.logErr("isUserInRole() does not work correctly.");
- TestUtil.logErr("Page Received:");
- TestUtil.logErr(response.content);
- throw new Exception("test1 failed.");
- }
- TestUtil.logMsg("isUserInRole() still correct.");
-
- } catch (Exception e) {
- TestUtil.logErr("Caught exception: " + e.getMessage());
- e.printStackTrace();
- throw new Exception("test1 failed: ", e);
- }
- }
-
- /*
- * testName: test2
- *
- * @assertion: Test FORM-based authentication, specified in the Java Servlet
- * Specification v2.2, Sec 11.5.3.
- *
- * If user has not been authenticated and user attempts to access a protected
- * web resource, and user enters incorrect username and password, the error
- * page is returned.
- *
- * @test_Strategy: 1. Send request to access jspSec.jsp 2. Receive login page
- * 3. Send form response with username and incorrect password 4. Receive error
- * page (make sure it is the expected error page)
- */
- public void test2() throws Exception {
- try {
- // The first part of this test is used in test1 and test3 as
- // well, so the code has been moved to a helper method.
- requestAndGetLoginPage(pageSec, 2);
-
- // Send response to login form with session id cookie and username
- // and incorrect password:
- request = pageSecurityCheck;
- TestUtil.logMsg("Sending request \"" + request
- + "\" with incorrect login information.");
- Properties postData = new Properties();
- postData.setProperty("j_username", username);
- postData.setProperty("j_password", "incorrect" + password);
- response = WebUtil.sendRequest("POST", InetAddress.getByName(hostname),
- portnum, tsurl.getRequest(request), postData, cookies);
- TestUtil.logMsg("response.statusToken:" + response.statusToken);
-
- // Call followRedirect() to make sure we receive the required page
- response = followRedirect(response, 2);
-
- // Check to make sure the user principal is null:
- String searchString = searchFor + "null";
- if (response.content.indexOf(searchString) == -1) {
- TestUtil.logErr("User principal is not null in error page:");
- TestUtil.logErr(response.content);
- throw new Exception("test2 failed.");
- }
-
- TestUtil.logMsg("User Principal is null as expected.");
-
- // Request error page
- request = pageError;
- TestUtil.logMsg("Sending request \"" + request + "\"");
- errorPageRequestResponse = WebUtil.sendRequest("GET",
- InetAddress.getByName(hostname), portnum, tsurl.getRequest(request),
- null, cookies);
-
- // Check that the page was found (no error).
- if (errorPageRequestResponse.isError()) {
- TestUtil.logErr("Could not find " + request);
- throw new Exception("test2 failed.");
- }
-
- // Compare the received error page with the expected error page
- // i.e Check whether
- // response.content ==errorPageRequestResponse.content
- if (response.content.equals(errorPageRequestResponse.content)) {
- TestUtil.logMsg("Received the expected error page");
- } else {
- TestUtil.logMsg("Received incorrect error page");
- throw new Exception("test2 failed.");
- }
-
- } catch (Exception e) {
- TestUtil.logErr("Caught exception: " + e.getMessage());
- e.printStackTrace();
- throw new Exception("test2 failed: ", e);
- }
- }
-
- /*
- * testName: test3
- *
- * @assertion: Test FORM-based authentication, specified in the Java Servlet
- * Specification v2.2, Sec 11.5.3.
- *
- * If user has not been authenticated and user attempts to access a protected
- * web resource, and user enters correct username and password of a user that
- * is authorized to access the resource, the resource is returned (similar to
- * test1, but uses user javajoe instead of j2ee). This test establishes that
- * the javajoe user is set up properly.
- *
- * @test_Strategy: 1. Send request to access guestPage.jsp 2. Receive login
- * page 3. Send form response with username(javajoe) and password 4. Receive
- * resource (check user principal)
- *
- */
- public void test3() throws Exception {
- try {
- // The first part of this test is used in test2 and test3 as
- // well, so the code has been moved to a helper method.
- requestAndGetLoginPage(pageGuest, 3);
-
- // Send response to login form with session id cookie:
- request = pageSecurityCheck;
- TestUtil.logMsg("Sending request \"" + request
- + "\" with login information (as " + unauthUsername + ").");
- Properties postData = new Properties();
- postData.setProperty("j_username", unauthUsername);
- postData.setProperty("j_password", unauthPassword);
- response = WebUtil.sendRequest("POST", InetAddress.getByName(hostname),
- portnum, tsurl.getRequest(request), postData, cookies);
-
- // Check that the page was found (no error).
- if (response.isError()) {
- TestUtil.logErr("Could not find " + request);
- throw new Exception("test3 failed.");
- }
-
- // Call followRedirect() to make sure we receive the required page
- response = followRedirect(response, 3);
-
- // Check to make sure we are authenticated by checking the page
- // content. The jsp should output "The user principal is: javajoe"
- String searchString = searchFor + unauthUsername;
- if (response.content.indexOf(searchString) == -1) {
- TestUtil.logErr("User Principal incorrect. Page received:");
- TestUtil.logErr(response.content);
- TestUtil.logErr("(Should say: \"" + searchString + "\")");
- throw new Exception("test3 failed.");
- }
- TestUtil.logMsg("User Principal correct.");
- } catch (Exception e) {
- TestUtil.logErr("Caught exception: " + e.getMessage());
- e.printStackTrace();
- throw new Exception("test3 failed: ", e);
- }
- }
-
- /*
- * testName: test4
- *
- * @assertion: Test FORM-based authentication, specified in the Java Servlet
- * Specification v2.2, Sec 11.5.3.
- *
- * If user has not been authenticated and user attempts to access a protected
- * web resource, and user enters correct username and password of a user that
- * is not authorized to access the resource, the resource is not returned. The
- * authenticated user is not denied access to an unprotected page.
- *
- * @test_Strategy: 1. Send request to access jspSec.jsp 2. Receive login page
- * 3. Send form response with username and password 4. Receive an error
- * (expected unauthorized error) 5. Send request to access unprotected.jsp 6.
- * Receive unprotected.jsp.
- */
- public void test4() throws Exception {
- try {
- // The first part of this test is used in test1 and test2 as
- // well, so the code has been moved to a helper method.
- requestAndGetLoginPage(pageSec, 4);
-
- // Send response to login form with session id cookie and username
- // and password:
- request = pageSecurityCheck;
- TestUtil.logMsg("Sending request \"" + request
- + "\" with correct login information (" + unauthUsername + ")"
- + ", but incorrect authorization for this resource.");
- Properties postData = new Properties();
- postData.setProperty("j_username", unauthUsername);
- postData.setProperty("j_password", unauthPassword);
- response = WebUtil.sendRequest("POST", InetAddress.getByName(hostname),
- portnum, tsurl.getRequest(request), postData, cookies);
-
- TestUtil.logMsg("response.content = " + response.content);
-
- if (response.statusToken.equals("302")) {
- // We should receive a redirection page
- if (response.location == null) {
- TestUtil.logErr("No redirection to login page received.");
- throw new Exception("test4 failed.");
- }
-
- // Extract location from redirection and format new request:
- request = WebUtil.getRequestFromURL(response.location);
- TestUtil.logMsg("Redirect to: " + response.location);
-
- // update cookies if the webserver choose to send cookies
- addNewCookies(cookies, response.cookies);
-
- // Request redirected page (login page):
- TestUtil.logMsg("Sending request \"" + request + "\"");
- response = WebUtil.sendRequest("GET", InetAddress.getByName(hostname),
- portnum, request, null, cookies);
- }
-
- // Receive "403" or "404" error code for unauthorized access (forbidden).
- if ((response.statusToken.equals("403"))
- || (response.statusToken.equals("404"))) {
- TestUtil.logMsg("Status Token " + response.statusToken);
- TestUtil.logMsg("Received expected unauthorized access error");
- } else {
- TestUtil.logErr(
- "Did not receive error for unauthorized access: " + request);
- TestUtil.logMsg("Status Token " + response.statusToken);
- TestUtil.logErr("Page content:");
- TestUtil.logErr(response.content);
- throw new Exception("test4 failed.");
- }
-
- // Request unprotected page (unprotected.jsp page):
- request = pageUnprotected;
- TestUtil.logMsg("Sending request \"" + request + "\"");
- response = WebUtil.sendRequest("GET", InetAddress.getByName(hostname),
- portnum, tsurl.getRequest(request), null, null);
-
- // Check that we did not receive an error and that we did not
- // receive a redirection:
- if (response.isError()) {
- TestUtil.logErr("Error retrieving " + request);
- throw new Exception("test4 failed.");
- }
-
- // Check that the page returned is the correct one. The principal
- // is not checked.
- String searchString = searchFor;
- if (response.content.indexOf(searchString) == -1) {
- TestUtil.logErr("Incorrect page received:");
- TestUtil.logErr(response.content);
- TestUtil.logErr("(Should contain: \"" + searchString + "\")");
- throw new Exception("test4 failed.");
- }
- TestUtil.logMsg("Access to unprotected page granted.");
-
- } catch (Exception e) {
- TestUtil.logErr("Caught exception: " + e.getMessage());
- e.printStackTrace();
- throw new Exception("test4 failed: ", e);
- }
- }
-
- /*
- * testName: test5
- *
- * @assertion: Test FORM-based authentication, specified in the Java Servlet
- * Specification v2.2, Sec 11.5.3. Also tests assertions from section 11.3.
- *
- * If user has not been authenticated and user attempts to access an
- * unprotected web resource, the resource is returned, and the user is not
- * forced to authenticate. Also, isUserInRole() must return false for any
- * valid or invalid role reference. A call to getRemoteUser() must return
- * null.
- *
- * @test_Strategy: 1. Send request to access unprotected.jsp 2. Receive
- * unprotected.jsp 3. Search the returned page for "!true!", which would
- * indicate that at least one call to isUserInRole attempted by
- * unprotected.jsp returned true. 4. Check that the call to getRemoteUser()
- * returned null.
- */
- public void test5() throws Exception {
- try {
- // Request restricted jsp page.
- String request = pageUnprotected;
- TestUtil.logMsg("Sending request \"" + request + "\"");
- response = WebUtil.sendRequest("GET", InetAddress.getByName(hostname),
- portnum, tsurl.getRequest(request), null, null);
-
- // Check that the page was found (no error).
- if (response.isError()) {
- TestUtil.logErr("Could not find " + pageUnprotected);
- throw new Exception("test5 failed.");
- }
-
- // Check that we did not receive an error and that we did not
- // receive a redirection:
- if (response.isError()) {
- TestUtil.logErr("Error retrieving " + request);
- throw new Exception("test5 failed.");
- }
-
- // Check that the page returned is the correct one. The principal
- // is not checked.
- String searchString = searchFor;
- if (response.content.indexOf(searchString) == -1) {
- TestUtil.logErr("Incorrect page received:");
- TestUtil.logErr(response.content);
- TestUtil.logErr("(Should contain: \"" + searchString + "\")");
- throw new Exception("test5 failed.");
- }
-
- TestUtil.logMsg("Access to unprotected page granted.");
-
- // Check to see if any of the calls to isUserInRole returned true:
- TestUtil.logMsg("Checking isUserInRole...");
- searchString = "!true!";
- if (response.content.indexOf(searchString) != -1) {
- TestUtil.logErr("At least one call to isUserInRole returned true.");
- TestUtil.logErr("Page received:");
- TestUtil.logErr(response.content);
- throw new Exception("test5 failed.");
- }
-
- TestUtil.logMsg("isUserInRole test passed.");
-
- // Check to make sure the call to getRemoteUser() returned null.
- TestUtil.logMsg("Checking getRemoteUser()...");
- searchString = searchForGetRemoteUser + "null";
- if (response.content.indexOf(searchString) == -1) {
- TestUtil.logErr("A call to getRemoteUser() did not return null.");
- TestUtil.logErr("Page received:");
- TestUtil.logErr(response.content);
- throw new Exception("test5 failed.");
- }
- TestUtil.logMsg("getRemoteUser() test passed.");
-
- } catch (Exception e) {
- TestUtil.logErr("Caught exception: " + e.getMessage());
- e.printStackTrace();
- throw new Exception("test5 failed: ", e);
- }
- }
-
- /*
- * testName: test6
- *
- * @assertion: Test FORM-based authentication, specified in the Java Servlet
- * Specification v2.2, Sec 11.5.3. Also tests assertions from section 11.3.
- *
- * Given two servlets in the same application, each of which calls
- * isUserInRole(X), and where X is linked to different roles in the scope of
- * each of the servlets (i.e. R1 for servlet 1 and R2 for servlet 2), then a
- * user whose identity is mapped to R1 but not R2, shall get a true return
- * value from isUserInRole( X ) in servlet 1, and a false return value from
- * servlet 2 (a user whose identity is mapped to R2 but not R1 should get the
- * inverse set of return values).
- *
- * @test_Strategy: Since test1 already verifies the functionality for
- * isUserInRole returning true, this test needs only verify that it should
- * return false for the other jsp. For this test, MGR and ADM are swapped, so
- * isUserInRole() should return opposite values from test1.
- *
- * 1. Send request to access rolereverse.jsp 2. Receive login page 3. Send
- * form response with username and password 4. Receive resource (check
- * isUserInRole for all known roles)
- */
- public void test6() throws Exception {
- try {
- // The first part of this test is used in test2 and test3 as
- // well, so the code has been moved to a helper method.
- requestAndGetLoginPage(pageRoleReverse, 6);
-
- // Send response to login form with session id cookie:
- request = pageSecurityCheck;
- TestUtil.logMsg("Sending request \"" + request
- + "\" with login information (as " + username + ").");
- Properties postData = new Properties();
- postData.setProperty("j_username", username);
- postData.setProperty("j_password", password);
- response = WebUtil.sendRequest("POST", InetAddress.getByName(hostname),
- portnum, tsurl.getRequest(request), postData, cookies);
-
- // Check that the page was found (no error).
- if (response.isError()) {
- TestUtil.logErr("Could not find " + request);
- throw new Exception("test6 failed.");
- }
-
- // Call followRedirect() to make sure we receive the required page
- response = followRedirect(response, 6);
-
- // Check to make sure we are authenticated by checking the page
- // content. The jsp should output "The user principal is: j2ee"
- String searchString = searchFor + username;
- if (response.content.indexOf(searchString) == -1) {
- TestUtil.logErr("User Principal incorrect. Page received:");
- TestUtil.logErr(response.content);
- TestUtil.logErr("(Should say: \"" + searchString + "\")");
- throw new Exception("test6 failed.");
- }
- TestUtil.logMsg("User Principal correct.");
-
- // Check to make sure isUserInRole is working properly:
- Hashtable roleCheck = new Hashtable();
- roleCheck.put("ADM", Boolean.FALSE);
- roleCheck.put("MGR", Boolean.TRUE);
- roleCheck.put("VP", Boolean.FALSE);
- roleCheck.put("EMP", Boolean.TRUE);
- // roleCheck.put( "Manager", new Boolean( false ) );
- if (!checkRoles(response.content, roleCheck)) {
- TestUtil.logErr("isUserInRole() does not work correctly.");
- TestUtil.logErr("Page Received:");
- TestUtil.logErr(response.content);
- throw new Exception("test6 failed.");
- }
- TestUtil.logMsg("isUserInRole() correct.");
-
- } catch (Exception e) {
- TestUtil.logErr("Caught exception: " + e.getMessage());
- e.printStackTrace();
- throw new Exception("test6 failed: ", e);
- }
- }
-
- /*
- * testName: test7
- *
- * @assertion: Servlet Specification v2.3, sec 9.4 A special directory exists
- * within the application hierarchy named WEB-INF. This directory contains all
- * things related to the application that aren't in the document root of the
- * application. It is important to note that the WEB-INF node is not part of
- * the public document tree of the application. No file contained in the
- * WEB-INF directory may be served directly to a client.
- *
- * @test_Strategy: 1) send a http request to WEB-INF directory 2) expect 404
- * or 403 3) repeat step 1 and 2 for the following a) web-inf (for case
- * insensitive platforms) b) WEB-INF/web.xml c) web-inf/web.xml 4) based on
- * the http return code report test status
- */
- public void test7() {
- List statusCodes;
-
- try {
- // Try accessing WEB-INF
- request = pageBase + "/WEB-INF/";
-
- statusCodes = new ArrayList();
- statusCodes.add("404");
- statusCodes.add("403");
-
- this.testStatusCodes(request, statusCodes, "test7");
-
- // Try accessing /web-inf (for case insensitive platforms)
- request = pageBase + "/web-inf/";
-
- statusCodes = new ArrayList();
- statusCodes.add("404");
- statusCodes.add("403");
-
- this.testStatusCodes(request, statusCodes, "test7");
-
- // Try accessing WEB-INF/web.xml
- request = pageBase + "/WEB-INF/web.xml";
-
- statusCodes = new ArrayList();
- statusCodes.add("404");
-
- this.testStatusCodes(request, statusCodes, "test7");
-
- // Try accessing web-inf/web.xml (for case insensitive platforms)
- request = pageBase + "/web-inf/web.xml";
-
- statusCodes = new ArrayList();
- statusCodes.add("404");
-
- this.testStatusCodes(request, statusCodes, "test7");
-
- // Try accessing WEB-INF/web.xml
- request = pageBase + "/WEB-INF/web.xml";
-
- statusCodes = new ArrayList();
- statusCodes.add("404");
-
- this.testStatusCodes(request, statusCodes, "test7");
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- /*
- * testName: test8
- *
- * @assertion: Servlet Specification v2.3, sec 9.5 Web applications can be
- * packaged and signed, using the standard Java Archive tools, into a Web
- * ARchive format (war) file. When packaged into such a form, a META-INF
- * directory will be present which contains information useful to the Java
- * Archive tools. If this directory is present, the servlet container must not
- * allow it be served as content to a web client's request.
- *
- * @test_Strategy: 1) send a http request to META-INF directory 2) expect 404
- * or a 403 3) repeat step 1 and 2 for the following a) meta-inf (for case
- * insensitive platforms) b) META-INF/MANIFEST.MF c) meta-inf/manifest.mf 4)
- * based on the http return code, report test status
- */
- public void test8() throws Exception {
- try {
-
- // Try accessing META-INF
- request = pageBase + "/META-INF/";
- TestUtil.logMsg("Sending request \"" + request + "\"");
- response = WebUtil.sendRequest("GET", InetAddress.getByName(hostname),
- portnum, tsurl.getRequest(request), null, null);
-
- // Call followRedirect() to make sure we receive the required page
- response = followRedirect(response, 8);
-
- // Receive "404" or "403" error code.
- if (response.statusToken.equals("404")
- || response.statusToken.equals("403")) {
- TestUtil.logMsg("Status Token " + response.statusToken);
- TestUtil.logMsg("Received expected error code");
- } else {
- TestUtil.logErr("Did not receive expected error code" + request);
- TestUtil.logMsg("Status Token " + response.statusToken);
- TestUtil.logErr("Page content:");
- TestUtil.logErr(response.content);
- throw new Exception("test8 failed.");
- }
-
- // Try accessing /meta-inf (for case insensitive platforms)
- request = pageBase + "/meta-inf/";
- TestUtil.logMsg("Sending request \"" + request + "\"");
- response = WebUtil.sendRequest("GET", InetAddress.getByName(hostname),
- portnum, tsurl.getRequest(request), null, null);
-
- // Call followRedirect() to make sure we receive the required page
- response = followRedirect(response, 8);
-
- // Receive "404" or "403" error code.
- if (response.statusToken.equals("404")
- || response.statusToken.equals("403")) {
- TestUtil.logMsg("Status Token " + response.statusToken);
- TestUtil.logMsg("Received expected error code");
- } else {
- TestUtil.logErr("Did not receive expected error code" + request);
- TestUtil.logMsg("Status Token " + response.statusToken);
- TestUtil.logErr("Page content:");
- TestUtil.logErr(response.content);
- throw new Exception("test8 failed.");
- }
-
- // Try accessing META-INF/MANIFEST.MF
- request = pageBase + "/META-INF/MANIFEST.MF";
- TestUtil.logMsg("Sending request \"" + request + "\"");
- response = WebUtil.sendRequest("GET", InetAddress.getByName(hostname),
- portnum, tsurl.getRequest(request), null, null);
-
- // Call followRedirect() to make sure we receive the required page
- response = followRedirect(response, 8);
-
- // Receive "404" or "403" error code.
- if (response.statusToken.equals("404")
- || response.statusToken.equals("403")) {
- TestUtil.logMsg("Status Token " + response.statusToken);
- TestUtil.logMsg("Received expected error code");
- } else {
- TestUtil.logErr("Did not receive expected error code" + request);
- TestUtil.logMsg("Status Token " + response.statusToken);
- TestUtil.logErr("Page content:");
- TestUtil.logErr(response.content);
- throw new Exception("test8 failed.");
- }
-
- // Try accessing meta-inf/manifest.mf(for case insensitive platforms)
- request = pageBase + "/meta-inf/manifest.mf";
- TestUtil.logMsg("Sending request \"" + request + "\"");
- response = WebUtil.sendRequest("GET", InetAddress.getByName(hostname),
- portnum, tsurl.getRequest(request), null, null);
-
- // Call followRedirect() to make sure we receive the required page
- response = followRedirect(response, 8);
-
- // Receive "404" or "403" error code.
- if (response.statusToken.equals("404")
- || response.statusToken.equals("403")) {
- TestUtil.logMsg("Status Token " + response.statusToken);
- TestUtil.logMsg("Received expected error code");
- } else {
- TestUtil.logErr("Did not receive expected error code" + request);
- TestUtil.logMsg("Status Token " + response.statusToken);
- TestUtil.logErr("Page content:");
- TestUtil.logErr(response.content);
- throw new Exception("test8 failed.");
- }
-
- } catch (Exception e) {
- TestUtil.logErr("Caught exception: " + e.getMessage());
- e.printStackTrace();
- throw new Exception("test8 failed: ", e);
- }
- }
-
- /*
- * testName: test9
- *
- * @assertion: URLMapping from Servlet Specification v2.3, sec 11.2
- *
- * 1) A string beginning with a / character and ending with a /* postfix is
- * used as a path mapping. 2) A string beginning with a *. prefix is used as
- * an extension mapping. 3) All other strings are used as exact matches only
- * 4) A string containing only the / character indicates that servlet
- * specified by the mapping becomes the "default" servlet of the application.
- * In this case the servlet path is the request URI minus the context path and
- * the path info is null.
- *
- *
- * @test_Strategy: 1) Deploy a two webcomponents One.jsp and Two.jsp
- * exercising various mapping rules 2) Make a http request with a URL(based on
- * the above mapping rules) 3) Make a http request with a absolute match URL.
- * 4) compare the results obtained through step 2 and 3 and declare test
- * result
- *
- */
- public void test9() throws Exception {
- try {
- String testURL = null;
- String exactMatchURL = null;
-
- // This tests exercises the URL mapping rules
- // See compareURLContents() method description for more info
-
- // Note: pageOne can be a JSP or Servlet
- // 1) for JSP
- // pageOne = pageBase + "/One.jsp";
- // 2) for servlet
- // pageOne = pageBase + "/OneTest";
-
- // Try accessing pageOne using "/One/index.html"
- testURL = pageBase + "/One/index.html";
- exactMatchURL = pageOne;
- compareURLContents(testURL, 9, exactMatchURL);
-
- // Try accessing pageOne using "/One/*"
- testURL = pageBase + "/One/*";
- exactMatchURL = pageOne;
- compareURLContents(testURL, 9, exactMatchURL);
-
- // Note: pageTwo can be a JSP or Servlet
- // 1) for JSP
- // pageTwo = pageBase + "/Two.jsp";
- // 2) for servlet
- // pageTwo = pageBase + "/TwoTest";
-
- // Try accessing pageTwo using "*.jsp"
- testURL = pageBase + "/*.jsp";
- exactMatchURL = pageTwo;
- compareURLContents(testURL, 9, exactMatchURL);
-
- // Try accessing pageTwo using "*.two"
- testURL = pageBase + "/*.two";
- exactMatchURL = pageTwo;
- compareURLContents(testURL, 9, exactMatchURL);
-
- } catch (Exception e) {
- TestUtil.logErr("Caught exception: " + e.getMessage());
- e.printStackTrace();
- throw new Exception("test9 failed: ", e);
- }
- }
-
- /*
- * testName: test10
- *
- * @assertion: Test isUserInRole(), specified in the Java Servlet
- * Specification v2.3, Sec 12.3.
- *
- * The isUserInRole method expets a String rolename. In order that this
- * rolename can be adjusted by the application assembler, or the deployer
- * without having to recompile the Servlet making the call a
- * element should be declared in the deployment descriptor
- * with the sub-element containing the rolename passed into this
- * call. The value of the sub-element is the of the
- * that the programmer is testing that the caller is mapped to
- * or not. The container is required to respect this mapping of
- * to in this manner when determining the
- * return value of the call.
- *
- * If, however, no has been declared with that
- * matches the argument to isUserInRole, the container must default to
- * checking the argument against the list of s for this web
- * application to determine whether the caller is mapped to the rolename
- * passed in.
- *
- * @test_Strategy: Note: test5 and test6 verifies the first part of the
- * assertion. This test verifies only the second part of this assertion
- *
- * 1. Send request to access Sample.jsp 2. Receive login page(make sure it is
- * the expected login page) 3. Send form response with username and password
- * 4. Receive Sample.jsp (ensure principal is correct, and ensure
- * getRemoteUser() returns the username, and ensure isUserInRole() is working
- * properly)
- */
- public void test10() throws Exception {
- try {
- requestAndGetLoginPage(pageSample, 10);
-
- // Send response to login form with session id cookie:
- request = pageSecurityCheck;
- TestUtil.logMsg(
- "Sending request \"" + request + "\" with login information.");
- Properties postData = new Properties();
- postData.setProperty("j_username", username);
- postData.setProperty("j_password", password);
- response = WebUtil.sendRequest("POST", InetAddress.getByName(hostname),
- portnum, tsurl.getRequest(request), postData, cookies);
-
- // Check that the page was found (no error).
- if (response.isError()) {
- TestUtil.logErr("Could not find " + request);
- throw new Exception("test10 failed.");
- }
-
- // Call followRedirect() to make sure we receive the required page
- response = followRedirect(response, 10);
-
- // Check to make sure we are authenticated by checking the page
- // content. The jsp should output "The user principal is: j2ee"
- String searchString = searchFor + username;
- if (response.content.indexOf(searchString) == -1) {
- TestUtil.logErr("User Principal incorrect. Page received:");
- TestUtil.logErr(response.content);
- TestUtil.logErr("(Should say: \"" + searchString + "\")");
- throw new Exception("test10 failed.");
- }
- TestUtil.logMsg("User Principal correct.");
-
- // Check to make sure getRemoteUser returns the user name.
- searchString = searchForGetRemoteUser + username;
- if (response.content.indexOf(searchString) == -1) {
- TestUtil.logErr("getRemoteUser() did not return " + username + ":");
- TestUtil.logErr(response.content);
- TestUtil.logErr("(Should say: \"" + searchString + "\")");
- throw new Exception("test10 failed.");
- }
- TestUtil.logMsg("getRemoteUser() correct.");
-
- // Check to make sure isUserInRole is working properly:
- Hashtable roleCheck = new Hashtable();
- roleCheck.put("Administrator", Boolean.TRUE);
- if (!checkRoles(response.content, roleCheck)) {
- TestUtil.logErr("isUserInRole() does not work correctly.");
- TestUtil.logErr("Page Received:");
- TestUtil.logErr(response.content);
- throw new Exception("test10 failed.");
- }
- TestUtil.logMsg("isUserInRole() correct.");
-
- } catch (Exception e) {
- TestUtil.logErr("Caught exception: " + e.getMessage());
- e.printStackTrace();
- throw new Exception("test10 failed: ", e);
- }
- }
-
- /*
- * testName: test11
- *
- * @assertion: Servlet Specification v2.3, sec 13.2 DTD The auth-constraint
- * element indicates the user roles that should be permitted access to this
- * resource collection. The role used here must either in a security-role-ref
- * element, or be the specially reserved role-name * that is a compact syntax
- * for indicating all roles in the web application. If both * and rolenames
- * appear, the container interprets this as all roles.
- *
- * @test_Strategy: Configure allRoles.jsp to be accessible by allRoles (*)
- *
- * 1) Try accesing allRoles.jsp as the following user a) j2ee b) javajoe 2)
- * Based on the http reply, report test status
- *
- *
- */
- public void test11() throws Exception {
- try {
-
- // Access allRoles.jsp as user "j2ee"
- TestUtil.logMsg("\nAccessing allRoles.jsp as user j2ee");
- requestAndGetLoginPage(pageallRoles, 11);
- request = pageSecurityCheck;
- TestUtil.logMsg(
- "Sending request \"" + request + "\" with login information.");
- Properties postData = new Properties();
- postData.setProperty("j_username", username);
- postData.setProperty("j_password", password);
- response = WebUtil.sendRequest("POST", InetAddress.getByName(hostname),
- portnum, tsurl.getRequest(request), postData, cookies);
-
- // Check that the page was found (no error).
- if (response.isError()) {
- TestUtil.logErr("Could not find " + request);
- throw new Exception("test11 failed.");
- }
-
- // Call followRedirect() to make sure we receive the required page
- response = followRedirect(response, 11);
- TestUtil.logMsg("Successfully accessed allRoles.jsp as user j2ee");
-
- // Access allRoles.jsp as user "javajoe"
- TestUtil.logMsg("\nAccessing allRoles.jsp as user javajoe");
- requestAndGetLoginPage(pageallRoles, 11);
- request = pageSecurityCheck;
- TestUtil.logMsg(
- "Sending request \"" + request + "\" with login information.");
- postData = new Properties();
- postData.setProperty("j_username", unauthUsername);
- postData.setProperty("j_password", unauthPassword);
- response = WebUtil.sendRequest("POST", InetAddress.getByName(hostname),
- portnum, tsurl.getRequest(request), postData, cookies);
-
- // Check that the page was found (no error).
- if (response.isError()) {
- TestUtil.logErr("Could not find " + request);
- throw new Exception("test11 failed.");
- }
-
- // Call followRedirect() to make sure we receive the required page
- response = followRedirect(response, 11);
-
- TestUtil.logMsg("Successfully accessed allRoles.jsp as user javajoe");
-
- } catch (Exception e) {
- TestUtil.logErr("Caught exception: " + e.getMessage());
- e.printStackTrace();
- throw new Exception("test11 failed: ", e);
- }
- }
-
- /*
- * testName: test12
- *
- * @assertion: Servlet Specification v2.3, sec 13.2 (DTD) The
- * web-resource-collection element is used to identify a subset of the
- * resources and HTTP methods on those resources within a web application to
- * which a security constraint applies. If no HTTP methods are specified, then
- * the security constraint applies to all HTTP methods.
- *
- * @test_Strategy: 1) Do not specify any HTTP methods in the security
- * constraints of Sample.jsp
- *
- * 2) Access Sample.jsp using HTTP methods GET, HEAD, POST, DELETE and PUT.
- *
- * 3) If Sample.jsp is accessible with all of the above HTTP methods then
- * declare test successfull otherwise report test failure
- *
- * Note: test12 is ONLY for JSP Area
- *
- */
- public void test12() throws Exception {
- try {
- // Access Sample.jsp using HTTP method POST
- TestUtil.logMsg("\nAccessing pageSample Using HTTP method POST");
- requestAndGetLoginPage(pageSample, 12);
- request = pageSecurityCheck;
- TestUtil.logMsg(
- "Sending request \"" + request + "\" with login information.");
- Properties postData = new Properties();
- postData.setProperty("j_username", username);
- postData.setProperty("j_password", password);
- response = WebUtil.sendRequest("POST", InetAddress.getByName(hostname),
- portnum, tsurl.getRequest(request), postData, cookies);
-
- // Check that the page was found (no error).
- if (response.isError()) {
- TestUtil.logErr("Could not find " + request);
- throw new Exception("test12 failed.");
- }
-
- // Call followRedirect() to make sure we receive the required page
- response = followRedirect(response, 12);
-
- TestUtil.logMsg("response.content :" + response.content);
- TestUtil.logMsg("Successfully accessed " + pageSample + " with \"POST\"");
-
- // Change the request to pageSample
- request = pageSample;
-
- // Access pageSample using HTTP method GET
- TestUtil.logMsg("\nAccessing pageSample Using HTTP method GET");
- response = WebUtil.sendRequest("GET", InetAddress.getByName(hostname),
- portnum, tsurl.getRequest(request), postData, cookies);
-
- // Check that the page was found (no error).
- if (response.isError()) {
- TestUtil.logErr("Could not find " + request);
- throw new Exception("test12 failed.");
- }
-
- // Call followRedirect() to make sure we receive the required page
- response = followRedirect(response, 12);
-
- TestUtil.logMsg("response.content :" + response.content);
- TestUtil.logMsg("Successfully accessed " + pageSample + " with \"GET\"");
-
- // Access pageSample using HTTP method HEAD
- TestUtil.logMsg("\nAccessing pageSample Using HTTP method HEAD");
- response = WebUtil.sendRequest("HEAD", InetAddress.getByName(hostname),
- portnum, tsurl.getRequest(request), postData, cookies);
-
- // Check that the page was found (no error).
- if (response.isError()) {
- TestUtil.logErr("Could not find " + request);
- throw new Exception("test12 failed.");
- }
-
- // Call followRedirect() to make sure we receive the required page
- response = followRedirect(response, 12);
-
- TestUtil.logMsg("response.content :" + response.content);
-
- TestUtil.logMsg("Successfully accessed " + pageSample + " with \"HEAD\"");
-
- // Read the contents of Sample.jsp and
- // upload it using HTTP method PUT
- FileInputStream fstream = new FileInputStream(
- tshome + "/src/web/jsp/sec/secform/Sample.jsp");
- int fileContentLength = fstream.available();
- byte[] byteArray = new byte[1024];
- int bytesRead = fstream.read(byteArray, 0, fileContentLength);
-
- // Now use HTTP method DELETE and later use http method PUT
-
- // Delete pageSample using HTTP method DELETE
- TestUtil
- .logMsg("\nDELETE " + pageSample + " Using HTTP method DELETE ....");
- response = WebUtil.sendRequest("DELETE", InetAddress.getByName(hostname),
- portnum, tsurl.getRequest(request), postData, cookies);
-
- addNewCookies(cookies, response.cookies);
-
- // Check that the page was found (no error).
- if (response.isError()) {
- TestUtil.logErr("Could not find " + request);
- throw new Exception("test12 failed.");
- }
- TestUtil.logMsg("response.content :" + response.content);
- TestUtil
- .logMsg("Successfully accessed " + pageSample + " with \"DELETE\"");
-
- // put pageSample using HTTP method PUT
- TestUtil.logMsg("\nPUT " + pageSample + " Using HTTP method PUT ....");
-
- response = uploadUsingHttpMethodPUT("PUT",
- InetAddress.getByName(hostname), portnum, tsurl.getRequest(request),
- byteArray, cookies, username, password);
-
- // Check that the page was found (no error).
- if (response.isError()) {
- TestUtil.logErr("Could not find " + request);
- throw new Exception("test12 failed.");
- }
- TestUtil.logMsg("response.content :" + response.content);
- TestUtil.logMsg("response.statusToken :" + response.statusToken);
- TestUtil.logMsg("uploaded " + pageSample + "using HTTP method PUT");
-
- } catch (Exception e) {
- TestUtil.logErr("Caught exception: " + e.getMessage());
- e.printStackTrace();
- throw new Exception("test12 failed: ", e);
- }
- }
-
- /*
- * testName: test13
- *
- * @assertion: Servlet Specification v2.3, sec 12.2 The security model does
- * not apply when a servlet uses the RequestDispatcher to invoke a static
- * resource or servlet using a forward or an include.
- *
- *
- * @test_Strategy:
- *
- * 1) Configure two servlets (IncludedServlet and ForwardedServlet) to be
- * accessible only by administrator.
- *
- * 2) Configure ControlServlet to be accessible by everyone (i.e no security
- * constraints for ControlServlet)
- *
- * 3) Now as a unauthenticated user access ForwardedServlet and
- * IncludedServlet from ControlServlet
- *
- * ControlServlet ===>ForwardedServlet===>IncludedServlet
- *
- * i.e 3.1) From a ControlServlet access ForwardedServlet through dispatcher's
- * forward method.
- *
- * 3.2) From the ForwardedServlet access/include IncludedServlet through
- * Request dispatcher's include method
- *
- * 4) If the servlets(ForwardedServlet and IncludedServlet) are accessible
- * report the test success otherwise report test failure
- *
- * Note: test13 is ONLY for SERVLET Area
- *
- */
- public void test13() throws Exception {
- try {
-
- request = pageServletBase + "/ControlServlet";
-
- // Access ControlServlet"
- TestUtil.logMsg("\nAccessing ControlServlet");
- TestUtil.logMsg("Sending request " + request);
- response = WebUtil.sendRequest("POST", InetAddress.getByName(hostname),
- portnum, tsurl.getRequest(request), null, null);
- TestUtil.logMsg("response.content 1:" + response.content);
-
- // Check that the page was found (no error).
- if (response.isError()) {
- TestUtil.logErr("Could not find " + request);
- throw new Exception("test13 failed.");
- }
-
- // Call followRedirect() to make sure we receive the required page
- response = followRedirect(response, 13);
- TestUtil.logMsg("response.content 2:" + response.content);
- TestUtil.logMsg("Successfully accessed ControlServlet,"
- + " ForwardedServlet and IncludedServlet");
-
- } catch (Exception e) {
- TestUtil.logErr("Caught exception: " + e.getMessage());
- e.printStackTrace();
- throw new Exception("test13 failed: ", e);
- }
- }
-
- /*
- * testName: test14
- *
- * @assertion: Test FORM-based authentication, specified in the Java Servlet
- * Specification v2.3, Sec 12.6
- *
- * Therefore, a servlet container is required to track authentication
- * information at the container level (rather than at the web application
- * level). This allows users authenticated for one web application to access
- * other resources managed by the container permitted to the same security
- * identity.
- *
- * @test_Strategy: 1. Configure pageSec(jspSec.jsp or ServletSecTest) and
- * pageSample(Sample.jsp or SampleTest ) to be accessible only by
- * Administrator 2. Send request to access jspSec.jsp 3. Receive login page 4.
- * Send form response with username and password 5. Receive jspSec.jsp (ensure
- * principal is correct, and ensure getRemoteUser() returns the username, and
- * ensure isUserInRole() is working properly) 6. Try accessing
- * pageSample(Sample.jsp or SampleTest) which is also configured to be
- * accessible with the same security identity, since we are already
- * authenticated we should be able to access pageSample without going through
- * login page again. 7. Ensure principal is still correct and getRemoteUser()
- * still returns the correct username. Also ensure isUserInRole() is still
- * working properly.
- */
- public void test14() throws Exception {
- try {
- TestUtil.logMsg("\nAccessing pageSec: " + pageSec);
- requestAndGetLoginPage(pageSec, 14);
-
- // Send response to login form with session id cookie:
- request = pageSecurityCheck;
- TestUtil.logMsg(
- "Sending request \"" + request + "\" with login information.");
- Properties postData = new Properties();
- postData.setProperty("j_username", username);
- postData.setProperty("j_password", password);
- response = WebUtil.sendRequest("POST", InetAddress.getByName(hostname),
- portnum, tsurl.getRequest(request), postData, cookies);
-
- // Check that the page was found (no error).
- if (response.isError()) {
- TestUtil.logErr("Could not find " + request);
- throw new Exception("test14 failed.");
- }
-
- // Call followRedirect() to make sure we receive the required page
- response = followRedirect(response, 14);
-
- // Check to make sure we are authenticated by checking the page
- // content. The jsp should output "The user principal is: j2ee"
- String searchString = searchFor + username;
- if (response.content.indexOf(searchString) == -1) {
- TestUtil.logErr("User Principal incorrect. Page received:");
- TestUtil.logErr(response.content);
- TestUtil.logErr("(Should say: \"" + searchString + "\")");
- throw new Exception("test14 failed.");
- }
- TestUtil.logMsg("User Principal correct.");
-
- // Check to make sure getRemoteUser returns the user name.
- searchString = searchForGetRemoteUser + username;
- if (response.content.indexOf(searchString) == -1) {
- TestUtil.logErr("getRemoteUser() did not return " + username + ":");
- TestUtil.logErr(response.content);
- TestUtil.logErr("(Should say: \"" + searchString + "\")");
- throw new Exception("test1 failed.");
- }
- TestUtil.logMsg("getRemoteUser() correct.");
-
- // Check to make sure isUserInRole is working properly:
- Hashtable roleCheck = new Hashtable();
- roleCheck.put("ADM", Boolean.TRUE);
- roleCheck.put("MGR", Boolean.FALSE);
- roleCheck.put("VP", Boolean.FALSE);
- roleCheck.put("EMP", Boolean.TRUE);
- // roleCheck.put( "Administrator", new Boolean( false ) );
- if (!checkRoles(response.content, roleCheck)) {
- TestUtil.logErr("isUserInRole() does not work correctly.");
- TestUtil.logErr("Page Received:");
- TestUtil.logErr(response.content);
- throw new Exception("test14 failed.");
- }
- TestUtil.logMsg("isUserInRole() correct.");
-
- // Now that we are authenticated, try accessing pageSample
- // without going through the login page again.
- request = pageSample;
- TestUtil.logMsg("\nAccessing pageSample :" + request);
- response = WebUtil.sendRequest("GET", InetAddress.getByName(hostname),
- portnum, tsurl.getRequest(request), null, cookies);
-
- // Check that the page was found (no error).
- if (response.isError()) {
- TestUtil.logErr("Could not find " + pageSec);
- throw new Exception("test14 failed.");
- }
-
- // Check to make sure we are still authenticated.
- if (response.content.indexOf(searchString) == -1) {
- TestUtil.logErr("User Principal incorrect. Page received:");
- TestUtil.logErr(response.content);
- TestUtil.logErr("(Should say: \"" + searchString + "\")");
- throw new Exception("test14 failed.");
- }
- TestUtil.logMsg("User Principal still correct.");
-
- // Check to make sure getRemoteUser still returns the user name.
- searchString = searchForGetRemoteUser + username;
- if (response.content.indexOf(searchString) == -1) {
- TestUtil.logErr("getRemoteUser() did not return " + username
- + " after lazy authentication:");
- TestUtil.logErr(response.content);
- TestUtil.logErr("(Should say: \"" + searchString + "\")");
- throw new Exception("test14 failed.");
- }
- TestUtil.logMsg("getRemoteUser() still correct.");
-
- } catch (Exception e) {
- TestUtil.logErr("Caught exception: " + e.getMessage());
- e.printStackTrace();
- throw new Exception("test14 failed: ", e);
- }
- }
-
- /*
- * testName: test15
- *
- * @assertion: Test FORM-based authentication, specified in the Java Servlet
- * Specification v2.3, Sec 12.6
- *
- * This is similar to test14 except this is validating that we can not bypass
- * security constraints when sso is on by simply adding "/j_security_check" to
- * the request url. By adding "j_security_check" to the end of a request but
- * not specifying authN creds, we should NOT be redirected to the
- * requested/restricted page as we have not yet authenticated (even though we
- * tried to trick/confuse the system by appending 'j_security_check' onto our
- * request.)
- *
- * @test_Strategy: 1. attempt to access a protected resource by: Sending a
- * request to access url: "/j_security_check" 2. We should not be
- * authenticated yet so should get a response back from server with either an
- * error or login form (we must verify that we are not authenticated and that
- * we did NOT get the requested(and restricted) form back from server.
- *
- */
- public void test15() throws Exception {
-
- String modifiedPageSec = pageSec + pageSecurityCheck;
- try {
- // 1. attempt to access a protected resource
- TestUtil.logTrace("Sending request \"" + modifiedPageSec + "\"");
- try {
- response = WebUtil.sendRequest("GET", InetAddress.getByName(hostname),
- portnum, tsurl.getRequest(modifiedPageSec), null, null);
- } catch (Exception ex) {
- // if here, problem as we should have been redirected
- TestUtil.logErr(
- "ERROR - got exception when trying to access restricted page w/out AuthN first.");
- ex.printStackTrace();
- throw new Exception("test15 failed.");
- }
-
- if (response != null) {
- // if we got directed to login page that is okay too
- TestUtil.logTrace("response.content=" + response.content);
-
- // 2. verify that the requested page was NOT accessed/found
- String searchString = "getAuthType()"; // this string appears on the
- // pageSec page
- if (response.content.indexOf(searchString) != -1) {
- // Error - it looks like we were able to access the requested page!
- String err = "Error - we were not authenticated but were able to access the ";
- err += "following page: " + modifiedPageSec
- + " with a return status = " + response.statusToken;
- TestUtil.logErr(err);
- TestUtil.logErr("response.content = " + response.content);
- throw new Exception("test15 failed.");
- } else {
- TestUtil.logTrace(
- "Good - we were not able to access restricted page without authenticating.");
- }
- } else {
- TestUtil.logTrace("response=null");
- }
-
- TestUtil.logMsg("test15 passed.");
-
- } catch (Exception e) {
- TestUtil.logErr("Caught exception: " + e.getMessage());
- e.printStackTrace();
- throw new Exception("test15 failed: ", e);
- }
- }
-
- /*
- * testName: test16
- *
- * @assertion: Test ability to login via the HttpServletRequst.login() method.
- * as specified in the Java Servlet Specification v3.1, Sec 13.3
- *
- * If user has not been authenticated and user attempts to access an
- * unprotected web resource, the user should be able to access it. Since the
- * user was not authenticated, calls to getUserPrincipal() should not return
- * the name of user "j2ee" since. Once in the servlet, we should be able to
- * invoke the HttpServletRequest.login() call to authenticate user "j2ee" and
- * then calls to getUserPrincipal() should return user "j2ee"
- *
- *
- * @test_Strategy: 1. Send request to access ServletProgrammaticLogin 2. the
- * servlet performs tasks and sends response data back 3. we parse the data to
- * see if we got desired output
- */
- public void test16() throws Exception {
- try {
-
- // Send request to ProgrammaticLogin servlet and include username
- // and password for use within servlet
- request = pageProgLogin;
-
- // set some params that will be needed from within the pageProgLogin
- // servlet
- Properties postData = new Properties();
- TestUtil.logTrace("setting request parameter my_username = " + username);
- TestUtil.logTrace("setting request parameter my_password = " + password);
- postData.setProperty("the_username", username);
- postData.setProperty("the_password", password);
-
- TestUtil.logMsg("Sending request " + request);
- response = WebUtil.sendRequest("POST", InetAddress.getByName(hostname),
- portnum, tsurl.getRequest(request), postData, cookies);
-
- TestUtil.logTrace("response.content = \n" + response.content);
-
- if (!response.statusToken.equals("200")) {
- TestUtil.logErr(
- "ERROR: not able to do Programmatic Login in: " + pageProgLogin);
- throw new Exception("test16 failed.");
- }
-
- // Check that we did not receive an error
- if (response.isError()) {
- TestUtil.logErr("Error retrieving " + request);
- throw new Exception("test16 failed.");
- }
-
- TestUtil.logTrace(response.content); // debug aid
-
- // verify there were no errors detected fom within our servlet
- String searchString = "ERROR - HttpServletRequest.login";
- if (response.content.indexOf(searchString) != -1) {
- TestUtil.logErr(response.content);
- throw new Exception("test16 failed.");
- }
-
- // verify that we got success
- searchString = "HttpServletRequest.login() passed";
- if (response.content.indexOf(searchString) == -1) {
- TestUtil.logErr(response.content);
- throw new Exception("test16 failed.");
- }
-
- TestUtil.logMsg("test16 passed.");
-
- } catch (Exception e) {
- TestUtil.logErr("Caught exception: " + e.getMessage());
- e.printStackTrace();
- throw new Exception("test16 failed: ", e);
- }
- }
-
- /*
- * testName: test17
- *
- * @assertion: Test FORM-based authentication, specified in the Java Servlet
- * Specification v2.2, Sec 11.5.3.
- *
- * If user has been authenticated and user attempts to access a protected web
- * resource, and user enters correct username and password of a user that is
- * authorized to access the resource, the resource is returned (similar to
- * test1)
- *
- * @test_Strategy: 1. Send request to access protected page (ie.
- * pageServletProgLogout) 2. Receive login page 3. Send form response with
- * username(j2ee) and password 4. Receive resource 5. make sure no ERRORs
- * occurrred on pageServletProgLogout and that it actually did log us out.
- *
- */
- public void test17() throws Exception {
- try {
- requestAndGetLoginPage(pageServletProgLogout, 1);
-
- // Send response to login form with session id cookie:
- request = pageSecurityCheck;
- TestUtil.logMsg(
- "Sending request \"" + request + "\" with login information.");
- Properties postData = new Properties();
- postData.setProperty("j_username", username);
- postData.setProperty("j_password", password);
- response = WebUtil.sendRequest("POST", InetAddress.getByName(hostname),
- portnum, tsurl.getRequest(request), postData, cookies);
-
- // Check that the page was found (no error).
- TestUtil.logTrace("response.content = " + response.content); // debug aid
- if (response.isError()) {
- TestUtil.logErr("Could not find " + request);
- throw new Exception("test17 failed.");
- }
-
- // Call followRedirect() to make sure we receive the required page
- response = followRedirect(response, 17);
- TestUtil.logTrace("response.content = " + response.content); // debug aid
-
- // Check to make sure we are authenticated by checking the page
- // content. It should contain the string below to indicate we
- // properly accessed the servlet.
- String searchString = "enterred ServletProgrammaticLogout.service()";
- if (response.content.indexOf(searchString) == -1) {
- String str = "Error - Did not get expected content from page: "
- + pageServletProgLogout;
- str += " Content should have contained: " + searchString;
- TestUtil.logErr(str);
- throw new Exception("test17 failed.");
- }
-
- // now make sure we didnt get any errors in our content
- String errString = "ERROR - HttpServletRequest.logout()";
- if (response.content.indexOf(errString) != -1) {
- // there was an error msg detected in servlet content
- String str = "Error - returned in content from page: "
- + pageServletProgLogout;
- TestUtil.logErr(str);
- throw new Exception("test17 failed.");
- }
- TestUtil.logMsg("test17 passed.");
-
- } catch (Exception e) {
- TestUtil.logErr("Caught exception: " + e.getMessage());
- e.printStackTrace();
- throw new Exception("test17 failed: ", e);
- }
- }
-
- /*
- * testName: test18
- *
- * @assertion: Test ability to authenticate using
- * HttpServletRequst.authenticate() as specified in the Java Servlet
- * Specification v3.1, Sec 13.3
- *
- * If user has not been authenticated and user attempts to access an
- * unprotected web resource, the user should be able to access it. Since the
- * user was not authenticated, calls to getUserPrincipal() should return null.
- * Calls to authenticate() should return false. Once in the servlet, we should
- * be able to invoke the HttpServletRequest.login() call to login with user
- * "j2ee" and then calls to getUserPrincipal() should return user "j2ee".
- * Calls to authenticate() should return true.
- *
- * @test_Strategy: 1. Send request to access ServletProgrammaticLogin 2. the
- * servlet performs tasks and sends response data back 3. we parse the data to
- * see if we got desired output
- */
- public void test18() throws Exception {
- try {
-
- // Send request to ProgrammaticLogin servlet and include username
- // and password for use within servlet
- request = pageProgAuthen;
-
- // set some params that will be needed from within the pageProgLogin
- // servlet
- Properties postData = new Properties();
- postData.setProperty("the_username", username);
- postData.setProperty("the_password", password);
-
- TestUtil.logMsg("Sending request " + request);
- response = WebUtil.sendRequest("POST", InetAddress.getByName(hostname),
- portnum, tsurl.getRequest(request), postData, cookies);
-
- // Call followRedirect() to make sure we receive the required page
- TestUtil.logTrace("YYYYY: response.content = \n" + response.content);
-
- if (!response.statusToken.equals("200")) {
- TestUtil.logErr(
- "ERROR: not able to do Programmatic Login in: " + pageProgLogin);
- throw new Exception("test18 failed.");
- }
-
- // Check that we did not receive an error
- if (response.isError()) {
- TestUtil.logErr("Error retrieving " + request);
- throw new Exception("test18 failed.");
- }
-
- // verify there were no errors detected fom within our servlet
- String searchString = "ERROR - HttpServletRequest.authenticate";
- if (response.content.indexOf(searchString) != -1) {
- TestUtil.logErr(response.content);
- throw new Exception("test18 failed.");
- }
-
- // now verify the authenticate truely passed
- if (response.content
- .indexOf("HttpServletRequest.authenticate passed") == -1) {
- TestUtil.logErr(response.content);
- throw new Exception("test18 failed.");
- }
-
- TestUtil.logMsg("test18 passed.");
-
- } catch (Exception e) {
- TestUtil.logErr("Caught exception: " + e.getMessage());
- e.printStackTrace();
- throw new Exception("test18 failed: ", e);
- }
- }
-
- /**
- * Uploads data from a byteArray to an URL. A WebUtil.Response object is
- * returned with the response information.
- *
- * @param method
- * http method "PUT"
- * @param addr
- * Address of web server
- * @param port
- * Port of web server
- * @param req
- * The file to request (e.g. /jsp_dep_secContextRoot/jspSec.jsp)
- * @param postData
- * is a byteArray which contains the data to be posted
- * @param cookieList
- * A list of cookies to send when requesting the page. null if no
- * cookie list is to be sent.
- * @param username
- * The username for authentication, null if no authentication
- * required.
- * @param password
- * The password for authentication, null if no authentication
- * required.
- * @return WebUtil.Response object containing response information
- * @exception IOException
- * Thrown if request could not be made
- */
- public static Response uploadUsingHttpMethodPUT(String method,
- InetAddress addr, int port, String req, byte[] postData,
- Hashtable cookieList, String username, String password)
- throws IOException {
- String protocol = "HTTP/1.0";
- URL requestURL;
- Socket socket = null;
- PrintWriter out = null;
- BufferedReader in = null;
- String line;
- Response response = new Response();
-
- try {
- requestURL = new URL("http", addr.getHostName(), port, req);
- req = method + " " + req + " " + protocol;
-
- socket = new Socket(addr, port);
-
- in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
- out = new PrintWriter(new OutputStreamWriter(socket.getOutputStream()));
- out.println(req);
-
- if (cookieList != null) {
- // Send cookies:
- Enumeration keys = cookieList.keys();
-
- // Does at least one cookie exist?
- if (keys.hasMoreElements()) {
- String cookieString = "Cookie: ";
-
- // Add each cookie to the string
- boolean first = true;
- while (keys.hasMoreElements()) {
- String key = (String) keys.nextElement();
- String value = (String) cookieList.get(key);
- cookieString += (first ? "" : "; ") + key + "=" + value; // + ";
- // $Path=/";
- first = false;
- }
-
- // Write cookies:
- out.println(cookieString);
- }
- }
-
- // Send authentication information if necessary:
- if (username != null) {
- String code = WebUtil.encodeBase64(username + ":" + password);
- out.println("Authorization: Basic " + code.trim());
- }
-
- // Send extra header information if we are posting.
- if (postData != null) {
- out.println("Content-type: text/data");
- }
-
- // Read the file contents from the byte array(postData)
- // and store it in a string(fileContents)
- StringBuffer content = new StringBuffer(1024);
- ByteArrayInputStream bais = new ByteArrayInputStream(postData);
- int c;
- while ((c = bais.read()) != -1) {
- content.append((char) c);
- }
- String fileContents = content.toString();
-
- // TestUtil.logMsg("File Content: "+ fileContents);
-
- // If this is a post request, send post data:
- if ((postData != null) && method.toUpperCase().equals("PUT")) {
- String postString = WebUtil.encodeBase64(fileContents);
-
- // Skip a line:
- out.println("Content-length: " + postString.length());
- out.println("");
- out.println(postString);
- } else {
- // Skip a line:
- out.println("");
- }
-
- out.flush();
-
- // Read first line and check for HTTP version and OK.
- line = in.readLine();
- if (line != null) {
-
- StringTokenizer st = new StringTokenizer(line.trim());
- response.versionToken = st.nextToken();
- response.statusToken = st.nextToken();
- }
-
- // Read each line of the header until we hit a blank line
- while ((line = in.readLine()) != null) {
-
- // Blank line means we are done with the header:
- if (line.trim().equals("")) {
- break;
- }
-
- // Analyze special tags location and set cookie
- if (line.toLowerCase().startsWith("location:")) {
- // This is a redirect. Extract valuable infomration:
- response.location = line.substring(10);
- } else if (line.toLowerCase().startsWith("set-cookie:")) {
- // This is a cookie. Add the cookie to the response
- // object.
- response.parseCookie(line);
- } else if (line.toLowerCase().startsWith("www-authenticate:")) {
- // Request to authenticate this page.
- response.authenticationRequested = true;
- }
- }
-
- // The rest is content:
- while ((line = in.readLine()) != null) {
- response.content += line + "\n";
- }
-
- in.close();
- out.close();
- } catch (MalformedURLException e) {
- throw new IOException("MalformedURLException: " + e.getMessage());
- } catch (UnknownHostException e) {
- throw new IOException("UnknownHostException: " + e.getMessage());
- } catch (ConnectException e) {
- throw new IOException("ConnectException: " + e.getMessage());
- }
-
- return response;
- }
-
- /**
- * Outputs a single line of text to the given output stream. Appends a \r\n
- * automatically. By adding a System.out.println here, you can easily echo
- * what is being sent to the web server.
- */
- private static void send(PrintWriter out, String s) {
- out.print(s + "\r\n");
- // if( debugOutputRequests ) {
- // System.out.println( "REQUEST: " + s );
- // }
- }
-
- /**
- * Helper method that is used in tests 1, 2 and 3. Performs the following
- * actions:
- *
- * 1. Send request to access passed in url 2. Receive redirect to login page,
- * extract location and session id cookie 3. Send request to access new
- * location, send cookie 4. Receive login page
- *
- * @param request
- * The initial page to request
- * @param testNum
- * The test number for correct display of error messages.
- */
- private void requestAndGetLoginPage(String request, int testNum)
- throws Exception {
- // Request restricted jsp page.
- TestUtil.logMsg("Sending request \"" + request + "\"");
- response = WebUtil.sendRequest("GET", InetAddress.getByName(hostname),
- portnum, tsurl.getRequest(request), null, null);
-
- // Check that the page was found (no error).
- if (response.isError()) {
- TestUtil.logErr("Could not find " + request);
- throw new Exception("test" + testNum + " failed.");
- }
-
- // if (response.statusToken=302)
- // then follow redirect to get the login page
-
- if (response.statusToken.equals("302")) {
- // We should receive a redirection to the login page:
- if (response.location == null) {
- TestUtil.logErr("No redirection to login page received.");
- throw new Exception("test" + testNum + " failed.");
- }
-
- // Extract location from redirection and format new request:
- request = WebUtil.getRequestFromURL(response.location);
- TestUtil.logMsg("Redirect to: " + response.location);
-
- // Extract cookies:
- cookies = response.cookies;
-
- TestUtil.logMsg("Before requesting redirected Page:" + "response.content="
- + response.content);
-
- // Request redirected page (login page):
- TestUtil.logMsg("Sending request \"" + request + "\"");
- response = WebUtil.sendRequest("GET", InetAddress.getByName(hostname),
- portnum, request, null, cookies);
-
- // Check that the page was found (no error).
- if (response.isError()) {
- TestUtil.logErr("Could not find " + request);
- throw new Exception("test" + testNum + " failed.");
- }
-
- } else {
- // Extract cookies:
- cookies = response.cookies;
- }
-
- // Because the authentication data is posted on the registered login form,
- // There is no need to compare login page here.
- /*
- * request = pageLogin;
- *
- * // Request login page TestUtil.logMsg( "Sending request \"" + request +
- * "\"" ); loginPageRequestResponse = WebUtil.sendRequest( "GET",
- * InetAddress.getByName( hostname ), portnum, tsurl.getRequest(request),
- * null, cookies );
- *
- * // Check that the page was found (no error). if(
- * loginPageRequestResponse.isError() ) { TestUtil.logErr( "Could not find "
- * + request ); throw new Exception( "test" + testNum + " failed." ); }
- *
- * //Compare the received login page with the expected login page // i.e
- * Check whether response.content ==loginPageRequestResponse.content if
- * (response.content.equals(loginPageRequestResponse.content))
- * TestUtil.logMsg("Received the expected login form"); else {
- * TestUtil.logMsg("response.conent\n"+response.content);
- * TestUtil.logMsg("loginPageRequestResponse.conent\n"+
- * loginPageRequestResponse.content);
- * TestUtil.logMsg("Received incorrect login form"); throw new Exception( "test"
- * + testNum + " failed." ); }
- */
-
- }
-
- /**
- * Helper method that is used in test 9. Performs the following actions:
- *
- * 1. Send request to access a jsp using testURL (for example testURL can be
- * "/*.jsp") 2. Checks the status of the http reply 3. If the page is not
- * accessible throw exception 4. If the page is accessible, then compare the
- * content from the testURL with the contents of exact match URL. i.e compare
- * 1) TEST URL : http://hostname:port/context_root/*.jsp 2) Exact match URL:
- * http://hostname:port/context_root/foo.jsp
- *
- * Note: Here *.jsp is mapped to foo.jsp
- *
- * If the contents are same then the mapping is correct, otherwise throw
- * exception
- *
- * @param testURL
- * The test URL (for example "/*.jsp")
- * @param testNum
- * The test number for correct display of error messages.
- * @param exactMatchURL
- * The exact match URL (for example "/foo.jsp")
- */
- private void compareURLContents(String testURL, int testNum,
- String exactMatchURL) throws Exception {
- // Request a jsp page using testURL.
- TestUtil.logMsg("Sending request \"" + testURL + "\"");
- response = WebUtil.sendRequest("GET", InetAddress.getByName(hostname),
- portnum, tsurl.getRequest(testURL), null, null);
-
- // Check that the page was found (no error).
- if (response.isError()) {
- TestUtil.logErr("Could not find " + testURL);
- throw new Exception("test" + testNum + " failed.");
- }
-
- WebUtil.Response response2 = null;
-
- // Request the jsp page using exactMatchURL.
- TestUtil.logMsg("Sending request \"" + exactMatchURL + "\"");
- response2 = WebUtil.sendRequest("GET", InetAddress.getByName(hostname),
- portnum, tsurl.getRequest(exactMatchURL), null, null);
-
- // Check that the page was found (no error).
- if (response.isError()) {
- TestUtil.logErr("Could not find " + exactMatchURL);
- throw new Exception("test" + testNum + " failed.");
- }
-
- TestUtil
- .logMsg("Comparing contents of " + testURL + " and " + exactMatchURL);
-
- // compare the contents of testURL and exactMatchURL
- if (!response.content.equals(response2.content)) {
- TestUtil.logErr(
- "MISMATCH in contents of " + testURL + " and " + exactMatchURL);
- TestUtil.logErr("contents of " + testURL);
- TestUtil.logErr(response.content);
- TestUtil.logErr("contents of " + exactMatchURL);
- TestUtil.logErr(response2.content);
- throw new Exception("test" + testNum + " failed.");
- } else {
- TestUtil.logMsg("Contents MATCH : correct URL mapping\n");
- }
-
- }
-
- /**
- * Helper method to check that isUserInRole is working correctly. Searches the
- * given page content for "isUserInRole( x ): !y!" for each x = key in
- * Hashtable and y = corresponding value in hashtable. If all results are as
- * expected, returns true, else returns false.
- */
- private boolean checkRoles(String content, Hashtable roleCheck) {
- Enumeration keys = roleCheck.keys();
- boolean pass = true;
-
- while (pass && keys.hasMoreElements()) {
- String key = (String) keys.nextElement();
- boolean expected = ((Boolean) roleCheck.get(key)).booleanValue();
-
- String search = "isUserInRole(\"" + key + "\"): !" + expected + "!";
- String logMsg = "Searching for \"" + search + "\": ";
-
- if (content.indexOf(search) == -1) {
- pass = false;
- logMsg += "NOT FOUND!";
- } else {
- logMsg += "found.";
- }
-
- TestUtil.logMsg(logMsg);
- }
-
- return pass;
- }
-
- public void cleanup() throws Exception {
- logMsg("cleanup");
- }
-
- /**
- * Helper method that is used in tests 1, 2, 3, 5 and 6. Performs the
- * following actions:
- *
- * 1. Checks whether the response.statusToken==302 or 301
- * if(response.statusToken==302) || (response.statusToken==301) send request
- * to redirected URL 2. Returns Response object
- *
- * @param response
- * The initial page response
- * @param testNum
- * The test number for correct display of error messages.
- */
- public WebUtil.Response followRedirect(WebUtil.Response response, int testNum)
- throws Exception {
-
- // if (response.statusToken=302)
- // send request to redirected URL
- if ((response.statusToken.equals("301"))
- || (response.statusToken.equals("302"))) {
- // We should receive a redirection page:
- if (response.location == null) {
- TestUtil.logErr("redirection URL : null");
- throw new Exception("test" + testNum + " failed.");
- }
-
- // Extract location from redirection and format new request:
- request = WebUtil.getRequestFromURL(response.location);
- TestUtil.logMsg("Redirect to: " + response.location);
-
- // update cookies if the webserver choose to send cookies,
- // immediately after a successful http post request.
- addNewCookies(cookies, response.cookies);
-
- // Request redirected page
- TestUtil.logMsg("Sending request \"" + request + "\"");
- response = WebUtil.sendRequest("GET", InetAddress.getByName(hostname),
- portnum, request, null, cookies);
-
- // After a succesful http post request,
- // Sun's Reference Implementation returns a redirected URL
- // (Note: No cookies are sent back to the client at this point)
- // Only when the client accesses the redirected URL,
- // Sun RI sends a cookie (single sign on cookie) back to
- // the client. So update cookies hashtable with new cookies
- addNewCookies(cookies, response.cookies);
-
- // Do not check for error code for testNum 7 and testNum 8
- // those test access an unauthorized resource and expect
- // error code.
- if (testNum != 7 && testNum != 8) {
- // Check that the page was found (no error).
- if (response.isError()) {
- TestUtil.logErr("Status Token " + response.statusToken);
- TestUtil.logErr("Could not find " + request);
- throw new Exception("test" + testNum + " failed.");
- }
- }
- } else {
- // After a successful post request, if a webserver
- // returns the webresource without redirecting to new URL
- // then update any new cookies received during this process.
- addNewCookies(cookies, response.cookies);
-
- }
-
- return response;
- }
-
- /**
- * Helper method that is used to update cookies
- *
- * This helper method retrieves cookies from "newCookies" hashtable and
- * updates it to "oldCookies" hashtable
- *
- * @param oldCookies
- * Hashtable containing original cookies
- * @param newCookies
- * Hashtable containing new cookies error messages.
- */
- public void addNewCookies(Hashtable oldCookies, Hashtable newCookies) {
- // Add new cookie/cookies to the existing cookies Hashtable
- for (Enumeration e = newCookies.keys(); e.hasMoreElements();) {
- // get cookie name
- String name = (String) e.nextElement();
-
- // get value for this name
- String value = (String) newCookies.get(name);
-
- if (oldCookies == null) {
- oldCookies = new Hashtable();
- }
-
- // Add this name value pair (cookie) to old cookies
- oldCookies.put(name.trim(), value.trim());
-
- }
- }
-
- /**
- * Get the HttpResponse, and check the status code to see if matches one of
- * the expected status codes.
- *
- * @param request-
- * @String request URL
- * @param expectedCodes
- * - @List<@String> status codes we will test for
- * @param testName
- * - The name calling test
- */
- private void testStatusCodes(String request, List expectedCodes,
- String testName) throws Exception {
-
- try {
- TestUtil.logMsg("Sending request \"" + request + "\"");
- response = WebUtil.sendRequest("GET", InetAddress.getByName(hostname),
- portnum, tsurl.getRequest(request), null, null);
-
- // Call followRedirect() to make sure we receive the required page
- response = followRedirect(response, 7);
-
- // Check status code(s).
- if (expectedCodes.contains(response.statusToken)) {
- TestUtil.logMsg("Status Token " + response.statusToken);
- TestUtil.logMsg("Received expected error code");
-
- } else {
- TestUtil.logErr("Did not receive expected error code" + request);
- TestUtil.logMsg("Status Token " + response.statusToken);
- TestUtil.logErr("Page content: ");
- TestUtil.logErr(response.content);
- throw new Exception(testName + " failed.");
- }
-
- } catch (Exception e) {
- TestUtil.logErr("Caught exception: " + e.getMessage());
- e.printStackTrace();
- throw new Exception(testName + " failed: ", e);
- }
-
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/taglibsig/AttributeEntry.java b/common/src/main/java/com/sun/ts/tests/common/taglibsig/AttributeEntry.java
deleted file mode 100644
index b2968dfc4f..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/taglibsig/AttributeEntry.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (c) 2007, 2018 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-/*
- * $URL$ $LastChangedDate$
- */
-
-package com.sun.ts.tests.common.taglibsig;
-
-public class AttributeEntry {
-
- public static final String NO_ATTRIBUTE_NAME = "no attribute name";
-
- private String name = NO_ATTRIBUTE_NAME;
-
- private String type = "java.lang.String";
-
- private String rtexpr = "false";
-
- private String required = "false";
-
- public AttributeEntry() {
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- if (name != null) {
- this.name = name;
- }
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- if (type != null) {
- this.type = type;
- }
- }
-
- public String getRtexpr() {
- return rtexpr;
- }
-
- public void setRtexpr(String rtexpr) {
- if (rtexpr != null) {
- this.rtexpr = rtexpr;
- }
- }
-
- public String getRequired() {
- return required;
- }
-
- public void setRequired(String required) {
- if (required != null) {
- this.required = required;
- }
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/taglibsig/TagEntry.java b/common/src/main/java/com/sun/ts/tests/common/taglibsig/TagEntry.java
deleted file mode 100644
index 7cca268d36..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/taglibsig/TagEntry.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-/*
- * $URL$ $LastChangedDate$
- */
-
-package com.sun.ts.tests.common.taglibsig;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-public class TagEntry {
-
- private static final AttributeEntry[] NO_DEFINED_ATTRIBUTES = {};
-
- private static final VariableEntry[] NO_DEFINED_VARIABLES = {};
-
- private static final String DEFAULT_BODY = "JSP";
-
- private Map attributes;
-
- private Map variables;
-
- private String name;
-
- private String body = DEFAULT_BODY;
-
- public TagEntry() {
- attributes = new HashMap();
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getBody() {
- return body;
- }
-
- public void setBody(String body) {
- if (body != null) {
- this.body = body;
- }
- }
-
- public void addVariable(VariableEntry entry) {
- variables.put(entry.getNameGiven(), entry);
- }
-
- public VariableEntry getVariable(String name) {
- return (VariableEntry) attributes.get(name);
- }
-
- public VariableEntry[] getVariables() {
- if (variables.isEmpty()) {
- return NO_DEFINED_VARIABLES;
- } else {
- List list = new ArrayList();
- for (Iterator i = variables.values().iterator(); i.hasNext();) {
- list.add(i.next());
- }
- return (VariableEntry[]) list.toArray(new VariableEntry[list.size()]);
- }
- }
-
- public void addAttribute(AttributeEntry entry) {
- attributes.put(entry.getName(), entry);
- }
-
- public AttributeEntry getAttribute(String name) {
- return (AttributeEntry) attributes.get(name);
- }
-
- public AttributeEntry[] getAttributes() {
- if (attributes.isEmpty()) {
- return NO_DEFINED_ATTRIBUTES;
- } else {
- List list = new ArrayList();
- for (Iterator i = attributes.values().iterator(); i.hasNext();) {
- list.add(i.next());
- }
- return (AttributeEntry[]) list.toArray(new AttributeEntry[list.size()]);
- }
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/taglibsig/TagLibraryComparitor.java b/common/src/main/java/com/sun/ts/tests/common/taglibsig/TagLibraryComparitor.java
deleted file mode 100644
index e3c864e392..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/taglibsig/TagLibraryComparitor.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $URL$ $LastChangedDate$
- */
-
-package com.sun.ts.tests.common.taglibsig;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import com.sun.ts.tests.common.taglibsig.validation.ValidationConfiguration;
-import com.sun.ts.tests.common.taglibsig.validation.Validator;
-import com.sun.ts.tests.common.taglibsig.validation.ValidatorFactory;
-
-/**
- * Provides the ability to compare two TagLibraryDescriptor objects and return
- * any differences found.
- */
-public class TagLibraryComparitor {
-
- // The current configuration for this TagLibraryComparitory.
- ValidationConfiguration configuration;
-
- /**
- *
- * Constructs a new TagLibraryComparitor that will use the provided
- * {@link ValidationConfiguration} to perform its comparison.
- *
- * Performs a comparison of two {@link TagLibraryDescriptor} objects using the
- * configured {@link ValidationConfiguration}.
- *
- * @param control
- * - the control TagLibraryDescriptor
- * @param underTest
- * - the TagLibraryDescriptor that we are validating for correctness
- * @return an empty array if no differences are found
- * @throws IllegalStateException
- * if the provided ValidationConfiguration is null, or has not be
- * configured.
- */
- public String[] compare(TagLibraryDescriptor control,
- TagLibraryDescriptor underTest) {
- List messages = new ArrayList();
-
- if (configuration != null && configuration.hasBeenConfigured()) {
- for (Iterator i = configuration.getValidatorNames(); i.hasNext();) {
- Validator validator = ValidatorFactory
- .getValidator(configuration.getValidatorClass((String) i.next()));
- if (validator != null) {
- messages.addAll(validator.validate(control, underTest));
- }
- }
- } else {
- throw new IllegalStateException("No Configuration Available...");
- }
- return (String[]) messages.toArray(new String[messages.size()]);
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/taglibsig/TagLibraryDescriptor.java b/common/src/main/java/com/sun/ts/tests/common/taglibsig/TagLibraryDescriptor.java
deleted file mode 100644
index f883dc88a5..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/taglibsig/TagLibraryDescriptor.java
+++ /dev/null
@@ -1,553 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-/*
- * $URL$ $LastChangedDate$
- */
-
-package com.sun.ts.tests.common.taglibsig;
-
-import java.io.CharArrayReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.JarURLConnection;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.List;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.EntityResolver;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-import com.sun.ts.lib.util.TestUtil;
-
-/**
- * Represents a TLD from a JAR file allowing access to the tag and function and
- * validator entries as well as TLD level metatdata such as support container
- * version and version of the taglibrary itself.
- */
-public class TagLibraryDescriptor {
-
- private static final String ONE_DOT_TWO_CONTAINER = "1.2";
-
- private static final String TWO_DOT_ZERO_CONTAINER = "2.0";
-
- private static final String DEFAULT_TAGLIB_VERSION = "1.0";
-
- private static final HashMap TAGLIB_CACHE = new HashMap();
-
- private static final TagEntry[] EMPTY_TAG_ENTRIES = {};
-
- private static final FunctionEntry[] EMPTY_FUNCTION_ENTRIES = {};
-
- private static final ValidatorEntry[] EMPTY_VALIDATOR_ENTRIES = {};
-
- private String _containerVersion = ONE_DOT_TWO_CONTAINER;
-
- private String _taglibVersion = DEFAULT_TAGLIB_VERSION;
-
- private String _uri;
-
- private List _tagEntries;
-
- private List _functionEntries;
-
- private List _validatorEntries;
-
- // Private
- private TagLibraryDescriptor() {
- }
-
- /**
- * Returns a TagLibraryDescriptor instance based on the URI the tag library is
- * known by (i.e. the element of the TLD). If the TagLibraryDescriptor
- * is not found in the cache, the this method will use the URL to the jar file
- * and scan the JAR file for TLDs. Any TLD's found will be processed and added
- * cache. If, after scanning the JAR file, no TLD's matching the specified
- * ttaglib uri can be found, this method will return null.
- *
- * @param jarUrl
- * - The file URL of the JAR file to scan for TLDs if the cache
- * doesn't contain the requested TagLibraryDescriptor instance
- * @param taglibUri
- * - The uri of the tag library of interest
- * @return a TagLibraryDescriptor for the provided uri, or null if no tag
- * library can be found
- */
- public static TagLibraryDescriptor getInstance(String jarUrl,
- String taglibUri) {
- TagLibraryDescriptor tld = (TagLibraryDescriptor) TAGLIB_CACHE
- .get(taglibUri);
- if (tld == null) {
- URL url = null;
- jarUrl = "jar:" + jarUrl + "!/";
- try {
- url = new URL(jarUrl);
- } catch (MalformedURLException e) {
- TestUtil.logErr("Malformed URL: " + jarUrl, e);
- }
-
- // Begin constructing the cache...
- TestUtil.logTrace("<<<<<>>>>>");
- try {
- TldBuilder builder = new TldBuilder(new TldLocator(url));
- builder.build();
- } catch (BuildException be) {
- TestUtil.logErr(be.getMessage(), be);
- }
-
- tld = (TagLibraryDescriptor) TAGLIB_CACHE.get(taglibUri);
- }
- return tld;
- }
-
- /**
- * Returns the tags of this tag library.
- *
- * @return the tags of this tag library
- */
- public TagEntry[] getTagEntries() {
- if (_tagEntries == null || _tagEntries.isEmpty()) {
- return EMPTY_TAG_ENTRIES;
- } else {
- return (TagEntry[]) _tagEntries.toArray(new TagEntry[_tagEntries.size()]);
- }
- }
-
- /**
- * Returns the functions of this tag library.
- *
- * @return the functions of this tag library
- */
- public FunctionEntry[] getFunctionEntries() {
- if (_functionEntries == null || _functionEntries.isEmpty()) {
- return EMPTY_FUNCTION_ENTRIES;
- } else {
- return (FunctionEntry[]) _functionEntries
- .toArray(new FunctionEntry[_functionEntries.size()]);
- }
- }
-
- /**
- * The validators of this tag library.
- *
- * @return the validators of this tag library
- */
- public ValidatorEntry[] getValidatorEntries() {
- if (_validatorEntries == null || _validatorEntries.isEmpty()) {
- return EMPTY_VALIDATOR_ENTRIES;
- } else {
- return (ValidatorEntry[]) _validatorEntries
- .toArray(new ValidatorEntry[_validatorEntries.size()]);
- }
- }
-
- /**
- * Returns the minimum container version required to use this tag libary.
- *
- * @return the minimum container version required to use this tag library
- */
- public String getRequiredContainerVersion() {
- return this._containerVersion;
- }
-
- /**
- * Returns the version of this tag library.
- *
- * @return the version of this tag library
- */
- public String getTaglibraryVersion() {
- return this._taglibVersion;
- }
-
- /**
- * Returns the URI that identifies this tag library
- *
- * @return the URI that identifies this tag library
- */
- public String getURI() {
- return this._uri;
- }
-
- /**
- * Adds a TagEntry to the internal list of tags
- *
- * @param entry
- * - a TagEntry
- */
- private void addTagEntry(TagEntry entry) {
- if (_tagEntries == null)
- _tagEntries = new ArrayList();
- _tagEntries.add(entry);
- }
-
- /**
- * Adds a FunctionEntry to the internal list of functions
- *
- * @param entry
- * - a FunctionEntry
- */
- private void addFunctionEntry(FunctionEntry entry) {
- if (_functionEntries == null)
- _functionEntries = new ArrayList();
- _functionEntries.add(entry);
- }
-
- /**
- * Adds a ValidatorEntry to the internal list of validators.
- *
- * @param entry
- * - a ValidatorEntry
- */
- private void addValidatorEntry(ValidatorEntry entry) {
- if (_validatorEntries == null)
- _validatorEntries = new ArrayList();
- _validatorEntries.add(entry);
- }
-
- /**
- * Sets the required container version for this tag library.
- *
- * @param version
- * - required container version
- */
- private void setRequiredContainerVersion(String version) {
- _containerVersion = version;
- }
-
- /**
- * Sets the version of this tag library
- *
- * @param version
- * - tag library version
- */
- private void setTaglibraryVersion(String version) {
- _taglibVersion = version;
- }
-
- /**
- * Sets the URI of this tag library
- *
- * @param uri
- * - the URI of this tag library
- */
- private void setURI(String uri) {
- _uri = uri;
- }
-
- // ======================================== Inner Classes
- // =====================
-
- /**
- * Utility class to encapsulate all XML related functionality in creating
- * TagLibraryDescriptor objects.
- */
- private static class TldBuilder {
-
- /**
- * Elements that are of interest in a Tag Library Descriptor.
- */
- private static final String TLIB_VERSION_ELEMENT = "tlib-version";
-
- private static final String JSP_VERSION_ELEMENT = "jsp-version";
-
- private static final String VALIDATOR_ELEMENT = "validator";
-
- private static final String FUNCTION_ELEMENT = "function";
-
- private static final String TAG_ELEMENT = "tag";
-
- private static final String NAME_ELEMENT = "name";
-
- private static final String ATTRIBUTE_ELEMENT = "attribute";
-
- private static final String TYPE_ELEMENT = "type";
-
- private static final String VARIABLE_ELEMENT = "variable";
-
- private static final String BODY_ELEMENT = "body-content";
-
- private static final String URI_ELEMENT = "uri";
-
- private static final String RTEXPR_ELEMENT = "rtexprvalue";
-
- private static final String REQUIRED_ELEMENT = "required";
-
- private static final String NAME_GIVEN_ELEMENT = "name-given";
-
- private static final String SCOPE_ELEMENT = "scope";
-
- private static final String DECLARE_ELEMENT = "declare";
-
- private static final String VARIABLE_CLASS_ELEMENT = "variable-class";
-
- private static final String FUNCTION_SIGNATURE_ELEMENT = "function-signature";
-
- /**
- * The TldLocator used to obtain input streams to the TLD's.
- */
- TldLocator _locator;
-
- /**
- * Creates a new TldBuilder instance.
- *
- * @param locator
- * - the TldLocator to get InputStreams from
- */
- public TldBuilder(TldLocator locator) {
- _locator = locator;
- }
-
- /**
- * Builds TagLibraryDescriptor objects based off all TLD's that contain URI
- * elements.
- *
- * @throws BuildException
- * if an error occurs during processing.
- */
- public void build() throws BuildException {
- try {
- processTlds(_locator.getTldsAsStreams());
- } catch (Throwable t) {
- throw new BuildException(
- "Unexpected Exception building TLDs: " + t.toString());
- }
- }
-
- /**
- * Utility method to setup and return a DocumentBuilder for XML parsing.
- *
- * @return - DocumentBuilder instance
- */
- private DocumentBuilder getDocumentBuilder() {
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- factory.setExpandEntityReferences(false);
- factory.setNamespaceAware(false);
- factory.setValidating(false);
- DocumentBuilder builder = null;
- try {
- builder = factory.newDocumentBuilder();
- } catch (ParserConfigurationException e) {
- TestUtil.logErr(e.getMessage(), e);
- }
- return builder;
- }
-
- /**
- * Parses the provided Document object (created from a TLD), and constructs
- * logical TagLibraryDescriptor instances from the information contained
- * within the Document.
- *
- * @param doc
- * - Document object representing a TLD
- */
- private void processDocument(Document doc) {
- TagLibraryDescriptor tld = new TagLibraryDescriptor();
- Element taglib = doc.getDocumentElement();
-
- processTopLevelElements(taglib, tld);
-
- processTagEntries(taglib.getElementsByTagName(TAG_ELEMENT), tld);
- processFunctionEntries(taglib.getElementsByTagName(FUNCTION_ELEMENT),
- tld);
- }
-
- private void processTopLevelElements(Element taglib,
- TagLibraryDescriptor des) {
-
- des.setTaglibraryVersion(getNodeText(taglib, TLIB_VERSION_ELEMENT));
- des.setRequiredContainerVersion(getNodeText(taglib, JSP_VERSION_ELEMENT));
- String uri = getNodeText(taglib, URI_ELEMENT);
- des.setURI(uri);
- addCacheEntry(uri, des);
- }
-
- private void processFunctionEntries(NodeList functionNodes,
- TagLibraryDescriptor des) {
- for (int i = 0, size = functionNodes.getLength(); i < size; i++) {
- Element functionElement = (Element) functionNodes.item(i);
- FunctionEntry funcEntry = new FunctionEntry();
- funcEntry.setName(getNodeText(functionElement, NAME_ELEMENT));
- funcEntry.setFunctionSignature(
- getNodeText(functionElement, FUNCTION_SIGNATURE_ELEMENT));
- }
- }
-
- private void processTagEntries(NodeList tagNodes,
- TagLibraryDescriptor des) {
- for (int i = 0, size = tagNodes.getLength(); i < size; i++) {
- Element tagElement = (Element) tagNodes.item(i);
- TagEntry tagEntry = new TagEntry();
- tagEntry.setName(getNodeText(tagElement, NAME_ELEMENT));
- tagEntry.setBody(getNodeText(tagElement, BODY_ELEMENT));
-
- processTagAttributes(tagElement.getElementsByTagName(ATTRIBUTE_ELEMENT),
- tagEntry);
-
- processTagVariables(tagElement.getElementsByTagName(VARIABLE_ELEMENT),
- tagEntry);
-
- des.addTagEntry(tagEntry);
- }
-
- }
-
- private void processTagAttributes(NodeList attrNodes, TagEntry tag) {
- for (int i = 0, size = attrNodes.getLength(); i < size; i++) {
- Element attrElement = (Element) attrNodes.item(i);
- AttributeEntry attrEntry = new AttributeEntry();
- attrEntry.setName(getNodeText(attrElement, NAME_ELEMENT));
- attrEntry.setType(getNodeText(attrElement, TYPE_ELEMENT));
- attrEntry.setRtexpr(getNodeText(attrElement, RTEXPR_ELEMENT));
- attrEntry.setRequired(getNodeText(attrElement, REQUIRED_ELEMENT));
- tag.addAttribute(attrEntry);
- }
- }
-
- private void processTagVariables(NodeList varNodes, TagEntry tag) {
- for (int i = 0, size = varNodes.getLength(); i < size; i++) {
- Element varElement = (Element) varNodes.item(i);
- VariableEntry varEntry = new VariableEntry();
- varEntry.setNameGiven(getNodeText(varElement, NAME_GIVEN_ELEMENT));
- varEntry
- .setVariableClass(getNodeText(varElement, VARIABLE_CLASS_ELEMENT));
- varEntry.setScope(getNodeText(varElement, SCOPE_ELEMENT));
- varEntry.setDeclare(getNodeText(varElement, DECLARE_ELEMENT));
- tag.addVariable(varEntry);
- }
- }
-
- private String getNodeText(Element parent, String nodeName) {
- String nodeText = null;
- NodeList list = parent.getElementsByTagName(nodeName);
-
- for (int i = 0, size = list.getLength(); i < size; i++) {
- Node node = list.item(0).getFirstChild();
- if (node.getNodeType() == Node.TEXT_NODE) {
- nodeText = node.getNodeValue();
- break;
- }
- }
-
- return nodeText;
- }
-
- private void addCacheEntry(String key, Object value) {
- TAGLIB_CACHE.put(key, value);
- }
-
- /**
- * Sequentially processes the array of InputStreams, where each input stream
- * represents a TLD.
- *
- * @param inStreams
- * - array of input streams representing one or more TLDs
- * @throws SAXException
- * - if an unexpected parsing error occurs
- * @throws IOException
- * - if an unexpected IO error occurs
- */
- private void processTlds(InputStream[] inStreams)
- throws SAXException, IOException {
- DocumentBuilder builder = getDocumentBuilder();
- builder.setEntityResolver(new EntityResolver() {
- public InputSource resolveEntity(String publicId, String systemId)
- throws SAXException, IOException {
- return new InputSource(new CharArrayReader(new char[0]));
- }
- });
-
- for (int i = 0; i < inStreams.length; i++) {
- Document doc = builder.parse(inStreams[i]);
- processDocument(doc);
- }
- }
-
- }
-
- /**
- * Processes the JAR file as identified by the provided URL. Create new
- * TagLibraryDescriptor instances based on the any TLD's found.
- */
- private static class TldLocator {
-
- /**
- * The META-INF directory of the target JAR URL.
- */
- private static final String META_INF = "META-INF/";
-
- /**
- * The file extension of Tag Library Descriptor files.
- */
- private static final String TLD_EXTENSION = ".tld";
-
- /**
- * The URL of the JAR file.
- */
- private URL _url;
-
- /**
- * Creates a new TldLocator instance.
- *
- * @param url
- * - the JAR url to use in scanning for TLDs
- */
- public TldLocator(URL url) {
- _url = url;
- }
-
- /**
- * Scans the JAR file idetified by the provided URL. For each TLD found an
- * InputStream will be created for processing.
- *
- * @return - array of InputStreams representing TLDs found in the JAR
- * @throws IOException
- * - if an unexpected I/O error occurs
- */
- public InputStream[] getTldsAsStreams() throws IOException {
- JarURLConnection jarCon = (JarURLConnection) _url.openConnection();
- JarFile jar = jarCon.getJarFile();
- List inputStreams = new ArrayList();
- for (Enumeration e = jar.entries(); e.hasMoreElements();) {
- JarEntry entry = (JarEntry) e.nextElement();
- String name = entry.getName();
- if (!name.startsWith(META_INF) || !name.endsWith(TLD_EXTENSION)) {
- continue;
- }
- inputStreams.add(jar.getInputStream(entry));
- }
- return (InputStream[]) inputStreams
- .toArray(new InputStream[inputStreams.size()]);
- }
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/taglibsig/Test.java b/common/src/main/java/com/sun/ts/tests/common/taglibsig/Test.java
deleted file mode 100644
index 1f469a26e4..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/taglibsig/Test.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (c) 2007, 2018 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $URL$ $LastChangedDate$
- */
-
-package com.sun.ts.tests.common.taglibsig;
-
-import com.sun.ts.tests.common.taglibsig.validation.ValidationConfiguration;
-
-public class Test {
-
- public Test() {
- }
-
- public static void main(String[] args) {
- TagLibraryDescriptor tld = TagLibraryDescriptor.getInstance(
- "file:///files/projects/jakarta-taglibs/dist/standard/lib/standard.jar",
- "http://java.sun.com/jstl/core_rt");
-
- System.out.println();
- if (tld != null) {
- System.out.println("URI: " + tld.getURI());
- System.out.println("TAGLIB VERSION: " + tld.getTaglibraryVersion());
- System.out
- .println("CONTAINER VERSION: " + tld.getRequiredContainerVersion());
- TagEntry[] tagEntries = tld.getTagEntries();
- for (int i = 0; i < tagEntries.length; i++) {
- System.out.println("TAG NAME: " + tagEntries[i].getName());
- System.out.println("TAG BODY: " + tagEntries[i].getBody());
- AttributeEntry[] attrs = tagEntries[i].getAttributes();
- for (int j = 0; j < attrs.length; j++) {
- System.out.println("ATTRIBUTE NAME: " + attrs[j].getName());
- System.out.println("ATTRIBUTE TYPE: " + attrs[j].getType());
- System.out.println("ATTRIBUTE REQ: " + attrs[j].getRequired());
- System.out.println("ATTRIBUTE RTEXPR: " + attrs[j].getRtexpr());
- }
- }
- } else {
- System.out.println("OOOPPS");
- }
-
- TagLibraryDescriptor tld2 = TagLibraryDescriptor.getInstance(
- "file:///files/nightly/jstl/lib/standard.jar",
- "http://java.sun.com/jstl/fmt");
-
- System.out.println();
- if (tld2 != null) {
- System.out.println("URI: " + tld2.getURI());
- System.out.println("TAGLIB VERSION: " + tld2.getTaglibraryVersion());
- System.out
- .println("CONTAINER VERSION: " + tld2.getRequiredContainerVersion());
- TagEntry[] tagEntries = tld2.getTagEntries();
- for (int i = 0; i < tagEntries.length; i++) {
- System.out.println("TAG NAME: " + tagEntries[i].getName());
- System.out.println("TAG BODY: " + tagEntries[i].getBody());
- AttributeEntry[] attrs = tagEntries[i].getAttributes();
- for (int j = 0; j < attrs.length; j++) {
- System.out.println("ATTRIBUTE NAME: " + attrs[j].getName());
- System.out.println("ATTRIBUTE TYPE: " + attrs[j].getType());
- System.out.println("ATTRIBUTE REQ: " + attrs[j].getRequired());
- System.out.println("ATTRIBUTE RTEXPR: " + attrs[j].getRtexpr());
- }
- }
- } else {
- System.out.println("OOOPPS");
- }
-
- ValidationConfiguration configuration = new ValidationConfiguration();
- configuration.addValidator(ValidationConfiguration.URI_VALIDATOR);
-
- TagLibraryComparitor comparitor = new TagLibraryComparitor(configuration);
- String[] messages = comparitor.compare(tld, tld2);
- if (messages.length == 0) {
- System.out.println("EQUAL");
- } else {
- for (int i = 0; i < messages.length; i++) {
- System.out.println("ERRORS\n==================");
- System.out.println(messages[i]);
- }
- }
-
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/taglibsig/VariableEntry.java b/common/src/main/java/com/sun/ts/tests/common/taglibsig/VariableEntry.java
deleted file mode 100644
index 926442fe19..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/taglibsig/VariableEntry.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (c) 2007, 2018 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-/*
- * $URL$ $LastChangedDate$
- */
-
-package com.sun.ts.tests.common.taglibsig;
-
-public class VariableEntry {
-
- public static final String NO_VARIABLE_NAME = "no variable name";
-
- private String nameGiven = NO_VARIABLE_NAME;
-
- private String declare = "false";
-
- private String variableClass = "java.lang.String";
-
- private String scope = "AT_BEGIN";
-
- public VariableEntry() {
- }
-
- public String getNameGiven() {
- return nameGiven;
- }
-
- public void setNameGiven(String nameGiven) {
- if (nameGiven != null) {
- this.nameGiven = nameGiven;
- }
- }
-
- public String getDeclare() {
- return declare;
- }
-
- public void setDeclare(String declare) {
- if (declare != null) {
- this.declare = declare;
- }
- }
-
- public String getVariableClass() {
- return variableClass;
- }
-
- public void setVariableClass(String variableClass) {
- if (variableClass != null) {
- this.variableClass = variableClass;
- }
- }
-
- public String getScope() {
- return scope;
- }
-
- public void setScope(String scope) {
- if (scope != null) {
- this.scope = scope;
- }
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/taglibsig/validation/ValidationConfiguration.java b/common/src/main/java/com/sun/ts/tests/common/taglibsig/validation/ValidationConfiguration.java
deleted file mode 100644
index 6b5badf83b..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/taglibsig/validation/ValidationConfiguration.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Copyright (c) 2007, 2018 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $URL$ $LastChangedDate$
- */
-
-package com.sun.ts.tests.common.taglibsig.validation;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-/**
- * This configuration class defines the {@link Validator} names that will be
- * used to perform the validation of the TaglibraryDescriptor objects. This
- * class is used exclusively by the {@link ValidatorFactory}, which will take
- * the names contained within and create {@link Validator} instances.
- */
-
-public class ValidationConfiguration {
-
- /*
- * All standard Validators will be listed here.
- */
- public static final String URI_VALIDATOR = "URIValidator";
-
- /*
- * Package name for standard validator implementations.
- */
- private static final String VALIDATOR_PACKAGE = "com.sun.ts.tests.common.taglibsig.validation.";
-
- /*
- * All standard validators will be stored in here as well. This is used by the
- * initValidators() method.
- */
- private static final String[] VALIDATORS = { URI_VALIDATOR };
-
- /*
- * Map of all Validator's and their implementing class.
- */
- private static final Map KNOWN_VALIDATORS = new HashMap();
-
- static {
- // init the standard validator map
- initValidators();
- }
-
- /*
- * Map containing the Validators the end-user is interested in.
- */
- private Map configuredValidatorMap;
-
- /**
- * Constructs a new ValidationConfiguation instance.
- */
- public ValidationConfiguration() {
- configuredValidatorMap = new HashMap();
- }
-
- /**
- *
- * Adds the name of a {@link Validator} implementation to this configuration.
- * The name must be a known name (i.e. be a constant name defined by this
- * class), or a {@link Validator} will not be added. If a non-standard
- * validator is required, use addValidator(String, String)
- * instead.
- *
- * Returns an Iterator of the {@link Validator} names in the current
- * configuration.
- *
- *
- * @return Iterator of this configuration's {@link Validator} names
- */
- public Iterator getValidatorNames() {
- return configuredValidatorMap.keySet().iterator();
- }
-
- /**
- *
- * Returns the name of the {@link Validator} implementation class.
- *
- *
- * @param validatorName
- * - Validator name
- * @return The name of the {@link Validator} implementation class.
- */
- public String getValidatorClass(String validatorName) {
- return (String) configuredValidatorMap.get(validatorName);
- }
-
- /**
- *
- * True if {@link Validator} names have been added to the current
- * configuration, otherwise false.
- *
- *
- * @return True if {@link Validator} names have been added to the current
- * configuration, otherwise false.
- */
- public boolean hasBeenConfigured() {
- if (configuredValidatorMap.size() > 0)
- return true;
- return false;
- }
-
- // Initialize all standard validators.
- private static void initValidators() {
- for (int i = 0; i < VALIDATORS.length; i++) {
- KNOWN_VALIDATORS.put(VALIDATORS[i], VALIDATOR_PACKAGE + VALIDATORS[i]);
- }
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/testlogic/ejb/bb/argsemantics/TestLogic.java b/common/src/main/java/com/sun/ts/tests/common/testlogic/ejb/bb/argsemantics/TestLogic.java
deleted file mode 100644
index 9312ac6018..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/testlogic/ejb/bb/argsemantics/TestLogic.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Copyright (c) 2007, 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.testlogic.ejb.bb.argsemantics;
-
-import java.util.Properties;
-
-import com.sun.ts.lib.util.TSNamingContext;
-import com.sun.ts.lib.util.TestUtil;
-import com.sun.ts.tests.common.ejb.calleebeans.SimpleArgument;
-import com.sun.ts.tests.common.ejb.calleebeans.StatefulCallee;
-import com.sun.ts.tests.common.ejb.calleebeans.StatefulCalleeHome;
-import com.sun.ts.tests.common.ejb.calleebeans.StatefulCalleeLocal;
-import com.sun.ts.tests.common.ejb.calleebeans.StatefulCalleeLocalHome;
-
-public class TestLogic {
-
- /*
- * Names used for Callee beans lookups.
- */
- public static final String prefix = "java:comp/env/";
-
- public static final String statefulRemoteLookup = prefix
- + "ejb/StatefulCalleeRemote";
-
- public static final String statefulLocalLookup = prefix
- + "ejb/StatefulCalleeLocal";
-
- public static final String statefulBiRemoteLookup = prefix
- + "ejb/StatefulCalleeBothRemote";
-
- public static final String statefulBiLocalLookup = prefix
- + "ejb/StatefulCalleeBothLocal";
-
- /*
- * Expected values for our custom argument.
- */
- public static final int initialValue = 12;
-
- public static final int modifiedValue = 24;
-
- public static final int modifiedValue2 = 48;
-
- private static StatefulCallee ssfCalleeBean = null;
-
- private static StatefulCalleeLocal ssfCalleeLocalBean = null;
-
- public static boolean testStatefulRemote(TSNamingContext nctx,
- Properties props) {
-
- return testStatefulRemote(statefulRemoteLookup, nctx, props);
- }
-
- public static boolean testStatefulLocal(TSNamingContext nctx,
- Properties props) {
-
- return testStatefulLocal(statefulLocalLookup, nctx, props);
- }
-
- public static boolean testStatefulBoth(TSNamingContext nctx,
- Properties props) {
-
- boolean pass;
-
- pass = testStatefulRemote(statefulBiRemoteLookup, nctx, props);
- pass &= testStatefulLocal(statefulBiLocalLookup, nctx, props);
-
- return pass;
- }
-
- protected static boolean testStatefulRemote(String lookupName,
- TSNamingContext nctx, Properties props) {
-
- StatefulCalleeHome home;
- ssfCalleeBean = null;
- SimpleArgument arg;
- boolean pass;
-
- try {
- arg = new SimpleArgument(initialValue);
- TestUtil.logTrace("[TestLogic] Initial value is " + arg.getValue());
-
- TestUtil.logTrace("[TestLogic] Looking up Callee " + lookupName + " ...");
- home = (StatefulCalleeHome) nctx.lookup(lookupName,
- StatefulCalleeHome.class);
-
- ssfCalleeBean = home.create(props, arg);
- TestUtil.logTrace("[TestLogic] Value after create is " + arg.getValue());
-
- ssfCalleeBean.call(props, arg);
- TestUtil.logTrace(
- "[TestLogic] Value after business " + "method is " + arg.getValue());
-
- pass = (arg.getValue() == initialValue);
- if (!pass) {
- TestUtil.logErr(
- "[TestLogic] Argument has been " + "modified to " + arg.getValue());
- }
- } catch (Exception e) {
- pass = false;
- TestUtil.logErr("[TestLogic] Unexpected exception", e);
- }
-
- return pass;
- }
-
- protected static boolean testStatefulLocal(String lookupName,
- TSNamingContext nctx, Properties props) {
-
- StatefulCalleeLocalHome home;
- ssfCalleeLocalBean = null;
- SimpleArgument arg;
- String msg;
- boolean pass;
-
- try {
- arg = new SimpleArgument(initialValue);
- TestUtil.logTrace("[TestLogic] Initial value is " + arg.getValue());
-
- TestUtil.logTrace("[TestLogic] Looking up Callee " + lookupName + " ...");
- home = (StatefulCalleeLocalHome) nctx.lookup(lookupName);
-
- ssfCalleeLocalBean = home.create(props, arg);
- TestUtil.logTrace("[TestLogic] Value after create is " + arg.getValue());
- pass = (arg.getValue() == modifiedValue);
- if (!pass) {
- msg = "Expected Argument to be set to " + modifiedValue;
- TestUtil.logErr("[TestLogic] " + msg);
- throw new Exception(msg);
- }
-
- ssfCalleeLocalBean.call(props, arg);
- TestUtil.logTrace(
- "[TestLogic] Value after business " + "method is " + arg.getValue());
-
- pass = (arg.getValue() == modifiedValue2);
- if (!pass) {
- TestUtil.logErr("[TestLogic] Expected argument to be " + "set to "
- + modifiedValue2);
- }
- } catch (Exception e) {
- pass = false;
- TestUtil.logErr("[TestLogic] Unexpected exception", e);
- }
-
- return pass;
- }
-
- public static void cleanUpStatefulBean() {
- TestUtil.logTrace("cleanUpStatefulBean");
- try {
- if (ssfCalleeBean != null) {
- TestUtil.logTrace("cleanUp Session Stateful Remote Callee Bean");
- ssfCalleeBean.remove();
- ssfCalleeBean = null;
- }
-
- if (ssfCalleeLocalBean != null) {
- TestUtil.logTrace("cleanUp Session Stateful Local Callee Bean");
- ssfCalleeLocalBean.remove();
- ssfCalleeLocalBean = null;
- }
- } catch (Exception e) {
- TestUtil.logErr(
- "Exception caught trying to remove Stateful Session beans", e);
- }
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/vehicle/EmptyVehicleRunner.java b/common/src/main/java/com/sun/ts/tests/common/vehicle/EmptyVehicleRunner.java
deleted file mode 100644
index b8a029f770..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/vehicle/EmptyVehicleRunner.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.vehicle;
-
-import java.util.Properties;
-
-import com.sun.ts.lib.harness.Status;
-import com.sun.ts.lib.harness.ServiceEETest;
-import com.sun.ts.lib.util.TestUtil;
-
-public class EmptyVehicleRunner implements VehicleRunnable {
-
- public Status run(String[] argv, Properties p) {
-
- ServiceEETest theTestClient;
- Status sTestStatus = Status.passed("");
-
- // create an instance of the test client and run here
- try {
- String testClassName = TestUtil.getProperty(p, "test_classname");
- Class c = Class.forName(testClassName);
- theTestClient = (ServiceEETest) c.newInstance();
- theTestClient.setSharedObject(VehicleClient.getClientSharedObject());
- sTestStatus = theTestClient.run(argv, p);
- } catch (ClassNotFoundException cnfe) {
- TestUtil.logErr("Failed to create the EETest instance", cnfe);
- sTestStatus = Status.failed("Failed to create the EETest instance");
- } catch (InstantiationException ie) {
- TestUtil.logErr("Failed to create the EETest instance", ie);
- sTestStatus = Status.failed("Failed to create the EETest instance");
- } catch (Exception e) {
- TestUtil.logErr("Failed running in a client side vehicle", e);
- sTestStatus = Status.failed("Failed running in a client side vehicle");
- }
-
- return sTestStatus;
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/vehicle/VehicleRunnerFactory.java b/common/src/main/java/com/sun/ts/tests/common/vehicle/VehicleRunnerFactory.java
deleted file mode 100644
index 6e96fc1f6e..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/vehicle/VehicleRunnerFactory.java
+++ /dev/null
@@ -1,354 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.vehicle;
-
-import java.lang.System.Logger;
-
-public final class VehicleRunnerFactory {
-
- private static final Logger logger = System.getLogger(VehicleRunnerFactory.class.getName());
-
- private static VehicleRunnable ejbRunner;
-
- private static VehicleRunnable servletRunner;
-
- private static VehicleRunnable jspRunner;
-
- private static VehicleRunnable ejbLiteJsfRunner;
-
- private static VehicleRunnable ejbLiteJspRunner;
-
- private static VehicleRunnable ejbLiteSecuredJspRunner;
-
- private static VehicleRunnable emptyRunner;
-
- private static VehicleRunnable stateless3Runner;
-
- private static VehicleRunnable stateful3Runner;
-
- private static VehicleRunnable appmanagedRunner;
-
- private static VehicleRunnable appmanagedNoTxRunner;
-
- private static VehicleRunnable wsejbRunner;
-
- private static VehicleRunnable wsservletRunner;
-
- private static VehicleRunnable pmservletRunner;
-
- private static VehicleRunnable puservletRunner;
-
- private static VehicleRunnable connectorServletRunner;
-
- private static VehicleRunnable customVehicleRunner;
-
- private static VehicleRunnable webRunner;
-
- private VehicleRunnerFactory() {
- }
-
- private static VehicleRunnable getEJBRunner() {
- if (ejbRunner == null) {
- try {
- Class c = Class
- .forName("com.sun.ts.tests.common.vehicle.ejb.EJBVehicleRunner");
- ejbRunner = (VehicleRunnable) c.newInstance();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- return ejbRunner;
- }
-
- private static VehicleRunnable getServletRunner() {
- if (servletRunner == null) {
- try {
- Class c = Class.forName(
- "com.sun.ts.tests.common.vehicle.servlet.ServletVehicleRunner");
- servletRunner = (VehicleRunnable) c.newInstance();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- return servletRunner;
- }
-
- private static VehicleRunnable getJSPRunner() {
- if (jspRunner == null) {
- try {
- Class c = Class
- .forName("com.sun.ts.tests.common.vehicle.jsp.JSPVehicleRunner");
- jspRunner = (VehicleRunnable) c.newInstance();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- return jspRunner;
- }
-
- private static VehicleRunnable getEJBLiteJSFRunner() {
- if (ejbLiteJsfRunner == null) {
- try {
- Class c = Class.forName(
- "com.sun.ts.tests.common.vehicle.ejblitejsf.EJBLiteJSFVehicleRunner");
- ejbLiteJsfRunner = (VehicleRunnable) c.newInstance();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- return ejbLiteJsfRunner;
- }
-
- private static VehicleRunnable getEJBLiteWebRunner() {
- if (ejbLiteJspRunner == null) {
- try {
- Class c = Class.forName(
- "com.sun.ts.tests.common.vehicle.ejbliteshare.EJBLiteWebVehicleRunner");
- ejbLiteJspRunner = (VehicleRunnable) c.newInstance();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- return ejbLiteJspRunner;
- }
-
- private static VehicleRunnable getEJBLiteSecuredWebRunner() {
- if (ejbLiteSecuredJspRunner == null) {
- try {
- Class c = Class.forName(
- "com.sun.ts.tests.common.vehicle.ejbliteshare.EJBLiteSecuredWebVehicleRunner");
- ejbLiteSecuredJspRunner = (VehicleRunnable) c.newInstance();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- return ejbLiteSecuredJspRunner;
- }
-
- private static VehicleRunnable getWebRunner() {
- if (webRunner == null) {
- try {
- Class c = Class
- .forName("com.sun.ts.tests.common.vehicle.web.WebVehicleRunner");
- webRunner = (VehicleRunnable) c.newInstance();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- return webRunner;
- }
-
- private static VehicleRunnable getEmptyRunner() {
- if (emptyRunner == null) {
- try {
- Class c = Class
- .forName("com.sun.ts.tests.common.vehicle.EmptyVehicleRunner");
- emptyRunner = (VehicleRunnable) c.newInstance();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- return emptyRunner;
- }
-
- private static VehicleRunnable getStateless3Runner() {
- if (stateless3Runner == null) {
- try {
- Class c = Class.forName(
- "com.sun.ts.tests.common.vehicle.stateless3.Stateless3VehicleRunner");
- stateless3Runner = (VehicleRunnable) c.newInstance();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- return stateless3Runner;
- }
-
- private static VehicleRunnable getStateful3Runner() {
- if (stateful3Runner == null) {
- try {
- Class c = Class.forName(
- "com.sun.ts.tests.common.vehicle.stateful3.Stateful3VehicleRunner");
- stateful3Runner = (VehicleRunnable) c.newInstance();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- return stateful3Runner;
- }
-
- private static VehicleRunnable getAppManagedRunner() {
- if (appmanagedRunner == null) {
- try {
- Class c = Class.forName(
- "com.sun.ts.tests.common.vehicle.appmanaged.AppManagedVehicleRunner");
- appmanagedRunner = (VehicleRunnable) c.newInstance();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- return appmanagedRunner;
- }
-
- private static VehicleRunnable getAppManagedNoTxRunner() {
- if (appmanagedNoTxRunner == null) {
- try {
- Class c = Class.forName(
- "com.sun.ts.tests.common.vehicle.appmanagedNoTx.AppManagedNoTxVehicleRunner");
- appmanagedNoTxRunner = (VehicleRunnable) c.newInstance();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- return appmanagedNoTxRunner;
- }
-
- private static VehicleRunnable getWSEJBRunner() {
- if (wsejbRunner == null) {
- try {
- Class c = Class.forName(
- "com.sun.ts.tests.common.vehicle.wsejb.WSEJBVehicleRunner");
- wsejbRunner = (VehicleRunnable) c.newInstance();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- return wsejbRunner;
- }
-
- private static VehicleRunnable getWSServletRunner() {
- if (wsservletRunner == null) {
- try {
- Class c = Class.forName(
- "com.sun.ts.tests.common.vehicle.wsservlet.WSServletVehicleRunner");
- wsservletRunner = (VehicleRunnable) c.newInstance();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- return wsservletRunner;
- }
-
- private static VehicleRunnable getPMServletRunner() {
- if (pmservletRunner == null) {
- try {
- Class c = Class.forName(
- "com.sun.ts.tests.common.vehicle.pmservlet.PMServletVehicleRunner");
- pmservletRunner = (VehicleRunnable) c.newInstance();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- return pmservletRunner;
- }
-
- private static VehicleRunnable getPUServletRunner() {
- if (puservletRunner == null) {
- try {
- Class c = Class.forName(
- "com.sun.ts.tests.common.vehicle.puservlet.PUServletVehicleRunner");
- puservletRunner = (VehicleRunnable) c.newInstance();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- return puservletRunner;
- }
-
- private static VehicleRunnable getConnectorServletRunner() {
- if (connectorServletRunner == null) {
- try {
- Class c = Class.forName(
- "com.sun.ts.tests.common.vehicle.connectorservlet.ConnectorServletVehicleRunner");
- connectorServletRunner = (VehicleRunnable) c.newInstance();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- return connectorServletRunner;
- }
-
- // this supports the rare case of a user defined custome vehicle
- private static VehicleRunnable getCustomVehicleRunner() {
- if (customVehicleRunner == null) {
- try {
- Class c = Class.forName(
- "com.sun.ts.tests.common.vehicle.customvehicle.CustomVehicleRunner");
- customVehicleRunner = (VehicleRunnable) c.newInstance();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- return customVehicleRunner;
- }
-
- // runners are stateless and thus can be cached and reused.
- // But we cannot have reference to ejb vehicle directory in
- // order to compile this class in any tck's.
- public static VehicleRunnable getVehicleRunner(String vtype) {
- if (vtype.equalsIgnoreCase("ejb")) {
- return getEJBRunner();
- } else if (vtype.equalsIgnoreCase("servlet")) {
- return getServletRunner();
- } else if (vtype.equalsIgnoreCase("jsp")) {
- return getJSPRunner();
- } else if (vtype.equalsIgnoreCase("web")) {
- return getWebRunner();
- } else if (vtype.equalsIgnoreCase("stateless3")) {
- return getStateless3Runner();
- } else if (vtype.equalsIgnoreCase("stateful3")) {
- return getStateful3Runner();
- } else if (vtype.equalsIgnoreCase("appmanaged")) {
- return getAppManagedRunner();
- } else if (vtype.equalsIgnoreCase("appmanagedNoTx")) {
- return getAppManagedNoTxRunner();
- } else if (vtype.equalsIgnoreCase("wsejb")) {
- return getWSEJBRunner();
- } else if (vtype.equalsIgnoreCase("wsservlet")) {
- return getWSServletRunner();
- } else if (vtype.equalsIgnoreCase("pmservlet")) {
- return getPMServletRunner();
- } else if (vtype.equalsIgnoreCase("puservlet")) {
- return getPUServletRunner();
- } else if (vtype.equalsIgnoreCase("connectorservlet")) {
- return getConnectorServletRunner();
- } else if (vtype.equalsIgnoreCase("customvehicle")) {
- return getCustomVehicleRunner();
- } else if (vtype.equalsIgnoreCase("ejblitejsf")) {
- return getEJBLiteJSFRunner();
- } else if (vtype.equalsIgnoreCase("ejblitejsp")
- || vtype.equalsIgnoreCase("ejbliteservlet")
- || vtype.equalsIgnoreCase("ejbliteservlet2")
- || vtype.equalsIgnoreCase("ejbliteservletcal")) {
- return getEJBLiteWebRunner();
- } else if (vtype.equalsIgnoreCase("ejblitesecuredjsp")) {
- return getEJBLiteSecuredWebRunner();
- } else {
- if (!vtype.equalsIgnoreCase("appclient")
- && !vtype.equalsIgnoreCase("wsappclient")
- && !vtype.equalsIgnoreCase("standalone")) {
- logger.log(Logger.Level.WARNING,"Invalid vehicle {"+vtype+"}. Will run test directly.");
-
- }
- return getEmptyRunner();
- }
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/vehicle/appmanaged/AppManagedVehicleBean.java b/common/src/main/java/com/sun/ts/tests/common/vehicle/appmanaged/AppManagedVehicleBean.java
deleted file mode 100644
index 2744434acb..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/vehicle/appmanaged/AppManagedVehicleBean.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.vehicle.appmanaged;
-
-import java.util.Properties;
-
-import com.sun.ts.lib.harness.RemoteStatus;
-import com.sun.ts.tests.common.vehicle.ejb3share.NoopTransactionWrapper;
-
-import jakarta.annotation.Resource;
-import jakarta.ejb.Remote;
-import jakarta.ejb.Remove;
-import jakarta.ejb.SessionContext;
-import jakarta.ejb.Stateful;
-import jakarta.persistence.EntityManager;
-import jakarta.persistence.EntityManagerFactory;
-import jakarta.persistence.EntityTransaction;
-import jakarta.persistence.PersistenceUnit;
-
-@Stateful(name = "AppManagedVehicleBean")
-@Remote({ AppManagedVehicleIF.class })
-public class AppManagedVehicleBean
- extends com.sun.ts.tests.common.vehicle.ejb3share.EJB3ShareBaseBean
- implements AppManagedVehicleIF, java.io.Serializable {
-
- public AppManagedVehicleBean() {
- super();
- }
-
- protected String getVehicleType() {
- return APPMANAGED;
- }
-
- private EntityManagerFactory emf;
-
- // ================== business methods ====================================
- @Remove
- public RemoteStatus runTest(String[] args, Properties props) {
- props.put("persistence.unit.name", "CTS-EM");
- try {
- setEntityManager(emf.createEntityManager());
- RemoteStatus retValue;
- retValue = super.runTest(args, props);
- return retValue;
- } finally {
- try {
- if (getEntityManager().isOpen()) {
- getEntityManager().close();
- }
- } catch (Exception e) {
- System.out.println("Exception caught during em.close()" + e);
- }
- }
- }
- /////////////////////////////////////////////////////////////////////////
-
- @Resource
- public void setSessionContext(SessionContext sessionContext) {
- this.sessionContext = sessionContext;
- }
-
- @PersistenceUnit(unitName = "CTS-EM")
- public void setEntityManagerFactory(EntityManagerFactory emf) {
- this.emf = emf;
- this.entityManagerFactory = emf;
- }
-
- public void setEntityManager(EntityManager entityManager) {
- this.entityManager = entityManager;
- }
-
- protected EntityTransaction getEntityTransaction() {
- return new NoopTransactionWrapper();
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/vehicle/appmanaged/AppManagedVehicleRunner.java b/common/src/main/java/com/sun/ts/tests/common/vehicle/appmanaged/AppManagedVehicleRunner.java
deleted file mode 100644
index 14720b2a0d..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/vehicle/appmanaged/AppManagedVehicleRunner.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.vehicle.appmanaged;
-
-import java.util.Properties;
-
-import javax.naming.InitialContext;
-import javax.naming.NameClassPair;
-import javax.naming.NamingEnumeration;
-import javax.naming.NamingException;
-
-import com.sun.ts.lib.harness.Status;
-import com.sun.ts.lib.util.TSNamingContext;
-import com.sun.ts.lib.util.TestUtil;
-import com.sun.ts.tests.common.vehicle.VehicleRunnable;
-
-public class AppManagedVehicleRunner implements VehicleRunnable {
- public static final String APPMANAGED_REF_NAME = "java:comp/env/ejb/AppManagedVehicleBean";
-
- public Status run(String[] args, Properties props) {
- Status sTestStatus = null;
- try {
- AppManagedVehicleIF bean=null;
- TSNamingContext jc = new TSNamingContext(props);
- try {
- bean = (AppManagedVehicleIF) jc
- .lookup(APPMANAGED_REF_NAME);
- } catch (Exception e) {
- e.printStackTrace();
- dumpJndi("", new InitialContext());
- }
- TestUtil.logTrace(
- "application-managed JTA runner looked up vehicle: " + bean);
- sTestStatus = (bean.runTest(args, props)).toStatus();
- } catch (Exception e) {
- TestUtil.logErr("Test failed.", e);
- sTestStatus = Status
- .failed("Test run in application-managed JTA vehicle failed.");
- }
- return sTestStatus;
- }
-
- private void dumpJndi(String s,InitialContext jc ) {
- try {
- dumpTreeEntry(jc, jc.list(s), s);
- } catch (Exception ignore) {
- }
- }
- private void dumpTreeEntry(InitialContext jc, NamingEnumeration list, String s) throws NamingException {
- System.out.println("\n1. AppManagedVehicleRunner jndi dump walking down tree branch name = " + s);
- while (list.hasMore()) {
- NameClassPair ncp = list.next();
- System.out.println("2. AppManagedVehicleRunner jndi dump (show name + classname pair): " + ncp.toString());
- if (s.length() == 0) {
- dumpJndi(ncp.getName(), jc);
- } else {
- dumpJndi(s + "/" + ncp.getName(), jc);
- }
- }
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/vehicle/appmanagedNoTx/AppManagedNoTxVehicleBean.java b/common/src/main/java/com/sun/ts/tests/common/vehicle/appmanagedNoTx/AppManagedNoTxVehicleBean.java
deleted file mode 100644
index a9aa7423e4..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/vehicle/appmanagedNoTx/AppManagedNoTxVehicleBean.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.vehicle.appmanagedNoTx;
-
-import java.util.Properties;
-
-import com.sun.ts.lib.harness.RemoteStatus;
-import com.sun.ts.tests.common.vehicle.ejb3share.EntityTransactionWrapper;
-
-import jakarta.annotation.Resource;
-import jakarta.ejb.Remote;
-import jakarta.ejb.Remove;
-import jakarta.ejb.SessionContext;
-import jakarta.ejb.Stateful;
-import jakarta.persistence.EntityManager;
-import jakarta.persistence.EntityManagerFactory;
-import jakarta.persistence.EntityTransaction;
-import jakarta.persistence.PersistenceUnit;
-
-@Stateful(name = "AppManagedNoTxVehicleBean")
-@Remote({ AppManagedNoTxVehicleIF.class })
-public class AppManagedNoTxVehicleBean
- extends com.sun.ts.tests.common.vehicle.ejb3share.EJB3ShareBaseBean
- implements AppManagedNoTxVehicleIF, java.io.Serializable {
-
- public AppManagedNoTxVehicleBean() {
- super();
- }
-
- protected String getVehicleType() {
- return APPMANAGEDNOTX;
- }
-
- private EntityManagerFactory emf;
-
- // ================== business methods ====================================
- @Remove
- public RemoteStatus runTest(String[] args, Properties props) {
- props.put("persistence.unit.name", "CTS-EM-NOTX");
- try {
- setEntityManager(emf.createEntityManager());
- RemoteStatus retValue;
- retValue = super.runTest(args, props);
- return retValue;
- } finally {
- try {
- if (getEntityManager().isOpen()) {
- getEntityManager().close();
- }
- } catch (Exception e) {
- System.out.println("Exception caught during em.close()" + e);
- }
- }
- }
- /////////////////////////////////////////////////////////////////////////
-
- @Resource
- public void setSessionContext(SessionContext sessionContext) {
- this.sessionContext = sessionContext;
- }
-
- @PersistenceUnit(unitName = "CTS-EM-NOTX")
- public void setEntityManagerFactory(EntityManagerFactory emf) {
- this.emf = emf;
- this.entityManagerFactory = emf;
- }
-
- public void setEntityManager(EntityManager entityManager) {
- this.entityManager = entityManager;
- }
-
- protected EntityTransaction getEntityTransaction() {
- return new EntityTransactionWrapper(getEntityManager().getTransaction());
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/vehicle/connectorservlet/ConnectorServletVehicle.java b/common/src/main/java/com/sun/ts/tests/common/vehicle/connectorservlet/ConnectorServletVehicle.java
deleted file mode 100644
index 438ad6f191..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/vehicle/connectorservlet/ConnectorServletVehicle.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright (c) 2008, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- *
- */
-package com.sun.ts.tests.common.vehicle.connectorservlet;
-
-import java.io.BufferedInputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.rmi.RemoteException;
-import java.util.Properties;
-
-import com.sun.ts.lib.harness.Status;
-import com.sun.ts.lib.harness.EETest;
-import com.sun.ts.lib.harness.RemoteStatus;
-import com.sun.ts.lib.util.TestUtil;
-
-import jakarta.servlet.ServletConfig;
-import jakarta.servlet.ServletException;
-import jakarta.servlet.http.HttpServlet;
-import jakarta.servlet.http.HttpServletRequest;
-import jakarta.servlet.http.HttpServletResponse;
-
-public class ConnectorServletVehicle extends HttpServlet {
- protected Properties properties = null;
-
- protected String[] arguments = null;
-
- protected EETest testObj = null;
-
- public void init(ServletConfig config) throws ServletException {
- TestUtil.logTrace("init " + this.getClass().getName() + " ...");
- super.init(config);
- }
-
- public void doGet(HttpServletRequest req, HttpServletResponse res)
- throws ServletException, IOException {
- try {
- // get the inputstream and read any objects passed from the
- // client, e.g. properties, args, etc.
- // wrap the Inputstream in an ObjectInputstream and read
- // the properties and args.
- TestUtil.logTrace("ConnectorServletVehicle - In doGet");
-
- ObjectInputStream objInStream = new ObjectInputStream(
- new BufferedInputStream(req.getInputStream()));
- System.out.println("ConnectorServletVehicle - got InputStream");
- TestUtil.logTrace("ConnectorServletVehicle - got InputStream");
- properties = (Properties) objInStream.readObject();
- System.out.println("read properties!!!");
-
- // create an instance of the test client and run here
- String testClassName = TestUtil.getProperty(properties, "test_classname");
- Class c = Class.forName(testClassName);
- testObj = (EETest) c.newInstance();
-
- // Thread.currentThread().dumpStack();
- arguments = (String[]) objInStream.readObject();
- // arguments = new String[1];
- // arguments[0] = "";
- TestUtil.logTrace("ConnectorServletVehicle - read Objects");
- try {
- TestUtil.init(properties);
- TestUtil.logTrace("Remote logging set for Servlet Vehicle");
- TestUtil.logTrace("ConnectorServletVehicle - Here are the props");
- TestUtil.list(properties);
- } catch (Exception e) {
- throw new ServletException("unable to initialize remote logging");
- }
- ObjectOutputStream objOutStream = new ObjectOutputStream(
- res.getOutputStream());
- System.out.println("got outputstream");
- // now run the test and return the result
- RemoteStatus finalStatus = runTest();
- System.out.println("ran test");
- objOutStream.writeObject(finalStatus);
- objOutStream.flush();
- objOutStream.close();
-
- } catch (Throwable t) {
- System.out.println(t.getMessage());
- TestUtil.logTrace(t.getMessage());
- t.printStackTrace();
- throw new ServletException(
- "test failed to run within the Servlet Vehicle");
- }
-
- }
-
- public void doPost(HttpServletRequest req, HttpServletResponse res)
- throws ServletException, IOException {
- System.out.println("In doPost!");
- TestUtil.logTrace("In doPost");
- doGet(req, res);
- }
-
- protected RemoteStatus runTest() throws RemoteException {
- RemoteStatus sTestStatus = new RemoteStatus(Status.passed(""));
-
- try {
- // call EETest impl's run method
- sTestStatus = new RemoteStatus(testObj.run(arguments, properties));
-
- if (sTestStatus.getType() == Status.PASSED)
- TestUtil.logMsg("Test running in servlet vehicle passed");
- else
- TestUtil.logMsg("Test running in servlet vehicle failed");
- } catch (Throwable e) {
- TestUtil.logErr("Test running in servlet vehicle failed", e);
- sTestStatus = new RemoteStatus(
- Status.failed("Test running in servlet vehicle failed"));
- }
- return sTestStatus;
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/vehicle/connectorservlet/ConnectorVehicleRunner.java b/common/src/main/java/com/sun/ts/tests/common/vehicle/connectorservlet/ConnectorVehicleRunner.java
deleted file mode 100644
index c4e3981aeb..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/vehicle/connectorservlet/ConnectorVehicleRunner.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Copyright (c) 2008, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.common.vehicle.connectorservlet;
-
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.Properties;
-
-import com.sun.ts.lib.harness.Status;
-import com.sun.ts.lib.harness.RemoteStatus;
-import com.sun.ts.lib.util.TestUtil;
-import com.sun.ts.tests.common.vehicle.VehicleRunnable;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ConnectorVehicleRunner implements VehicleRunnable {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(ConnectorVehicleRunner.class);
-
- protected String sVehicle = "connectorservlet";
-
- protected Status sTestStatus = Status.passed("");
-
- String urlSuffix = "";
-
- Status sServletStatus = Status.passed("");
-
- String sVehicleArchiveName = "";
-
- String contextRootPrefix;
-
- String[] argv;
-
- Properties p;
-
- public Status run(String[] argv, Properties p) {
- this.argv = argv;
- this.p = p;
- sVehicle = TestUtil.getProperty(p, "vehicle");
-
- // use this name for the context root or jndi name to eliminate
- // naming conflicts for apps deployed at the same time
- sVehicleArchiveName = TestUtil.getProperty(p, "vehicle_archive_name");
-
- if (sVehicleArchiveName.indexOf("_vehicles") != -1) {
- contextRootPrefix = sVehicleArchiveName.substring(0,
- sVehicleArchiveName.indexOf("_vehicles") + 1) + sVehicle
- + "_vehicle_web";
- } else {
- if (sVehicleArchiveName.endsWith("_web")) {
- contextRootPrefix = sVehicleArchiveName;
- } else {
- contextRootPrefix = sVehicleArchiveName + "_web";
- }
- }
-
- // default urlSuffix
- urlSuffix = "/" + contextRootPrefix + "/" + sVehicle + "_vehicle";
-
- return run();
- } // run
-
- protected Status run() {
- // run in a connectorservlet
- urlSuffix = "/" + contextRootPrefix + "/connectorservlet_vehicle";
- sServletStatus = runWebVehicleTest("connectorservlet");
-
- LOGGER.info("Test: returning from running in connectorservlet vehicles");
-
- if (sServletStatus.isPassed()) {
- sTestStatus = Status.passed("Test passed in a connectorservlet ");
- } else {
- sTestStatus = Status.failed("Test failed in a connectorservlet ");
- }
- return sTestStatus;
- }
-
- protected Status runWebVehicleTest(String vehicle) {
- URLConnection connection = null;
- URL url = null;
- ObjectOutputStream objOut = null;
- ObjectInputStream objIn = null;
- Status status;
-
- try {
- String webServerHost = TestUtil.getProperty(p, "webServerHost");
- String webServerPort = TestUtil.getProperty(p, "webServerPort");
- url = new URL("http://" + webServerHost + ":" + Integer.parseInt(webServerPort) + urlSuffix);
- connection = url.openConnection();
- LOGGER.info("Opened connection to {}", url);
- connection.setDoOutput(true);
- connection.setDoInput(true);
- connection.setUseCaches(false);
- connection.setRequestProperty("Content-Type",
- "java-internal/" + p.getClass().getName());
- // connection.connect();
- objOut = new ObjectOutputStream(connection.getOutputStream());
- LOGGER.trace("got outputstream");
- objOut.writeObject(p);
- objOut.writeObject(argv);
- LOGGER.trace("wrote objects to the {} vehicle", vehicle);
- objOut.flush();
- objOut.close();
- objOut = null;
-
- // read the status when it comes back
- objIn = new ObjectInputStream(connection.getInputStream());
- status = ((RemoteStatus) objIn.readObject()).toStatus();
- TestUtil.logMsg("Test status from a " + vehicle + ": " + status.getType()
- + ":" + status.getReason());
-
- } catch (MalformedURLException e) {
- e.printStackTrace();
- status = Status.failed("Fatal: Improper URL");
- } catch (NumberFormatException e) {
- e.printStackTrace();
- status = Status.failed(
- "Please set an appropriate value for the property: webServerPort");
- } catch (IOException e) {
- e.printStackTrace();
- status = Status.failed("Fatal: Problem with connection: " + e);
- } catch (Exception e) {
- e.printStackTrace();
- status = Status.failed(
- "ServiceTest failed inside a " + vehicle + ": " + e.getMessage());
- } finally {
-
- if (objOut != null) {
- try {
- objOut.close();
- } catch (Exception e) {
- }
- }
-
- if (objIn != null) {
- try {
- objIn.close();
- } catch (Exception e) {
- }
- }
- }
- return status;
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/vehicle/ejb/EJBVehicle.java b/common/src/main/java/com/sun/ts/tests/common/vehicle/ejb/EJBVehicle.java
deleted file mode 100644
index 01e1e4c0eb..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/vehicle/ejb/EJBVehicle.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (c) 2007, 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.vehicle.ejb;
-
-import java.util.Properties;
-
-import com.sun.ts.lib.harness.Status;
-import com.sun.ts.lib.harness.EETest;
-import com.sun.ts.lib.harness.RemoteStatus;
-import com.sun.ts.lib.util.TestUtil;
-
-import jakarta.ejb.EJBException;
-
-public class EJBVehicle {
- private EETest testObj;
-
- private Properties properties;
-
- private String[] arguments;
-
- public void initialize(String[] args, Properties p) {
- // Initialize TestUtil Reporting
- try {
- TestUtil.init(p);
- } catch (Exception e) {
- TestUtil.logErr("initLogging failed in ejb vehicle.", e);
- throw new EJBException();
- }
-
- arguments = args;
- properties = p;
-
- // create an instance of the test client
- try {
- String testClassName = TestUtil.getProperty(properties, "test_classname");
- Class c = Class.forName(testClassName);
- testObj = (EETest) c.newInstance();
- } catch (Exception e) {
- TestUtil.logErr("Failed to create the EETest instance in the vehicle", e);
- throw new EJBException();
- }
- TestUtil.logTrace("initialize");
- }
-
- // the run method that we call here will either throw
- // an exception (failed), or return void (pass)
- public RemoteStatus runTest() {
- RemoteStatus sTestStatus = new RemoteStatus(Status.passed(""));
-
- TestUtil.logTrace("in runTest()");
-
- try {
- // call EETest impl's run method
- sTestStatus = new RemoteStatus(testObj.run(arguments, properties));
-
- if (sTestStatus.getType() == Status.PASSED)
- TestUtil.logMsg("Test running in ejb vehicle passed");
- else
- TestUtil.logMsg("Test running in ejb vehicle failed");
- } catch (Throwable e) {
- e.printStackTrace();
- TestUtil.logErr("Test running in ejb vehicle failed", e);
- sTestStatus = new RemoteStatus(
- Status.failed("Test running in ejb vehicle failed"));
- }
- return sTestStatus;
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/vehicle/ejb/EJBVehicleRunner.java b/common/src/main/java/com/sun/ts/tests/common/vehicle/ejb/EJBVehicleRunner.java
deleted file mode 100644
index 526ffa6133..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/vehicle/ejb/EJBVehicleRunner.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 2007, 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.vehicle.ejb;
-
-import java.util.Properties;
-
-import com.sun.ts.lib.harness.Status;
-import com.sun.ts.lib.porting.TSLoginContext;
-import com.sun.ts.lib.util.TSNamingContext;
-import com.sun.ts.lib.util.TestUtil;
-import com.sun.ts.tests.common.vehicle.VehicleRunnable;
-
-public class EJBVehicleRunner implements VehicleRunnable {
- public Status run(String[] argv, Properties p) {
-
- Status sTestStatus = Status.passed("");
- String username = TestUtil.getProperty(p, "user");
- String password = TestUtil.getProperty(p, "password");
-
- String isSecuredEjbClientValue = TestUtil.getProperty(p, "secured.ejb.vehicle.client");
- boolean isSecuredEjbClient = (isSecuredEjbClientValue != null);
- TestUtil.logTrace("%%%%%%% isSecuredEjbClient = " + isSecuredEjbClient);
-
- if (isSecuredEjbClient) {
- try {
- TestUtil.logTrace("Test login in appclient for user " + username
- + " password " + password);
- TSLoginContext loginContext = new TSLoginContext();
- loginContext.login(username, password);
- } catch (Exception e) {
- TestUtil.logErr("login failed", e);
- sTestStatus = Status.failed("Test login in appclient failed for user "
- + username + " password " + password);
- }
- }
-
- String sEJBVehicleJndiName = "";
- EJBVehicleRemote ref = null;
- try {
- TSNamingContext jc = new TSNamingContext();
- sEJBVehicleJndiName = "java:comp/env/ejb/EJBVehicle";
- ref = (EJBVehicleRemote) jc.lookup(sEJBVehicleJndiName,
- EJBVehicleRemote.class);
- ref.initialize(argv, p);
- TestUtil.logTrace("in ejbvehicle: initialize ok; call runTest()");
- sTestStatus = (ref.runTest()).toStatus();
- } catch (Exception e) {
- TestUtil.logErr("Test failed", e);
- sTestStatus = Status.failed("Test run in ejb vehicle failed");
- }
- return sTestStatus;
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/vehicle/ejb3share/EJB3ShareBaseBean.java b/common/src/main/java/com/sun/ts/tests/common/vehicle/ejb3share/EJB3ShareBaseBean.java
deleted file mode 100644
index 30b7359835..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/vehicle/ejb3share/EJB3ShareBaseBean.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Copyright (c) 2009, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.common.vehicle.ejb3share;
-
-import java.util.Properties;
-
-import com.sun.ts.lib.harness.Status;
-import com.sun.ts.lib.harness.EETest;
-import com.sun.ts.lib.harness.RemoteStatus;
-import com.sun.ts.lib.util.TestUtil;
-
-import jakarta.ejb.SessionContext;
-import jakarta.persistence.EntityManager;
-import jakarta.persistence.EntityManagerFactory;
-import jakarta.persistence.EntityTransaction;
-
-abstract public class EJB3ShareBaseBean implements EJB3ShareIF {
- public static final String FINDER_TEST_NAME_KEY = "testName";
-
- public static final String STATELESS3 = "stateless3";
-
- public static final String STATEFUL3 = "stateful3";
-
- public static final String APPMANAGED = "appmanaged";
-
- public static final String APPMANAGEDNOTX = "appmanagedNoTx";
-
- protected EntityManager entityManager;
-
- protected EntityManagerFactory entityManagerFactory;
-
- protected SessionContext sessionContext;
-
- protected abstract String getVehicleType();
-
- protected EJB3ShareBaseBean() {
- super();
- }
-
- // ================== business methods ====================================
- public RemoteStatus runTest(String[] args, Properties props) {
-
- try {
- TestUtil.init(props);
- } catch (Exception e) {
- TestUtil.logErr("initLogging failed in " + getVehicleType() + " vehicle.",
- e);
- }
-
- String testName = getTestName(props);
- System.out.println(
- "===== Starting " + testName + " in " + getVehicleType() + " =====");
- RemoteStatus sTestStatus = null;
-
- try {
- // create an instance of the test client and run here
- String testClassName = TestUtil.getProperty(props, "test_classname");
- Class c = Class.forName(testClassName);
- EETest testClient = (EETest) c.newInstance();
-
- initClient(testClient);
- sTestStatus = new RemoteStatus(testClient.run(args, props));
- if (sTestStatus.getType() == Status.PASSED)
- TestUtil.logMsg(testName + " in vehicle passed");
- } catch (Throwable e) {
- String fail = testName + " in vehicle failed";
- // e.printStackTrace();
- TestUtil.logErr(fail, e);
- sTestStatus = new RemoteStatus(Status.failed(fail));
- }
- return sTestStatus;
- }
-
- protected String getTestName(Properties props) {
- String testName = TestUtil.getProperty(props, FINDER_TEST_NAME_KEY);
- if (testName == null) {
- testName = "test";
- }
- return testName;
- }
-
- private void initClient(EETest testClient) {
- if (testClient instanceof UseEntityManager) {
- EntityManager em = getEntityManager();
- if (em == null) {
- throw new IllegalStateException("EntityManager is null");
- }
- UseEntityManager client2 = (UseEntityManager) testClient;
- EntityTransaction et = getEntityTransaction();
- client2.setEntityManager(em);
- client2.setEntityTransaction(et);
- client2.setInContainer(true);
- }
-
- if (testClient instanceof UseEntityManagerFactory) {
- EntityManagerFactory emf = getEntityManagerFactory();
- if (emf != null) {
- UseEntityManagerFactory client2 = (UseEntityManagerFactory) testClient;
- client2.setEntityManagerFactory(emf);
- }
- }
-
- }
-
- public SessionContext getSessionContext() {
- return sessionContext;
- }
-
- abstract public void setSessionContext(SessionContext sessionContext);
-
- public EntityManager getEntityManager() {
- return entityManager;
- }
-
- public EntityManagerFactory getEntityManagerFactory() {
- return entityManagerFactory;
- }
-
- public void setEntityManagerFactory(EntityManagerFactory emf) {
- // do nothing this gets overridden in subclass
- }
-
- abstract protected EntityTransaction getEntityTransaction();
-
- abstract public void setEntityManager(EntityManager entityManager);
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/vehicle/ejb3share/UserTransactionWrapper.java b/common/src/main/java/com/sun/ts/tests/common/vehicle/ejb3share/UserTransactionWrapper.java
deleted file mode 100644
index 461a95aa75..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/vehicle/ejb3share/UserTransactionWrapper.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.vehicle.ejb3share;
-
-import com.sun.ts.lib.util.TestUtil;
-
-import jakarta.persistence.EntityTransaction;
-import jakarta.persistence.PersistenceException;
-import jakarta.transaction.NotSupportedException;
-import jakarta.transaction.Status;
-import jakarta.transaction.SystemException;
-import jakarta.transaction.UserTransaction;
-
-final public class UserTransactionWrapper implements EntityTransaction {
- private UserTransaction delegate;
-
- /**
- * These are the various status and values for a transaction STATUS_ACTIVE:0
- * STATUS_COMMITTED:3 STATUS_COMMITTING:8 STATUS_MARKED_ROLLBACK:1
- * STATUS_NO_TRANSACTION:6 STATUS_PREPARED:2 STATUS_PREPARING:7
- * STATUS_ROLLEDBACK:4 STATUS_ROLLING_BACK:9 STATUS_UNKNOWN:5 *
- */
- public UserTransactionWrapper() {
- }
-
- public UserTransactionWrapper(UserTransaction delegate) {
- this.delegate = delegate;
- }
-
- public void setDelegate(UserTransaction delegate) {
- this.delegate = delegate;
- }
-
- public void rollback() {
- TestUtil.logTrace("in UserTransactionWrapper.rollback()");
- if (!isActive()) {
- throw new IllegalStateException("Transaction is not active.");
- }
- try {
- delegate.rollback();
- } catch (SystemException e) {
- throw new PersistenceException(e);
- }
- }
-
- public boolean isActive() {
- boolean active = false;
- try {
- int txStatus = delegate.getStatus();
- TestUtil.logTrace(
- "UserTransactionWrapper.isActive().getStatus():" + txStatus);
- if ((txStatus == Status.STATUS_ACTIVE)
- || (txStatus == Status.STATUS_MARKED_ROLLBACK)) {
- active = true;
- }
- } catch (SystemException e) {
- throw new PersistenceException(e);
- }
- return active;
- }
-
- @Override
- public void setTimeout(Integer timeout) {
-
- }
-
- @Override
- public Integer getTimeout() {
- return null;
- }
-
- public void commit() {
- TestUtil.logTrace("in UserTransactionWrapper.commit()");
-
- if (!isActive()) {
- throw new IllegalStateException("Transaction is not active.");
- }
- try {
- delegate.commit();
- } catch (Exception e) {
- throw new jakarta.persistence.RollbackException(e);
- }
- }
-
- public void begin() {
- TestUtil.logTrace("in UserTransactionWrapper.begin()");
- if (isActive()) {
- throw new IllegalStateException("Transaction is already active.");
- }
- try {
- delegate.begin();
- TestUtil.logTrace(
- "UserTransactionWrapper.begin().getStatus():" + delegate.getStatus());
- } catch (SystemException e) {
- throw new PersistenceException(e);
- } catch (NotSupportedException e) {
- throw new PersistenceException(e);
- }
- }
-
- public void setRollbackOnly() {
- TestUtil.logTrace("in UserTransactionWrapper.setRollbackOnly()");
- if (!isActive()) {
- throw new IllegalStateException("Transaction is not active.");
- }
- }
-
- public boolean getRollbackOnly() {
- TestUtil.logTrace("in UserTransactionWrapper.getRollbackOnly()");
- if (!isActive()) {
- throw new IllegalStateException("Transaction is not active.");
- }
- try {
- int txStatus = delegate.getStatus();
- TestUtil.logTrace(
- "UserTransactionWrapper.getRollbackOnly().getStatus():" + txStatus);
- return txStatus == Status.STATUS_MARKED_ROLLBACK;
- } catch (SystemException e) {
- throw new PersistenceException(e);
- }
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/vehicle/ejbembed/InjectionResolver.java b/common/src/main/java/com/sun/ts/tests/common/vehicle/ejbembed/InjectionResolver.java
deleted file mode 100644
index cf24ec5a57..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/vehicle/ejbembed/InjectionResolver.java
+++ /dev/null
@@ -1,291 +0,0 @@
-/*
- * Copyright (c) 2009, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-package com.sun.ts.tests.common.vehicle.ejbembed;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.logging.Logger;
-
-import com.sun.ts.tests.common.vehicle.ejbliteshare.EJBLiteClientIF;
-
-import jakarta.annotation.PostConstruct;
-import jakarta.ejb.EJB;
-import jakarta.ejb.EJBs;
-import jakarta.ejb.embeddable.EJBContainer;
-
-/**
- * Since JavaEE annotations are not required in ejb embeddable usage, this class
- * helps resolving @EJB and @PostConstruct in client classes when tests are
- * running in ejbembed vehicle.
- *
- * It resolves type-level, field and setter @EJB injections, and @PostConstruct
- * methods as well. This class constructs a portable jndi name from the metadata
- * in @EJB annotations.
- *
- * All client classes and their superclasses need to be scanned for @EJB
- * and @PostConstruct. The most general superclass should be processed first.
- * However, all @PostConstruct methods must be invoked after all @EJB injections
- * have been resolved and initialized.
- *
- * For type-level injections, name, beanName, and beanInterface are all
- * required, and so they are sufficient to construct the portable jndi name.
- * Then a mapping between JavaEE lookup name and portable global jndi name is
- * recorded, which can be consulted when test methods look up the ejb ref.
- *
- * For field and setter @EJB injection, all 3 @EJB attributes are optional.
- * beanInterface may be present or be inferred from the field or parameter type.
- * Obtaining beanName is complicated and requires searching all ejb bean
- * classes, parsing its component- defining annotations and parsing ejb-jar.xml.
- * This part is too much for our purpose.
- *
- * So we make it a rule for test writers that all client classes that are to be
- * run in ejbembed vehicle always use beanName attribute in @EJB injections.
- *
- * After a portable global jndi name is constructed, the field is initialized to
- * the lookup result, and the setter method is invoked, passing the lookup
- * result as the parameter.
- *
- * moduleName is set by various vehicles.
- */
-public class InjectionResolver {
- private static final Logger logger = Logger
- .getLogger("com.sun.ts.tests.common.vehicle.ejbembed");
-
- private EJBContainer container;
-
- private EJBLiteClientIF client;
-
- private List postConstructMethods = new ArrayList();
-
- public InjectionResolver(EJBLiteClientIF client, EJBContainer container) {
- super();
- this.client = client;
- this.container = container;
- }
-
- public void resolve() {
- resolve0(client.getClass());
- invokePostConstructMethods();
- }
-
- public void resolve0(Class extends EJBLiteClientIF> cls) {
- Class> sup = cls.getSuperclass();
- if (sup != null && EJBLiteClientIF.class.isAssignableFrom(sup)) {
- resolve0((Class extends EJBLiteClientIF>) sup);
- }
-
- resolveTypeLevelInjections(cls);
- resolveFieldInjections(cls);
- resolveSetterInjections(cls);
- resolvePostConstruct(cls);
-
- logger.info("Resolved " + cls);
- }
-
- private void resolvePostConstruct(Class extends EJBLiteClientIF> cls) {
- Method[] methods = cls.getDeclaredMethods();
- for (Method m : methods) {
- PostConstruct pc = m.getAnnotation(PostConstruct.class);
- if (pc != null) {
- postConstructMethods.add(m);
- }
- }
- }
-
- private void invokePostConstructMethods() {
- for (Method m : postConstructMethods) {
- m.setAccessible(true);
- try {
- m.invoke(client);
- logger.info("Invoked PostConstruct method: " + m);
- } catch (IllegalAccessException e) {
- throw new RuntimeException(e);
- } catch (InvocationTargetException e) {
- throw new RuntimeException(e);
- }
- }
- }
-
- private void resolveSetterInjections(Class extends EJBLiteClientIF> cls) {
- Method[] methods = cls.getDeclaredMethods();
- for (Method m : methods) {
- EJB b = m.getAnnotation(EJB.class);
- if (b == null) {
- continue;
- }
-
- logger.info("Resolving setter @EJB injection: " + b);
-
- String lookup = b.lookup(); // default value is ""
- if (lookup.length() > 0 && lookup.startsWith("java:global")) {
- logger.info("Got @EJB.lookup " + lookup);
- } else {
- Class> beanInterface = b.beanInterface();
- String beanName = b.beanName();
- if (beanInterface.equals(Object.class)) {
- Class>[] paramTypes = m.getParameterTypes();
- beanInterface = paramTypes[0];
- }
- if (beanName.length() == 0) {
- beanName = getBeanNameFromDescription(b.description());
- }
- if (beanName.length() == 0) {
- throw new RuntimeException(
- "beanName is not specified in @EJB injection on method "
- + m.toString());
- }
- lookup = createGlobalJNDIName(beanInterface, beanName);
- }
-
- Object beanFromLookup = lookup(lookup);
-
- m.setAccessible(true);
- try {
- m.invoke(client, beanFromLookup);
- } catch (IllegalAccessException e) {
- throw new RuntimeException(e);
- } catch (InvocationTargetException e) {
- throw new RuntimeException(e);
- }
- }
- }
-
- private void resolveFieldInjections(Class extends EJBLiteClientIF> cls) {
- Field[] fields = cls.getDeclaredFields();
- for (Field f : fields) {
- EJB b = f.getAnnotation(EJB.class);
- if (b == null) {
- continue;
- }
-
- logger.info("Resolving field @EJB injection: " + b);
-
- String lookup = b.lookup(); // default value is ""
- if (lookup.length() > 0 && lookup.startsWith("java:global")) {
- logger.info("Got @EJB.lookup " + lookup);
- } else {
- Class> beanInterface = b.beanInterface();
- String beanName = b.beanName();
- if (beanInterface.equals(Object.class)) {
- beanInterface = f.getType();
- }
- if (beanName.length() == 0) {
- beanName = getBeanNameFromDescription(b.description());
- }
- if (beanName.length() == 0) {
- throw new RuntimeException(
- "beanName is not specified in @EJB injection on field "
- + f.toString());
- }
- lookup = createGlobalJNDIName(beanInterface, beanName);
- }
-
- Object beanFromLookup = lookup(lookup);
-
- f.setAccessible(true);
- try {
- f.set(client, beanFromLookup);
- } catch (IllegalAccessException e) {
- throw new RuntimeException(e);
- }
- }
- }
-
- /**
- * EJB spec requires that lookup and beanName attributes cannot be both
- * present in the same @EJB. For those tests that specifically test lookup
- * attribute, beanName value has to be indirectly specified in description
- * attribute in the form: description="beanName=LookupBean" This method
- * extracts the beanName value from description attribute of @EJB
- */
- private String getBeanNameFromDescription(String description) {
- String[] tokens = description.split("=");
- String beanName = "";
- if (tokens.length == 2) {
- beanName = tokens[1];
- logger.info("Got beanName indirectly from description: " + beanName);
- }
- return beanName;
- }
-
- private void resolveTypeLevelInjections(
- Class extends EJBLiteClientIF> cls) {
- EJBs ejbs = cls.getAnnotation(EJBs.class);
- EJB ejb = cls.getAnnotation(EJB.class);
-
- if (ejbs != null) {
- for (EJB b : ejbs.value()) {
- resolveTypeLevelEJB(b);
- }
- }
- if (ejb != null) {
- resolveTypeLevelEJB(ejb);
- }
- }
-
- private void resolveTypeLevelEJB(EJB b) {
- // For type-level @EJB injections, all 3 attr are required
- logger.info("Resolving type-level @EJB injection: " + b);
-
- Class> beanInterface = b.beanInterface();
- String beanName = b.beanName();
- String name = b.name();
- String lookup = b.lookup(); // should be very rare to use lookup attr in
- // type-level injections
-
- if (lookup.length() > 0 && lookup.startsWith("java:global")) {
- logger.info("Got @EJB.lookup " + lookup);
- } else {
- lookup = createGlobalJNDIName(beanInterface, beanName);
- }
-
- client.getJndiMapping().put(createJavaEELookupName(name), lookup);
- }
-
- private String createJavaEELookupName(String name) {
- return "java:comp/env/" + name;
- }
-
- // java:global[/]//[!]
- private String createGlobalJNDIName(Class> beanInterface, String beanName) {
- String result = EJBLiteClientIF.JAVA_GLOBAL_PREFIX;
- result += client.getModuleName() + "/" + beanName + "!"
- + beanInterface.getName();
-
- logger.info("Constructed portable global jndi name: " + result);
- return result;
- }
-
- private Object lookup(String lookupName) {
- Object result = null;
- javax.naming.Context context = container.getContext();
- try {
- result = context.lookup(lookupName);
- } catch (javax.naming.NamingException e) {
- throw new RuntimeException(e);
- }
-
- return result;
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/vehicle/ejbliteshare/EJBLiteClientIF.java b/common/src/main/java/com/sun/ts/tests/common/vehicle/ejbliteshare/EJBLiteClientIF.java
deleted file mode 100644
index a822ca7641..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/vehicle/ejbliteshare/EJBLiteClientIF.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (c) 2009, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.vehicle.ejbliteshare;
-
-import java.io.File;
-import java.util.Map;
-
-import jakarta.ejb.embeddable.EJBContainer;
-
-public interface EJBLiteClientIF {
- public static final String TEST_PASSED = "[TEST PASSED] ";
-
- public static final String TEST_FAILED = "[TEST FAILED] ";
-
- public static final String JAVA_GLOBAL_PREFIX = "java:global/";
-
- public static final String JAVA_COMP_ENV_PREFIX = "java:comp/env/";
-
- public static final String ADDITIONAL_MODULES_KEY = "-additionalModule";
-
- public static final String EJBEMBED_JAR_NAME_BASE = "ejbembed_vehicle_ejb";
-
- public void setInjectionSupported(Boolean injectionSupported);
-
- public Boolean getInjectionSupported();
-
- public void runTestInVehicle();
-
- public String getTestName();
-
- public void setTestName(String testName);
-
- public String getStatus();
-
- public String getReason();
-
- public String getModuleName();
-
- public void setModuleName(String mn);
-
- public Map getJndiMapping();
-
- public EJBContainer getContainer();
-
- public void setContainer(EJBContainer container);
-
- public javax.naming.Context getContext();
-
- public void setAdditionalModules(File[] additionalModules);
-
- public void setContext(javax.naming.Context context);
-
- /**
- * Subclass client can override this method to customize the container
- * creation. The default implementation returns null in EJBLiteClientBase.
- * Since the method must be invoked prior to container creation, way ahead of
- * actual test method, this customization is only possible at test client
- * level, not at test method level.
- */
- public Map getContainerInitProperties();
-
- /**
- * This method is called by test client to set context ClassLoader to include
- * additional classes and ejb modules. This method is called prior to creating
- * EJBContainer. The default implementation does nothing and makes no change
- * to the context ClassLoader in the current thread. Subclass client may
- * choose to override this method to provide for additional ejb modules and
- * classes.
- */
- public void setContextClassLoader();
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/vehicle/ejbliteshare/EJBLiteSecuredWebVehicleRunner.java b/common/src/main/java/com/sun/ts/tests/common/vehicle/ejbliteshare/EJBLiteSecuredWebVehicleRunner.java
deleted file mode 100644
index a57494b88e..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/vehicle/ejbliteshare/EJBLiteSecuredWebVehicleRunner.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (c) 2008, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.common.vehicle.ejbliteshare;
-
-import static com.sun.ts.tests.common.vehicle.ejbliteshare.EJBLiteClientIF.TEST_PASSED;
-
-import java.io.IOException;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.util.Properties;
-import java.util.logging.Logger;
-
-import com.sun.ts.lib.harness.Status;
-import com.sun.ts.lib.porting.TSURL;
-import com.sun.ts.lib.util.BASE64Encoder;
-import com.sun.ts.lib.util.TestUtil;
-import com.sun.ts.tests.common.vehicle.VehicleRunnable;
-
-public class EJBLiteSecuredWebVehicleRunner implements VehicleRunnable {
- private final static Logger logger = Logger
- .getLogger(EJBLiteSecuredWebVehicleRunner.class.getName());
-
- protected String getServletPath(String vehicle) {
- return "/" + vehicle + "_vehicle.jsp";
- }
-
- public Status run(String[] argv, Properties p) {
- String testName = TestUtil.getProperty(p, "testName");
- String vehicle = TestUtil.getProperty(p, "vehicle");
- String contextRoot = TestUtil.getProperty(p, "vehicle_archive_name");
- String queryString = "?testName=" + testName;
- String requestUrl = "/" + contextRoot + getServletPath(vehicle)
- + queryString;
-
- String username = TestUtil.getProperty(p, "user");
- String password = TestUtil.getProperty(p, "password");
-
- TSURL ctsURL = new TSURL();
- URL url = null;
- HttpURLConnection connection = null;
- int statusCode = Status.NOT_RUN;
- String response = null;
- try {
- url = ctsURL.getURL("http", TestUtil.getProperty(p, "webServerHost"),
- Integer.parseInt(TestUtil.getProperty(p, "webServerPort")), requestUrl);
-
- // Encode authData
- String authData = username + ":" + password;
-
- BASE64Encoder encoder = new BASE64Encoder();
-
- String encodedAuthData = encoder.encode(authData.getBytes());
-
- connection = (HttpURLConnection) url.openConnection();
- connection.setRequestMethod("GET");
- connection.setUseCaches(false);
-
- // set request property
- connection.setRequestProperty("Authorization",
- "Basic " + encodedAuthData.trim());
-
- logger.info("Connecting " + url.toExternalForm());
- connection.connect();
-
- response = TestUtil.getResponse(connection).trim();
- if (response.indexOf(TEST_PASSED) >= 0) {
- statusCode = Status.PASSED;
- } else {
- statusCode = Status.FAILED;
- }
- } catch (IOException e) {
- statusCode = Status.FAILED;
- response = "Failed to connect to the test webapp."
- + TestUtil.printStackTraceToString(e);
- }
- return new ReasonableStatus(statusCode, response);
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/vehicle/ejbliteshare/EJBLiteWebVehicleRunner.java b/common/src/main/java/com/sun/ts/tests/common/vehicle/ejbliteshare/EJBLiteWebVehicleRunner.java
deleted file mode 100644
index 860d3cc236..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/vehicle/ejbliteshare/EJBLiteWebVehicleRunner.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (c) 2008, 2018 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-package com.sun.ts.tests.common.vehicle.ejbliteshare;
-
-import static com.sun.ts.tests.common.vehicle.ejbliteshare.EJBLiteClientIF.TEST_PASSED;
-
-import java.io.IOException;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.util.Properties;
-import java.util.logging.Logger;
-
-import com.sun.ts.lib.harness.Status;
-import com.sun.ts.lib.porting.TSURL;
-import com.sun.ts.lib.util.TestUtil;
-import com.sun.ts.tests.common.vehicle.VehicleRunnable;
-
-public class EJBLiteWebVehicleRunner implements VehicleRunnable {
- private final static Logger logger = Logger
- .getLogger(EJBLiteWebVehicleRunner.class.getName());
-
- protected String getServletPath(String vehicle) {
- return "/" + vehicle + "_vehicle.jsp";
- }
-
- protected String getQueryString(Properties p) {
- return "?testName=" + TestUtil.getProperty(p, "testName");
- }
-
- public Status run(String[] argv, Properties p) {
- String vehicle = TestUtil.getProperty(p, "vehicle");
- String contextRoot = TestUtil.getProperty(p, "vehicle_archive_name");
- String requestUrl = "/" + contextRoot + getServletPath(vehicle)
- + getQueryString(p);
-
- TSURL ctsURL = new TSURL();
- URL url = null;
- HttpURLConnection connection = null;
- int statusCode = Status.NOT_RUN;
- String response = null;
- try {
- url = ctsURL.getURL("http", TestUtil.getProperty(p, "webServerHost"),
- Integer.parseInt(TestUtil.getProperty(p, "webServerPort")), requestUrl);
-
- connection = (HttpURLConnection) url.openConnection();
- connection.setRequestMethod("GET");
- connection.setUseCaches(false);
- logger.info("Connecting " + url.toExternalForm());
- connection.connect();
-
- response = TestUtil.getResponse(connection).trim();
- if (response.indexOf(TEST_PASSED) >= 0) {
- statusCode = Status.PASSED;
- } else {
- statusCode = Status.FAILED;
- }
- } catch (IOException e) {
- statusCode = Status.FAILED;
- response = "Failed to connect to the test webapp."
- + TestUtil.printStackTraceToString(e);
- }
- return new ReasonableStatus(statusCode, response);
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/vehicle/ejbliteshare/ReasonableStatus.java b/common/src/main/java/com/sun/ts/tests/common/vehicle/ejbliteshare/ReasonableStatus.java
deleted file mode 100644
index 5f506b44c2..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/vehicle/ejbliteshare/ReasonableStatus.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 2008, 2018 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-package com.sun.ts.tests.common.vehicle.ejbliteshare;
-
-import com.sun.ts.lib.harness.Status;
-
-/**
- * This class is used to work around javatest bugs/features: javatest Status
- * constructor replaces all unprintable chars with one single space, making any
- * multi-line reason unreadable; javatest Status does not have an overrideable
- * setReason method.
- */
-public class ReasonableStatus extends Status {
- private String reason;
-
- public ReasonableStatus(int c, String r) {
- super(c, "");
- reason = r;
-
- // print the status reason to console, regardless of same.jvm value.
- // If it were printed inside exit() method, it will not be called when
- // same.jvm is enabled (e.g., with -Dsame.jvm=true from command line)
- System.out.println(reason);
- }
-
- @Override
- public String getReason() {
- return reason;
- }
-
- // In same.jvm mode, when this method is overridden, the test status is
- // printed
- // three times in jtr report file. When not overridden, only the status
- // withou
- // detailed reason (only pass/fail/notrun, etc) is included in jtr file.
- //
- // It does not affect different jvm mode.
- // It does not affect test output on the console.
- // @Override
- // public String toString() {
- // return String.format("%s; %s", super.toString(), reason);
- // }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/vehicle/pmservlet/PMServletVehicle.java b/common/src/main/java/com/sun/ts/tests/common/vehicle/pmservlet/PMServletVehicle.java
deleted file mode 100644
index 80ad7217d1..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/vehicle/pmservlet/PMServletVehicle.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-package com.sun.ts.tests.common.vehicle.pmservlet;
-
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-import com.sun.ts.lib.harness.Status;
-import com.sun.ts.lib.harness.RemoteStatus;
-import com.sun.ts.lib.util.TSNamingContext;
-import com.sun.ts.lib.util.TestUtil;
-import com.sun.ts.tests.common.vehicle.ejb3share.UseEntityManager;
-import com.sun.ts.tests.common.vehicle.ejb3share.UseEntityManagerFactory;
-import com.sun.ts.tests.common.vehicle.ejb3share.UserTransactionWrapper;
-import com.sun.ts.tests.common.vehicle.servlet.ServletVehicle;
-
-import jakarta.persistence.EntityManager;
-import jakarta.persistence.EntityManagerFactory;
-import jakarta.persistence.EntityTransaction;
-import jakarta.persistence.PersistenceContext;
-import jakarta.persistence.PersistenceContexts;
-import jakarta.persistence.PersistenceUnit;
-import jakarta.transaction.UserTransaction;
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-
-@PersistenceContexts({
- @PersistenceContext(name = "persistence/CTS-EM", unitName = "CTS-EM"),
- @PersistenceContext(name = "persistence/CTS-EM2", unitName = "CTS-EM2") })
-public class PMServletVehicle extends ServletVehicle {
-
- private static final String EM_LOOKUP_NAME = "java:comp/env/persistence/CTS-EM";
-
- private UserTransaction ut;
-
- @PersistenceUnit(unitName = "CTS-EM")
- EntityManagerFactory emf;
-
- public EntityTransaction getEntityTransaction() {
- try {
- TSNamingContext nctx = new TSNamingContext();
- ut = (UserTransaction) nctx.lookup("java:comp/UserTransaction");
- } catch (Exception e) {
- TestUtil.logMsg("Naming service exception: " + e.getMessage());
- e.printStackTrace();
- }
- return new UserTransactionWrapper(ut);
- }
-
- private Object lookup(String lookupName) throws IllegalStateException {
- Object result = null;
- try {
- Context context = new InitialContext();
- result = context.lookup(lookupName);
- } catch (NamingException e) {
- throw new IllegalStateException("Failed to lookup:" + lookupName, e);
- }
- return result;
- }
-
- protected RemoteStatus runTest() {
- properties.put("persistence.unit.name", "CTS-EM");
-
- RemoteStatus sTestStatus = new RemoteStatus(Status.passed(""));
-
- try {
- // call EETest impl's run method
- if (testObj instanceof UseEntityManager) {
-
- // lookup EntityManager for each http request,
- // so it's not shared by multiple threads
- EntityManager em = (EntityManager) lookup(EM_LOOKUP_NAME);
-
- if (em == null) {
- throw new IllegalStateException("EntityManager is null");
- }
- UseEntityManager client2 = (UseEntityManager) testObj;
- EntityTransaction et = getEntityTransaction();
- client2.setEntityManager(em);
- client2.setEntityTransaction(et);
- client2.setInContainer(true);
- }
-
- if (testObj instanceof UseEntityManagerFactory) {
-
- if (emf == null) {
- throw new IllegalStateException("EntityManagerFactory is null");
- }
- UseEntityManagerFactory client2 = (UseEntityManagerFactory) testObj;
- client2.setEntityManagerFactory(emf);
- }
-
- sTestStatus = new RemoteStatus(testObj.run(arguments, properties));
-
- if (sTestStatus.getType() == Status.PASSED) {
- System.out.println("Test running in pmservlet vehicle passed");
- } else {
- System.out.println("Test running in pmservlet vehicle failed");
- }
- } catch (Throwable e) {
- StringBuilder sb = new StringBuilder();
- sb.append("Test running in pmservlet vehicle failed: ");
- StringWriter sw = new StringWriter();
- e.printStackTrace(new PrintWriter(sw));
- sb.append(sw.toString());
- sTestStatus = new RemoteStatus(Status.failed(sb.toString()));
- TestUtil.logErr("Test running in pmservlet vehicle failed", e);
- }
-
- return sTestStatus;
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/vehicle/puservlet/PUServletVehicle.java b/common/src/main/java/com/sun/ts/tests/common/vehicle/puservlet/PUServletVehicle.java
deleted file mode 100644
index 2f69de3ae2..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/vehicle/puservlet/PUServletVehicle.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-package com.sun.ts.tests.common.vehicle.puservlet;
-
-import com.sun.ts.lib.harness.Status;
-import com.sun.ts.lib.harness.RemoteStatus;
-import com.sun.ts.tests.common.vehicle.ejb3share.UseEntityManager;
-import com.sun.ts.tests.common.vehicle.ejb3share.UseEntityManagerFactory;
-import com.sun.ts.tests.common.vehicle.servlet.ServletVehicle;
-
-import jakarta.persistence.EntityManager;
-import jakarta.persistence.EntityManagerFactory;
-import jakarta.persistence.EntityTransaction;
-import jakarta.persistence.PersistenceUnit;
-
-public class PUServletVehicle extends ServletVehicle {
-
- @PersistenceUnit(unitName = "CTS-EM-NOTX")
- EntityManagerFactory emf;
-
- protected RemoteStatus runTest() {
- RemoteStatus sTestStatus = new RemoteStatus(Status.passed(""));
- properties.put("persistence.unit.name", "CTS-EM-NOTX");
-
- EntityManager em = null;
- try {
- // call EETest impl's run method
- if (testObj instanceof UseEntityManager) {
- em = emf.createEntityManager();
- if (em == null) {
- throw new IllegalStateException("EntityManager is null");
- }
- UseEntityManager client2 = (UseEntityManager) testObj;
- EntityTransaction et = em.getTransaction();
- client2.setEntityManager(em);
- client2.setEntityTransaction(et);
- client2.setInContainer(true);
- }
-
- if (testObj instanceof UseEntityManagerFactory) {
- if (emf == null) {
- throw new IllegalStateException("EntityManagerFactory is null");
- }
- UseEntityManagerFactory client2 = (UseEntityManagerFactory) testObj;
- client2.setEntityManagerFactory(emf);
- }
-
- sTestStatus = new RemoteStatus(testObj.run(arguments, properties));
-
- if (sTestStatus.getType() == Status.PASSED) {
- System.out
- .println("Test running in PersistenceUnit servlet vehicle passed");
- } else {
- System.out
- .println("Test running in PersistenceUnit servlet vehicle failed");
- }
- } catch (Throwable e) {
- sTestStatus = new RemoteStatus(Status
- .failed("Test running in PersistenceUnit servlet vehicle failed"));
- e.printStackTrace();
- } finally {
- if (em != null) {
- if (em.isOpen())
- em.close();
- }
- }
-
- return sTestStatus;
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/vehicle/stateful3/Stateful3VehicleBean.java b/common/src/main/java/com/sun/ts/tests/common/vehicle/stateful3/Stateful3VehicleBean.java
deleted file mode 100644
index af4abdacc7..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/vehicle/stateful3/Stateful3VehicleBean.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.vehicle.stateful3;
-
-import java.util.Properties;
-
-import com.sun.ts.lib.harness.RemoteStatus;
-import com.sun.ts.tests.common.vehicle.ejb3share.NoopTransactionWrapper;
-
-import jakarta.annotation.PostConstruct;
-import jakarta.annotation.Resource;
-import jakarta.ejb.Remote;
-import jakarta.ejb.Remove;
-import jakarta.ejb.SessionContext;
-import jakarta.ejb.Stateful;
-import jakarta.persistence.EntityManager;
-import jakarta.persistence.EntityManagerFactory;
-import jakarta.persistence.EntityTransaction;
-import jakarta.persistence.PersistenceContext;
-import jakarta.persistence.PersistenceUnit;
-
-@Stateful(name = "Stateful3VehicleBean")
-@Remote({ Stateful3VehicleIF.class })
-public class Stateful3VehicleBean
- extends com.sun.ts.tests.common.vehicle.ejb3share.EJB3ShareBaseBean
- implements Stateful3VehicleIF, java.io.Serializable {
-
- @PersistenceUnit(name = "STATEFUL3EMF", unitName = "CTS-EM")
- EntityManagerFactory emf;
-
- public Stateful3VehicleBean() {
- super();
- }
-
- protected String getVehicleType() {
- return STATEFUL3;
- }
-
- @PostConstruct
- public void init() {
- try {
- System.out.println("In PostContruct");
- EntityManagerFactory emf = (EntityManagerFactory) sessionContext
- .lookup("STATEFUL3EMF");
- setEntityManagerFactory(emf);
- } catch (Exception e) {
- System.out.println("ERROR: "
- + " In PostConstruct: Exception caught while setting EntityManagerFactory");
- e.printStackTrace();
- }
- }
-
- // ================== business methods ====================================
- @Remove
- public RemoteStatus runTest(String[] args, Properties props) {
- RemoteStatus retValue;
- props.put("persistence.unit.name", "CTS-EM");
- retValue = super.runTest(args, props);
- return retValue;
- }
- /////////////////////////////////////////////////////////////////////////
-
- @Resource
- public void setSessionContext(SessionContext sessionContext) {
- this.sessionContext = sessionContext;
- }
-
- @PersistenceContext(unitName = "CTS-EM")
- public void setEntityManager(EntityManager entityManager) {
- this.entityManager = entityManager;
- }
-
- public void setEntityManagerFactory(EntityManagerFactory emf) {
- this.entityManagerFactory = emf;
- }
-
- protected EntityTransaction getEntityTransaction() {
- return new NoopTransactionWrapper();
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/vehicle/web/WebVehicleRunner.java b/common/src/main/java/com/sun/ts/tests/common/vehicle/web/WebVehicleRunner.java
deleted file mode 100644
index 40e588d28d..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/vehicle/web/WebVehicleRunner.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.vehicle.web;
-
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.Properties;
-
-import com.sun.ts.lib.harness.Status;
-import com.sun.ts.lib.harness.RemoteStatus;
-import com.sun.ts.lib.porting.TSURL;
-import com.sun.ts.lib.util.TestUtil;
-import com.sun.ts.tests.common.vehicle.VehicleRunnable;
-
-public class WebVehicleRunner implements VehicleRunnable {
-
- protected String sVehicle = "";
-
- protected Status sTestStatus = Status.passed("");
-
- String urlSuffix = "";
-
- Status sServletStatus = Status.passed("");
-
- Status sJspStatus = Status.passed("");
-
- String sVehicleArchiveName = "";
-
- String contextRootPrefix;
-
- String[] argv;
-
- Properties p;
-
- public Status run(String[] argv, Properties p) {
- this.argv = argv;
- this.p = p;
- sVehicle = TestUtil.getProperty(p, "vehicle");
-
- // use this name for the context root or jndi name to eliminate
- // naming conflicts for apps deployed at the same time
- sVehicleArchiveName = TestUtil.getProperty(p, "vehicle_archive_name");
-
- if (sVehicleArchiveName.indexOf("_vehicles") != -1) {
- contextRootPrefix = sVehicleArchiveName.substring(0,
- sVehicleArchiveName.indexOf("_vehicles") + 1) + sVehicle
- + "_vehicle_web";
- } else {
- if (sVehicleArchiveName.endsWith("_web")) {
- contextRootPrefix = sVehicleArchiveName;
- } else {
- contextRootPrefix = sVehicleArchiveName + "_web";
- }
- }
-
- // default urlSuffix
- urlSuffix = "/" + contextRootPrefix + "/" + sVehicle + "_vehicle";
-
- return run();
- }// run
-
- protected Status run() {
- if (sVehicle.equalsIgnoreCase("web")) {
- // run in a servlet
- urlSuffix = "/" + contextRootPrefix + "/servlet_vehicle";
- sServletStatus = runWebVehicleTest("servlet");
-
- // run in a Jsp
- urlSuffix = "/" + contextRootPrefix + "/jsp_vehicle";
- sJspStatus = runWebVehicleTest("jsp");
-
- TestUtil.logMsg("Test: returning from running in web vehicles");
- }
-
- if (sServletStatus.isPassed() && sJspStatus.isPassed()) {
- sTestStatus = Status.passed("Test passed in a servlet and in a jsp");
- } else if (sServletStatus.isFailed() && sServletStatus.isFailed()) {
- sTestStatus = Status.failed("Test failed in a servlet and in a jsp");
- } else if (sJspStatus.isFailed()) {
- sTestStatus = Status
- .failed("Test passed in a jsp but failed in a servlet");
- } else {
- sTestStatus = Status
- .failed("Test passed in a servlet but failed in a jsp");
- }
- return sTestStatus;
- }
-
- protected Status runWebVehicleTest(String vehicle) {
- URLConnection connection = null;
- URL url = null;
- ObjectOutputStream objOut = null;
- ObjectInputStream objIn = null;
- Status status;
-
- try {
- if (vehicle.indexOf("jsp") != -1) {
- urlSuffix += ".jsp";
- }
-
- TSURL ctsURL = new TSURL();
- url = ctsURL.getURL("http", TestUtil.getProperty(p, "webServerHost"),
- Integer.parseInt(TestUtil.getProperty(p, "webServerPort")), urlSuffix);
- connection = url.openConnection();
- TestUtil.logMsg("Opened connection to " + url);
- connection.setDoOutput(true);
- connection.setDoInput(true);
- connection.setUseCaches(false);
- connection.setRequestProperty("Content-Type",
- "java-internal/" + p.getClass().getName());
- // connection.connect();
- objOut = new ObjectOutputStream(connection.getOutputStream());
- TestUtil.logTrace("got outputstream");
- objOut.writeObject(p);
- objOut.writeObject(argv);
- TestUtil.logTrace("wrote objects to the " + vehicle + " vehicle");
- objOut.flush();
- objOut.close();
- objOut = null;
-
- // read the status when it comes back
- if (vehicle.indexOf("jsp") != -1) {
- Properties sprop = TestUtil.getResponseProperties(connection);
- int type = Integer.parseInt(TestUtil.getProperty(sprop, "type"));
- String reason = TestUtil.getProperty(sprop, "reason");
- status = new Status(type, reason);
- } else {
- objIn = new ObjectInputStream(connection.getInputStream());
- status = ((RemoteStatus) objIn.readObject()).toStatus();
- }
- TestUtil.logMsg("Test status from a " + vehicle + ": " + status.getType()
- + ":" + status.getReason());
-
- } catch (MalformedURLException e) {
- e.printStackTrace();
- status = Status.failed("Fatal: Improper URL");
- } catch (NumberFormatException e) {
- e.printStackTrace();
- status = Status.failed(
- "Please set an appropriate value for the property: webServerPort");
- } catch (IOException e) {
- e.printStackTrace();
- status = Status.failed("Fatal: Problem with connection: " + e);
- } catch (Exception e) {
- e.printStackTrace();
- status = Status.failed(
- "ServiceTest failed inside a " + vehicle + ": " + e.getMessage());
- } finally {
-
- if (objOut != null) {
- try {
- objOut.close();
- } catch (Exception e) {
- }
- }
-
- if (objIn != null) {
- try {
- objIn.close();
- } catch (Exception e) {
- }
- }
- }
- return status;
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/web/ServletWrapper.java b/common/src/main/java/com/sun/ts/tests/common/web/ServletWrapper.java
deleted file mode 100644
index 36958f51ce..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/web/ServletWrapper.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.web;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.Properties;
-
-import com.sun.ts.lib.util.TSNamingContext;
-
-import jakarta.servlet.ServletConfig;
-import jakarta.servlet.ServletException;
-import jakarta.servlet.http.HttpServlet;
-import jakarta.servlet.http.HttpServletRequest;
-import jakarta.servlet.http.HttpServletResponse;
-
-/**
- * Provide a testing framework for a Servlet test.
- *
- * This class is intended to be extended by the actual Servlet test class that
- * will define one or more test methods. This is why this class is tagged
- * "abstract".
- *
- * This class shield the final Servlet class from Servlet life cycle and
- * specific testing framework.
- *
- * @see com.sun.ts.tests.common.web.WebServer
- */
-public abstract class ServletWrapper extends HttpServlet {
-
- /** Name of property used to send back test result to client */
- public static final String RESULT_PROP = "ctsWebTestResult";
-
- public static final String TEST_NAME_PROP = "ctsWebTestName";
-
- protected static TSNamingContext nctx = null;
-
- private Properties servletProps = null;
-
- public void init(ServletConfig config) throws ServletException {
- super.init(config);
-
- try {
- WebUtil.logTrace("[ServletWrapper] init()");
- WebUtil.logTrace("[ServletWrapper] Getting naming ctx...");
- nctx = new TSNamingContext();
- } catch (Exception e) {
- WebUtil.logErr("[ServletWrapper] Cannot get Naming ctx", e);
- throw new ServletException("Cannot initialize Servlet");
- }
- }
-
- public void doGet(HttpServletRequest req, HttpServletResponse res)
- throws ServletException, IOException {
-
- PrintWriter out = null;
-
- try {
- WebUtil.logTrace("[ServletWrapper] doGet()");
- res.setContentType("text/plain");
- out = res.getWriter();
- servletProps.list(out);
- } catch (Exception e) {
- WebUtil.logErr("[ServletWrapper] Exception in doGet()", e);
- if (null != out) {
- e.printStackTrace(out);
- }
- } finally {
- if (null != out) {
- out.close();
- }
- }
- }
-
- public void doPost(HttpServletRequest req, HttpServletResponse res)
- throws ServletException, IOException {
-
- WebUtil.logTrace("[ServletWrapper] doPost()");
- servletProps = WebUtil.executeTest(this, req);
- doGet(req, res);
- servletProps = null;
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/web/WebServer.java b/common/src/main/java/com/sun/ts/tests/common/web/WebServer.java
deleted file mode 100644
index f7281c5412..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/web/WebServer.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.web;
-
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.Properties;
-
-import com.sun.ts.lib.porting.TSURL;
-import com.sun.ts.lib.util.TestUtil;
-
-/**
- * Facade class to ease client access to a TS test deployed in the Web
- * container. Shield clients from underlying TS and HTPP indiosyncrasies.
- */
-public class WebServer {
-
- protected static final String PROTOCOL = "http";
-
- protected static final String WEB_HOST_PROP = "webServerHost";
-
- protected static final String WEB_PORT_PROP = "webServerPort";
-
- protected static final String RESULT_PROP = "ctsWebTestResult";
-
- protected static final String TEST_NAME_PROP = "ctsWebTestName";
-
- protected String host;
-
- protected int port;
-
- protected URL url;
-
- protected URLConnection conn;
-
- protected Properties props;
-
- /** Constructor */
- private WebServer(String hostName, int portNumber, Properties p)
- throws IllegalArgumentException {
-
- if (null == hostName) {
- throw new IllegalArgumentException("null host name!");
- }
-
- this.host = hostName;
- this.port = portNumber;
- this.props = p;
- }
-
- /**
- * Factory method to build a WebServer object from TS props parsing relevant
- * properties.
- */
- public static WebServer newInstance(Properties props)
- throws IllegalArgumentException {
-
- String host;
- String portValue;
- String msg;
- int port;
-
- if (null == props) {
- msg = "null properties!";
- TestUtil.logErr("[TSTestURL] " + msg);
- throw new IllegalArgumentException(msg);
- }
-
- host = TestUtil.getProperty(props, WEB_HOST_PROP);
- if (null == host || host.equals("")) {
- msg = "Empty " + WEB_HOST_PROP + " property: " + host;
- printConfigError(msg);
- throw new IllegalArgumentException(msg);
- }
-
- portValue = TestUtil.getProperty(props, WEB_PORT_PROP);
- if (null == portValue || portValue.equals("")) {
- msg = "Empty " + WEB_PORT_PROP + " property: " + portValue;
- printConfigError(msg);
- throw new IllegalArgumentException(msg);
- }
-
- try {
- port = Integer.parseInt(portValue);
- } catch (Exception e) {
- msg = "Invalid " + WEB_PORT_PROP + " property: '" + portValue + "' : "
- + e.getMessage();
- printConfigError(msg);
- throw new IllegalArgumentException(msg);
- }
-
- return new WebServer(host, port, props);
- }
-
- /**
- * Call test 'testName' in web component deployed as 'webFile'.
- *
- * @param webFile
- * file component (see java.net.URL) of the url the web component
- * mapped to.
- *
- * @param testName
- * Name of the test to run in this web component.
- *
- * @return true if test pass. false otherwise.
- */
- public boolean test(String webFile, String testName) {
- return (null != call(webFile, testName, this.props));
- }
-
- /**
- * Call test 'testName' in web component deployed as 'webFile', passing 'args'
- * as input parameters.
- *
- * @param webFile
- * file component (see java.net.URL) of the url the web component
- * mapped to.
- *
- * @param testName
- * Name of the test to run in this web component.
- *
- * @param args
- * input parameters in a Properties object. This object need at least
- * to have valid TS harness logging properties;
- *
- * @return output parameters in a Properties object. Return null if a problem
- * occured or test failed.
- */
- public Properties call(String webFile, String testName, Properties args)
- throws IllegalArgumentException {
-
- URL url;
- String status;
- Properties results;
-
- if (null == args) {
- throw new IllegalArgumentException("null args!");
- }
-
- try {
- args.setProperty(TEST_NAME_PROP, testName);
-
- url = (new TSURL()).getURL(PROTOCOL, host, port, webFile);
- conn = TestUtil.sendPostData(args, url);
- TestUtil
- .logMsg("Getting response from url connection: " + url.toString());
-
- results = TestUtil.getResponseProperties(conn);
- if (null == results) {
- TestUtil.logErr("[TSTestURL] null response props!");
- return null;
- }
-
- // Too verbose - TestUtil.list(results);
-
- /* Check whether test passed, return null if test failed */
- status = results.getProperty(RESULT_PROP);
- if (!(Boolean.valueOf(status).booleanValue())) {
- return null;
- }
- } catch (Exception e) {
- TestUtil.logErr("Caught exception: " + e.getMessage());
- e.printStackTrace();
- return null;
- }
-
- return results;
- }
-
- /** Convenience method to print TS configuration error messages */
- protected static void printConfigError(String msg) {
- TestUtil.logErr("[TSTestURL] " + msg);
- TestUtil.logErr(
- "Please check you that " + WEB_HOST_PROP + " and " + WEB_PORT_PROP
- + " properties are set correctly " + "in you ts.jte file");
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/web/WebUtil.java b/common/src/main/java/com/sun/ts/tests/common/web/WebUtil.java
deleted file mode 100644
index f7d0ca5ac9..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/web/WebUtil.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.web;
-
-import java.lang.reflect.Method;
-import java.util.Enumeration;
-import java.util.Properties;
-
-import com.sun.ts.lib.util.TSNamingContext;
-import com.sun.ts.lib.util.TestUtil;
-
-import jakarta.servlet.ServletException;
-import jakarta.servlet.http.HttpServletRequest;
-
-/**
- * Factorize code used by JSP and Servlets.
- *
- * @see com.sun.ts.tests.common.web.ServletWrapper
- * @see com.sun.ts.common.util.TestUtil
- */
-public class WebUtil {
-
- /** Name of property used to send back test result to client */
- public static final String RESULT_PROP = "ctsWebTestResult";
-
- /** Name of the property used to get the test method name */
- public static final String TEST_NAME_PROP = "ctsWebTestName";
-
- public static void logMsg(String msg) {
- TestUtil.logMsg(msg);
- System.out.println(msg);
- }
-
- public static void logTrace(String msg) {
- TestUtil.logTrace(msg);
- System.out.println(msg);
- }
-
- public static void logErr(String msg) {
- TestUtil.logErr(msg);
- System.out.println(msg);
- }
-
- public static void logErr(String msg, Exception e) {
- TestUtil.logErr(msg, e);
- System.out.println(msg + " : " + e);
- e.printStackTrace();
- }
-
- /**
- * Use information provided in a HTTPRequest to execute a test method on a
- * testDriver object. The test method is "discovered" at runtime using the
- * reflection API. The testDriver could be any java object.
- */
- public static Properties executeTest(Object testDriver, HttpServletRequest req) throws ServletException {
-
- Boolean pass = Boolean.FALSE;
- Properties webProps = null;
- Class testDriverClass;
- String testName;
- Method testMethod;
- Class params[] = { Properties.class };
- Object args[] = new Object[1];
-
- logTrace("[WebUtil] executeTestOnInstance()");
-
- /*
- * Get harness properties and initialize logging.
- */
- try {
- logTrace("[WebUtil] Retrieving harness props...");
-
- webProps = new Properties();
- Enumeration names = req.getParameterNames();
- while (names.hasMoreElements()) {
- String name = (String) names.nextElement();
- String value = req.getParameter(name);
- webProps.setProperty(name, value);
- }
-
- logTrace("[WebUtil] Initializing Remote Logging...");
- TestUtil.init(webProps);
- } catch (Exception e) {
- System.out.println("Exception: " + e);
- e.printStackTrace();
- throw new ServletException("Cannot Initialize CST Logging");
- }
-
- /*
- * Get name of the test method.
- */
- try {
- logTrace("[WebUtil] Getting test name...");
- testName = TestUtil.getProperty(webProps, TEST_NAME_PROP);
- } catch (Exception e) {
- logErr("[WebUtil] Unexpected exception", e);
- throw new ServletException("Cannot get test name");
- }
- if (null == testName || testName.equals("")) {
- logErr("[WebUtil] Invalid test name : " + testName);
- throw new ServletException("Invalid test name");
- }
-
- /*
- * Invoke test method on current instance.
- */
- try {
- logTrace("[WebUtil] Invoke test '" + testName + "'");
- testDriverClass = testDriver.getClass();
- testMethod = testDriverClass.getMethod(testName, params);
- args[0] = webProps;
- pass = (Boolean) testMethod.invoke(testDriver, args);
- } catch (NoSuchMethodException e) {
- logErr("[WebUtil] Cannot find method '" + testName
- + "' make sure it is defined in sub-class", e);
- throw new ServletException("Test method is not defined");
- } catch (java.lang.reflect.InvocationTargetException e) {
- logErr("[WebUtil] InvocationTargetException '" + testName + "' caused by "
- + e.getTargetException());
- throw new ServletException("Test method is not defined");
- } catch (Exception e) {
- logErr("[WebUtil] Unexpected exception", e);
- throw new ServletException("Cannot Invoke test method");
- }
-
- /*
- * Set test result and send all properties back to client.
- */
- webProps.setProperty(RESULT_PROP, pass.toString());
-
- return webProps;
- }
-
- /**
- * Convert Java Properties to a String, as expected by on the client side
- * (WebServer)
- */
- public static String propsToString(Properties props) {
- StringBuffer sb = new StringBuffer(1000);
- Enumeration keys;
- String name;
-
- if (null == props) {
- throw new IllegalArgumentException("null props!");
- }
-
- keys = props.keys();
- while (keys.hasMoreElements()) {
- name = (String) keys.nextElement();
- sb.append(name + "=" + props.getProperty(name) + "\n");
- }
-
- return sb.toString();
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/webclient/BaseUrlClient.java b/common/src/main/java/com/sun/ts/tests/common/webclient/BaseUrlClient.java
deleted file mode 100644
index 634153d1f9..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/webclient/BaseUrlClient.java
+++ /dev/null
@@ -1,602 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.webclient;
-
-import java.util.Enumeration;
-import java.util.Properties;
-import java.util.logging.Logger;
-import java.util.logging.Level;
-
-import com.sun.ts.lib.harness.Status;
-import com.sun.ts.lib.harness.EETest;
-import com.sun.ts.lib.util.TestUtil;
-import org.apache.commons.httpclient.HttpState;
-
-import com.sun.ts.tests.common.webclient.http.HttpRequest;
-
-/**
- *
- * Provides base test initialization and runtime
- * logic into a common class.
- * All test areas will need to extend this class
- * to provided area specific functionality needed for
- * that particular technology.
- *
- */
-public abstract class BaseUrlClient extends EETest {
- private static final Logger LOGGER = Logger.getLogger(BaseUrlClient.class.getName());
-
- /**
- * Properties parameters
- */
- public Properties _props;
-
- /**
- * 401 - Unauthorized
- */
- protected static final String UNAUTHORIZED = "401";
-
- /**
- * 403 - Forbidden
- */
- protected static final String FORBIDDEN = "403";
-
- /**
- * 404 - not found
- */
- protected static final String NOT_FOUND = "404";
-
- /**
- * 200 - ok
- */
- protected static final String OK = "200";
-
- /**
- * 201 - created
- */
- protected static final String CREATED = "201";
-
- /**
- * 500 - internal server error
- */
- protected static final String INTERNAL_SERVER_ERROR = "500";
-
- /**
- * 503 - service unavailable
- */
- protected static final String SERVICE_UNAVAILABLE = "503";
-
- /**
- * 100 - continue
- */
- protected static final String CONTINUE = "100";
-
- /**
- * 302 - moved temporarily
- */
- protected static final String MOVED_TEMPORARY = "302";
-
- /**
- * 410 - GONE
- */
- protected static final String GONE = "410";
-
- /**
- * 411 - length required
- */
- protected static final String LENGTH_REQUIRED = "411";
-
- /**
- * TS Webserver host property
- */
- protected static final String SERVLETHOSTPROP = "webServerHost";
-
- /**
- * TS Webserver port property
- */
- protected static final String SERVLETPORTPROP = "webServerPort";
-
- /**
- * TS home property
- */
- protected static final String TSHOME = "ts_home";
-
- /**
- * Test properties
- */
- protected static final Properties TEST_PROPS = new Properties();
-
- /**
- * StatusCode property
- */
- protected static final String STATUS_CODE = "status-code";
-
- /**
- * Reason-Phrase property
- */
- protected static final String REASON_PHRASE = "reason-phrase";
-
- /**
- * Expected headers property
- */
- protected static final String EXPECTED_HEADERS = "expected_headers";
-
- /**
- * Unexpected header property
- */
- protected static final String UNEXPECTED_HEADERS = "unexpected_headers";
-
- /**
- * Expect response body property
- */
- protected static final String EXPECT_RESPONSE_BODY = "expect_response_body";
-
- /**
- * Request property
- */
- protected static final String REQUEST = "request";
-
- /**
- * Request headers property
- */
- protected static final String REQUEST_HEADERS = "request_headers";
-
- /**
- * Goldenfile property
- */
- protected static final String GOLDENFILE = "goldenfile";
-
- /**
- * Search string property
- */
- protected static final String SEARCH_STRING = "search_string";
-
- /**
- * Search string case insensitive property
- */
- protected static final String SEARCH_STRING_IGNORE_CASE = "search_string_ignore_case";
-
- /**
- * Basic Auth username
- */
- protected static final String BASIC_AUTH_USER = "basic_auth_user";
-
- /**
- * Basic Auth password
- */
- protected static final String BASIC_AUTH_PASSWD = "basic_auth_passwd";
-
- /**
- * Basic Auth realm
- */
- protected static final String BASIC_AUTH_REALM = "basic_auth_realm";
-
- /**
- * Unordered search string property
- */
- protected static final String UNORDERED_SEARCH_STRING = "unordered_search_string";
-
- /**
- * Content property
- */
- protected static final String CONTENT = "content";
-
- /**
- * Test name property
- */
- protected static final String TEST_NAME = "testname";
-
- /**
- * Response Match property
- */
- protected static final String RESPONSE_MATCH = "response_match";
-
- /**
- * Unexpected response match property
- */
- protected static final String UNEXPECTED_RESPONSE_MATCH = "unexpected_response_match";
-
- /**
- * Standard test property
- */
- protected static final String STANDARD = "standard";
-
- /**
- * Ignore response body
- */
- protected static final String IGNORE_BODY = "ignore_body";
-
- /**
- * Validation strategy
- */
- protected static final String STRATEGY = "strategy";
-
- /**
- * Current test directory
- */
- protected String TESTDIR = null;
-
- /**
- * Goldenfile directory
- */
- protected String GOLDENFILEDIR = "/src/web";
-
- /**
- * Default request method
- */
- protected static final String GET = "GET ";
-
- /**
- * HTTP 1.0
- */
- protected static final String HTTP10 = " HTTP/1.0";
-
- /**
- * HTTP 1.1
- */
- protected static final String HTTP11 = " HTTP/1.1";
-
- /**
- * Forward slash
- */
- protected static final String SL = "/";
-
- /**
- * Goldenfile suffix
- */
- protected static final String GF_SUFFIX = ".gf";
-
- /**
- * JSP suffix
- */
- protected static final String JSP_SUFFIX = ".jsp";
-
- /**
- * Use any saved state
- */
- protected static final String USE_SAVED_STATE = "use_saved_state";
-
- /**
- * Save current HTTP state.
- */
- protected static final String SAVE_STATE = "save_state";
-
- /**
- * Ignore HTTP status codes
- */
- protected static final String IGNORE_STATUS_CODE = "ignore_status_code";
-
- /**
- * Current test name
- */
- protected String _testName = null;
-
- /**
- * location of _tsHome
- */
- protected String _tsHome = null;
-
- /**
- * Context root of target tests
- */
- protected String _contextRoot = null;
-
- /**
- * General file/request URI for both gfiles and tests
- */
- protected String _generalURI = null;
-
- /**
- * Target webserver hostname
- */
- protected String _hostname = null;
-
- /**
- * Target webserver port
- */
- protected int _port = 0;
-
- /**
- * HttpState that may be used for multiple invocations requiring state.
- */
- protected HttpState _state = null;
-
- /**
- * Test case.
- */
- protected WebTestCase _testCase = null;
-
- /**
- * Use saved state.
- */
- protected boolean _useSavedState = false;
-
- /**
- * Save state.
- */
- protected boolean _saveState = false;
-
- /**
- * Follow redirect.
- */
- protected String FOLLOW_REDIRECT = "follow_redirect";
-
- protected boolean _redirect = false;
-
- /*
- * public methods
- * ========================================================================
- */
-
- /**
- * setTestDir sets the current test directory.
- *
- * @param testDir
- * a String value
- */
- public void setTestDir(String testDir) {
- TESTDIR = testDir;
- // setGoldenFileDir(testDir);
- }
-
- public void setGeneralURI(String URI) {
- _generalURI = URI;
- }
-
- public void setContextRoot(String root) {
- _contextRoot = root;
- }
-
- public String getContextRoot() {
- return _contextRoot;
- }
-
- /**
- * Sets the goldenfile directory
- *
- * @param goldenDir
- * goldenfile directory based off test directory
- */
- public void setGoldenFileDir(String goldenDir) {
- GOLDENFILEDIR = goldenDir;
- }
-
- /**
- * setup is by the test harness to initialize the tests.
- *
- * @param args
- * a String[] value
- * @param p
- * a Properties value
- */
- public void setup(String[] args, Properties p) throws Exception {
- _props = p;
- String hostname = TestUtil.getProperty(p, SERVLETHOSTPROP).trim();
- String portnum = TestUtil.getProperty(p, SERVLETPORTPROP).trim();
- String tshome = TestUtil.getProperty(p, TSHOME).trim();
-
- if (!isNullOrEmpty(hostname)) {
- _hostname = hostname;
- } else {
- throw new Exception(
- "[BaseUrlClient] 'webServerHost' was not set in the" + " ts.jte.");
- }
-
- if (!isNullOrEmpty(portnum)) {
- _port = Integer.parseInt(portnum);
- } else {
- throw new Exception(
- "[BaseUrlClient] 'webServerPort' was not set in the" + " ts.jte.");
- }
-
- if (!isNullOrEmpty(tshome)) {
- _tsHome = tshome;
- } else {
- throw new Exception(
- "[BaseUrlClient] 'tshome' was not set in the " + " ts.jte.");
- }
-
- TestUtil.logMsg("[BaseUrlClient] Test setup OK");
- }
-
- /**
- * cleanup is called by the test harness to cleanup after text
- * execution
- *
- */
- public void cleanup() throws Exception {
- TestUtil.logMsg( "[BaseUrlClient] Test cleanup OK");
- }
-
- /*
- * protected methods
- * ========================================================================
- */
-
- /**
- *
- * Invokes a test based on the properties
- * stored in TEST_PROPS. Once the test has completed,
- * the properties in TEST_PROPS will be cleared.
- *
- *
- * @throws Exception
- * If an error occurs during the test run
- */
- protected void invoke() throws Exception {
- try {
- _testCase = new WebTestCase();
- setTestProperties(_testCase);
- TestUtil.logTrace("[BaseUrlClient] EXECUTING");
- LOGGER.fine("[BaseUrlClient] EXECUTING");
- if (_useSavedState && _state != null) {
- _testCase.getRequest().setState(_state);
- }
- if (_redirect != false) {
- TestUtil.logTrace("##########Call setFollowRedirects");
- LOGGER.fine("##########Call setFollowRedirects");
- _testCase.getRequest().setFollowRedirects(_redirect);
- }
- _testCase.execute();
- TestUtil.logMsg(_testCase.getResponse().getResponseBodyAsString());
- if (_saveState) {
- _state = _testCase.getResponse().getState();
- }
- } catch (TestFailureException tfe) {
- Throwable t = tfe.getRootCause();
- if (t != null) {
- TestUtil.logErr("Root cause of Failure: " + t.getMessage(), t);
- LOGGER.log(Level.WARNING, "Root cause of Failure: " + t.getMessage(), t);
- }
- throw new Exception("[BaseUrlClient] " + _testName
- + " failed! Check output for cause of failure.", tfe);
- } finally {
- _useSavedState = false;
- _saveState = false;
- _redirect = false;
- clearTestProperties();
- }
- }
-
- /**
- *
- * Sets the appropriate test properties based
- * on the values stored in TEST_PROPS
- *
- */
- protected void setTestProperties(WebTestCase testCase) {
- HttpRequest req = testCase.getRequest();
-
- // Check for a request object. If doesn't exist, then
- // check for a REQUEST property and create the request object.
-
- if (req == null) {
- String request = TEST_PROPS.getProperty(REQUEST);
-
- if (request.startsWith("GET") || request.startsWith("POST")
- || request.startsWith("OPTIONS") || request.startsWith("PUT")
- || request.startsWith("DELETE") || request.startsWith("HEAD")
- || request.endsWith(HTTP10) || request.endsWith(HTTP11)) {
- // user has overriden default request behavior
- req = new HttpRequest(request, _hostname, _port);
- testCase.setRequest(req);
- } else {
- req = new HttpRequest(getTSRequest(request), _hostname, _port);
- testCase.setRequest(req);
- }
- }
-
- String key = null;
- String value = null;
- // proces the remainder of the properties
- for (Enumeration e = TEST_PROPS.propertyNames(); e.hasMoreElements();) {
- key = (String) e.nextElement();
- value = TEST_PROPS.getProperty(key);
-
- if (key.equals(STATUS_CODE)) {
- testCase.setExpectedStatusCode(value);
- } else if (key.equals(IGNORE_STATUS_CODE)) {
- testCase.setExpectedStatusCode("-1");
- } else if (key.equals(REASON_PHRASE)) {
- testCase.setExpectedReasonPhrase(value);
- } else if (key.equals(EXPECTED_HEADERS)) {
- testCase.addExpectedHeader(value);
- } else if (key.equals(UNEXPECTED_HEADERS)) {
- testCase.addUnexpectedHeader(value);
- } else if (key.equals(SEARCH_STRING)) {
- testCase.setResponseSearchString(value);
- } else if (key.equals(SEARCH_STRING_IGNORE_CASE)) {
- testCase.setResponseSearchStringIgnoreCase(value);
- } else if (key.equals(STRATEGY)) {
- testCase.setStrategy(value);
- } else if (key.equals(GOLDENFILE)) {
- StringBuffer sb = new StringBuffer(50);
- sb.append(_tsHome).append(GOLDENFILEDIR);
- sb.append(_generalURI).append(SL);
- sb.append(value);
- testCase.setGoldenFilePath(sb.toString());
- } else if (key.equals(CONTENT)) {
- req.setContent(value);
- } else if (key.equals(TEST_NAME)) {
- // testName = TEST_PROPS.getProperty(key);
- } else if (key.equals(RESPONSE_MATCH)) {
- // setResponseMatch(TEST_PROPS.getProperty(key));
- } else if (key.equals(REQUEST_HEADERS)) {
- req.addRequestHeader(TEST_PROPS.getProperty(key));
- } else if (key.equals(EXPECT_RESPONSE_BODY)) {
- // FIXME
- // setExpectResponseBody(false);
- } else if (key.equals(IGNORE_BODY)) {
- // FIXME
- // setIgnoreResponseBody(true);
- testCase.setGoldenFilePath(null);
- } else if (key.equals(UNEXPECTED_RESPONSE_MATCH)) {
- testCase.setUnexpectedResponseSearchString(value);
- } else if (key.equals(UNORDERED_SEARCH_STRING)) {
- testCase.setUnorderedSearchString(value);
- } else if (key.equals(USE_SAVED_STATE)) {
- _useSavedState = true;
- } else if (key.equals(SAVE_STATE)) {
- _saveState = true;
- } else if (key.equals(FOLLOW_REDIRECT)) {
- LOGGER.fine("##########Found redirect Property");
- _redirect = true;
- } else if (key.equals(BASIC_AUTH_USER) || key.equals(BASIC_AUTH_PASSWD)
- || key.equals(BASIC_AUTH_REALM)) {
-
- String user = TEST_PROPS.getProperty(BASIC_AUTH_USER);
- String password = TEST_PROPS.getProperty(BASIC_AUTH_PASSWD);
- String realm = TEST_PROPS.getProperty(BASIC_AUTH_REALM);
- req.setAuthenticationCredentials(user, password,
- HttpRequest.BASIC_AUTHENTICATION, realm);
- }
- }
- }
-
- /*
- * private methods
- * ========================================================================
- */
-
- private String getTSRequest(String request) {
- StringBuffer finReq = new StringBuffer(50);
-
- finReq.append(GET).append(_contextRoot).append(SL).append(_generalURI);
- finReq.append(SL).append(request).append(HTTP10);
-
- return finReq.toString();
- }
-
- /**
- * Clears the contents of TEST_PROPS
- */
- private void clearTestProperties() {
- TEST_PROPS.clear();
- }
-
- private boolean isNullOrEmpty(String val) {
- if (val == null || val.equals("")) {
- return true;
- }
- return false;
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/webclient/Goldenfile.java b/common/src/main/java/com/sun/ts/tests/common/webclient/Goldenfile.java
deleted file mode 100644
index bdad8c2f5c..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/webclient/Goldenfile.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.webclient;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-import com.sun.ts.lib.util.TestUtil;
-
-/**
- * A representation of a Goldenfile that may be used by a particular test case.
- */
-
-public class Goldenfile {
-
- /*
- * Message to be returned if the goldenfile cannot be located.
- */
- private static final byte[] NOTFOUND = "NO GOLDENFILE FOUND".getBytes();
-
- /*
- * Message to be returned if the goldenfile doesn't have read permissions.
- */
- private static final byte[] NOPERM = "INSUFFICIENT PERMISSIONS".getBytes();
-
- /*
- * Goldenfile represented by this object.
- */
- private File _file = null;
-
- /*
- * Error message to return by public methods if the file is not found or the
- * user has insufficient permissions.
- */
- private byte[] _errMessage = null;
-
- /*
- * Goldenfile length
- */
- private long _length = 0L;
-
- /*
- * Encoding
- */
- private String _encoding = null;
-
- /**
- * Creates a new GoldenFile based on the fully qualified filename provided.
- *
- * @param path
- * Fully qualified file name
- * @param encoding
- * to use when reading the goldenfile
- */
- public Goldenfile(String path, String encoding) {
- _file = new File(path);
- if (!_file.exists()) {
- TestUtil.logTrace("[GoldenFile] Goldenfile: " + path + ", not found!");
- _errMessage = NOTFOUND;
- _file = null;
- } else if (!_file.canRead()) {
- _errMessage = NOPERM;
- _file = null;
- } else {
- _length = _file.length();
- _encoding = encoding;
- }
- }
-
- /*
- * public methods
- * ========================================================================
- */
-
- /**
- * Returns the length of the Goldenfile.
- *
- * @return long length
- */
- public long getLength() {
- return _length;
- }
-
- /**
- * Returns the byte content of the specified goldenfile using the charset
- * encoding specified in the response from the server.
- *
- * @return the goldenfile as a byte array
- * @throws IOException
- * if an error occurs processing the file.
- */
- public byte[] getGoldenFileAsBytes() throws IOException {
- if (_file != null) {
- return getGoldenFileAsString().getBytes();
- } else {
- return _errMessage;
- }
- }
-
- /**
- * Retuns a string representation of the specified goldenfile using the
- * charset encoding specified in the response from the server.
- *
- * @return the goldenfile as a String.
- * @throws IOException
- * if an error occurs processing the file.
- */
- public String getGoldenFileAsString() throws IOException {
- String gf = null;
- if (_file != null) {
- TestUtil.logTrace(
- "[Goldenfile] Loading goldenfile using " + "encoding: " + _encoding);
- FileInputStream in = new FileInputStream(_file);
- gf = Util.getEncodedStringFromStream(in, _encoding);
- in.close();
- } else {
- gf = new String(_errMessage);
- }
- return gf;
- }
-
- /**
- * Returns the goldenfile as an InputStream using the charset encoding
- * specified in the response from the server.
- *
- * @return goldenfile as an InputStream
- * @throws IOException
- * If an error occurs processing the file.
- */
- public InputStream getGoldenFileAsStream() throws IOException {
- if (_file != null) {
- return new ByteArrayInputStream(getGoldenFileAsBytes());
- } else {
- return new ByteArrayInputStream(_errMessage);
- }
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/webclient/TestFailureException.java b/common/src/main/java/com/sun/ts/tests/common/webclient/TestFailureException.java
deleted file mode 100644
index b36cc2f6eb..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/webclient/TestFailureException.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (c) 2007, 2018 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.webclient;
-
-/**
- * Signifies a failure at some point during a test cycle.
- */
-public class TestFailureException extends java.lang.Exception {
-
- private static final long serialVersionUID = -4651996590051941456L;
-
- /**
- * Creates a new instance of TestFailureException without a
- * detailed message.
- */
- public TestFailureException() {
- }
-
- /**
- * Creates a new instance of TestFailureException containing the
- * root cause of the test failure.
- *
- * @param t
- * - root cause
- */
- public TestFailureException(Throwable t) {
- super(t);
- }
-
- /**
- * Creates a new instance of TestFailureException with the
- * specified detail message.
- *
- * @param msg
- * - the detail message.
- */
- public TestFailureException(String msg) {
- super(msg);
- }
-
- /**
- * Creates a new instance of TestFailureException with the
- * specified detail message, and the root cause of the test failure
- *
- * @param msg
- * - the detail message
- * @param t
- * - root cause
- */
- public TestFailureException(String msg, Throwable t) {
- super(msg, t);
- }
-
- /**
- * Returns, if any, the root cause of this Exception.
- *
- * @return the root cause of this exception, or null
- */
- public Throwable getRootCause() {
- return getCause();
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/webclient/TestSequence.java b/common/src/main/java/com/sun/ts/tests/common/webclient/TestSequence.java
deleted file mode 100644
index 435491611a..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/webclient/TestSequence.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.webclient;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import com.sun.ts.lib.util.TestUtil;
-
-/**
- * This class represents a logic sequence for executing a series of test cases
- * in a specific order. In this case, the execution order will be the same order
- * that the test cases were added to the sequence.
- *
- * The TestSequence has the added benefit of managing state between
- * the test invocations.
- */
-public class TestSequence implements TestCase {
-
- private Map _testMap = null;
-
- private List _testNameList = null;
-
- private String _name = "DEFAULT";
-
- private boolean _managed = false;
-
- /** Creates a new instance of TestSequence */
- public TestSequence() {
- _testMap = new HashMap();
- _testNameList = new ArrayList();
- }
-
- /*
- * public methods
- * ========================================================================
- */
-
- /**
- * Executes the test sequence.
- *
- * @throws TestFailureException
- * if any test in the sequence fails.
- */
- public void execute() throws TestFailureException {
-
- TestUtil.logTrace("[TestSequence] Beginning execution of sequence '" + _name
- + "' containing '" + _testNameList.size() + "' test entities.");
-
- TestCase cse;
- for (int i = 0, size = _testNameList.size(); i < size; i++) {
- String testName = _testNameList.get(i);
- TestUtil.logTrace("[TestSequence] Executing test case: " + testName);
- cse = _testMap.get(testName);
- if (_managed) {
- cse.setState(cse.getState());
- }
- cse.execute();
- TestUtil.logTrace("[TestSequence] Test case: " + testName + "complete.");
- }
- TestUtil.logTrace("[TestSequence] Sequence complete!");
- }
-
- /**
- * enableStateManagement, when enabled, will cause the test
- * sequence to manage state between test case invocations. By default, a test
- * sequence will not manage state.
- *
- * @param value
- * a value of true enables session management.
- */
- public void enableStateManagement(boolean value) {
- _managed = value;
- }
-
- /**
- * Returns a value indicating whether state management is enabled or not.
- *
- * @return boolean value indicating state management status
- */
- public boolean isStateManagementEnabled() {
- return _managed;
- }
-
- /**
- * Adds a test case to the sequence denoted by a unique identifier.
- *
- * @param identifier
- * for this test case
- * @param cs
- * the test case
- */
- public void addTestCase(String identifier, TestCase cs) {
- _testMap.put(identifier, cs);
- _testNameList.add(identifier);
- }
-
- /**
- * Removes a test case from the sequence.
- *
- * @param identifier
- */
- public void removeTestCase(String identifier) {
- _testMap.remove(identifier);
- _testNameList.remove(identifier);
- }
-
- /**
- * Sets the name of this TestSequence. If not set, the default value is
- * "DEFAULT".
- *
- * @param name
- */
- public void setName(String name) {
- _name = name;
- }
-
- /**
- * Returns the name of this TestSequence.
- *
- * @return sequence name
- */
- public String getName() {
- return _name;
- }
-
- /**
- * Sets the initial state for the test sequence to use when invoking test
- * cases.
- *
- * @param state
- * the initial state
- */
- public void setState(Object state) {
- }
-
- /**
- * Returns the state of the sequence. Note: This value can differ depending on
- * when it has been called in relation to when execute has been called.
- *
- * @return state of the sequence
- */
- public Object getState() {
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/webclient/Util.java b/common/src/main/java/com/sun/ts/tests/common/webclient/Util.java
deleted file mode 100644
index 5096d0f16b..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/webclient/Util.java
+++ /dev/null
@@ -1,234 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2007, 2020 Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2000 The Apache Software Foundation. All rights
- * Copyright (c) 2000 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Apache" and "Apache Software Foundation" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written
- * permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- * nor may "Apache" appear in their name, without prior written
- * permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- * Portions of this software are based upon public domain software
- * originally written at the National Center for Supercomputing Applications,
- * University of Illinois, Urbana-Champaign.
- */
-
-package com.sun.ts.tests.common.webclient;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-
-import com.sun.ts.lib.util.BASE64Encoder;
-
-public class Util {
-
- /**
- * Zeros
- */
- private static final String ZEROS = "00000000";
-
- /**
- * short pad size
- */
- private static final int SHORTPADSIZE = 4;
-
- /**
- * byte pad size
- */
- private static final int BYTEPADSIZE = 2;
-
- /** Creates new Util */
- private Util() {
- }
-
- /*
- * public methods
- * ========================================================================
- */
-
- /**
- * BASE64 encodes the provided string.
- *
- * @return BASE64 encoded string.
- */
- public static String getBase64EncodedString(String value) {
- BASE64Encoder encoder = new BASE64Encoder();
- return encoder.encode(value.getBytes());
- }
-
- /**
- * Returns a charset encoded string based on the provided InputStream and
- * charset encoding.
- *
- * @return encoding string
- */
- public static String getEncodedStringFromStream(InputStream in, String enc)
- throws IOException {
- BufferedReader bin = new BufferedReader(new InputStreamReader(in, enc));
- StringBuffer sb = new StringBuffer(128);
- for (int ch = bin.read(); ch != -1; ch = bin.read()) {
- sb.append((char) ch);
- }
- return sb.toString();
- }
-
- /**
- * getHexValue displays a formatted hex representation of the
- * passed byte array. It also allows for only a specified offset and length of
- * a particular array to be returned.
- *
- * @param bytes
- * byte[] array to process.
- * @param pos
- * int specifies offset to begin processing.
- * @param len
- * int specifies the number of bytes to process.
- * @return String formatted hex representation of processed
- * array.
- */
- public static String getHexValue(byte[] bytes, int pos, int len) {
- StringBuffer outBuf = new StringBuffer(bytes.length * 2);
- int bytesPerLine = 36;
- int cnt = 1;
- int groups = 4;
- int curPos = pos;
- int linePos = 1;
- boolean displayOffset = true;
-
- while (len-- > 0) {
- if (displayOffset) {
-
- outBuf.append("\n" + paddedHexString(pos, SHORTPADSIZE, true) + ": ");
- displayOffset = false;
- }
-
- outBuf.append(paddedHexString((int) bytes[pos], BYTEPADSIZE, false));
- linePos += 2; // Byte is padded to 2 characters
-
- if ((cnt % 4) == 0) {
- outBuf.append(" ");
- linePos++;
- }
-
- // Now display the characters that are printable
- if ((cnt % (groups * 4)) == 0) {
- outBuf.append(" ");
-
- while (curPos <= pos) {
- if (!Character.isWhitespace((char) bytes[curPos])) {
- outBuf.append((char) bytes[curPos]);
- } else {
- outBuf.append(".");
- }
-
- curPos++;
- }
-
- curPos = pos + 1;
- linePos = 1;
- displayOffset = true;
- }
-
- cnt++;
- pos++;
- }
-
- // pad out the line with spaces
- while (linePos++ <= bytesPerLine) {
- outBuf.append(" ");
- }
-
- outBuf.append(" ");
- // Now display the printable characters for the trailing bytes
- while (curPos < pos) {
- if (!Character.isWhitespace((char) bytes[curPos])) {
- outBuf.append((char) bytes[curPos]);
- } else {
- outBuf.append(".");
- }
-
- curPos++;
- }
-
- return outBuf.toString();
- }
-
- /*
- * private methods
- * ========================================================================
- */
-
- /**
- * paddedHexString pads the passed value based on the specified
- * wordsize and the value of the prefixFlag.
- *
- * @param val
- * an int value
- * @param wordsize
- * an int value
- * @param prefixFlag
- * a boolean value
- * @return a String value
- */
- private static String paddedHexString(int val, int wordsize,
- boolean prefixFlag) {
-
- String prefix = prefixFlag ? "0x" : "";
- String hexVal = Integer.toHexString(val);
-
- if (hexVal.length() > wordsize)
- hexVal = hexVal.substring(hexVal.length() - wordsize);
-
- return (prefix + (wordsize > hexVal.length()
- ? ZEROS.substring(0, wordsize - hexVal.length())
- : "") + hexVal);
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/webclient/WebTestCase.java b/common/src/main/java/com/sun/ts/tests/common/webclient/WebTestCase.java
deleted file mode 100644
index 762f2f7176..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/webclient/WebTestCase.java
+++ /dev/null
@@ -1,613 +0,0 @@
-/*
- * Copyright (c) 2007, 2022 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.webclient;
-
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.StringTokenizer;
-import java.util.logging.Logger;
-
-import com.sun.ts.lib.util.TestUtil;
-import com.sun.ts.tests.common.webclient.http.HttpRequest;
-import com.sun.ts.tests.common.webclient.http.HttpResponse;
-import com.sun.ts.tests.common.webclient.validation.ValidationFactory;
-import com.sun.ts.tests.common.webclient.validation.ValidationStrategy;
-import org.apache.commons.httpclient.Header;
-import org.apache.commons.httpclient.HttpState;
-
-
-/**
- * A TestCase implementation for HTTP-based testing. This allows the user to set
- * criteria for test success which will be compared against the response from
- * the server.
- */
-public class WebTestCase implements TestCase {
-
- private static final Logger LOGGER = Logger.getLogger(WebTestCase.class.getName());
-
- /**
- * Tokenized response validation strategy
- */
- public static final String TOKENIZED_STRATEGY = "com.sun.ts.tests.common.webclient.validation.TokenizedValidator";
-
- /**
- * Whitespace response validation strategy
- */
- public static final String WHITESPACE_STRATEGY = "com.sun.ts.tests.common.webclient.validation.WhitespaceValidator";
-
- /**
- * The request for this case.
- */
- private HttpRequest _request = null;
-
- /**
- * The server's response.
- */
- private HttpResponse _response = null;
-
- // use HttpMethod instances to store test
- // case headers that are expected or not
- // expected.
-
- /**
- * Storage for headers that are expected in the response
- */
- private Map _expected = null;
-
- /**
- * Storage for headers that are not expected in the response
- */
- private Map _unexpected = null;
-
- /**
- * Expected response status code.
- */
- private String _statusCode = null;
-
- /**
- * Expected response reason phrase.
- */
- private String _reasonPhrase = null;
-
- /**
- * Path to goldenfile.
- */
- private String _goldenfilePath = null;
-
- private InputStream _goldenfileStream = null;
-
- /**
- * A List of strings that will be searched for in the response in the order
- * they appear in the list.
- */
- private List _searchStrings = null;
-
- /**
- * A List of case insensitive strings that will be searched for in the
- * response in the order they appear in the list.
- */
- private List _searchStringsNoCase = null;
-
- /**
- * A List of strings that will be search for in the response with no attention
- * paid to the order they appear.
- */
- private List _unorderedSearchStrings = null;
-
- /**
- * A List of strings that should not be in the server's response.
- */
- private List _uSearchStrings = null;
-
- /**
- * Indicates whether a response body should be expected or not.
- */
- private boolean _expectResponseBody = true;
-
- /**
- * Strategy to use when validating the test case against the server's
- * response.
- */
- private ValidationStrategy _strategy = null;
-
- /**
- * Logical name for test case.
- */
- private String _name = "Test Case";
-
- /**
- * Creates a new instance of WebTestCase By default, a new WebTestCase
- * instance will use the TokenizedValidator to verify the response with the
- * configured properties of the test case.
- */
- public WebTestCase() {
- _strategy = ValidationFactory.getInstance(TOKENIZED_STRATEGY);
- }
-
- /*
- * public methods
- * ========================================================================
- */
- /**
- * Executes the test case.
- *
- * @throws TestFailureException
- * if the test fails for any reason.
- * @throws IllegalStateException
- * if no request was configured or if no Validator is available at
- * runtime.
- */
- public void execute() throws TestFailureException {
-
- // If no request was created, we can't run.
- if (_request == null) {
- throw new IllegalStateException("[FATAL] HttpRequest is null.");
- }
-
- // If no stragey instance is available (strange, but has happened),
- // fail.
- if (_strategy == null) {
- throw new IllegalStateException("[FATAL] No Validator available.");
- }
-
- try {
- _response = _request.execute();
- } catch (Throwable t) {
- String message = t.getMessage();
- throw new TestFailureException("[FATAL] Unexpected failure during "
- + "test execution." + (message == null ? t.toString() : message), t);
- }
-
- // Validate this test case instance
- if (!_strategy.validate(this)) {
- throw new TestFailureException("Test FAILED!");
- }
-
- }
-
- /**
- * Sets the status code to be expected in the response from the server, i.e.
- * 500 or 404, etc.
- *
- * @param statusCode
- * the expected status code
- */
- public void setExpectedStatusCode(String statusCode) {
- _statusCode = statusCode;
- }
-
- /**
- * Sets the reason phrase to be expected in the response from the server.
- *
- * @param reasonPhrase
- * the expected reason-phrase
- */
- public void setExpectedReasonPhrase(String reasonPhrase) {
- _reasonPhrase = reasonPhrase;
- }
-
- /**
- * Adds a header that is to be expected in the response from the server.
- *
- * @param header
- * in the format of : (test:foo)
- */
- public void addExpectedHeader(String header) {
- if (_expected == null) {
- _expected = new HashMap<>();
- }
- addHeader(_expected, header);
- }
-
- /**
- * Sets the path to the goldenfile the test case should use.
- *
- * @param gfPath
- * a fully qualified path including filename.
- */
- public void setGoldenFilePath(String gfPath) {
- _goldenfilePath = gfPath;
- }
-
-
- /**
- * Sets the InputStream of the goldenfile the test case should use.
- *
- * @param in
- * an InputStream value of the goldenfile.
- */
- public void setGoldenFileStream(InputStream in) {
- _goldenfileStream = in;
- }
-
- /**
- * Sets the request that should be dispatched by this test case.
- *
- * @param request
- * the HTTP request used for this test case
- */
- public void setRequest(HttpRequest request) {
- _request = request;
- }
-
- /**
- * Adds a header that is should not be in the server's response.
- *
- * @param header
- * in the format of : (test:foo)
- */
- public void addUnexpectedHeader(String header) {
- if (_unexpected == null) {
- _unexpected = new HashMap();
- }
- addHeader(_unexpected, header);
- }
-
- /**
- * Enables/Disables an assertion that a response body is present.
- *
- * @param value
- * a value of true will enable the assertion.
- */
- public void setAssertNoResponseBody(boolean value) {
- }
-
- /**
- * Sets a string that will be scanned for and expected in the response body
- * from the server.
- *
- * If multiple search strings are required, one can either call this method
- * for each string, or pass in one string with pipe | delimiting
- * the individual search strings within the large string.
- *
- * @param searchString
- * a string expected in the server's response body
- */
- public void setResponseSearchString(String searchString) {
- if (_searchStrings == null) {
- _searchStrings = new ArrayList();
- }
- addSearchStrings(_searchStrings, searchString);
- }
-
- /**
- * Sets a string that will be scanned for and expected in the response body
- * from the server.
- *
- * If multiple search strings are required, one can either call this method
- * for each string, or pass in one string with pipe | delimiting
- * the individual search strings within the large string.
- *
- * @param searchString
- * a case insensitive string expected in the server's response body
- */
- public void setResponseSearchStringIgnoreCase(String searchString) {
- if (_searchStringsNoCase == null) {
- _searchStringsNoCase = new ArrayList();
- }
- addSearchStrings(_searchStringsNoCase, searchString);
- }
-
- /**
- * Sets a string that will be scanned for and should not be present in the
- * response body from the server.
- *
- * If multiple search strings are required, one can either call this method
- * for each string, or pass in one string with pipe | delimiting
- * the individual search strings within the large string.
- *
- * @param searchString
- * a string that is not expected in the server's response body
- */
- public void setUnexpectedResponseSearchString(String searchString) {
- if (_uSearchStrings == null) {
- _uSearchStrings = new ArrayList();
- }
- addSearchStrings(_uSearchStrings, searchString);
- }
-
- /**
- * Sets a string or series of strings that will be searched for in the
- * response. If multiple search strings are required, one can either call this
- * method for each string, or pass in one string with pipe |
- * delimiting the individual search strings within the large string.
- *
- * @param searchString
- * a string that is not expected in the server's response body
- */
- public void setUnorderedSearchString(String searchString) {
- if (_unorderedSearchStrings == null) {
- _unorderedSearchStrings = new ArrayList();
- }
- addSearchStrings(_unorderedSearchStrings, searchString);
- }
-
- /**
- * Returns the list of search strings.
- *
- * @return the list of search strings.
- */
- public List getUnorderedSearchStrings() {
- return _unorderedSearchStrings;
- }
-
- /**
- * Returns the response for this particular test case.
- *
- * @return an HttpResponse object
- */
- public HttpResponse getResponse() {
- return _response;
- }
-
- /**
- * Returns an array of Header objects that are expected to be found in the
- * responst.
- *
- * @return an array of headers
- */
- public Header[] getExpectedHeaders() {
- if (_expected == null) {
- return null;
- }
- return _expected.values().toArray(new Header[_expected.size()]);
- }
-
- /**
- * Returns an array of Header objects that are not expected to be found in the
- * responst.
- *
- * @return an array of headers
- */
- public Header[] getUnexpectedHeaders() {
- if (_unexpected == null) {
- return null;
- }
- return _unexpected.values().toArray(new Header[_unexpected.size()]);
- }
-
- /**
- * Returns the status code expected to be found in the server's response
- *
- * @return status code
- */
- public String getStatusCode() {
- return _statusCode;
- }
-
- /**
- * Returns the reason phrase that is expected to be found in the server's
- * response.
- *
- * @return reason phrase
- */
- public String getReasonPhrase() {
- return _reasonPhrase;
- }
-
- /**
- * Returns the configured list of strings that will be used when scanning the
- * server's response.
- *
- * @return list of Strings
- */
- public List getSearchStrings() {
- if (_searchStrings == null) {
- return null;
- }
- return _searchStrings;
- }
-
- /**
- * Returns the configured list of strings that will be used when scanning the
- * server's response.
- *
- * @return list of case insensitive Strings
- */
- public List getSearchStringsNoCase() {
- if (_searchStringsNoCase == null) {
- return null;
- }
- return _searchStringsNoCase;
- }
-
- /**
- * Returns the configured list of strings that will be used when scanning the
- * server's response (these strings are not expected in the response).
- *
- * @return list of Strings
- */
- public List getUnexpectedSearchStrings() {
- if (_uSearchStrings == null) {
- return null;
- }
- return _uSearchStrings;
- }
-
- /**
- * Returns an indicator on whether a response body is expected or not.
- *
- * @return boolean value
- */
- public boolean getExpectResponseBody() {
- return _expectResponseBody;
- }
-
- /**
- * Returns the HttpRequest for this particular test case.
- *
- * @return HttpRequest of this test case
- */
- public HttpRequest getRequest() {
- return _request;
- }
-
- /**
- * Returns the path to the goldenfile.
- *
- * @return path to the goldenfile
- */
- public String getGoldenfilePath() {
- return _goldenfilePath;
- }
-
- /**
- * Returns the InputStream of the goldenfile.
- *
- * @return InputStream of the goldenfile
- */
- public InputStream getGoldenfileStream() {
- return _goldenfileStream;
- }
-
- /**
- * Returns the state for this particular test case.
- *
- * @return test state
- */
- public Object getState() {
- if (_response != null) {
- return _response.getState();
- } else {
- // an initial request for state
- return _request.getState();
- }
- }
-
- /**
- * Sets the state for this test case.
- *
- * @param state
- * test state
- */
- public void setState(Object state) {
- _request.setState((HttpState) state);
- }
-
- /**
- * Sets a logical name for this test case.
- *
- * @param name
- * the logical name for this test
- */
- public void setName(String name) {
- _name = name;
- }
-
- /**
- * Returns the logical name for this test case.
- *
- * @return test name
- */
- public String getName() {
- return _name;
- }
-
- /**
- * Sets the validation strategy for this test case instance.
- *
- * @param validator
- * - the fully qualified class name of the response validator to use.
- */
- public void setStrategy(String validator) {
- ValidationStrategy strat = ValidationFactory.getInstance(validator);
- if (strat != null) {
- _strategy = strat;
- } else {
- TestUtil.logMsg("[WebTestCase][WARNING] An attempt was made to use a "
- + "non-existing validator (" + validator + ")"
- + ". Falling back to the TokenizedValidator");
- }
- }
-
- /**
- * Returns the class name of the response validator used.
- *
- * @return the fully qualified class of the validator used
- */
- public String getStrategy() {
- return _strategy.getClass().getName();
- }
-
- /*
- * Private Methods
- * ===========================================================================
- */
-
- /**
- * Utility method to add headers to test case holder objects.
- *
- * @param map
- * the object in which to add header to
- * @param headerString
- * String representation of a header in the form of
- * :
- */
- private void addHeader(Map map, String headerString) {
- LOGGER.fine("[WebTestCase] addHeader utility method called: " + headerString);
- StringTokenizer st = new StringTokenizer(headerString, "|");
- while (st.hasMoreTokens()) {
- String head = st.nextToken();
- int colIdx = head.indexOf(':');
- String name = head.substring(0, colIdx).trim();
- String value = head.substring(colIdx + 1).trim();
- LOGGER.fine("[WebTestCase] Adding test header: " + name + ", " + value);
- Header header = map.get(name);
- if (header != null) {
- map.put(name, createNewHeader(value, header));
- } else {
- map.put(name, new Header(name, value));
- }
- }
- }
-
- /**
- * Creates a new header based of the provided header and value.
- *
- * @param newValue
- * - the new value to add to an existing header
- * @param header
- * - the original header
- * @return new Header
- */
- private Header createNewHeader(String newValue, Header header) {
- String oldValue = header.getValue();
- return new Header(header.getName(), oldValue + ", " + newValue);
- }
-
- /**
- * Adds a search string to the provided list
- *
- * @param stringList
- * - list to add the string to
- * @param s
- * - the search string
- */
- private void addSearchStrings(List stringList, String s) {
- StringTokenizer st = new StringTokenizer(s, "|");
- while (st.hasMoreTokens()) {
- stringList.add(st.nextToken());
- }
- }
-}
\ No newline at end of file
diff --git a/common/src/main/java/com/sun/ts/tests/common/webclient/handler/ALLOWHandler.java b/common/src/main/java/com/sun/ts/tests/common/webclient/handler/ALLOWHandler.java
deleted file mode 100644
index 4d2dacbec2..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/webclient/handler/ALLOWHandler.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 2008, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-package com.sun.ts.tests.common.webclient.handler;
-
-import java.util.StringTokenizer;
-
-import org.apache.commons.httpclient.Header;
-
-import com.sun.ts.lib.util.TestUtil;
-
-public class ALLOWHandler implements Handler {
-
- private static final Handler HANDLER = new ALLOWHandler();
-
- private static final String DELIM = "##";
-
- private ALLOWHandler() {
- }
-
- public static Handler getInstance() {
- return HANDLER;
- }
-
- public boolean invoke(Header configuredHeader, Header responseHeader) {
- String ALLOWHeader = responseHeader.getValue().toLowerCase();
- String expectedValues = configuredHeader.getValue().toLowerCase()
- .replace(" ", "");
-
- TestUtil.logTrace("[ALLOWHandler] ALLOW header received: " + ALLOWHeader);
-
- StringTokenizer conf = new StringTokenizer(expectedValues, ",");
- while (conf.hasMoreTokens()) {
- String token = conf.nextToken();
- String token1 = token;
-
- if ((ALLOWHeader.indexOf(token) < 0)
- && (ALLOWHeader.indexOf(token1) < 0)) {
- TestUtil.logErr("[ALLOWHandler] Unable to find '" + token
- + "' within the ALLOW header returned by the server.");
- return false;
- } else {
- TestUtil.logTrace("[ALLOWHandler] Found expected value, '" + token
- + "' in ALLOW header returned by server.");
- }
- }
- return true;
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/webclient/handler/SetCookieHandler.java b/common/src/main/java/com/sun/ts/tests/common/webclient/handler/SetCookieHandler.java
deleted file mode 100644
index 944f3448c5..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/webclient/handler/SetCookieHandler.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.webclient.handler;
-
-import java.util.StringTokenizer;
-
-import org.apache.commons.httpclient.Header;
-
-import com.sun.ts.lib.util.TestUtil;
-
-public class SetCookieHandler implements Handler {
-
- private static final Handler HANDLER = new SetCookieHandler();
-
- private static final String DELIM = "##";
-
- private SetCookieHandler() {
- }
-
- public static Handler getInstance() {
- return HANDLER;
- }
-
- public boolean invoke(Header configuredHeader, Header responseHeader) {
- String setCookieHeader = responseHeader.getValue().toLowerCase();
- String expectedValues = configuredHeader.getValue().toLowerCase();
-
- TestUtil.logTrace(
- "[SetCookieHandler] Set-Cookie header received: " + setCookieHeader);
-
- StringTokenizer conf = new StringTokenizer(expectedValues, DELIM);
- while (conf.hasMoreTokens()) {
- String token = conf.nextToken();
- String token1 = token;
-
- if (token.endsWith("\"") && (token.indexOf("=\"") > 1)) {
- token1 = token.replace("=\"", "=");
- token1 = token1.substring(0, token.length() - 2);
- }
-
- if (token.startsWith("!")) {
- String attr = token.substring(1);
- String attr1 = token1.substring(1);
- if ((setCookieHeader.indexOf(attr) > -1)
- || (setCookieHeader.indexOf(attr1) > -1)) {
- TestUtil.logErr("[SetCookieHandler] Unexpected attribute found "
- + " Set-Cookie header. Attribute: " + attr
- + "\nSet-Cookie header: " + setCookieHeader);
- return false;
- }
- } else {
- if ((setCookieHeader.indexOf(token) < 0)
- && (setCookieHeader.indexOf(token1) < 0)) {
- TestUtil.logErr("[SetCookieHandler] Unable to find '" + token
- + "' within the Set-Cookie header returned by the server.");
- return false;
- } else {
- TestUtil.logTrace("[SetCookieHandler] Found expected value, '" + token
- + "' in Set-Cookie header returned by server.");
- }
- }
- }
-
- return true;
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/webclient/http/HttpRequest.java b/common/src/main/java/com/sun/ts/tests/common/webclient/http/HttpRequest.java
deleted file mode 100644
index 2edfad04a7..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/webclient/http/HttpRequest.java
+++ /dev/null
@@ -1,588 +0,0 @@
-/*
- * Copyright (c) 2007, 2022 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.webclient.http;
-
-import java.io.IOException;
-import java.util.StringTokenizer;
-
-import org.apache.commons.httpclient.Cookie;
-import org.apache.commons.httpclient.Header;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpConnection;
-import org.apache.commons.httpclient.HttpException;
-import org.apache.commons.httpclient.HttpMethod;
-import org.apache.commons.httpclient.HttpState;
-import org.apache.commons.httpclient.UsernamePasswordCredentials;
-import org.apache.commons.httpclient.auth.AuthScope;
-import org.apache.commons.httpclient.cookie.CookiePolicy;
-import org.apache.commons.httpclient.methods.EntityEnclosingMethod;
-import org.apache.commons.httpclient.methods.StringRequestEntity;
-import org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory;
-import org.apache.commons.httpclient.protocol.Protocol;
-import org.apache.commons.httpclient.protocol.ProtocolSocketFactory;
-import org.apache.commons.httpclient.protocol.SSLProtocolSocketFactory;
-// this import is used to force this class to get compiled
-import com.sun.ts.tests.common.webclient.log.WebLog;
-
-import com.sun.ts.lib.util.TestUtil;
-import com.sun.ts.tests.common.webclient.Util;
-
-/**
- * Represents an HTTP client Request
- */
-
-public class HttpRequest {
-
- static {
- if (TestUtil.traceflag) {
- System.setProperty("org.apache.commons.logging.Log",
- "com.sun.ts.tests.common.webclient.log.WebLog");
- System.setProperty(
- "org.apache.commons.logging.simplelog.log.httpclient.wire", "debug");
- }
- }
-
- /**
- * Default HTTP port.
- */
- public static int DEFAULT_HTTP_PORT = 80;
-
- /**
- * Default HTTP SSL port.
- */
- public static final int DEFAULT_SSL_PORT = 443;
-
- /**
- * No authentication
- */
- public static final int NO_AUTHENTICATION = 0;
-
- /**
- * Basic authentication
- */
- public static final int BASIC_AUTHENTICATION = 1;
-
- /**
- * Digest authenctication
- */
- public static final int DIGEST_AUTHENTICATION = 2;
-
- /**
- * Method representation of request.
- */
- private HttpMethod _method = null;
-
- /**
- * Target web container host
- */
- private String _host = null;
-
- /**
- * Target web container port
- */
- private int _port = DEFAULT_HTTP_PORT;
-
- /**
- * Is the request going over SSL
- */
- private boolean _isSecure = false;
-
- /**
- * HTTP state
- */
- private HttpState _state = null;
-
- /**
- * Original request line for this request.
- */
- private String _requestLine = null;
-
- /**
- * Authentication type for current request
- */
- private int _authType = NO_AUTHENTICATION;
-
- /**
- * Flag to determine if session tracking will be used or not.
- */
- private boolean _useCookies = false;
-
- /**
- * Content length of request body.
- */
- private int _contentLength = 0;
-
- /**
- * FollowRedirects
- */
- private boolean _redirect = false;
-
- Header[] _headers = null;
-
- protected HttpClient client = null;
-
- /**
- * Creates new HttpRequest based of the passed request line. The request line
- * provied must be in the form of:
- *
- *
- */
- public HttpRequest(String requestLine, String host, int port) {
- client = new HttpClient();
- _method = MethodFactory.getInstance(requestLine);
- _method.setFollowRedirects(false);
- _host = host;
- _port = port;
-
- if (port == DEFAULT_SSL_PORT) {
- _isSecure = true;
- }
-
- // If we got this far, the request line is in the proper
- // format
- _requestLine = requestLine;
- }
-
- /*
- * public methods
- * ========================================================================
- */
-
- /**
- * getRequestPath returns the request path for this particular
- * request.
- *
- * @return String request path
- */
- public String getRequestPath() {
- return _method.getPath();
- }
-
- /**
- * getRequestMethod returns the request type, i.e., GET, POST,
- * etc.
- *
- * @return String request type
- */
- public String getRequestMethod() {
- return _method.getName();
- }
-
- /**
- * isSecureConnection() indicates if the Request is secure or
- * not.
- *
- * @return boolean whether Request is using SSL or not.
- */
- public boolean isSecureRequest() {
- return _isSecure;
- }
-
- /**
- * setSecureRequest configures this request to use SSL.
- *
- * @param secure
- * - whether the Request uses SSL or not.
- */
- public void setSecureRequest(boolean secure) {
- _isSecure = secure;
- }
-
- /**
- * setContent will set the body for this request. Note, this is
- * only valid for POST and PUT operations, however, if called and the request
- * represents some other HTTP method, it will be no-op'd.
- *
- * @param content
- * request content
- */
- public void setContent(String content) {
- if (_method instanceof EntityEnclosingMethod) {
- ((EntityEnclosingMethod) _method)
- .setRequestEntity(new StringRequestEntity(content));
- }
- _contentLength = content.length();
- }
-
- /**
- * setAuthenticationCredentials configures the request to
- * perform authentication.
- *
- *
username and password cannot be null.
- *
- *
- *
- * It is legal for realm to be null.
- *
- *
- * @param username
- * the user
- * @param password
- * the user's password
- * @param authType
- * authentication type
- * @param realm
- * authentication realm
- */
- public void setAuthenticationCredentials(String username, String password,
- int authType, String realm) {
- if (username == null) {
- throw new IllegalArgumentException("Username cannot be null");
- }
-
- if (password == null) {
- throw new IllegalArgumentException("Password cannot be null");
- }
-
- UsernamePasswordCredentials cred = new UsernamePasswordCredentials(username,
- password);
- AuthScope scope = new AuthScope(_host, _port, realm);
- getState().setCredentials(scope, cred);
- TestUtil.logTrace("[HttpRequest] Added credentials for '" + username
- + "' with password '" + password + "' in realm '" + realm + "'");
-
- _authType = authType;
- }
-
- /**
- * addRequestHeader adds a request header to this request. If a
- * request header of the same name already exists, the new value, will be
- * added to the set of already existing values.
- *
- * NOTE: that header names are not case-sensitive.
- *
- * @param headerName
- * request header name
- * @param headerValue
- * request header value
- */
- public void addRequestHeader(String headerName, String headerValue) {
- _method.addRequestHeader(headerName, headerValue);
- TestUtil.logTrace("[HttpRequest] Added request header: "
- + _method.getRequestHeader(headerName).toExternalForm());
- }
-
- public void addRequestHeader(String header) {
- StringTokenizer st = new StringTokenizer(header, "|");
- while (st.hasMoreTokens()) {
- String h = st.nextToken();
- if (h.toLowerCase().startsWith("cookie")) {
- createCookie(h);
- continue;
- }
- int col = h.indexOf(':');
- addRequestHeader(h.substring(0, col).trim(), h.substring(col + 1).trim());
- }
- }
-
- /**
- * setRequestHeader sets a request header for this request
- * overwritting any previously existing header/values with the same name.
- *
- * NOTE: Header names are not case-sensitive.
- *
- * @param headerName
- * request header name
- * @param headerValue
- * request header value
- */
- public void setRequestHeader(String headerName, String headerValue) {
- _method.setRequestHeader(headerName, headerValue);
- TestUtil.logTrace("[HttpRequest] Set request header: "
- + _method.getRequestHeader(headerName).toExternalForm());
-
- }
-
- /**
- * setFollowRedirects indicates whether HTTP redirects are
- * followed. By default, redirects are not followed.
- */
- public void setFollowRedirects(boolean followRedirects) {
- _method.setFollowRedirects(followRedirects);
- }
-
- /**
- * getFollowRedirects indicates whether HTTP redirects are
- * followed.
- */
- public boolean getFollowRedirects() {
- return _method.getFollowRedirects();
- }
-
- /**
- * setState will set the HTTP state for the current request (i.e.
- * session tracking). This has the side affect
- */
- public void setState(HttpState state) {
- _state = state;
- _useCookies = true;
- }
-
- /**
- * execute will dispatch the current request to the target
- * server.
- *
- * @return HttpResponse the server's response.
- * @throws IOException
- * if an I/O error occurs during dispatch.
- */
- public HttpResponse execute() throws IOException, HttpException {
- String method;
- int defaultPort;
- ProtocolSocketFactory factory;
-
- if (_method.getFollowRedirects()) {
- client = new HttpClient();
-
- if (_isSecure) {
- method = "https";
- defaultPort = DEFAULT_SSL_PORT;
- factory = new SSLProtocolSocketFactory();
- } else {
- method = "http";
- defaultPort = DEFAULT_HTTP_PORT;
- factory = new DefaultProtocolSocketFactory();
- }
-
- Protocol protocol = new Protocol(method, factory, defaultPort);
- HttpConnection conn = new HttpConnection(_host, _port, protocol);
-
- if (conn.isOpen()) {
- throw new IllegalStateException("Connection incorrectly opened");
- }
-
- conn.open();
-
- TestUtil.logMsg("[HttpRequest] Dispatching request: '" + _requestLine
- + "' to target server at '" + _host + ":" + _port + "'");
-
- addSupportHeaders();
- _headers = _method.getRequestHeaders();
-
- TestUtil.logTrace(
- "########## The real value set: " + _method.getFollowRedirects());
-
- client.getHostConfiguration().setHost(_host, _port, protocol);
-
- client.executeMethod(_method);
-
- return new HttpResponse(_host, _port, _isSecure, _method, getState());
- } else {
- if (_isSecure) {
- method = "https";
- defaultPort = DEFAULT_SSL_PORT;
- factory = new SSLProtocolSocketFactory();
- } else {
- method = "http";
- defaultPort = DEFAULT_HTTP_PORT;
- factory = new DefaultProtocolSocketFactory();
- }
-
- Protocol protocol = new Protocol(method, factory, defaultPort);
- HttpConnection conn = new HttpConnection(_host, _port, protocol);
-
- if (conn.isOpen()) {
- throw new IllegalStateException("Connection incorrectly opened");
- }
-
- conn.open();
-
- TestUtil.logMsg("[HttpRequest] Dispatching request: '" + _requestLine
- + "' to target server at '" + _host + ":" + _port + "'");
-
- addSupportHeaders();
- _headers = _method.getRequestHeaders();
-
- TestUtil.logTrace(
- "########## The real value set: " + _method.getFollowRedirects());
-
- _method.execute(getState(), conn);
-
- return new HttpResponse(_host, _port, _isSecure, _method, getState());
- }
- }
-
- /**
- * Returns the current state for this request.
- *
- * @return HttpState current state
- */
- public HttpState getState() {
- if (_state == null) {
- _state = new HttpState();
- }
- return _state;
- }
-
- public String toString() {
- StringBuffer sb = new StringBuffer(255);
- sb.append("[REQUEST LINE] -> ").append(_requestLine).append('\n');
-
- if (_headers != null && _headers.length != 0) {
-
- for (Header _header : _headers) {
- sb.append(" [REQUEST HEADER] -> ");
- sb.append(_header.toExternalForm()).append('\n');
- }
- }
-
- if (_contentLength != 0) {
- sb.append(" [REQUEST BODY LENGTH] -> ").append(_contentLength);
- sb.append('\n');
- }
-
- return sb.toString();
-
- }
-
- /*
- * private methods
- * ========================================================================
- */
-
- private void createCookie(String cookieHeader) {
- String cookieLine = cookieHeader.substring(cookieHeader.indexOf(':') + 1)
- .trim();
- StringTokenizer st = new StringTokenizer(cookieLine, " ;");
- Cookie cookie = new Cookie();
- cookie.setVersion(1);
-
- getState();
-
- if (cookieLine.indexOf("$Version") == -1) {
- cookie.setVersion(0);
- _method.getParams().setCookiePolicy(CookiePolicy.NETSCAPE);
- }
-
- while (st.hasMoreTokens()) {
- String token = st.nextToken();
-
- if (token.charAt(0) != '$' && !token.startsWith("Domain")
- && !token.startsWith("Path")) {
- cookie.setName(token.substring(0, token.indexOf('=')));
- cookie.setValue(token.substring(token.indexOf('=') + 1));
- } else if (token.indexOf("Domain") > -1) {
- cookie.setDomainAttributeSpecified(true);
- cookie.setDomain(token.substring(token.indexOf('=') + 1));
- } else if (token.indexOf("Path") > -1) {
- cookie.setPathAttributeSpecified(true);
- cookie.setPath(token.substring(token.indexOf('=') + 1));
- }
- }
- _state.addCookie(cookie);
-
- }
-
- /**
- * Adds any support request headers necessary for this request. These headers
- * will be added based on the state of the request.
- */
- private void addSupportHeaders() {
-
- // Authentication headers
- // NOTE: Possibly move logic to generic method
- switch (_authType) {
- case NO_AUTHENTICATION:
- break;
- case BASIC_AUTHENTICATION:
- setBasicAuthorizationHeader();
- break;
- case DIGEST_AUTHENTICATION:
- throw new UnsupportedOperationException(
- "Digest Authentication is not currently " + "supported");
- }
-
- // A Host header will be added to each request to handle
- // cases where virtual hosts are used, or there is no DNS
- // available on the system where the container is running.
- setHostHeader();
-
- // Content length header
- setContentLengthHeader();
-
- // Cookies
- setCookieHeader();
- }
-
- /**
- * Sets a basic authentication header in the request is Request is configured
- * to use basic authentication
- */
- private void setBasicAuthorizationHeader() {
- UsernamePasswordCredentials cred = (UsernamePasswordCredentials) getState()
- .getCredentials(new AuthScope(_host, _port, null));
- String authString = null;
- if (cred != null) {
- authString = "Basic " + Util.getBase64EncodedString(
- cred.getUserName() + ":" + cred.getPassword());
- } else {
- TestUtil.logTrace("[HttpRequest] NULL CREDENTIALS");
- }
- _method.setRequestHeader("Authorization", authString);
- }
-
- /**
- * Sets a Content-Length header in the request if content is present
- */
- private void setContentLengthHeader() {
- if (_contentLength > 0) {
- _method.setRequestHeader("Content-Length",
- Integer.toString(_contentLength));
- }
- }
-
- /**
- * Sets a host header in the request. If the configured host value is an IP
- * address, the Host header will be sent, but without any value.
- *
- * If we adhered to the HTTP/1.1 spec, the Host header must be empty of the
- * target server is identified via IP address. However, no user agents I've
- * tested follow this. And if a custom client library does this, it may not
- * work properly with the target server. For now, the Host request-header will
- * always have a value.
- */
- private void setHostHeader() {
- if (_port == DEFAULT_HTTP_PORT || _port == DEFAULT_SSL_PORT) {
- _method.setRequestHeader("Host", _host);
- } else {
- _method.setRequestHeader("Host", _host + ":" + _port);
- }
- }
-
- /**
- * Sets a Cookie header if this request is using cookies.
- */
- private void setCookieHeader() {
- if (_useCookies) {
- Cookie[] cookies = _state.getCookies();
- if (cookies != null && cookies.length > 0) {
- Header cHeader = CookiePolicy.getCookieSpec(CookiePolicy.RFC_2109)
- .formatCookieHeader(_state.getCookies());
- if (cHeader != null) {
- _method.setRequestHeader(cHeader);
- }
- }
- }
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/webclient/http/HttpResponse.java b/common/src/main/java/com/sun/ts/tests/common/webclient/http/HttpResponse.java
deleted file mode 100644
index 4aaa06d978..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/webclient/http/HttpResponse.java
+++ /dev/null
@@ -1,313 +0,0 @@
-/*
- * Copyright (c) 2006, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.webclient.http;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.apache.commons.httpclient.Header;
-import org.apache.commons.httpclient.HttpMethod;
-import org.apache.commons.httpclient.HttpMethodBase;
-import org.apache.commons.httpclient.HttpState;
-import org.apache.commons.httpclient.HttpVersion;
-
-import com.sun.ts.tests.common.webclient.Util;
-
-/**
- * This class represents an HTTP response from the server.
- */
-
-public class HttpResponse {
-
- /**
- * Default encoding based on Servlet Specification
- */
- private static final String DEFAULT_ENCODING = "ISO-8859-1";
-
- /**
- * Content-Type header
- */
- private static final String CONTENT_TYPE = "Content-Type";
-
- /**
- * Wrapped HttpMethod used to pull response info from.
- */
- private HttpMethod _method = null;
-
- /**
- * HttpState obtained after execution of request
- */
- private HttpState _state = null;
-
- /**
- * Charset encoding returned in the response
- */
- private String _encoding = DEFAULT_ENCODING;
-
- /**
- * The response body. Initialized after first call to one of the
- * getResponseBody methods and cached for subsequent calls.
- */
- private String _responseBody = null;
-
- /**
- * Host name used for processing request
- */
- private String _host = null;
-
- /**
- * Port number used for processing request
- */
- private int _port;
-
- /**
- * Issecure
- */
- private boolean _isSecure;
-
- /** Creates new HttpResponse */
- public HttpResponse(String host, int port, boolean isSecure,
- HttpMethod method, HttpState state) {
-
- _host = host;
- _port = port;
- _isSecure = isSecure;
- _method = method;
- _state = state;
- }
-
- /*
- * public methods
- * ========================================================================
- */
-
- /**
- * Returns the HTTP status code returned by the server
- *
- * @return HTTP status code
- */
- public String getStatusCode() {
- return Integer.toString(_method.getStatusCode());
- }
-
- /**
- * Returns the HTTP reason-phrase returned by the server
- *
- * @return HTTP reason-phrase
- */
- public String getReasonPhrase() {
- return _method.getStatusText();
- }
-
- /**
- * Returns the headers received in the response from the server.
- *
- * @return response headers
- */
- public Header[] getResponseHeaders() {
- return _method.getResponseHeaders();
- }
-
- /**
- * Returns the headers designated by the name provided.
- *
- * @return response headers
- */
- public Header[] getResponseHeaders(String headerName) {
- return _method.getResponseHeaders(headerName);
- }
-
- /**
- * Returns the response header designated by the name provided.
- *
- * @return a specfic response header or null if the specified header doesn't
- * exist.
- */
- public Header getResponseHeader(String headerName) {
- return _method.getResponseHeader(headerName);
- }
-
- /**
- * Returns the response body as a byte array using the charset specified in
- * the server's response.
- *
- * @return response body as an array of bytes.
- */
- public byte[] getResponseBodyAsBytes() throws IOException {
- return getEncodedResponse().getBytes();
- }
-
- /**
- * Returns the response as bytes (no encoding is performed by client.
- *
- * @return the raw response bytes
- * @throws IOException
- * if an error occurs reading from server
- */
- public byte[] getResponseBodyAsRawBytes() throws IOException {
- return _method.getResponseBody();
- }
-
- /**
- * Returns the response body as a string using the charset specified in the
- * server's response.
- *
- * @return response body as a String
- */
- public String getResponseBodyAsString() throws IOException {
- return getEncodedResponse();
- }
-
- /**
- * Returns the response body of the server without being encoding by the
- * client.
- *
- * @return an unecoded String representation of the response
- * @throws IOException
- * if an error occurs reading from the server
- */
- public String getResponseBodyAsRawString() throws IOException {
- return _method.getResponseBodyAsString();
- }
-
- /**
- * Returns the response body as an InputStream using the encoding specified in
- * the server's response.
- *
- * @return response body as an InputStream
- */
- public InputStream getResponseBodyAsStream() throws IOException {
- return new ByteArrayInputStream(getEncodedResponse().getBytes());
- }
-
- /**
- * Returns the response body as an InputStream without any encoding applied by
- * the client.
- *
- * @return an InputStream to read the response
- * @throws IOException
- * if an error occurs reading from the server
- */
- public InputStream getResponseBodyAsRawStream() throws IOException {
- return _method.getResponseBodyAsStream();
- }
-
- /**
- * Returns the charset encoding for this response.
- *
- * @return charset encoding
- */
- public String getResponseEncoding() {
- Header content = _method.getResponseHeader(CONTENT_TYPE);
- if (content != null) {
- String headerVal = content.getValue();
- int idx = headerVal.indexOf(";charset=");
- if (idx > -1) {
- // content encoding included in response
- _encoding = headerVal.substring(idx + 9);
- }
- }
- return _encoding;
- }
-
- /**
- * Returns the post-request state.
- *
- * @return an HttpState object
- */
- public HttpState getState() {
- return _state;
- }
-
- /**
- * Displays a String representation of the response.
- *
- * @return string representation of response
- */
- public String toString() {
- StringBuffer sb = new StringBuffer(255);
-
- sb.append("[RESPONSE STATUS LINE] -> ");
- sb.append(((HttpMethodBase) _method).getParams().getVersion()
- .equals(HttpVersion.HTTP_1_1) ? "HTTP/1.1 " : "HTTP/1.0 ");
- sb.append(_method.getStatusCode()).append(' ');
- sb.append(_method.getStatusText()).append('\n');
- Header[] headers = _method.getResponseHeaders();
- if (headers != null && headers.length != 0) {
- for (int i = 0; i < headers.length; i++) {
- sb.append(" [RESPONSE HEADER] -> ");
- sb.append(headers[i].toExternalForm()).append('\n');
- }
- }
-
- String resBody;
- try {
- resBody = _method.getResponseBodyAsString();
- } catch (IOException ioe) {
- resBody = "UNEXECTED EXCEPTION: " + ioe.toString();
- }
- if (resBody != null && resBody.length() != 0) {
- sb.append("------ [RESPONSE BODY] ------\n");
- sb.append(resBody);
- sb.append("\n-----------------------------\n\n");
- }
- return sb.toString();
- }
-
- /*
- * Eventually they need to come from _method
- */
-
- public String getHost() {
- return _host;
- }
-
- public int getPort() {
- return _port;
- }
-
- public String getProtocol() {
- return _isSecure ? "https" : "http";
- }
-
- public String getPath() {
- return _method.getPath();
- }
-
- /*
- * Private Methods
- * ==========================================================================
- */
-
- /**
- * Returns the response body using the encoding returned in the response.
- *
- * @return encoded response String.
- */
- private String getEncodedResponse() throws IOException {
- if (_responseBody == null) {
- _responseBody = Util.getEncodedStringFromStream(
- _method.getResponseBodyAsStream(), getResponseEncoding());
- }
- return _responseBody;
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/webclient/http/MethodFactory.java b/common/src/main/java/com/sun/ts/tests/common/webclient/http/MethodFactory.java
deleted file mode 100644
index 1aecde8229..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/webclient/http/MethodFactory.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.webclient.http;
-
-import java.util.NoSuchElementException;
-import java.util.StringTokenizer;
-
-import org.apache.commons.httpclient.HttpMethod;
-import org.apache.commons.httpclient.HttpMethodBase;
-import org.apache.commons.httpclient.HttpVersion;
-import org.apache.commons.httpclient.methods.DeleteMethod;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.commons.httpclient.methods.HeadMethod;
-import org.apache.commons.httpclient.methods.OptionsMethod;
-import org.apache.commons.httpclient.methods.PostMethod;
-import org.apache.commons.httpclient.methods.PutMethod;
-
-import com.sun.ts.lib.porting.TSURL;
-
-/**
- * Simple factory class which returns HttpMethod implementations based on a
- * request line.
- *
- * For example, a request line of GET /index.jsp HTTP/1.0 would return
- * an HttpMethod implementation that handles GET requests using HTTP/1.0.
- *
- */
-
-public class MethodFactory {
-
- /**
- * HTTP GET
- */
- private static final String GET_METHOD = "GET";
-
- /**
- * HTTP POST
- */
- private static final String POST_METHOD = "POST";
-
- /**
- * HTTP HEAD
- */
- private static final String HEAD_METHOD = "HEAD";
-
- /**
- * HTTP PUT
- */
- private static final String PUT_METHOD = "PUT";
-
- /**
- * HTTP DELETE
- */
- private static final String DELETE_METHOD = "DELETE";
-
- /**
- * HTTP OPTIONS
- */
- private static final String OPTIONS_METHOD = "OPTIONS";
-
- /**
- * TSURL implementation
- */
- private static final TSURL TS_URL = new TSURL();
-
- /**
- * Private constructor as all interaction with this class is through the
- * getInstance() method.
- */
- private MethodFactory() {
- }
-
- /*
- * public methods
- * ========================================================================
- */
-
- /**
- * Returns the approriate request method based on the provided request string.
- * The request must be in the format of METHOD URI_PATH HTTP_VERSION, i.e. GET
- * /index.jsp HTTP/1.1.
- *
- * @return HttpMethod based in request.
- */
- public static HttpMethod getInstance(String request) {
- StringTokenizer st = new StringTokenizer(request);
- String method;
- String query = null;
- String uri;
- String version;
- try {
- method = st.nextToken();
- uri = TS_URL.getRequest(st.nextToken());
- version = st.nextToken();
- } catch (NoSuchElementException nsee) {
- throw new IllegalArgumentException(
- "Request provided: " + request + " is malformed.");
- }
-
- // check to see if there is a query string appended
- // to the URI
- int queryStart = uri.indexOf('?');
- if (queryStart != -1) {
- query = uri.substring(queryStart + 1);
- uri = uri.substring(0, queryStart);
- }
-
- HttpMethodBase req;
-
- if (method.equals(GET_METHOD)) {
- req = new GetMethod(uri);
- } else if (method.equals(POST_METHOD)) {
- req = new PostMethod(uri);
- } else if (method.equals(PUT_METHOD)) {
- req = new PutMethod(uri);
- } else if (method.equals(DELETE_METHOD)) {
- req = new DeleteMethod(uri);
- } else if (method.equals(HEAD_METHOD)) {
- req = new HeadMethod(uri);
- } else if (method.equals(OPTIONS_METHOD)) {
- req = new OptionsMethod(uri);
- } else {
- throw new IllegalArgumentException("Invalid method: " + method);
- }
-
- setHttpVersion(version, req);
-
- if (query != null) {
- req.setQueryString(query);
- }
-
- return req;
- }
-
- /*
- * private methods
- * ========================================================================
- */
-
- /**
- * Sets the HTTP version for the method in question.
- *
- * @param version
- * HTTP version to use for this request
- * @param method
- * method to adjust HTTP version
- */
- private static void setHttpVersion(String version, HttpMethodBase method) {
- final String oneOne = "HTTP/1.1";
- method.getParams().setVersion(
- (version.equals(oneOne) ? HttpVersion.HTTP_1_1 : HttpVersion.HTTP_1_0));
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/webclient/validation/TokenizedValidator.java b/common/src/main/java/com/sun/ts/tests/common/webclient/validation/TokenizedValidator.java
deleted file mode 100644
index b74ff95a2c..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/webclient/validation/TokenizedValidator.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.webclient.validation;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.util.StringTokenizer;
-
-import com.sun.ts.lib.util.TestUtil;
-import com.sun.ts.tests.common.webclient.Goldenfile;
-import com.sun.ts.tests.common.webclient.Util;
-
-/**
- *
- * This class provides all of the functionality of the
- * WebValidatorBase class. Additionally, it will compare
- * the server's response body with the test case's configured
- * goldenfile using a StringTokenizer.
- *
- */
-public class TokenizedValidator extends WebValidatorBase {
-
- /**
- * System property that will cause the specified goldenfile to be written if
- * it doesn't already exist.
- */
- private static final String RECORD_GF = "ts.record.gf";
-
- /**
- * Creates a new instance of TokenizedValidator
- */
- public TokenizedValidator() {
- }
-
- /*
- * protected methods
- * ========================================================================
- */
-
- /**
- * Compare the server response and golenfile using a StringTokenizer.
- *
- * @return true if response and goldenfile are the same.
- * @throws IOException
- * if an error occurs will processing the Goldenfile
- */
- protected boolean checkGoldenfile() throws IOException {
- String gf = null;
- String path = _case.getGoldenfilePath();
- String enc = _res.getResponseEncoding();
-
- if (path == null) {
- return true;
- }
-
- Goldenfile file = new Goldenfile(_case.getGoldenfilePath(), enc);
-
- try {
- File goldenFile = new File(_case.getGoldenfilePath());
- if(goldenFile.exists()){
- gf = file.getGoldenFileAsString();
- }
- else if(_case.getGoldenfileStream()!=null){
- gf = Util.getEncodedStringFromStream(_case.getGoldenfileStream(), enc);
- }
- } catch (IOException ioe) {
- TestUtil
- .logErr("[TokenizedValidator] Unexpected exception while accessing "
- + "goldenfile! " + ioe.toString());
- return false;
- }
-
- String response = _res.getResponseBodyAsString();
- StringTokenizer gfTokenizer = new StringTokenizer(gf);
- StringTokenizer resTokenizer = new StringTokenizer(response);
- int gfCount = gfTokenizer.countTokens();
- int resCount = resTokenizer.countTokens();
-
- // Logic to handle the recording of goldenfiles.
- if (gf.equals("NO GOLDENFILE FOUND") && Boolean.getBoolean(RECORD_GF)) {
-
- TestUtil
- .logTrace("[TokenizedValidator][INFO] RECORDING GOLDENFILE: " + path);
- OutputStreamWriter out = new OutputStreamWriter(
- new FileOutputStream(path), enc);
- out.write(response);
- out.flush();
- out.close();
- }
-
- // If the token counts are the same, continue checking
- // each individual token, otherwise, immediately fail.
- if (gfCount == resCount) {
- while (gfTokenizer.hasMoreTokens()) {
- String exp = gfTokenizer.nextToken();
- String res = resTokenizer.nextToken();
- if (!exp.equals(res)) {
- StringBuffer sb = new StringBuffer(255);
- sb.append("[TokenizedValidator]: Server's response and ");
- sb.append("goldenfile to not match!\n");
- sb.append("\n Goldenfile token: ").append(exp);
- sb.append("\n Response token: ").append(res);
- TestUtil.logErr(sb.toString());
- dumpResponseInfo(response, gf);
- return false;
- }
- }
- } else {
- TestUtil
- .logErr("[TokenizedValidator]: Token count between server response "
- + "and goldenfile do not match.\n Response Token" + "count: "
- + resCount + "\nGoldenfile Token count: " + gfCount);
-
- dumpResponseInfo(response, gf);
- return false;
- }
- TestUtil.logTrace("[TokenizedValidator]: Server's response matches the "
- + "configured goldenfile.");
- return true;
- }
-
- /*
- * private methods
- * ========================================================================
- */
-
- /**
- * Dumps the response from the server and the content of the Goldenfile/
- *
- * @param serverResponse
- * the response body from the server.
- * @param goldenFile
- * the test goldenfile
- */
- private static void dumpResponseInfo(String serverResponse,
- String goldenFile) {
- StringBuffer sb = new StringBuffer(255);
- sb.append("\nServer Response (below):\n");
- sb.append("------------------------------------------\n");
- sb.append(serverResponse);
- sb.append("\n------------------------------------------\n");
- sb.append("\nGoldenfile (below):\n");
- sb.append("------------------------------------------\n");
- sb.append(goldenFile);
- sb.append("\n------------------------------------------\n");
- TestUtil.logErr(sb.toString());
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/webclient/validation/ValidationFactory.java b/common/src/main/java/com/sun/ts/tests/common/webclient/validation/ValidationFactory.java
deleted file mode 100644
index 80d8310d17..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/webclient/validation/ValidationFactory.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 2007, 2018 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.webclient.validation;
-
-import com.sun.ts.lib.util.TestUtil;
-
-/**
- * Returns a ValidationStrategy instance used to validate a response against a
- * particular WebTestCase
- *
- * @author Ryan Lubke
- * @version %I%
- */
-public class ValidationFactory {
-
- /**
- * Private constructor as all interaction with the class is through the
- * getInstance() method.
- */
- private ValidationFactory() {
- }
-
- /*
- * public methods
- * ========================================================================
- */
-
- /**
- * Returns a ValidationStrategy instance based on the available factory types.
- *
- * @param validator
- * Validator instance to obtain
- * @return a ValidationStrategy instance or null if the instance could not be
- * obtained.
- */
- public static ValidationStrategy getInstance(String validator) {
- try {
- Object o = Thread.currentThread().getContextClassLoader()
- .loadClass(validator).newInstance();
- if (o instanceof ValidationStrategy) {
- return (ValidationStrategy) o;
- }
- } catch (Throwable t) {
- TestUtil.logMsg("[ValidationFactory] Unable to obtain "
- + "ValidationStrategy instance: " + validator);
- }
- return null;
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/common/webclient/validation/WebValidatorBase.java b/common/src/main/java/com/sun/ts/tests/common/webclient/validation/WebValidatorBase.java
deleted file mode 100644
index 3bff6024af..0000000000
--- a/common/src/main/java/com/sun/ts/tests/common/webclient/validation/WebValidatorBase.java
+++ /dev/null
@@ -1,684 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.common.webclient.validation;
-
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.commons.httpclient.Header;
-
-import com.sun.ts.lib.util.TestUtil;
-import com.sun.ts.tests.common.webclient.WebTestCase;
-import com.sun.ts.tests.common.webclient.handler.Handler;
-import com.sun.ts.tests.common.webclient.handler.HandlerFactory;
-import com.sun.ts.tests.common.webclient.http.HttpRequest;
-import com.sun.ts.tests.common.webclient.http.HttpResponse;
-
-/**
- * Base abstract class for WebTestCase validation.
- */
-public abstract class WebValidatorBase implements ValidationStrategy {
-
- /**
- * Used to detect 4xx class HTTP errors to allow fail fast situations when 4xx
- * errors are not expected.
- */
- protected static final char CLIENT_ERROR = '4';
-
- /**
- * Used to detect 5xx class HTTP errors to allows fail fast situations when
- * 5xx errors are not expected.
- */
- protected static final char SERVER_ERROR = '5';
-
- /**
- * This test case's HttpResponse
- */
- protected HttpResponse _res = null;
-
- /**
- * This test case's HttpRequest
- */
- protected HttpRequest _req = null;
-
- /**
- * The test case being validated
- */
- protected WebTestCase _case = null;
-
- /**
- * validate Will validate the response against the configured
- * TestCase.
- *
- *
- *
- * If test case status code null and response 4xx, return failure, print
- * error; return false
- *
- *
- *
- *
- * If test case status code null and response 5xx, return failure include
- * response body; return false
- *
- *
- *
- *
- * If test case status code null, and response not 4xx or 5xx, return true
- *
- *
- *
- *
- * Test case status code not null, compare it with the response status code;
- * return true if equal
- *
- *
- *
- *
- *
- * @return boolen result of check
- * @throws IOException
- * if an IO error occurs during validation
- */
- protected boolean checkStatusCode() throws IOException {
- String sCode = _case.getStatusCode();
- String resCode = _res.getStatusCode();
- if ("-1".equals(sCode))
- return true;
-
- if (sCode == null && resCode.charAt(0) == CLIENT_ERROR) {
- TestUtil
- .logErr("[WebValidatorBase] Unexpected " + resCode + " received from "
- + "target server! Request path: " + _req.getRequestPath());
- return false;
- }
-
- if (sCode == null && (resCode.charAt(0) == SERVER_ERROR)) {
- String resBody = _res.getResponseBodyAsRawString();
- StringBuffer sb = new StringBuffer(75 + resBody.length());
- sb.append("[WebValidatorBase] Unexpected '");
- sb.append(resCode).append("' received from target server!\n");
- sb.append("Error response recieved from server:\n");
- sb.append("------------------------------------------------\n");
- sb.append(resBody != null ? resBody : "NO RESPONSE");
- TestUtil.logErr(sb.toString());
- return false;
- }
-
- if (sCode == null) {
- return true;
- }
-
- /*
- * Take sCode as a comma separated list of status codes.
- *
- * If prefixed by "!" the response status code must not match any in the list.
- *
- * Otherwise matching any in the list is accepted.
- */
-
- boolean exclusions = sCode.charAt(0) == '!';
- String[] sCodes = exclusions ? sCode.substring(1).split(",") : sCode.split(",");
-
- if (exclusions) {
- for (String current : sCodes) {
- if (current.equals(resCode)) {
- TestUtil.logErr("[WebValidatorBase] Unexpected Status Code "
- + "recieved from server. Expected any value except '" + sCode
- + "', received '" + resCode + "'");
- return false;
- }
- }
- } else {
- boolean found = false;
- for (String current : sCodes) {
- if (current.equals(resCode)) {
- TestUtil.logTrace("[WebValidatorBase] Expected Status Code '" + current
- + "' found in response line!");
- found = true;
- break;
- }
- }
-
- if (!found) {
- TestUtil.logTrace("[WebValidatorBase] Status Code '" + sCode
- + "' not found in response line!");
-
- return false;
- }
- }
-
- return true;
- }
-
- /**
- * checkSearchStrings will scan the response for the configured
- * strings that are to be expected in the response.
- *
- *
Check search strings
- *
- *
- *
- * If list of Strings is null, return true.
- *
- *
- *
- *
- * If list of Strings is not null, scan response body. If string is found,
- * return true, otherwise display error and return false.
- *
- *
- *
- *
- * NOTE: If there are multiple search strings, the search will be
- * performed as such to preserve the order. For example, if the list of search
- * strings contains two entities, the search for the second entity will be
- * started after the index if the first match.
- *
- * @return boolen result of check
- * @throws IOException
- * if an IO error occurs during validation
- */
- protected boolean checkSearchStrings() throws IOException {
- List list = _case.getSearchStrings();
- boolean found = true;
- if (list != null && !list.isEmpty()) {
- String responseBody = _res.getResponseBodyAsRawString();
-
- String search = null;
-
- for (int i = 0, n = list.size(), startIdx = 0, bodyLength = responseBody
- .length(); i < n; i++) {
-
- // set the startIdx to the same value as the body length
- // and let the test fail (prevents index based runtime
- // exceptions).
- if (startIdx >= bodyLength) {
- startIdx = bodyLength;
- }
-
- search = (String) list.get(i);
- int searchIdx = responseBody.indexOf(search, startIdx);
-
- TestUtil.logTrace(
- "[WebValidatorBase] Scanning response for " + "search string: '"
- + search + "' starting at index " + "location: " + startIdx);
- if (searchIdx < 0) {
- found = false;
- StringBuffer sb = new StringBuffer(255);
- sb.append("[WebValidatorBase] Unable to find the following ");
- sb.append("search string in the server's ");
- sb.append("response: '").append(search).append("' at index: ");
- sb.append(startIdx);
- sb.append("\n[WebValidatorBase] Server's response:\n");
- sb.append("-------------------------------------------\n");
- sb.append(responseBody);
- sb.append("\n-------------------------------------------\n");
- TestUtil.logErr(sb.toString());
- break;
- }
-
- TestUtil.logTrace("[WebValidatorBase] Found search string: '" + search
- + "' at index '" + searchIdx + "' in the server's " + "response");
- // the new searchIdx is the old index plus the lenght of the
- // search string.
- startIdx = searchIdx + search.length();
- }
- }
- return found;
- }
-
- /**
- * checkSearchStringsNoCase will scan the response for the
- * configured case insensitive strings that are to be expected in the
- * response.
- *
- *
Check search strings
- *
- *
- *
- * If list of Strings is null, return true.
- *
- *
- *
- *
- * If list of Strings is not null, scan response body. If string is found,
- * return true, otherwise display error and return false.
- *
- *
- *
- *
- * NOTE: If there are multiple search strings, the search will be
- * performed as such to preserve the order. For example, if the list of search
- * strings contains two entities, the search for the second entity will be
- * started after the index if the first match.
- *
- * @return boolen result of check
- * @throws IOException
- * if an IO error occurs during validation
- */
- protected boolean checkSearchStringsNoCase() throws IOException {
- List list = _case.getSearchStringsNoCase();
- boolean found = true;
- if (list != null && !list.isEmpty()) {
- String responseBody = _res.getResponseBodyAsRawString();
-
- String search = null;
-
- for (int i = 0, n = list.size(), startIdx = 0, bodyLength = responseBody
- .length(); i < n; i++) {
-
- // set the startIdx to the same value as the body length
- // and let the test fail (prevents index based runtime
- // exceptions).
- if (startIdx >= bodyLength) {
- startIdx = bodyLength;
- }
-
- search = (String) list.get(i);
- int searchIdx = responseBody.toLowerCase().indexOf(search.toLowerCase(),
- startIdx);
-
- TestUtil.logTrace(
- "[WebValidatorBase] Scanning response for " + "search string: '"
- + search + "' starting at index " + "location: " + startIdx);
- if (searchIdx < 0) {
- found = false;
- StringBuffer sb = new StringBuffer(255);
- sb.append("[WebValidatorBase] Unable to find the following ");
- sb.append("search string in the server's ");
- sb.append("response: '").append(search).append("' at index: ");
- sb.append(startIdx);
- sb.append("\n[WebValidatorBase] Server's response:\n");
- sb.append("-------------------------------------------\n");
- sb.append(responseBody);
- sb.append("\n-------------------------------------------\n");
- TestUtil.logErr(sb.toString());
- break;
- }
-
- TestUtil.logTrace("[WebValidatorBase] Found search string: '" + search
- + "' at index '" + searchIdx + "' in the server's " + "response");
- // the new searchIdx is the old index plus the lenght of the
- // search string.
- startIdx = searchIdx + search.length();
- }
- }
- return found;
- }
-
- /**
- * checkUnorderedSearchStrings will scan the response for the
- * configured strings that are to be expected in the response.
- *
- *
Check search strings
- *
- *
- *
- * If list of Strings is null, return true.
- *
- *
- *
- *
- * If list of Strings is not null, scan response body. If string is found,
- * return true, otherwise display error and return false.
- *
- *
- *
- *
- *
- * @return boolen result of check
- * @throws IOException
- * if an IO error occurs during validation
- */
- protected boolean checkUnorderedSearchStrings() throws IOException {
- List list = _case.getUnorderedSearchStrings();
- boolean found = true;
- if (list != null && !list.isEmpty()) {
- String responseBody = _res.getResponseBodyAsRawString();
-
- String search = null;
-
- for (int i = 0, n = list.size(); i < n; i++) {
-
- search = (String) list.get(i);
- int searchIdx = responseBody.indexOf(search);
-
- TestUtil.logTrace("[WebValidatorBase] Scanning response for "
- + "search string: '" + search + "'...");
- if (searchIdx < 0) {
- found = false;
- StringBuffer sb = new StringBuffer(255);
- sb.append("[WebValidatorBase] Unable to find the following ");
- sb.append("search string in the server's ");
- sb.append("response: '").append(search);
- sb.append("\n[WebValidatorBase] Server's response:\n");
- sb.append("-------------------------------------------\n");
- sb.append(responseBody);
- sb.append("\n-------------------------------------------\n");
- TestUtil.logErr(sb.toString());
- break;
- }
-
- TestUtil.logTrace("[WebValidatorBase] Found search string: '" + search
- + "' at index '" + searchIdx + "' in the server's " + "response");
- }
- }
- return found;
- }
-
- /**
- * checkUnexpectedSearchStrings will scan the response for the
- * configured strings that are not expected in the response.
- *
- *
Check unexpected search strings
- *
- *
- *
- * If list of Strings is null, return true.
- *
- *
- *
- *
- * If list of Strings is not null, scan response body. If string is not found,
- * return true, otherwise display error and return false.
- *
- *
- *
- *
- *
- * @return boolen result of check
- * @throws IOException
- * if an IO error occurs during validation
- */
- protected boolean checkUnexpectedSearchStrings() throws IOException {
- List list = _case.getUnexpectedSearchStrings();
- if (list != null && !list.isEmpty()) {
- String responseBody = _res.getResponseBodyAsRawString();
- Iterator iter = list.iterator();
- while (iter.hasNext()) {
- String search = (String) iter.next();
- TestUtil.logTrace("[WebValidatorBase] Scanning response. The following"
- + " string should not be present in the response: '" + search
- + "'");
- if (responseBody.indexOf(search) > -1) {
- StringBuffer sb = new StringBuffer(255);
- sb.append("[WebValidatorBase] Found the following unexpected ");
- sb.append("search string in the server's ");
- sb.append("response: '").append(search).append("'");
- sb.append("\n[WebValidatorBase] Server's response:\n");
- sb.append("-------------------------------------------\n");
- sb.append(responseBody);
- sb.append("\n-------------------------------------------\n");
- TestUtil.logErr(sb.toString());
- return false;
- }
- }
- }
- return true;
- }
-
- /**
- * checkGoldenFile compare the server's response with the
- * configured goldenfile
- *
- *
Check the goldenfile
- *
- *
- *
- * If goldenfile is null, return true.
- *
- *
- *
- *
- * If goldenfile is not null, compare the goldenfile with the response. If
- * equal, return true, otherwise display error and return false.
- *
- *
- *
- *
- *
- * @return boolen result of check
- * @throws IOException
- * if an IO error occurs during validation
- */
- protected abstract boolean checkGoldenfile() throws IOException;
-
- /**
- * checkReasonPhrase will perform comparisons between the
- * configued reason-phrase and that of the response.
- *
- *
Check reason-phrase
- *
- *
- *
- * If configured reason-phrase is null, return true.
- *
- *
- *
- *
- * If configured reason-phrase is not null, compare the reason-phrases with
- * the response. If equal, return true, otherwise display error and return
- * false.
- *
- *
- *
- *
- *
- * @return boolen result of check
- */
- protected boolean checkReasonPhrase() {
- String sReason = _case.getReasonPhrase();
- String resReason = _res.getReasonPhrase();
-
- if (sReason == null) {
- return true;
- } else if (sReason.equalsIgnoreCase(resReason)) {
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * checkExpectedHeaders will check the response for the
- * configured expected headers.
- *
- *
Check expected headers
- *
- *
- *
- * If there are no expected headers, return true.
- *
- *
- *
- *
- * If there are expected headers, scan the response for the expected headers.
- * If all expected headers are found, return true, otherwise display an error
- * and return false.
- *
- *
- *
- *
- *
- * @return boolen result of check
- */
- protected boolean checkExpectedHeaders() {
- Header[] expected = _case.getExpectedHeaders();
- if (isEmpty(expected)) {
- return true;
- } else {
- boolean found = true;
- Header currentHeader = null;
- for (int i = 0; i < expected.length; i++) {
- currentHeader = expected[i];
- Header resHeader = _res.getResponseHeader(currentHeader.getName());
- if (resHeader != null) {
- Handler handler = HandlerFactory.getHandler(currentHeader.getName());
- if (!handler.invoke(currentHeader, resHeader)) {
- found = false;
- break;
- }
- } else {
- found = false;
- break;
- }
- }
- if (!found) {
- StringBuffer sb = new StringBuffer(255);
- sb.append("[WebValidatorBase] Unable to find the following header");
- sb.append(" in the server's response: ");
- sb.append(currentHeader.toExternalForm()).append("\n");
- sb.append("[WebValidatorBase] Response headers recieved from");
- sb.append(" server:");
-
- Header[] resHeaders = _res.getResponseHeaders();
- for (int i = 0; i < resHeaders.length; i++) {
- sb.append("\n\tResponseHeader -> ");
- sb.append(resHeaders[i].toExternalForm());
- }
- sb.append("\n");
- TestUtil.logErr(sb.toString());
-
- return false;
- } else {
- TestUtil.logTrace("[WebValidatorBase] Found expected header: "
- + currentHeader.toExternalForm());
- return true;
- }
- }
- }
-
- /**
- * checkUnexpectedHeaders will check the response for the
- * configured unexpected expected headers.
- *
- *
Check unexpected headers
- *
- *
- *
- * If there are no configured unexpected headers, return true.
- *
- *
- *
- *
- * If there are configured unexpected headers, scan the response for the
- * unexpected headers. If the headers are not found, return true, otherwise
- * display an error and return false.
- *
- *
- *
- *
- *
- * @return boolen result of check
- */
- protected boolean checkUnexpectedHeaders() {
- Header[] unexpected = _case.getUnexpectedHeaders();
- if (isEmpty(unexpected)) {
- return true;
- } else {
- Header currentHeader = null;
- for (int i = 0; i < unexpected.length; i++) {
- currentHeader = unexpected[i];
- String currName = currentHeader.getName();
- String currValue = currentHeader.getValue();
- Header resHeader = _res.getResponseHeader(currName);
- if (resHeader != null) {
- if (resHeader.getValue().equals(currValue)) {
- StringBuffer sb = new StringBuffer(255);
- sb.append("[WebValidatorBase] Unexpected header found in the ");
- sb.append("server's response: ");
- sb.append(currentHeader.toExternalForm()).append("\n");
- sb.append("[WebValidatorBase] Response headers recieved from");
- sb.append("server:");
-
- Header[] resHeaders = _res.getResponseHeaders();
- for (int j = 0; j < resHeaders.length; j++) {
- sb.append("\n\tResponseHeader -> ");
- sb.append(resHeaders[j].toExternalForm());
- }
- sb.append("\n");
- TestUtil.logErr(sb.toString());
-
- return false;
- }
- }
- }
- }
- return true;
- }
-
- /**
- * Utility method to determine of the expected or unexpected headers are empty
- * or not.
- */
- protected boolean isEmpty(Header[] headers) {
- if (headers == null || headers.length == 0) {
- return true;
- } else {
- return false;
- }
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/jms/common/BytesMessageTestImpl.java b/common/src/main/java/com/sun/ts/tests/jms/common/BytesMessageTestImpl.java
deleted file mode 100644
index 95f0a9869b..0000000000
--- a/common/src/main/java/com/sun/ts/tests/jms/common/BytesMessageTestImpl.java
+++ /dev/null
@@ -1,933 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.jms.common;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.EOFException;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.ObjectStreamField;
-
-import jakarta.jms.BytesMessage;
-import jakarta.jms.JMSException;
-import jakarta.jms.MessageEOFException;
-import jakarta.jms.MessageFormatException;
-import jakarta.jms.MessageNotReadableException;
-import jakarta.jms.MessageNotWriteableException;
-
-/**
- * Class Declaration.
- *
- * @see
- *
- * @author
- */
-public class BytesMessageTestImpl extends MessageTestImpl
- implements BytesMessage {
- static final private ObjectStreamField[] serialPersistentFields = {
- new ObjectStreamField("buf", byte[].class) };
-
- long bodyLength = 0;
-
- transient ByteArrayInputStream bais;
-
- transient DataInputStream dis;
-
- byte[] buf;
-
- transient ByteArrayOutputStream baos;
-
- transient DataOutputStream dos;
-
- /**
- * Class Constructor.
- *
- * @see
- */
- public BytesMessageTestImpl() {
- super();
- init();
- }
-
- /**
- * Method Declaration.
- *
- *
- * @see
- */
- private void init() {
- buf = new byte[0];
- baos = new ByteArrayOutputStream();
- dos = new DataOutputStream(baos);
- }
-
- /**
- * Method Declaration.
- *
- * @param oos
- *
- * @exception IOException
- *
- * @see
- */
- private void writeObject(ObjectOutputStream oos) throws IOException {
- dos.flush();
- buf = baos.toByteArray();
- oos.defaultWriteObject();
- }
-
- /**
- * Method Declaration.
- *
- * @param ois
- *
- * @exception ClassNotFoundException
- * @exception IOException
- *
- * @see
- */
- private void readObject(ObjectInputStream ois)
- throws ClassNotFoundException, IOException {
- ois.defaultReadObject();
- baos = new ByteArrayOutputStream();
- dos = new DataOutputStream(baos);
- if (buf != null) {
- dos.write(buf);
- buf = null;
- }
- }
-
- /**
- * Method Declaration.
- *
- * @exception JMSException
- *
- * @see
- */
- public void clearBody() throws JMSException {
- buf = null;
- bais = null;
- dis = null;
- readMode = false;
- }
-
- /**
- * Read a boolean from the BytesMessage.
- *
- * @return the boolean value read.
- *
- * @exception MessageNotReadableException
- * if message in write-only mode.
- * @exception JMSException
- * if JMS fails to read message due to some internal JMS error.
- * @exception MessageEOFException
- * if end of message stream
- */
- public boolean readBoolean() throws JMSException {
- boolean ret = false;
- checkReadAccess();
-
- try {
- ret = dis.readBoolean();
- } catch (EOFException e1) {
- throw new MessageEOFException("at end of message"); // I18N
- } catch (IOException e2) {
- JMSException jmsEx = new JMSException("IOException"); // I18N
-
- jmsEx.setLinkedException(e2);
- throw jmsEx;
- } // try .. catch
- return ret;
- } // readBoolean()
-
- /**
- * Read a signed 8-bit value from the BytesMessage.
- *
- * @return the next byte from the BytesMessage as a signed 8-bit
- * byte.
- *
- * @exception MessageNotReadableException
- * if message in write-only mode.
- * @exception MessageEOFException
- * if end of message stream
- * @exception JMSException
- * if JMS fails to read message due to some internal JMS error.
- */
- public byte readByte() throws JMSException {
- com.sun.ts.lib.util.TestUtil.logTrace("readByte");
- checkReadAccess();
-
- byte ret = 0;
- try {
- ret = dis.readByte();
- } catch (EOFException e1) {
- throw new MessageEOFException("at end of message"); // I18N
- } catch (IOException e2) {
- JMSException jmsEx = new JMSException("IOException"); // I18N
-
- jmsEx.setLinkedException(e2);
- throw jmsEx;
- } // try .. catch
- return ret;
- } // readByte()
-
- /**
- * Read an unsigned 8-bit number from the BytesMessage.
- *
- * @return the next byte from the BytesMessage, interpreted as an unsigned
- * 8-bit number.
- *
- * @exception MessageNotReadableException
- * if message in write-only mode.
- * @exception MessageEOFException
- * if end of message stream
- * @exception JMSException
- * if JMS fails to read message due to some internal JMS error.
- */
- public int readUnsignedByte() throws JMSException {
- com.sun.ts.lib.util.TestUtil.logTrace("readUnsignedByte");
- int ret = 0;
- checkReadAccess();
-
- try {
- ret = dis.readUnsignedByte();
- } catch (EOFException e1) {
- throw new MessageEOFException("at end of message"); // I18N
- } catch (IOException e2) {
- JMSException jmsEx = new JMSException("IOException"); // I18N
-
- jmsEx.setLinkedException(e2);
- throw jmsEx;
- } // try .. catch
- return ret;
- } // readUnsignedByte()
-
- /**
- * Read a signed 16-bit number from the BytesMessage.
- *
- * @return the next two bytes from the BytesMessage, interpreted as a signed
- * 16-bit number.
- *
- * @exception MessageNotReadableException
- * if message in write-only mode.
- * @exception MessageEOFException
- * if end of message stream
- * @exception JMSException
- * if JMS fails to read message due to some internal JMS error.
- */
- public short readShort() throws JMSException {
- com.sun.ts.lib.util.TestUtil.logTrace("readShort");
- checkReadAccess();
- short ret = 0;
-
- try {
- ret = dis.readShort();
- } catch (EOFException e1) {
- throw new MessageEOFException("at end of message"); // I18N
- } catch (IOException e2) {
- JMSException jmsEx = new JMSException("IOException"); // I18N
-
- jmsEx.setLinkedException(e2);
- throw jmsEx;
- } // try .. catch
- return ret;
- } // readShort()
-
- /**
- * Read an unsigned 16-bit number from the BytesMessage.
- *
- * @return the next two bytes from the BytesMessage, interpreted as an
- * unsigned 16-bit integer.
- *
- * @exception MessageNotReadableException
- * if message in write-only mode.
- * @exception MessageEOFException
- * if end of message stream
- * @exception JMSException
- * if JMS fails to read message due to some internal JMS error.
- */
- public int readUnsignedShort() throws JMSException {
- com.sun.ts.lib.util.TestUtil.logTrace("readUnsignedShort");
- checkReadAccess();
- int ret = 0;
-
- try {
- ret = dis.readUnsignedShort();
- } catch (EOFException e1) {
- throw new MessageEOFException("at end of message"); // I18N
- } catch (IOException e2) {
- JMSException jmsEx = new JMSException("IOException"); // I18N
-
- jmsEx.setLinkedException(e2);
- throw jmsEx;
- } // try .. catch
- return ret;
- } // readUnsignedShort()
-
- /**
- * Read a Unicode character value from the BytesMessage.
- *
- * @return the next two bytes from the BytesMessage as a Unicode character.
- *
- * @exception MessageNotReadableException
- * if message in write-only mode.
- * @exception MessageEOFException
- * if end of message stream
- * @exception JMSException
- * if JMS fails to read message due to some internal JMS error.
- */
- public char readChar() throws JMSException {
- com.sun.ts.lib.util.TestUtil.logTrace("readChar");
- checkReadAccess();
- char ret = 0;
-
- try {
- ret = dis.readChar();
- } catch (EOFException e1) {
- throw new MessageEOFException("at end of message"); // I18N
- } catch (IOException e2) {
- JMSException jmsEx = new JMSException("IOException"); // I18N
-
- jmsEx.setLinkedException(e2);
- throw jmsEx;
- } // try .. catch
- return ret;
- } // readChar()
-
- /**
- * Read a signed 32-bit integer from the BytesMessage.
- *
- * @return the next four bytes from the BytesMessage, interpreted as an
- * int.
- *
- * @exception MessageNotReadableException
- * if message in write-only mode.
- * @exception MessageEOFException
- * if end of message stream
- * @exception JMSException
- * if JMS fails to read message due to some internal JMS error.
- */
- public int readInt() throws JMSException {
- com.sun.ts.lib.util.TestUtil.logTrace("readInt");
- checkReadAccess();
- int ret = 0;
-
- try {
- ret = dis.readInt();
- } catch (EOFException e1) {
- throw new MessageEOFException("at end of message"); // I18N
- } catch (IOException e2) {
- JMSException jmsEx = new JMSException("IOException"); // I18N
-
- jmsEx.setLinkedException(e2);
- throw jmsEx;
- } // try .. catch
- return ret;
- } // readInt()
-
- /**
- * Read a signed 64-bit integer from the BytesMessage.
- *
- * @return the next eight bytes from the BytesMessage, interpreted as a
- * long.
- *
- * @exception MessageNotReadableException
- * if message in write-only mode.
- * @exception MessageEOFException
- * if end of message stream
- * @exception JMSException
- * if JMS fails to read message due to some internal JMS error.
- */
- public long readLong() throws JMSException {
- com.sun.ts.lib.util.TestUtil.logTrace("readLong");
- checkReadAccess();
- long ret = 0;
-
- try {
- ret = dis.readLong();
- } catch (EOFException e1) {
- throw new MessageEOFException("at end of message"); // I18N
- } catch (IOException e2) {
- JMSException jmsEx = new JMSException("IOException"); // I18N
-
- jmsEx.setLinkedException(e2);
- throw jmsEx;
- } // try .. catch
- return ret;
- } // readLong()
-
- /**
- * Read a float from the BytesMessage.
- *
- * @return the next four bytes from the BytesMessage, interpreted as a
- * float.
- *
- * @exception MessageNotReadableException
- * if message in write-only mode.
- * @exception MessageEOFException
- * if end of message stream
- * @exception JMSException
- * if JMS fails to read message due to some internal JMS error.
- */
- public float readFloat() throws JMSException {
- com.sun.ts.lib.util.TestUtil.logTrace("readFloat");
- checkReadAccess();
- float ret = 0;
-
- try {
- ret = dis.readFloat();
- } catch (EOFException e1) {
- throw new MessageEOFException("at end of message"); // I18N
- } catch (IOException e2) {
- JMSException jmsEx = new JMSException("IOException"); // I18N
-
- jmsEx.setLinkedException(e2);
- throw jmsEx;
- } // try .. catch
- return ret;
- } // readFloat()
-
- /**
- * Read a double from the BytesMessage.
- *
- * @return the next eight bytes from the BytesMessage, interpreted as a
- * double.
- *
- * @exception MessageNotReadableException
- * if message in write-only mode.
- * @exception MessageEOFException
- * if end of message stream
- * @exception JMSException
- * if JMS fails to read message due to some internal JMS error.
- */
- public double readDouble() throws JMSException {
- com.sun.ts.lib.util.TestUtil.logTrace("readDouble");
- checkReadAccess();
- double ret = 0;
-
- try {
- ret = dis.readDouble();
- } catch (EOFException e1) {
- throw new MessageEOFException("at end of message"); // I18N
- } catch (IOException e2) {
- JMSException jmsEx = new JMSException("IOException"); // I18N
-
- jmsEx.setLinkedException(e2);
- throw jmsEx;
- } // try .. catch
- return ret;
- } // readDouble()
-
- /**
- * Read in a string that has been encoded using a modified UTF-8 format from
- * the BytesMessage.
- *
- *
- * For more information on the UTF-8 format, see "File System Safe UCS
- * Transformation Format (FSS_UFT)", X/Open Preliminary Specification, X/Open
- * Company Ltd., Document Number: P316. This information also appears in
- * ISO/IEC 10646, Annex P.
- *
- * @return a Unicode string from the BytesMessage.
- *
- * @exception MessageNotReadableException
- * if message in write-only mode.
- * @exception MessageEOFException
- * if end of message stream
- * @exception JMSException
- * if JMS fails to read message due to some internal JMS error.
- */
- public String readUTF() throws JMSException {
- com.sun.ts.lib.util.TestUtil.logTrace("readUTF");
- checkReadAccess();
- String ret = null;
-
- try {
- ret = dis.readUTF();
- } catch (EOFException e1) {
- throw new MessageEOFException("at end of message"); // I18N
- } catch (IOException e2) {
- JMSException jmsEx = new JMSException("IOException"); // I18N
-
- jmsEx.setLinkedException(e2);
- throw jmsEx;
- } // try .. catch
- return ret;
- } // readUTF()
-
- /**
- * Read a byte array from the BytesMessage.
- *
- * @param value
- * the buffer into which the data is read.
- *
- * @return the total number of bytes read into the buffer, or -1 if there is
- * no more data because the end of the stream has been reached.
- *
- * @exception MessageNotReadableException
- * if message in write-only mode.
- * @exception MessageEOFException
- * if end of message stream
- * @exception JMSException
- * if JMS fails to read message due to some internal JMS error.
- */
- public int readBytes(byte[] value) throws JMSException {
- com.sun.ts.lib.util.TestUtil.logTrace("readBytes");
- checkReadAccess();
- int ret = -1;
-
- try {
- ret = dis.read(value);
- } catch (IOException e2) {
- JMSException jmsEx = new JMSException("IOException"); // I18N
-
- jmsEx.setLinkedException(e2);
- throw jmsEx;
- } // try .. catch
- return ret;
- } // readBytes()
-
- /**
- * Read a portion of the bytes message.
- *
- * @param value
- * the buffer into which the data is read.
- * @param length
- * the number of bytes to read.
- *
- * @return the total number of bytes read into the buffer, or -1 if there is
- * no more data because the end of the stream has been reached.
- *
- * @exception MessageNotReadableException
- * if message in write-only mode.
- * @exception MessageEOFException
- * if end of message stream
- * @exception JMSException
- * if JMS fails to read message due to some internal JMS error.
- */
- public int readBytes(byte[] value, int length) throws JMSException {
- com.sun.ts.lib.util.TestUtil.logTrace("readBytes");
- checkReadAccess();
- int ret = -1;
-
- if ((length < 0) || (length > value.length)) {
- throw new IndexOutOfBoundsException();
- }
- try {
- ret = dis.read(value, 0, length);
- } catch (IOException e2) {
- JMSException jmsEx = new JMSException("IOException"); // I18N
-
- jmsEx.setLinkedException(e2);
- throw jmsEx;
- } // try .. catch
- return ret;
- } // readBytes()
-
- /**
- * Write a boolean to the BytesMessage as a 1-byte value. The
- * value true is written out as the value (byte)1;
- * the value false is written out as the value
- * (byte)0.
- *
- * @param value
- * the boolean value to be written.
- *
- * @exception MessageNotWriteableException
- * if message in read-only mode.
- * @exception JMSException
- * if JMS fails to write message due to some internal JMS error.
- */
- public void writeBoolean(boolean writeBoolean) throws JMSException {
-
- try {
- dos.writeBoolean(writeBoolean);
- } catch (IOException e) {
- JMSException jmsEx = new JMSException("IOException"); // I18N
-
- jmsEx.setLinkedException(e);
- throw jmsEx;
- } // try .. catch
- } // writeBoolean()
-
- /**
- * Write out a byte to the BytesMessage as a 1-byte value.
- *
- * @param value
- * the byte value to be written.
- *
- * @exception MessageNotWriteableException
- * if message in read-only mode.
- * @exception JMSException
- * if JMS fails to write message due to some internal JMS error.
- */
- public void writeByte(byte value) throws JMSException {
-
- try {
- dos.writeByte((int) value);
- setBufferIsDirty(true);
- } catch (IOException e) {
- JMSException jmsEx = new JMSException("IOException"); // I18N
-
- jmsEx.setLinkedException(e);
- throw jmsEx;
- }
- } // writeByte()
-
- /**
- * Write a short to the BytesMessage as two bytes, high byte
- * first.
- *
- * @param value
- * the short to be written.
- *
- * @exception MessageNotWriteableException
- * if message in read-only mode.
- * @exception JMSException
- * if JMS fails to write message due to some internal JMS error.
- */
- public void writeShort(short value) throws JMSException {
-
- try {
- dos.writeShort((int) value);
- setBufferIsDirty(true);
- } catch (IOException e) {
- JMSException jmsEx = new JMSException("IOException"); // I18N
-
- jmsEx.setLinkedException(e);
- throw jmsEx;
- }
- } // writeShort()
-
- /**
- * Write a char to the BytesMessage as a 2-byte value, high byte
- * first.
- *
- * @param value
- * the char value to be written.
- *
- * @exception MessageNotWriteableException
- * if message in read-only mode.
- * @exception JMSException
- * if JMS fails to write message due to some internal JMS error.
- */
- public void writeChar(char value) throws JMSException {
-
- try {
- dos.writeChar((int) value);
- setBufferIsDirty(true);
- } catch (IOException e) {
- JMSException jmsEx = new JMSException("IOException"); // I18N
-
- jmsEx.setLinkedException(e);
- throw jmsEx;
- }
- } // writeChar()
-
- /**
- * Write an int to the BytesMessage as four bytes, high byte
- * first.
- *
- * @param value
- * the int to be written.
- *
- * @exception MessageNotWriteableException
- * if message in read-only mode.
- * @exception JMSException
- * if JMS fails to write message due to some internal JMS error.
- */
- public void writeInt(int value) throws JMSException {
- try {
- dos.writeInt(value);
- setBufferIsDirty(true);
- } catch (IOException e) {
- JMSException jmsEx = new JMSException("IOException"); // I18N
-
- jmsEx.setLinkedException(e);
- throw jmsEx;
- }
- } // writeInt()
-
- /**
- * Write a long to the BytesMessage as eight bytes, high byte
- * first.
- *
- * @param value
- * the long to be written.
- *
- * @exception MessageNotWriteableException
- * if message in read-only mode.
- * @exception JMSException
- * if JMS fails to write message due to some internal JMS error.
- */
- public void writeLong(long value) throws JMSException {
- try {
- dos.writeLong(value);
- setBufferIsDirty(true);
- } catch (IOException e) {
- JMSException jmsEx = new JMSException("IOException"); // I18N
-
- jmsEx.setLinkedException(e);
- throw jmsEx;
- }
- } // writeLong()
-
- /**
- * Convert the float argument to an int using the
- * floatToIntBits method in class Float, and then
- * writes that int value to the stream message as a 4-byte
- * quantity, high byte first.
- *
- * @param value
- * the float value to be written.
- *
- * @exception MessageNotWriteableException
- * if message in read-only mode.
- * @exception JMSException
- * if JMS fails to write message due to some internal JMS error.
- */
- public void writeFloat(float value) throws JMSException {
- try {
- dos.writeFloat(value);
- setBufferIsDirty(true);
- } catch (IOException e) {
- JMSException jmsEx = new JMSException("IOException"); // I18N
-
- jmsEx.setLinkedException(e);
- throw jmsEx;
- }
- } // writeFloat()
-
- /**
- * Convert the double argument to a long using the
- * doubleToLongBits method in class Double, and then
- * writes that long value to the stream message as an 8-byte
- * quantity, high byte first.
- *
- * @param value
- * the double value to be written.
- *
- * @exception MessageNotWriteableException
- * if message in read-only mode.
- * @exception JMSException
- * if JMS fails to write message due to some internal JMS error.
- */
- public void writeDouble(double value) throws JMSException {
- try {
- dos.writeDouble(value);
- setBufferIsDirty(true);
- } catch (IOException e) {
- JMSException jmsEx = new JMSException("IOException"); // I18N
-
- jmsEx.setLinkedException(e);
- throw jmsEx;
- }
- } // writeDouble()
-
- /**
- * Write a string to the BytesMessage using UTF-8 encoding in a
- * machine-independent manner.
- *
- *
- * For more information on the UTF-8 format, see "File System Safe UCS
- * Transformation Format (FSS_UFT)", X/Open Preliminary Specification, X/Open
- * Company Ltd., Document Number: P316. This information also appears in
- * ISO/IEC 10646, Annex P.
- *
- * @param value
- * the String value to be written.
- *
- * @exception MessageNotWriteableException
- * if message in read-only mode.
- * @exception JMSException
- * if JMS fails to write message due to some internal JMS error.
- */
- public void writeUTF(String value) throws JMSException {
- try {
- dos.writeUTF(value);
- setBufferIsDirty(true);
- } catch (IOException e) {
- JMSException jmsEx = new JMSException("IOException"); // I18N
-
- jmsEx.setLinkedException(e);
- throw jmsEx;
- }
- } // writeUTF()
-
- /**
- * Write a byte array to the BytesMessage.
- *
- * @param value
- * the byte array to be written.
- *
- * @exception MessageNotWriteableException
- * if message in read-only mode.
- * @exception JMSException
- * if JMS fails to write message due to some internal JMS error.
- */
- public void writeBytes(byte[] value) throws JMSException {
- try {
- dos.write(value);
- setBufferIsDirty(true);
- } catch (IOException e) {
- JMSException jmsEx = new JMSException("IOException"); // I18N
-
- jmsEx.setLinkedException(e);
- throw jmsEx;
- }
- } // writeBytes()
-
- /**
- * Write a portion of a byte array to the BytesMessage.
- *
- * @param value
- * the byte array value to be written.
- * @param offset
- * the initial offset within the byte array.
- * @param length
- * the number of bytes to use.
- *
- * @exception MessageNotWriteableException
- * if message in read-only mode.
- * @exception JMSException
- * if JMS fails to write message due to some internal JMS error.
- */
- public void writeBytes(byte[] value, int offset, int length)
- throws JMSException {
- try {
- dos.write(value, offset, length);
- setBufferIsDirty(true);
- } catch (IOException e) {
- JMSException jmsEx = new JMSException("IOException"); // I18N
-
- jmsEx.setLinkedException(e);
- throw jmsEx;
- }
- } // writeBytes()
-
- /**
- * Write a Java object to the BytesMessage.
- *
- *
- * Note that this method only works for the objectified primitive object types
- * (Integer, Double, Long ...), String's and byte arrays.
- *
- * @param value
- * the Java object to be written.
- *
- * @exception MessageNotWriteableException
- * if message in read-only mode.
- * @exception MessageFormatException
- * if object is invalid type.
- * @exception JMSException
- * if JMS fails to write message due to some internal JMS error.
- */
- public void writeObject(Object value) throws JMSException {
- if (value == null) {
- throw new NullPointerException();
- }
- if (value instanceof Boolean) {
- writeBoolean(((Boolean) value).booleanValue());
- } else if (value instanceof Byte) {
- writeByte(((Byte) value).byteValue());
- } else if (value instanceof Character) {
- writeChar(((Character) value).charValue());
- } else if (value instanceof Double) {
- writeDouble(((Double) value).doubleValue());
- } else if (value instanceof Float) {
- writeFloat(((Float) value).floatValue());
- } else if (value instanceof Integer) {
- writeInt(((Integer) value).intValue());
- } else if (value instanceof Long) {
- writeLong(((Long) value).longValue());
- } else if (value instanceof Short) {
- writeShort(((Short) value).shortValue());
- } else if (value instanceof String) {
- writeUTF((String) value);
- } else if (value instanceof byte[]) {
- writeBytes((byte[]) value);
- } else {
- throw new MessageFormatException("Invalid type"); // I18N
- } // if .. else
- } // writeObject()
-
- /**
- * Put the message in read-only mode, and reposition the stream of bytes to
- * the beginning.
- *
- * @exception JMSException
- * if JMS fails to reset the message due to some internal JMS
- * error.
- * @exception MessageFormatException
- * if message has an invalid format
- */
- public void reset() throws JMSException {
-
- // forces any buffered output bytes to be written out to the stream
- // not really needed in this case, because the underlying output stream
- // is a ByteArrayOutputStream
- try {
- if (bufferIsDirty) {
- com.sun.ts.lib.util.TestUtil.logTrace("flush dos");
- dos.flush();
- dos.close();
- baos.close();
- }
-
- } catch (IOException e) {
- JMSException jmsEx = new JMSException("IOException");
- jmsEx.setLinkedException(e);
- throw jmsEx;
- }
-
- if (baos != null) {
-
- // copy the content of DataOutputStream dos to buf
- buf = baos.toByteArray();
- com.sun.ts.lib.util.TestUtil.logTrace("baos.toByteArray");
-
- } else {
- if (buf == null) {
- buf = new byte[0];
- com.sun.ts.lib.util.TestUtil.logTrace("buf = new byte[0]");
- }
- }
- bais = new ByteArrayInputStream(buf);
- com.sun.ts.lib.util.TestUtil.logTrace("dis = new DataInputStream(bais)");
- dis = new DataInputStream(bais);
-
- setBufferIsDirty(false);
- readMode = true;
- }
-
- public long getBodyLength() {
- return bodyLength;
- }
-
- public void setBodyLength(long l) {
- bodyLength = l;
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/jms/common/Cleanup.java b/common/src/main/java/com/sun/ts/tests/jms/common/Cleanup.java
deleted file mode 100644
index 3778fb16de..0000000000
--- a/common/src/main/java/com/sun/ts/tests/jms/common/Cleanup.java
+++ /dev/null
@@ -1,329 +0,0 @@
-/*
- * Copyright (c) 2013, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-package com.sun.ts.tests.jms.common;
-
-import java.util.ArrayList;
-import java.util.Enumeration;
-
-import com.sun.ts.lib.util.TestUtil;
-
-import jakarta.jms.Connection;
-import jakarta.jms.ConnectionFactory;
-import jakarta.jms.Destination;
-import jakarta.jms.Message;
-import jakarta.jms.MessageConsumer;
-import jakarta.jms.MessageProducer;
-import jakarta.jms.ObjectMessage;
-import jakarta.jms.Queue;
-import jakarta.jms.QueueBrowser;
-import jakarta.jms.Session;
-
-public final class Cleanup {
- private String user = null;
-
- private String pass = null;
-
- private ConnectionFactory cf = null;
-
- public static final String JMSDEFAULT = "jmsDefault";
-
- /**
- * Default constructor
- */
- public Cleanup() {
- this(JMSDEFAULT, JMSDEFAULT, null);
- }
-
- /**
- * Second constructor
- *
- * @param ConnectionFactory
- * connfactory the connection factory object
- */
- public Cleanup(ConnectionFactory cf) {
- this(JMSDEFAULT, JMSDEFAULT, cf);
- }
-
- /**
- * Third constructor
- *
- * @param String
- * user the username credentials
- * @param String
- * pass the password credentials
- * @param ConnectionFactory
- * connfactory the connection factory object
- */
- public Cleanup(String user, String pass, ConnectionFactory cf) {
- this.user = user;
- this.pass = pass;
- this.cf = cf;
- }
-
- /**
- * Use this method at cleanup time to remove any connections and messages that
- * have remained on the queue.
- *
- * @param ArrayList
- * connections list of open connections
- * @param ArrayList
- * queues list of queues to flush
- */
- public void doClientQueueTestCleanup(ArrayList connections,
- ArrayList queues) {
- TestUtil.logTrace("Entering doClientQueueTestCleanup()");
- try {
- closeAllConnections(connections);
- flushQueue(queues);
- if (queues != null) {
- queues.clear();
- }
-
- if (connections != null) {
- connections.clear();
- }
- } catch (Exception e) {
- TestUtil.logTrace("Ignoring exception: " + e);
- }
- TestUtil.logTrace("Leaving doClientQueueTestCleanup()");
- }
-
- /**
- * Close any connections opened by the tests
- *
- * @param ArrayList
- * connections list of connections to close
- */
- public void closeAllConnections(ArrayList connections) {
- TestUtil.logTrace("Entering closeAllConnections()");
- try {
- if (connections != null) {
- if (!connections.isEmpty()) {
- for (int i = 0; i < connections.size(); i++) {
- ((Connection) connections.get(i)).close();
- }
- }
- }
- } catch (Exception e) {
- }
- TestUtil.logTrace("Leaving closeAllConnections()");
- }
-
- /**********************************************************************************
- * flushDestination(Destination)
- *
- * Use this method at cleanup time to remove any messages that have remained
- * on the queue.
- **********************************************************************************/
- public void flushDestination(Destination destination) throws Exception {
- Connection conn = null;
- MessageConsumer consumer = null;
- MessageProducer producer = null;
- Session sess = null;
- ObjectMessage msg = null;
- int priority = 0;
- int numMsgsFlushed = 0;
-
- TestUtil.logTrace("Entering flushDestination()");
- try {
- TestUtil.logTrace(
- "Create new Connection,Session,MessageProducer,MessageConsumer to flush Destination");
- conn = cf.createConnection(user, pass);
- sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
- producer = sess.createProducer(destination);
- consumer = sess.createConsumer(destination);
- conn.start(); // start the connections so that messages may be received.
-
- // send a low priority message
- // any other messages on the queue should be received first
- // and low priority message should signal the end
- msg = sess.createObjectMessage();
- msg.setObject("Flush Destination");
- msg.setStringProperty("COM_SUN_JMS_TESTNAME", "flushDestination");
- TestUtil.logTrace(
- "Send low priority message to Destination to signal the last message");
- producer.send(msg, jakarta.jms.Message.DEFAULT_DELIVERY_MODE, priority,
- jakarta.jms.Message.DEFAULT_TIME_TO_LIVE);
-
- // flush the Destination
- TestUtil.logTrace("Now flush the Destination");
- Message rmsg = consumer.receive(5000);
- while (rmsg != null) {
- String tname = rmsg.getStringProperty("COM_SUN_JMS_TESTNAME");
- if (tname != null && tname.equals("flushDestination")) {
- // Should be last message (try receiveNoWait() to make sure it is)
- rmsg = consumer.receiveNoWait();
- while (rmsg != null) {
- numMsgsFlushed++;
- rmsg = consumer.receiveNoWait();
- }
- break;
- } else {
- numMsgsFlushed++;
- rmsg = consumer.receiveNoWait();
- }
- }
- if (numMsgsFlushed > 0) {
- TestUtil.logTrace("#######flushed " + numMsgsFlushed + " messages");
- }
- } catch (Exception e) {
- TestUtil.logErr("flushDestination exception: " + e.toString());
- TestUtil.printStackTrace(e);
- } finally {
- try {
- conn.close();
- } catch (Exception e) {
- }
- }
- TestUtil.logTrace("Leaving flushDestination()");
- }
-
- /**********************************************************************************
- * flushQueue(ArrayList)
- *
- * Use this method at cleanup time to remove any messages that have remained
- * on the queue.
- *
- * @param Queue
- * qToFlush[] QUEUES
- **********************************************************************************/
- public void flushQueue(ArrayList queues) throws Exception {
- Connection qc = null;
- MessageConsumer qconsumer = null;
- Session qs = null;
- ObjectMessage msg = null;
- Enumeration msgs = null;
- int priority = 0;
- int numMsgsFlushed = 0;
- int numMsgs = 0;
-
- TestUtil.logTrace("Entering flushQueue(Arraylist)");
- try {
- TestUtil.logTrace("Create new Connection,Session to flush Queue");
- qc = cf.createConnection(user, pass);
- qs = qc.createSession(false, Session.AUTO_ACKNOWLEDGE);
- qc.start(); // start the connections so that messages may be received.
-
- for (int i = 0; i < queues.size(); i++) {
- TestUtil.logTrace(
- "Create QueueBrowser to count number of messages left on Queue");
- QueueBrowser qBrowser = qs.createBrowser((Queue) queues.get(i));
- // count the number of messages
- msgs = qBrowser.getEnumeration();
- while (msgs.hasMoreElements()) {
- msgs.nextElement();
- numMsgs++;
- }
-
- if (numMsgs == 0) {
- TestUtil.logTrace("No messages left on Queue "
- + ((Queue) queues.get(i)).getQueueName());
- } else {
- TestUtil.logTrace(numMsgs + " messages left on Queue "
- + ((Queue) queues.get(i)).getQueueName());
-
- TestUtil.logTrace(
- "Create new MessageConsumer to flush messages in Queue");
- qconsumer = qs.createConsumer((Queue) queues.get(i));
-
- // flush the queue
- TestUtil.logTrace("Now flush the Queue");
- Message rmsg = qconsumer.receive(5000);
- while (rmsg != null) {
- numMsgsFlushed++;
- rmsg = qconsumer.receiveNoWait();
- if (rmsg == null) {
- // Should be last message (try receiveNoWait() one more time to
- // make sure it is)
- rmsg = qconsumer.receiveNoWait();
- }
- }
-
- if (numMsgsFlushed > 0) {
- TestUtil.logTrace("Flushed " + numMsgsFlushed + " messages");
- }
- }
- }
- } catch (Exception e) {
- TestUtil.logErr("flushQueue exception: " + e.toString());
- TestUtil.printStackTrace(e);
- } finally {
- try {
- qc.close();
- } catch (Exception e) {
- }
- }
- TestUtil.logTrace("Leaving flushQueue(ArrayList)");
- }
-
- /**********************************************************************************
- * flushQueue(Queue, Session)
- *
- * Use this method at cleanup time to remove any messages that have remained
- * on the queue.
- *
- * @param Queue
- * queue the queue to flush
- * @param Session
- * session the session
- **********************************************************************************/
- public void flushQueue(Queue queue, Session session) throws Exception {
- int numMsgsFlushed = 0;
- int numMsgs = 0;
- Enumeration msgs = null;
-
- TestUtil.logTrace("Entering flushQueue(Queue, Session)");
- try {
- QueueBrowser qBrowser = session.createBrowser(queue);
- MessageConsumer consumer = session.createConsumer(queue);
- // count the number of messages
- msgs = qBrowser.getEnumeration();
- while (msgs.hasMoreElements()) {
- msgs.nextElement();
- numMsgs++;
- }
-
- if (numMsgs == 0) {
- TestUtil.logTrace("No messages left on Queue " + queue.getQueueName());
- } else {
- TestUtil.logTrace(
- numMsgs + " messages left on Queue " + queue.getQueueName());
- if (consumer != null) {
- // flush the queue
- Message msg = consumer.receiveNoWait();
- while (msg != null) {
- numMsgsFlushed++;
- msg = consumer.receiveNoWait();
- }
- if (numMsgsFlushed > 0) {
- TestUtil.logTrace("Flushed " + numMsgsFlushed + " messages");
- }
-
- // if Session is transacted be sure to commit consumed messages
- if (numMsgsFlushed > 0 && session.getTransacted()) {
- session.commit();
- }
- }
- }
- } catch (Exception e) {
- }
- TestUtil.logTrace("Leaving flushQueue(Queue, Session)");
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/jms/common/JmsTool.java b/common/src/main/java/com/sun/ts/tests/jms/common/JmsTool.java
deleted file mode 100644
index b801e4f7b0..0000000000
--- a/common/src/main/java/com/sun/ts/tests/jms/common/JmsTool.java
+++ /dev/null
@@ -1,1673 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-package com.sun.ts.tests.jms.common;
-
-import java.util.ArrayList;
-import java.util.Enumeration;
-
-import com.sun.ts.lib.porting.TSJMSObjects;
-import com.sun.ts.lib.porting.TSJMSObjectsInterface;
-import com.sun.ts.lib.util.TSNamingContext;
-import com.sun.ts.lib.util.TestUtil;
-
-import jakarta.jms.Connection;
-import jakarta.jms.ConnectionFactory;
-import jakarta.jms.Destination;
-import jakarta.jms.JMSConsumer;
-import jakarta.jms.JMSContext;
-import jakarta.jms.JMSException;
-import jakarta.jms.Message;
-import jakarta.jms.MessageConsumer;
-import jakarta.jms.MessageProducer;
-import jakarta.jms.ObjectMessage;
-import jakarta.jms.Queue;
-import jakarta.jms.QueueBrowser;
-import jakarta.jms.QueueConnection;
-import jakarta.jms.QueueConnectionFactory;
-import jakarta.jms.QueueReceiver;
-import jakarta.jms.QueueSender;
-import jakarta.jms.QueueSession;
-import jakarta.jms.Session;
-import jakarta.jms.Topic;
-import jakarta.jms.TopicConnection;
-import jakarta.jms.TopicConnectionFactory;
-import jakarta.jms.TopicPublisher;
-import jakarta.jms.TopicSession;
-import jakarta.jms.TopicSubscriber;
-
-public class JmsTool {
-
- // QUEUE declarations
- private Queue testQueue = null;
-
- private QueueConnection qConnection = null;
-
- private QueueSession qSession = null;
-
- private QueueReceiver qReceiver = null;
-
- private QueueSender qSender = null;
-
- // TOPIC declarations
- private Topic testTopic = null;
-
- private TopicConnection tConnection = null;
-
- private TopicSession tSession = null;
-
- private TopicSubscriber tSubscriber = null;
-
- private TopicPublisher tPublisher = null;
-
- // COMMON declarations
- private Destination testDestination = null;
-
- private Connection conn = null;
-
- private Session sess = null;
-
- private MessageConsumer receiver = null;
-
- private MessageProducer sender = null;
-
- private boolean durableTopic = false;
-
- private boolean transacted = false;
-
- private int ttype = 0;
-
- private int ftype = 5;
-
- private String username = null;
-
- private String password = null;
-
- private String jndiLookupName = null;
-
- // constants
- public static final int QUEUE = 0;
-
- public static final int TOPIC = 1;
-
- public static final int TX_QUEUE = 2;
-
- public static final int TX_TOPIC = 3;
-
- public static final int DURABLE_TOPIC = 4;
-
- public static final int DURABLE_TX_TOPIC = 5;
-
- public static final int FACTORIES_ONLY = 6;
-
- public static final int QUEUE_FACTORY = 7;
-
- public static final int TOPIC_FACTORY = 8;
-
- public static final int DURABLE_TOPIC_FACTORY = 9;
-
- public static final int FACTORY_Q = 10;
-
- public static final int FACTORY_T = 11;
-
- public static final int FACTORY_DT = 12;
-
- public static final int COMMON_Q = 13;
-
- public static final int COMMON_T = 14;
-
- public static final int COMMON_QTX = 15;
-
- public static final int COMMON_TTX = 16;
-
- public static final int COMMON_FACTORY = 17;
-
- public static final String JMS_VERSION = "3.1";
-
- public static final int JMS_MAJOR_VERSION = 3;
-
- public static final int JMS_MINOR_VERSION = 1;
-
- // JNDI names for JMS objects (Standalone mode)
- public static final String TCKTESTQUEUENAME = "MY_QUEUE";
-
- public static final String TCKTESTTOPICNAME = "MY_TOPIC";
-
- public static final String TCKCONNECTIONFACTORY = "MyConnectionFactory";
-
- public static final String TCKQUEUECONNECTIONFACTORY = "MyQueueConnectionFactory";
-
- public static final String TCKTOPICCONNECTIONFACTORY = "MyTopicConnectionFactory";
-
- public static final String TCKDURABLETOPICCONNECTIONFACTORY = "DURABLE_SUB_CONNECTION_FACTORY";
-
- // JNDI names for JMS objects (JakartaEE mode)
- public static final String TESTQUEUENAME = "java:comp/env/jms/MY_QUEUE";
-
- public static final String TESTTOPICNAME = "java:comp/env/jms/MY_TOPIC";
-
- public static final String CONNECTIONFACTORY = "java:comp/env/jms/MyConnectionFactory";
-
- public static final String QUEUECONNECTIONFACTORY = "java:comp/env/jms/MyQueueConnectionFactory";
-
- public static final String TOPICCONNECTIONFACTORY = "java:comp/env/jms/MyTopicConnectionFactory";
-
- public static final String DURABLETOPICCONNECTIONFACTORY = "java:comp/env/jms/DURABLE_SUB_CONNECTION_FACTORY";
-
- public static final String JMSDEFAULT = "jmsDefault";
-
- // statics
- private TSNamingContext jndiContext = null;
-
- private QueueConnectionFactory qcf = null;
-
- private TopicConnectionFactory tcf = null;
-
- private TopicConnectionFactory tcf2 = null;
-
- private ConnectionFactory cf = null;
-
- private ConnectionFactory cf2 = null;
-
- private TSJMSObjectsInterface jmsObjects = null;
-
- private String mode = "jakartaEE";
-
- /**********************************************************************************
- * Public constructor. Takes a connection type and mode argument. Create
- * connection factory, connection type, and single producer/consumer for
- * either QUEUE or TOPIC client.
- *
- * @param int
- * type (QUEUE type or TOPIC type)
- * @param String
- * m (JakartaEE mode or Standalone mode)
- **********************************************************************************/
- public JmsTool(int type, String m) throws Exception {
-
- this(type, JMSDEFAULT, JMSDEFAULT, m);
- }
-
- /**********************************************************************************
- * Public constructor. Takes connection type, username, password, jndi lookup
- * name, and mode argument. Create connection factory, connection type, and
- * single producer/consumer for TOPIC client.
- *
- * @param int
- * type (TOPIC type)
- * @param String
- * user (username)
- * @param String
- * pw (password)
- * @param String
- * lookup (connection factory to lookup)
- * @param String
- * m (JakartaEE mode or Standalone mode)
- **********************************************************************************/
- public JmsTool(int type, String user, String pw, String lookup, String m)
- throws Exception {
- username = user;
- password = pw;
- ttype = type;
- mode = m;
-
- if (mode.equals("jakartaEE")) {
- getJNDIContext();
- } else {
- jmsObjects = TSJMSObjects.getJMSObjectsInstance();
- }
-
- if (type == TOPIC) {
- transacted = false;
- createTopicSetup(lookup);
- } else if (type == TX_TOPIC) {
- transacted = true;
- createTopicSetup(lookup);
- } else if (type == DURABLE_TOPIC) {
- transacted = false;
- createTopicSetup(lookup);
- } else if (type == DURABLE_TX_TOPIC) {
- transacted = true;
- createTopicSetup(lookup);
- } else if (type == COMMON_T) {
- transacted = false;
- createCommonTSetup(lookup);
- } else if (type == COMMON_TTX) {
- transacted = true;
- createCommonTSetup(lookup);
- } else {
- String eMsg = "Type must be JmsTool.TOPIC, JmsTool.TX_TOPIC, JmsTool.DURABLE_TOPIC, "
- + "JmsTool.DURABLE_TX_TOPIC, JmsTool.COMMON_T, JmsTool.COMMON_TTX.";
- throw new Exception(eMsg);
- }
- }
-
- /**********************************************************************************
- * Public constructor. Takes connection type, username, password, and mode
- * argument. Create connection factory, connection type, and single
- * producer/consumer for either QUEUE or TOPIC client. If just a FACTORY type
- * is passed then just create the connection factory type.
- *
- * @param int
- * type (QUEUE type or TOPIC type or FACTORY type)
- * @param String
- * user (username)
- * @param String
- * pw (password)
- * @param String
- * m (JakartaEE mode or Standalone mode)
- **********************************************************************************/
- public JmsTool(int type, String user, String pw, String m) throws Exception {
- username = user;
- password = pw;
- ttype = type;
- mode = m;
-
- if (mode.equals("jakartaEE")) {
- getJNDIContext();
- } else {
- jmsObjects = TSJMSObjects.getJMSObjectsInstance();
- }
-
- if (type == QUEUE) {
- transacted = false;
- createQueueSetup();
- } else if (type == TX_QUEUE) {
- transacted = true;
- createQueueSetup();
- } else if (type == TOPIC) {
- durableTopic = false;
- transacted = false;
- createTopicSetup();
- } else if (type == TX_TOPIC) {
- durableTopic = false;
- transacted = true;
- createTopicSetup();
- } else if (type == DURABLE_TOPIC) {
- durableTopic = true;
- transacted = false;
- createTopicSetup();
- } else if (type == DURABLE_TX_TOPIC) {
- durableTopic = true;
- transacted = true;
- createTopicSetup();
- } else if (type == COMMON_Q) {
- transacted = false;
- createCommonQSetup();
- } else if (type == COMMON_T) {
- transacted = false;
- createCommonTSetup();
- } else if (type == COMMON_QTX) {
- transacted = true;
- createCommonQSetup();
- } else if (type == COMMON_TTX) {
- transacted = true;
- createCommonTSetup();
- } else if ((type == FACTORIES_ONLY) || (type == QUEUE_FACTORY)
- || (type == DURABLE_TOPIC_FACTORY) || (type == TOPIC_FACTORY)
- || (type == COMMON_FACTORY) || (type == FACTORY_Q)
- || (type == FACTORY_DT) || (type == FACTORY_T))
- getConnectionFactoriesOnly(type);
- else {
- String eMsg = "Type must be JmsTool.QUEUE, JmsTool.TOPIC, JmsTool.TX_QUEUE, JmsTool.TX_TOPIC, "
- + "JmsTool.DURABLE_TOPIC, JmsTool.DURABLE_TX_TOPIC, JmsTool.FACTORIES_ONLY, "
- + "JmsTool.QUEUE_FACTORY, JmsTool.TOPIC_FACTORY, JmsTool.COMMON_FACTORY, "
- + "JmsTool.FACTORY_Q, JmsTool.FACTORY_T, JmsTool.FACTORY_DT, "
- + "JmsTool.DURABLE_TOPIC_FACTORY, JmsTool.COMMON_Q, JmsTool.COMMON_T, "
- + "JmsTool.COMMON_QTX, or JmsTool.COMMON_TTX.";
- throw new Exception(eMsg);
- }
- }
-
- private void getJNDIContext() throws Exception {
-
- if (jndiContext == null) {
-
- try {
- TestUtil.logTrace("Getting initial context");
- jndiContext = new TSNamingContext();
- } catch (javax.naming.NamingException ne) {
- TestUtil.logErr("Could not create JNDI context because: ", ne);
- throw ne;
- }
- }
- }
-
- /************************************************************************
- * Used by tests that create all their own connections
- ***********************************************************************/
- private void getConnectionFactoriesOnly(int factype) throws Exception {
-
- try {
- ftype = factype;
- this.getConnectionFactoriesOnly();
- } catch (Exception e) {
- TestUtil.printStackTrace(e);
- throw e;
- }
- }
-
- /************************************************************************
- * Used by tests that create all their own connections
- ***********************************************************************/
- private void getConnectionFactoriesOnly() throws Exception {
-
- if ((ftype == QUEUE_FACTORY) || (ftype == FACTORIES_ONLY)) {
- try {
- if (mode.equals("jakartaEE")) {
- TestUtil.logTrace(
- "Getting QueueConnectionFactory " + QUEUECONNECTIONFACTORY);
- qcf = (QueueConnectionFactory) jndiContext
- .lookup(QUEUECONNECTIONFACTORY);
- jndiLookupName = QUEUECONNECTIONFACTORY;
- } else {
- TestUtil.logTrace(
- "Getting QueueConnectionFactory " + TCKQUEUECONNECTIONFACTORY);
- qcf = (QueueConnectionFactory) jmsObjects
- .getQueueConnectionFactory(TCKQUEUECONNECTIONFACTORY);
- jndiLookupName = TCKQUEUECONNECTIONFACTORY;
- }
- } catch (Exception e) {
- TestUtil.logErr("Failed to lookup connection factory using name "
- + jndiLookupName + " because: ", e);
- TestUtil.printStackTrace(e);
- throw e;
- }
- }
-
- if ((ftype == TOPIC_FACTORY) || (ftype == FACTORIES_ONLY)) {
- try {
- if (mode.equals("jakartaEE")) {
- TestUtil.logTrace(
- "Getting TopicConnectionFactory " + TOPICCONNECTIONFACTORY);
- tcf = (TopicConnectionFactory) jndiContext
- .lookup(TOPICCONNECTIONFACTORY);
- jndiLookupName = TOPICCONNECTIONFACTORY;
- } else {
- TestUtil.logTrace(
- "Getting TopicConnectionFactory " + TCKTOPICCONNECTIONFACTORY);
- tcf = (TopicConnectionFactory) jmsObjects
- .getTopicConnectionFactory(TCKTOPICCONNECTIONFACTORY);
- jndiLookupName = TCKTOPICCONNECTIONFACTORY;
- }
-
- } catch (Exception e) {
- TestUtil.logErr("Failed to lookup connection factory using name "
- + jndiLookupName + " because: ", e);
- TestUtil.printStackTrace(e);
- throw e;
- }
- }
-
- if (ftype == DURABLE_TOPIC_FACTORY) {
- try {
- if (mode.equals("jakartaEE")) {
- TestUtil.logTrace("Getting Durable TopicConnectionFactory "
- + DURABLETOPICCONNECTIONFACTORY);
- tcf = (TopicConnectionFactory) jndiContext
- .lookup(DURABLETOPICCONNECTIONFACTORY);
- jndiLookupName = DURABLETOPICCONNECTIONFACTORY;
- } else {
- TestUtil.logTrace("Getting Durable TopicConnectionFactory "
- + TCKDURABLETOPICCONNECTIONFACTORY);
- tcf = (TopicConnectionFactory) jmsObjects
- .getTopicConnectionFactory(TCKDURABLETOPICCONNECTIONFACTORY);
- jndiLookupName = TCKDURABLETOPICCONNECTIONFACTORY;
- }
-
- } catch (Exception e) {
- TestUtil.logErr("Failed to lookup connection factory using name "
- + jndiLookupName + " because: ", e);
- TestUtil.printStackTrace(e);
- throw e;
- }
- }
-
- if (ftype == COMMON_FACTORY) {
- try {
- if (mode.equals("jakartaEE")) {
- TestUtil.logTrace("Getting ConnectionFactory " + CONNECTIONFACTORY);
- cf = (ConnectionFactory) jndiContext.lookup(CONNECTIONFACTORY);
- jndiLookupName = CONNECTIONFACTORY;
- } else {
- TestUtil
- .logTrace("Getting ConnectionFactory " + TCKCONNECTIONFACTORY);
- cf = (ConnectionFactory) jmsObjects
- .getConnectionFactory(TCKCONNECTIONFACTORY);
- jndiLookupName = TCKCONNECTIONFACTORY;
- }
- } catch (Exception e) {
- TestUtil.logErr("Failed to lookup connection factory using name "
- + jndiLookupName + " because: ", e);
- throw e;
- }
- }
-
- if ((ftype == FACTORY_T) || (ftype == FACTORIES_ONLY)) {
- try {
- if (mode.equals("jakartaEE")) {
- TestUtil
- .logTrace("Getting TopicConnectionFactory as a ConnectionFactory "
- + TOPICCONNECTIONFACTORY);
- cf = (ConnectionFactory) jndiContext.lookup(TOPICCONNECTIONFACTORY);
- jndiLookupName = TOPICCONNECTIONFACTORY;
- } else {
- TestUtil
- .logTrace("Getting TopicConnectionFactory as a ConnectionFactory "
- + TCKTOPICCONNECTIONFACTORY);
- cf = (ConnectionFactory) jmsObjects
- .getTopicConnectionFactory(TCKTOPICCONNECTIONFACTORY);
- jndiLookupName = TCKTOPICCONNECTIONFACTORY;
- }
-
- } catch (Exception e) {
- TestUtil.logErr("Failed to lookup connection factory using name "
- + jndiLookupName + " because: ", e);
- throw e;
- }
- }
-
- if (ftype == FACTORY_DT) {
- try {
- if (mode.equals("jakartaEE")) {
- TestUtil.logTrace(
- "Getting Durable TopicConnectionFactory as a ConnectionFactory "
- + DURABLETOPICCONNECTIONFACTORY);
- cf = (ConnectionFactory) jndiContext
- .lookup(DURABLETOPICCONNECTIONFACTORY);
- jndiLookupName = DURABLETOPICCONNECTIONFACTORY;
- } else {
- TestUtil.logTrace(
- "Getting Durable TopicConnectionFactory as a ConnectionFactory "
- + TCKDURABLETOPICCONNECTIONFACTORY);
- cf = (ConnectionFactory) jmsObjects
- .getTopicConnectionFactory(TCKDURABLETOPICCONNECTIONFACTORY);
- jndiLookupName = TCKDURABLETOPICCONNECTIONFACTORY;
- }
-
- } catch (Exception e) {
- TestUtil.logErr("Failed to lookup connection factory using name "
- + jndiLookupName + " because: ", e);
- throw e;
- }
- }
-
- if ((ftype == FACTORY_Q) || (ftype == FACTORIES_ONLY)) {
- try {
- if (mode.equals("jakartaEE")) {
- TestUtil
- .logTrace("Getting QueueConnectionFactory as a ConnectionFactory "
- + QUEUECONNECTIONFACTORY);
- cf = (ConnectionFactory) jndiContext.lookup(QUEUECONNECTIONFACTORY);
- jndiLookupName = QUEUECONNECTIONFACTORY;
- } else {
- TestUtil
- .logTrace("Getting QueueConnectionFactory as a ConnectionFactory "
- + TCKQUEUECONNECTIONFACTORY);
- cf = (ConnectionFactory) jmsObjects
- .getQueueConnectionFactory(TCKQUEUECONNECTIONFACTORY);
- jndiLookupName = TCKQUEUECONNECTIONFACTORY;
- }
- qcf = (QueueConnectionFactory) cf;
- } catch (Exception e) {
- TestUtil.logErr("Failed to lookup connection factory using name "
- + jndiLookupName + " because: ", e);
- throw e;
- }
- }
-
- }
-
- /************************************************************************
- * Queue setup using Queue specific classes/interfaces
- ************************************************************************/
- private void createQueueSetup() throws Exception {
-
- String eMsg = ""; // error Message if exception thrown
-
- try {
- if (mode.equals("jakartaEE")) {
- TestUtil.logTrace(
- "Getting QueueConnectionFactory " + QUEUECONNECTIONFACTORY);
- qcf = (QueueConnectionFactory) jndiContext
- .lookup(QUEUECONNECTIONFACTORY);
- eMsg = "Failed to lookup QueueConnectionFactory using name "
- + QUEUECONNECTIONFACTORY;
- } else {
- TestUtil.logTrace(
- "Getting QueueConnectionFactory " + TCKQUEUECONNECTIONFACTORY);
- qcf = (QueueConnectionFactory) jmsObjects
- .getQueueConnectionFactory(TCKQUEUECONNECTIONFACTORY);
- eMsg = "Failed to lookup QueueConnectionFactory using name "
- + TCKQUEUECONNECTIONFACTORY;
- }
-
- // now lookup the queue
- if (mode.equals("jakartaEE")) {
- TestUtil.logTrace("Getting Queue " + TESTQUEUENAME);
- testQueue = (Queue) jndiContext.lookup(TESTQUEUENAME);
- eMsg = "Failed to lookup Queue " + TESTQUEUENAME;
- } else {
- TestUtil.logTrace("Getting Queue " + TCKTESTQUEUENAME);
- testQueue = (Queue) jmsObjects.getQueue(TCKTESTQUEUENAME);
- eMsg = "Failed to lookup Queue " + TCKTESTQUEUENAME;
- }
-
- // create default connection
- TestUtil.logTrace("Creating QueueConnection");
- eMsg = "Failed to create queue connection using username, " + username
- + " password, " + password;
- qConnection = (QueueConnection) createNewConnection(ttype, username,
- password);
-
- // create default QueueSession and Queue reference
- TestUtil.logTrace("Creating QueueSession");
- eMsg = "Failed to create queue session";
-
- qSession = qConnection.createQueueSession(transacted,
- Session.AUTO_ACKNOWLEDGE);
-
- // create default consumer/producer
- TestUtil.logTrace("Creating receiver");
- eMsg = "Failed to create receiver for queue " + testQueue;
- qReceiver = qSession.createReceiver(testQueue);
-
- TestUtil.logTrace("Creating sender");
- eMsg = "Failed to create sender for queue " + testQueue;
- qSender = qSession.createSender(testQueue);
- TestUtil.logTrace("Success - Queue Setup done");
- } catch (Exception e) {
- TestUtil.logErr(eMsg + "due to ", e);
- TestUtil.printStackTrace(e);
- throw e;
- }
- }
-
- /************************************************************************
- * Topic setup using Topic specific classes/interfaces
- ************************************************************************/
- private void createTopicSetup() throws Exception {
- String eMsg = "";
-
- try {
-
- if (durableTopic) {
- if (mode.equals("jakartaEE")) {
- TestUtil.logTrace("Getting Durable TopicConnectionFactory "
- + DURABLETOPICCONNECTIONFACTORY);
- tcf = (TopicConnectionFactory) jndiContext
- .lookup(DURABLETOPICCONNECTIONFACTORY);
- eMsg = "Failed to lookup TopicConnectionFactory using name "
- + DURABLETOPICCONNECTIONFACTORY;
- } else {
- TestUtil.logTrace("Getting Durable TopicConnectionFactory "
- + TCKDURABLETOPICCONNECTIONFACTORY);
- tcf = (TopicConnectionFactory) jmsObjects
- .getTopicConnectionFactory(TCKDURABLETOPICCONNECTIONFACTORY);
- eMsg = "Failed to lookup TopicConnectionFactory using name "
- + TCKDURABLETOPICCONNECTIONFACTORY;
- }
- } else {
- if (mode.equals("jakartaEE")) {
- TestUtil.logTrace(
- "Getting TopicConnectionFactory " + TOPICCONNECTIONFACTORY);
- tcf = (TopicConnectionFactory) jndiContext
- .lookup(TOPICCONNECTIONFACTORY);
- eMsg = "Failed to lookup TopicConnectionFactory using name "
- + TOPICCONNECTIONFACTORY;
- } else {
- TestUtil.logTrace(
- "Getting TopicConnectionFactory " + TCKTOPICCONNECTIONFACTORY);
- tcf = (TopicConnectionFactory) jmsObjects
- .getTopicConnectionFactory(TCKTOPICCONNECTIONFACTORY);
- eMsg = "Failed to lookup TopicConnectionFactory using name "
- + TCKTOPICCONNECTIONFACTORY;
- }
- }
-
- if (mode.equals("jakartaEE")) {
- TestUtil.logTrace("Getting Topic " + TESTTOPICNAME);
- testTopic = (Topic) jndiContext.lookup(TESTTOPICNAME);
- eMsg = "Failed to lookup Topic " + TESTTOPICNAME;
- } else {
- TestUtil.logTrace("Getting Topic " + TCKTESTTOPICNAME);
- testTopic = (Topic) jmsObjects.getTopic(TCKTESTTOPICNAME);
- eMsg = "Failed to lookup Topic " + TCKTESTTOPICNAME;
- }
-
- // create default connection
- TestUtil.logTrace("Creating TopicConnection");
- eMsg = "Failed to create topic connection using username, " + username
- + " password, " + password;
- tConnection = (TopicConnection) createNewConnection(ttype, username,
- password);
-
- // create default TopicSession
- TestUtil.logTrace("Creating TopicSession");
- eMsg = "Failed to create topic session";
- tSession = tConnection.createTopicSession(transacted,
- Session.AUTO_ACKNOWLEDGE);
-
- // create default consumer/producer
- TestUtil.logTrace("Creating subscriber");
- eMsg = "Failed to create subscriber for topic " + testTopic;
- tSubscriber = tSession.createSubscriber(testTopic);
-
- TestUtil.logTrace("Creating publisher");
- eMsg = "Failed to create publisher for topic " + testTopic;
- tPublisher = tSession.createPublisher(testTopic);
-
- } catch (Exception e) {
- TestUtil.logErr(eMsg + "due to ", e);
- throw e;
- }
- }
-
- /************************************************************************
- * Topic setup using Topic specific classes/interfaces
- ************************************************************************/
- private void createTopicSetup(String lookup) throws Exception {
- String eMsg = "";
-
- try {
-
- TestUtil.logTrace("Getting TopicConnectionFactory " + lookup);
- if (mode.equals("jakartaEE")) {
- tcf = (TopicConnectionFactory) jndiContext
- .lookup("java:comp/env/jms/" + lookup);
- eMsg = "Failed to lookup TopicConnectionFactory using name java:comp/env/jms/"
- + lookup;
- } else {
- tcf = (TopicConnectionFactory) jmsObjects
- .getTopicConnectionFactory(lookup);
- eMsg = "Failed to lookup TopicConnectionFactory using name " + lookup;
- }
-
- if (mode.equals("jakartaEE")) {
- TestUtil.logTrace("Getting Topic " + TESTTOPICNAME);
- testTopic = (Topic) jndiContext.lookup(TESTTOPICNAME);
- eMsg = "Failed to lookup Topic " + TESTTOPICNAME;
- } else {
- TestUtil.logTrace("Getting Topic " + TCKTESTTOPICNAME);
- testTopic = (Topic) jmsObjects.getTopic(TCKTESTTOPICNAME);
- eMsg = "Failed to lookup Topic " + TCKTESTTOPICNAME;
- }
-
- // create default connection
- TestUtil.logTrace("Creating TopicConnection");
- eMsg = "Failed to create topic connection using username, " + username
- + " password, " + password;
- tConnection = (TopicConnection) createNewConnection(ttype, username,
- password);
-
- // create default TopicSession
- TestUtil.logTrace("Creating TopicSession");
- eMsg = "Failed to create topic session";
- tSession = tConnection.createTopicSession(transacted,
- Session.AUTO_ACKNOWLEDGE);
-
- // create default consumer/producer
- TestUtil.logTrace("Creating subscriber");
- eMsg = "Failed to create subscriber for topic " + testTopic;
- tSubscriber = tSession.createSubscriber(testTopic);
-
- TestUtil.logTrace("Creating publisher");
- eMsg = "Failed to create publisher for topic " + testTopic;
- tPublisher = tSession.createPublisher(testTopic);
-
- } catch (Exception e) {
- TestUtil.logErr(eMsg + "due to ", e);
- throw e;
- }
- }
-
- /************************************************************************
- * Queue setup using common classes/interfaces
- ************************************************************************/
- private void createCommonQSetup() throws Exception {
- String eMsg = "";
-
- try {
-
- if (mode.equals("jakartaEE")) {
- TestUtil
- .logTrace("Getting ConnectionFactory " + QUEUECONNECTIONFACTORY);
- cf = (ConnectionFactory) jndiContext.lookup(QUEUECONNECTIONFACTORY);
- eMsg = "Failed to lookup ConnectionFactory using name "
- + QUEUECONNECTIONFACTORY;
- } else {
- TestUtil
- .logTrace("Getting ConnectionFactory " + TCKQUEUECONNECTIONFACTORY);
- cf = (ConnectionFactory) jmsObjects
- .getQueueConnectionFactory(TCKQUEUECONNECTIONFACTORY);
- eMsg = "Failed to lookup ConnectionFactory using name "
- + TCKQUEUECONNECTIONFACTORY;
- }
- qcf = (QueueConnectionFactory) cf;
-
- if (mode.equals("jakartaEE")) {
- TestUtil.logTrace("Getting Queue " + TESTQUEUENAME);
- testDestination = (Destination) jndiContext.lookup(TESTQUEUENAME);
- eMsg = "Failed to lookup Queue " + TESTQUEUENAME;
- } else {
- TestUtil.logTrace("Getting Queue " + TCKTESTQUEUENAME);
- testDestination = (Destination) jmsObjects.getQueue(TCKTESTQUEUENAME);
- eMsg = "Failed to lookup Queue " + TCKTESTQUEUENAME;
- }
-
- // create default connection
- TestUtil.logTrace("Creating Connection");
- eMsg = "Failed to create connection using username, " + username
- + " password, " + password;
- conn = cf.createConnection(username, password);
-
- // create default Session
- TestUtil.logTrace("Creating Session");
- eMsg = "Failed to create session";
- sess = conn.createSession(transacted, Session.AUTO_ACKNOWLEDGE);
-
- // create default consumer/producer
- TestUtil.logTrace("Creating messageProducer");
- eMsg = "Failed to create producer for destination " + testDestination;
- sender = sess.createProducer(testDestination);
-
- TestUtil.logTrace("Creating MessageConsumer");
- eMsg = "Failed to create consumer for destination " + testDestination;
- receiver = sess.createConsumer(testDestination);
-
- } catch (Exception e) {
- TestUtil.logErr(eMsg + "due to ", e);
- throw e;
- }
- }
-
- /************************************************************************
- * Topic setup using common classes/interfaces
- ************************************************************************/
- private void createCommonTSetup() throws Exception {
- String eMsg = "";
-
- try {
-
- if (mode.equals("jakartaEE")) {
- TestUtil
- .logTrace("Getting ConnectionFactory " + TOPICCONNECTIONFACTORY);
- cf = (ConnectionFactory) jndiContext.lookup(TOPICCONNECTIONFACTORY);
- eMsg = "Failed to lookup ConnectionFactory using name "
- + TOPICCONNECTIONFACTORY;
- } else {
- TestUtil
- .logTrace("Getting ConnectionFactory " + TCKTOPICCONNECTIONFACTORY);
- cf = (ConnectionFactory) jmsObjects
- .getTopicConnectionFactory(TCKTOPICCONNECTIONFACTORY);
- eMsg = "Failed to lookup ConnectionFactory using name "
- + TCKTOPICCONNECTIONFACTORY;
- }
-
- TestUtil.logTrace("Getting Topic " + TESTTOPICNAME);
- if (mode.equals("jakartaEE")) {
- testDestination = (Destination) jndiContext.lookup(TESTTOPICNAME);
- eMsg = "Failed to lookup Topic " + TESTTOPICNAME;
- } else {
- testDestination = (Destination) jmsObjects.getTopic(TCKTESTTOPICNAME);
- eMsg = "Failed to lookup Topic " + TCKTESTTOPICNAME;
- }
-
- // create default connection
- TestUtil.logTrace("Creating Connection");
- eMsg = "Failed to create connection using username, " + username
- + " password, " + password;
- conn = cf.createConnection(username, password);
-
- // create default Session
- TestUtil.logTrace("Creating Session");
- eMsg = "Failed to create session";
- sess = conn.createSession(transacted, Session.AUTO_ACKNOWLEDGE);
-
- // create default consumer/producer
- TestUtil.logTrace("Creating messageProducer");
- eMsg = "Failed to create producer for destination " + testDestination;
- sender = sess.createProducer(testDestination);
-
- TestUtil.logTrace("Creating MessageConsumer");
- eMsg = "Failed to create consumer for destination " + testDestination;
- receiver = sess.createConsumer(testDestination);
-
- } catch (Exception e) {
- TestUtil.logErr(eMsg + "due to ", e);
- throw e;
- }
- }
-
- /************************************************************************
- * Topic setup using common classes/interfaces
- ************************************************************************/
- private void createCommonTSetup(String lookup) throws Exception {
- String eMsg = "";
-
- try {
-
- TestUtil.logTrace("Getting ConnectionFactory " + lookup);
- if (mode.equals("jakartaEE")) {
- cf = (ConnectionFactory) jndiContext
- .lookup("java:comp/env/jms/" + lookup);
- eMsg = "Failed to lookup ConnectionFactory using name java:comp/env/jms/"
- + lookup;
- } else {
- cf = (ConnectionFactory) jmsObjects.getTopicConnectionFactory(lookup);
- eMsg = "Failed to lookup ConnectionFactory using name " + lookup;
- }
-
- TestUtil.logTrace("Getting Topic " + TESTTOPICNAME);
- if (mode.equals("jakartaEE")) {
- testDestination = (Destination) jndiContext.lookup(TESTTOPICNAME);
- eMsg = "Failed to lookup Topic " + TESTTOPICNAME;
- } else {
- testDestination = (Destination) jmsObjects.getTopic(TCKTESTTOPICNAME);
- eMsg = "Failed to lookup Topic " + TCKTESTTOPICNAME;
- }
-
- // create default connection
- TestUtil.logTrace("Creating Connection");
- eMsg = "Failed to create connection using username, " + username
- + " password, " + password;
- conn = cf.createConnection(username, password);
-
- // create default Session
- TestUtil.logTrace("Creating Session");
- eMsg = "Failed to create session";
- sess = conn.createSession(transacted, Session.AUTO_ACKNOWLEDGE);
-
- // create default consumer/producer
- TestUtil.logTrace("Creating messageProducer");
- eMsg = "Failed to create producer for destination " + testDestination;
- sender = sess.createProducer(testDestination);
-
- TestUtil.logTrace("Creating MessageConsumer");
- eMsg = "Failed to create consumer for destination " + testDestination;
- receiver = sess.createConsumer(testDestination);
-
- } catch (Exception e) {
- TestUtil.logErr(eMsg + "due to ", e);
- throw e;
- }
- }
-
- /***********************************************************************
- * Default getter's for COMMON QUEUE or COMMON TOPIC created objects
- ***********************************************************************/
- public ConnectionFactory getConnectionFactory() throws Exception {
- return cf;
- }
-
- public Connection getDefaultConnection() throws Exception {
- return conn;
- }
-
- public Session getDefaultSession() throws Exception {
- return sess;
- }
-
- public MessageProducer getDefaultProducer() throws Exception {
- return sender;
- }
-
- public MessageConsumer getDefaultConsumer() throws Exception {
- return receiver;
- }
-
- public Destination getDefaultDestination() throws Exception {
- return testDestination;
- }
-
- /**********************************************************************************
- * Creates a new Topic for tests that require more than the Topic. The topic
- * should be setup by the administrator
- *
- * @param String
- * the topic name
- **********************************************************************************/
- public Topic createNewTopic(String topicName) throws Exception {
- Topic testT = null;
- if (mode.equals("jakartaEE"))
- testT = (Topic) jndiContext.lookup("java:comp/env/jms/" + topicName);
- else
- testT = (Topic) jmsObjects.getTopic(topicName);
-
- return testT;
- }
-
- /**********************************************************************************
- * Creates a new Queue for tests that require more than the Queue. The queue
- * should already be setup by the administrator
- *
- * @param String
- * the queue name
- **********************************************************************************/
- public Queue createNewQueue(String queueName) throws Exception {
- Queue testQ = null;
- if (mode.equals("jakartaEE"))
- testQ = (Queue) jndiContext.lookup("java:comp/env/jms/" + queueName);
- else
- testQ = (Queue) jmsObjects.getQueue(queueName);
- return testQ;
- }
-
- /**********************************************************************************
- * Close all resources created by JmsTool except connection resource which
- * gets closed in the closeAllConnections() or closeDefaultConnections()
- * methods.
- *
- * @exception Exception
- *
- **********************************************************************************/
- public void closeAllResources() throws Exception {
- // Close QUEUE resource objects
- try {
- if (qSession != null)
- qSession.close();
- } catch (JMSException e) {
- }
-
- try {
- if (qSender != null)
- qSender.close();
- } catch (JMSException e) {
- }
-
- try {
- if (qReceiver != null)
- qReceiver.close();
- } catch (JMSException e) {
- }
-
- qSession = null;
- qReceiver = null;
- qSender = null;
-
- // Close TOPIC resource objects
- try {
- if (tSession != null)
- tSession.close();
- } catch (JMSException e) {
- }
-
- try {
- if (tPublisher != null)
- tPublisher.close();
- } catch (JMSException e) {
- }
-
- try {
- if (tSubscriber != null)
- tSubscriber.close();
- } catch (JMSException e) {
- }
-
- tSession = null;
- tSubscriber = null;
- tPublisher = null;
-
- // Close COMMON resource objects
- try {
- if (sess != null)
- sess.close();
- } catch (JMSException e) {
- }
- try {
- if (sender != null)
- sender.close();
- } catch (JMSException e) {
- }
- try {
- if (receiver != null)
- receiver.close();
- } catch (JMSException e) {
- }
-
- sess = null;
- receiver = null;
- sender = null;
- }
-
- /**********************************************************************************
- * Close any connections opened by the tests
- *
- * @exception Exception
- *
- * @see It is allowable to do a second call to close connection per the JMS
- * Specification
- **********************************************************************************/
- public void closeAllConnections(ArrayList connections) throws Exception {
- try {
- closeDefaultConnections();
- if (connections != null) {
- if (!connections.isEmpty()) {
- for (int i = 0; i < connections.size(); i++) {
- ((Connection) connections.get(i)).close();
- TestUtil.logTrace("Closing non default connection");
- }
- }
- }
- } catch (JMSException e) {
- TestUtil.logErr("Problem closing connections", e);
- }
- }
-
- /**********************************************************************************
- * Close default connections
- *
- * @see It is allowable to do a second call to close connection per the JMS
- * Specification
- **********************************************************************************/
- public void closeDefaultConnections() throws Exception {
- try {
- if (conn != null) {
- TestUtil.logTrace("JmstTool: Closing default Connection");
- conn.close();
- }
-
- if (qConnection != null) {
- TestUtil.logTrace("JmstTool: Closing default QueueConnection");
- qConnection.close();
- }
-
- if (tConnection != null) {
- TestUtil.logTrace("JmsTool: Closing default TopicConnection");
- tConnection.close();
- }
- } catch (JMSException e) {
-
- /*
- * Connection may already be closed by test method. If it is another type
- * of excption, pass it up to the calling method. Should only catch
- * JMSException if there is a regression in the RI.
- */
- TestUtil.logErr("Problem closing connections", e);
- }
- }
-
- /***********************************************************************
- * Default getter's for QUEUE created objects
- ***********************************************************************/
- public QueueConnectionFactory getQueueConnectionFactory() {
- return qcf;
- }
-
- public QueueConnection getDefaultQueueConnection() {
- return qConnection;
- }
-
- public QueueSession getDefaultQueueSession() {
- return qSession;
- }
-
- public QueueReceiver getDefaultQueueReceiver() {
- return qReceiver;
- }
-
- public QueueSender getDefaultQueueSender() {
- return qSender;
- }
-
- public Queue getDefaultQueue() {
- return testQueue;
- }
-
- public Destination getQueueDestination(String lookup) throws Exception {
- Destination dest = null;
- if (mode.equals("jakartaEE"))
- dest = (Destination) jndiContext.lookup("java:comp/env/jms/" + lookup);
- else
- dest = (Destination) jmsObjects.getQueue(lookup);
- return dest;
- }
-
- /***********************************************************************
- * Default getter's for TOPIC created objects
- ***********************************************************************/
- public TopicConnectionFactory getTopicConnectionFactory() {
- return tcf;
- }
-
- public TopicConnection getDefaultTopicConnection() {
- return tConnection;
- }
-
- public TopicSession getDefaultTopicSession() {
- return tSession;
- }
-
- public TopicSubscriber getDefaultTopicSubscriber() {
- return tSubscriber;
- }
-
- public TopicPublisher getDefaultTopicPublisher() {
- return tPublisher;
- }
-
- public Topic getDefaultTopic() {
- return testTopic;
- }
-
- public Destination getTopicDestination(String lookup) throws Exception {
- Destination dest = null;
- if (mode.equals("jakartaEE"))
- dest = (Destination) jndiContext.lookup("java:comp/env/jms/" + lookup);
- else
- dest = (Destination) jmsObjects.getTopic(lookup);
- return dest;
- }
-
- /**********************************************************************************
- * Use this method at cleanup time to remove any connections and messages that
- * have remained on the queue.
- *
- * @param ArrayList
- * connections list of open connections
- * @param ArrayList
- * queues list of queues to flush
- **********************************************************************************/
- public void doClientQueueTestCleanup(ArrayList connections,
- ArrayList queues) {
- try {
- closeAllConnections(connections);
- flushQueue(queues);
- if (queues != null) {
- queues.clear();
- }
-
- if (connections != null) {
- connections.clear();
- }
- } catch (Exception e) {
- TestUtil.logErr("Cleanup error: " + e.toString());
- TestUtil.printStackTrace(e);
- }
- }
-
- /**********************************************************************************
- * Use this method at cleanup time to remove any messages that have remained
- * on the queue.
- **********************************************************************************/
- public void flushDestination() throws Exception {
- Connection cC = null;
- MessageConsumer receiver = null;
- MessageProducer sender = null;
- Session sess = null;
- ObjectMessage msg = null;
- int priority = 0; // lowest priority
- int numMsgsFlushed = 0;
-
- try {
- if (conn != null) {
- TestUtil.logTrace("Closing default connection in flushDestination()");
- try {
- conn.close();
- } catch (Exception ex) {
- TestUtil.logErr("Error closing default connection", ex);
- }
- }
-
- TestUtil.logTrace(
- "Create new Connection,Session,MessageProducer,MessageConsumer to flush Destination");
- cC = createNewConnection(ttype, username, password);
- sess = cC.createSession(false, Session.AUTO_ACKNOWLEDGE);
- cC.start(); // start the connections so that messages may be received.
- sender = sess.createProducer(testDestination);
- receiver = sess.createConsumer(testDestination);
-
- // create and send a low priority message
- // any other messages on the queue should be received first
- // and low priority message should signal the end
- msg = sess.createObjectMessage();
- msg.setObject("Flush Destination");
- msg.setStringProperty("COM_SUN_JMS_TESTNAME", "flushDestination");
- TestUtil.logTrace(
- "Send low priority message to Destination to signal the last message");
- sender.send(msg, jakarta.jms.Message.DEFAULT_DELIVERY_MODE, priority,
- jakarta.jms.Message.DEFAULT_TIME_TO_LIVE);
-
- // flush the Destination
- TestUtil.logTrace("Now flush the Destination");
- Message rmsg = receiver.receive(5000);
- while (rmsg != null) {
- String tname = rmsg.getStringProperty("COM_SUN_JMS_TESTNAME");
- if (tname != null && tname.equals("flushDestination")) {
- // Should be last message (try receiveNoWait() one more time to make
- // sure it is)
- rmsg = receiver.receiveNoWait();
- if (rmsg != null)
- numMsgsFlushed++;
- } else {
- numMsgsFlushed++;
- }
- rmsg = receiver.receive(1000);
- }
-
- if (numMsgsFlushed > 0) {
- TestUtil.logTrace("Flushed " + numMsgsFlushed + " messages");
- } else {
- TestUtil.logTrace("No messages to flush");
- }
-
- } catch (Exception e) {
- TestUtil.logErr(
- "Cleanup error attempting to flush Destination: " + e.toString());
- } finally {
- try {
- cC.close();
- } catch (Exception e) {
- TestUtil.logErr(
- "Error closing Connection in flushDestination()" + e.toString());
- }
- }
- }
-
- /**********************************************************************************
- * Use this method at cleanup time to remove any messages that have remained
- * on the queue.
- *
- * @param Queue
- * qToFlush[] QUEUE
- **********************************************************************************/
- public void flushQueue(ArrayList qToFlush) throws Exception {
- QueueConnection qc = null;
- QueueReceiver qr = null;
- QueueSession qs = null;
- QueueSender qsndr = null;
- ObjectMessage msg = null;
- Enumeration msgs = null;
- int priority = 0; // lowest priority
- int numMsgsFlushed = 0;
- int numMsgs = 0;
-
- try {
-
- if (getDefaultQueue() != null) {
- qToFlush.add(getDefaultQueue());
- }
- TestUtil
- .logTrace("Create new QueueConnection,QueueSession to flush Queue");
- qc = (QueueConnection) createNewConnection(QUEUE, username, password);
- qs = qc.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
- qc.start(); // start the connections so that messages may be received.
-
- for (int i = 0; i < qToFlush.size(); i++) {
- TestUtil.logTrace(
- "Create QueueBrowser to count number of messages left on Queue");
- QueueBrowser qBrowser = qs.createBrowser((Queue) qToFlush.get(i));
- // count the number of messages
- msgs = qBrowser.getEnumeration();
- while (msgs.hasMoreElements()) {
- msgs.nextElement();
- numMsgs++;
- }
-
- if (numMsgs == 0) {
- TestUtil.logTrace("No Messages left on Queue "
- + ((Queue) qToFlush.get(i)).getQueueName());
- } else {
- TestUtil.logTrace(numMsgs + " Messages left on Queue "
- + ((Queue) qToFlush.get(i)).getQueueName());
-
- TestUtil
- .logTrace("Create new QueueReceiver to flush messages in Queue");
- qr = qs.createReceiver((Queue) qToFlush.get(i));
-
- // flush the queue
- TestUtil.logTrace("Now flush the Queue");
- Message rmsg = qr.receive(5000);
- while (rmsg != null) {
- numMsgsFlushed++;
- rmsg = qr.receiveNoWait();
- if (rmsg == null) {
- // Should be last message (try receive(1000) one more time to make
- // sure it is)
- rmsg = qr.receive(1000);
- }
- }
-
- if (numMsgsFlushed > 0) {
- TestUtil.logTrace("Flushed " + numMsgsFlushed + " messages");
- }
- }
- }
- } catch (Exception e) {
- TestUtil
- .logErr("Cleanup error attempting to flush Queue: " + e.toString());
- } finally {
- try {
- qc.close();
- } catch (Exception e) {
- TestUtil.logErr("Error closing QueueConnection in flushQueue(Array)"
- + e.toString());
- }
- }
- }
-
- public void flushQueue() throws Exception {
- int numMsgsFlushed = 0;
- int numMsgs = 0;
- Enumeration msgs = null;
-
- try {
- TestUtil.logTrace(
- "Create QueueBrowser to count number of messages left on Queue");
- QueueBrowser qBrowser = getDefaultQueueSession()
- .createBrowser(getDefaultQueue());
- // count the number of messages
- msgs = qBrowser.getEnumeration();
- while (msgs.hasMoreElements()) {
- msgs.nextElement();
- numMsgs++;
- }
-
- if (numMsgs == 0) {
- TestUtil.logTrace(
- "No Messages left on Queue " + getDefaultQueue().getQueueName());
- } else {
- TestUtil.logTrace(numMsgs + " Messages left on Queue "
- + getDefaultQueue().getQueueName());
- if (getDefaultQueueReceiver() != null) {
- // flush the queue
- Message msg = getDefaultQueueReceiver().receive(5000);
- while (msg != null) {
- numMsgsFlushed++;
- msg = getDefaultQueueReceiver().receiveNoWait();
- if (msg == null) {
- // Should be last message (try receive(1000) one more time to make
- // sure it is)
- msg = getDefaultQueueReceiver().receive(1000);
- }
- }
- if (numMsgsFlushed > 0) {
- TestUtil.logTrace("Flushed " + numMsgsFlushed + " messages");
- }
-
- // if default QueueSession is transacted,
- // be sure to commit consumed messages.
- if (numMsgsFlushed > 0 && getDefaultQueueSession().getTransacted()) {
- getDefaultQueueSession().commit();
- }
- }
- }
- } catch (Exception e) {
- }
- }
-
- /**********************************************************************************
- * Returns a the default Connection. The returned Connection object must be
- * explicitly cast into a QueueConnection or TopicConnection.
- *
- * @param int
- * type (QUEUE type or TOPIC type)
- * @return Connection from the default Queue or Topic or Common
- * ConnectionFactory
- **********************************************************************************/
- private Connection createNewConnection(int type, String username,
- String password) throws Exception {
- QueueConnection qC = null;
- TopicConnection tC = null;
-
- if ((type == QUEUE) || (type == TX_QUEUE)) {
- if (username.equals(JMSDEFAULT) || password.equals(JMSDEFAULT)) {
- qC = qcf.createQueueConnection();
- return qC;
- } else {
- qC = qcf.createQueueConnection(username, password);
- return qC;
- }
- } else if ((type == TOPIC) || (type == TX_TOPIC)) {
- if (username.equals(JMSDEFAULT) || password.equals(JMSDEFAULT)) {
- tC = tcf.createTopicConnection();
- return tC;
- } else {
- tC = tcf.createTopicConnection(username, password);
- return tC;
- }
- } else if ((type == DURABLE_TOPIC) || (type == DURABLE_TX_TOPIC)) {
- if (username.equals(JMSDEFAULT) || password.equals(JMSDEFAULT)) {
- tC = tcf.createTopicConnection();
- return tC;
- } else {
- tC = tcf.createTopicConnection(username, password);
- return tC;
- }
- } else if ((type == COMMON_Q) || (type == COMMON_T) || (type == COMMON_QTX)
- || (type == COMMON_TTX)) {
- if (username.equals(JMSDEFAULT) || password.equals(JMSDEFAULT)) {
- conn = cf.createConnection();
- return conn;
- } else {
- conn = cf.createConnection(username, password);
- return conn;
- }
-
- } else {
- throw new Exception("Failed to create new Connection");
- }
- }
-
- /**********************************************************************************
- * Returns a new Queue Connection for tests that require more than the default
- * connection. The returned Connection object must be explicitly cast into a
- * QueueConnection.
- *
- * @param int
- * type (QUEUE type)
- * @return Connection from the default ConnectionFactory
- **********************************************************************************/
- public Connection getNewConnection(int type, String username, String password)
- throws Exception {
- QueueConnection qC = null;
- Connection cC = null;
-
- if ((type == QUEUE) || (type == TX_QUEUE)) {
- if (username.equals(JMSDEFAULT) || password.equals(JMSDEFAULT)) {
- qC = qcf.createQueueConnection();
- return qC;
- } else {
- qC = qcf.createQueueConnection(username, password);
- return qC;
- }
- } else if (type == COMMON_Q) {
- if (username.equals(JMSDEFAULT) || password.equals(JMSDEFAULT)) {
- cC = cf.createConnection();
- return cC;
- } else {
- cC = cf.createConnection(username, password);
- return cC;
- }
- } else {
- throw new Exception("Failed to get new Connection");
- }
- }
-
- /**********************************************************************************
- * Returns a new Topic Connection for tests that require more than the default
- * connection. The returned Connection object must be explicitly cast into a
- * TopicConnection.
- *
- * @param int
- * type (TOPIC type)
- * @return Connection from the default ConnectionFactory
- **********************************************************************************/
- public Connection getNewConnection(int type, String username, String password,
- String lookup) throws Exception {
- TopicConnection tC = null;
- Connection cC = null;
-
- if ((type == TOPIC) || (type == TX_TOPIC)) {
- if (mode.equals("jakartaEE"))
- tcf2 = (TopicConnectionFactory) jndiContext
- .lookup("java:comp/env/jms/" + lookup);
- else
- tcf2 = (TopicConnectionFactory) jmsObjects
- .getTopicConnectionFactory(lookup);
- if (username.equals(JMSDEFAULT) || password.equals(JMSDEFAULT)) {
- tC = tcf2.createTopicConnection();
- return tC;
- } else {
- tC = tcf2.createTopicConnection(username, password);
- return tC;
- }
- } else if ((type == DURABLE_TOPIC) || (type == DURABLE_TX_TOPIC)) {
- if (username.equals(JMSDEFAULT) || password.equals(JMSDEFAULT)) {
- tC = tcf.createTopicConnection();
- return tC;
- } else {
- tC = tcf.createTopicConnection(username, password);
- return tC;
- }
- } else if ((type == COMMON_T) || (type == COMMON_TTX)) {
- if (mode.equals("jakartaEE"))
- cf2 = (TopicConnectionFactory) jndiContext
- .lookup("java:comp/env/jms/" + lookup);
- else
- cf2 = (TopicConnectionFactory) jmsObjects
- .getTopicConnectionFactory(lookup);
- if (username.equals(JMSDEFAULT) || password.equals(JMSDEFAULT)) {
- cC = cf2.createConnection();
- return cC;
- } else {
- cC = cf2.createConnection(username, password);
- return cC;
- }
- } else {
- throw new Exception("Failed to get new Connection");
- }
- }
-
- /**********************************************************************************
- * Returns a new Connection for tests that require more than the default
- * connection. The returned Connection object must be explicitly cast into a
- * QueueConnection or TopicConnection.
- *
- * @param int
- * type (QUEUE type or TOPIC type)
- * @return Connection from the default Queue or Topic ConnectionFactory
- **********************************************************************************/
- public Connection getNewConnection(int type) throws Exception {
- return getNewConnection(type, JMSDEFAULT, JMSDEFAULT);
- }
-
- /***************************************************************
- * Return connection type (QUEUE or TOPIC)
- **************************************************************/
- public int getType() {
- return ttype;
- }
-
- /**********************************************************************************
- * flushDestinationJMSContext Flush destination Queue using JMSContext
- *
- * Use this method at cleanup time to remove any messages that have remained
- * on the queue.
- **********************************************************************************/
- public void flushDestinationJMSContext() throws Exception {
- JMSConsumer consumer = null;
- JMSContext context = null;
- int numMsgsFlushed = 0;
-
- try {
- if (getDefaultConnection() != null) {
- TestUtil.logTrace(
- "Closing default connection in flushDestinationJMSContext()");
- try {
- getDefaultConnection().close();
- } catch (Exception ex) {
- TestUtil.logErr("Error closing default connection", ex);
- }
- }
-
- TestUtil.logTrace(
- "Create new JMSContext and JMSConsumer to flush Destination");
- context = createNewJMSContext(ttype, username, password);
- consumer = context.createConsumer(testDestination);
-
- TestUtil.logTrace("Now flush the Destination");
- Message rmsg = consumer.receive(5000);
- while (rmsg != null) {
- numMsgsFlushed++;
- rmsg = consumer.receiveNoWait();
- if (rmsg == null) {
- // Should be last message (try receive(1000) one more time to make
- // sure it is)
- rmsg = consumer.receive(1000);
- }
- }
-
- if (numMsgsFlushed > 0) {
- TestUtil.logTrace("Flushed " + numMsgsFlushed + " messages");
- } else {
- TestUtil.logTrace("No messages to flush");
- }
- } catch (Exception e) {
- TestUtil.logErr(
- "Cleanup error attempting to flush Destination: " + e.toString());
- } finally {
- try {
- consumer.close();
- context.close();
- } catch (Exception e) {
- }
- }
- }
-
- /**********************************************************************************
- * createNewJMSContext Return a new JMSContext.
- *
- * @param int
- * type (QUEUE type or TOPIC type)
- * @param String
- * (username)
- * @param String
- * (password)
- * @return JMSContext
- **********************************************************************************/
- private JMSContext createNewJMSContext(int type, String username,
- String password) throws Exception {
- JMSContext context = null;
- if ((type == QUEUE) || (type == TX_QUEUE)) {
- if (username.equals(JMSDEFAULT) || password.equals(JMSDEFAULT)) {
- context = qcf.createContext();
- } else {
- context = qcf.createContext(username, password);
- }
- } else if ((type == TOPIC) || (type == TX_TOPIC) || (type == DURABLE_TOPIC)
- || (type == DURABLE_TX_TOPIC)) {
- if (username.equals(JMSDEFAULT) || password.equals(JMSDEFAULT)) {
- context = tcf.createContext();
- } else {
- context = tcf.createContext(username, password);
- }
- } else if ((type == COMMON_Q) || (type == COMMON_T) || (type == COMMON_QTX)
- || (type == COMMON_TTX)) {
- if (username.equals(JMSDEFAULT) || password.equals(JMSDEFAULT)) {
- context = cf.createContext();
- } else {
- context = cf.createContext(username, password);
- }
- } else {
- throw new Exception("Failed to create new JMSContext");
- }
- return context;
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/jms/common/JmsUtil.java b/common/src/main/java/com/sun/ts/tests/jms/common/JmsUtil.java
deleted file mode 100644
index 052456c949..0000000000
--- a/common/src/main/java/com/sun/ts/tests/jms/common/JmsUtil.java
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.jms.common;
-
-import java.util.Enumeration;
-
-import com.sun.ts.lib.util.TestUtil;
-
-import jakarta.jms.JMSException;
-import jakarta.jms.Message;
-import jakarta.jms.QueueSender;
-import jakarta.jms.QueueSession;
-import jakarta.jms.TextMessage;
-
-/**
- * JmsUtil is a final tool class that will provide support for common code for
- * jms tests.
- *
- * @author Irene Caruso
- *
- */
-public final class JmsUtil {
- public static boolean test1SecondTime = false;
-
- public static boolean test2SecondTime = false;
-
- public static boolean test2Results = false;
-
- public static boolean test7SecondTime = false;
-
- // used by initHarnessProps() to cache last value
- private static String cHost = null;
-
- private static String cTrace = null;
-
- private static String cPort = null;
-
- // used by addPropsToMessage() to cache last value
- private static String hHost = null;
-
- private static String hTrace = null;
-
- private static String hPort = null;
-
- /**
- * used by jms tests to pass cts properties object to mdb to initialize cts
- * logging mechanism
- *
- * @param p
- * the Properties object
- * @param msg
- * the JMS Message object
- *
- */
-
- public static void addPropsToMessage(Message msg, java.util.Properties p) {
- String hostname = null;
- String traceFlag = null;
- String logPort = null;
- Enumeration e = null;
- String key = null;
- String notValid = ".";
-
- try {
-
- // get the properties that have "." in them
- // can't put "." in JMS message, rename them.
-
- // cache last value for these props -
- // sometimes they are null when passed
- // ??Harness issue??
-
- hostname = TestUtil.getProperty(p, "harness.host");
- TestUtil.logTrace("Hostname " + hostname);
- if (hostname == null) {
- if (hHost != null)
- msg.setStringProperty("harnesshost", hHost);
- else {
- TestUtil.logTrace("addPropsToMsg: Hostname is null");
- throw new Exception("Error getting hostname");
- }
- } else {
- msg.setStringProperty("harnesshost", hostname);
- hHost = hostname;
- }
-
- traceFlag = TestUtil.getProperty(p, "harness.log.traceflag");
- TestUtil.logTrace("testFlag " + traceFlag);
- if (traceFlag == null) {
- if (hTrace != null)
- msg.setStringProperty("harnesslogtraceflag", hTrace);
- else {
- TestUtil.logTrace("addProps:traceflag is null");
- throw new Exception("Error getting traceflag");
- }
- } else {
- msg.setStringProperty("harnesslogtraceflag", traceFlag);
- hTrace = traceFlag;
- }
-
- logPort = TestUtil.getProperty(p, "harness.log.port");
- TestUtil.logTrace("logPort " + logPort);
- if (logPort == null) {
- if (hPort != null)
- msg.setStringProperty("harnesslogport", hPort);
- else {
- TestUtil.logTrace("addProps: logport is null");
- throw new Exception("Error getting port");
- }
- } else {
- msg.setStringProperty("harnesslogport", logPort);
- hPort = logPort;
- }
-
- // get the rest of the props to put in JMS message.
- // Sql queries are currently passed as props, may need
- // them in the message for testing w/ DB's
-
- e = p.propertyNames();
- key = null;
- while (e.hasMoreElements()) {
- key = (String) e.nextElement();
- TestUtil.logTrace("addProps: " + key);
- if ((key.indexOf(notValid) == -1) && (key.indexOf("***") == -1)
- && !(key.startsWith("JMS"))) {
- TestUtil.logTrace("addProps: add property " + key);
- msg.setStringProperty(key, TestUtil.getProperty(p, key));
- }
- }
- } catch (Exception ex) {
- TestUtil.printStackTrace(ex);
- TestUtil.logMsg("Error setting harness Properties in jms msg");
- }
- }
-
- /**
- * used by MDB onMessage() to extract cts properties from JMS Message to
- * initialize cts logging mechanism
- *
- * @param p
- * the Properties object
- * @param msg
- * the JMS Message object
- *
- */
- public static void initHarnessProps(Message msg, java.util.Properties p) {
-
- String hostname = null;
- String traceflag = null;
- String logport = null;
-
- try {
- hostname = msg.getStringProperty("harnesshost");
- TestUtil.logTrace("initHarn: Hostname " + hostname);
- if (hostname == null) {
- TestUtil.logTrace("intiHarn:Hostname is null");
- if (cHost != null)
- p.put("harness.host", cHost);
- else
- throw new Exception("Error getting hostname");
- } else {
- p.put("harness.host", hostname);
- cHost = hostname;
- }
-
- traceflag = msg.getStringProperty("harnesslogtraceflag");
- TestUtil.logTrace("initHarn:traceflag " + traceflag);
- if (traceflag == null) {
- TestUtil.logTrace("initHarn: is null");
- if (cTrace != null)
- p.put("harness.log.traceflag", cTrace);
- else
- throw new Exception("Error getting traceflag");
- } else {
- p.put("harness.log.traceflag", traceflag);
- cTrace = traceflag;
- }
-
- logport = msg.getStringProperty("harnesslogport");
- TestUtil.logTrace("initHarn:logport " + logport);
- if (logport == null) {
- TestUtil.logTrace("initHarn:logport is null");
- if (cPort != null)
- p.put("harness.log.port", cPort);
- else
- throw new Exception("Error getting port");
- } else {
- p.put("harness.log.port", logport);
- cPort = logport;
- }
-
- // now pull out the rest of the properties from the message
- Enumeration e = msg.getPropertyNames();
- String key = null;
- while (e.hasMoreElements()) {
- key = (String) e.nextElement();
- if (!key.startsWith("JMS"))
- p.put(key, msg.getStringProperty(key));
- }
-
- // now initialize the props
- TestUtil.init(p);
-
- } catch (Exception e) {
- TestUtil.printStackTrace(e);
- }
- }
-
- public static void sendTestResults(String testCase, boolean results,
- QueueSession qSession, jakarta.jms.Queue queueR) {
- TextMessage msg = null;
- QueueSender mSender = null;
-
- TestUtil.logTrace("*@$#)@(@#$ --- - - sendTestResults ");
-
- try {
- // create a msg sender for the response queue
- mSender = qSession.createSender(queueR);
- // and we'll send a text msg
- msg = qSession.createTextMessage();
- msg.setStringProperty("TestCase", testCase);
- msg.setText(testCase);
- if (results)
- msg.setStringProperty("Status", "Pass");
- else
- msg.setStringProperty("Status", "Fail");
- TestUtil.logTrace("*@$#)@(@$#@($----Sending response message ");
- TestUtil.logTrace(
- "*@$#)@(@ ----- status: " + msg.getStringProperty("Status"));
- TestUtil.logTrace(
- "*@$#)@(@# -----test: " + msg.getStringProperty("TestCase"));
- mSender.send(msg);
-
- } catch (JMSException je) {
- TestUtil.printStackTrace(je);
- } catch (Exception ee) {
- TestUtil.printStackTrace(ee);
- }
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/jms/common/MapMessageTestImpl.java b/common/src/main/java/com/sun/ts/tests/jms/common/MapMessageTestImpl.java
deleted file mode 100644
index bb0557fb5c..0000000000
--- a/common/src/main/java/com/sun/ts/tests/jms/common/MapMessageTestImpl.java
+++ /dev/null
@@ -1,711 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * @(#)MapMessageTestImpl.java 1.5 03/05/16
- */
-
-package com.sun.ts.tests.jms.common;
-
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Vector;
-
-import jakarta.jms.JMSException;
-import jakarta.jms.MapMessage;
-import jakarta.jms.MessageFormatException;
-import jakarta.jms.MessageNotWriteableException;
-
-/**
- * Class Declaration.
- *
- *
- * @see
- *
- * @author
- * @version 1.2, 09/26/00
- */
-public class MapMessageTestImpl extends MessageTestImpl implements MapMessage {
- private HashMap htable;
-
- /**
- * Class Constructor.
- *
- *
- * @see
- */
- public MapMessageTestImpl() {
- super();
- init();
- } // MapMessageTestImpl()
-
- /**
- * Initializes the object during construction. Put things that are common to
- * all constructors here
- */
- private void init() {
- htable = new HashMap();
- }
-
- /**
- * Return the boolean value with the given name.
- *
- * @param name
- * the name of the boolean
- *
- * @return the boolean value with the given name.
- *
- * @exception JMSException
- * if JMS fails to read message due to some internal JMS error.
- * @exception MessageFormatException
- * if this type conversion is invalid.
- */
- public boolean getBoolean(String name) throws JMSException {
- boolean ret = false;
- Object value = htable.get(name);
-
- if (value instanceof Boolean) {
- ret = ((Boolean) value).booleanValue();
- } else if (value instanceof String) {
- ret = Boolean.valueOf((String) value).booleanValue();
- } else {
- throw new MessageFormatException("type conversion is invalid");
- } // if .. else
- return ret;
- } // getBoolean()
-
- /**
- * Return the byte value with the given name.
- *
- * @param name
- * the name of the byte
- *
- * @return the byte value with the given name.
- *
- * @exception JMSException
- * if JMS fails to read message due to some internal JMS error.
- * @exception MessageFormatException
- * if this type conversion is invalid.
- */
- public byte getByte(String name) throws JMSException {
- byte ret = 0;
- Object value = htable.get(name);
-
- if (value instanceof Byte) {
- ret = ((Byte) value).byteValue();
- } else if (value instanceof String) {
- ret = Byte.valueOf((String) value).byteValue();
- } else {
- throw new MessageFormatException("type conversion is invalid");
- } // if .. else
- return ret;
- } // getByte()
-
- /**
- * Return the short value with the given name.
- *
- * @param name
- * the name of the short
- *
- * @return the short value with the given name.
- *
- * @exception JMSException
- * if JMS fails to read message due to some internal JMS error.
- * @exception MessageFormatException
- * if this type conversion is invalid.
- */
- public short getShort(String name) throws JMSException {
- short ret = 0;
- Object value = htable.get(name);
-
- if (value instanceof Byte) {
- ret = ((Byte) value).byteValue();
- } else if (value instanceof Short) {
- ret = ((Short) value).shortValue();
- } else if (value instanceof String) {
- ret = Short.valueOf((String) value).shortValue();
- } else {
- throw new MessageFormatException("type conversion is invalid");
- } // if .. else
- return ret;
- } // getShort()
-
- /**
- * Return the Unicode character value with the given name.
- *
- * @param name
- * the name of the Unicode character
- *
- * @return the Unicode character value with the given name.
- *
- * @exception JMSException
- * if JMS fails to read message due to some internal JMS error.
- * @exception MessageFormatException
- * if this type conversion is invalid.
- */
- public char getChar(String name) throws JMSException {
- char ret = 0;
- Object value = htable.get(name);
-
- if (value instanceof Character) {
- ret = ((Character) value).charValue();
- } else if (value instanceof String) {
- ret = ((String) value).charAt(0);
- } else {
- throw new MessageFormatException("type conversion is invalid");
- } // if .. else
- return ret;
- } // getChar()
-
- /**
- * Return the integer value with the given name.
- *
- * @param name
- * the name of the integer
- *
- * @return the integer value with the given name.
- *
- * @exception JMSException
- * if JMS fails to read message due to some internal JMS error.
- * @exception MessageFormatException
- * if this type conversion is invalid.
- */
- public int getInt(String name) throws JMSException {
- int ret = 0;
- Object value = htable.get(name);
-
- if (value instanceof Byte) {
- ret = ((Byte) value).byteValue();
- } else if (value instanceof Short) {
- ret = ((Short) value).shortValue();
- } else if (value instanceof Integer) {
- ret = ((Integer) value).intValue();
- } else if (value instanceof String) {
- ret = Integer.valueOf((String) value).intValue();
- } else {
- throw new MessageFormatException("type conversion is invalid");
- } // if .. else
- return ret;
- } // getInt()
-
- /**
- * Return the long value with the given name.
- *
- * @param name
- * the name of the long
- *
- * @return the long value with the given name.
- *
- * @exception JMSException
- * if JMS fails to read message due to some internal JMS error.
- * @exception MessageFormatException
- * if this type conversion is invalid.
- */
- public long getLong(String name) throws JMSException {
- long ret = 0;
- Object value = htable.get(name);
-
- if (value instanceof Byte) {
- ret = ((Byte) value).byteValue();
- } else if (value instanceof Short) {
- ret = ((Short) value).shortValue();
- } else if (value instanceof Integer) {
- ret = ((Integer) value).intValue();
- } else if (value instanceof Long) {
- ret = ((Long) value).longValue();
- } else if (value instanceof String) {
- ret = Long.valueOf((String) value).longValue();
- } else {
- throw new MessageFormatException("type conversion is invalid");
- } // if .. else
- return ret;
- } // getLong()
-
- /**
- * Return the float value with the given name.
- *
- * @param name
- * the name of the float
- *
- * @return the float value with the given name.
- *
- * @exception JMSException
- * if JMS fails to read message due to some internal JMS error.
- * @exception MessageFormatException
- * if this type conversion is invalid.
- */
- public float getFloat(String name) throws JMSException {
- float ret = 0;
- Object value = htable.get(name);
-
- if (value instanceof Float) {
- ret = ((Float) value).floatValue();
- } else if (value instanceof String) {
- ret = Float.valueOf((String) value).floatValue();
- } else {
- throw new MessageFormatException("type conversion is invalid");
- } // if .. else
- return ret;
- } // getFloat()
-
- /**
- * Return the double value with the given name.
- *
- * @param name
- * the name of the double
- *
- * @return the double value with the given name.
- *
- * @exception JMSException
- * if JMS fails to read message due to some internal JMS error.
- * @exception MessageFormatException
- * if this type conversion is invalid.
- */
- public double getDouble(String name) throws JMSException {
- double ret = 0;
- Object value = htable.get(name);
-
- if (value instanceof Float) {
- ret = ((Float) value).floatValue();
- } else if (value instanceof Double) {
- ret = ((Double) value).doubleValue();
- } else if (value instanceof String) {
- ret = Double.valueOf((String) value).doubleValue();
- } else {
- throw new MessageFormatException("type conversion is invalid");
- } // if .. else
- return ret;
- } // getDouble()
-
- /**
- * Return the String value with the given name.
- *
- * @param name
- * the name of the String
- *
- * @return the String value with the given name. If there is no item by this
- * name, a null value is returned.
- *
- * @exception JMSException
- * if JMS fails to read message due to some internal JMS error.
- * @exception MessageFormatException
- * if this type conversion is invalid.
- */
- public String getString(String name) throws JMSException {
- String ret = null;
- Object value = htable.get(name);
-
- if ((value instanceof Boolean) || (value instanceof Byte)
- || (value instanceof Short) || (value instanceof Character)
- || (value instanceof Integer) || (value instanceof Long)
- || (value instanceof Float) || (value instanceof Double)
- || (value instanceof String)) {
- ret = String.valueOf(value);
- } else {
- throw new MessageFormatException("invalid type");
- } // if .. else
- return ret;
- } // getString()
-
- /**
- * Return the byte array value with the given name.
- *
- * @param name
- * the name of the byte array
- *
- * @return the byte array value with the given name. If there is no item by
- * this name, a null value is returned.
- *
- * @exception JMSException
- * if JMS fails to read message due to some internal JMS error.
- * @exception MessageFormatException
- * if this type conversion is invalid.
- */
- public byte[] getBytes(String name) throws JMSException {
- byte[] ret = null;
- Object value = htable.get(name);
-
- if (value instanceof byte[]) {
- ret = (byte[]) value;
- } else {
- throw new MessageFormatException("invalid type");
- } // if .. else
- return ret;
- } // getBytes()
-
- /**
- * Return the Java object value with the given name.
- *
- *
- * Note that this method can be used to return in objectified format, an
- * object that had been stored in the Map with the equivalent
- * setObject method call, or it's equivalent primitive set
- * method.
- *
- * @param name
- * the name of the Java object
- *
- * @return the Java object value with the given name, in objectified format
- * (ie. if it set as an int, then a Integer is returned). If there is
- * no item by this name, a null value is returned.
- *
- * @exception JMSException
- * if JMS fails to read message due to some internal JMS error.
- */
- public Object getObject(String name) throws JMSException {
- return htable.get(name);
- } // getObject()
-
- /**
- * Return an Enumeration of all the Map message's names.
- *
- * @return an enumeration of all the names in this Map message.
- *
- * @exception JMSException
- * if JMS fails to read message due to some internal JMS error.
- */
- public Enumeration getMapNames() throws JMSException {
- Vector v = new Vector(htable.keySet());
-
- return v.elements();
- } // getMapNames()
-
- /**
- * Set a boolean value with the given name, into the Map.
- *
- * @param name
- * the name of the boolean
- * @param value
- * the boolean value to set in the Map.
- *
- * @exception JMSException
- * if JMS fails to write message due to some internal JMS error.
- * @exception MessageNotWriteableException
- * if message in read-only mode.
- */
- public void setBoolean(String name, boolean value) throws JMSException {
- try {
- htable.put(name, Boolean.valueOf(value));
- } catch (NullPointerException e) {
- JMSException jmsEx = new JMSException("NullPointerException"); // I18N
-
- jmsEx.setLinkedException(e);
- throw jmsEx;
- } // try .. catch
- } // setBoolean()
-
- /**
- * Set a byte value with the given name, into the Map.
- *
- * @param name
- * the name of the byte
- * @param value
- * the byte value to set in the Map.
- *
- * @exception JMSException
- * if JMS fails to write message due to some internal JMS error.
- * @exception MessageNotWriteableException
- * if message in read-only mode.
- */
- public void setByte(String name, byte value) throws JMSException {
- try {
- htable.put(name, Byte.valueOf(value));
- } catch (NullPointerException e) {
- JMSException jmsEx = new JMSException("NullPointerException"); // I18N
-
- jmsEx.setLinkedException(e);
- throw jmsEx;
- } // try .. catch
- } // setByte()
-
- /**
- * Set a short value with the given name, into the Map.
- *
- * @param name
- * the name of the short
- * @param value
- * the short value to set in the Map.
- *
- * @exception JMSException
- * if JMS fails to write message due to some internal JMS error.
- * @exception MessageNotWriteableException
- * if message in read-only mode.
- */
- public void setShort(String name, short value) throws JMSException {
- try {
- htable.put(name, Short.valueOf(value));
- } catch (NullPointerException e) {
- JMSException jmsEx = new JMSException("NullPointerException"); // I18N
-
- jmsEx.setLinkedException(e);
- throw jmsEx;
- } // try .. catch
- } // setShort()
-
- /**
- * Set a Unicode character value with the given name, into the Map.
- *
- * @param name
- * the name of the Unicode character
- * @param value
- * the Unicode character value to set in the Map.
- *
- * @exception JMSException
- * if JMS fails to write message due to some internal JMS error.
- * @exception MessageNotWriteableException
- * if message in read-only mode.
- */
- public void setChar(String name, char value) throws JMSException {
- try {
- htable.put(name, Character.valueOf(value));
- } catch (NullPointerException e) {
- JMSException jmsEx = new JMSException("NullPointerException"); // I18N
-
- jmsEx.setLinkedException(e);
- throw jmsEx;
- } // try .. catch
- } // setChar()
-
- /**
- * Set an integer value with the given name, into the Map.
- *
- * @param name
- * the name of the integer
- * @param value
- * the integer value to set in the Map.
- *
- * @exception JMSException
- * if JMS fails to write message due to some internal JMS error.
- * @exception MessageNotWriteableException
- * if message in read-only mode.
- */
- public void setInt(String name, int value) throws JMSException {
- try {
- htable.put(name, Integer.valueOf(value));
- } catch (NullPointerException e) {
- JMSException jmsEx = new JMSException("NullPointerException"); // I18N
-
- jmsEx.setLinkedException(e);
- throw jmsEx;
- } // try .. catch
- } // setInt()
-
- /**
- * Set a long value with the given name, into the Map.
- *
- * @param name
- * the name of the long
- * @param value
- * the long value to set in the Map.
- *
- * @exception JMSException
- * if JMS fails to write message due to some internal JMS error.
- * @exception MessageNotWriteableException
- * if message in read-only mode.
- */
- public void setLong(String name, long value) throws JMSException {
- try {
- htable.put(name, Long.valueOf(value));
- } catch (NullPointerException e) {
- JMSException jmsEx = new JMSException("NullPointerException"); // I18N
-
- jmsEx.setLinkedException(e);
- throw jmsEx;
- } // try .. catch
- } // setLong()
-
- /**
- * Set a float value with the given name, into the Map.
- *
- * @param name
- * the name of the float
- * @param value
- * the float value to set in the Map.
- *
- * @exception JMSException
- * if JMS fails to write message due to some internal JMS error.
- * @exception MessageNotWriteableException
- * if message in read-only mode.
- */
- public void setFloat(String name, float value) throws JMSException {
- try {
- htable.put(name, Float.valueOf(value));
- } catch (NullPointerException e) {
- JMSException jmsEx = new JMSException("NullPointerException"); // I18N
-
- jmsEx.setLinkedException(e);
- throw jmsEx;
- } // try .. catch
- } // setFloat()
-
- /**
- * Set a double value with the given name, into the Map.
- *
- * @param name
- * the name of the double
- * @param value
- * the double value to set in the Map.
- *
- * @exception JMSException
- * if JMS fails to write message due to some internal JMS error.
- * @exception MessageNotWriteableException
- * if message in read-only mode.
- */
- public void setDouble(String name, double value) throws JMSException {
- try {
- htable.put(name, Double.valueOf(value));
- } catch (NullPointerException e) {
- JMSException jmsEx = new JMSException("NullPointerException"); // I18N
-
- jmsEx.setLinkedException(e);
- throw jmsEx;
- } // try .. catch
- } // setDouble()
-
- /**
- * Set a String value with the given name, into the Map.
- *
- * @param name
- * the name of the String
- * @param value
- * the String value to set in the Map.
- *
- * @exception JMSException
- * if JMS fails to write message due to some internal JMS error.
- * @exception MessageNotWriteableException
- * if message in read-only mode.
- */
- public void setString(String name, String value) throws JMSException {
- try {
- htable.put(name, value);
- } catch (NullPointerException e) {
- JMSException jmsEx = new JMSException("NullPointerException"); // I18N
-
- jmsEx.setLinkedException(e);
- throw jmsEx;
- } // try .. catch
- } // setString()
-
- /**
- * Set a byte array value with the given name, into the Map.
- *
- * @param name
- * the name of the byte array
- * @param value
- * the byte array value to set in the Map.
- *
- * @exception JMSException
- * if JMS fails to write message due to some internal JMS error.
- * @exception MessageNotWriteableException
- * if message in read-only mode.
- */
- public void setBytes(String name, byte[] value) throws JMSException {
- try {
- htable.put(name, value);
- } catch (NullPointerException e) {
- JMSException jmsEx = new JMSException("NullPointerException"); // I18N
-
- jmsEx.setLinkedException(e);
- throw jmsEx;
- } // try .. catch
- } // setBytes()
-
- /**
- * Set a portion of the byte array value with the given name, into the Map.
- *
- * @param name
- * the name of the byte array
- * @param value
- * the byte array value to set in the Map.
- * @param offset
- * the initial offset within the byte array.
- * @param length
- * the number of bytes to use.
- *
- * @exception JMSException
- * if JMS fails to write message due to some internal JMS error.
- * @exception MessageNotWriteableException
- * if message in read-only mode.
- */
- public void setBytes(String name, byte[] value, int offset, int length)
- throws JMSException {
- try {
- byte[] newValue = (byte[]) htable.get(name);
-
- System.arraycopy(value, 0, newValue, offset, length);
- htable.put(name, newValue);
- } catch (NullPointerException e) {
- JMSException jmsEx = new JMSException("NullPointerException"); // I18N
-
- jmsEx.setLinkedException(e);
- throw jmsEx;
- } // try .. catch
- } // setBytes()
-
- /**
- * Set a Java object value with the given name, into the Map.
- *
- *
- * Note that this method only works for the objectified primitive object types
- * (Integer, Double, Long ...), String's and byte arrays.
- *
- * @param name
- * the name of the Java object
- * @param value
- * the Java object value to set in the Map.
- *
- * @exception JMSException
- * if JMS fails to write message due to some internal JMS error.
- * @exception MessageFormatException
- * if object is invalid
- * @exception MessageNotWriteableException
- * if message in read-only mode.
- */
- public void setObject(String name, Object value) throws JMSException {
- try {
- if ((value instanceof Boolean) || (value instanceof Byte)
- || (value instanceof Short) || (value instanceof Character)
- || (value instanceof Integer) || (value instanceof Long)
- || (value instanceof Float) || (value instanceof Double)
- || (value instanceof String) || (value instanceof byte[])) {
- htable.put(name, value);
- } else {
- throw new MessageFormatException("invalid type");
- } // if .. else
- } catch (NullPointerException e) {
- JMSException jmsEx = new JMSException("NullPointerException"); // I18N
-
- jmsEx.setLinkedException(e);
- throw jmsEx;
- } // try .. catch
- } // setObject()
-
- /**
- * Check if an item exists in this MapMessage.
- *
- * @param name
- * the name of the item to test
- *
- * @return true if the item does exist.
- *
- * @exception JMSException
- * if a JMS error occurs.
- */
- public boolean itemExists(String name) throws JMSException {
- return htable.containsKey(name);
- } // itemExists()
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/jms/common/MessageTestImpl.java b/common/src/main/java/com/sun/ts/tests/jms/common/MessageTestImpl.java
deleted file mode 100644
index cb903f961d..0000000000
--- a/common/src/main/java/com/sun/ts/tests/jms/common/MessageTestImpl.java
+++ /dev/null
@@ -1,839 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.jms.common;
-
-import java.util.Enumeration;
-import java.util.Hashtable;
-
-import jakarta.jms.Destination;
-import jakarta.jms.JMSException;
-import jakarta.jms.Message;
-import jakarta.jms.MessageFormatException;
-import jakarta.jms.MessageNotReadableException;
-
-/**
- * Class Declaration.
- *
- *
- * @see
- *
- * @author
- * @version 1.2, 09/26/00
- */
-public class MessageTestImpl implements Message {
- public boolean dummy = false;
-
- private String JMSMessageID;
-
- private long JMSTimestamp;
-
- private byte[] JMSCorrelationIDAsBytes;
-
- private String JMSCorrelationID;
-
- private Destination JMSReplyTo;
-
- private Destination JMSDestination;
-
- private int JMSDeliveryMode;
-
- private boolean JMSRedelivered;
-
- private String JMSType;
-
- private long JMSExpiration;
-
- private long JMSDeliveryTime;
-
- private long JMSDeliveryDelay;
-
- private int JMSPriority;
-
- private Hashtable properties;
-
- protected boolean bufferIsDirty = false;
-
- protected boolean readMode = false;
-
- /**
- * Constructor
- */
- public MessageTestImpl() {
- properties = new Hashtable();
- this.JMSPriority = jakarta.jms.Message.DEFAULT_PRIORITY;
- this.JMSDeliveryMode = jakarta.jms.Message.DEFAULT_DELIVERY_MODE;
- this.JMSDeliveryDelay = 0L;
- }
-
- /**
- * Method Declaration.
- *
- *
- * @return
- *
- * @exception JMSException
- *
- * @see
- */
- public String getJMSMessageID() throws JMSException {
- return JMSMessageID;
- }
-
- /**
- * Method Declaration.
- *
- *
- * @param id
- *
- * @exception JMSException
- *
- * @see
- */
- public void setJMSMessageID(String id) throws JMSException {
- JMSMessageID = id;
- }
-
- /**
- * Method Declaration.
- *
- *
- * @return
- *
- * @exception JMSException
- *
- * @see
- */
- public long getJMSTimestamp() throws JMSException {
- return JMSTimestamp;
- }
-
- /**
- * Method Declaration.
- *
- *
- * @param timestamp
- *
- * @exception JMSException
- *
- * @see
- */
- public void setJMSTimestamp(long timestamp) throws JMSException {
- JMSTimestamp = timestamp;
- }
-
- /**
- * Method Declaration.
- *
- *
- * @return
- *
- * @exception JMSException
- *
- * @see
- */
- public byte[] getJMSCorrelationIDAsBytes() throws JMSException {
- return JMSCorrelationIDAsBytes;
- }
-
- /**
- * Method Declaration.
- *
- *
- * @param correlationID
- *
- * @exception JMSException
- *
- * @see
- */
- public void setJMSCorrelationIDAsBytes(byte[] correlationID)
- throws JMSException {
- JMSCorrelationIDAsBytes = correlationID;
- }
-
- /**
- * Method Declaration.
- *
- *
- * @param correlationID
- *
- * @exception JMSException
- *
- * @see
- */
- public void setJMSCorrelationID(String correlationID) throws JMSException {
- JMSCorrelationID = correlationID;
- }
-
- /**
- * Method Declaration.
- *
- *
- * @return
- *
- * @exception JMSException
- *
- * @see
- */
- public String getJMSCorrelationID() throws JMSException {
- return JMSCorrelationID;
- }
-
- /**
- * Method Declaration.
- *
- *
- * @return
- *
- * @exception JMSException
- *
- * @see
- */
- public Destination getJMSReplyTo() throws JMSException {
- return JMSReplyTo;
- }
-
- /**
- * Method Declaration.
- *
- *
- * @param replyTo
- *
- * @exception JMSException
- *
- * @see
- */
- public void setJMSReplyTo(Destination replyTo) throws JMSException {
- JMSReplyTo = replyTo;
- }
-
- /**
- * Method Declaration.
- *
- *
- * @return
- *
- * @exception JMSException
- *
- * @see
- */
- public Destination getJMSDestination() throws JMSException {
- return JMSDestination;
- }
-
- /**
- * Method Declaration.
- *
- *
- * @param destination
- *
- * @exception JMSException
- *
- * @see
- */
- public void setJMSDestination(Destination destination) throws JMSException {
- JMSDestination = destination;
- }
-
- /**
- * Method Declaration.
- *
- *
- * @return
- *
- * @exception JMSException
- *
- * @see
- */
- public int getJMSDeliveryMode() throws JMSException {
- return JMSDeliveryMode;
- }
-
- /**
- * Method Declaration.
- *
- *
- * @param deliveryTime
- *
- * @exception JMSException
- *
- * @see
- */
- public void setJMSDeliveryTime(long deliveryTime) throws JMSException {
- JMSDeliveryTime = deliveryTime;
- }
-
- /**
- * Method Declaration.
- *
- *
- * @return
- *
- * @exception JMSException
- *
- * @see
- */
- public long getJMSDeliveryTime() throws JMSException {
- return JMSDeliveryTime;
- }
-
- /**
- * Method Declaration.
- *
- *
- * @param deliveryMode
- *
- * @exception JMSException
- *
- * @see
- */
- public void setJMSDeliveryMode(int deliveryMode) throws JMSException {
- JMSDeliveryMode = deliveryMode;
- }
-
- /**
- * Method Declaration.
- *
- *
- * @return
- *
- * @exception JMSException
- *
- * @see
- */
- public boolean getJMSRedelivered() throws JMSException {
- return JMSRedelivered;
- }
-
- /**
- * Method Declaration.
- *
- *
- * @param redelivered
- *
- * @exception JMSException
- *
- * @see
- */
- public void setJMSRedelivered(boolean redelivered) throws JMSException {
- JMSRedelivered = redelivered;
- }
-
- /**
- * Method Declaration.
- *
- *
- * @return
- *
- * @exception JMSException
- *
- * @see
- */
- public String getJMSType() throws JMSException {
- return JMSType;
- }
-
- /**
- * Method Declaration.
- *
- *
- * @param type
- *
- * @exception JMSException
- *
- * @see
- */
- public void setJMSType(String type) throws JMSException {
- JMSType = type;
- }
-
- /**
- * Method Declaration.
- *
- *
- * @return
- *
- * @exception JMSException
- *
- * @see
- */
- public long getJMSExpiration() throws JMSException {
- return JMSExpiration;
- }
-
- /**
- * Method Declaration.
- *
- *
- * @param expiration
- *
- * @exception JMSException
- *
- * @see
- */
- public void setJMSExpiration(long expiration) throws JMSException {
- JMSExpiration = expiration;
- }
-
- /**
- * Method Declaration.
- *
- *
- * @return
- *
- * @exception JMSException
- *
- * @see
- */
- public int getJMSPriority() throws JMSException {
- return JMSPriority;
- }
-
- /**
- * Method Declaration.
- *
- *
- * @param priority
- *
- * @exception JMSException
- *
- * @see
- */
- public void setJMSPriority(int priority) throws JMSException {
- JMSPriority = priority;
- }
-
- /**
- * Method Declaration.
- *
- *
- * @exception JMSException
- *
- * @see
- */
- public void clearProperties() throws JMSException {
- properties.clear();
- }
-
- /**
- * Method Declaration.
- *
- *
- * @param name
- *
- * @return
- *
- * @exception JMSException
- *
- * @see
- */
- public boolean propertyExists(String name) throws JMSException {
- return properties.containsKey(name);
- }
-
- /**
- * Method Declaration.
- *
- *
- * @param name
- *
- * @return
- *
- * @exception JMSException
- *
- * @see
- */
- public boolean getBooleanProperty(String name) throws JMSException {
- if (propertyExists(name)) {
- return ((Boolean) properties.get(name)).booleanValue();
- } else {
- throw new JMSException("property does not exist: " + name);
- }
- }
-
- /**
- * Method Declaration.
- *
- *
- * @param name
- *
- * @return
- *
- * @exception JMSException
- *
- * @see
- */
- public byte getByteProperty(String name) throws JMSException {
- if (propertyExists(name)) {
- return ((Byte) properties.get(name)).byteValue();
- } else {
- throw new JMSException("property does not exist: " + name);
- }
- }
-
- /**
- * Method Declaration.
- *
- *
- * @param name
- *
- * @return
- *
- * @exception JMSException
- *
- * @see
- */
- public short getShortProperty(String name) throws JMSException {
- if (propertyExists(name)) {
- return ((Short) properties.get(name)).shortValue();
- } else {
- throw new JMSException("property does not exist: " + name);
- }
- }
-
- /**
- * Method Declaration.
- *
- *
- * @param name
- *
- * @return
- *
- * @exception JMSException
- *
- * @see
- */
- public int getIntProperty(String name) throws JMSException {
- if (propertyExists(name)) {
- return ((Integer) properties.get(name)).intValue();
- } else {
- throw new JMSException("property does not exist: " + name);
- }
- }
-
- /**
- * Method Declaration.
- *
- *
- * @param name
- *
- * @return
- *
- * @exception JMSException
- *
- * @see
- */
- public long getLongProperty(String name) throws JMSException {
- if (propertyExists(name)) {
- return ((Long) properties.get(name)).longValue();
- } else {
- throw new JMSException("property does not exist: " + name);
- }
- }
-
- /**
- * Method Declaration.
- *
- *
- * @param name
- *
- * @return
- *
- * @exception JMSException
- *
- * @see
- */
- public float getFloatProperty(String name) throws JMSException {
- if (propertyExists(name)) {
- return ((Float) properties.get(name)).floatValue();
- } else {
- throw new JMSException("property does not exist: " + name);
- }
- }
-
- /**
- * Method Declaration.
- *
- *
- * @param name
- *
- * @return
- *
- * @exception JMSException
- *
- * @see
- */
- public double getDoubleProperty(String name) throws JMSException {
- if (propertyExists(name)) {
- return ((Double) properties.get(name)).doubleValue();
- } else {
- throw new JMSException("property does not exist: " + name);
- }
- }
-
- /**
- * Method Declaration.
- *
- *
- * @param name
- *
- * @return
- *
- * @exception JMSException
- *
- * @see
- */
- public String getStringProperty(String name) throws JMSException {
- if (propertyExists(name)) {
- return (String) properties.get(name);
- } else {
- throw new JMSException("property does not exist: " + name);
- }
- }
-
- /**
- * Method Declaration.
- *
- *
- * @param name
- *
- * @return
- *
- * @exception JMSException
- *
- * @see
- */
- public Object getObjectProperty(String name) throws JMSException {
- if (propertyExists(name)) {
- return properties.get(name);
- } else {
- throw new JMSException("property does not exist: " + name);
- }
- }
-
- /**
- * Method Declaration.
- *
- *
- * @return
- *
- * @exception JMSException
- *
- * @see
- */
- public Enumeration getPropertyNames() throws JMSException {
- return properties.keys();
-
- // Vector v = new Vector();
- // return v.elements();
- }
-
- /**
- * Method Declaration.
- *
- *
- * @param name
- * @param value
- *
- * @exception JMSException
- *
- * @see
- */
- public void setBooleanProperty(String name, boolean value)
- throws JMSException {
- properties.put(name, Boolean.valueOf(value));
- }
-
- /**
- * Method Declaration.
- *
- *
- * @param name
- * @param value
- *
- * @exception JMSException
- *
- * @see
- */
- public void setByteProperty(String name, byte value) throws JMSException {
- properties.put(name, Byte.valueOf(value));
- }
-
- /**
- * Method Declaration.
- *
- *
- * @param name
- * @param value
- *
- * @exception JMSException
- *
- * @see
- */
- public void setShortProperty(String name, short value) throws JMSException {
- properties.put(name, Short.valueOf(value));
- }
-
- /**
- * Method Declaration.
- *
- *
- * @param name
- * @param value
- *
- * @exception JMSException
- *
- * @see
- */
- public void setIntProperty(String name, int value) throws JMSException {
- properties.put(name, Integer.valueOf(value));
- }
-
- /**
- * Method Declaration.
- *
- *
- * @param name
- * @param value
- *
- * @exception JMSException
- *
- * @see
- */
- public void setLongProperty(String name, long value) throws JMSException {
- properties.put(name, Long.valueOf(value));
- }
-
- /**
- * Method Declaration.
- *
- *
- * @param name
- * @param value
- *
- * @exception JMSException
- *
- * @see
- */
- public void setFloatProperty(String name, float value) throws JMSException {
- properties.put(name, Float.valueOf(value));
- }
-
- /**
- * Method Declaration.
- *
- *
- * @param name
- * @param value
- *
- * @exception JMSException
- *
- * @see
- */
- public void setDoubleProperty(String name, double value) throws JMSException {
- properties.put(name, Double.valueOf(value));
- }
-
- /**
- * Method Declaration.
- *
- *
- * @param name
- * @param value
- *
- * @exception JMSException
- *
- * @see
- */
- public void setStringProperty(String name, String value) throws JMSException {
- properties.put(name, value);
- }
-
- /**
- * Method Declaration.
- *
- *
- * @param name
- * @param value
- *
- * @exception JMSException
- *
- * @see
- */
- public void setObjectProperty(String name, Object value) throws JMSException {
- properties.put(name, value);
- }
-
- /**
- * Dummy method for acknowledge
- */
- public void acknowledge() throws JMSException {
- }
-
- /**
- * Dummy method for clear
- */
- public void clearBody() throws JMSException {
- }
-
- protected void setBufferIsDirty(boolean state) {
- bufferIsDirty = state;
- }
-
- protected void checkReadAccess() throws JMSException {
- if (!readMode) {
- throw new MessageNotReadableException("Message is not Readable");
- }
- }
-
- /**
- * Returns the message body as an object of the specified type.
- *
- * @param c
- * - The type to which the message body will be assigned.
- *
- * @return the message body
- *
- * @exception JMSException
- * if JMS fails to read message due to some internal JMS error.
- * @exception MessageFormatException
- * if this type conversion is invalid.
- */
- public T getBody(Class c) throws JMSException {
- return (T) c;
- }
-
- /**
- * Returns whether the message body is capable of being assigned to the
- * specified type.
- *
- * @param c
- * - The specified type.
- *
- * @return whether the message body is capable of being assigned to the
- * specified type
- *
- * @exception JMSException
- * if a JMS error occurs.
- */
- public boolean isBodyAssignableTo(Class c) throws JMSException {
- return true;
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/jms/common/SerialTestMessageListenerImpl.java b/common/src/main/java/com/sun/ts/tests/jms/common/SerialTestMessageListenerImpl.java
deleted file mode 100644
index fea381da0d..0000000000
--- a/common/src/main/java/com/sun/ts/tests/jms/common/SerialTestMessageListenerImpl.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * @(#)SerialTestMessageListenerImpl.java 1.10 03/05/16
- */
-package com.sun.ts.tests.jms.common;
-
-import com.sun.ts.lib.util.TestUtil;
-
-import jakarta.jms.Message;
-
-public class SerialTestMessageListenerImpl
- implements jakarta.jms.MessageListener {
- public boolean inUse = false;
-
- public boolean testFailed = false;
-
- public DoneLatch monitor = new DoneLatch();
-
- public void onMessage(Message m) {
-
- // first check for concurrent usage
- if (inUse == true) {
- TestUtil.logMsg("Error -- concurrent use of MessageListener");
- testFailed = true;
- }
-
- // set flag, then check for final message
- inUse = true;
- TestUtil.logMsg("*MessageListener: onMessage() called. "
- + "Forcing other message listeners to wait.");
- try {
- if (m.getBooleanProperty("COM_SUN_JMS_TEST_LASTMESSAGE") == true) {
- TestUtil.logMsg("*MessageListener: Received final message");
- monitor.allDone();
- } else {
-
- // wait to force next onMessage() to wait
- for (int i = 0; i < 10000; i++) {
- }
- }
- } catch (Exception e) {
- TestUtil.printStackTrace(e);
- TestUtil.logErr("Failure in message listener: " + e.getMessage());
- testFailed = true;
- }
-
- // unset flag
- inUse = false;
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/jms/common/SessionThread.java b/common/src/main/java/com/sun/ts/tests/jms/common/SessionThread.java
deleted file mode 100644
index f796fa3834..0000000000
--- a/common/src/main/java/com/sun/ts/tests/jms/common/SessionThread.java
+++ /dev/null
@@ -1,364 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-package com.sun.ts.tests.jms.common;
-
-import com.sun.ts.lib.util.TestUtil;
-
-import jakarta.jms.Destination;
-import jakarta.jms.JMSException;
-import jakarta.jms.Message;
-import jakarta.jms.MessageConsumer;
-import jakarta.jms.MessageProducer;
-import jakarta.jms.Queue;
-import jakarta.jms.QueueConnection;
-import jakarta.jms.QueueSession;
-import jakarta.jms.Session;
-import jakarta.jms.Topic;
-import jakarta.jms.TopicConnection;
-import jakarta.jms.TopicSession;
-
-/**
- * Class Declaration.
- *
- *
- * @see
- *
- * @author
- * @version 1.16, 09/27/00
- */
-public class SessionThread extends Thread {
- private QueueConnection qConnection = null;
-
- private QueueSession qSession = null;
-
- private TopicConnection tConnection = null;
-
- private TopicSession tSession = null;
-
- // currently, only 1 producer and 1 consumer
- MessageConsumer consumer = null;
-
- MessageProducer producer = null;
-
- private boolean replyToMessages = false; // reply when receiving?
-
- private boolean stayAlive = false; // receive indefinitely
-
- private int messagesReceivedCount = 0; // total messages received
-
- boolean stdebug = false; // debug output
-
- /**
- * Default constructor creates Session Thread with connections specified.
- *
- * @param QueueConnection
- * for creating QueueSessions
- * @param TopicConnection
- * for creating TopicSessions
- */
- public SessionThread(QueueConnection qC, TopicConnection tC)
- throws JMSException {
-
- if (qC != null && tC != null) {
- throw new JMSException(
- "Both QueueConnection and TopicConnection are assigned, this is an error, it must be one or the other");
- }
- if (qC == null && tC == null) {
- throw new JMSException(
- "Both QueueConnection and TopicConnection are null, this is an error, it must be one or the other");
- }
- if (qC != null) {
- this.qConnection = qC;
- setQueueSession(false, Session.AUTO_ACKNOWLEDGE);
- } else {
- this.tConnection = tC;
- setTopicSession(false, Session.AUTO_ACKNOWLEDGE);
- }
- }
-
- /**
- * Method for specifying the QueueSession attributes.
- *
- * @param boolean
- * transacted
- * @param int
- * acknowledgement mode
- */
- public void setQueueSession(boolean transacted, int mode)
- throws JMSException {
- if (qConnection != null) {
- qSession = qConnection.createQueueSession(transacted, mode);
- }
- }
-
- /**
- * Method for specifying the TopicSession attributes..
- *
- * @param boolean
- * transacted
- * @param int
- * acknowledgement mode
- */
- public void setTopicSession(boolean transacted, int mode)
- throws JMSException {
- if (tConnection != null) {
- tSession = tConnection.createTopicSession(transacted, mode);
- }
- }
-
- /**
- * Return the current QueueSession
- *
- * @return QueueSession the current QueueSession for this client
- */
- public QueueSession getQueueSession() {
- return qSession;
- }
-
- /**
- * Return the current TopicSession
- *
- * @return TopicSession the current TopicSession for this client
- */
- public TopicSession getTopicSession() {
- return tSession;
- }
-
- /**
- * Used to start the Queue and Topic Connections when they are not the default
- * Connections. May also be used in place of someConnection.start() within the
- * main testing method.
- */
- public void startConnection() throws JMSException {
- if (qConnection != null) {
- if (stdebug) {
- TestUtil.logMsg("*ST: starting QueueConnection");
- }
- qConnection.start();
- }
- if (tConnection != null) {
- if (stdebug) {
- TestUtil.logMsg("*ST: starting TopicConnection");
- }
- tConnection.start();
- }
- }
-
- /**
- * Used to start only the specified Connection. Useful when it is not the
- * default Connection.
- */
- public void startQueueConnection() throws Exception {
- if (stdebug) {
- TestUtil.logMsg("*ST: starting specified connection -- Queue");
- }
- qConnection.start();
- }
-
- /**
- * Used to start only the specified Connection. Useful when it is not the
- * default Connection.
- */
- public void startTopicConnection() throws Exception {
- if (stdebug) {
- TestUtil.logMsg("*ST: starting specified connection -- Topic");
- }
- tConnection.start();
- }
-
- /**
- * Create message producers
- *
- * @param Destination
- * Queue or Topic
- */
- public void createProducer(Destination dest) throws Exception {
- if (qSession != null) {
- if (stdebug) {
- TestUtil.logMsg("*ST: creating QueueSender");
- }
- producer = qSession.createSender((Queue) dest);
- } else if (tSession != null) {
- if (stdebug) {
- TestUtil.logMsg("*ST: creating TopicPublisher");
- }
- producer = tSession.createPublisher((Topic) dest);
- } else {
- throw new Exception("Neither Queue or Topic were set");
- }
- TestUtil.logMsg("producer=" + producer);
- }
-
- /**
- * Create message consumers
- *
- * @param Destination
- * Queue or Topic
- */
- public void createConsumer(Destination dest) throws Exception {
- if (qSession != null) {
- if (stdebug) {
- TestUtil.logMsg("*ST: creating QueueReceiver");
- }
- consumer = qSession.createReceiver((Queue) dest);
- } else if (tSession != null) {
- if (stdebug) {
- TestUtil.logMsg("*ST: creating TopicSubscriber");
- }
- consumer = tSession.createSubscriber((Topic) dest);
- } else {
- throw new Exception("Neither Queue or Topic were configured");
- }
- TestUtil.logMsg("consumer=" + consumer);
- }
-
- /**
- * Set to true to have SessionThread reply automatically to messages.
- *
- * @param boolean
- * true for automatic request/reply
- */
- public void setReplyToMessages(boolean boo) {
- replyToMessages = boo;
- if (stdebug) {
- TestUtil.logMsg("*ST: will reply to messages -- " + replyToMessages);
- }
- }
-
- /**
- * Set to true to have SessionThread keep receiving messages indefinitely.
- *
- * @param boolean
- * true for indefinite receive()
- */
- public void setStayAlive(boolean boo) {
- stayAlive = boo;
- if (stdebug) {
- TestUtil
- .logMsg("*ST: will keep receiving after 1st message -- " + stayAlive);
- }
- }
-
- /**
- * Get the number of messages that have been received by this thread.
- *
- * @return int number of messages received
- */
- public int getMessagesReceivedCount() {
- return messagesReceivedCount;
- }
-
- /**
- * Reset the number of messages that have been received by this thread. Useful
- * once "steady-state" has been reached.
- */
- public void resetMessagesReceivedCount() {
- messagesReceivedCount = 0;
- if (stdebug) {
- TestUtil.logMsg("*ST: message count is now " + messagesReceivedCount);
- }
- }
-
- /**
- * Receive messages
- */
- private void receiveMessages() throws Exception {
- if (consumer == null) {
- throw new Exception("No message consumer ready");
- } else {
- if (replyToMessages) {
- do {
-
- // get Message
- TestUtil.logMsg("*ST: waiting to receive (reply mode)");
- Message msg = consumer.receive();
-
- if (msg == null) { // just being safe
- throw new Exception("Cannot respond to null message!");
- }
- messagesReceivedCount++;
- TestUtil.logMsg("*ST: received message -- creating reply");
-
- // get return Destination
- Destination dest = msg.getJMSReplyTo();
-
- if (stdebug) {
- TestUtil.logMsg("*ST: replying to " + dest);
- }
-
- // create Producer and reply with new Message
- if (qSession != null) {
- TestUtil.logMsg("Replying to TemporaryQueue");
- qSession.createSender((Queue) dest).send(qSession.createMessage());
- } else if (tSession != null) {
- TestUtil.logMsg("Replying to TemporaryTopic");
- tSession.createPublisher((Topic) dest)
- .publish(tSession.createMessage());
- } else {
-
- // this would be a strange case indeed
- throw new Exception("Neither Queue or Topic were configured");
- }
- if (stdebug) {
- TestUtil.logMsg("*ST: keep receiving -- " + stayAlive);
- }
- } while (stayAlive);
- } else { // non reply mode
- do {
- TestUtil
- .logMsg("*ST: waiting to receive. Will continue after receiving: "
- + stayAlive);
- Message msg = consumer.receive();
-
- if (msg == null) { // safety first
- throw new Exception("Received null message");
- }
- messagesReceivedCount++;
- if (stdebug) {
- TestUtil.logMsg("*ST: messages received: " + messagesReceivedCount);
- }
- TestUtil.logMsg("*ST: received " + msg.toString());
- } while (stayAlive);
- }
- }
- } // receiveMessages()
-
- /**
- * Stop it
- */
- public void stopWaiting() throws JMSException {
- TestUtil.logMsg("Attempting to stop MessageConsumer(s)");
- consumer.close();
- }
-
- /**
- * Run method
- */
- public void run() {
- TestUtil.logMsg("*ST: thread running");
- try {
- receiveMessages();
- } catch (Exception e) {
- TestUtil.logMsg("Session thread: could not receive message");
- TestUtil.logMsg("Reason being: " + e.getMessage());
- }
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/jms/common/StreamMessageTestImpl.java b/common/src/main/java/com/sun/ts/tests/jms/common/StreamMessageTestImpl.java
deleted file mode 100644
index 3d60e9a299..0000000000
--- a/common/src/main/java/com/sun/ts/tests/jms/common/StreamMessageTestImpl.java
+++ /dev/null
@@ -1,1133 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.jms.common;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.EOFException;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.ObjectStreamField;
-
-import jakarta.jms.JMSException;
-import jakarta.jms.MessageEOFException;
-import jakarta.jms.MessageFormatException;
-import jakarta.jms.MessageNotReadableException;
-import jakarta.jms.MessageNotWriteableException;
-import jakarta.jms.StreamMessage;
-
-/**
- * Class Declaration.
- *
- *
- * @see
- *
- * @author
- * @version 1.2, 09/26/00
- */
-public class StreamMessageTestImpl extends MessageTestImpl
- implements StreamMessage {
- static final private ObjectStreamField[] serialPersistentFields = {
- new ObjectStreamField("buf", byte[].class) };
-
- // every write method will first write the type byte,
- // and then the data with that type.
- public static final byte BOOLEAN_TYPE = 1;
-
- public static final byte BYTE_TYPE = 2;
-
- public static final byte CHAR_TYPE = 3;
-
- public static final byte DOUBLE_TYPE = 4;
-
- public static final byte FLOAT_TYPE = 5;
-
- public static final byte INT_TYPE = 6;
-
- public static final byte LONG_TYPE = 7;
-
- public static final byte SHORT_TYPE = 8;
-
- public static final byte STRING_TYPE = 9;
-
- public static final byte BYTES_TYPE = 10;
-
- byte[] buf = new byte[0];
-
- transient ByteArrayInputStream bais;
-
- transient ByteArrayOutputStream baos;
-
- transient DataInputStream dis;
-
- transient DataOutputStream dos;
-
- // for read/writeBytes
- private boolean first_time_readBytes = true;
-
- private int available_bytes = 0;
-
- /**
- * Class Constructor.
- *
- *
- * @see
- */
- public StreamMessageTestImpl() {
- super();
- init();
- } // StreamMessageTestImpl()
-
- /**
- * Method Declaration.
- *
- *
- * @see
- */
- private void init() {
- baos = new ByteArrayOutputStream();
- dos = new DataOutputStream(baos);
- }
-
- /**
- * Method Declaration.
- *
- *
- * @param oos
- *
- * @exception IOException
- *
- * @see
- */
- private void writeObject(ObjectOutputStream oos) throws IOException {
- dos.flush();
- buf = baos.toByteArray();
- oos.defaultWriteObject();
- }
-
- /**
- * Method Declaration.
- *
- *
- * @param ois
- *
- * @exception ClassNotFoundException
- * @exception IOException
- *
- * @see
- */
- private void readObject(ObjectInputStream ois)
- throws ClassNotFoundException, IOException {
- ois.defaultReadObject();
- baos = new ByteArrayOutputStream();
- dos = new DataOutputStream(baos);
- if (buf != null) {
- dos.write(buf);
- buf = null;
- }
- }
-
- /**
- * Method Declaration.
- *
- *
- * @return
- *
- * @exception JMSException
- *
- * @see
- */
- private byte getType() throws IOException {
- return dis.readByte();
- } // getType()
-
- /**
- * Method Declaration.
- *
- *
- * @return
- *
- * @exception IOException
- *
- * @see
- */
- private int getBytesLength() throws IOException {
- return dis.readInt();
- } // getType()
-
- /**
- * Read a boolean from the stream message.
- *
- * @return the boolean value read.
- *
- * @exception JMSException
- * if JMS fails to read message due to some internal JMS error.
- * @exception MessageEOFException
- * if an end of message stream
- * @exception MessageFormatException
- * if this type conversion is invalid
- * @exception MessageNotReadableException
- * if message in write-only mode.
- */
- public boolean readBoolean() throws JMSException {
- boolean ret = false;
- checkReadAccess();
-
- try {
- byte type = getType();
-
- switch (type) {
- case BOOLEAN_TYPE:
- ret = dis.readBoolean();
- break;
- case STRING_TYPE:
- String s = dis.readUTF();
-
- ret = Boolean.valueOf(s).booleanValue();
- break;
- default:
- throw new MessageFormatException("type conversion is invalid");
- } // switch
- } catch (EOFException e1) {
- throw new MessageEOFException("at end of message"); // I18N
- } catch (IOException e2) {
- JMSException jmsEx = new JMSException("IOException"); // I18N
-
- jmsEx.setLinkedException(e2);
- throw jmsEx;
- } // try .. catch
- return ret;
- } // readBoolean()
-
- /**
- * Read a byte value from the stream message.
- *
- * @return the next byte from the stream message as a 8-bit byte.
- *
- * @exception JMSException
- * if JMS fails to read message due to some internal JMS error.
- * @exception MessageEOFException
- * if an end of message stream
- * @exception MessageFormatException
- * if this type conversion is invalid
- * @exception MessageNotReadableException
- * if message in write-only mode.
- */
- public byte readByte() throws JMSException {
- byte ret = 0;
- checkReadAccess();
-
- try {
- byte type = getType();
-
- switch (type) {
- case BYTE_TYPE:
- ret = dis.readByte();
- break;
- case STRING_TYPE:
- String s = dis.readUTF();
-
- ret = Byte.valueOf(s).byteValue();
- break;
- default:
- throw new MessageFormatException("type conversion is invalid");
- } // switch
- } catch (EOFException e1) {
- throw new MessageEOFException("at end of message"); // I18N
- } catch (IOException e2) {
- JMSException jmsEx = new JMSException("IOException"); // I18N
-
- jmsEx.setLinkedException(e2);
- throw jmsEx;
- } // try .. catch
- return ret;
- } // readByte()
-
- /**
- * Read a 16-bit number from the stream message.
- *
- * @return a 16-bit number from the stream message.
- *
- * @exception JMSException
- * if JMS fails to read message due to some internal JMS error.
- * @exception MessageEOFException
- * if an end of message stream
- * @exception MessageFormatException
- * if this type conversion is invalid
- * @exception MessageNotReadableException
- * if message in write-only mode.
- */
- public short readShort() throws JMSException {
- short ret = 0;
- checkReadAccess();
-
- try {
- byte type = getType();
-
- switch (type) {
- case BYTE_TYPE:
- ret = dis.readByte();
- break;
- case SHORT_TYPE:
- ret = dis.readShort();
- break;
- case STRING_TYPE:
- String s = dis.readUTF();
-
- ret = Short.valueOf(s).shortValue();
- break;
- default:
- throw new MessageFormatException("type conversion is invalid");
- } // switch
- } catch (EOFException e1) {
- throw new MessageEOFException("at end of message"); // I18N
- } catch (IOException e2) {
- JMSException jmsEx = new JMSException("IOException"); // I18N
-
- jmsEx.setLinkedException(e2);
- throw jmsEx;
- } // try .. catch
- return ret;
- } // readShort()
-
- /**
- * Read a Unicode character value from the stream message.
- *
- * @return a Unicode character from the stream message.
- *
- * @exception JMSException
- * if JMS fails to read message due to some internal JMS error.
- * @exception MessageEOFException
- * if an end of message stream
- * @exception MessageFormatException
- * if this type conversion is invalid
- * @exception MessageNotReadableException
- * if message in write-only mode.
- */
- public char readChar() throws JMSException {
- char ret = 0;
- checkReadAccess();
-
- try {
- byte type = getType();
-
- switch (type) {
- case CHAR_TYPE:
- ret = dis.readChar();
- break;
- case STRING_TYPE:
- String s = dis.readUTF();
-
- ret = s.charAt(0); // ???
- break;
- default:
- throw new MessageFormatException("type conversion is invalid");
- } // switch
- } catch (EOFException e1) {
- throw new MessageEOFException("at end of message"); // I18N
- } catch (IOException e2) {
- JMSException jmsEx = new JMSException("IOException"); // I18N
-
- jmsEx.setLinkedException(e2);
- throw jmsEx;
- } // try .. catch
- return ret;
- } // readChar()
-
- /**
- * Read a 32-bit integer from the stream message.
- *
- * @return a 32-bit integer value from the stream message, interpreted as a
- * int.
- *
- * @exception JMSException
- * if JMS fails to read message due to some internal JMS error.
- * @exception MessageEOFException
- * if an end of message stream
- * @exception MessageFormatException
- * if this type conversion is invalid
- * @exception MessageNotReadableException
- * if message in write-only mode.
- */
- public int readInt() throws JMSException {
- int ret = 0;
- checkReadAccess();
-
- try {
- byte type = getType();
-
- switch (type) {
- case BYTE_TYPE:
- ret = dis.readByte();
- break;
- case SHORT_TYPE:
- ret = dis.readShort();
- break;
- case INT_TYPE:
- ret = dis.readInt();
- break;
- case STRING_TYPE:
- String s = dis.readUTF();
-
- ret = Integer.valueOf(s).intValue();
- break;
- default:
- throw new MessageFormatException("type conversion is invalid");
- } // switch
- } catch (EOFException e1) {
- throw new MessageEOFException("at end of message"); // I18N
- } catch (IOException e2) {
- JMSException jmsEx = new JMSException("IOException"); // I18N
-
- jmsEx.setLinkedException(e2);
- throw jmsEx;
- } // try .. catch
- return ret;
- } // readInt()
-
- /**
- * Read a 64-bit integer from the stream message.
- *
- * @return a 64-bit integer value from the stream message, interpreted as a
- * long.
- *
- * @exception JMSException
- * if JMS fails to read message due to some internal JMS error.
- * @exception MessageEOFException
- * if an end of message stream
- * @exception MessageFormatException
- * if this type conversion is invalid
- * @exception MessageNotReadableException
- * if message in write-only mode.
- */
- public long readLong() throws JMSException {
- long ret = 0;
- checkReadAccess();
-
- try {
- byte type = getType();
-
- switch (type) {
- case BYTE_TYPE:
- ret = dis.readByte();
- break;
- case SHORT_TYPE:
- ret = dis.readShort();
- break;
- case INT_TYPE:
- ret = dis.readInt();
- break;
- case LONG_TYPE:
- ret = dis.readLong();
- break;
- case STRING_TYPE:
- String s = dis.readUTF();
-
- ret = Long.valueOf(s).longValue();
- break;
- default:
- throw new MessageFormatException("type conversion is invalid");
- } // switch
- } catch (EOFException e1) {
- throw new MessageEOFException("at end of message"); // I18N
- } catch (IOException e2) {
- JMSException jmsEx = new JMSException("IOException"); // I18N
-
- jmsEx.setLinkedException(e2);
- throw jmsEx;
- } // try .. catch
- return ret;
- } // readLong()
-
- /**
- * Read a float from the stream message.
- *
- * @return a float value from the stream message.
- *
- * @exception JMSException
- * if JMS fails to read message due to some internal JMS error.
- * @exception MessageEOFException
- * if an end of message stream
- * @exception MessageFormatException
- * if this type conversion is invalid
- * @exception MessageNotReadableException
- * if message in write-only mode.
- */
- public float readFloat() throws JMSException {
- float ret = 0;
- checkReadAccess();
-
- try {
- byte type = getType();
-
- switch (type) {
- case FLOAT_TYPE:
- ret = dis.readFloat();
- break;
- case STRING_TYPE:
- String s = dis.readUTF();
-
- ret = Float.valueOf(s).floatValue();
- break;
- default:
- throw new MessageFormatException("type conversion is invalid");
- } // switch
- } catch (EOFException e1) {
- throw new MessageEOFException("at end of message"); // I18N
- } catch (IOException e2) {
- JMSException jmsEx = new JMSException("IOException"); // I18N
-
- jmsEx.setLinkedException(e2);
- throw jmsEx;
- } // try .. catch
- return ret;
- } // readFloat()
-
- /**
- * Read a double from the stream message.
- *
- * @return a double value from the stream message.
- *
- * @exception JMSException
- * if JMS fails to read message due to some internal JMS error.
- * @exception MessageEOFException
- * if an end of message stream
- * @exception MessageFormatException
- * if this type conversion is invalid
- * @exception MessageNotReadableException
- * if message in write-only mode.
- */
- public double readDouble() throws JMSException {
- double ret = 0;
- checkReadAccess();
-
- try {
- byte type = getType();
-
- switch (type) {
- case FLOAT_TYPE:
- ret = dis.readFloat();
- break;
- case DOUBLE_TYPE:
- ret = dis.readDouble();
- break;
- case STRING_TYPE:
- String s = dis.readUTF();
-
- ret = Double.valueOf(s).doubleValue();
- break;
- default:
- throw new MessageFormatException("type conversion is invalid");
- } // switch
- } catch (EOFException e1) {
- throw new MessageEOFException("at end of message"); // I18N
- } catch (IOException e2) {
- JMSException jmsEx = new JMSException("IOException"); // I18N
-
- jmsEx.setLinkedException(e2);
- throw jmsEx;
- } // try .. catch
- return ret;
- } // readDouble()
-
- /**
- * Read in a string from the stream message.
- *
- * @return a Unicode string from the stream message.
- *
- * @exception JMSException
- * if JMS fails to read message due to some internal JMS error.
- * @exception MessageEOFException
- * if an end of message stream
- * @exception MessageFormatException
- * if this type conversion is invalid
- * @exception MessageNotReadableException
- * if message in write-only mode.
- */
- public String readString() throws JMSException {
- String ret = null;
- checkReadAccess();
-
- try {
- byte type = getType();
-
- switch (type) {
- case BOOLEAN_TYPE:
- ret = String.valueOf(dis.readBoolean());
- break;
- case BYTE_TYPE:
- ret = String.valueOf(dis.readByte());
- break;
- case SHORT_TYPE:
- ret = String.valueOf(dis.readShort());
- break;
- case CHAR_TYPE:
- ret = String.valueOf(dis.readChar());
- break;
- case INT_TYPE:
- ret = String.valueOf(dis.readInt());
- break;
- case LONG_TYPE:
- ret = String.valueOf(dis.readLong());
- break;
- case FLOAT_TYPE:
- ret = String.valueOf(dis.readFloat());
- break;
- case DOUBLE_TYPE:
- ret = String.valueOf(dis.readDouble());
- break;
- case STRING_TYPE:
- ret = dis.readUTF();
- break;
- default:
- throw new MessageFormatException("type conversion is invalid");
- } // switch
- } catch (EOFException e1) {
- throw new MessageEOFException("at end of message"); // I18N
- } catch (IOException e2) {
- JMSException jmsEx = new JMSException("IOException"); // I18N
-
- jmsEx.setLinkedException(e2);
- throw jmsEx;
- } // try .. catch
- return ret;
- } // readString()
-
- /**
- * Read a byte array from the stream message.
- *
- * @param value
- * the buffer into which the data is read.
- *
- * @return the total number of bytes read into the buffer, or -1 if there is
- * no more data because the end of the stream has been reached.
- *
- * @exception JMSException
- * if JMS fails to read message due to some internal JMS error.
- * @exception MessageEOFException
- * if an end of message stream
- * @exception MessageFormatException
- * if this type conversion is invalid
- * @exception MessageNotReadableException
- * if message in write-only mode.
- */
- public int readBytes(byte[] value) throws JMSException {
- int ret = -1;
- checkReadAccess();
-
- try {
- byte type = BYTES_TYPE;
-
- // get the type and the length of this bytes array field
- // if this is the first time read this bytes array field
- if (first_time_readBytes) {
- type = getType();
- available_bytes = getBytesLength();
- }
- switch (type) {
- case BYTES_TYPE:
-
- // bytes array field is empty
- if (first_time_readBytes && available_bytes == 0) {
- return 0;
- } else if (!first_time_readBytes && available_bytes == 0) {
-
- /*
- * this is the case that last time readBytes() read exactly same bytes
- * left in the bytes array field, spec requires an extra readBytes(),
- * and return -1 ;-(
- */
- return -1;
- }
- if (value.length > available_bytes) {
-
- // read all! (available_bytes won't be zero.)
- ret = dis.read(value, 0, available_bytes);
- available_bytes = 0;
-
- // initiate first_time_readBytes to true for next field
- first_time_readBytes = true;
- } else if (value.length <= available_bytes) {
-
- // read all, but needs readBytes again
- ret = dis.read(value, 0, value.length);
- available_bytes = available_bytes - value.length;
- first_time_readBytes = false;
- }
- break;
- default:
- throw new MessageFormatException("type conversion is invalid");
- } // switch
- } catch (EOFException e1) {
- throw new MessageEOFException("at end of message"); // I18N
- } catch (IOException e2) {
- JMSException jmsEx = new JMSException("IOException"); // I18N
-
- jmsEx.setLinkedException(e2);
- throw jmsEx;
- } // try .. catch
- return ret;
- } // readBytes()
-
- /**
- * Read a Java object from the stream message.
- *
- *
- * Note that this method can be used to return in objectified format, an
- * object that had been written to the Stream with the equivalent
- * writeObject method call, or it's equivalent primitive
- * write method.
- *
- * @return a Java object from the stream message, in objectified format (ie.
- * if it set as an int, then a Integer is returned).
- *
- * @exception JMSException
- * if JMS fails to read message due to some internal JMS error.
- * @exception MessageEOFException
- * if an end of message stream
- * @exception MessageNotReadableException
- * if message in write-only mode.
- */
- public Object readObject() throws JMSException {
- Object ret = null;
- checkReadAccess();
-
- try {
- byte type = getType();
-
- switch (type) {
- case BOOLEAN_TYPE:
- ret = Boolean.valueOf(dis.readBoolean());
- break;
- case BYTE_TYPE:
- ret = Byte.valueOf(dis.readByte());
- break;
- case SHORT_TYPE:
- ret = Short.valueOf(dis.readShort());
- break;
- case CHAR_TYPE:
- ret = Character.valueOf(dis.readChar());
- break;
- case INT_TYPE:
- ret = Integer.valueOf(dis.readInt());
- break;
- case LONG_TYPE:
- ret = Long.valueOf(dis.readLong());
- break;
- case FLOAT_TYPE:
- ret = Float.valueOf(dis.readFloat());
- break;
- case DOUBLE_TYPE:
- ret = Double.valueOf(dis.readDouble());
- break;
- case STRING_TYPE:
- ret = dis.readUTF();
- break;
- default:
- throw new MessageFormatException("type conversion is invalid");
- } // switch
- } catch (EOFException e1) {
- throw new MessageEOFException("at end of message"); // I18N
- } catch (IOException e2) {
- JMSException jmsEx = new JMSException("IOException"); // I18N
-
- jmsEx.setLinkedException(e2);
- throw jmsEx;
- } // try .. catch
- return ret;
- } // readObject()
-
- /**
- * Write a boolean to the stream message. The value
- * true is written out as the value (byte)1; the
- * value false is written out as the value (byte)0.
- *
- * @param value
- * the boolean value to be written.
- *
- * @exception JMSException
- * if JMS fails to read message due to some internal JMS error.
- * @exception MessageNotWriteableException
- * if message in read-only mode.
- */
- public void writeBoolean(boolean value) throws JMSException {
- try {
- dos.writeByte((int) BOOLEAN_TYPE);
- dos.writeBoolean(value);
- setBufferIsDirty(true);
- } catch (IOException e) {
- JMSException jmsEx = new JMSException("IOException"); // I18N
-
- jmsEx.setLinkedException(e);
- throw jmsEx;
- } // try .. catch
- } // writeBoolean()
-
- /**
- * Write out a byte to the stream message.
- *
- * @param value
- * the byte value to be written.
- * @exception JMSException
- * if JMS fails to write message due to some internal JMS error.
- * @exception MessageNotWriteableException
- * if message in read-only mode.
- */
- public void writeByte(byte value) throws JMSException {
- try {
- dos.writeByte((int) BYTE_TYPE);
- dos.writeByte((int) value);
- setBufferIsDirty(true);
- } catch (IOException e) {
- JMSException jmsEx = new JMSException("IOException"); // I18N
-
- jmsEx.setLinkedException(e);
- throw jmsEx;
- } // try .. catch
- } // writeByte()
-
- /**
- * Write a short to the stream message.
- *
- * @param value
- * the short to be written.
- *
- * @exception JMSException
- * if JMS fails to write message due to some internal JMS error.
- * @exception MessageNotWriteableException
- * if message in read-only mode.
- */
- public void writeShort(short value) throws JMSException {
- try {
- dos.writeByte((int) SHORT_TYPE);
- dos.writeShort((int) value);
- setBufferIsDirty(true);
- } catch (IOException e) {
- JMSException jmsEx = new JMSException("IOException"); // I18N
-
- jmsEx.setLinkedException(e);
- throw jmsEx;
- } // try .. catch
- } // writeShort()
-
- /**
- * Write a char to the stream message.
- *
- * @param value
- * the char value to be written.
- *
- * @exception JMSException
- * if JMS fails to write message due to some internal JMS error.
- * @exception MessageNotWriteableException
- * if message in read-only mode.
- */
- public void writeChar(char value) throws JMSException {
- try {
- dos.writeByte((int) CHAR_TYPE);
- dos.writeChar((int) value);
- setBufferIsDirty(true);
- } catch (IOException e) {
- JMSException jmsEx = new JMSException("IOException"); // I18N
-
- jmsEx.setLinkedException(e);
- throw jmsEx;
- } // try .. catch
- } // writeChar()
-
- /**
- * Write an int to the stream message.
- *
- * @param value
- * the int to be written.
- *
- * @exception JMSException
- * if JMS fails to write message due to some internal JMS error.
- * @exception MessageNotWriteableException
- * if message in read-only mode.
- */
- public void writeInt(int value) throws JMSException {
- try {
- dos.writeByte((int) INT_TYPE);
- dos.writeInt(value);
- setBufferIsDirty(true);
- } catch (IOException e) {
- JMSException jmsEx = new JMSException("IOException"); // I18N
-
- jmsEx.setLinkedException(e);
- throw jmsEx;
- } // try .. catch
- } // writeInt()
-
- /**
- * Write a long to the stream message.
- *
- * @param value
- * the long to be written.
- *
- * @exception JMSException
- * if JMS fails to write message due to some internal JMS error.
- * @exception MessageNotWriteableException
- * if message in read-only mode.
- */
- public void writeLong(long value) throws JMSException {
- try {
- dos.writeByte((int) LONG_TYPE);
- dos.writeLong(value);
- setBufferIsDirty(true);
- } catch (IOException e) {
- JMSException jmsEx = new JMSException("IOException"); // I18N
-
- jmsEx.setLinkedException(e);
- throw jmsEx;
- } // try .. catch
- } // writeLong()
-
- /**
- * Write a float to the stream message.
- *
- * @param value
- * the float value to be written.
- *
- * @exception JMSException
- * if JMS fails to write message due to some internal JMS error.
- * @exception MessageNotWriteableException
- * if message in read-only mode.
- */
- public void writeFloat(float value) throws JMSException {
- try {
- dos.writeByte((int) FLOAT_TYPE);
- dos.writeFloat(value);
- setBufferIsDirty(true);
- } catch (IOException e) {
- JMSException jmsEx = new JMSException("IOException"); // I18N
-
- jmsEx.setLinkedException(e);
- throw jmsEx;
- } // try .. catch
- } // writeFloat()
-
- /**
- * Write a double to the stream message.
- *
- * @param value
- * the double value to be written.
- *
- * @exception JMSException
- * if JMS fails to write message due to some internal JMS error.
- * @exception MessageNotWriteableException
- * if message in read-only mode.
- */
- public void writeDouble(double value) throws JMSException {
- try {
- dos.writeByte((int) DOUBLE_TYPE);
- dos.writeDouble(value);
- setBufferIsDirty(true);
- } catch (IOException e) {
- JMSException jmsEx = new JMSException("IOException"); // I18N
-
- jmsEx.setLinkedException(e);
- throw jmsEx;
- } // try .. catch
- } // writeDouble()
-
- /**
- * Write a string to the stream message.
- *
- * @param value
- * the String value to be written.
- *
- * @exception JMSException
- * if JMS fails to write message due to some internal JMS error.
- * @exception MessageNotWriteableException
- * if message in read-only mode.
- */
- public void writeString(String value) throws JMSException {
- try {
- dos.writeByte((int) STRING_TYPE);
- dos.writeUTF(value);
- setBufferIsDirty(true);
- } catch (IOException e) {
- JMSException jmsEx = new JMSException("IOException"); // I18N
-
- jmsEx.setLinkedException(e);
- throw jmsEx;
- } // try .. catch
- } // writeString()
-
- /**
- * Write a byte array to the stream message.
- *
- * @param value
- * the byte array to be written.
- *
- * @exception JMSException
- * if JMS fails to write message due to some internal JMS error.
- * @exception MessageNotWriteableException
- * if message in read-only mode.
- */
- public void writeBytes(byte[] value) throws JMSException {
- writeBytes(value, 0, value.length);
- } // writeBytes()
-
- /**
- * Write a portion of a byte array to the stream message.
- *
- * @param value
- * the byte array value to be written.
- * @param offset
- * the initial offset within the byte array.
- * @param length
- * the number of bytes to use.
- *
- * @exception JMSException
- * if JMS fails to write message due to some internal JMS error.
- * @exception MessageNotWriteableException
- * if message in read-only mode.
- */
- public void writeBytes(byte[] value, int offset, int length)
- throws JMSException {
-
- /*
- * bytes array field format as following: TYPE LENGTH DATA
- */
- try {
- dos.writeByte((int) BYTES_TYPE);
- dos.writeInt(length);
- dos.write(value, offset, length);
- setBufferIsDirty(true);
- } catch (IOException e) {
- JMSException jmsEx = new JMSException("IOException"); // I18N
-
- jmsEx.setLinkedException(e);
- throw jmsEx;
- } // try .. catch
- } // writeBytes()
-
- /**
- * Write a Java object to the stream message.
- *
- *
- * Note that this method only works for the objectified primitive object types
- * (Integer, Double, Long ...), String's and byte arrays.
- *
- * @param value
- * the Java object to be written.
- *
- * @exception JMSException
- * if JMS fails to write message due to some internal JMS error.
- * @exception MessageNotWriteableException
- * if message in read-only mode.
- * @exception MessageFormatException
- * if the object is invalid
- */
- public void writeObject(Object value) throws JMSException {
- if (value instanceof Boolean) {
- writeBoolean(((Boolean) value).booleanValue());
- } else if (value instanceof Byte) {
- writeByte(((Byte) value).byteValue());
- } else if (value instanceof Character) {
- writeChar(((Character) value).charValue());
- } else if (value instanceof Double) {
- writeDouble(((Double) value).doubleValue());
- } else if (value instanceof Float) {
- writeFloat(((Float) value).floatValue());
- } else if (value instanceof Integer) {
- writeInt(((Integer) value).intValue());
- } else if (value instanceof Long) {
- writeLong(((Long) value).longValue());
- } else if (value instanceof Short) {
- writeShort(((Short) value).shortValue());
- } else if (value instanceof String) {
- writeString((String) value);
- } else if (value instanceof byte[]) {
- writeBytes((byte[]) value);
- } else {
- throw new MessageFormatException("Invalid type"); // I18N
- } // if .. else
- } // writeObject()
-
- /**
- * Put the message in read-only mode, and reposition the stream to the
- * beginning.
- *
- * @exception JMSException
- * if JMS fails to reset the message due to some internal JMS
- * error.
- * @exception MessageFormatException
- * if message has an invalid format
- */
- public void reset() throws JMSException {
-
- // forces any buffered output bytes to be written out to the stream
- // not really needed in this case, because the underlying output stream
- // is a ByteArrayOutputStream
- try {
- if (bufferIsDirty) {
- dos.flush();
- dos.close();
- baos.close();
- }
- } catch (IOException e) {
- JMSException jmsEx = new JMSException("IOException"); // I18N
-
- jmsEx.setLinkedException(e);
- throw jmsEx;
- } // try .. catch
- if (baos != null) {
-
- // copy the content of DataOutputStream dos to buf
- buf = baos.toByteArray();
-
- } else {
- if (buf == null) {
- buf = new byte[0];
- }
- }
- bais = new ByteArrayInputStream(buf);
- dis = new DataInputStream(bais);
-
- // initiate first_time_readBytes to true for readBytes()
- first_time_readBytes = true;
- setBufferIsDirty(false);
- readMode = true;
- } // reset()
-
- // overwrite methods in MessageImpl
-
- /**
- * Method Declaration.
- *
- *
- * @exception JMSException
- *
- * @see
- */
- public void clearBody() throws JMSException {
- buf = null;
- bais = null;
- dis = null;
- readMode = false;
- } // clearBody()
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/jms/common/TestMessageListener.java b/common/src/main/java/com/sun/ts/tests/jms/common/TestMessageListener.java
deleted file mode 100644
index 141ca2f0ea..0000000000
--- a/common/src/main/java/com/sun/ts/tests/jms/common/TestMessageListener.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * @(#)TestMessageListener.java 1.11 03/05/16
- */
-package com.sun.ts.tests.jms.common;
-
-import java.util.ArrayList;
-
-import com.sun.ts.lib.util.TestUtil;
-
-import jakarta.jms.Message;
-import jakarta.jms.MessageConsumer;
-import jakarta.jms.TextMessage;
-
-/**
- * Message Listener implementation for JMS testing
- */
-public class TestMessageListener implements jakarta.jms.MessageListener {
- public MessageConsumer mConsumer;
-
- public DoneLatch monitor;
-
- public ArrayList messageArray = new ArrayList();
-
- /**
- * Constructor takes a MessageConsumer argument
- *
- * @param MessageConsumer
- */
- public TestMessageListener(MessageConsumer mc, DoneLatch dl) {
- mConsumer = mc;
- monitor = dl;
- }
-
- /**
- * Returns the list of messages received.
- *
- * @return ArrayList the list of Messages that have been received
- */
- public ArrayList getMessageArray() {
- return messageArray;
- }
-
- /**
- * Clears the list of messages received.
- *
- */
- public DoneLatch getLatch() {
- return monitor;
- }
-
- /**
- * Clears the list of messages received.
- *
- */
- public void clearMessageArray() {
- messageArray.clear();
- }
-
- /**
- * Responds to incoming Messages. A TextMessage is the end of stream signal.
- *
- * @param Message
- * the message passed to the listener
- */
- public void onMessage(Message message) {
- try {
- TestUtil.logTrace("MessageListener for " + mConsumer.toString()
- + " received message: " + message.toString());
- messageArray.add(message);
- } catch (Exception e) {
- TestUtil.logErr("Error in MessageListener: " + e.toString(), e);
- }
- if (message instanceof TextMessage) {
- monitor.allDone();
- }
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/jms/commonee/Client.java b/common/src/main/java/com/sun/ts/tests/jms/commonee/Client.java
deleted file mode 100644
index 3b51d1eec7..0000000000
--- a/common/src/main/java/com/sun/ts/tests/jms/commonee/Client.java
+++ /dev/null
@@ -1,355 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id: Client.java 59995 2009-10-14 12:05:29Z af70133 $
- */
-
-package com.sun.ts.tests.jms.commonee;
-
-import java.util.Enumeration;
-import java.util.Properties;
-
-import com.sun.ts.lib.harness.EETest;
-import com.sun.ts.lib.util.TSNamingContext;
-import com.sun.ts.lib.util.TSNamingContextInterface;
-import com.sun.ts.lib.util.TestUtil;
-
-import jakarta.jms.BytesMessage;
-import jakarta.jms.JMSException;
-import jakarta.jms.MapMessage;
-import jakarta.jms.Message;
-import jakarta.jms.ObjectMessage;
-import jakarta.jms.Queue;
-import jakarta.jms.QueueConnection;
-import jakarta.jms.QueueConnectionFactory;
-import jakarta.jms.QueueReceiver;
-import jakarta.jms.QueueSender;
-import jakarta.jms.QueueSession;
-import jakarta.jms.Session;
-import jakarta.jms.StreamMessage;
-import jakarta.jms.TextMessage;
-import jakarta.jms.TopicConnection;
-import jakarta.jms.TopicConnectionFactory;
-import jakarta.jms.TopicPublisher;
-import jakarta.jms.TopicSession;
-
-public class Client extends EETest {
-
- // Naming specific member variables
- protected TSNamingContextInterface context = null;
-
- protected Properties props = null;
-
- protected Queue rcvrQueue;
-
- protected QueueConnection qConnect;
-
- protected QueueSession session;
-
- protected QueueConnectionFactory qFactory;
-
- protected QueueSender qSender;
-
- protected TopicConnection tConnect;
-
- protected TopicSession tSession;
-
- protected TopicConnectionFactory tFactory;
-
- protected TopicPublisher tPub;
-
- protected String jmsUser = null;
-
- protected String jmsPassword = null;
-
- protected String hostname = null;
-
- protected String traceFlag = null;
-
- protected String logPort = null;
-
- protected TextMessage msg = null;
-
- // get this from ts.jte
- protected long timeout = 0;
-
- /*
- * @class.setup_props:
- *
- * jms_timeout; user; password; harness.log.traceflag; harness.log.port;
- * generateSQL;
- *
- * @class.testArgs: -ap tssql.stmt
- *
- *
- */
- public void setup(String[] args, Properties p) throws Exception {
- props = p;
-
- try {
- jmsUser = TestUtil.getProperty(p, "user");
- if (jmsUser == null) {
- TestUtil.logTrace("user is null");
- throw new Exception("Error getting user");
- }
-
- jmsPassword = TestUtil.getProperty(p, "password");
- if (jmsPassword == null) {
- TestUtil.logTrace("password is null");
- throw new Exception("Error getting password");
- }
-
- String time = TestUtil.getProperty(p, "jms_timeout");
- if (time == null) {
- TestUtil.logTrace("jms_timeout is null");
- throw new Exception("Error getting jms_timeout");
- }
-
- hostname = TestUtil.getProperty(p, "harness.host");
- if (hostname == null) {
- TestUtil.logTrace("harness.host is null");
- throw new Exception("Error getting harness.host");
- }
- traceFlag = TestUtil.getProperty(p, "harness.log.traceflag");
- if (traceFlag == null) {
- TestUtil.logTrace("harness.log.traceflag is null");
- throw new Exception("Error getting harness.log.traceflag");
- }
- logPort = TestUtil.getProperty(p, "harness.log.port");
- if (logPort == null) {
- TestUtil.logTrace("harness.log.port is null");
- throw new Exception("Error getting harness.log.port");
- }
-
- timeout = Long.parseLong(time);
-
- TestUtil.logTrace("in client setup");
-
- context = new TSNamingContext();
- TestUtil.logTrace("Client: Do lookups!");
-
- rcvrQueue = (Queue) context.lookup("java:comp/env/jms/MDB_QUEUE_REPLY");
-
- qFactory = (QueueConnectionFactory) context
- .lookup("java:comp/env/jms/MyQueueConnectionFactory");
- qConnect = qFactory.createQueueConnection(jmsUser, jmsPassword);
- session = qConnect.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
- qConnect.start();
-
- tFactory = (TopicConnectionFactory) context
- .lookup("java:comp/env/jms/MyTopicConnectionFactory");
- tConnect = tFactory.createTopicConnection(jmsUser, jmsPassword);
- tSession = tConnect.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
- tConnect.start();
-
- TestUtil.logTrace("get the connection and starter up");
- TestUtil
- .logTrace("Client: connection started, now send initialization msg!");
-
- } catch (Exception e) {
- throw new Exception("Setup Failed!", e);
- }
- }
-
- protected void createTestMessage(String TestCase, int num) {
- String myMessage = "MDB deploy tests";
- Enumeration e;
- String key = null;
- String notValid = ".";
- try {
- msg = session.createTextMessage();
- e = props.propertyNames();
- // we need to extract the properties passed from the harness
- // and set them in the message properties
- // This is so we can send them to the mdb
- msg.setStringProperty("user", jmsUser);
- msg.setStringProperty("password", jmsPassword);
- msg.setStringProperty("harnesshost", hostname);
- msg.setStringProperty("harnesslogtraceflag", traceFlag);
- msg.setStringProperty("harnesslogport", logPort);
- e = props.propertyNames();
- key = null;
- while (e.hasMoreElements()) {
- key = (String) e.nextElement();
- if ((key.indexOf(notValid) == -1) && (key.indexOf("***") == -1)) {
- String value = TestUtil.getProperty(props, key);
- msg.setStringProperty(key, value);
- }
- }
-
- msg.setText(myMessage);
- msg.setIntProperty("TestCaseNum", num);
- msg.setStringProperty("COM_SUN_JMS_TESTNAME", TestCase);
-
- } catch (Exception ee) {
- TestUtil.printStackTrace(ee);
- TestUtil.logMsg("key was: " + key);
- TestUtil.logMsg("props was: " + props.getProperty(key));
- TestUtil.logMsg("Error setting properties");
- }
- }
-
- public boolean checkOnResponse(String TestCase) {
- boolean status = false;
- try {
- TestUtil.logMsg("@checkOnResponse");
- status = recvMessageInternal(session, TestCase);
- TestUtil.logMsg("Close the session");
- } catch (Exception e) {
- TestUtil.printStackTrace(e);
- }
- return status;
- }
-
- protected boolean recvMessageInternal(QueueSession session, String TestCase)
- throws JMSException {
- boolean retcode = false;
- TestUtil.logMsg("@recvMessageInternal");
- // Create a message consumer.
- QueueReceiver rcvr = session.createReceiver(rcvrQueue);
- // dequeue the response from the mdb
- Message msgRec = null;
-
- for (int i = 0; i < 10; ++i) {
- TestUtil
- .logMsg("@recvMessageInternal trying to receive the message: " + i);
- msgRec = rcvr.receive(timeout);
- if (msgRec != null) {
- break;
- }
- } // end for loop
- if (msgRec != null) {
- if (msgRec instanceof TextMessage) {
- TestUtil.logMsg("**** Received msg text = "
- + ((TextMessage) msgRec).getText() + " ****");
- }
- TestUtil.logMsg("**** Received msg getStringProperty('TestCase') = "
- + msgRec.getStringProperty("TestCase"));
- TestUtil.logMsg("**** Received msg getStringProperty('Status') = "
- + msgRec.getStringProperty("Status"));
- if (msgRec.getStringProperty("TestCase") == null
- || msgRec.getStringProperty("Status") == null) {
- TestUtil.logMsg(
- "Fail: unexpected message received from MDB_QUEUE_REPLY msgRec="
- + msgRec);
- } else if (msgRec.getStringProperty("TestCase").equals(TestCase)
- && msgRec.getStringProperty("Status").equals("Pass")) {
- TestUtil.logMsg("TestCase: " + msgRec.getStringProperty("TestCase"));
- TestUtil
- .logMsg("Status from msg: " + msgRec.getStringProperty("Status"));
- TestUtil.logMsg("Pass: we got the expected msg back! ");
- retcode = true;
- } else if (msgRec.getStringProperty("Status").equals("Fail")) {
- TestUtil.logMsg("TestCase: " + msgRec.getStringProperty("TestCase"));
- TestUtil
- .logMsg("Status from msg: " + msgRec.getStringProperty("Status"));
- TestUtil.logMsg("Fail: Error(s) occurred! ");
- } else {
- TestUtil.logMsg("Fail: we didnt get the expected msg back! ");
- TestUtil.logMsg("TestCase: " + msgRec.getStringProperty("TestCase"));
- }
- } else if (msgRec == null) {
- TestUtil.logMsg("Fail: we didnt get any msg back! ");
- }
- return retcode;
- }
-
- public void cleanup() throws Exception {
- try {
- closeDefaultConnections();
- flushQueue();
- } catch (Exception e) {
- TestUtil.logErr("Cleanup error: " + e.toString());
- TestUtil.printStackTrace(e);
- }
- }
-
- /**
- * Use this method at cleanup time to remove any messages that have remained
- * on the queue.
- *
- */
-
- public void flushQueue() throws Exception {
- QueueConnection qc = null;
- QueueReceiver qr = null;
- QueueSession qs = null;
- int numMsgsFlushed = 0;
- try {
- qc = qFactory.createQueueConnection(jmsUser, jmsPassword);
- qs = qc.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
- qc.start(); // start the connections so that messages may be received.
-
- qr = qs.createReceiver(rcvrQueue);
- // flush the queue
- Message msg = qr.receive(timeout);
- while (msg != null) {
- if (msg instanceof TextMessage) {
- TestUtil.logMsg("**** Flushed TextMessage ="
- + ((TextMessage) msg).getText() + " ****");
- } else {
- String msgType = "Message";
- if (msg instanceof BytesMessage)
- msgType = "BytesMessage";
- else if (msg instanceof MapMessage)
- msgType = "MapMessage";
- else if (msg instanceof ObjectMessage)
- msgType = "ObjectMessage";
- else if (msg instanceof StreamMessage)
- msgType = "StreamMessage";
- TestUtil.logMsg("**** Flushed Message of type " + msgType + " ****");
- }
- numMsgsFlushed++;
- msg = qr.receiveNoWait();
- }
- if (numMsgsFlushed > 0) {
- TestUtil.logMsg("flushed " + numMsgsFlushed + " messages");
- }
-
- } catch (Exception e) {
- TestUtil
- .logErr("Cleanup error attempting to flush Queue: " + e.toString());
- TestUtil.printStackTrace(e);
- } finally {
- qc.close();
- }
- }
-
- /**
- * Close default connections if open
- *
- * @exception Exception
- *
- * @see
- */
- public void closeDefaultConnections() throws Exception {
- try {
- if (qConnect != null) {
- TestUtil.logMsg("Client: Closing QueueConnection");
- qConnect.close();
- }
- if (tConnect != null) {
- TestUtil.logMsg("Client: Closing TopicConnection");
- tConnect.close();
- }
- } catch (Exception e) {
- TestUtil.logErr("Cleanup error: " + e.toString());
- TestUtil.printStackTrace(e);
-
- }
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/jms/commonee/MDB_Q_TestEJB.java b/common/src/main/java/com/sun/ts/tests/jms/commonee/MDB_Q_TestEJB.java
deleted file mode 100644
index 8baedc1720..0000000000
--- a/common/src/main/java/com/sun/ts/tests/jms/commonee/MDB_Q_TestEJB.java
+++ /dev/null
@@ -1,393 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id: MDB_Q_TestEJB.java 59995 2009-10-14 12:05:29Z af70133 $
- */
-package com.sun.ts.tests.jms.commonee;
-
-import java.util.Enumeration;
-import java.util.Properties;
-
-import com.sun.ts.lib.util.TSNamingContext;
-import com.sun.ts.lib.util.TestUtil;
-
-import com.sun.ts.tests.jms.common.JmsUtil;
-import jakarta.annotation.Resource;
-import jakarta.ejb.EJBException;
-import jakarta.ejb.PostActivate;
-import jakarta.ejb.PrePassivate;
-import jakarta.ejb.Remote;
-import jakarta.ejb.Remove;
-import jakarta.ejb.SessionContext;
-import jakarta.ejb.Stateful;
-import jakarta.jms.JMSException;
-import jakarta.jms.Message;
-import jakarta.jms.Queue;
-import jakarta.jms.QueueBrowser;
-import jakarta.jms.QueueConnection;
-import jakarta.jms.QueueConnectionFactory;
-import jakarta.jms.QueueReceiver;
-import jakarta.jms.QueueSender;
-import jakarta.jms.QueueSession;
-import jakarta.jms.TextMessage;
-
-@Stateful
-@Remote(MDB_Q_Test.class)
-public class MDB_Q_TestEJB implements MDB_Q_Test {
-
- @Resource
- private SessionContext sessionContext;
-
- private Properties p = null;
-
- @Resource(name = "jms/MDB_QUEUE_REPLY")
- private transient Queue rcvrQueue;
-
- @Resource(name = "jms/MDB_QUEUE")
- private transient Queue q;
-
- @Resource(name = "jms/MyQueueConnectionFactory")
- private transient QueueConnectionFactory qFactory;
-
- private transient QueueConnection qConnect;
-
- private String jmsUser;
-
- private String jmsPassword;
-
- private long timeout;
-
- public MDB_Q_TestEJB() {
- }
-
- public void setup(Properties props) {
- TestUtil.logTrace("MDB_Q_TestEJB.setup()");
- p = props;
- try {
- TestUtil.init(props);
- // get props
- timeout = Long.parseLong(TestUtil.getProperty(props, "jms_timeout"));
- jmsUser = TestUtil.getProperty(props, "user");
- jmsPassword = TestUtil.getProperty(props, "password");
- // check props for errors
- if (timeout < 1) {
- throw new Exception(
- "'jms_timeout' (milliseconds) in ts.jte must be > 0");
- }
- if (jmsUser == null) {
- throw new Exception("'user' in ts.jte must be null");
- }
- if (jmsPassword == null) {
- throw new Exception("'password' in ts.jte must be null");
- }
- if (qFactory == null || q == null | rcvrQueue == null
- || sessionContext == null) {
- throw new Exception("@Resource injection failed");
- }
- } catch (Exception e) {
- throw new EJBException("@setup failed: ", e);
- }
- }
-
- public boolean askMDBToRunATest(String typeOfTest) {
- TestUtil.logTrace("MDB_Q_TestEJB.askMDBToRunATest()");
- boolean ok = true;
- String myMessage = "Sending a message to mdb";
-
- try {
- qConnect = qFactory.createQueueConnection(jmsUser, jmsPassword);
- QueueSession session = qConnect.createQueueSession(true, 0);
- qConnect.start();
- QueueSender qSender = session.createSender(q);
-
- // create a text message
- TextMessage msg = session.createTextMessage();
- JmsUtil.addPropsToMessage(msg, p);
- msg.setText(myMessage);
- msg.setStringProperty("TestCase", typeOfTest);
-
- qSender.send(msg);
-
- } catch (Exception e) {
- TestUtil.printStackTrace(e);
- throw new EJBException("askMDBToRunATest: Error!", e);
- } finally {
- try {
- if (qConnect != null) {
- qConnect.close();
- }
- } catch (Exception e) {
- TestUtil.logErr("Error closing QueueConnection", e);
- }
- }
- return ok;
- }
-
- public boolean askMDBToSendAMessage(String typeOfMessage) {
- TestUtil.logTrace("MDB_Q_TestEJB.askMDBToSendAMessage()");
- boolean ok = true;
- String myMessage = "I want you to send a message";
-
- try {
- qConnect = qFactory.createQueueConnection(jmsUser, jmsPassword);
- QueueSession session = qConnect.createQueueSession(true, 0);
- qConnect.start();
-
- QueueSender qSender = session.createSender(q);
- TestUtil
- .logTrace("got a q sender for: " + qSender.getQueue().getQueueName());
-
- // create a text message
- TextMessage msg = session.createTextMessage();
- JmsUtil.addPropsToMessage(msg, p);
- msg.setText(myMessage);
- msg.setStringProperty("MessageType", typeOfMessage);
-
- qSender.send(msg);
- } catch (Exception e) {
- TestUtil.printStackTrace(e);
- throw new EJBException("@askMDBToSendAMessage: Error!", e);
- } finally {
- try {
- if (qConnect != null) {
- qConnect.close();
- }
- } catch (Exception e) {
- TestUtil.logErr("Error closing connection in askMDBToSendAMessage", e);
- }
- }
- return ok;
- }
-
- // Validate that a given message was sent by mdb
- // prop = validate string
- //
- public boolean checkOnResponse(String prop) {
-
- boolean status = false;
- try {
- TestUtil.logTrace("MDB_Q_TestEJB.checkOnResponse()");
- qConnect = qFactory.createQueueConnection(jmsUser, jmsPassword);
- QueueSession session = qConnect.createQueueSession(true, 0);
- qConnect.start();
- status = recvMessageInternal(session, prop);
- TestUtil.logTrace("Close the session");
- session.close();
- } catch (Exception e) {
- TestUtil.logErr("Error in checkOnResponse", e);
- } finally {
- try {
- if (qConnect != null) {
- qConnect.close();
- }
- } catch (Exception e) {
- TestUtil.logErr("Error closing QueueConnection", e);
- }
- }
- return status;
- }
-
- private boolean recvMessageInternal(QueueSession session, String prop)
- throws JMSException {
- boolean retcode = false;
- TestUtil.logTrace("MDB_Q_TestEJB.recvMessageInternal()");
- // Create a message producer.
- QueueReceiver rcvr = session.createReceiver(rcvrQueue);
- // dequeue the response from the mdb
- Message msgRec = null;
-
- for (int i = 0; i < 10; ++i) {
- TestUtil
- .logTrace("@recvMessageInternal trying to receive the message: " + i);
- msgRec = rcvr.receive(timeout);
- if (msgRec != null) {
- break;
- }
- } // end for loop
-
- if (msgRec != null) {
- if ((msgRec.getStringProperty("TestCase") != null)
- || (msgRec.getStringProperty("Status") != null)) {
- if (msgRec.getStringProperty("TestCase").equals(prop)
- && msgRec.getStringProperty("Status").equals("Pass")) {
- TestUtil
- .logTrace("TestCase: " + msgRec.getStringProperty("TestCase"));
- TestUtil.logTrace(
- "Status from msg: " + msgRec.getStringProperty("Status"));
- TestUtil.logTrace("Pass: we got the expected msg back! ");
- retcode = true;
-
- } else if (msgRec.getStringProperty("Status").equals("Fail")) {
- TestUtil
- .logTrace("TestCase: " + msgRec.getStringProperty("TestCase"));
- TestUtil.logTrace(
- "Status from msg: " + msgRec.getStringProperty("Status"));
- TestUtil.logTrace("Fail: Error(s) occurred! ");
- } else {
- TestUtil.logTrace("Fail: we didnt get the expected msg back! ");
- TestUtil
- .logTrace("TestCase: " + msgRec.getStringProperty("TestCase"));
- }
- } else if (msgRec.getStringProperty("MessageType") != null) {
- if (msgRec.getStringProperty("MessageType").equals(prop)) {
- TestUtil.logTrace("Success: received Msg from Q! "
- + msgRec.getStringProperty("MessageType"));
- TestUtil.logTrace("Pass: we got the expected msg back! ");
- retcode = true;
-
- } else {
- TestUtil.logTrace("Fail: we didnt get the expected msg back! ");
- TestUtil.logTrace(
- "MessageType: " + msgRec.getStringProperty("MessageType"));
- }
- } else {
- TestUtil.logTrace("Fail: we didnt get the expected msg back! ");
- }
- } else {
- TestUtil.logTrace("Fail: we didnt get any msg back! ");
- }
- return retcode;
- }
-
- public boolean isThereSomethingInTheQueue() {
- TestUtil.logTrace("MDB_Q_TestEJB.isThereSomethingInTheQueue()");
- QueueBrowser qBrowser = null;
- Enumeration msgs = null;
- boolean ret = false;
-
- try {
- // Hopefully nothing is left in the queue
- qConnect = qFactory.createQueueConnection(jmsUser, jmsPassword);
- QueueSession session = qConnect.createQueueSession(true, 0);
- qConnect.start();
- qBrowser = session.createBrowser(rcvrQueue);
- msgs = qBrowser.getEnumeration();
- if (msgs.hasMoreElements()) {
- ret = true;
- }
- qBrowser.close();
- session.close();
-
- } catch (Exception e) {
- TestUtil.logErr("Error in isThereSomethingInTheQueue", e);
- } finally {
- try {
- if (qConnect != null) {
- qConnect.close();
- }
- } catch (Exception e) {
- TestUtil.logErr("Error closing QueueConnection", e);
- }
- }
- return ret;
- }
-
- public void cleanTheQueue() {
- TestUtil.logTrace("MDB_Q_TestEJB.cleanTheQueue()");
- QueueBrowser qBrowser = null;
- Enumeration msgs = null;
- int numMsgs = 0;
-
- try {
- qConnect = qFactory.createQueueConnection(jmsUser, jmsPassword);
- QueueSession session = qConnect.createQueueSession(true, 0);
- qConnect.start();
- TextMessage msgRec = null;
-
- // delete anything left in the queue
- qBrowser = session.createBrowser(rcvrQueue);
- // count the number of messages
- msgs = qBrowser.getEnumeration();
- while (msgs.hasMoreElements()) {
- msgs.nextElement();
- numMsgs++;
- }
- qBrowser.close();
-
- // Read messages until Q is cleaned
- QueueReceiver rcvr = session.createReceiver(rcvrQueue);
- TestUtil.logTrace("Cleaning " + numMsgs + " messages from the Q: "
- + rcvrQueue.getQueueName());
- for (int n = 0; n < numMsgs; n++) {
- //
- TestUtil.logTrace(
- "dequeuing msg: " + n + " from the Q: " + rcvrQueue.getQueueName());
- for (int i = 0; i < 10; ++i) {
- msgRec = (TextMessage) rcvr.receive(timeout);
- if (msgRec != null) {
- TestUtil.logTrace("dequeued message: " + n);
- break;
- }
- TestUtil.logTrace(
- "Attempt no: " + i + " Trying to dequeue message: " + n);
- } // end of internal for loop
- }
- session.close();
- } catch (Exception e) {
- TestUtil.logErr("Error in cleanTheQueue", e);
- } finally {
- try {
- if (qConnect != null) {
- qConnect.close();
- }
- } catch (Exception e) {
- TestUtil.logErr("Error closing QueueConnection", e);
- }
- }
- }
-
- @Remove
- public void remove() {
- TestUtil.logTrace("MDB_Q_TestEJB.remove()");
- }
-
- @PostActivate
- public void activate() {
- TestUtil.logTrace("MDB_Q_TestEJB.activate()");
-
- try {
- TSNamingContext context = new TSNamingContext();
- TestUtil.logTrace("got the context");
-
- rcvrQueue = (Queue) context.lookup("java:comp/env/jms/MDB_QUEUE_REPLY");
- q = (Queue) context.lookup("java:comp/env/jms/MDB_QUEUE");
- qFactory = (QueueConnectionFactory) context
- .lookup("java:comp/env/jms/MyQueueConnectionFactory");
- } catch (Exception e) {
- TestUtil.logErr("Error looking up Queue, QueueConnectionFactory objects",
- e);
- throw new EJBException("@activate: Error!", e);
- }
- }
-
- @PrePassivate
- public void passivate() {
- TestUtil.logTrace("MDB_Q_TestEJB.passivate()");
-
- if (qConnect != null) {
- try {
- qConnect.close();
- } catch (Exception e) {
- TestUtil.logErr("Error closing QueueConnection", e);
- }
- qConnect = null;
- }
- rcvrQueue = null;
- q = null;
- qFactory = null;
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/jms/commonee/MDB_T_TestEJB.java b/common/src/main/java/com/sun/ts/tests/jms/commonee/MDB_T_TestEJB.java
deleted file mode 100644
index 853467a7e6..0000000000
--- a/common/src/main/java/com/sun/ts/tests/jms/commonee/MDB_T_TestEJB.java
+++ /dev/null
@@ -1,411 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id: MDB_T_TestEJB.java 59995 2009-10-14 12:05:29Z af70133 $
- */
-package com.sun.ts.tests.jms.commonee;
-
-import java.util.Enumeration;
-import java.util.Properties;
-
-import com.sun.ts.lib.util.TSNamingContext;
-import com.sun.ts.lib.util.TestUtil;
-import com.sun.ts.tests.jms.common.JmsUtil;
-import jakarta.annotation.Resource;
-import jakarta.ejb.EJBException;
-import jakarta.ejb.PostActivate;
-import jakarta.ejb.PrePassivate;
-import jakarta.ejb.Remote;
-import jakarta.ejb.Remove;
-import jakarta.ejb.SessionContext;
-import jakarta.ejb.Stateful;
-import jakarta.jms.JMSException;
-import jakarta.jms.Message;
-import jakarta.jms.Queue;
-import jakarta.jms.QueueBrowser;
-import jakarta.jms.QueueConnection;
-import jakarta.jms.QueueConnectionFactory;
-import jakarta.jms.QueueReceiver;
-import jakarta.jms.QueueSession;
-import jakarta.jms.TextMessage;
-import jakarta.jms.Topic;
-import jakarta.jms.TopicConnection;
-import jakarta.jms.TopicConnectionFactory;
-import jakarta.jms.TopicPublisher;
-import jakarta.jms.TopicSession;
-
-@Stateful
-@Remote(MDB_T_Test.class)
-public class MDB_T_TestEJB implements MDB_T_Test {
-
- @Resource
- private SessionContext sessionContext;
-
- private Properties p = null;
-
- @Resource(name = "jms/MDB_QUEUE_REPLY")
- private transient Queue rcvrQueue;
-
- @Resource(name = "jms/MyQueueConnectionFactory")
- private transient QueueConnectionFactory qFactory;
-
- private transient QueueConnection qConnect;
-
- @Resource(name = "jms/MDB_TOPIC")
- private transient Topic topic;
-
- @Resource(name = "jms/MyTopicConnectionFactory")
- private transient TopicConnectionFactory tFactory;
-
- private transient TopicConnection tConnect;
-
- private String jmsUser;
-
- private String jmsPassword;
-
- private long timeout;
-
- public MDB_T_TestEJB() {
- }
-
- public void setup(Properties props) {
- TestUtil.logTrace("MDB_T_TestEJB.setup()");
- p = props;
- try {
- TestUtil.init(props);
- // get props
- timeout = Long.parseLong(TestUtil.getProperty(props, "jms_timeout"));
- jmsUser = TestUtil.getProperty(props, "user");
- jmsPassword = TestUtil.getProperty(props, "password");
- // check props for errors
- if (timeout < 1) {
- throw new Exception(
- "'jms_timeout' (milliseconds) in ts.jte must be > 0");
- }
- if (jmsUser == null) {
- throw new Exception("'user' in ts.jte must not be null");
- }
- if (jmsPassword == null) {
- throw new Exception("'password' in ts.jte must not be null");
- }
- if (qFactory == null || tFactory == null | rcvrQueue == null
- || topic == null || sessionContext == null) {
- throw new Exception("@Resource injection failed");
- }
- } catch (Exception e) {
- throw new EJBException("@setup failed: ", e);
- }
- }
-
- public boolean askMDBToRunATest(String typeOfTest) {
- TestUtil.logTrace("MDB_T_TestEJB.askMDBToRunATest()");
- boolean ok = true;
- String myMessage = "Sending a message to mdb";
-
- try {
- tConnect = tFactory.createTopicConnection(jmsUser, jmsPassword);
- TopicSession tSession = tConnect.createTopicSession(true, 0);
- tConnect.start();
- TopicPublisher tPublisher = tSession.createPublisher(topic);
- // create a text message
- TextMessage msg = tSession.createTextMessage();
- JmsUtil.addPropsToMessage(msg, p);
-
- msg.setText(myMessage);
- msg.setStringProperty("TestCase", typeOfTest);
-
- // send the message
- tPublisher.publish(msg);
-
- } catch (Exception e) {
- TestUtil.printStackTrace(e);
- throw new EJBException("@askMDBToRunATest: Error!", e);
- } finally {
- try {
- if (tConnect != null) {
- tConnect.close();
- }
- } catch (Exception e) {
- TestUtil.logErr("Error closing TopicConnection", e);
- }
- }
- return ok;
- }
-
- public boolean askMDBToSendAMessage(String typeOfMessage) {
- TestUtil.logTrace("MDB_T_TestEJB.askMDBToSendAMessage()");
- boolean ok = true;
- String myMessage = "I want you to send a message";
-
- try {
- tConnect = tFactory.createTopicConnection(jmsUser, jmsPassword);
- TopicSession session = tConnect.createTopicSession(true, 0);
- TopicPublisher tPublisher = session.createPublisher(topic);
-
- tConnect.start();
-
- // create a text message
- TextMessage msg = session.createTextMessage();
- JmsUtil.addPropsToMessage(msg, p);
-
- msg.setText(myMessage);
- msg.setStringProperty("MessageType", typeOfMessage);
- TestUtil.logTrace("@TestEJB - about to publish a message");
- // send the message
- tPublisher.publish(msg);
- } catch (Exception e) {
- TestUtil.logErr("Unexpected Exception in askMDBToSendAMessage:", e);
- throw new EJBException("@askMDBToSendAMessage: Error!");
- } finally {
- try {
- if (tConnect != null) {
- tConnect.close();
- }
- } catch (Exception e) {
- TestUtil.logErr("Error Closing TopicConnection!", e);
- }
- }
- return ok;
- }
-
- // Validate that a given message was sent by mdb
- // prop = validate string
- //
- public boolean checkOnResponse(String prop) {
-
- boolean status = false;
- try {
- TestUtil.logTrace("MDB_T_TestEJB.checkOnResponse()");
- qConnect = qFactory.createQueueConnection(jmsUser, jmsPassword);
- QueueSession session = qConnect.createQueueSession(true, 0);
- qConnect.start();
- status = recvMessageInternal(session, prop);
- TestUtil.logTrace("Close the session");
- session.close();
- } catch (Exception e) {
- TestUtil.logErr("Error in checkOnResponse", e);
- } finally {
- try {
- if (qConnect != null) {
- qConnect.close();
- }
- } catch (Exception e) {
- TestUtil.logErr("Error closing QueueConnection", e);
- }
- }
- return status;
- }
-
- private boolean recvMessageInternal(QueueSession session, String prop)
- throws JMSException {
- boolean retcode = false;
- TestUtil.logTrace("MDB_T_TestEJB.recvMessageInternal()");
- // Create a message producer.
- QueueReceiver rcvr = session.createReceiver(rcvrQueue);
- // dequeue the response from the mdb
- Message msgRec = null;
-
- for (int i = 0; i < 10; ++i) {
- TestUtil
- .logTrace("@recvMessageInternal trying to receive the message: " + i);
- msgRec = rcvr.receive(timeout);
- if (msgRec != null) {
- break;
- }
- } // end for loop
-
- if (msgRec != null) {
- if ((msgRec.getStringProperty("TestCase") != null)
- || (msgRec.getStringProperty("Status") != null)) {
- if (msgRec.getStringProperty("TestCase").equals(prop)
- && msgRec.getStringProperty("Status").equals("Pass")) {
- TestUtil
- .logTrace("TestCase: " + msgRec.getStringProperty("TestCase"));
- TestUtil.logTrace(
- "Status from msg: " + msgRec.getStringProperty("Status"));
- TestUtil.logTrace("Pass: we got the expected msg back! ");
- retcode = true;
- } else if (msgRec.getStringProperty("Status").equals("Fail")) {
- TestUtil
- .logTrace("TestCase: " + msgRec.getStringProperty("TestCase"));
- TestUtil.logTrace(
- "Status from msg: " + msgRec.getStringProperty("Status"));
- TestUtil.logTrace("Fail: Error(s) occurred! ");
- } else {
- TestUtil.logTrace("Fail: we didnt get the expected msg back! ");
- TestUtil
- .logTrace("TestCase: " + msgRec.getStringProperty("TestCase"));
- }
- } else if (msgRec.getStringProperty("MessageType") != null) {
- if (msgRec.getStringProperty("MessageType").equals(prop)) {
- TestUtil.logTrace("Success: received Msg");
- TestUtil.logTrace("Pass: we got the expected msg back! ");
- retcode = true;
- } else {
- TestUtil.logTrace("Fail: we didnt get the expected msg back! ");
- TestUtil.logTrace(
- "MessageType: " + msgRec.getStringProperty("MessageType"));
- }
- } else {
- TestUtil.logTrace("Fail: we didnt get the expected msg back! ");
- }
- } else {
- TestUtil.logTrace("Fail: we didnt get any msg back! ");
- }
- return retcode;
- }
-
- public boolean isThereSomethingInTheQueue() {
- TestUtil.logTrace("MDB_T_TestEJB.isThereSomethingInTheQueue()");
- QueueBrowser qBrowser = null;
- Enumeration msgs = null;
- boolean ret = false;
-
- try {
- // Hopefully nothing is left in the queue
- qConnect = qFactory.createQueueConnection(jmsUser, jmsPassword);
- QueueSession session = qConnect.createQueueSession(true, 0);
- qConnect.start();
- qBrowser = session.createBrowser(rcvrQueue);
- msgs = qBrowser.getEnumeration();
- if (msgs.hasMoreElements()) {
- ret = true;
- }
- qBrowser.close();
- session.close();
-
- } catch (Exception e) {
- TestUtil.logErr("Error in isThereSomethingInTheQueue", e);
- } finally {
- try {
- if (qConnect != null) {
- qConnect.close();
- }
- } catch (Exception e) {
- TestUtil.logErr("Error closing QueueConnection", e);
- }
- }
- return ret;
- }
-
- public void cleanTheQueue() {
- TestUtil.logTrace("MDB_T_TestEJB.cleanTheQueue()");
- QueueBrowser qBrowser = null;
- Enumeration msgs = null;
- int numMsgs = 0;
-
- try {
- qConnect = qFactory.createQueueConnection(jmsUser, jmsPassword);
- QueueSession session = qConnect.createQueueSession(true, 0);
- qConnect.start();
- TextMessage msgRec = null;
-
- // delete anything left in the queue
- qBrowser = session.createBrowser(rcvrQueue);
- // count the number of messages
- msgs = qBrowser.getEnumeration();
- while (msgs.hasMoreElements()) {
- msgs.nextElement();
- numMsgs++;
- }
- qBrowser.close();
-
- // Read messages until Q is cleaned
- QueueReceiver rcvr = session.createReceiver(rcvrQueue);
- TestUtil.logTrace("Cleaning " + numMsgs + " messages from the Q: "
- + rcvrQueue.getQueueName());
- for (int n = 0; n < numMsgs; n++) {
-
- TestUtil.logTrace(
- "dequeuing msg: " + n + " from the Q: " + rcvrQueue.getQueueName());
- for (int i = 0; i < 10; ++i) {
- msgRec = (TextMessage) rcvr.receive(timeout);
- if (msgRec != null) {
- TestUtil.logTrace("dequeued message: " + n);
- break;
- }
- TestUtil.logTrace(
- "Attempt no: " + i + " Trying to dequeue message: " + n);
- } // end of internal for loop
- }
- session.close();
- } catch (Exception e) {
- TestUtil.logErr("Error in cleanTheQueue", e);
- } finally {
- try {
- if (qConnect != null) {
- qConnect.close();
- }
- } catch (Exception e) {
- TestUtil.logErr("Error closing QueueConnection", e);
- }
- }
- }
-
- @Remove
- public void remove() {
- TestUtil.logTrace("MDB_T_TestEJB.remove()");
- }
-
- @PostActivate
- public void activate() {
- TestUtil.logTrace("MDB_T_TestEJB.activate()");
- try {
- TSNamingContext context = new TSNamingContext();
- rcvrQueue = (Queue) context.lookup("java:comp/env/jms/MDB_QUEUE_REPLY");
- qFactory = (QueueConnectionFactory) context
- .lookup("java:comp/env/jms/MyQueueConnectionFactory");
- tFactory = (TopicConnectionFactory) context
- .lookup("java:comp/env/jms/MyTopicConnectionFactory");
- topic = (Topic) context.lookup("java:comp/env/jms/MDB_TOPIC");
- } catch (Exception e) {
- TestUtil.logErr(
- "Error looking up Queue, Topic, ConnectionFactory objects", e);
- throw new EJBException("@activate: Error!", e);
- }
- }
-
- @PrePassivate
- public void passivate() {
- TestUtil.logTrace("MDB_T_TestEJB.passivate()");
-
- rcvrQueue = null;
-
- if (qConnect != null) {
- try {
- qConnect.close();
- } catch (Exception e) {
- TestUtil.logErr("Error closing QueueConnection", e);
- }
- qConnect = null;
- }
-
- qFactory = null;
-
- topic = null;
- if (tConnect != null) {
- try {
- tConnect.close();
- } catch (Exception e) {
- TestUtil.logErr("Error closing TopicConnection", e);
- }
- tConnect = null;
- }
-
- tFactory = null;
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/jms/commonee/ParentMsgBean.java b/common/src/main/java/com/sun/ts/tests/jms/commonee/ParentMsgBean.java
deleted file mode 100644
index db00214271..0000000000
--- a/common/src/main/java/com/sun/ts/tests/jms/commonee/ParentMsgBean.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id: ParentMsgBean.java 59995 2009-10-14 12:05:29Z af70133 $
- */
-
-package com.sun.ts.tests.jms.commonee;
-
-import java.util.Enumeration;
-import java.util.Properties;
-
-import com.sun.ts.lib.util.TSNamingContext;
-import com.sun.ts.lib.util.TestUtil;
-
-import jakarta.ejb.EJBException;
-import jakarta.ejb.MessageDrivenBean;
-import jakarta.ejb.MessageDrivenContext;
-import jakarta.jms.Message;
-import jakarta.jms.MessageListener;
-import jakarta.jms.Queue;
-import jakarta.jms.QueueConnection;
-import jakarta.jms.QueueConnectionFactory;
-import jakarta.jms.QueueSender;
-import jakarta.jms.QueueSession;
-import jakarta.jms.Session;
-import jakarta.jms.TextMessage;
-
-public class ParentMsgBean implements MessageDrivenBean, MessageListener {
-
- // properties object needed for logging,
- // get this from the message object passed into
- // the onMessage method.
- protected java.util.Properties p = null;
-
- protected TSNamingContext context = null;
-
- protected MessageDrivenContext mdc = null;
-
- // JMS PTP
- protected QueueConnectionFactory qFactory;
-
- protected QueueConnection qConnection = null;
-
- protected Queue queueR = null;
-
- protected Queue queue = null;
-
- protected QueueSender mSender = null;
-
- protected boolean result = false;
-
- public ParentMsgBean() {
- TestUtil.logTrace("@MsgBean()!");
- };
-
- public void ejbCreate() {
- TestUtil.logTrace("@EJBCreate()!");
-
- try {
-
- context = new TSNamingContext();
- qFactory = (QueueConnectionFactory) context
- .lookup("java:comp/env/jms/MyQueueConnectionFactory");
- queueR = (Queue) context.lookup("java:comp/env/jms/MDB_QUEUE_REPLY");
- } catch (Exception e) {
- TestUtil.printStackTrace(e);
- throw new EJBException("MDB ejbCreate Error", e);
- }
- }
-
- public void setMessageDrivenContext(MessageDrivenContext mdc) {
- TestUtil.logTrace("@MsgBean:setMessageDrivenContext()!");
- this.mdc = mdc;
- }
-
- public void ejbRemove() {
- TestUtil.logTrace("@ejbRemove()");
- }
-
- public void onMessage(Message msg) {
- QueueSession qSession = null;
- TextMessage messageSent = null;
- String testName = null;
- String hostname = null;
- String traceflag = null;
- String logport = null;
-
- p = new Properties();
- try {
- // because a jms property name cannot contain '.' the
- // following properties are a special case
- hostname = msg.getStringProperty("harnesshost");
- traceflag = msg.getStringProperty("harnesslogtraceflag");
- logport = msg.getStringProperty("harnesslogport");
- p.put("harness.host", hostname);
- p.put("harness.log.traceflag", traceflag);
- p.put("harness.log.port", logport);
-
- // now pull out the rest of the properties from the message
- Enumeration e = msg.getPropertyNames();
- String key = null;
- while (e.hasMoreElements()) {
- key = (String) e.nextElement();
- p.put(key, msg.getStringProperty(key));
- }
-
- testName = msg.getStringProperty("COM_SUN_JMS_TESTNAME");
- qConnection = qFactory.createQueueConnection();
- if (qConnection == null)
- throw new EJBException("MDB connection Error!");
-
- qSession = qConnection.createQueueSession(true,
- Session.SESSION_TRANSACTED);
-
- // Diagnostic - pull out after testing
- // for (Enumeration enum = p.propertyNames(); enum.hasMoreElements();){
- // System.out.println(enum.nextElement());
- // }
- TestUtil.init(p);
- TestUtil.logTrace("will run TestCase: " + testName);
- runTests(msg, qSession, testName, p);
-
- } catch (Exception e) {
- TestUtil.printStackTrace(e);
- } finally {
- if (qConnection != null) {
- try {
- qConnection.close();
- } catch (Exception e) {
- TestUtil.printStackTrace(e);
- }
- }
- }
-
- }
-
- protected void runTests(Message msg, QueueSession qSession, String testName,
- java.util.Properties p) {
- TestUtil.logTrace("ParentMsgBean - runTests");
-
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/jms/commonee/ParentMsgBeanNoTx.java b/common/src/main/java/com/sun/ts/tests/jms/commonee/ParentMsgBeanNoTx.java
deleted file mode 100644
index 71e3647267..0000000000
--- a/common/src/main/java/com/sun/ts/tests/jms/commonee/ParentMsgBeanNoTx.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id: ParentMsgBeanNoTx.java 59995 2009-10-14 12:05:29Z af70133 $
- */
-
-package com.sun.ts.tests.jms.commonee;
-
-import java.util.Enumeration;
-import java.util.Properties;
-
-import com.sun.ts.lib.util.TSNamingContext;
-import com.sun.ts.lib.util.TestUtil;
-
-import jakarta.ejb.EJBException;
-import jakarta.ejb.MessageDrivenBean;
-import jakarta.ejb.MessageDrivenContext;
-import jakarta.jms.Message;
-import jakarta.jms.MessageListener;
-import jakarta.jms.Queue;
-import jakarta.jms.QueueConnection;
-import jakarta.jms.QueueConnectionFactory;
-import jakarta.jms.QueueSender;
-import jakarta.jms.QueueSession;
-import jakarta.jms.Session;
-import jakarta.jms.TextMessage;
-
-public class ParentMsgBeanNoTx implements MessageDrivenBean, MessageListener {
-
- // properties object needed for logging,
- // get this from the message object passed into
- // the onMessage method.
- protected java.util.Properties p = null;
-
- protected TSNamingContext context = null;
-
- protected MessageDrivenContext mdc = null;
-
- // JMS PTP
- protected QueueConnectionFactory qFactory;
-
- protected QueueConnection qConnection = null;
-
- protected Queue queueR = null;
-
- protected Queue queue = null;
-
- protected QueueSender mSender = null;
-
- protected boolean result = false;
-
- public ParentMsgBeanNoTx() {
- TestUtil.logTrace("@MsgBean()!");
- };
-
- public void ejbCreate() {
- TestUtil.logTrace("@EJBCreate()!");
-
- try {
-
- context = new TSNamingContext();
- qFactory = (QueueConnectionFactory) context
- .lookup("java:comp/env/jms/MyQueueConnectionFactory");
- queueR = (Queue) context.lookup("java:comp/env/jms/MDB_QUEUE_REPLY");
- } catch (Exception e) {
- TestUtil.printStackTrace(e);
- throw new EJBException("MDB ejbCreate Error", e);
- }
- }
-
- public void setMessageDrivenContext(MessageDrivenContext mdc) {
- TestUtil.logTrace("@MsgBean:setMessageDrivenContext()!");
- this.mdc = mdc;
- }
-
- public void ejbRemove() {
- TestUtil.logTrace("@ejbRemove()");
- }
-
- public void onMessage(Message msg) {
- QueueSession qSession = null;
- TextMessage messageSent = null;
- String testName = null;
- String hostname = null;
- String traceflag = null;
- String logport = null;
-
- p = new Properties();
- try {
- // because a jms property name cannot contain '.' the
- // following properties are a special case
- hostname = msg.getStringProperty("harnesshost");
- traceflag = msg.getStringProperty("harnesslogtraceflag");
- logport = msg.getStringProperty("harnesslogport");
- p.put("harness.host", hostname);
- p.put("harness.log.traceflag", traceflag);
- p.put("harness.log.port", logport);
-
- // now pull out the rest of the properties from the message
- Enumeration e = msg.getPropertyNames();
- String key = null;
- while (e.hasMoreElements()) {
- key = (String) e.nextElement();
- p.put(key, msg.getStringProperty(key));
- }
-
- testName = msg.getStringProperty("COM_SUN_JMS_TESTNAME");
- qConnection = qFactory.createQueueConnection();
- if (qConnection == null)
- throw new EJBException("MDB connection Error!");
-
- qSession = qConnection.createQueueSession(false,
- Session.AUTO_ACKNOWLEDGE);
-
- // Diagnostic - pull out after testing
- // for (Enumeration enum = p.propertyNames(); enum.hasMoreElements();){
- // System.out.println(enum.nextElement());
- // }
- TestUtil.init(p);
- TestUtil.logTrace("will run TestCase: " + testName);
- runTests(msg, qSession, testName, p);
-
- } catch (Exception e) {
- TestUtil.printStackTrace(e);
- } finally {
- if (qConnection != null) {
- try {
- qConnection.close();
- } catch (Exception e) {
- TestUtil.printStackTrace(e);
- }
- }
- }
-
- }
-
- protected void runTests(Message msg, QueueSession qSession, String testName,
- java.util.Properties p) {
- TestUtil.logTrace("ParentMsgBeanNoTx - runTests");
-
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/jms/commonee/Tests.java b/common/src/main/java/com/sun/ts/tests/jms/commonee/Tests.java
deleted file mode 100644
index 8c5c2124fa..0000000000
--- a/common/src/main/java/com/sun/ts/tests/jms/commonee/Tests.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id: Tests.java 59995 2009-10-14 12:05:29Z af70133 $
- */
-package com.sun.ts.tests.jms.commonee;
-
-import java.util.ArrayList;
-import java.util.Properties;
-
-import jakarta.ejb.Remote;
-import jakarta.jms.Queue;
-
-@Remote
-public interface Tests {
- public void initLogging(Properties p);
-
- public void remove();
-
- public ArrayList sendTextMessage_CQ(String tesname, String text);
-
- public ArrayList sendMessageP_CQ(String tesname, String text, boolean val);
-
- public ArrayList sendMessagePP_CQ(String tesname, String text, boolean val,
- String props, String value);
-
- public String receiveTextMessage_CQ();
-
- public String receiveMessageS_CQ(String selector);
-
- public int browseTextMessage_CQ(int num, String msg);
-
- public int browseMessageS_CQ(int num, String msg, String selector);
-
- public ArrayList sendTextMessage_CT(String tesname, String text);
-
- public String receiveTextMessage_CT();
-
- public int getAck_CQ();
-
- public int getAck_CT();
-
- public boolean getQueue();
-
- public boolean getSelector(String selector);
-
- public ArrayList sendTextMessage_Q(String tesname);
-
- public ArrayList sendTextMessage_Q(String tesname, boolean setDest);
-
- public ArrayList sendTextMessage_Q(String tesname, String text);
-
- public ArrayList sendTextMessage_Q(String tesname, String text,
- Queue testQueue);
-
- public ArrayList sendTextMessage_Q(String tesname, boolean setDest, int mode);
-
- public ArrayList sendFullBytesMessage_Q(String tesname);
-
- public ArrayList sendBytesMessage_Q(String tesname, boolean setDest);
-
- public ArrayList sendBytesMessage_Q(String tesname, boolean setDest,
- int mode);
-
- public boolean verifyFullBytesMessage();
-
- public ArrayList sendFullMapMessage_Q(String tesname);
-
- public ArrayList sendMapMessage_Q(String tesname, boolean setDest);
-
- public ArrayList sendMapMessage_Q(String tesname, boolean setDest, int mode);
-
- public boolean verifyFullMapMessage();
-
- public ArrayList sendFullStreamMessage_Q(String tesname);
-
- public ArrayList sendStreamMessage_Q(String tesname, boolean setDest);
-
- public ArrayList sendStreamMessage_Q(String tesname, boolean setDest,
- int mode);
-
- public boolean verifyFullStreamMessage();
-
- public ArrayList sendObjectMessage_Q(String tesname);
-
- public ArrayList sendObjectMessage_Q(String tesname, boolean setDest);
-
- public ArrayList sendObjectMessage_Q(String tesname, boolean setDest,
- int mode);
-
- public String getMessageID();
-
- public long getTimeStamp();
-
- public String getCorrelationID();
-
- public String getReplyTo();
-
- public String getDestination_1();
-
- public String getDestination();
-
- public String getType();
-
- public int getPriority();
-
- public long getExpiration();
-
- public int getDeliveryMode();
-
- public String getText();
-}
diff --git a/common/src/main/java/com/sun/ts/tests/jms/commonee/TestsEJB.java b/common/src/main/java/com/sun/ts/tests/jms/commonee/TestsEJB.java
deleted file mode 100644
index 655fe643b7..0000000000
--- a/common/src/main/java/com/sun/ts/tests/jms/commonee/TestsEJB.java
+++ /dev/null
@@ -1,2098 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id: TestsEJB.java 59995 2009-10-14 12:05:29Z af70133 $
- */
-package com.sun.ts.tests.jms.commonee;
-
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.Properties;
-
-import com.sun.ts.lib.util.RemoteLoggingInitException;
-import com.sun.ts.lib.util.TSNamingContext;
-import com.sun.ts.lib.util.TestUtil;
-
-import jakarta.annotation.PostConstruct;
-import jakarta.annotation.Resource;
-import jakarta.ejb.EJBException;
-import jakarta.ejb.PostActivate;
-import jakarta.ejb.PrePassivate;
-import jakarta.ejb.Remote;
-import jakarta.ejb.Remove;
-import jakarta.ejb.SessionContext;
-import jakarta.ejb.Stateful;
-import jakarta.jms.BytesMessage;
-import jakarta.jms.Connection;
-import jakarta.jms.ConnectionFactory;
-import jakarta.jms.DeliveryMode;
-import jakarta.jms.Destination;
-import jakarta.jms.MapMessage;
-import jakarta.jms.Message;
-import jakarta.jms.MessageConsumer;
-import jakarta.jms.MessageProducer;
-import jakarta.jms.ObjectMessage;
-import jakarta.jms.Queue;
-import jakarta.jms.QueueBrowser;
-import jakarta.jms.QueueConnection;
-import jakarta.jms.QueueConnectionFactory;
-import jakarta.jms.QueueReceiver;
-import jakarta.jms.QueueSender;
-import jakarta.jms.QueueSession;
-import jakarta.jms.Session;
-import jakarta.jms.StreamMessage;
-import jakarta.jms.TextMessage;
-
-@Stateful
-@Remote(Tests.class)
-public class TestsEJB implements Tests {
-
- @Resource
- private SessionContext sessionContext;
-
- private Properties harnessProps = null;
-
- private TSNamingContext nctx = null;
-
- private transient Destination testDestination = null;
-
- private transient ConnectionFactory cf = null;
-
- private transient Connection conn = null;
-
- private transient Queue queue = null;
-
- private transient QueueConnectionFactory qcf = null;
-
- private transient QueueConnection qconn = null;
-
- private static final String TESTQUEUENAME = "java:comp/env/jms/MY_QUEUE";
-
- private static final String TESTTOPICNAME = "java:comp/env/jms/MY_TOPIC";
-
- private static final String QUEUECONNECTIONFACTORY = "java:comp/env/jms/MyQueueConnectionFactory";
-
- private static final String DURABLETOPICCONNECTIONFACTORY = "java:comp/env/jms/MyTopicConnectionFactory";
-
- private TextMessage messageSent = null;
-
- private BytesMessage messageSentB = null;
-
- private String username = null;
-
- private String password = null;
-
- private long timeout;
-
- private boolean booleanValue = false;
-
- private byte byteValue = 127;
-
- private byte byteValue1 = -12;
-
- private int byteValue2 = 244;
-
- private byte[] bytesValue = { 127, -127, 1, 0 };
-
- private byte[] bytesValueRecvd = { 0, 0, 0, 0 };
-
- private byte[] byteValues = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
-
- private byte[] byteValues2 = { 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 };
-
- private byte[] byteValuesReturned = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
-
- private byte[] byteValuesReturned2 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
-
- private char charValue = 'Z';
-
- private double doubleValue = 6.02e23;
-
- private float floatValue = 6.02e23f;
-
- private int intValue = 2147483647;
-
- private long longValue = 9223372036854775807L;
-
- private Integer nInteger = Integer.valueOf(-2147483648);
-
- private short shortValue = -32768;
-
- private short shortValue1 = -28679;
-
- private int shortValue2 = 36857;
-
- private String utfValue = "what";
-
- private String stringValue = "Map Message Test";
-
- private String sTesting = "Testing StreamMessages";
-
- private String type = "JMSTCKTESTMSG";
-
- private String jmsCorrelationID = "JMSTCKCorrelationID";
-
- private int priority = 2;
-
- private long forever = 0L;
-
- public TestsEJB() {
- TestUtil.logTrace("TestsEJB => default constructor called");
- }
-
- @PostConstruct
- public void postConstruct() {
- TestUtil.logTrace("postConstruct");
- try {
- TestUtil.logMsg("obtain naming context");
- nctx = new TSNamingContext();
- } catch (Exception e) {
- TestUtil.logErr("Error obtaining naming context: ", e);
- throw new EJBException("postConstruct: Failed!", e);
- }
- }
-
- @PostActivate
- public void activate() {
- TestUtil.logTrace("activate");
- try {
- common_Q();
- setup_Q();
- } catch (Exception e) {
- TestUtil.logErr("Error during common Queue setup: ", e);
- throw new EJBException("activate: Failed!", e);
- }
- }
-
- @PrePassivate
- public void passivate() {
- TestUtil.logTrace("passivate");
-
- testDestination = null;
- cf = null;
- conn = null;
- queue = null;
- qcf = null;
- qconn = null;
- }
-
- @Remove
- public void remove() {
- TestUtil.logTrace("remove");
- }
-
- public void initLogging(Properties p) {
- TestUtil.logTrace("initLogging");
- harnessProps = p;
- try {
- TestUtil.logMsg("initialize remote logging");
- TestUtil.init(p);
- timeout = Long.parseLong(TestUtil.getProperty(harnessProps, "jms_timeout"));
- username = TestUtil.getProperty(harnessProps, "user");
- password = TestUtil.getProperty(harnessProps, "password");
- // check props for errors
- if (timeout < 1) {
- throw new EJBException(
- "'jms_timeout' (milliseconds) in ts.jte must be > 0");
- }
- if (username == null) {
- throw new EJBException("'user' in ts.jte must be null");
- }
- if (password == null) {
- throw new EJBException("'password' in ts.jte must be null");
- }
- if (sessionContext == null) {
- throw new EJBException("@Resource injection failed");
- }
- } catch (RemoteLoggingInitException e) {
- TestUtil.printStackTrace(e);
- throw new EJBException("initLogging: Failed!", e);
- }
- }
-
- private void common_Q() throws Exception {
-
- TestUtil.logTrace("Getting ConnectionFactory " + QUEUECONNECTIONFACTORY);
- cf = (ConnectionFactory) nctx.lookup(QUEUECONNECTIONFACTORY);
-
- TestUtil.logTrace("Getting Destination " + TESTQUEUENAME);
- testDestination = (Destination) nctx.lookup(TESTQUEUENAME);
-
- // create default connection
- TestUtil.logTrace("Creating Connection with username, " + username
- + " password, " + password);
- conn = cf.createConnection(username, password);
- }
-
- private void setup_Q() throws Exception {
-
- TestUtil.logTrace("Getting ConnectionFactory " + QUEUECONNECTIONFACTORY);
- qcf = (QueueConnectionFactory) nctx.lookup(QUEUECONNECTIONFACTORY);
-
- TestUtil.logTrace("Getting Queue" + TESTQUEUENAME);
- queue = (Queue) nctx.lookup(TESTQUEUENAME);
-
- // create default QueueConnection
- TestUtil.logTrace("Creating QueueConnection with username, " + username
- + " password, " + password);
- qconn = qcf.createQueueConnection(username, password);
- }
-
- private void common_T() throws Exception {
-
- TestUtil
- .logTrace("Getting ConnectionFactory " + DURABLETOPICCONNECTIONFACTORY);
- cf = (ConnectionFactory) nctx.lookup(DURABLETOPICCONNECTIONFACTORY);
-
- TestUtil.logTrace("Getting Destination " + TESTTOPICNAME);
- testDestination = (Destination) nctx.lookup(TESTTOPICNAME);
-
- // create default connection
- TestUtil.logTrace("Creating Connection with username, " + username
- + " password, " + password);
- conn = cf.createConnection(username, password);
-
- }
-
- public ArrayList sendTextMessage_CQ(String TestName, String message) {
- ArrayList valueAtSend = null;
- long timeBeforeSend = 0L;
- long timeAfterSend = 0L;
-
- try {
- // get ConnectionFactory and Connection
- common_Q();
-
- // create default Session
- TestUtil.logTrace("Creating Session");
- Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- // create default consumer/producer
- TestUtil.logTrace("Creating messageProducer");
- MessageProducer sender = sess.createProducer(testDestination);
-
- TestUtil.logMsg("Creating 1 TextMessage");
- messageSent = sess.createTextMessage();
- messageSent.setText(message);
- messageSent.setStringProperty("COM_SUN_JMS_TESTNAME", TestName);
-
- TestUtil.logMsg("Sending a TextMessage");
- timeBeforeSend = System.currentTimeMillis();
- sender.send(messageSent);
- timeAfterSend = System.currentTimeMillis();
-
- valueAtSend = logPropertyAtSend(messageSent, timeBeforeSend,
- timeAfterSend);
-
- } catch (Exception e) {
- TestUtil.logErr("Failed to send a Message in sendTextMessage_CQ");
- TestUtil.printStackTrace(e);
- } finally {
- if (conn != null) {
- try {
- TestUtil.logTrace("Closing Connection in sendTextMessage_CQ");
- conn.close();
- } catch (Exception ce) {
- TestUtil.logErr(
- "Error closing conn in sendTextMessage_CQ" + ce.getMessage(), ce);
- }
- }
- }
- return valueAtSend;
- }
-
- private ArrayList logPropertyAtSend(Message messageSent, long timeBeforeSend,
- long timeAfterSend) throws Exception {
- ArrayList valueAtSend = new ArrayList(9);
-
- valueAtSend.add(0, Long.valueOf(timeBeforeSend));
- TestUtil.logTrace("Time before send..." + valueAtSend.get(0));
-
- valueAtSend.add(1, Long.valueOf(timeAfterSend));
- TestUtil.logTrace("Time after send...." + valueAtSend.get(1));
-
- valueAtSend.add(2, Long.valueOf(messageSent.getJMSTimestamp()));
- TestUtil.logTrace("JMSTimeStamp......." + valueAtSend.get(2));
-
- valueAtSend.add(3, Long.valueOf(messageSent.getJMSExpiration()));
- TestUtil.logTrace("JMSExpiration......" + valueAtSend.get(3));
-
- valueAtSend.add(4, messageSent.getJMSDestination());
- TestUtil.logTrace("JMSDestination....." + valueAtSend.get(4));
-
- valueAtSend.add(5, Long.valueOf(messageSent.getJMSPriority()));
- TestUtil.logTrace("JMSPriority........" + valueAtSend.get(5));
-
- valueAtSend.add(6, Long.valueOf(messageSent.getJMSDeliveryMode()));
- TestUtil.logTrace("JMSDeliveryMode...." + valueAtSend.get(6));
-
- valueAtSend.add(7, messageSent.getJMSMessageID());
- TestUtil.logTrace("JMSMessageID......." + valueAtSend.get(7));
-
- valueAtSend.add(8, messageSent.getJMSCorrelationID());
- TestUtil.logTrace("JMSCorrelationID..." + valueAtSend.get(8));
-
- return valueAtSend;
- }
-
- public String receiveTextMessage_CQ() {
- TextMessage receivedM = null;
- String tmp = null;
- try {
- // get ConnectionFactory and Connection
- common_Q();
- conn.start();
-
- // create default Session
- TestUtil.logTrace("Creating Session");
- Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- // create default consumer
- TestUtil.logTrace("Creating MessageConsumer");
- MessageConsumer receiver = sess.createConsumer(testDestination);
-
- receivedM = (TextMessage) receiver.receive(timeout);
- tmp = receivedM.getText();
- } catch (Exception e) {
- TestUtil.logErr("Failed to receive a message in receiveTextMessage_CQ: ",
- e);
- throw new EJBException(e);
- } finally {
- if (conn != null) {
- try {
- TestUtil.logTrace("Closing Connection in receiveTextMessage_CQ");
- conn.close();
- } catch (Exception ce) {
- TestUtil.logErr(
- "Error closing conn in receiveTextMessage_CQ" + ce.getMessage(),
- ce);
- }
- }
- }
- return tmp;
- }
-
- public String receiveMessageS_CQ(String selector) {
- TextMessage receivedM = null;
- String tmp = null;
-
- try {
- // get ConnectionFactory and Connection
- common_Q();
- conn.start();
-
- // create default Session
- TestUtil.logTrace("Creating Session");
- Session sess = conn.createSession(true, Session.AUTO_ACKNOWLEDGE);
-
- // create default consumer
- TestUtil.logTrace("Creating MessageConsumer");
- MessageConsumer receiver = sess.createConsumer(testDestination, selector);
-
- receivedM = (TextMessage) receiver.receive(timeout);
- tmp = receivedM.getText();
- } catch (Exception e) {
- TestUtil.logErr("Failed to receive a message in receiveMessageS_CQ: ", e);
- throw new EJBException(e);
- } finally {
- if (conn != null) {
- try {
- TestUtil.logTrace("Closing Connection in receiveMessageS_CQ");
- conn.close();
- } catch (Exception ce) {
- TestUtil.logErr(
- "Error closing conn in receiveMessageS_CQ" + ce.getMessage(), ce);
- }
- }
- }
- return tmp;
- }
-
- public int browseTextMessage_CQ(int num, String message) {
- QueueBrowser browseAll = null;
- int msgCount = 0;
- int totalMsg = 0;
- TextMessage tempMsg = null;
- try {
- // get ConnectionFactory and Connection
- common_Q();
- conn.start();
-
- // create default Session
- TestUtil.logTrace("Creating Session");
- Session sess = conn.createSession(true, Session.AUTO_ACKNOWLEDGE);
-
- // create browser
- TestUtil.logTrace("Creating QueueBrowser");
- browseAll = sess.createBrowser((Queue) testDestination);
-
- // getting Emumeration that contains at least two test messages
- // without getting into dead loop.
- // Workaround for possible timing problem
- Enumeration msgs = null;
- int i = 0;
- do {
- i++;
- msgCount = 0;
- totalMsg = 0;
- msgs = browseAll.getEnumeration();
- TestUtil.logTrace("getting Enumeration " + i);
- while (msgs.hasMoreElements()) {
- tempMsg = (TextMessage) msgs.nextElement();
- totalMsg++;
- if (!(tempMsg.getText().indexOf(message) < 0))
- msgCount++;
- }
- TestUtil.logTrace("found " + msgCount + " messages total in browser");
- } while ((msgCount < num) && (i < 10));
-
- } catch (Exception e) {
- TestUtil.logErr("Failed to browse message in browseTextMessage_CQ: ", e);
- throw new EJBException(e);
- } finally {
- if (conn != null) {
- try {
- TestUtil.logTrace("Closing Connection in browseTextMessage_CQ");
- conn.close();
- } catch (Exception ce) {
- TestUtil.logErr(
- "Error closing conn in browseTextMessage_CQ" + ce.getMessage(),
- ce);
- }
- }
- }
- return totalMsg;
- }
-
- public int browseMessageS_CQ(int num, String message, String selector) {
- QueueBrowser selectiveBrowser = null;
- int msgCount = 0;
- int totalMsg = 0;
- TextMessage tempMsg = null;
-
- try {
- // get ConnectionFactory and Connection
- common_Q();
- conn.start();
-
- // create default Session
- TestUtil.logTrace("Creating Session");
- Session sess = conn.createSession(true, Session.AUTO_ACKNOWLEDGE);
-
- // create browser
- TestUtil.logTrace("Creating QueueBrowser");
- selectiveBrowser = sess.createBrowser((Queue) testDestination, selector);
-
- // getting Emumeration that contains at least two test messages
- // without getting into dead loop.
- // Workaround for possible timing problem
- Enumeration msgs = null;
- int i = 0;
- do {
- i++;
- msgCount = 0;
- totalMsg = 0;
- msgs = selectiveBrowser.getEnumeration();
- TestUtil.logTrace("getting Enumeration " + i);
- while (msgs.hasMoreElements()) {
- tempMsg = (TextMessage) msgs.nextElement();
- totalMsg++;
- if (!(tempMsg.getText().indexOf(message) < 0))
- msgCount++;
- }
- TestUtil.logTrace("found " + msgCount + " messages total in browser");
- } while ((msgCount < num) && (i < 10));
-
- } catch (Exception e) {
- TestUtil.logErr("Failed to browse message in browseMessageS_CQ: ", e);
- throw new EJBException(e);
- } finally {
- if (conn != null) {
- try {
- TestUtil.logTrace("Closing Connection in browseMessageS_CQ");
- conn.close();
- } catch (Exception ce) {
- TestUtil.logErr(
- "Error closing conn in browseMessageS_CQ" + ce.getMessage(), ce);
- }
- }
- }
- return totalMsg;
- }
-
- public ArrayList sendMessageP_CQ(String TestName, String message,
- boolean val) {
- ArrayList valueAtSend = null;
- long timeBeforeSend = 0L;
- long timeAfterSend = 0L;
-
- try {
- // get ConnectionFactory and Connection
- common_Q();
-
- // create default Session
- TestUtil.logTrace("Creating Session");
- Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- // create default consumer/producer
- TestUtil.logTrace("Creating messageProducer");
- MessageProducer sender = sess.createProducer(testDestination);
-
- TestUtil.logMsg("Creating 1 TextMessage");
- messageSent = sess.createTextMessage();
- messageSent.setText(message);
- messageSent.setStringProperty("COM_SUN_JMS_TESTNAME", TestName);
- messageSent.setBooleanProperty("lastMessage", val);
-
- TestUtil.logMsg("Sending a TextMessage");
- timeBeforeSend = System.currentTimeMillis();
- sender.send(messageSent);
- timeAfterSend = System.currentTimeMillis();
-
- valueAtSend = logPropertyAtSend(messageSent, timeBeforeSend,
- timeAfterSend);
-
- } catch (Exception e) {
- TestUtil.logErr("Failed to send a Message in sendMessageP_CQ");
- TestUtil.printStackTrace(e);
- } finally {
- if (conn != null) {
- try {
- TestUtil.logTrace("Closing Connection in sendMessageP_CQ");
- conn.close();
- } catch (Exception ce) {
- TestUtil.logErr(
- "Error closing conn in sendMessageP_CQ" + ce.getMessage(), ce);
- }
- }
- }
- return valueAtSend;
- }
-
- public ArrayList sendMessagePP_CQ(String TestName, String message,
- boolean val, String p, String value) {
- ArrayList valueAtSend = null;
- long timeBeforeSend = 0L;
- long timeAfterSend = 0L;
-
- try {
- // get ConnectionFactory and Connection
- common_Q();
-
- // create default Session
- TestUtil.logTrace("Creating Session");
- Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- // create default consumer/producer
- TestUtil.logTrace("Creating messageProducer");
- MessageProducer sender = sess.createProducer(testDestination);
-
- TestUtil.logMsg("Creating 1 TextMessage");
- messageSent = sess.createTextMessage();
- messageSent.setText(message);
- messageSent.setStringProperty("COM_SUN_JMS_TESTNAME", TestName);
- messageSent.setStringProperty(p, value);
- messageSent.setBooleanProperty("lastMessage", val);
-
- TestUtil.logMsg("Sending a TextMessage");
- timeBeforeSend = System.currentTimeMillis();
- sender.send(messageSent);
- timeAfterSend = System.currentTimeMillis();
-
- valueAtSend = logPropertyAtSend(messageSent, timeBeforeSend,
- timeAfterSend);
-
- } catch (Exception e) {
- TestUtil.logErr("Failed to send a Message in sendMessagePP_CQ");
- TestUtil.printStackTrace(e);
- } finally {
- if (conn != null) {
- try {
- TestUtil.logTrace("Closing Connection in sendMessagePP_CQ");
- conn.close();
- } catch (Exception ce) {
- TestUtil.logErr(
- "Error closing conn in sendMessagePP_CQ" + ce.getMessage(), ce);
- }
- }
- }
- return valueAtSend;
- }
-
- public ArrayList sendTextMessage_CT(String TestName, String message) {
- ArrayList valueAtSend = null;
- long timeBeforeSend = 0L;
- long timeAfterSend = 0L;
-
- try {
- // get ConnectionFactory and Connection
- common_T();
-
- // create default Session
- TestUtil.logTrace("Creating Session");
- Session sess = conn.createSession(true, Session.AUTO_ACKNOWLEDGE);
-
- // create default consumer/producer
- TestUtil.logTrace("Creating messageProducer");
- MessageProducer sender = sess.createProducer(testDestination);
-
- TestUtil.logMsg("Creating 1 TextMessage");
- messageSent = sess.createTextMessage();
- messageSent.setText(message);
- messageSent.setStringProperty("COM_SUN_JMS_TESTNAME", TestName);
-
- TestUtil.logMsg("Sending a TextMessage");
- timeBeforeSend = System.currentTimeMillis();
- sender.send(messageSent);
- timeAfterSend = System.currentTimeMillis();
-
- valueAtSend = logPropertyAtSend(messageSent, timeBeforeSend,
- timeAfterSend);
-
- } catch (Exception e) {
- TestUtil.logErr("Failed to send a Message in sendTextMessage_CT");
- TestUtil.printStackTrace(e);
- } finally {
- if (conn != null) {
- try {
- TestUtil.logTrace("Closing Connection in sendTextMessage_CT");
- conn.close();
- } catch (Exception ce) {
- TestUtil.logErr(
- "Error closing conn in sendTextMessage_CT" + ce.getMessage(), ce);
- }
- }
- }
- return valueAtSend;
- }
-
- public String receiveTextMessage_CT() {
- TextMessage receivedM = null;
- String tmp = null;
-
- try {
- // get ConnectionFactory and Connection
- common_T();
- conn.start();
-
- // create default Session
- TestUtil.logTrace("Creating Session");
- Session sess = conn.createSession(true, Session.AUTO_ACKNOWLEDGE);
-
- // create default consumer
- TestUtil.logTrace("Creating MessageConsumer");
- MessageConsumer receiver = sess.createConsumer(testDestination);
-
- receivedM = (TextMessage) receiver.receive(timeout);
- tmp = receivedM.getText();
- } catch (Exception e) {
- TestUtil.logErr("Failed to receive a message in receiveTextMessage_CT: ",
- e);
- throw new EJBException(e);
- } finally {
- if (conn != null) {
- try {
- TestUtil.logTrace("Closing Connection in receiveTextMessage_CT");
- conn.close();
- } catch (Exception ce) {
- TestUtil.logErr(
- "Error closing conn in receiveTextMessage_CT" + ce.getMessage(),
- ce);
- }
- }
- }
- return tmp;
- }
-
- public int getAck_CT() {
- int mode = 0;
-
- try {
- common_T();
- Session sess = conn.createSession(true, Session.AUTO_ACKNOWLEDGE);
- mode = sess.getAcknowledgeMode();
- TestUtil
- .logTrace("AcknowledgeMode is set at " + Session.AUTO_ACKNOWLEDGE);
- TestUtil.logTrace("AcknowledgeMode returned as " + mode);
- } catch (Exception e) {
- TestUtil.logErr("Failed to getAcknowledgeMode: ", e);
- throw new EJBException(e);
- } finally {
- if (conn != null) {
- try {
- TestUtil.logTrace("Closing Connection in getAck_CT");
- conn.close();
- } catch (Exception ce) {
- TestUtil.logErr(
- "Error closing conn in getAck_CT():" + ce.getMessage(), ce);
- }
- }
- }
- return mode;
- }
-
- public int getAck_CQ() {
- int mode = 0;
-
- try {
- common_Q();
- Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
- mode = sess.getAcknowledgeMode();
- } catch (Exception e) {
- TestUtil.logErr("Failed to getAcknowledgeMode: ", e);
- throw new EJBException(e);
- } finally {
- if (conn != null) {
- try {
- TestUtil.logTrace("Closing Connection in getAck_CQ");
- conn.close();
- } catch (Exception ce) {
- TestUtil.logErr(
- "Error closing conn in getAck_CQ():" + ce.getMessage(), ce);
- }
- }
- }
- return mode;
- }
-
- public boolean getQueue() {
- QueueBrowser browseAll = null;
- boolean pass = true;
-
- try {
- common_Q();
- Session sess = conn.createSession(true, Session.AUTO_ACKNOWLEDGE);
-
- // create browser
- TestUtil.logTrace("Creating QueueBrowser");
- browseAll = sess.createBrowser((Queue) testDestination);
-
- if (!browseAll.getQueue().toString().equals(testDestination.toString())) {
- pass = false;
- TestUtil.logErr("Error: QueueBrowser.getQueue test failed");
- TestUtil.logErr(
- "QueueBrowser.getQueue=" + browseAll.getQueue().toString() + ".");
- TestUtil.logErr("testDestination=" + testDestination.toString() + ".");
- }
- browseAll.close();
-
- } catch (Exception e) {
- TestUtil.logErr("Failed to getQueue: ", e);
- throw new EJBException(e);
- } finally {
- if (conn != null) {
- try {
- TestUtil.logTrace("Closing Connection in getQueue");
- conn.close();
- } catch (Exception ce) {
- TestUtil.logErr("Error closing conn in getQueue():" + ce.getMessage(),
- ce);
- }
- }
- }
- return pass;
- }
-
- public boolean getSelector(String selector) {
- QueueBrowser selectiveBrowser = null;
- boolean pass = true;
-
- try {
- common_Q();
- Session sess = conn.createSession(true, Session.AUTO_ACKNOWLEDGE);
-
- // create browser
- TestUtil.logTrace("Creating QueueBrowser");
- selectiveBrowser = sess.createBrowser((Queue) testDestination, selector);
-
- String tmp = selectiveBrowser.getMessageSelector();
- if (tmp.indexOf("TEST") < 0 || tmp.indexOf("test") < 0) {
- pass = false;
- TestUtil.logErr("Error: QueueBrowser.getMessageSelector test failed");
- TestUtil.logErr("selectiveBrowser.getMessageSelector()="
- + selectiveBrowser.getMessageSelector());
- }
-
- selectiveBrowser.close();
- } catch (Exception e) {
- TestUtil.logErr("Failed to getMessageSelector: ", e);
- throw new EJBException(e);
- } finally {
- if (conn != null) {
- try {
- TestUtil.logTrace("Closing Connection in getSelector");
- conn.close();
- } catch (Exception ce) {
- TestUtil.logErr(
- "Error closing conn in getSelector():" + ce.getMessage(), ce);
- }
- }
- }
- return pass;
- }
-
- public ArrayList sendTextMessage_Q(String TestName) {
- return sendTextMessage_Q(TestName, null, false, DeliveryMode.PERSISTENT,
- true);
- }
-
- public ArrayList sendTextMessage_Q(String TestName, String text) {
- return sendTextMessage_Q(TestName, text, false, DeliveryMode.PERSISTENT,
- true);
- }
-
- public ArrayList sendTextMessage_Q(String TestName, boolean setDest) {
- return sendTextMessage_Q(TestName, null, setDest, DeliveryMode.PERSISTENT,
- true);
- }
-
- public ArrayList sendTextMessage_Q(String TestName, boolean setDest,
- int mode) {
- return sendTextMessage_Q(TestName, null, setDest, mode, true);
- }
-
- public ArrayList sendTextMessage_Q(String TestName, String text,
- boolean setDest, int mode) {
- return sendTextMessage_Q(TestName, text, setDest, mode, true);
- }
-
- public ArrayList sendTextMessage_Q(String TestName, String text,
- Queue testQueue) {
- return sendTextMessage_Q(TestName, text, false, DeliveryMode.PERSISTENT,
- false);
- }
-
- private ArrayList sendTextMessage_Q(String TestName, String text,
- boolean setDest, int mode, boolean setQueue) {
- ArrayList valueAtSend = null;
- long timeBeforeSend = 0L;
- long timeAfterSend = 0L;
-
- QueueSender qsender = null;
-
- try {
- // get QueueConnectionFactory and QueueConnection
- setup_Q();
-
- // create default QueueSession
- TestUtil.logTrace("Creating QueueSession");
- QueueSession qsess = qconn.createQueueSession(true,
- Session.AUTO_ACKNOWLEDGE);
-
- // create default QueueSender
- TestUtil.logTrace("Creating QueueSender");
- if (setQueue)
- qsender = qsess.createSender(queue);
- else
- qsender = qsess.createSender((Queue) null);
- qsender.setPriority(priority);
- qsender.setTimeToLive(forever);
- if (mode != DeliveryMode.PERSISTENT)
- qsender.setDeliveryMode(mode);
-
- TestUtil.logMsg("Creating 1 TextMessage");
- messageSent = qsess.createTextMessage();
-
- if (text != null)
- messageSent.setText(text);
- messageSent.setStringProperty("COM_SUN_JMS_TESTNAME", TestName);
- messageSent.setJMSCorrelationID(jmsCorrelationID);
- messageSent.setJMSType(type);
-
- if (setDest)
- messageSent.setJMSReplyTo(queue);
-
- // -----------------------------------------------------------------------------
- TestUtil.logMsg("Sending a TextMessage");
- timeBeforeSend = System.currentTimeMillis();
- if (setQueue)
- qsender.send(messageSent);
- else
- qsender.send(queue, messageSent);
- timeAfterSend = System.currentTimeMillis();
-
- valueAtSend = logPropertyAtSend(messageSent, timeBeforeSend,
- timeAfterSend);
-
- } catch (Exception e) {
- TestUtil.logErr("Failed to send a Message in sendTextMessage_Q", e);
- } finally {
- if (qconn != null) {
- try {
- TestUtil.logTrace("Closing QueueConnection in sendTextMessage_Q");
- qconn.close();
- } catch (Exception ce) {
- TestUtil.logErr("Error closing QueueConnection in sendTextMessage_Q",
- ce);
- }
- }
- }
- return valueAtSend;
- }
-
- /*
- * public String receiveTextMessage_Q() { TextMessage receivedM = null; String
- * tmp = null;
- *
- * try { //get QueueConnectionFactory and QueueConnection setup_Q();
- * qconn.start();
- *
- * // create default Session TestUtil.logTrace("Creating QueueSession");
- * QueueSession qsess = qconn.createQueueSession(true,
- * Session.AUTO_ACKNOWLEDGE);
- *
- * // create default QueueReceiver
- * TestUtil.logTrace("Creating QueueReceiver"); QueueReceiver qreceiver =
- * qsess.createReceiver(queue);
- *
- * receivedM = (TextMessage) qreceiver.receive(timeout); tmp =
- * receivedM.getText(); } catch (Exception e ) {
- * TestUtil.logErr("Failed to receive a message in receiveTextMessage_Q: ",
- * e); throw new EJBException(e); } finally { if ( qconn != null) { try {
- * TestUtil.logTrace("Closing Connection in receiveTextMessage_Q");
- * qconn.close(); } catch (Exception ce) {
- * TestUtil.logErr("Error closing conn in receiveTextMessage_Q" +
- * ce.getMessage(), ce); } } } return tmp; }
- */
-
- public ArrayList sendFullBytesMessage_Q(String TestName) {
- return sendBytesMessage_Q(TestName, false, DeliveryMode.PERSISTENT);
- }
-
- public ArrayList sendBytesMessage_Q(String TestName, boolean setDest) {
- return sendBytesMessage_Q(TestName, setDest, DeliveryMode.PERSISTENT);
- }
-
- public ArrayList sendBytesMessage_Q(String TestName, boolean setDest,
- int mode) {
- ArrayList valueAtSend = null;
- long timeBeforeSend = 0L;
- long timeAfterSend = 0L;
-
- try {
- // get QueueConnectionFactory and QueueConnection
- setup_Q();
-
- // create default QueueSession
- TestUtil.logTrace("Creating QueueSession");
- QueueSession qsess = qconn.createQueueSession(true,
- Session.AUTO_ACKNOWLEDGE);
-
- // create default QueueSender
- TestUtil.logTrace("Creating QueueSender");
- QueueSender qsender = qsess.createSender(queue);
- qsender.setPriority(priority);
- qsender.setTimeToLive(forever);
- if (mode != DeliveryMode.PERSISTENT)
- qsender.setDeliveryMode(mode);
-
- TestUtil.logMsg("Creating 1 BytesMessage");
- messageSentB = qsess.createBytesMessage();
-
- messageSentB.setStringProperty("COM_SUN_JMS_TESTNAME", TestName);
- messageSentB.setJMSCorrelationID(jmsCorrelationID);
- messageSentB.setJMSType(type);
-
- if (setDest)
- messageSentB.setJMSReplyTo(queue);
-
- // -----------------------------------------------------------------------------
- TestUtil.logMsg("Writing one of each primitive type to the message");
-
- // -----------------------------------------------------------------------------
- messageSentB.writeBoolean(booleanValue);
- messageSentB.writeByte(byteValue);
- messageSentB.writeByte(byteValue1);
- messageSentB.writeChar(charValue);
- messageSentB.writeDouble(doubleValue);
- messageSentB.writeFloat(floatValue);
- messageSentB.writeInt(intValue);
- messageSentB.writeLong(longValue);
- messageSentB.writeObject(nInteger);
- messageSentB.writeShort(shortValue);
- messageSentB.writeShort(shortValue1);
- messageSentB.writeUTF(utfValue);
- messageSentB.writeBytes(bytesValue);
- messageSentB.writeBytes(bytesValue, 0, 1);
-
- TestUtil.logMsg("Sending a BytesMessage");
- timeBeforeSend = System.currentTimeMillis();
- qsender.send(messageSentB);
- timeAfterSend = System.currentTimeMillis();
-
- valueAtSend = logPropertyAtSend(messageSentB, timeBeforeSend,
- timeAfterSend);
-
- } catch (Exception e) {
- TestUtil.logErr("Failed to send a Message in sendFullBytesMessage_Q", e);
- } finally {
- if (qconn != null) {
- try {
- TestUtil
- .logTrace("Closing QueueConnection in sendFullBytesMessage_Q");
- qconn.close();
- } catch (Exception ce) {
- TestUtil.logErr(
- "Error closing QueueConnection in sendFullBytesMessage_Q", ce);
- }
- }
- }
- return valueAtSend;
- }
-
- public boolean verifyFullBytesMessage() {
- TestUtil.logTrace("In verifyFullBytesMessage ...");
-
- BytesMessage messageReceived = null;
-
- try {
- // get QueueConnectionFactory and QueueConnection
- setup_Q();
- qconn.start();
-
- // create default Session
- TestUtil.logTrace("Creating QueueSession");
- QueueSession qsess = qconn.createQueueSession(true,
- Session.AUTO_ACKNOWLEDGE);
-
- // create default QueueReceiver
- TestUtil.logTrace("Creating QueueReceiver");
- QueueReceiver qreceiver = qsess.createReceiver(queue);
-
- messageReceived = (BytesMessage) qreceiver.receive(timeout);
- } catch (Exception e) {
- TestUtil.logErr("Failed to receive a message in verifyFullBytesMessage: ",
- e);
- throw new EJBException(e);
- } finally {
- if (qconn != null) {
- try {
- TestUtil.logTrace("Closing Connection in verifyFullBytesMessage");
- qconn.close();
- } catch (Exception ce) {
- TestUtil.logErr("Error closing conn in verifyFullBytesMessage", ce);
- }
- }
- }
-
- boolean pass = true;
-
- try {
- if (!messageReceived.readBoolean() == booleanValue) {
- TestUtil.logErr("Error: boolean not returned as expected");
- pass = false;
- }
- } catch (Exception e) {
- TestUtil.logErr("Error: unexpected exception was thrown", e);
- pass = false;
- }
-
- try {
- if (messageReceived.readByte() != byteValue) {
- TestUtil.logErr("Error: Byte not returned as expected");
- pass = false;
- }
- } catch (Exception e) {
- TestUtil.logErr("Error: unexpected exception was thrown", e);
- pass = false;
- }
-
- try {
- int tmp = messageReceived.readUnsignedByte();
-
- if (tmp != byteValue2) {
- TestUtil.logErr(
- "Fail: readUnsignedByte not returned expected value: " + tmp);
- pass = false;
- }
- } catch (Exception e) {
- TestUtil.logErr("Error: unexpected exception was thrown", e);
- pass = false;
- }
-
- try {
- if (messageReceived.readChar() != charValue) {
- TestUtil.logErr("Fail: char not returned as expected");
- pass = false;
- }
- } catch (Exception e) {
- TestUtil.logErr("Error: unexpected exception was thrown", e);
- pass = false;
- }
-
- try {
- if (messageReceived.readDouble() != doubleValue) {
- TestUtil.logErr("Fail: double not returned as expected");
- pass = false;
- }
- } catch (Exception e) {
- TestUtil.logErr("Error: unexpected exception was thrown", e);
- pass = false;
- }
-
- try {
- if (messageReceived.readFloat() != floatValue) {
- TestUtil.logErr("Fail: float not returned as expected");
- pass = false;
- }
- } catch (Exception e) {
- TestUtil.logErr("Error: unexpected exception was thrown", e);
- pass = false;
- }
-
- try {
- if (messageReceived.readInt() != intValue) {
- TestUtil.logErr("Fail: int not returned as expected");
- pass = false;
- }
- } catch (Exception e) {
- TestUtil.logErr("Error: unexpected exception was thrown", e);
- pass = false;
- }
-
- try {
- if (messageReceived.readLong() != longValue) {
- TestUtil.logErr("Fail: long not returned as expected");
- pass = false;
- }
- } catch (Exception e) {
- TestUtil.logErr("Error: unexpected exception was thrown", e);
- pass = false;
- }
-
- try {
- if (messageReceived.readInt() != nInteger.intValue()) {
- TestUtil.logErr("Fail: Integer not returned as expected");
- pass = false;
- }
- } catch (Exception e) {
- TestUtil.logErr("Error: unexpected exception was thrown", e);
- pass = false;
- }
-
- try {
- if (messageReceived.readShort() != shortValue) {
- TestUtil.logErr("Fail: short not returned as expected");
- pass = false;
- }
- } catch (Exception e) {
- TestUtil.logErr("Error: unexpected exception was thrown", e);
- pass = false;
- }
-
- try {
- int tmps = messageReceived.readUnsignedShort();
- if (tmps != shortValue2) {
- TestUtil.logErr(
- "Fail: readUnsignedShort did not return expected value: " + tmps);
- pass = false;
- }
- } catch (Exception e) {
- TestUtil.logErr("Error: unexpected exception was thrown", e);
- pass = false;
- }
-
- try {
- if (!messageReceived.readUTF().equals(utfValue)) {
- TestUtil.logErr("Fail: UTF not returned as expected");
- pass = false;
- }
- } catch (Exception e) {
- TestUtil.logErr("Error: unexpected exception was thrown", e);
- pass = false;
- }
-
- try {
- int nCount = messageReceived.readBytes(bytesValueRecvd);
-
- for (int i = 0; i < nCount; i++) {
- if (bytesValueRecvd[i] != bytesValue[i]) {
- TestUtil.logErr("Fail: bytes value incorrect");
- pass = false;
- }
- }
- } catch (Exception e) {
- TestUtil.logErr("Error: unexpected exception was thrown", e);
- pass = false;
- }
-
- try {
- int nCount = messageReceived.readBytes(bytesValueRecvd);
-
- TestUtil.logTrace("count returned " + nCount);
- if (bytesValueRecvd[0] != bytesValue[0]) {
- TestUtil.logErr("Fail: bytes value incorrect");
- pass = false;
- }
-
- if (nCount != 1) {
- TestUtil.logErr("Error: count not returned as expected");
- pass = false;
- }
- } catch (Exception e) {
- TestUtil.logErr("Error: unexpected exception was thrown", e);
- pass = false;
- }
-
- try {
- long length = 37l;
- long tmpl = messageReceived.getBodyLength();
- if (tmpl < length) {
- TestUtil
- .logErr("getBodyLength test failed with incorrect length=" + tmpl);
- pass = false;
- }
- } catch (Exception e) {
- TestUtil.logErr("Error: unexpected exception was thrown", e);
- pass = false;
- }
- return pass;
- }
-
- public ArrayList sendFullMapMessage_Q(String testName) {
- return sendMapMessage_Q(testName, false, DeliveryMode.PERSISTENT);
- }
-
- public ArrayList sendMapMessage_Q(String testName, boolean setDest) {
- return sendMapMessage_Q(testName, setDest, DeliveryMode.PERSISTENT);
- }
-
- public ArrayList sendMapMessage_Q(String testName, boolean setDest,
- int mode) {
- ArrayList valueAtSend = null;
- long timeBeforeSend = 0L;
- long timeAfterSend = 0L;
-
- try {
- setup_Q();
-
- MapMessage messageSent = null;
- MapMessage msgReceivedM = null;
-
- // create default QueueSession
- TestUtil.logTrace("Creating QueueSession");
- QueueSession qsess = qconn.createQueueSession(true,
- Session.AUTO_ACKNOWLEDGE);
-
- // create default QueueSender
- TestUtil.logTrace("Creating QueueSender");
- QueueSender qsender = qsess.createSender(queue);
- qsender.setPriority(priority);
- qsender.setTimeToLive(forever);
- if (mode != DeliveryMode.PERSISTENT)
- qsender.setDeliveryMode(mode);
-
- TestUtil.logMsg("Creating 1 MapMessage");
- messageSent = qsess.createMapMessage();
-
- messageSent.setStringProperty("COM_SUN_JMS_TESTNAME", testName);
- messageSent.setJMSCorrelationID(jmsCorrelationID);
- messageSent.setJMSType(type);
-
- if (setDest)
- messageSent.setJMSReplyTo(queue);
-
- messageSent.setBoolean("booleanValue", booleanValue);
- messageSent.setByte("byteValue", byteValue);
- messageSent.setBytes("bytesValue", bytesValue);
- messageSent.setBytes("bytesValue2", bytesValue, 0, 1);
- messageSent.setChar("charValue", charValue);
- messageSent.setDouble("doubleValue", doubleValue);
- messageSent.setFloat("floatValue", floatValue);
- messageSent.setInt("intValue", intValue);
- messageSent.setLong("longValue", longValue);
- messageSent.setObject("nInteger", nInteger);
- messageSent.setShort("shortValue", shortValue);
- messageSent.setString("stringValue", stringValue);
- messageSent.setString("nullTest", null);
-
- TestUtil.logTrace("Sending a MapMessage...");
- timeBeforeSend = System.currentTimeMillis();
- qsender.send(messageSent);
- timeAfterSend = System.currentTimeMillis();
-
- valueAtSend = logPropertyAtSend(messageSent, timeBeforeSend,
- timeAfterSend);
-
- } catch (Exception e) {
- TestUtil.logErr("Failed to send a Message in sendFullMapMessage_Q", e);
- } finally {
- if (qconn != null) {
- try {
- TestUtil.logTrace("Closing QueueConnection in sendFullMapMessage_Q");
- qconn.close();
- } catch (Exception ce) {
- TestUtil.logErr(
- "Error closing QueueConnection in sendFullMapMessage_Q", ce);
- }
- }
- }
- return valueAtSend;
- }
-
- public boolean verifyFullMapMessage() {
- boolean pass = true;
- MapMessage msgReceivedM = null;
-
- try {
- // get QueueConnectionFactory and QueueConnection
- setup_Q();
- qconn.start();
-
- // create default Session
- TestUtil.logTrace("Creating QueueSession");
- QueueSession qsess = qconn.createQueueSession(true,
- Session.AUTO_ACKNOWLEDGE);
-
- // create default QueueReceiver
- TestUtil.logTrace("Creating QueueReceiver");
- QueueReceiver qreceiver = qsess.createReceiver(queue);
-
- msgReceivedM = (MapMessage) qreceiver.receive(timeout);
- } catch (Exception e) {
- TestUtil.logErr("Failed to receive a message in verifyFullMapMessage: ",
- e);
- throw new EJBException(e);
- } finally {
- if (qconn != null) {
- try {
- TestUtil.logTrace("Closing Connection in verifyFullMapMessage");
- qconn.close();
- } catch (Exception ce) {
- TestUtil.logErr("Error closing conn in verifyFullMapMessage", ce);
- }
- }
- }
-
- try {
- if (msgReceivedM.getBoolean("booleanValue") != booleanValue) {
- TestUtil.logErr("Fail: invalid boolean returned: "
- + msgReceivedM.getBoolean("booleanValue"));
- pass = false;
- }
- } catch (Exception e) {
- TestUtil.logErr("Fail: unexpected exception " + e.getClass().getName()
- + " was returned", e);
- pass = false;
- }
-
- try {
- if (msgReceivedM.getByte("byteValue") != byteValue) {
- TestUtil.logErr("Fail: invalid byte returned: "
- + msgReceivedM.getByte("byteValue"));
- pass = false;
- }
- } catch (Exception e) {
- TestUtil.logErr("Fail: unexpected exception " + e.getClass().getName()
- + " was returned", e);
- pass = false;
- }
-
- try {
- byte[] b = msgReceivedM.getBytes("bytesValue");
-
- for (int i = 0; i < b.length; i++) {
- if (b[i] != bytesValue[i]) {
- TestUtil.logErr("Fail: byte array " + i + " not valid: " + b[i]);
- pass = false;
- }
- }
- } catch (Exception e) {
- TestUtil.logErr("Fail: unexpected exception " + e.getClass().getName()
- + " was returned", e);
- pass = false;
- }
-
- try {
- byte[] b = msgReceivedM.getBytes("bytesValue2");
-
- if (b[0] != bytesValue[0]) {
- TestUtil.logErr("Fail: byte array not valid " + b[0]);
- pass = false;
- }
- } catch (Exception e) {
- TestUtil.logErr("Fail: unexpected exception " + e.getClass().getName()
- + " was returned", e);
- pass = false;
- }
-
- try {
- if (msgReceivedM.getChar("charValue") != charValue) {
- TestUtil.logErr("Fail: invalid char returned: "
- + msgReceivedM.getChar("charValue"));
- pass = false;
- }
- } catch (Exception e) {
- TestUtil.logErr("Fail: unexpected exception " + e.getClass().getName()
- + " was returned", e);
- pass = false;
- }
-
- try {
- if (msgReceivedM.getDouble("doubleValue") != doubleValue) {
- TestUtil.logErr("Fail: invalid double returned: "
- + msgReceivedM.getDouble("doubleValue"));
- pass = false;
- }
- } catch (Exception e) {
- TestUtil.logErr("Fail: unexpected exception " + e.getClass().getName()
- + " was returned", e);
- pass = false;
- }
-
- try {
- if (msgReceivedM.getFloat("floatValue") != floatValue) {
- TestUtil.logErr("Fail: invalid float returned");
- pass = false;
- }
- } catch (Exception e) {
- TestUtil.logErr("Fail: unexpected exception " + e.getClass().getName()
- + " was returned", e);
- pass = false;
- }
-
- try {
- if (msgReceivedM.getInt("intValue") != intValue) {
- TestUtil.logErr("Fail: invalid int returned");
- pass = false;
- }
- } catch (Exception e) {
- TestUtil.logErr("Fail: unexpected exception " + e.getClass().getName()
- + " was returned", e);
- pass = false;
- }
-
- try {
- if (msgReceivedM.getLong("longValue") != longValue) {
- TestUtil.logErr("Fail: invalid long returned");
- pass = false;
- }
- } catch (Exception e) {
- TestUtil.logErr("Fail: unexpected exception " + e.getClass().getName()
- + " was returned", e);
- pass = false;
- }
-
- try {
- if (!msgReceivedM.getObject("nInteger").toString()
- .equals(nInteger.toString())) {
- TestUtil.logErr("Fail: invalid object returned");
- pass = false;
- }
- } catch (Exception e) {
- TestUtil.logErr("Fail: unexpected exception " + e.getClass().getName()
- + " was returned", e);
- pass = false;
- }
-
- try {
- if (msgReceivedM.getShort("shortValue") != shortValue) {
- TestUtil.logErr("Fail: invalid short returned");
- pass = false;
- }
- } catch (Exception e) {
- TestUtil.logErr("Fail: unexpected exception " + e.getClass().getName()
- + " was returned", e);
- pass = false;
- }
-
- try {
- if (!msgReceivedM.getString("stringValue").equals(stringValue)) {
- TestUtil.logErr("Fail: invalid string returned");
- pass = false;
- }
- } catch (Exception e) {
- TestUtil.logErr("Fail: unexpected exception " + e.getClass().getName()
- + " was returned", e);
- pass = false;
- }
-
- try {
- if (msgReceivedM.getString("nullTest") != null) {
- TestUtil.logErr("Fail: null not returned from getString: "
- + msgReceivedM.getString("nullTest"));
- pass = false;
- }
- } catch (Exception e) {
- TestUtil.logErr("Fail: unexpected exception " + e.getClass().getName()
- + " was returned", e);
- pass = false;
- }
- return pass;
- }
-
- public ArrayList sendFullStreamMessage_Q(String testName) {
- return sendStreamMessage_Q(testName, false, DeliveryMode.PERSISTENT);
- }
-
- public ArrayList sendStreamMessage_Q(String testName, boolean setDest) {
- return sendStreamMessage_Q(testName, setDest, DeliveryMode.PERSISTENT);
- }
-
- public ArrayList sendStreamMessage_Q(String testName, boolean setDest,
- int mode) {
- ArrayList valueAtSend = null;
- long timeBeforeSend = 0L;
- long timeAfterSend = 0L;
-
- try {
- setup_Q();
-
- StreamMessage messageSent = null;
-
- // create default QueueSession
- TestUtil.logTrace("Creating QueueSession");
- QueueSession qsess = qconn.createQueueSession(true,
- Session.AUTO_ACKNOWLEDGE);
-
- // create default QueueSender
- TestUtil.logTrace("Creating QueueSender");
- QueueSender qsender = qsess.createSender(queue);
- qsender.setPriority(priority);
- qsender.setTimeToLive(forever);
- if (mode != DeliveryMode.PERSISTENT)
- qsender.setDeliveryMode(mode);
-
- TestUtil.logMsg("Creating 1 StreamMessage");
- messageSent = qsess.createStreamMessage();
-
- messageSent.setStringProperty("COM_SUN_JMS_TESTNAME", testName);
- messageSent.setJMSCorrelationID(jmsCorrelationID);
- messageSent.setJMSType(type);
-
- if (setDest)
- messageSent.setJMSReplyTo(queue);
-
- messageSent.writeBytes(byteValues2, 0, byteValues.length);
- messageSent.writeBoolean(booleanValue);
- messageSent.writeByte(byteValue);
- messageSent.writeBytes(byteValues);
- messageSent.writeChar(charValue);
- messageSent.writeDouble(doubleValue);
- messageSent.writeFloat(floatValue);
- messageSent.writeInt(intValue);
- messageSent.writeLong(longValue);
- messageSent.writeObject(sTesting);
- messageSent.writeShort(shortValue);
- messageSent.writeString(stringValue);
- messageSent.writeObject(null);
-
- TestUtil.logTrace("Sending a StreamMessage ...");
- timeBeforeSend = System.currentTimeMillis();
- qsender.send(messageSent);
- timeAfterSend = System.currentTimeMillis();
-
- valueAtSend = logPropertyAtSend(messageSent, timeBeforeSend,
- timeAfterSend);
-
- } catch (Exception e) {
- TestUtil.logErr("Failed to send a Message in sendFullStreamMessage_Q", e);
- } finally {
- if (qconn != null) {
- try {
- TestUtil
- .logTrace("Closing QueueConnection in sendFullStreamMessage_Q");
- qconn.close();
- } catch (Exception ce) {
- TestUtil.logErr(
- "Error closing QueueConnection in sendFullStreamMessage_Q", ce);
- }
- }
- }
- return valueAtSend;
- }
-
- public boolean verifyFullStreamMessage() {
- TestUtil.logTrace("In verifyFullStreamMessage");
-
- boolean pass = true;
- StreamMessage messageReceived = null;
-
- try {
- // get QueueConnectionFactory and QueueConnection
- setup_Q();
- qconn.start();
-
- // create default Session
- TestUtil.logTrace("Creating QueueSession");
- QueueSession qsess = qconn.createQueueSession(true,
- Session.AUTO_ACKNOWLEDGE);
-
- // create default QueueReceiver
- TestUtil.logTrace("Creating QueueReceiver");
- QueueReceiver qreceiver = qsess.createReceiver(queue);
-
- messageReceived = (StreamMessage) qreceiver.receive(timeout);
- } catch (Exception e) {
- TestUtil.logErr(
- "Failed to receive a message in verifyFullStreamMessage: ", e);
- throw new EJBException(e);
- } finally {
- if (qconn != null) {
- try {
- TestUtil.logTrace("Closing Connection in verifyFullStreamMessage");
- qconn.close();
- } catch (Exception ce) {
- TestUtil.logErr("Error closing conn in verifyFullStreamMessage", ce);
- }
- }
- }
-
- try {
- int nCount;
- do {
- nCount = messageReceived.readBytes(byteValuesReturned2);
- TestUtil.logTrace("nCount is " + nCount);
- if (nCount != -1) {
- for (int i = 0; i < byteValuesReturned2.length; i++) {
- if (byteValuesReturned2[i] != byteValues2[i]) {
- TestUtil.logErr("Fail: byte[] " + i + " is not valid ="
- + byteValuesReturned2[i]);
- pass = false;
- }
- }
- }
- } while (nCount >= byteValuesReturned2.length);
- } catch (Exception e) {
- TestUtil.logErr(
- "Error: exception was thrown in verifyFullStreamMessage: ", e);
- pass = false;
- }
-
- try {
- if (messageReceived.readBoolean() != booleanValue) {
- TestUtil.logErr("Fail: boolean not returned as expected");
- pass = false;
- }
- } catch (Exception e) {
- TestUtil.logErr(
- "Error: exception was thrown in verifyFullStreamMessage: ", e);
- pass = false;
- }
-
- try {
- if (messageReceived.readByte() != byteValue) {
- TestUtil.logErr("Fail: Byte not returned as expected");
- pass = false;
- }
- } catch (Exception e) {
- TestUtil.logErr(
- "Error: exception was thrown in verifyFullStreamMessage: ", e);
- pass = false;
- }
-
- try {
- int nCount;
- do {
- nCount = messageReceived.readBytes(byteValuesReturned);
- TestUtil.logTrace("nCount is " + nCount);
- if (nCount != -1) {
- for (int i = 0; i < byteValuesReturned.length; i++) {
- if (byteValuesReturned[i] != byteValues[i]) {
- TestUtil.logErr("Fail: byte[] " + i + " is not valid");
- pass = false;
- }
- }
- }
- } while (nCount >= byteValuesReturned.length);
- } catch (Exception e) {
- TestUtil.logErr(
- "Error: exception was thrown in verifyFullStreamMessage: ", e);
- pass = false;
- }
-
- try {
- if (messageReceived.readChar() != charValue) {
- TestUtil.logErr("Fail: char not returned as expected");
- pass = false;
- }
- } catch (Exception e) {
- TestUtil.logErr(
- "Error: exception was thrown in verifyFullStreamMessage: ", e);
- pass = false;
- }
-
- try {
- if (messageReceived.readDouble() != doubleValue) {
- TestUtil.logErr("Fail: double not returned as expected");
- pass = false;
- }
- } catch (Exception e) {
- TestUtil.logErr(
- "Error: exception was thrown in verifyFullStreamMessage: ", e);
- pass = false;
- }
-
- try {
- if (messageReceived.readFloat() != floatValue) {
- TestUtil.logErr("Fail: float not returned as expected");
- pass = false;
- }
- } catch (Exception e) {
- TestUtil.logErr(
- "Error: exception was thrown in verifyFullStreamMessage: ", e);
- pass = false;
- }
-
- try {
- if (messageReceived.readInt() != intValue) {
- TestUtil.logErr("Fail: int not returned as expected");
- pass = false;
- }
- } catch (Exception e) {
- TestUtil.logErr(
- "Error: exception was thrown in verifyFullStreamMessage: ", e);
- pass = false;
- }
-
- try {
- if (messageReceived.readLong() != longValue) {
- TestUtil.logErr("Fail: long not returned as expected");
- pass = false;
- }
- } catch (Exception e) {
- TestUtil.logErr(
- "Error: exception was thrown in verifyFullStreamMessage: ", e);
- pass = false;
- }
-
- try {
- if (!messageReceived.readObject().equals(sTesting)) {
- TestUtil.logErr("Fail: object not returned as expected");
- pass = false;
- }
- } catch (Exception e) {
- TestUtil.logErr(
- "Error: exception was thrown in verifyFullStreamMessage: ", e);
- pass = false;
- }
-
- try {
- if (messageReceived.readShort() != shortValue) {
- TestUtil.logErr("Fail: short not returned as expected");
- pass = false;
- }
- } catch (Exception e) {
- TestUtil.logErr(
- "Error: exception was thrown in verifyFullStreamMessage: ", e);
- pass = false;
- }
-
- try {
- if (!messageReceived.readString().equals(stringValue)) {
- TestUtil.logErr("Fail: string not returned as expected");
- pass = false;
- }
- } catch (Exception e) {
- TestUtil.logErr(
- "Error: exception was thrown in verifyFullStreamMessage: ", e);
- pass = false;
- }
-
- try {
- if (messageReceived.readObject() != null) {
- TestUtil.logErr("Fail: object not returned as expected");
- pass = false;
- }
- } catch (Exception e) {
- TestUtil.logErr(
- "Error: exception was thrown in verifyFullStreamMessage: ", e);
- pass = false;
- }
-
- return pass;
- }
-
- public ArrayList sendObjectMessage_Q(String testName) {
- return sendObjectMessage_Q(testName, false, DeliveryMode.PERSISTENT);
- }
-
- public ArrayList sendObjectMessage_Q(String testName, boolean setDest) {
- return sendObjectMessage_Q(testName, setDest, DeliveryMode.PERSISTENT);
- }
-
- public ArrayList sendObjectMessage_Q(String testName, boolean setDest,
- int mode) {
- ArrayList valueAtSend = null;
- long timeBeforeSend = 0L;
- long timeAfterSend = 0L;
-
- try {
- setup_Q();
-
- ObjectMessage messageSent = null;
-
- // create default QueueSession
- TestUtil.logTrace("Creating QueueSession");
- QueueSession qsess = qconn.createQueueSession(true,
- Session.AUTO_ACKNOWLEDGE);
-
- // create default QueueSender
- TestUtil.logTrace("Creating QueueSender");
- QueueSender qsender = qsess.createSender(queue);
- qsender.setPriority(priority);
- qsender.setTimeToLive(forever);
- if (mode != DeliveryMode.PERSISTENT)
- qsender.setDeliveryMode(mode);
-
- TestUtil.logMsg("Creating 1 ObjectMessage");
- messageSent = qsess.createObjectMessage();
-
- messageSent.setObject(String.valueOf("HeaderIDTest for ObjectMessage"));
- messageSent.setStringProperty("COM_SUN_JMS_TESTNAME", testName);
- messageSent.setJMSCorrelationID(jmsCorrelationID);
- messageSent.setJMSType(type);
-
- if (setDest)
- messageSent.setJMSReplyTo(queue);
-
- TestUtil.logTrace("Sending an ObjectMessage...");
- timeBeforeSend = System.currentTimeMillis();
- qsender.send(messageSent);
- timeAfterSend = System.currentTimeMillis();
- valueAtSend = logPropertyAtSend(messageSentB, timeBeforeSend,
- timeAfterSend);
-
- } catch (Exception e) {
- TestUtil.logErr("Failed to send a Message in sendObjectMessage_Q", e);
- } finally {
- if (qconn != null) {
- try {
- TestUtil.logTrace("Closing QueueConnection in sendObjectMessage_Q");
- qconn.close();
- } catch (Exception ce) {
- TestUtil.logErr(
- "Error closing QueueConnection in sendObjectMessage_Q", ce);
- }
- }
- }
- return valueAtSend;
- }
-
- public ObjectMessage receiveObjectMessage_Q() {
- ObjectMessage receivedM = null;
-
- try {
- // get QueueConnectionFactory and QueueConnection
- setup_Q();
- qconn.start();
-
- // create default Session
- TestUtil.logTrace("Creating QueueSession");
- QueueSession qsess = qconn.createQueueSession(true,
- Session.AUTO_ACKNOWLEDGE);
-
- // create default QueueReceiver
- TestUtil.logTrace("Creating QueueReceiver");
- QueueReceiver qreceiver = qsess.createReceiver(queue);
-
- receivedM = (ObjectMessage) qreceiver.receive(timeout);
- } catch (Exception e) {
- TestUtil.logErr("Failed to receive a message in receiveObjectMessage_Q: ",
- e);
- throw new EJBException(e);
- } finally {
- if (qconn != null) {
- try {
- TestUtil.logTrace("Closing Connection in receiveObjectMessage_Q");
- qconn.close();
- } catch (Exception ce) {
- TestUtil.logErr(
- "Error closing conn in receiveObjectMessage_Q" + ce.getMessage(),
- ce);
- }
- }
- }
- return receivedM;
- }
-
- public Message receiveMessage_Q() {
- Message receivedM = null;
-
- try {
- // get QueueConnectionFactory and QueueConnection
- setup_Q();
- qconn.start();
-
- // create default Session
- TestUtil.logTrace("Creating QueueSession");
- QueueSession qsess = qconn.createQueueSession(true,
- Session.AUTO_ACKNOWLEDGE);
-
- // create default QueueReceiver
- TestUtil.logTrace("Creating QueueReceiver");
- QueueReceiver qreceiver = qsess.createReceiver(queue);
-
- receivedM = (Message) qreceiver.receive(timeout);
- } catch (Exception e) {
- TestUtil.logErr("Failed to receive a message in receiveMessage_Q: ", e);
- throw new EJBException(e);
- } finally {
- if (qconn != null) {
- try {
- TestUtil.logTrace("Closing Connection in receiveMessage_Q");
- qconn.close();
- } catch (Exception ce) {
- TestUtil.logErr(
- "Error closing conn in receiveMessage_Q" + ce.getMessage(), ce);
- }
- }
- }
- return receivedM;
- }
-
- public String getMessageID() {
- Message msg = receiveMessage_Q();
-
- String id = null;
- try {
- id = msg.getJMSMessageID();
- } catch (Exception e) {
- TestUtil.logErr("Exception calling getJMSMessageID in getMessageID: ", e);
- }
- return id;
- }
-
- public long getTimeStamp() {
- Message msg = receiveMessage_Q();
- long JMSTimestamp = 0L;
- try {
- JMSTimestamp = msg.getJMSTimestamp();
- } catch (Exception e) {
- TestUtil.logErr("Exception calling getJMSTimestamp in getTimeStamp: ", e);
- }
- return JMSTimestamp;
- }
-
- public String getCorrelationID() {
- String jmsCorrelationID = null;
- Message msg = receiveMessage_Q();
-
- try {
- jmsCorrelationID = msg.getJMSCorrelationID();
- } catch (Exception e) {
- TestUtil.logErr(
- "Exception calling getJMSCorrelationID in getCorrelationID: ", e);
- }
- return jmsCorrelationID;
- }
-
- public String getReplyTo() {
- Message msg = receiveMessage_Q();
- Destination replyto = null;
-
- try {
- replyto = msg.getJMSReplyTo();
- if (replyto != null)
- return ((Queue) replyto).getQueueName();
- else
- return null;
- } catch (Exception e) {
- TestUtil.logErr("Exception calling getJMSReplyTo in getReplyTo: ", e);
- return null;
- }
- }
-
- public String getType() {
- Message msg = receiveMessage_Q();
- String jmsType = null;
-
- try {
- jmsType = msg.getJMSType();
- } catch (Exception e) {
- TestUtil.logErr("Exception calling getJMSType in getType: ", e);
- }
- return jmsType;
- }
-
- public int getPriority() {
- Message msg = receiveMessage_Q();
- int jmsPriority = 0;
-
- try {
- jmsPriority = msg.getJMSPriority();
- } catch (Exception e) {
- TestUtil.logErr("Exception calling getJMSPriority in getPriority: ", e);
- }
- return jmsPriority;
- }
-
- public long getExpiration() {
- Message msg = receiveMessage_Q();
- long jmsExpiration = 0L;
-
- try {
- jmsExpiration = msg.getJMSExpiration();
- } catch (Exception e) {
- TestUtil.logErr("Exception calling getJMSExpiration in getExpiration: ",
- e);
- }
- return jmsExpiration;
- }
-
- public String getDestination_1() {
- String tmp = null;
- try {
- TestUtil.logTrace("Getting Destination " + TESTQUEUENAME);
- Destination dest = (Destination) nctx.lookup(TESTQUEUENAME);
- tmp = ((Queue) dest).getQueueName();
-
- } catch (Exception e) {
- TestUtil.logErr("Exception in getDestination_1: ", e);
- }
- return tmp;
- }
-
- public String getDestination() {
- Message msg = receiveMessage_Q();
- String tmp = null;
-
- try {
- tmp = ((Queue) msg.getJMSDestination()).getQueueName();
- } catch (Exception e) {
- TestUtil.logErr("Exception calling getJMSDestination in getDestination: ",
- e);
- }
- return tmp;
- }
-
- public int getDeliveryMode() {
- Message msg = receiveMessage_Q();
- int jmsMode = 0;
-
- try {
- jmsMode = msg.getJMSDeliveryMode();
- } catch (Exception e) {
- TestUtil.logErr(
- "Exception calling getJMSDeliveryMode in getDeliveryMode: ", e);
- }
- return jmsMode;
- }
-
- public String getText() {
- Message msg = receiveMessage_Q();
- String text = null;
-
- try {
- text = ((TextMessage) msg).getText();
- } catch (Exception e) {
- TestUtil.logErr("Exception calling getText in getText: ", e);
- }
- return text;
- }
-
-}
diff --git a/common/src/main/java/com/sun/ts/tests/jms/commonee/TestsTEJB.java b/common/src/main/java/com/sun/ts/tests/jms/commonee/TestsTEJB.java
deleted file mode 100644
index 9e2500423b..0000000000
--- a/common/src/main/java/com/sun/ts/tests/jms/commonee/TestsTEJB.java
+++ /dev/null
@@ -1,265 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id: TestsTEJB.java 59995 2009-10-14 12:05:29Z af70133 $
- */
-package com.sun.ts.tests.jms.commonee;
-
-import java.util.Properties;
-
-import com.sun.ts.lib.util.RemoteLoggingInitException;
-import com.sun.ts.lib.util.TSNamingContext;
-import com.sun.ts.lib.util.TestUtil;
-
-import jakarta.annotation.PostConstruct;
-import jakarta.annotation.Resource;
-import jakarta.ejb.EJBException;
-import jakarta.ejb.PostActivate;
-import jakarta.ejb.PrePassivate;
-import jakarta.ejb.Remote;
-import jakarta.ejb.Remove;
-import jakarta.ejb.SessionContext;
-import jakarta.ejb.Stateful;
-import jakarta.jms.Connection;
-import jakarta.jms.ConnectionFactory;
-import jakarta.jms.Destination;
-import jakarta.jms.MessageProducer;
-import jakarta.jms.Session;
-import jakarta.jms.TextMessage;
-import jakarta.jms.Topic;
-import jakarta.jms.TopicSubscriber;
-
-@Stateful
-@Remote(TestsT.class)
-public class TestsTEJB implements TestsT {
-
- @Resource
- private SessionContext sessionContext;
-
- private Properties harnessProps = null;
-
- private TSNamingContext nctx = null;
-
- private transient Destination testDestination = null;
-
- private transient ConnectionFactory cf = null;
-
- private transient Connection conn = null;
-
- private transient Connection connr = null;
-
- private static final String TESTTOPICNAME = "java:comp/env/jms/MY_TOPIC";
-
- private static final String DURABLETOPICCONNECTIONFACTORY = "java:comp/env/jms/DURABLE_SUB_CONNECTION_FACTORY";
-
- private String name = "ctssub";
-
- private String username = null;
-
- private String password = null;
-
- private long timeout;
-
- public TestsTEJB() {
- TestUtil.logTrace("TestsTEJB => default constructor called");
- }
-
- public void initLogging(Properties p) {
- TestUtil.logTrace("initLogging");
- harnessProps = p;
- try {
- TestUtil.logMsg("initialize remote logging");
- TestUtil.init(p);
- timeout = Long.parseLong(TestUtil.getProperty(harnessProps, "jms_timeout"));
- username = TestUtil.getProperty(harnessProps, "user");
- password = TestUtil.getProperty(harnessProps, "password");
- // check props for errors
- if (timeout < 1) {
- throw new EJBException(
- "'jms_timeout' (milliseconds) in ts.jte must be > 0");
- }
- if (username == null) {
- throw new EJBException("'user' in ts.jte must be null");
- }
- if (password == null) {
- throw new EJBException("'password' in ts.jte must be null");
- }
- if (sessionContext == null) {
- throw new EJBException("@Resource injection failed");
- }
- } catch (RemoteLoggingInitException e) {
- TestUtil.printStackTrace(e);
- throw new EJBException("initLogging: Failed!", e);
- }
- }
-
- @PostConstruct
- public void postConstruct() {
- TestUtil.logTrace("postConstruct");
- try {
- TestUtil.logMsg("obtain naming context");
- nctx = new TSNamingContext();
- } catch (Exception e) {
- TestUtil.printStackTrace(e);
- throw new EJBException("unable to obtain naming context");
- }
- }
-
- @PostActivate
- public void activate() {
- TestUtil.logTrace("activate");
- try {
- TestUtil.logTrace(
- "Getting ConnectionFactory " + DURABLETOPICCONNECTIONFACTORY);
- cf = (ConnectionFactory) nctx.lookup(DURABLETOPICCONNECTIONFACTORY);
-
- TestUtil.logTrace("Getting Destination " + TESTTOPICNAME);
- testDestination = (Destination) nctx.lookup(TESTTOPICNAME);
-
- } catch (Exception ex) {
- TestUtil.logErr("Unexpected Exception in Activate: ", ex);
- }
- }
-
- @PrePassivate
- public void passivate() {
- TestUtil.logTrace("passivate");
- testDestination = null;
- cf = null;
- conn = null;
- connr = null;
- }
-
- @Remove
- public void remove() {
- TestUtil.logTrace("remove");
- }
-
- private void common_T() throws Exception {
-
- TestUtil
- .logTrace("Getting ConnectionFactory " + DURABLETOPICCONNECTIONFACTORY);
- cf = (ConnectionFactory) nctx.lookup(DURABLETOPICCONNECTIONFACTORY);
-
- TestUtil.logTrace("Getting Destination " + TESTTOPICNAME);
- testDestination = (Destination) nctx.lookup(TESTTOPICNAME);
-
- }
-
- public void common_T_setup() {
- try {
- common_T();
-
- connr = cf.createConnection(username, password);
-
- Session sessr = connr.createSession(true, Session.AUTO_ACKNOWLEDGE);
- TopicSubscriber recr = sessr
- .createDurableSubscriber((Topic) testDestination, name);
- recr.close();
- } catch (Exception el) {
- TestUtil.printStackTrace(el);
- TestUtil.logErr("Failed to set up Consumer for Topic", el);
- } finally {
- try {
- connr.close();
- } catch (Exception e) {
- TestUtil.logErr("Exception closing receiving Connection:", e);
- }
- }
- }
-
- public void sendTextMessage_CT(String TestName, String message) {
- try {
- // get ConnectionFactory and Connection
- common_T();
-
- // create default connection
- TestUtil.logTrace("Creating Connection with username, " + username
- + " password, " + password);
- conn = cf.createConnection(username, password);
- // create default Session
- TestUtil.logTrace("Creating Session");
- Session sess = conn.createSession(true, Session.AUTO_ACKNOWLEDGE);
-
- // create default consumer/producer
- TestUtil.logTrace("Creating messageProducer");
- MessageProducer sender = sess.createProducer(testDestination);
-
- TestUtil.logMsg("Creating 1 message");
- TextMessage messageSent = sess.createTextMessage();
- messageSent.setText(message);
- messageSent.setStringProperty("COM_SUN_JMS_TESTNAME", TestName);
- TestUtil.logMsg("Sending message");
- sender.send(messageSent);
- sender.close();
-
- } catch (Exception e) {
- TestUtil.logErr("Failed to send a Message in sendTextMessage_CQ");
- TestUtil.printStackTrace(e);
- } finally {
- if (conn != null) {
- try {
- TestUtil.logTrace("Closing Connection in sendTextMessage_CT");
- conn.close();
- } catch (Exception ce) {
- TestUtil.logErr(
- "Error closing conn in sendTextMessage_CQ" + ce.getMessage(), ce);
- }
- }
- }
- }
-
- public String receiveTextMessage_CT() {
- TextMessage receivedM = null;
- String tmp = null;
-
- try {
- // create default connection
- TestUtil.logTrace("Creating Connection with username, " + username
- + " password, " + password);
- connr = cf.createConnection(username, password);
-
- connr.start();
- Session sessr = connr.createSession(true, Session.AUTO_ACKNOWLEDGE);
- TopicSubscriber recr = sessr
- .createDurableSubscriber((Topic) testDestination, name);
- receivedM = (TextMessage) recr.receive(timeout);
- recr.close();
-
- if (receivedM != null)
- tmp = receivedM.getText();
- else
- return null;
- } catch (Exception e) {
- TestUtil.logErr("Failed to receive a message in receiveTextMessage_CT: ",
- e);
- throw new EJBException(e);
- } finally {
- if (connr != null) {
- try {
- TestUtil.logTrace("Closing Connection in receiveTextMessage_CT");
- connr.close();
- } catch (Exception ce) {
- TestUtil.logErr(
- "Error closing conn in receiveTextMessage_CT" + ce.getMessage(),
- ce);
- }
- }
- }
- return tmp;
- }
-}
diff --git a/common/src/main/java/com/sun/ts/tests/servlet/common/client/AbstractUrlClient.java b/common/src/main/java/com/sun/ts/tests/servlet/common/client/AbstractUrlClient.java
deleted file mode 100644
index 50281866ab..0000000000
--- a/common/src/main/java/com/sun/ts/tests/servlet/common/client/AbstractUrlClient.java
+++ /dev/null
@@ -1,257 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.servlet.common.client;
-
-import com.sun.ts.tests.common.webclient.BaseUrlClient;
-import com.sun.ts.tests.common.webclient.http.HttpRequest;
-import com.sun.ts.tests.common.webclient.WebTestCase;
-import com.sun.ts.tests.servlet.common.util.Data;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.net.UnknownHostException;
-
-/**
- * Base client for Servlet tests.
- */
-
-public abstract class AbstractUrlClient extends BaseUrlClient {
-
- protected final Logger logger = LoggerFactory.getLogger(getClass());
-
- protected static final String APITEST = "apitest";
-
- protected static final String DONOTUSEServletName = "NoServletName";
-
- private InetAddress[] _addrs = null;
-
- private String _servlet = null;
-
- protected AbstractUrlClient() {
- // Construct a default context root based on the class name of
- // the concrete subclass of this class.
- String cname = this.getClass().getName();
- String prefix = "com.sun.ts.tests.";
- if (cname.startsWith(prefix))
- cname = cname.substring(prefix.length());
- String suffix = ".URLClient";
- if (cname.endsWith(suffix))
- cname = cname.substring(0, cname.length() - suffix.length());
- cname = cname.replace('.', '_');
- cname = "/" + cname + "_web";
- setContextRoot(cname);
- }
-
- protected void setTestProperties(WebTestCase testCase) {
- setStandardProperties(TEST_PROPS.getProperty(STANDARD), testCase);
- setApiTestProperties(TEST_PROPS.getProperty(APITEST), testCase);
- super.setTestProperties(testCase);
- }
-
- /**
- * Sets the request, testname, and a search string for test passed. A search
- * is also added for test failure. If found, the test will fail.
- *
- * @param testValue
- * - a logical test identifier
- * @param testCase
- * - the current test case
- */
- private void setApiTestProperties(String testValue, WebTestCase testCase) {
- if (testValue == null) {
- return;
- }
-
- // An API test consists of a request with a request parameter of
- // testname, a search string of Test PASSED, and a logical test name.
-
- // set the testname
- _testName = testValue;
-
- // set the request
- StringBuilder sb = new StringBuilder(50);
- if ((_servlet != null)
- && (TEST_PROPS.getProperty(DONOTUSEServletName) == null)) {
- sb.append(GET).append(_contextRoot).append(SL);
- sb.append(_servlet).append("?testname=").append(testValue);
- sb.append(HTTP11);
- } else {
- sb.append(GET).append(_contextRoot).append(SL);
- sb.append(testValue).append(HTTP10);
- }
- logger.debug("REQUEST LINE: {}", sb);
-
- HttpRequest req = new HttpRequest(sb.toString(), _hostname, _port);
- testCase.setRequest(req);
-
- if ((TEST_PROPS.getProperty(SEARCH_STRING) == null)
- || ((TEST_PROPS.getProperty(SEARCH_STRING)).equals(""))) {
- testCase.setResponseSearchString(Data.PASSED);
- testCase.setUnexpectedResponseSearchString(Data.FAILED);
- }
-
- }
-
- /**
- * Consists of a test name, a request, and a goldenfile.
- *
- * @param testValue
- * - a logical test identifier
- * @param testCase
- * - the current test case
- */
- private void setStandardProperties(String testValue, WebTestCase testCase) {
-
- if (testValue == null) {
- return;
- }
- // A standard test sets consists of a testname
- // a request, and a goldenfile. The URI is not used
- // in this case since the JSP's are assumed to be located
- // at the top of the contextRoot
- StringBuffer sb = new StringBuffer(50);
-
- // set the testname
- _testName = testValue;
-
- // set the request
- // sb.append(GET).append(_contextRoot).append(SL);
- // sb.append(testValue).append(JSP_SUFFIX).append(HTTP10);
- // setRequest(sb.toString());
- // HttpRequest req = new HttpRequest(sb.toString(), _hostname, _port);
- // testCase.setRequest(req);
-
- if (_servlet != null) {
- sb.append(GET).append(_contextRoot).append(SL);
- sb.append(_servlet).append("?testname=").append(testValue);
- sb.append(HTTP11);
- } else {
- sb.append(GET).append(_contextRoot).append(SL);
- sb.append(testValue).append(HTTP10);
- }
- logger.debug("REQUEST LINE: {}", sb);
- HttpRequest req = new HttpRequest(sb.toString(), _hostname, _port);
- testCase.setRequest(req);
- }
-
- /**
- * Sets the name of the servlet to use when building a request for a single
- * servlet API test.
- *
- * @param servlet
- * - the name of the servlet
- */
- protected void setServletName(String servlet) {
- _servlet = servlet;
- }
-
- protected String getServletName() {
- return _servlet;
- }
-
- protected String getLocalInterfaceInfo(boolean returnAddresses) {
- String result = null;
- initInetAddress();
- if (_addrs.length != 0) {
- StringBuilder sb = new StringBuilder(32);
- if (!returnAddresses) {
- // localhost might not show up if aliased
- sb.append("localhost,");
- } else {
- // add 127.0.0.1
- sb.append("127.0.0.1,");
- }
-
- for (int i = 0; i < _addrs.length; i++) {
- if (returnAddresses) {
- String ip = _addrs[i].getHostAddress();
- if (!ip.equals("127.0.0.1")) {
- if (ip.contains("%")) {
- int scope_id = ip.indexOf("%");
- ip = ip.substring(0, scope_id);
- }
- sb.append(ip);
- }
- } else {
- String host = _addrs[i].getCanonicalHostName();
- if (!host.equals("localhost")) {
- sb.append(host);
- }
- }
- if (i + 1 != _addrs.length) {
- sb.append(",");
- }
- }
- result = sb.toString();
- logger.trace("[AbstractUrlClient] Interface info: {}", result);
- }
- return result;
- }
-
- private void initInetAddress() {
- if (_addrs == null) {
- try {
- _addrs = InetAddress
- .getAllByName(InetAddress.getLocalHost().getCanonicalHostName());
- } catch (UnknownHostException uhe) {
- logger.info(
- "[AbstractUrlClient][WARNING] Unable to obtain local host information.");
- }
- }
- }
-
- protected String getRequest(String rq) {
- return rq;
- }
-
- protected String getURLString(String protocol, String hostname, int portnum, String sContext) {
- return protocol + "://" + hostname + ":" + portnum + "/" + sContext;
- }
-
- protected URL getURL(String protocol, String hostname, int portnum, String sContext) throws MalformedURLException {
- return new URL(protocol + "://" + hostname + ":" + portnum + "/" + sContext);
- }
-
-
- public URLConnection getHttpsURLConnection(URL newURL)
- throws IOException {
- // open HttpsURLConnection using TSHttpsURLConnection
- URLConnection httpsURLConn = null;
-
- httpsURLConn = newURL.openConnection();
- if (httpsURLConn != null) {
- httpsURLConn.setDoInput(true);
- httpsURLConn.setDoOutput(true);
- httpsURLConn.setUseCaches(false);
-
- } else
- throw new IOException("Error opening httsURLConnection");
-
- return httpsURLConn;
- }
-
-}
-
diff --git a/common/src/main/java/com/sun/ts/tests/servlet/common/util/ServletTestUtil.java b/common/src/main/java/com/sun/ts/tests/servlet/common/util/ServletTestUtil.java
deleted file mode 100644
index 33638dbabd..0000000000
--- a/common/src/main/java/com/sun/ts/tests/servlet/common/util/ServletTestUtil.java
+++ /dev/null
@@ -1,375 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 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
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.servlet.common.util;
-
-import jakarta.servlet.ServletOutputStream;
-import jakarta.servlet.http.Cookie;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.NoSuchElementException;
-import java.util.StringTokenizer;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-/**
- * A set of useful utility methods to help perform test functions.
- */
-public class ServletTestUtil {
-
- private static Logger LOGGER = LoggerFactory.getLogger(ServletTestUtil.class);
-
- /**
- * Private as this class contains only public static methods.
- */
- private ServletTestUtil() {
- }
-
- /**
- * Compares the String values in an Enumeration against the provides String
- * array of values. The number of elements in the enumeration must be the same
- * as the size of the array, or false will be returned. False will also be
- * returned if the provided Enumeration or String array is null.
- *
- * If all values are found, true will be returned.
- *
- * Note: This method isn't concerned with the presence of duplicate
- * values contained in the enumeration.
- *
- * The comparison is performed in a case sensitive manner.
- *
- * @param e
- * - Enumeration to validate
- * @param values
- * - the values expected to be found in the Enumeration
- *
- * @return true if all the expected values are found, otherwise false.
- */
- public static boolean checkEnumeration(Enumeration e, String[] values) {
- return checkEnumeration(e, values, true, true);
- }
-
- /**
- * Compares the String values in an Enumeration against the provides String
- * array of values. The number of elements in the enumeration must be the same
- * as the size of the array, or false will be returned. False will also be
- * returned if the provided Enumeration or String array is null.
- *
- * If all values are found, true will be returned.
- *
- * Note: This method isn't concerned with the presence of duplicate
- * values contained in the enumeration.
- *
- * The comparison is performed in a case sensitive manner.
- *
- * @param e
- * - Enumeration to validate
- * @param values
- * - the values expected to be found in the Enumeration
- * @param enforceSizes
- * - ensures that the number of elements in the Enumeration matches
- * the number of elements in the array of values
- * @param allowDuplicates
- * - If true, the method will true if duplicate elements are found in
- * the Enumeration, if false, then false will be return if duplicate
- * elements have been found.
- *
- * @return true if all the expected values are found, otherwise false.
- */
- public static boolean checkEnumeration(Enumeration> e, String[] values,
- boolean enforceSizes, boolean allowDuplicates) {
- List