incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From liu...@apache.org
Subject svn commit: r1386514 - in /incubator/ooo/trunk/test/testcommon/source/org/openoffice/test: Run.java common/FileUtil.java common/Installer.java
Date Mon, 17 Sep 2012 08:49:14 GMT
Author: liuzhe
Date: Mon Sep 17 08:49:14 2012
New Revision: 1386514

URL: http://svn.apache.org/viewvc?rev=1386514&view=rev
Log:
#120987 - Enable test automation framework to group test cases. Part 1

Modified:
    incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/Run.java
    incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/FileUtil.java
    incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/Installer.java

Modified: incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/Run.java
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/Run.java?rev=1386514&r1=1386513&r2=1386514&view=diff
==============================================================================
--- incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/Run.java (original)
+++ incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/Run.java Mon Sep 17 08:49:14
2012
@@ -62,7 +62,13 @@ public class Run {
 	public static void main(String... args) {
 		ArrayList<String> runnableClasses = new ArrayList<String>();
 		ArrayList<String> listenerClasses = new ArrayList<String>();
+		
+		ArrayList<String> tcs = new ArrayList<String>();
+		ArrayList<String> tps = new ArrayList<String>();
+		ArrayList<String> tms = new ArrayList<String>();
+		
 		List<NamedRequest> requests = new ArrayList<NamedRequest>();
+		
 		for (int i = 0; i < args.length; i++) {
 			String arg = args[i];
 			if ("-help".equals(arg)) {
@@ -88,18 +94,15 @@ public class Run {
 			} else if (arg.equals("-tc")) {
 				if (++i >= args.length)
 					printUsage("Invalid arguments", 1);
-				NamedRequest request = NamedRequest.tc(args[i]);
-				addRequest(requests, request);
+				tcs.add(args[i]);
 			} else if (arg.equals("-tp")) {
 				if (++i >= args.length)
 					printUsage("Invalid arguments", 1);
-				NamedRequest request = NamedRequest.tp(args[i]);
-				addRequest(requests, request);
+				tps.add(args[i]);
 			} else if (arg.equals("-tm")) {
 				if (++i >= args.length)
 					printUsage("Invalid arguments", 1);
-				NamedRequest request = NamedRequest.tm(args[i]);
-				addRequest(requests, request);
+				tms.add(args[i]);
 			}
 		}
 		
@@ -114,8 +117,6 @@ public class Run {
 		}
 		
 		JUnitCore core = new JUnitCore();
-//		core.addListener(new XMLReporter());
-//		core.addListener(new CSVReporter());
 		for (String l : listenerClasses)  {
 			try {
 				core.addListener((RunListener) Class.forName(l).newInstance());
@@ -125,6 +126,21 @@ public class Run {
 			}
 		}
 		
+		for (String s : tcs) {
+			NamedRequest request = NamedRequest.tc(s);
+			addRequest(requests, request);
+		}
+		
+		for (String s : tps) {
+			NamedRequest request = NamedRequest.tp(s);
+			addRequest(requests, request);
+		}
+		
+		for (String s : tms) {
+			NamedRequest request = NamedRequest.tm(s);
+			addRequest(requests, request);
+		}
+		
 		int code = 0;
 		for (NamedRequest request : requests) {
 			Result result = core.run(request.getRunner());

Modified: incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/FileUtil.java
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/FileUtil.java?rev=1386514&r1=1386513&r2=1386514&view=diff
==============================================================================
--- incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/FileUtil.java (original)
+++ incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/FileUtil.java Mon
Sep 17 08:49:14 2012
@@ -700,6 +700,8 @@ public class FileUtil {
      * @return
      */
     public static boolean fileExists(String file) {
+    	if (file == null)
+    		return false;
     	return new File(file).exists();
     }
    

Modified: incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/Installer.java
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/Installer.java?rev=1386514&r1=1386513&r2=1386514&view=diff
==============================================================================
--- incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/Installer.java (original)
+++ incubator/ooo/trunk/test/testcommon/source/org/openoffice/test/common/Installer.java Mon
Sep 17 08:49:14 2012
@@ -22,6 +22,9 @@ package org.openoffice.test.common;
 
 import java.io.File;
 import java.io.IOException;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URLClassLoader;
 import java.text.MessageFormat;
 import java.util.logging.Level;
 
@@ -103,8 +106,37 @@ public class Installer implements Runnab
 				FileUtil.deleteFile(installTempDir);
 			}
 		}
+		
+		 prop = System.getProperty("openoffice.home");
+		 if (!FileUtil.fileExists(prop)) {
+			 throw new RuntimeException("No OpenOffice is found!");
+		 }
+		 
+		 String[] jars = {"juh.jar", "unoil.jar", "ridl.jar", "jurt.jar"};
+		 for (String jar : jars) {
+			 File file = FileUtil.findFile(prop, jar);
+			 if (file != null)
+				 addToClassPath(file);
+		 }
+		
 	}
 
+	public static boolean addToClassPath(File file) {
+		try {
+			URL url = file.toURI().toURL();
+			System.out.println(url);
+			URLClassLoader classLoader = (URLClassLoader) ClassLoader.getSystemClassLoader();
+			Method method = URLClassLoader.class.getDeclaredMethod("addURL", new Class[] { URL.class
});
+			method.setAccessible(true);
+			method.invoke(classLoader, new Object[] { url });
+			return true;
+		} catch (Throwable t) {
+			t.printStackTrace();
+		}
+
+		return false;
+	}
+	
 	public static void main(String... args) {
 		new Installer().run();
 	}



Mime
View raw message