Author: lewismc
Date: Sun Jun 30 19:35:57 2013
New Revision: 1498172
URL: http://svn.apache.org/r1498172
Log:
trivial update to test driver to remove generated test index directory
Modified:
gora/trunk/gora-solr/src/test/java/org/apache/gora/solr/GoraSolrTestDriver.java
Modified:
gora/trunk/gora-solr/src/test/java/org/apache/gora/solr/GoraSolrTestDriver.java
URL:
http://svn.apache.org/viewvc/gora/trunk/gora-solr/src/test/java/org/apache/gora/solr/GoraSolrTestDriver.java?rev=1498172&r1=1498171&r2=1498172&view=diff
==============================================================================
---
gora/trunk/gora-solr/src/test/java/org/apache/gora/solr/GoraSolrTestDriver.java
(original)
+++
gora/trunk/gora-solr/src/test/java/org/apache/gora/solr/GoraSolrTestDriver.java
Sun Jun 30 19:35:57 2013
@@ -17,8 +17,10 @@
*/
package org.apache.gora.solr;
+import java.io.File;
import java.util.Properties;
+import org.apache.commons.io.FileUtils;
import org.apache.gora.GoraTestDriver;
import org.apache.gora.solr.store.SolrStore;
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
@@ -44,8 +46,44 @@ public class GoraSolrTestDriver extends
solr.stop();
solr = null;
}
+ cleanupDirectoriesFailover();
}
+ /**
+ * Simply cleans up Solr's output from the Unit tests.
+ * In the case of a failure, it waits 250 msecs and tries again, 3 times in
total.
+ */
+ public void cleanupDirectoriesFailover() {
+ int tries = 3;
+ while (tries-- > 0) {
+ try {
+ cleanupDirectories();
+ break;
+ } catch (Exception e) {
+ //ignore exception
+ try {
+ Thread.sleep(250);
+ } catch (InterruptedException e1) {
+ //ignore exception
+ }
+ }
+ }
+ }
+
+ /**
+ * Cleans up Solr's temp base directory.
+ *
+ * @throws Exception
+ * if an error occurs
+ */
+ public void cleanupDirectories() throws Exception {
+ File dirFile = new File("solr");
+ if (dirFile.exists()) {
+ FileUtils.deleteDirectory(dirFile);
+ }
+ }
+
+
@Override
protected void setProperties(Properties properties) {
// TODO Auto-generated method stub