[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:55 EDT 2008
Update of /home/repository/moby/moby-live/Java/src/test/java/org/biomoby/shared/parser
In directory dev.open-bio.org:/tmp/cvs-serv11933/src/test/java/org/biomoby/shared/parser

Modified Files:
	MobyParserTest.java 
Log Message:

moby-live/Java/src/test/java/org/biomoby/shared/parser MobyParserTest.java,1.4,1.5
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/test/java/org/biomoby/shared/parser/MobyParserTest.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- /home/repository/moby/moby-live/Java/src/test/java/org/biomoby/shared/parser/MobyParserTest.java	2008/03/03 11:34:17	1.4
+++ /home/repository/moby/moby-live/Java/src/test/java/org/biomoby/shared/parser/MobyParserTest.java	2008/03/15 13:10:55	1.5
@@ -216,14 +216,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 (MobyParserTest.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.shared.parser.MobyParserTest");
+	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