lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yo...@apache.org
Subject svn commit: r927833 - /lucene/dev/trunk/solr/src/test/org/apache/solr/SolrTestCaseJ4.java
Date Fri, 26 Mar 2010 13:14:13 GMT
Author: yonik
Date: Fri Mar 26 13:14:12 2010
New Revision: 927833

URL: http://svn.apache.org/viewvc?rev=927833&view=rev
Log:
tests: include classname in tmp dir names

Modified:
    lucene/dev/trunk/solr/src/test/org/apache/solr/SolrTestCaseJ4.java

Modified: lucene/dev/trunk/solr/src/test/org/apache/solr/SolrTestCaseJ4.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/test/org/apache/solr/SolrTestCaseJ4.java?rev=927833&r1=927832&r2=927833&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/test/org/apache/solr/SolrTestCaseJ4.java (original)
+++ lucene/dev/trunk/solr/src/test/org/apache/solr/SolrTestCaseJ4.java Fri Mar 26 13:14:12
2010
@@ -103,7 +103,22 @@ public class SolrTestCaseJ4 extends Luce
     ignoreException("ignore_exception");  // always ignore "ignore_exception"    
   }
 
+  protected static String getClassName() {
+    StackTraceElement[] stack = new RuntimeException("WhoAmI").fillInStackTrace().getStackTrace();
+    for (int i = stack.length-1; i>=0; i--) {
+      StackTraceElement ste = stack[i];
+      String cname = ste.getClassName();
+      if (cname.indexOf(".lucene.")>=0 || cname.indexOf(".solr.")>=0) {
+        return cname;
+      }
+    }
+    return SolrTestCaseJ4.class.getName();
+  }
 
+  protected static String getSimpleClassName() {
+    String cname = getClassName();
+    return cname.substring(cname.lastIndexOf('.')+1);
+  }
 
   protected static String configString;
   protected static String schemaString;
@@ -164,19 +179,24 @@ public class SolrTestCaseJ4 extends Luce
 
   private static String factoryProp;
 
+  public static void createTempDir() {
+    String cname = getSimpleClassName();
+    dataDir = new File(System.getProperty("java.io.tmpdir")
+            + System.getProperty("file.separator")
+            +"solrtest-" + cname + "-" + System.currentTimeMillis());
+    dataDir.mkdirs();
+  }
+
   public static void initCore() throws Exception {
     log.info("####initCore");
+
     ignoreException("ignore_exception");
     factoryProp = System.getProperty("solr.directoryFactory");
     if (factoryProp == null) {
       System.setProperty("solr.directoryFactory","solr.RAMDirectoryFactory");
     }
 
-    dataDir = new File(System.getProperty("java.io.tmpdir")
-            + System.getProperty("file.separator")
-    //        + getClass().getName() + "-" + System.currentTimeMillis());
-            + System.currentTimeMillis());
-    dataDir.mkdirs();
+    createTempDir();
 
     // other  methods like starting a jetty instance need these too
     System.setProperty("solr.test.sys.prop1", "propone");



Mime
View raw message