Author: sannegrinovero
Date: 2008-06-06 04:09:59 -0400 (Fri, 06 Jun 2008)
New Revision: 14746
Modified:
search/trunk/src/java/org/hibernate/search/store/FSDirectoryProvider.java
search/trunk/src/java/org/hibernate/search/store/FSMasterDirectoryProvider.java
search/trunk/src/java/org/hibernate/search/store/FSSlaveDirectoryProvider.java
search/trunk/src/test/org/hibernate/search/test/FSDirectoryTest.java
search/trunk/src/test/org/hibernate/search/test/analyzer/AnalyzerTest.java
search/trunk/src/test/org/hibernate/search/test/directoryProvider/FSSlaveAndMasterDPTest.java
search/trunk/src/test/org/hibernate/search/test/embedded/doubleinsert/DoubleInsertEmbeddedTest.java
search/trunk/src/test/org/hibernate/search/test/optimizer/OptimizerTestCase.java
search/trunk/src/test/org/hibernate/search/test/reader/ReaderPerfTestCase.java
search/trunk/src/test/org/hibernate/search/test/session/OptimizeTest.java
search/trunk/src/test/org/hibernate/search/test/shards/ShardsTest.java
search/trunk/src/test/org/hibernate/search/test/worker/ConcurrencyTest.java
search/trunk/src/test/org/hibernate/search/test/worker/WorkerTestCase.java
Log:
typos, style and testcases cleanup
Modified: search/trunk/src/java/org/hibernate/search/store/FSDirectoryProvider.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/store/FSDirectoryProvider.java 2008-06-06
07:43:00 UTC (rev 14745)
+++ search/trunk/src/java/org/hibernate/search/store/FSDirectoryProvider.java 2008-06-06
08:09:59 UTC (rev 14746)
@@ -6,7 +6,6 @@
import java.util.Properties;
import org.apache.lucene.store.FSDirectory;
-import org.hibernate.search.Environment;
import org.hibernate.search.SearchException;
import org.hibernate.search.engine.SearchFactoryImplementor;
import org.slf4j.Logger;
@@ -51,7 +50,7 @@
directory.close();
}
catch (Exception e) {
- log.error( "Unable to property close Lucene directory {}" +
directory.getFile(), e );
+ log.error( "Unable to properly close Lucene directory {}" +
directory.getFile(), e );
}
}
Modified: search/trunk/src/java/org/hibernate/search/store/FSMasterDirectoryProvider.java
===================================================================
---
search/trunk/src/java/org/hibernate/search/store/FSMasterDirectoryProvider.java 2008-06-06
07:43:00 UTC (rev 14745)
+++
search/trunk/src/java/org/hibernate/search/store/FSMasterDirectoryProvider.java 2008-06-06
08:09:59 UTC (rev 14746)
@@ -4,7 +4,7 @@
import java.util.Timer;
import java.util.Properties;
import java.util.TimerTask;
-import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.locks.Lock;
import java.io.File;
@@ -127,13 +127,13 @@
directory.close();
}
catch (Exception e) {
- log.error( "Unable to property close Lucene directory {}" +
directory.getFile(), e );
+ log.error( "Unable to properly close Lucene directory {}" +
directory.getFile(), e );
}
}
class TriggerTask extends TimerTask {
- private final ExecutorService executor;
+ private final Executor executor;
private final FSMasterDirectoryProvider.CopyDirectory copyTask;
public TriggerTask(File source, File destination, DirectoryProvider directoryProvider)
{
@@ -142,7 +142,7 @@
}
public void run() {
- if (!copyTask.inProgress) {
+ if ( ! copyTask.inProgress ) {
executor.execute( copyTask );
}
else {
Modified: search/trunk/src/java/org/hibernate/search/store/FSSlaveDirectoryProvider.java
===================================================================
---
search/trunk/src/java/org/hibernate/search/store/FSSlaveDirectoryProvider.java 2008-06-06
07:43:00 UTC (rev 14745)
+++
search/trunk/src/java/org/hibernate/search/store/FSSlaveDirectoryProvider.java 2008-06-06
08:09:59 UTC (rev 14746)
@@ -4,7 +4,7 @@
import java.util.Properties;
import java.util.Timer;
import java.util.TimerTask;
-import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.io.File;
import java.io.IOException;
@@ -19,7 +19,7 @@
/**
* File based directory provider that takes care of getting a version of the index
- * from a given source
+ * from a given source.
* The base directory is represented by hibernate.search.<index>.indexBase
* The index is created in <base directory>/<index name>
* The source (aka copy) directory is built from <sourceBase>/<index name>
@@ -104,7 +104,7 @@
catch (IOException e) {
throw new SearchException( "Unable to synchronize directory: " +
indexName, e );
}
- if (! currentMarker.createNewFile() ) {
+ if ( ! currentMarker.createNewFile() ) {
throw new SearchException( "Unable to create the directory marker file: "
+ indexName );
}
}
@@ -152,7 +152,7 @@
class TriggerTask extends TimerTask {
- private final ExecutorService executor;
+ private final Executor executor;
private final CopyDirectory copyTask;
public TriggerTask(File sourceIndexDir, File destination) {
@@ -161,7 +161,7 @@
}
public void run() {
- if (!copyTask.inProgress) {
+ if ( ! copyTask.inProgress ) {
executor.execute( copyTask );
}
else {
@@ -234,13 +234,13 @@
directory1.close();
}
catch (Exception e) {
- log.error( "Unable to property close Lucene directory {}" +
directory1.getFile(), e );
+ log.error( "Unable to properly close Lucene directory {}" +
directory1.getFile(), e );
}
try {
directory2.close();
}
catch (Exception e) {
- log.error( "Unable to property close Lucene directory {}" +
directory2.getFile(), e );
+ log.error( "Unable to properly close Lucene directory {}" +
directory2.getFile(), e );
}
}
}
Modified: search/trunk/src/test/org/hibernate/search/test/FSDirectoryTest.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/FSDirectoryTest.java 2008-06-06
07:43:00 UTC (rev 14745)
+++ search/trunk/src/test/org/hibernate/search/test/FSDirectoryTest.java 2008-06-06
08:09:59 UTC (rev 14746)
@@ -15,11 +15,7 @@
import org.apache.lucene.search.Query;
import org.apache.lucene.search.TermQuery;
import org.hibernate.Session;
-import org.hibernate.event.PostDeleteEventListener;
-import org.hibernate.event.PostInsertEventListener;
-import org.hibernate.event.PostUpdateEventListener;
import org.hibernate.search.Environment;
-import org.hibernate.search.event.FullTextIndexEventListener;
import org.hibernate.search.store.FSDirectoryProvider;
import org.hibernate.search.util.FileHelper;
@@ -191,10 +187,6 @@
cfg.setProperty( "hibernate.search.default.indexBase", sub.getAbsolutePath()
);
cfg.setProperty( "hibernate.search.default.directory_provider",
FSDirectoryProvider.class.getName() );
cfg.setProperty( Environment.ANALYZER_CLASS, StopAnalyzer.class.getName() );
- FullTextIndexEventListener del = new FullTextIndexEventListener();
- cfg.getEventListeners().setPostDeleteEventListeners( new PostDeleteEventListener[] {
del } );
- cfg.getEventListeners().setPostUpdateEventListeners( new PostUpdateEventListener[] {
del } );
- cfg.getEventListeners().setPostInsertEventListeners( new PostInsertEventListener[] {
del } );
}
}
Modified: search/trunk/src/test/org/hibernate/search/test/analyzer/AnalyzerTest.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/analyzer/AnalyzerTest.java 2008-06-06
07:43:00 UTC (rev 14745)
+++ search/trunk/src/test/org/hibernate/search/test/analyzer/AnalyzerTest.java 2008-06-06
08:09:59 UTC (rev 14746)
@@ -5,9 +5,7 @@
import org.hibernate.search.FullTextSession;
import org.hibernate.search.Search;
import org.hibernate.search.FullTextQuery;
-import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.Query;
import org.apache.lucene.queryParser.QueryParser;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
Modified:
search/trunk/src/test/org/hibernate/search/test/directoryProvider/FSSlaveAndMasterDPTest.java
===================================================================
---
search/trunk/src/test/org/hibernate/search/test/directoryProvider/FSSlaveAndMasterDPTest.java 2008-06-06
07:43:00 UTC (rev 14745)
+++
search/trunk/src/test/org/hibernate/search/test/directoryProvider/FSSlaveAndMasterDPTest.java 2008-06-06
08:09:59 UTC (rev 14746)
@@ -10,12 +10,8 @@
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
-import org.hibernate.event.PostDeleteEventListener;
-import org.hibernate.event.PostInsertEventListener;
-import org.hibernate.event.PostUpdateEventListener;
import org.hibernate.search.FullTextSession;
import org.hibernate.search.Search;
-import org.hibernate.search.event.FullTextIndexEventListener;
import org.hibernate.search.util.FileHelper;
/**
@@ -94,7 +90,6 @@
}
}
-
protected void setUp() throws Exception {
File base = new File(".");
File root = new File(base, "lucenedirs");
Modified:
search/trunk/src/test/org/hibernate/search/test/embedded/doubleinsert/DoubleInsertEmbeddedTest.java
===================================================================
---
search/trunk/src/test/org/hibernate/search/test/embedded/doubleinsert/DoubleInsertEmbeddedTest.java 2008-06-06
07:43:00 UTC (rev 14745)
+++
search/trunk/src/test/org/hibernate/search/test/embedded/doubleinsert/DoubleInsertEmbeddedTest.java 2008-06-06
08:09:59 UTC (rev 14746)
@@ -2,20 +2,12 @@
package org.hibernate.search.test.embedded.doubleinsert;
import java.util.Date;
-import java.io.File;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.TermQuery;
-import org.apache.lucene.analysis.StopAnalyzer;
import org.hibernate.Query;
-import org.hibernate.event.PostDeleteEventListener;
-import org.hibernate.event.PostUpdateEventListener;
-import org.hibernate.event.PostInsertEventListener;
import org.hibernate.search.FullTextSession;
import org.hibernate.search.Search;
-import org.hibernate.search.Environment;
-import org.hibernate.search.event.FullTextIndexEventListener;
-import org.hibernate.search.store.FSDirectoryProvider;
import org.hibernate.search.test.SearchTestCase;
/**
Modified:
search/trunk/src/test/org/hibernate/search/test/optimizer/OptimizerTestCase.java
===================================================================
---
search/trunk/src/test/org/hibernate/search/test/optimizer/OptimizerTestCase.java 2008-06-06
07:43:00 UTC (rev 14745)
+++
search/trunk/src/test/org/hibernate/search/test/optimizer/OptimizerTestCase.java 2008-06-06
08:09:59 UTC (rev 14746)
@@ -4,7 +4,6 @@
import java.io.File;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
-import java.util.Date;
import org.apache.lucene.analysis.StopAnalyzer;
import org.apache.lucene.queryParser.ParseException;
@@ -18,6 +17,7 @@
import org.hibernate.search.impl.FullTextSessionImpl;
import org.hibernate.search.store.FSDirectoryProvider;
import org.hibernate.search.test.SearchTestCase;
+import org.hibernate.search.util.FileHelper;
/**
* @author Emmanuel Bernard
@@ -25,12 +25,12 @@
public class OptimizerTestCase extends SearchTestCase {
protected void setUp() throws Exception {
File sub = getBaseIndexDir();
- delete( sub );
+ FileHelper.delete( sub );
sub.mkdir();
File[] files = sub.listFiles();
for (File file : files) {
if ( file.isDirectory() ) {
- delete( file );
+ FileHelper.delete( file );
}
}
//super.setUp(); //we need a fresh session factory each time for index set up
@@ -47,21 +47,9 @@
protected void tearDown() throws Exception {
super.tearDown();
File sub = getBaseIndexDir();
- delete( sub );
+ FileHelper.delete( sub );
}
- private void delete(File sub) {
- if ( sub.isDirectory() ) {
- for (File file : sub.listFiles()) {
- delete( file );
- }
- sub.delete();
- }
- else {
- sub.delete();
- }
- }
-
public void testConcurrency() throws Exception {
int nThreads = 15;
ExecutorService es = Executors.newFixedThreadPool( nThreads );
Modified: search/trunk/src/test/org/hibernate/search/test/reader/ReaderPerfTestCase.java
===================================================================
---
search/trunk/src/test/org/hibernate/search/test/reader/ReaderPerfTestCase.java 2008-06-06
07:43:00 UTC (rev 14745)
+++
search/trunk/src/test/org/hibernate/search/test/reader/ReaderPerfTestCase.java 2008-06-06
08:09:59 UTC (rev 14746)
@@ -2,29 +2,26 @@
package org.hibernate.search.test.reader;
import java.io.File;
+import java.util.List;
+import java.util.Random;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
-import java.util.Random;
-import java.util.List;
-import org.hibernate.search.test.SearchTestCase;
-import org.hibernate.search.Environment;
-import org.hibernate.search.Search;
-import org.hibernate.search.FullTextQuery;
-import org.hibernate.search.event.FullTextIndexEventListener;
-import org.hibernate.search.store.FSDirectoryProvider;
-import org.hibernate.SessionFactory;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.hibernate.event.PostDeleteEventListener;
-import org.hibernate.event.PostUpdateEventListener;
-import org.hibernate.event.PostInsertEventListener;
-import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.queryParser.ParseException;
-import org.apache.lucene.queryParser.MultiFieldQueryParser;
import org.apache.lucene.analysis.StopAnalyzer;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.queryParser.MultiFieldQueryParser;
+import org.apache.lucene.queryParser.ParseException;
+import org.apache.lucene.queryParser.QueryParser;
import org.apache.lucene.search.Query;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.Transaction;
+import org.hibernate.search.Environment;
+import org.hibernate.search.FullTextQuery;
+import org.hibernate.search.Search;
+import org.hibernate.search.store.FSDirectoryProvider;
+import org.hibernate.search.test.SearchTestCase;
+import org.hibernate.search.util.FileHelper;
/**
* @author Emmanuel Bernard
@@ -36,7 +33,7 @@
File[] files = sub.listFiles();
for ( File file : files ) {
if ( file.isDirectory() ) {
- delete( file );
+ FileHelper.delete( file );
}
}
//super.setUp(); //we need a fresh session factory each time for index set up
@@ -58,21 +55,9 @@
protected void tearDown() throws Exception {
super.tearDown();
File sub = getBaseIndexDir();
- delete( sub );
+ FileHelper.delete( sub );
}
- private void delete(File sub) {
- if ( sub.isDirectory() ) {
- for ( File file : sub.listFiles() ) {
- delete( file );
- }
- sub.delete();
- }
- else {
- sub.delete();
- }
- }
-
public boolean insert = true;
public void testConcurrency() throws Exception {
@@ -238,10 +223,6 @@
cfg.setProperty( "hibernate.search.default.indexBase", sub.getAbsolutePath()
);
cfg.setProperty( "hibernate.search.Clock.directory_provider",
FSDirectoryProvider.class.getName() );
cfg.setProperty( Environment.ANALYZER_CLASS, StopAnalyzer.class.getName() );
- FullTextIndexEventListener del = new FullTextIndexEventListener();
- cfg.getEventListeners().setPostDeleteEventListeners( new PostDeleteEventListener[]{del}
);
- cfg.getEventListeners().setPostUpdateEventListeners( new PostUpdateEventListener[]{del}
);
- cfg.getEventListeners().setPostInsertEventListeners( new PostInsertEventListener[]{del}
);
}
}
Modified: search/trunk/src/test/org/hibernate/search/test/session/OptimizeTest.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/session/OptimizeTest.java 2008-06-06
07:43:00 UTC (rev 14745)
+++ search/trunk/src/test/org/hibernate/search/test/session/OptimizeTest.java 2008-06-06
08:09:59 UTC (rev 14746)
@@ -6,16 +6,13 @@
import org.apache.lucene.analysis.StopAnalyzer;
import org.apache.lucene.queryParser.QueryParser;
import org.hibernate.Transaction;
-import org.hibernate.event.PostDeleteEventListener;
-import org.hibernate.event.PostInsertEventListener;
-import org.hibernate.event.PostUpdateEventListener;
import org.hibernate.search.Environment;
import org.hibernate.search.FullTextSession;
import org.hibernate.search.Search;
-import org.hibernate.search.event.FullTextIndexEventListener;
import org.hibernate.search.impl.FullTextSessionImpl;
import org.hibernate.search.store.FSDirectoryProvider;
import org.hibernate.search.test.SearchTestCase;
+import org.hibernate.search.util.FileHelper;
/**
* @author Emmanuel Bernard
@@ -67,7 +64,7 @@
File[] files = sub.listFiles();
for (File file : files) {
if ( file.isDirectory() ) {
- delete( file );
+ FileHelper.delete( file );
}
}
//super.setUp(); //we need a fresh session factory each time for index set up
@@ -82,21 +79,9 @@
protected void tearDown() throws Exception {
super.tearDown();
File sub = getBaseIndexDir();
- delete( sub );
+ FileHelper.delete( sub );
}
- private void delete(File sub) {
- if ( sub.isDirectory() ) {
- for (File file : sub.listFiles()) {
- delete( file );
- }
- sub.delete();
- }
- else {
- sub.delete();
- }
- }
-
protected Class[] getMappings() {
return new Class[] {
Email.class
Modified: search/trunk/src/test/org/hibernate/search/test/shards/ShardsTest.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/shards/ShardsTest.java 2008-06-06
07:43:00 UTC (rev 14745)
+++ search/trunk/src/test/org/hibernate/search/test/shards/ShardsTest.java 2008-06-06
08:09:59 UTC (rev 14746)
@@ -5,6 +5,7 @@
import java.util.List;
import org.hibernate.search.test.SearchTestCase;
+import org.hibernate.search.util.FileHelper;
import org.hibernate.search.store.RAMDirectoryProvider;
import org.hibernate.search.store.FSDirectoryProvider;
import org.hibernate.search.store.IdHashShardingStrategy;
@@ -158,7 +159,7 @@
File[] files = sub.listFiles();
for (File file : files) {
if ( file.isDirectory() ) {
- delete( file );
+ FileHelper.delete( file );
}
}
//super.setUp(); //we need a fresh session factory each time for index set up
@@ -173,21 +174,9 @@
protected void tearDown() throws Exception {
super.tearDown();
File sub = getBaseIndexDir();
- delete( sub );
+ FileHelper.delete( sub );
}
- private void delete(File sub) {
- if ( sub.isDirectory() ) {
- for ( File file : sub.listFiles() ) {
- delete( file );
- }
- sub.delete();
- }
- else {
- sub.delete();
- }
- }
-
protected Class[] getMappings() {
return new Class[] {
Animal.class,
Modified: search/trunk/src/test/org/hibernate/search/test/worker/ConcurrencyTest.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/worker/ConcurrencyTest.java 2008-06-06
07:43:00 UTC (rev 14745)
+++ search/trunk/src/test/org/hibernate/search/test/worker/ConcurrencyTest.java 2008-06-06
08:09:59 UTC (rev 14746)
@@ -3,7 +3,6 @@
import org.hibernate.search.test.SearchTestCase;
import org.hibernate.Session;
-import org.hibernate.annotations.common.AssertionFailure;
/**
* @author Emmanuel Bernard
Modified: search/trunk/src/test/org/hibernate/search/test/worker/WorkerTestCase.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/worker/WorkerTestCase.java 2008-06-06
07:43:00 UTC (rev 14745)
+++ search/trunk/src/test/org/hibernate/search/test/worker/WorkerTestCase.java 2008-06-06
08:09:59 UTC (rev 14746)
@@ -12,15 +12,12 @@
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
-import org.hibernate.event.PostDeleteEventListener;
-import org.hibernate.event.PostInsertEventListener;
-import org.hibernate.event.PostUpdateEventListener;
import org.hibernate.search.Environment;
import org.hibernate.search.FullTextSession;
-import org.hibernate.search.event.FullTextIndexEventListener;
import org.hibernate.search.impl.FullTextSessionImpl;
import org.hibernate.search.store.FSDirectoryProvider;
import org.hibernate.search.test.SearchTestCase;
+import org.hibernate.search.util.FileHelper;
/**
* @author Emmanuel Bernard
@@ -33,7 +30,7 @@
File[] files = sub.listFiles();
for ( File file : files ) {
if ( file.isDirectory() ) {
- delete( file );
+ FileHelper.delete( file );
}
}
//super.setUp(); //we need a fresh session factory each time for index set up
@@ -48,21 +45,9 @@
protected void tearDown() throws Exception {
super.tearDown();
File sub = getBaseIndexDir();
- delete( sub );
+ FileHelper.delete( sub );
}
- private void delete(File sub) {
- if ( sub.isDirectory() ) {
- for ( File file : sub.listFiles() ) {
- delete( file );
- }
- sub.delete();
- }
- else {
- sub.delete();
- }
- }
-
public void testConcurrency() throws Exception {
int nThreads = 15;
ExecutorService es = Executors.newFixedThreadPool( nThreads );
@@ -192,10 +177,6 @@
cfg.setProperty( "hibernate.search.default.indexBase", sub.getAbsolutePath()
);
cfg.setProperty( "hibernate.search.Clock.directory_provider",
FSDirectoryProvider.class.getName() );
cfg.setProperty( Environment.ANALYZER_CLASS, StopAnalyzer.class.getName() );
- FullTextIndexEventListener del = new FullTextIndexEventListener();
- cfg.getEventListeners().setPostDeleteEventListeners( new PostDeleteEventListener[]{del}
);
- cfg.getEventListeners().setPostUpdateEventListeners( new PostUpdateEventListener[]{del}
);
- cfg.getEventListeners().setPostInsertEventListeners( new PostInsertEventListener[]{del}
);
}
protected Class[] getMappings() {