[MOBY-guts] biomoby commit

Martin Senger senger at dev.open-bio.org
Sat Mar 15 13:10:55 UTC 2008


senger
Sat Mar 15 09:10:54 EDT 2008
Update of /home/repository/moby/moby-live/Java/src/test/java/org/biomoby/service
In directory dev.open-bio.org:/tmp/cvs-serv11933/src/test/java/org/biomoby/service

Modified Files:
	ServicesTest.java 
Log Message:

moby-live/Java/src/test/java/org/biomoby/service ServicesTest.java,1.1,1.2
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/test/java/org/biomoby/service/ServicesTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /home/repository/moby/moby-live/Java/src/test/java/org/biomoby/service/ServicesTest.java	2008/03/03 11:35:07	1.1
+++ /home/repository/moby/moby-live/Java/src/test/java/org/biomoby/service/ServicesTest.java	2008/03/15 13:10:54	1.2
@@ -190,14 +190,36 @@
      * This is to be able to run this JUnit 4 tests with a JUnit 3.x runner.
      **************************************************************************/
     public static junit.framework.Test suite() {
-        return new junit.framework.JUnit4TestAdapter (ServicesTest.class);
+        return new junit.framework.JUnit4TestAdapter (getThisClass());
     }
 
     /**************************************************************************
      * Run tests from the command line.
      **************************************************************************/
     public static void main (String args[]) {
-	org.junit.runner.JUnitCore.main ("org.biomoby.service.ServicesTest");
+	org.junit.runner.JUnitCore.main (getThisClassName());
+    }
+
+    /**************************************************************************
+     * Get the class (name) of this class (note that this is a static
+     * method). This madness is here just because I do not want to
+     * change the class name in the optional methods above when I copy
+     * and paste this into a new test file.
+     **************************************************************************/
+    private static String getThisClassName() {
+	Exception e = new Exception();
+	StackTraceElement[] sTrace = e.getStackTrace();
+	// sTrace[0] will be always there
+	return sTrace[0].getClassName();
+    }
+
+    private static Class getThisClass() {
+	try {
+	    return org.apache.commons.lang.ClassUtils.getClass (getThisClassName());
+	} catch (ClassNotFoundException e) {
+	    System.err.println ("Cannot get class name.");
+	    return java.lang.Object.class;
+	}
     }
 
 }




More information about the MOBY-guts mailing list