jcscoobyrs 2005/10/11 13:18:59
Modified: modules/itests/src/java/org/openejb/test TestRunner.java
RemoteTestServer.java TestManager.java
Log:
Updated for new launching concept. Removed all unused scripts, all
unecessary text files and all references to unused code, like Corba. All
scripts have been updated to use the new launch concept. Scripts could be
refactored a bit to utilize the new launcher a bit better but for flow control,
the scripts have been kept as-is in this respect.
Revision Changes Path
1.2 +190 -71
openejb1/modules/itests/src/java/org/openejb/test/TestRunner.java
Index: TestRunner.java
===================================================================
RCS file:
/scm/openejb/openejb1/modules/itests/src/java/org/openejb/test/TestRunner.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TestRunner.java 26 Mar 2004 21:43:14 -0000 1.1
+++ TestRunner.java 11 Oct 2005 17:18:59 -0000 1.2
@@ -44,83 +44,202 @@
*/
package org.openejb.test;
+import java.io.File;
+import java.io.InputStream;
+import java.io.OutputStream;
import java.io.PrintStream;
+import java.net.URL;
+import java.util.Properties;
import junit.framework.TestResult;
+import org.openejb.util.JarUtils;
+
/**
- *
+ *
* @author <a href="mailto:[EMAIL PROTECTED]">David Blevins</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Richard Monson-Haefel</a>
*/
public class TestRunner extends junit.textui.TestRunner {
-
- /**
- * Constructs a TestRunner.
- */
- public TestRunner() {
- this(System.out);
- }
-
- /**
- * Constructs a TestRunner using the given stream for all the output
- */
- public TestRunner(PrintStream writer) {
- this(new ResultPrinter(writer));
- }
-
- /**
- * Constructs a TestRunner using the given ResultPrinter all the output
- */
- public TestRunner(ResultPrinter printer) {
- super(printer);
- }
-
- /**
- * main entry point.
- */
- public static void main(String args[]) {
-
- try {
-// org.openejb.util.ClasspathUtils.addJarsToPath("lib");
-// org.openejb.util.ClasspathUtils.addJarsToPath("dist");
-// org.openejb.util.ClasspathUtils.addJarsToPath("beans");
-
- TestRunner aTestRunner= new TestRunner();
- TestResult r = aTestRunner.start(args);
- if (!r.wasSuccessful()) System.exit(FAILURE_EXIT);
- System.exit(SUCCESS_EXIT);
- } catch (Exception e) {
- System.err.println(e.getMessage());
- System.exit(EXCEPTION_EXIT);
- }
- }
-
-
- public TestResult start(String args[]) throws Exception {
- TestResult result = null;
- try {
-
- TestManager.init(null);
- TestManager.start();
- } catch (Exception e) {
- System.out.println("Cannot initialize the test environment: " +
e.getClass().getName() + " " + e.getMessage());
- //e.printStackTrace();
- //System.exit(-1);
- throw e;
- }
-
- try {
- result = super.start(args);
- } catch (Exception ex) {
- } finally {
- try {
- TestManager.stop();
- } catch (Exception e) {
- ; // ignore it
- }
- }
- //System.exit(0);
- return result;
- }
+ private static final String helpBase = "META-INF/org.openejb.cli/";
+
+ /**
+ * Constructs a TestRunner.
+ */
+ public TestRunner() {
+ this(System.out);
+ }
+
+ /**
+ * Constructs a TestRunner using the given stream for all the output
+ */
+ public TestRunner(PrintStream writer) {
+ this(new ResultPrinter(writer));
+ }
+
+ /**
+ * Constructs a TestRunner using the given ResultPrinter all the output
+ */
+ public TestRunner(ResultPrinter printer) {
+ super(printer);
+ }
+
+ /**
+ * main entry point.
+ */
+ public static void main(String args[]) {
+ if (args.length == 0) {
+ printHelp();
+ } else {
+ if (args[0].equals("--help")) {
+ printHelp();
+
+ return;
+ } else if (args[0].equals("local")) {
+ runLocalTests();
+ } else if (args[0].equals("remote")) {
+ runRemoteTests();
+ } else {
+ printHelp();
+
+ return;
+ }
+
+ try {
+ TestRunner aTestRunner = new TestRunner();
+ TestResult r = aTestRunner
+ .start(new String[] {
"org.openejb.test.ClientTestSuite" });
+ if (!r.wasSuccessful())
+ System.exit(FAILURE_EXIT);
+ System.exit(SUCCESS_EXIT);
+ } catch (Exception e) {
+ System.err.println(e.getMessage());
+ System.exit(EXCEPTION_EXIT);
+ }
+ }
+ }
+
+ private static void runLocalTests() {
+ System.setProperty("openejb.test.server",
+ "org.openejb.test.IvmTestServer");
+ System.setProperty("openejb.test.database",
+ "org.openejb.test.InstantDbTestDatabase");
+
+
System.out.println("_________________________________________________");
+ System.out
+
.println("|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|\n");
+ System.out.println("Running EJB compliance tests on IntraVM
Server");
+
System.out.println("_________________________________________________");
+ }
+
+ private static void runRemoteTests() {
+ System.setProperty("openejb.test.server",
+ "org.openejb.test.RemoteTestServer");
+ System.setProperty("openejb.test.database",
+ "org.openejb.test.InstantDbTestDatabase");
+
+
System.out.println("_________________________________________________");
+ System.out
+
.println("|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|\n");
+ System.out.println("Running EJB compliance tests on Remote
Server");
+
System.out.println("_________________________________________________");
+ }
+
+ private static void printHelp() {
+ String header = "OpenEJB Compliance Tests ";
+ try {
+ JarUtils.setHandlerSystemProperty();
+ Properties versionInfo = new Properties();
+ versionInfo.load(new
URL("resource:/openejb-version.properties")
+ .openConnection().getInputStream());
+ header += versionInfo.get("version");
+ } catch (java.io.IOException e) {
+ }
+
+ System.out.println(header);
+
+ // Internationalize this
+ try {
+ InputStream in =
Thread.currentThread().getContextClassLoader()
+ .getResource(helpBase +
"test.help").openConnection()
+ .getInputStream();
+
+ int b = in.read();
+ while (b != -1) {
+ System.out.write(b);
+ b = in.read();
+ }
+ } catch (java.io.IOException e) {
+ }
+ }
+
+ public TestResult start(String args[]) throws Exception {
+ TestResult result = null;
+ try {
+
+ TestManager.init(null);
+ TestManager.start();
+ } catch (Exception e) {
+ System.out.println("Cannot initialize the test
environment: "
+ + e.getClass().getName() + " " +
e.getMessage());
+ // e.printStackTrace();
+ // System.exit(-1);
+ throw e;
+ }
+
+ try {
+ result = super.start(args);
+ } catch (Exception ex) {
+ } finally {
+ try {
+ TestManager.stop();
+ } catch (Exception e) {
+ ; // ignore it
+ }
+ }
+ // System.exit(0);
+ return result;
+ }
+
+ private static final class Pipe implements Runnable {
+
+ private final InputStream is;
+
+ private final OutputStream out;
+
+ private Pipe(InputStream is, OutputStream out) {
+
+ super();
+
+ this.is = is;
+
+ this.out = out;
+
+ }
+
+ public void run() {
+
+ try {
+
+ int i = is.read();
+
+ out.write(i);
+
+ while (i != -1) {
+
+ i = is.read();
+
+ out.write(i);
+
+ }
+
+ } catch (Exception e) {
+
+ e.printStackTrace();
+
+ }
+
+ }
+
+ }
}
1.3 +72 -4
openejb1/modules/itests/src/java/org/openejb/test/RemoteTestServer.java
Index: RemoteTestServer.java
===================================================================
RCS file:
/scm/openejb/openejb1/modules/itests/src/java/org/openejb/test/RemoteTestServer.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- RemoteTestServer.java 16 Jun 2005 22:29:53 -0000 1.2
+++ RemoteTestServer.java 11 Oct 2005 17:18:59 -0000 1.3
@@ -44,14 +44,17 @@
*/
package org.openejb.test;
+import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
+import java.net.URL;
import java.util.Properties;
-import org.openejb.util.Launcher;
+import org.openejb.util.JarUtils;
/**
*
@@ -90,8 +93,30 @@
try{
System.out.println("[] START SERVER");
serverHasAlreadyBeenStarted = false;
- Launcher.main(new
String[]{"-nowait","org.openejb.server.Main"});
- //oldStart();
+ String version = null;
+
+ JarUtils.setHandlerSystemProperty();
+ Properties versionInfo = new Properties();
+ versionInfo.load( new URL(
"resource:/openejb-version.properties" ).openConnection().getInputStream() );
+ version = (String)versionInfo.get( "version" );
+
+ Process server = Runtime.getRuntime().exec("java -jar lib" +
File.separator + "openejb-core-" + version + ".jar start -nowait");
+
+ // Pipe the processes STDOUT to ours
+ InputStream out = server.getInputStream();
+ Thread serverOut = new Thread(new Pipe(out, System.out));
+
+ serverOut.setDaemon(true);
+ serverOut.start();
+
+
+
+ // Pipe the processes STDERR to ours
+ InputStream err = server.getErrorStream();
+ Thread serverErr = new Thread(new Pipe(err, System.err));
+
+ serverErr.setDaemon(true);
+ serverErr.start();
} catch (Exception e){
throw new RuntimeException("Cannot start the server.");
}
@@ -209,4 +234,47 @@
return true;
}
+ private static final class Pipe implements Runnable {
+
+
+
+ private final InputStream is;
+
+ private final OutputStream out;
+
+ private Pipe(InputStream is, OutputStream out) {
+
+ super();
+
+ this.is = is;
+
+ this.out = out;
+
+ }
+
+ public void run() {
+
+ try{
+
+ int i = is.read();
+
+ out.write( i );
+
+ while ( i != -1 ){
+
+ i = is.read();
+
+ out.write( i );
+
+ }
+
+ } catch (Exception e){
+
+ e.printStackTrace();
+
+ }
+
+ }
+
+ }
}
1.3 +2 -2
openejb1/modules/itests/src/java/org/openejb/test/TestManager.java
Index: TestManager.java
===================================================================
RCS file:
/scm/openejb/openejb1/modules/itests/src/java/org/openejb/test/TestManager.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TestManager.java 6 Jul 2005 02:04:04 -0000 1.2
+++ TestManager.java 11 Oct 2005 17:18:59 -0000 1.3
@@ -93,7 +93,7 @@
private static void initServer(Properties props){
try{
- String className =
(String)props.getProperty("openejb.test.server");
+ String className = props.getProperty("openejb.test.server");
if (className == null) throw new IllegalArgumentException("Must
specify a test server by setting its class name using the system property
\"openejb.test.server\"");
ClassLoader cl = getContextClassLoader();
Class testServerClass = Class.forName( className, true, cl );
@@ -108,7 +108,7 @@
private static void initDatabase(Properties props){
try{
- String className =
(String)props.getProperty("openejb.test.database");
+ String className = props.getProperty("openejb.test.database");
if (className == null) throw new IllegalArgumentException("Must
specify a test database by setting its class name using the system property
\"openejb.test.database\"");
ClassLoader cl = getContextClassLoader();
Class testDatabaseClass = Class.forName( className , true, cl);