From bf59506a644b4194ce4528e6defe66465b46a8a3 Mon Sep 17 00:00:00 2001 From: Scott M Stark Date: Thu, 5 Sep 2024 05:45:57 -0600 Subject: [PATCH] Fix the way the envp was passed to the appclient process Add missing properties used by javamail Fixes #139 Signed-off-by: Scott M Stark --- .../protocol/appclient/AppClientCmd.java | 1 + .../AppClientProtocolConfiguration.java | 16 +++++----------- .../protocol/AppClientConfigTest.java | 10 +++++----- .../protocol/common/ProtocolCommonConfig.java | 4 ++++ .../protocol/common/TsTestPropsBuilder.java | 19 ++++++++++++++++++- .../jakarta/platform/ant/PackageTarget.java | 7 ++++--- .../ant/api/DeploymentMethodTest.java | 18 ++++++++++++++++++ 7 files changed, 55 insertions(+), 20 deletions(-) diff --git a/arquillian/appclient/src/main/java/tck/arquillian/protocol/appclient/AppClientCmd.java b/arquillian/appclient/src/main/java/tck/arquillian/protocol/appclient/AppClientCmd.java index 6de64c661..6528a195d 100644 --- a/arquillian/appclient/src/main/java/tck/arquillian/protocol/appclient/AppClientCmd.java +++ b/arquillian/appclient/src/main/java/tck/arquillian/protocol/appclient/AppClientCmd.java @@ -136,6 +136,7 @@ public void run(String vehicleArchiveName, String... additionalArgs) throws Exce appClientProcess = Runtime.getRuntime().exec(cmdLine, clientEnvp, clientDir); onExit = appClientProcess.onExit(); LOGGER.info("Created process" + appClientProcess.info()); + LOGGER.info("process(%d).envp: %s".formatted(appClientProcess.pid(), Arrays.toString(clientEnvp))); outputReader = new BufferedReader(new InputStreamReader(appClientProcess.getInputStream(), StandardCharsets.UTF_8)); errorReader = new BufferedReader(new InputStreamReader(appClientProcess.getErrorStream(), StandardCharsets.UTF_8)); diff --git a/arquillian/appclient/src/main/java/tck/arquillian/protocol/appclient/AppClientProtocolConfiguration.java b/arquillian/appclient/src/main/java/tck/arquillian/protocol/appclient/AppClientProtocolConfiguration.java index 3a2b1ebb0..467ea8107 100644 --- a/arquillian/appclient/src/main/java/tck/arquillian/protocol/appclient/AppClientProtocolConfiguration.java +++ b/arquillian/appclient/src/main/java/tck/arquillian/protocol/appclient/AppClientProtocolConfiguration.java @@ -43,6 +43,9 @@ public class AppClientProtocolConfiguration implements ProtocolConfiguration, Pr // harness.log.traceflag private boolean trace; + public boolean isAppClient() { + return true; + } public boolean isRunClient() { return runClient; } @@ -140,17 +143,8 @@ public String[] clientEnvAsArray() { String[] envp = null; if (clientEnvString != null) { ArrayList tmp = new ArrayList(); - // First split on the env1=value1 ; separator - String[] pairs = clientEnvString.trim().split(";"); - // Now parse env1=value1 by breaking on the first '=' - for (String pair : pairs) { - int idx = pair.indexOf('='); - String env = pair.substring(0, idx); - String value = pair.substring(idx + 1); - tmp.add(env); - tmp.add(value); - } - envp = tmp.toArray(new String[tmp.size()]); + // Split on the env1=value1 ; separator + envp = clientEnvString.trim().split(";"); } return envp; } diff --git a/arquillian/appclient/src/test/java/org/jboss/arquillian/protocol/AppClientConfigTest.java b/arquillian/appclient/src/test/java/org/jboss/arquillian/protocol/AppClientConfigTest.java index a6e1dd59f..5b73b4a76 100644 --- a/arquillian/appclient/src/test/java/org/jboss/arquillian/protocol/AppClientConfigTest.java +++ b/arquillian/appclient/src/test/java/org/jboss/arquillian/protocol/AppClientConfigTest.java @@ -49,12 +49,12 @@ public void testConfig1() throws Exception { Assert.assertEquals("/home/jakartaeetck/bin/xml/../../tmp/tstest.jte", args[1]); String[] envp = config.clientEnvAsArray(); - Assert.assertEquals(4, envp.length); - Assert.assertEquals("JAVA_OPTS", envp[0]); - Assert.assertEquals("-Djboss.modules.system.pkgs=com.sun.ts.lib,com.sun.javatest", envp[1]); - Assert.assertEquals("CLASSPATH", envp[2]); + Assert.assertEquals(2, envp.length); + Assert.assertTrue(envp[0].startsWith("JAVA_OPTS=")); + Assert.assertEquals("-Djboss.modules.system.pkgs=com.sun.ts.lib,com.sun.javatest", envp[0].substring(10)); + Assert.assertTrue(envp[1].startsWith("CLASSPATH=")); String expectedCP = "${project.build.directory}/appclient/javatest.jar:${project.build.directory}/appclient/libutil.jar:${project.build.directory}/appclient/libcommon.jar"; - Assert.assertEquals(expectedCP, envp[3]); + Assert.assertEquals(expectedCP, envp[1].substring(10)); File expectedDir = new File("."); Assert.assertEquals(expectedDir, config.clientDirAsFile()); } diff --git a/arquillian/common/src/main/java/tck/arquillian/protocol/common/ProtocolCommonConfig.java b/arquillian/common/src/main/java/tck/arquillian/protocol/common/ProtocolCommonConfig.java index 25d5b1bd0..3bf1a664d 100644 --- a/arquillian/common/src/main/java/tck/arquillian/protocol/common/ProtocolCommonConfig.java +++ b/arquillian/common/src/main/java/tck/arquillian/protocol/common/ProtocolCommonConfig.java @@ -1,6 +1,10 @@ package tck.arquillian.protocol.common; public interface ProtocolCommonConfig { + default boolean isAppClient() { + return false; + }; + public boolean isTrace(); public void setTrace(boolean trace); diff --git a/arquillian/common/src/main/java/tck/arquillian/protocol/common/TsTestPropsBuilder.java b/arquillian/common/src/main/java/tck/arquillian/protocol/common/TsTestPropsBuilder.java index aa94a6039..1e2eb1abf 100644 --- a/arquillian/common/src/main/java/tck/arquillian/protocol/common/TsTestPropsBuilder.java +++ b/arquillian/common/src/main/java/tck/arquillian/protocol/common/TsTestPropsBuilder.java @@ -36,8 +36,13 @@ public class TsTestPropsBuilder { "harness.log.traceflag", "harness.socket.retry.count", "harness.temp.directory", + "imap.port", + "iofile", "java.naming.factory.initial", + "javamail.mailbox", + "javamail.password", "javamail.protocol", + "javamail.root.path", "javamail.server", "javamail.username", "jdbc.db", @@ -47,6 +52,7 @@ public class TsTestPropsBuilder { "log.file.location", "logical.hostname.servlet", "longvarbinarySize", + "mailuser1", "org.omg.CORBA.ORBClass", "password", "platform.mode", @@ -68,10 +74,13 @@ public class TsTestPropsBuilder { "rauser2", "securedWebServicePort", "sigTestClasspath", + "smtp.port", + "transport_protocol", "ts_home", "user", "user1", "varbinarySize", + "vehicle_ear_name", "webServerHost", "webServerPort", "whitebox-anno_no_md", @@ -79,9 +88,13 @@ public class TsTestPropsBuilder { "whitebox-mixedmode", "whitebox-multianno", "whitebox-notx", + "whitebox-notx-param", "whitebox-permissiondd", "whitebox-tx", + "whitebox-tx-param", "whitebox-xa", + "whitebox-xa-param", + "work.dir", "ws_wait", }; @@ -147,7 +160,11 @@ public static String[] runArgs(ProtocolCommonConfig config, Deployment deploymen // The test specific properties file Properties props = new Properties(); // A property set by the TSScript class - props.setProperty("finder", "cts"); + if(vehicle.equals("ejb") && config.isAppClient()) { + props.setProperty("finder", "jck"); + } else { + props.setProperty("finder", "cts"); + } // Vehicle props.setProperty("service_eetest.vehicles", vehicle); props.setProperty("vehicle", vehicle); diff --git a/tools/tck-rewrite-ant/src/main/java/tck/jakarta/platform/ant/PackageTarget.java b/tools/tck-rewrite-ant/src/main/java/tck/jakarta/platform/ant/PackageTarget.java index 18921125d..532d8cf51 100644 --- a/tools/tck-rewrite-ant/src/main/java/tck/jakarta/platform/ant/PackageTarget.java +++ b/tools/tck-rewrite-ant/src/main/java/tck/jakarta/platform/ant/PackageTarget.java @@ -266,10 +266,11 @@ public BaseJar addTask(Task task) { } public BaseJar getTaskJar(String targetName) { BaseJar targetJar = switch (targetName) { - case "package.ejb.jar", "package_mdb1", "package_mdb2", "package.ejb.jar1", "package.ejb.jar2" -> ejbJarDef; - case "package.war" -> warDef; + case "package.ejb.jar", "package_mdb1", "package_mdb2", "package.ejb.jar1", "package.ejb.jar2", "make.ejb.jar" -> ejbJarDef; + case "package.war", "make.war" -> warDef; case "package.appclient.jar" -> clientJarDef; - case "package.ear", "ejb30 twojars import.package.ear" -> earDef; + case "package.ear", "ejb30 twojars import.package.ear", "make.ear" -> earDef; + case "makeTheRar" -> rarDef; case "add.sigtest", "build", "build.common.app", "build.common.apps", "build.nested.jar", "build.whitebox.jar", "compile", "pre.package", "-precompile", "-postcompile", "package" -> null; default -> { diff --git a/tools/tck-rewrite-ant/src/test/java/tck/conversion/ant/api/DeploymentMethodTest.java b/tools/tck-rewrite-ant/src/test/java/tck/conversion/ant/api/DeploymentMethodTest.java index 7edc318db..3f943d517 100644 --- a/tools/tck-rewrite-ant/src/test/java/tck/conversion/ant/api/DeploymentMethodTest.java +++ b/tools/tck-rewrite-ant/src/test/java/tck/conversion/ant/api/DeploymentMethodTest.java @@ -720,4 +720,22 @@ public void test_jpa_core_entitytest_persist_oneXmany() throws IOException { System.out.println("---- TestClientFiles ----"); System.out.println(packageInfo.getTestClientFiles()); } + + @Test + public void test_connector_resourceDefs_ejb() throws IOException { + TestPackageInfoBuilder builder = new TestPackageInfoBuilder(tsHome); + List testMethods = Arrays.asList( + new TestMethodInfo("ValidateGlobalResourceDef", "Exception"), + new TestMethodInfo("ValidateAppResourceDef", "Exception"), + new TestMethodInfo("ValidateModuleResourceDef", "Exception") + ); + Class baseTestClass = com.sun.ts.tests.connector.resourceDefs.ejb.Client.class; + TestPackageInfo packageInfo = builder.buildTestPackgeInfoEx(baseTestClass, testMethods, DefaultEEMapping.getInstance()); + System.out.println(packageInfo); + DeploymentInfo deploymentInfo = packageInfo.getTestClients().get(0).getTestDeployment().getDebugInfo(); + System.out.printf("Ejbs: %s\n", deploymentInfo.getEjbJar()); + + System.out.println("---- TestClientFiles ----"); + System.out.println(packageInfo.getTestClientFiles()); + } }