You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by cu...@apache.org on 2001/12/19 18:37:36 UTC
cvs commit: xml-xalan/test/java/src/org/apache/qetest QetestUtils.java
curcuru 01/12/19 09:37:36
Modified: test/java/src/org/apache/qetest QetestUtils.java
Log:
Add new utility method getEnvironmentHash to wrap calling either
org.apache.env.Which or org.apache.xalan.xslt.EnvironmentCheck
Revision Changes Path
1.10 +55 -1 xml-xalan/test/java/src/org/apache/qetest/QetestUtils.java
Index: QetestUtils.java
===================================================================
RCS file: /home/cvs/xml-xalan/test/java/src/org/apache/qetest/QetestUtils.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- QetestUtils.java 2001/11/08 21:05:16 1.9
+++ QetestUtils.java 2001/12/19 17:37:36 1.10
@@ -59,6 +59,8 @@
import java.io.File;
import java.io.IOException;
+import java.lang.reflect.Method;
+import java.util.Hashtable;
/**
* Static utility class for both general-purpose testing methods
@@ -68,7 +70,7 @@
* line with a full or partial classname (in the org.apache.qetest
* area, obviously) and we'll load and execute that class instead.
* @author shane_curcuru@lotus.com
- * @version $Id: QetestUtils.java,v 1.9 2001/11/08 21:05:16 curcuru Exp $
+ * @version $Id: QetestUtils.java,v 1.10 2001/12/19 17:37:36 curcuru Exp $
*/
public abstract class QetestUtils
{
@@ -270,6 +272,58 @@
return formatter.format(new java.util.Date())+ ";" + baseId;
else
return formatter.format(new java.util.Date());
+ }
+
+
+ /**
+ * Utility method to get info about the environment.
+ *
+ * This is a simple way to get a Hashtable about the current
+ * JVM's environment from either Xalan's EnvironmentCheck
+ * utility or from org.apache.env.Which.
+ *
+ * @return Hashtable with info about the environment
+ */
+ public static Hashtable getEnvironmentHash()
+ {
+ Hashtable hash = new Hashtable();
+ // Attempt to use Which, which will be better supported
+ Class clazz = testClassForName("org.apache.env.Which", null, null);
+
+ try
+ {
+ if (null != clazz)
+ {
+ // Call Which's method to fill hash
+ final Class whichSignature[] =
+ { Hashtable.class, String.class, String.class };
+ Method which = clazz.getMethod("which", whichSignature);
+ String projects = "";
+ String options = "";
+ Object whichArgs[] = { hash, projects, options };
+ which.invoke(null, whichArgs);
+ }
+ else
+ {
+ // Use Xalan's EnvironmentCheck
+ clazz = testClassForName("org.apache.xalan.xslt.EnvironmentCheck", null, null);
+ if (null != clazz)
+ {
+ Object envCheck = clazz.newInstance();
+ final Class getSignature[] = { };
+ Method getHash = clazz.getMethod("getEnvironmentHash", getSignature);
+
+ Object getArgs[] = { }; // empty
+ hash = (Hashtable)getHash.invoke(envCheck, getArgs);
+ }
+ }
+ }
+ catch (Throwable t)
+ {
+ hash.put("FATAL-ERROR", "QetestUtils.getEnvironmentHash no services available; " + t.toString());
+ t.printStackTrace();
+ }
+ return hash;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org