Skip to content

Commit

Permalink
Merge pull request #141 from eclipse-ee4j/issue139
Browse files Browse the repository at this point in the history
Fix the way the envp was passed to the appclient process
  • Loading branch information
starksm64 authored Sep 5, 2024
2 parents 24c189a + bf59506 commit f39b2ff
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -140,17 +143,8 @@ public String[] clientEnvAsArray() {
String[] envp = null;
if (clientEnvString != null) {
ArrayList<String> tmp = new ArrayList<String>();
// 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -47,6 +52,7 @@ public class TsTestPropsBuilder {
"log.file.location",
"logical.hostname.servlet",
"longvarbinarySize",
"mailuser1",
"org.omg.CORBA.ORBClass",
"password",
"platform.mode",
Expand All @@ -68,20 +74,27 @@ public class TsTestPropsBuilder {
"rauser2",
"securedWebServicePort",
"sigTestClasspath",
"smtp.port",
"transport_protocol",
"ts_home",
"user",
"user1",
"varbinarySize",
"vehicle_ear_name",
"webServerHost",
"webServerPort",
"whitebox-anno_no_md",
"whitebox-mdcomplete",
"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",
};

Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<TestMethodInfo> 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());
}
}

0 comments on commit f39b2ff

Please sign in to comment.