Hibernate SVN: r14750 - annotations/trunk/src/test/org/hibernate/test/annotations/onetoone/primarykey.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2008-06-06 11:51:05 -0400 (Fri, 06 Jun 2008)
New Revision: 14750
Modified:
annotations/trunk/src/test/org/hibernate/test/annotations/onetoone/primarykey/Address.java
annotations/trunk/src/test/org/hibernate/test/annotations/onetoone/primarykey/NullablePrimaryKeyTest.java
Log:
ANN-742 fixed the flawed test by using mappedBy
Modified: annotations/trunk/src/test/org/hibernate/test/annotations/onetoone/primarykey/Address.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/onetoone/primarykey/Address.java 2008-06-06 11:42:54 UTC (rev 14749)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/onetoone/primarykey/Address.java 2008-06-06 15:51:05 UTC (rev 14750)
@@ -6,6 +6,7 @@
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.OneToOne;
+import javax.persistence.Transient;
@Entity
public class Address {
@@ -13,12 +14,8 @@
@Id
private long id;
- @OneToOne
- @JoinTable(
- name = "personAddress",
- joinColumns = @JoinColumn(name = "address_id", insertable = false, updatable = false),
- inverseJoinColumns = @JoinColumn(name = "person_id", insertable = false, updatable = false)
- )
+ @OneToOne(mappedBy = "address")
+
private Person person;
public long getId() {
Modified: annotations/trunk/src/test/org/hibernate/test/annotations/onetoone/primarykey/NullablePrimaryKeyTest.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/onetoone/primarykey/NullablePrimaryKeyTest.java 2008-06-06 11:42:54 UTC (rev 14749)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/onetoone/primarykey/NullablePrimaryKeyTest.java 2008-06-06 15:51:05 UTC (rev 14750)
@@ -29,8 +29,8 @@
for (String s : schema) {
log.debug(s);
}
- String expectedMappingTableSql = "create table personAddress (person_id numeric(19,0) not null, " +
- "address_id numeric(19,0) not null, primary key (person_id))";
+ String expectedMappingTableSql = "create table personAddress (address_id numeric(19,0) null, " +
+ "person_id numeric(19,0) not null, primary key (address_id))";
assertEquals("Wrong SQL", expectedMappingTableSql, schema[2]);
} catch (Exception e) {
fail(e.getMessage());
16 years, 6 months
Hibernate SVN: r14749 - in search/trunk/src: java/org/hibernate/search/store and 7 other directories.
by hibernate-commits@lists.jboss.org
Author: sannegrinovero
Date: 2008-06-06 07:42:54 -0400 (Fri, 06 Jun 2008)
New Revision: 14749
Modified:
search/trunk/src/java/org/hibernate/search/reader/SharedReaderProvider.java
search/trunk/src/java/org/hibernate/search/store/DirectoryProviderFactory.java
search/trunk/src/test/org/hibernate/search/test/FSDirectoryTest.java
search/trunk/src/test/org/hibernate/search/test/jms/master/JMSMasterTest.java
search/trunk/src/test/org/hibernate/search/test/optimizer/OptimizerTestCase.java
search/trunk/src/test/org/hibernate/search/test/query/LuceneQuerySortTest.java
search/trunk/src/test/org/hibernate/search/test/reader/ReaderPerfTestCase.java
search/trunk/src/test/org/hibernate/search/test/session/MassIndexTest.java
search/trunk/src/test/org/hibernate/search/test/worker/WorkerTestCase.java
Log:
minor improvements by FindBugs (and stop him throwing some false alarms).
Modified: search/trunk/src/java/org/hibernate/search/reader/SharedReaderProvider.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/reader/SharedReaderProvider.java 2008-06-06 10:35:35 UTC (rev 14748)
+++ search/trunk/src/java/org/hibernate/search/reader/SharedReaderProvider.java 2008-06-06 11:42:54 UTC (rev 14749)
@@ -306,7 +306,7 @@
perDirectoryProviderManipulationLocks = Collections.unmodifiableMap( perDirectoryProviderManipulationLocks );
}
- private class ReaderData {
+ private static class ReaderData {
public ReaderData(int semaphore, DirectoryProvider provider) {
this.semaphore = semaphore;
Modified: search/trunk/src/java/org/hibernate/search/store/DirectoryProviderFactory.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/store/DirectoryProviderFactory.java 2008-06-06 10:35:35 UTC (rev 14748)
+++ search/trunk/src/java/org/hibernate/search/store/DirectoryProviderFactory.java 2008-06-06 11:42:54 UTC (rev 14749)
@@ -258,7 +258,7 @@
}
}
- public class DirectoryProviders {
+ public static class DirectoryProviders {
private final IndexShardingStrategy shardingStrategy;
private final DirectoryProvider[] providers;
Modified: search/trunk/src/test/org/hibernate/search/test/FSDirectoryTest.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/FSDirectoryTest.java 2008-06-06 10:35:35 UTC (rev 14748)
+++ search/trunk/src/test/org/hibernate/search/test/FSDirectoryTest.java 2008-06-06 11:42:54 UTC (rev 14749)
@@ -75,7 +75,7 @@
s = getSessions().openSession();
s.getTransaction().begin();
- Document entity = (Document) s.get( Document.class, new Long( 1 ) );
+ Document entity = (Document) s.get( Document.class, Long.valueOf( 1 ) );
entity.setSummary( "Object/relational mapping with EJB3" );
s.persist( new Document( "Seam in Action", "", "blah blah blah blah" ) );
s.getTransaction().commit();
Modified: search/trunk/src/test/org/hibernate/search/test/jms/master/JMSMasterTest.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/jms/master/JMSMasterTest.java 2008-06-06 10:35:35 UTC (rev 14748)
+++ search/trunk/src/test/org/hibernate/search/test/jms/master/JMSMasterTest.java 2008-06-06 11:42:54 UTC (rev 14749)
@@ -2,6 +2,7 @@
package org.hibernate.search.test.jms.master;
import java.io.Serializable;
+import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import javax.jms.ObjectMessage;
@@ -43,9 +44,11 @@
//create an object wo trigggering indexing
Session s = openSession( );
s.getTransaction().begin();
- s.connection().createStatement().executeUpdate(
+ Statement statement = s.connection().createStatement();
+ statement.executeUpdate(
"insert into TShirt_Master(id, logo, size) values( '1', 'JBoss balls', 'large')"
);
+ statement.close();
TShirt ts = (TShirt) s.get(TShirt.class, 1);
s.getTransaction().commit();
s.close();
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 10:35:35 UTC (rev 14748)
+++ search/trunk/src/test/org/hibernate/search/test/optimizer/OptimizerTestCase.java 2008-06-06 11:42:54 UTC (rev 14749)
@@ -68,8 +68,8 @@
.currentTimeMillis() - start ) );
}
- protected class Work implements Runnable {
- private SessionFactory sf;
+ protected static class Work implements Runnable {
+ private final SessionFactory sf;
public volatile int count = 0;
public Work(SessionFactory sf) {
@@ -135,7 +135,7 @@
}
}
- protected class ReverseWork implements Runnable {
+ protected static class ReverseWork implements Runnable {
private SessionFactory sf;
public ReverseWork(SessionFactory sf) {
Modified: search/trunk/src/test/org/hibernate/search/test/query/LuceneQuerySortTest.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/query/LuceneQuerySortTest.java 2008-06-06 10:35:35 UTC (rev 14748)
+++ search/trunk/src/test/org/hibernate/search/test/query/LuceneQuerySortTest.java 2008-06-06 11:42:54 UTC (rev 14749)
@@ -41,7 +41,7 @@
// into the index.
int id = 1;
for(Book b : result) {
- assertEquals("Expected another id", new Integer(id), b.getId());
+ assertEquals( "Expected another id", Integer.valueOf( id ), b.getId() );
id++;
}
@@ -55,7 +55,7 @@
assertEquals( "Wrong number of test results.", 3, result.size() );
id = 3;
for(Book b : result) {
- assertEquals("Expected another id", new Integer(id), b.getId());
+ assertEquals("Expected another id", Integer.valueOf( id ), b.getId());
id--;
}
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 10:35:35 UTC (rev 14748)
+++ search/trunk/src/test/org/hibernate/search/test/reader/ReaderPerfTestCase.java 2008-06-06 11:42:54 UTC (rev 14749)
@@ -165,7 +165,7 @@
}
}
- protected class ReverseWork implements Runnable {
+ protected static class ReverseWork implements Runnable {
private SessionFactory sf;
private Random random = new Random();
Modified: search/trunk/src/test/org/hibernate/search/test/session/MassIndexTest.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/session/MassIndexTest.java 2008-06-06 10:35:35 UTC (rev 14748)
+++ search/trunk/src/test/org/hibernate/search/test/session/MassIndexTest.java 2008-06-06 11:42:54 UTC (rev 14749)
@@ -1,6 +1,7 @@
//$Id$
package org.hibernate.search.test.session;
+import java.sql.Statement;
import java.util.List;
import java.util.Iterator;
@@ -29,8 +30,10 @@
Transaction tx = s.beginTransaction();
int loop = 14;
for (int i = 0; i < loop; i++) {
- s.connection().createStatement().executeUpdate( "insert into Email(id, title, body, header) values( + "
+ Statement statmt = s.connection().createStatement();
+ statmt.executeUpdate( "insert into Email(id, title, body, header) values( + "
+ ( i + 1 ) + ", 'Bob Sponge', 'Meet the guys who create the software', 'nope')" );
+ statmt.close();
}
tx.commit();
s.close();
@@ -83,10 +86,14 @@
s = new FullTextSessionImpl( openSession() );
s.getTransaction().begin();
- s.connection().createStatement().executeUpdate( "update Email set body='Meet the guys who write the software'" );
+ Statement stmt = s.connection().createStatement();
+ stmt.executeUpdate( "update Email set body='Meet the guys who write the software'" );
+ stmt.close();
//insert an object never indexed
- s.connection().createStatement().executeUpdate( "insert into Email(id, title, body, header) values( + "
+ stmt = s.connection().createStatement();
+ stmt.executeUpdate( "insert into Email(id, title, body, header) values( + "
+ ( loop + 1 ) + ", 'Bob Sponge', 'Meet the guys who create the software', 'nope')" );
+ stmt.close();
s.getTransaction().commit();
s.close();
@@ -109,7 +116,7 @@
s = Search.createFullTextSession( openSession() );
tx = s.beginTransaction();
//object never indexed
- Email email = (Email) s.get( Email.class, new Long( loop + 1 ) );
+ Email email = (Email) s.get( Email.class, Long.valueOf( loop + 1 ) );
s.index( email );
tx.commit();
s.close();
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 10:35:35 UTC (rev 14748)
+++ search/trunk/src/test/org/hibernate/search/test/worker/WorkerTestCase.java 2008-06-06 11:42:54 UTC (rev 14749)
@@ -67,7 +67,7 @@
.currentTimeMillis() - start ) );
}
- protected class Work implements Runnable {
+ protected static class Work implements Runnable {
private SessionFactory sf;
public volatile int count = 0;
@@ -132,7 +132,7 @@
}
}
- protected class ReverseWork implements Runnable {
+ protected static class ReverseWork implements Runnable {
private SessionFactory sf;
public ReverseWork(SessionFactory sf) {
16 years, 6 months
Hibernate SVN: r14748 - in annotations/trunk/src: test/org/hibernate/test/annotations/onetoone and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2008-06-06 06:35:35 -0400 (Fri, 06 Jun 2008)
New Revision: 14748
Added:
annotations/trunk/src/test/org/hibernate/test/annotations/onetoone/primarykey/
annotations/trunk/src/test/org/hibernate/test/annotations/onetoone/primarykey/Address.java
annotations/trunk/src/test/org/hibernate/test/annotations/onetoone/primarykey/NullablePrimaryKeyTest.java
annotations/trunk/src/test/org/hibernate/test/annotations/onetoone/primarykey/Person.java
Modified:
annotations/trunk/src/java/org/hibernate/cfg/AnnotationConfiguration.java
annotations/trunk/src/java/org/hibernate/cfg/Ejb3Column.java
Log:
ANN-742 Added test case. So far the test case breaks.
Modified: annotations/trunk/src/java/org/hibernate/cfg/AnnotationConfiguration.java
===================================================================
--- annotations/trunk/src/java/org/hibernate/cfg/AnnotationConfiguration.java 2008-06-06 08:16:25 UTC (rev 14747)
+++ annotations/trunk/src/java/org/hibernate/cfg/AnnotationConfiguration.java 2008-06-06 10:35:35 UTC (rev 14748)
@@ -61,6 +61,7 @@
*
* @author Emmanuel Bernard
*/
+@SuppressWarnings({"unchecked", "serial"})
public class AnnotationConfiguration extends Configuration {
private Logger log = LoggerFactory.getLogger( AnnotationConfiguration.class );
Modified: annotations/trunk/src/java/org/hibernate/cfg/Ejb3Column.java
===================================================================
--- annotations/trunk/src/java/org/hibernate/cfg/Ejb3Column.java 2008-06-06 08:16:25 UTC (rev 14747)
+++ annotations/trunk/src/java/org/hibernate/cfg/Ejb3Column.java 2008-06-06 10:35:35 UTC (rev 14748)
@@ -158,7 +158,7 @@
initMappingColumn(
logicalColumnName, propertyName, length, precision, scale, nullable, sqlType, unique, true
);
- log.debug( "Binding column {}. Unique {}", mappingColumn.getName(), unique );
+ log.debug( "Binding column {}. Unique {}. Nullable {}.", new Object[] {mappingColumn.getName(), unique, nullable});
}
}
Added: annotations/trunk/src/test/org/hibernate/test/annotations/onetoone/primarykey/Address.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/onetoone/primarykey/Address.java (rev 0)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/onetoone/primarykey/Address.java 2008-06-06 10:35:35 UTC (rev 14748)
@@ -0,0 +1,40 @@
+//$Id: A320.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $
+package org.hibernate.test.annotations.onetoone.primarykey;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.JoinTable;
+import javax.persistence.OneToOne;
+
+@Entity
+public class Address {
+
+ @Id
+ private long id;
+
+ @OneToOne
+ @JoinTable(
+ name = "personAddress",
+ joinColumns = @JoinColumn(name = "address_id", insertable = false, updatable = false),
+ inverseJoinColumns = @JoinColumn(name = "person_id", insertable = false, updatable = false)
+ )
+ private Person person;
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public Person getPerson() {
+ return person;
+ }
+
+ public void setPerson(Person person) {
+ this.person = person;
+ }
+
+}
Property changes on: annotations/trunk/src/test/org/hibernate/test/annotations/onetoone/primarykey/Address.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: annotations/trunk/src/test/org/hibernate/test/annotations/onetoone/primarykey/NullablePrimaryKeyTest.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/onetoone/primarykey/NullablePrimaryKeyTest.java (rev 0)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/onetoone/primarykey/NullablePrimaryKeyTest.java 2008-06-06 10:35:35 UTC (rev 14748)
@@ -0,0 +1,39 @@
+//$Id: A320.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $
+package org.hibernate.test.annotations.onetoone.primarykey;
+
+import junit.framework.TestCase;
+
+import org.hibernate.cfg.AnnotationConfiguration;
+import org.hibernate.dialect.SQLServerDialect;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Test harness for ANN-742.
+ *
+ * @author Hardy Ferentschik
+ *
+ */
+public class NullablePrimaryKeyTest extends TestCase {
+
+ private Logger log = LoggerFactory.getLogger(NullablePrimaryKeyTest.class);
+
+ public void testGeneratedSql() {
+ try {
+ AnnotationConfiguration config = new AnnotationConfiguration();
+ config.addAnnotatedClass(Address.class);
+ config.addAnnotatedClass(Person.class);
+ config.buildSessionFactory();
+ String[] schema = config
+ .generateSchemaCreationScript(new SQLServerDialect());
+ for (String s : schema) {
+ log.debug(s);
+ }
+ String expectedMappingTableSql = "create table personAddress (person_id numeric(19,0) not null, " +
+ "address_id numeric(19,0) not null, primary key (person_id))";
+ assertEquals("Wrong SQL", expectedMappingTableSql, schema[2]);
+ } catch (Exception e) {
+ fail(e.getMessage());
+ }
+ }
+}
Property changes on: annotations/trunk/src/test/org/hibernate/test/annotations/onetoone/primarykey/NullablePrimaryKeyTest.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: annotations/trunk/src/test/org/hibernate/test/annotations/onetoone/primarykey/Person.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/onetoone/primarykey/Person.java (rev 0)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/onetoone/primarykey/Person.java 2008-06-06 10:35:35 UTC (rev 14748)
@@ -0,0 +1,39 @@
+//$Id: A320.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $
+package org.hibernate.test.annotations.onetoone.primarykey;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.JoinTable;
+import javax.persistence.OneToOne;
+
+@Entity
+public class Person {
+
+ @Id
+ private long id;
+
+ @OneToOne
+ @JoinTable(
+ name = "personAddress",
+ joinColumns = @JoinColumn(name = "person_id"),
+ inverseJoinColumns = @JoinColumn(name = "address_id")
+ )
+ private Address address;
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public Address getAddress() {
+ return address;
+ }
+
+ public void setAddress(Address address) {
+ this.address = address;
+ }
+}
Property changes on: annotations/trunk/src/test/org/hibernate/test/annotations/onetoone/primarykey/Person.java
___________________________________________________________________
Name: svn:eol-style
+ native
16 years, 6 months
Hibernate SVN: r14747 - in annotations/trunk/src: test/org/hibernate/test/annotations/backquotes and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2008-06-06 04:16:25 -0400 (Fri, 06 Jun 2008)
New Revision: 14747
Modified:
annotations/trunk/src/java/org/hibernate/cfg/IndexOrUniqueKeySecondPass.java
annotations/trunk/src/test/org/hibernate/test/annotations/backquotes/BackquoteTest.java
annotations/trunk/src/test/org/hibernate/test/annotations/backquotes/Bug.java
Log:
ANN-718 : Applied the fix from Ejb3JoinColumn to IndexOrUniqueKeySecondPass as well
Modified: annotations/trunk/src/java/org/hibernate/cfg/IndexOrUniqueKeySecondPass.java
===================================================================
--- annotations/trunk/src/java/org/hibernate/cfg/IndexOrUniqueKeySecondPass.java 2008-06-06 08:09:59 UTC (rev 14746)
+++ annotations/trunk/src/java/org/hibernate/cfg/IndexOrUniqueKeySecondPass.java 2008-06-06 08:16:25 UTC (rev 14747)
@@ -58,7 +58,7 @@
}
if ( column != null ) {
this.table = column.getTable();
- addConstraintToColumn( mappings.getLogicalColumnName( column.getName(), table ) );
+ addConstraintToColumn( mappings.getLogicalColumnName( column.getMappingColumn().getQuotedName(), table ) );
}
}
Modified: annotations/trunk/src/test/org/hibernate/test/annotations/backquotes/BackquoteTest.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/backquotes/BackquoteTest.java 2008-06-06 08:09:59 UTC (rev 14746)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/backquotes/BackquoteTest.java 2008-06-06 08:16:25 UTC (rev 14747)
@@ -1,9 +1,14 @@
//$Id$
package org.hibernate.test.annotations.backquotes;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
import junit.framework.TestCase;
import org.hibernate.cfg.AnnotationConfiguration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Testcase for ANN-718 - @JoinTable / @JoinColumn fail when using backquotes in PK field name.
@@ -13,6 +18,8 @@
*/
public class BackquoteTest extends TestCase {
+ private Logger log = LoggerFactory.getLogger(BackquoteTest.class);
+
public void testBackquotes() {
try {
AnnotationConfiguration config = new AnnotationConfiguration();
@@ -21,6 +28,9 @@
config.buildSessionFactory();
}
catch( Exception e ) {
+ StringWriter writer = new StringWriter();
+ e.printStackTrace(new PrintWriter(writer));
+ log.debug(writer.toString());
fail(e.getMessage());
}
}
Modified: annotations/trunk/src/test/org/hibernate/test/annotations/backquotes/Bug.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/backquotes/Bug.java 2008-06-06 08:09:59 UTC (rev 14746)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/backquotes/Bug.java 2008-06-06 08:16:25 UTC (rev 14747)
@@ -9,6 +9,8 @@
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
+import org.hibernate.annotations.Index;
+
@Entity
public class Bug
{
@@ -17,6 +19,7 @@
private int id;
@Column(name="`title`")
+ @Index(name="`titleindex`")
private String title;
@ManyToMany
16 years, 6 months
Hibernate SVN: r14746 - in search/trunk/src: test/org/hibernate/search/test and 8 other directories.
by hibernate-commits@lists.jboss.org
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() {
16 years, 6 months
Hibernate SVN: r14745 - in annotations/trunk: lib and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2008-06-06 03:43:00 -0400 (Fri, 06 Jun 2008)
New Revision: 14745
Added:
annotations/trunk/lib/
annotations/trunk/lib/README.txt
annotations/trunk/lib/build/
annotations/trunk/lib/build/ant-junit-1.6.5.jar
annotations/trunk/lib/build/junit-3.8.1.jar
Modified:
annotations/trunk/build.xml
annotations/trunk/common-build.xml
Log:
Resurrected the lib directory with ant-junit and junit dependencies. Turns out it was working for me because I had these libraries in my ant lib directory.
Also reintroduces the copylib target in common-build.xml
Modified: annotations/trunk/build.xml
===================================================================
--- annotations/trunk/build.xml 2008-06-05 23:41:49 UTC (rev 14744)
+++ annotations/trunk/build.xml 2008-06-06 07:43:00 UTC (rev 14745)
@@ -168,7 +168,7 @@
</target>
<!-- Some of this can probably be moved to common-build... -->
- <target name="dist" depends="get.deps.core,get.deps.test,jar,javadoc,jpa-javadoc,copysource,copytest,extras"
+ <target name="dist" depends="get.deps.core,get.deps.test,jar,javadoc,jpa-javadoc,copysource,copytest,copylib,extras"
description="Build everything">
<ant inheritall="false" dir="${basedir}/doc/reference"/>
Modified: annotations/trunk/common-build.xml
===================================================================
--- annotations/trunk/common-build.xml 2008-06-05 23:41:49 UTC (rev 14744)
+++ annotations/trunk/common-build.xml 2008-06-06 07:43:00 UTC (rev 14745)
@@ -13,6 +13,7 @@
<property name="src.dir" location="src/java"/>
<property name="test.dir" location="src/test"/>
+ <property name="lib.dir" location="lib"/>
<property name="build.dir" location="build"/>
<property name="classes.dir" location="${build.dir}/classes"/>
<property name="testclasses.dir" location="${build.dir}/testclasses"/>
@@ -43,10 +44,23 @@
<property name="pom.file" value="pom.xml"/>
<property name="src.jar" value="${build.dir}/src.jar"/>
- <taskdef name="junit" classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask">
+ <taskdef name="junit"
+ classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask">
+ <classpath>
+ <fileset dir="${common-build.basedir}/lib/build"><!-- ${build.lib.dir} fails in reference doc build -->
+ <include name="junit-*.jar"/>
+ <include name="ant-junit-*.jar"/>
+ </fileset>
+ </classpath>
</taskdef>
<taskdef name="junitreport" classname="org.apache.tools.ant.taskdefs.optional.junit.XMLResultAggregator">
+ <classpath>
+ <fileset dir="${common-build.basedir}/lib/build"><!-- ${build.lib.dir} fails in reference doc build -->
+ <include name="junit-*.jar"/>
+ <include name="ant-junit-*.jar"/>
+ </fileset>
+ </classpath>
</taskdef>
<!-- ivy load -->
@@ -257,7 +271,19 @@
</fileset>
</copy>
</target>
-
+
+ <target name="copylib" description="Copy jars to lib dir">
+ <mkdir dir="${dist.lib.dir}"/>
+ <copy todir="${dist.lib.dir}" verbose="true">
+ <fileset dir="${lib.dir}">
+ <include name="**/*.jar"/>
+ <exclude name="log4j.jar"/>
+ <exclude name="checkstyle*.jar"/>
+ <include name="*.txt"/>
+ </fileset>
+ </copy>
+ </target>
+
<target name="copydoc" description="Copy doc to dist dir" if="copy.doc">
<mkdir dir="${dist.doc.dir}"/>
<copy todir="${dist.doc.dir}">
Added: annotations/trunk/lib/README.txt
===================================================================
--- annotations/trunk/lib/README.txt (rev 0)
+++ annotations/trunk/lib/README.txt 2008-06-06 07:43:00 UTC (rev 14745)
@@ -0,0 +1,16 @@
+Hibernate Annotations dependencies
+==================================
+
+
+Core
+====
+hibernate-commons-annotations.jar: required
+hibernate3.jar: required
+hibernate core dependencies: required (see Hibernate Core for more information)
+ejb3-persistence.jar: required
+hibernate-validator.jar: optional
+hibernate-search.jar: optional
+
+Test
+====
+(no additinal dependency)
\ No newline at end of file
Property changes on: annotations/trunk/lib/README.txt
___________________________________________________________________
Name: svn:eol-style
+ native
Added: annotations/trunk/lib/build/ant-junit-1.6.5.jar
===================================================================
(Binary files differ)
Property changes on: annotations/trunk/lib/build/ant-junit-1.6.5.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: annotations/trunk/lib/build/junit-3.8.1.jar
===================================================================
(Binary files differ)
Property changes on: annotations/trunk/lib/build/junit-3.8.1.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
16 years, 6 months
Hibernate SVN: r14744 - in search/trunk: src/java/org/hibernate/search/store and 3 other directories.
by hibernate-commits@lists.jboss.org
Author: sannegrinovero
Date: 2008-06-05 19:41:49 -0400 (Thu, 05 Jun 2008)
New Revision: 14744
Added:
search/trunk/src/test/org/hibernate/search/test/directoryProvider/DirectoryProviderHelperTest.java
Modified:
search/trunk/doc/reference/en/modules/configuration.xml
search/trunk/src/java/org/hibernate/search/store/DirectoryProviderHelper.java
search/trunk/src/java/org/hibernate/search/store/FSMasterDirectoryProvider.java
search/trunk/src/java/org/hibernate/search/store/FSSlaveDirectoryProvider.java
search/trunk/src/java/org/hibernate/search/util/FileHelper.java
search/trunk/src/test/org/hibernate/search/test/FSDirectoryTest.java
Log:
HSEARCH-206 Enable configuration parameters for file transfer options in JMS DirectoryProviders
Modified: search/trunk/doc/reference/en/modules/configuration.xml
===================================================================
--- search/trunk/doc/reference/en/modules/configuration.xml 2008-06-05 23:21:58 UTC (rev 14743)
+++ search/trunk/doc/reference/en/modules/configuration.xml 2008-06-05 23:41:49 UTC (rev 14744)
@@ -52,7 +52,10 @@
3600 seconds - 60 minutes).</para><para>Note that the copy is
based on an incremental copy mechanism reducing the average copy
time.</para><para>DirectoryProvider typically used on the master
- node in a JMS back end cluster.</para></entry>
+ node in a JMS back end cluster.</para><para>The <literal>
+ buffer_size_on_copy</literal> optimum depends
+ on your operating system and available RAM; most people reported
+ good results using values between 16 and 64MB.</para></entry>
<entry><para><literal>indexBase</literal>: Base
directory</para><para><literal>indexName</literal>: override
@@ -63,7 +66,10 @@
The actual source directory name being
<filename><sourceBase>/<source></filename>
</para><para><literal>refresh</literal>: refresh period in second
- (the copy will take place every refresh seconds).</para></entry>
+ (the copy will take place every refresh seconds).</para><para>
+ <literal>buffer_size_on_copy</literal>: The amount of
+ MegaBytes to move in a single low level copy instruction;
+ defaults to 16MB.</para></entry>
</row>
<row>
@@ -77,7 +83,10 @@
information (default 3600 seconds - 60 minutes).</para><para>Note
that the copy is based on an incremental copy mechanism reducing
the average copy time.</para><para>DirectoryProvider typically
- used on slave nodes using a JMS back end.</para></entry>
+ used on slave nodes using a JMS back end.</para><para>The <literal>
+ buffer_size_on_copy</literal> optimum depends
+ on your operating system and available RAM; most people reported
+ good results using values between 16 and 64MB.</para></entry>
<entry><para><literal>indexBase</literal>: Base
directory</para><para><literal>indexName</literal>: override
@@ -88,7 +97,10 @@
The actual source directory name being
<filename><sourceBase>/<source></filename>
</para><para><literal>refresh</literal>: refresh period in second
- (the copy will take place every refresh seconds).</para></entry>
+ (the copy will take place every refresh seconds).</para><para>
+ <literal>buffer_size_on_copy</literal>: The amount of
+ MegaBytes to move in a single low level copy instruction;
+ defaults to 16MB.</para></entry>
</row>
<row>
Modified: search/trunk/src/java/org/hibernate/search/store/DirectoryProviderHelper.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/store/DirectoryProviderHelper.java 2008-06-05 23:21:58 UTC (rev 14743)
+++ search/trunk/src/java/org/hibernate/search/store/DirectoryProviderHelper.java 2008-06-05 23:41:49 UTC (rev 14744)
@@ -6,6 +6,7 @@
import java.io.IOException;
import org.hibernate.search.SearchException;
+import org.hibernate.search.util.FileHelper;
import org.hibernate.annotations.common.util.StringHelper;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.index.IndexReader;
@@ -23,6 +24,7 @@
private static final Logger log = LoggerFactory.getLogger( DirectoryProviderHelper.class );
private static final String ROOTINDEX_PROP_NAME = "sourceBase";
private static final String RELATIVEINDEX_PROP_NAME = "source";
+ public static final String COPYBUFFERSIZE_PROP_NAME = "buffer_size_on_copy";
/**
* Build a directory name out of a root and relative path, guessing the significant part
@@ -142,5 +144,31 @@
log.debug( "Refresh period: {} seconds", period );
return period * 1000; //per second
}
+
+ /**
+ * Users may configure the number of KB to use as
+ * "chunk size" for large file copy operations performed
+ * by DirectoryProviders.
+ * @param directoryProviderName
+ * @param properties
+ * @return the number of Bytes to use as "chunk size" in file copy operations.
+ */
+ public static long getCopyBufferSize(String directoryProviderName, Properties properties) {
+ String value = properties.getProperty( COPYBUFFERSIZE_PROP_NAME );
+ long size = FileHelper.DEFAULT_COPY_BUFFER_SIZE;
+ if ( value != null ) {
+ try {
+ size = Long.parseLong( value ) * 1024 * 1024; //from MB to B.
+ } catch (NumberFormatException nfe) {
+ throw new SearchException( "Unable to initialize index " +
+ directoryProviderName +"; "+ COPYBUFFERSIZE_PROP_NAME + " is not numeric.", nfe );
+ }
+ if ( size <= 0 ) {
+ throw new SearchException( "Unable to initialize index " +
+ directoryProviderName +"; "+ COPYBUFFERSIZE_PROP_NAME + " needs to be greater than zero.");
+ }
+ }
+ return size;
+ }
}
Modified: search/trunk/src/java/org/hibernate/search/store/FSMasterDirectoryProvider.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/store/FSMasterDirectoryProvider.java 2008-06-05 23:21:58 UTC (rev 14743)
+++ search/trunk/src/java/org/hibernate/search/store/FSMasterDirectoryProvider.java 2008-06-05 23:41:49 UTC (rev 14744)
@@ -38,6 +38,7 @@
private String indexName;
private Timer timer;
private SearchFactoryImplementor searchFactory;
+ private long copyChunkSize;
//variables needed between initialize and start
private File sourceDir;
@@ -60,6 +61,7 @@
catch (IOException e) {
throw new SearchException( "Unable to initialize index: " + directoryProviderName, e );
}
+ copyChunkSize = DirectoryProviderHelper.getCopyBufferSize( directoryProviderName, properties );
this.searchFactory = searchFactoryImplementor;
}
@@ -79,7 +81,7 @@
}
String currentString = Integer.valueOf( current ).toString();
File subDir = new File( sourceDir, currentString );
- FileHelper.synchronize( indexDir, subDir, true );
+ FileHelper.synchronize( indexDir, subDir, true, copyChunkSize );
new File( sourceDir, "current1 ").delete();
new File( sourceDir, "current2" ).delete();
//TODO small hole, no file can be found here
@@ -176,11 +178,10 @@
int oldIndex = current;
int index = current == 1 ? 2 : 1;
- File destinationFile = new File(destination, Integer.valueOf(index).toString() );
- //TODO make smart a parameter
+ File destinationFile = new File( destination, Integer.valueOf(index).toString() );
try {
log.trace( "Copying {} into {}", source, destinationFile );
- FileHelper.synchronize( source, destinationFile, true );
+ FileHelper.synchronize( source, destinationFile, true, copyChunkSize );
current = index;
}
catch (IOException e) {
Modified: search/trunk/src/java/org/hibernate/search/store/FSSlaveDirectoryProvider.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/store/FSSlaveDirectoryProvider.java 2008-06-05 23:21:58 UTC (rev 14743)
+++ search/trunk/src/java/org/hibernate/search/store/FSSlaveDirectoryProvider.java 2008-06-05 23:41:49 UTC (rev 14744)
@@ -38,7 +38,8 @@
private int current;
private String indexName;
private Timer timer;
-
+ private long copyChunkSize;
+
//variables needed between initialize and start
private File sourceIndexDir;
private File indexDir;
@@ -62,6 +63,7 @@
catch (IOException e) {
throw new SearchException( "Unable to initialize index: " + directoryProviderName, e );
}
+ copyChunkSize = DirectoryProviderHelper.getCopyBufferSize( directoryProviderName, properties );
}
public void start() {
@@ -96,7 +98,8 @@
throw new AssertionFailure( "No current file marker found in source directory: " + sourceIndexDir.getPath() );
}
try {
- FileHelper.synchronize( new File( sourceIndexDir, String.valueOf(sourceCurrent) ), destinationFile, true);
+ FileHelper.synchronize( new File( sourceIndexDir, String.valueOf(sourceCurrent) ),
+ destinationFile, true, copyChunkSize );
}
catch (IOException e) {
throw new SearchException( "Unable to synchronize directory: " + indexName, e );
@@ -197,10 +200,9 @@
}
File destinationFile = new File( destination, Integer.valueOf( index ).toString() );
- //TODO make smart a parameter
try {
log.trace( "Copying {} into {}", sourceFile, destinationFile );
- FileHelper.synchronize( sourceFile, destinationFile, true );
+ FileHelper.synchronize( sourceFile, destinationFile, true, copyChunkSize );
current = index;
}
catch (IOException e) {
Modified: search/trunk/src/java/org/hibernate/search/util/FileHelper.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/util/FileHelper.java 2008-06-05 23:21:58 UTC (rev 14743)
+++ search/trunk/src/java/org/hibernate/search/util/FileHelper.java 2008-06-05 23:41:49 UTC (rev 14744)
@@ -20,14 +20,18 @@
public abstract class FileHelper {
private static final int FAT_PRECISION = 2000;
- private static final long DEFAULT_CHUNK_SIZE = 16 * 1024 * 1024; // 16 MB
+ public static final long DEFAULT_COPY_BUFFER_SIZE = 16 * 1024 * 1024; // 16 MB
private static final Logger log = LoggerFactory.getLogger( FileHelper.class );
public static void synchronize(File source, File destination, boolean smart) throws IOException {
- synchronize( source, destination, smart, DEFAULT_CHUNK_SIZE );
+ synchronize( source, destination, smart, DEFAULT_COPY_BUFFER_SIZE );
}
public static void synchronize(File source, File destination, boolean smart, long chunkSize) throws IOException {
+ if ( chunkSize <= 0 ) {
+ log.warn( "Chunk size must be positive: using default value." );
+ chunkSize = DEFAULT_COPY_BUFFER_SIZE;
+ }
if ( source.isDirectory() ) {
if ( ! destination.exists() ) {
if ( ! destination.mkdirs() ){
Modified: search/trunk/src/test/org/hibernate/search/test/FSDirectoryTest.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/FSDirectoryTest.java 2008-06-05 23:21:58 UTC (rev 14743)
+++ search/trunk/src/test/org/hibernate/search/test/FSDirectoryTest.java 2008-06-05 23:41:49 UTC (rev 14744)
@@ -3,7 +3,6 @@
import java.io.File;
import java.util.List;
-import java.util.Properties;
import org.apache.lucene.analysis.StopAnalyzer;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
@@ -21,7 +20,6 @@
import org.hibernate.event.PostUpdateEventListener;
import org.hibernate.search.Environment;
import org.hibernate.search.event.FullTextIndexEventListener;
-import org.hibernate.search.store.DirectoryProviderHelper;
import org.hibernate.search.store.FSDirectoryProvider;
import org.hibernate.search.util.FileHelper;
@@ -54,36 +52,6 @@
FileHelper.delete( sub );
}
- public void testDirectoryProviderHelperMkdirsGetSource() throws Exception {
- String root = "./testDir";
- String relative = "dir1/dir2/dir3";
-
- Properties properties = new Properties();
- properties.put( "sourceBase", root );
- properties.put( "source", relative );
-
- File rel = DirectoryProviderHelper.getSourceDirectory( "name", properties, true );
-
- assertTrue( rel.exists() );
-
- FileHelper.delete( new File( root ) );
- }
-
- public void testDirectoryProviderHelperMkdirsDetermineIndex() throws Exception {
- String root = "./testDir/dir1/dir2";
- String relative = "dir3";
-
- Properties properties = new Properties();
- properties.put( "indexBase", root );
- properties.put( "indexName", relative );
-
- File f = DirectoryProviderHelper.getVerifiedIndexDir( "name", properties, true );
-
- assertTrue( new File( root ).exists() );
-
- FileHelper.delete( new File( "./testDir" ) );
- }
-
public void testEventIntegration() throws Exception {
Session s = getSessions().openSession();
Added: search/trunk/src/test/org/hibernate/search/test/directoryProvider/DirectoryProviderHelperTest.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/directoryProvider/DirectoryProviderHelperTest.java (rev 0)
+++ search/trunk/src/test/org/hibernate/search/test/directoryProvider/DirectoryProviderHelperTest.java 2008-06-05 23:41:49 UTC (rev 14744)
@@ -0,0 +1,78 @@
+package org.hibernate.search.test.directoryProvider;
+
+import java.io.File;
+import java.util.Properties;
+import junit.framework.TestCase;
+import org.hibernate.search.SearchException;
+import org.hibernate.search.store.DirectoryProviderHelper;
+import org.hibernate.search.util.FileHelper;
+
+/**
+ * @author Gavin King
+ * @author Sanne Grinovero
+ */
+public class DirectoryProviderHelperTest extends TestCase {
+
+ public void testMkdirsDetermineIndex() throws Exception {
+ String root = "./testDir/dir1/dir2";
+ String relative = "dir3";
+
+ Properties properties = new Properties();
+ properties.put( "indexBase", root );
+ properties.put( "indexName", relative );
+
+ File f = DirectoryProviderHelper.getVerifiedIndexDir( "name", properties, true );
+
+ assertTrue( new File( root ).exists() );
+
+ FileHelper.delete( new File( "./testDir" ) );
+ }
+
+ public void testMkdirsGetSource() throws Exception {
+ String root = "./testDir";
+ String relative = "dir1/dir2/dir3";
+
+ Properties properties = new Properties();
+ properties.put( "sourceBase", root );
+ properties.put( "source", relative );
+
+ File rel = DirectoryProviderHelper.getSourceDirectory( "name", properties, true );
+
+ assertTrue( rel.exists() );
+
+ FileHelper.delete( new File( root ) );
+ }
+
+ public void testConfiguringCopyBufferSize() {
+ Properties prop = new Properties();
+ long mB = 1024 * 1024;
+
+ //default to FileHelper default:
+ assertEquals( FileHelper.DEFAULT_COPY_BUFFER_SIZE, DirectoryProviderHelper.getCopyBufferSize( "testIdx", prop ) );
+
+ //any value from MegaBytes:
+ prop.setProperty( DirectoryProviderHelper.COPYBUFFERSIZE_PROP_NAME, "4" );
+ assertEquals( 4*mB, DirectoryProviderHelper.getCopyBufferSize( "testIdx", prop ) );
+ prop.setProperty( DirectoryProviderHelper.COPYBUFFERSIZE_PROP_NAME, "1000" );
+ assertEquals( 1000*mB, DirectoryProviderHelper.getCopyBufferSize( "testIdx", prop ) );
+
+ //invalid values
+ prop.setProperty( DirectoryProviderHelper.COPYBUFFERSIZE_PROP_NAME, "0" );
+ boolean testOk = false;
+ try {
+ DirectoryProviderHelper.getCopyBufferSize( "testIdx", prop );
+ } catch (SearchException e){
+ testOk = true;
+ }
+ assertTrue( testOk );
+ prop.setProperty( DirectoryProviderHelper.COPYBUFFERSIZE_PROP_NAME, "-100" );
+ testOk = false;
+ try {
+ DirectoryProviderHelper.getCopyBufferSize( "testIdx", prop );
+ } catch (SearchException e){
+ testOk = true;
+ }
+ assertTrue( testOk );
+ }
+
+}
16 years, 6 months
Hibernate SVN: r14743 - search/trunk/doc/reference/en/modules.
by hibernate-commits@lists.jboss.org
Author: sannegrinovero
Date: 2008-06-05 19:21:58 -0400 (Thu, 05 Jun 2008)
New Revision: 14743
Modified:
search/trunk/doc/reference/en/modules/configuration.xml
Log:
documentation fixes: replaced many @Index.name with @Indexed.index and some spellings.
Modified: search/trunk/doc/reference/en/modules/configuration.xml
===================================================================
--- search/trunk/doc/reference/en/modules/configuration.xml 2008-06-05 21:40:13 UTC (rev 14742)
+++ search/trunk/doc/reference/en/modules/configuration.xml 2008-06-05 23:21:58 UTC (rev 14743)
@@ -33,12 +33,12 @@
<entry>org.hibernate.search.store.FSDirectoryProvider</entry>
<entry>File system based directory. The directory used will be
- <indexBase>/< <literal>@Indexed.name</literal>
+ <indexBase>/< <literal>@Indexed.index</literal>
></entry>
<entry><para><literal>indexBase</literal> : Base
directory</para><para><literal>indexName</literal>: override
- @Index.name (useful for sharded indexes)</para></entry>
+ @Indexed.index (useful for sharded indexes)</para></entry>
</row>
<row>
@@ -52,19 +52,18 @@
3600 seconds - 60 minutes).</para><para>Note that the copy is
based on an incremental copy mechanism reducing the average copy
time.</para><para>DirectoryProvider typically used on the master
- node in a JMS back end cluster.</para>DirectoryProvider typically
- used on slave nodes using a JMS back end.</entry>
+ node in a JMS back end cluster.</para></entry>
<entry><para><literal>indexBase</literal>: Base
directory</para><para><literal>indexName</literal>: override
- @Index.name (useful for sharded
+ @Indexed.index (useful for sharded
indexes)</para><para><literal>sourceBase</literal>: Source (copy)
base directory.</para><para><literal>source</literal>: Source
- directory suffix (default to <literal>@Indexed.name</literal>).
+ directory suffix (default to <literal>@Indexed.index</literal>).
The actual source directory name being
<filename><sourceBase>/<source></filename>
- </para><para>refresh: refresh period in second (the copy will take
- place every refresh seconds).</para></entry>
+ </para><para><literal>refresh</literal>: refresh period in second
+ (the copy will take place every refresh seconds).</para></entry>
</row>
<row>
@@ -82,14 +81,14 @@
<entry><para><literal>indexBase</literal>: Base
directory</para><para><literal>indexName</literal>: override
- @Index.name (useful for sharded
+ @Indexed.index (useful for sharded
indexes)</para><para><literal>sourceBase</literal>: Source (copy)
base directory.</para><para><literal>source</literal>: Source
- directory suffix (default to <literal>@Indexed.name</literal>).
+ directory suffix (default to <literal>@Indexed.index</literal>).
The actual source directory name being
<filename><sourceBase>/<source></filename>
- </para><para>refresh: refresh period in second (the copy will take
- place every refresh seconds).</para></entry>
+ </para><para><literal>refresh</literal>: refresh period in second
+ (the copy will take place every refresh seconds).</para></entry>
</row>
<row>
@@ -97,7 +96,7 @@
<entry>Memory based directory, the directory will be uniquely
identified (in the same deployment unit) by the
- <literal>@Indexed.name</literal> element</entry>
+ <literal>@Indexed.index</literal> element</entry>
<entry>none</entry>
</row>
@@ -108,7 +107,7 @@
<para>If the built-in directory providers does not fit your needs, you can
write your own directory provider by implementing the
<classname>org.hibernate.store.DirectoryProvider</classname>
- interface</para>
+ interface.</para>
<para>Each indexed entity is associated to a Lucene index (an index can be
shared by several entities but this is not usually the case). You can
@@ -123,15 +122,14 @@
<programlisting>hibernate.search.default.directory_provider org.hibernate.search.store.FSDirectoryProvider
hibernate.search.default.indexBase=/usr/lucene/indexes
+hibernate.search.Rules.directory_provider org.hibernate.search.store.RAMDirectoryProvider</programlisting>
-hibernate.search.Rules.directory_provider org.hibernate.search.store.RAMDirectoryProvider </programlisting>
-
<para>applied on</para>
- <programlisting>@Indexed(name="Status")
+ <programlisting>@Indexed(index="Status")
public class Status { ... }
-@Indexed(name="Rules")
+@Indexed(index="Rules")
public class Rule { ... }</programlisting>
<para>will create a file system directory in
@@ -140,7 +138,7 @@
<literal>Rules</literal> where Rule entities will be indexed.</para>
<para>You can easily define common rules like the directory provider and
- base directory, and overide those default later on on a per index
+ base directory, and override those default later on on a per index
basis.</para>
<para>Writing your own <classname>DirectoryProvider</classname>, you can
@@ -155,7 +153,7 @@
several Lucene indexes. This solution is not recommended until you reach
significant index sizes and index update time are slowing down. The main
drawback of index sharding is that searches will end up being slower since
- more files have to be opend for a single search. In other words don't do
+ more files have to be opened for a single search. In other words don't do
it until you have problems :)</para>
<para>Despite this strong warning, Hibernate Search allows you to index a
@@ -451,7 +449,7 @@
<programlisting>hibernate.search.reader.strategy = my.corp.myapp.CustomReaderProvider</programlisting>
<para>where <classname>my.corp.myapp.CustomReaderProvider</classname> is
- the custom strategy implementation</para>
+ the custom strategy implementation.</para>
</section>
<section id="search-configuration-event" revision="2">
16 years, 6 months
Hibernate SVN: r14742 - in search/trunk/src/java/org/hibernate/search: impl and 1 other directories.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2008-06-05 17:40:13 -0400 (Thu, 05 Jun 2008)
New Revision: 14742
Modified:
search/trunk/src/java/org/hibernate/search/FullTextSession.java
search/trunk/src/java/org/hibernate/search/impl/FullTextSessionImpl.java
search/trunk/src/java/org/hibernate/search/jpa/FullTextEntityManager.java
Log:
HSEARCH-208 raise IAE on non indexed entity during s.index s.purge(All)
Modified: search/trunk/src/java/org/hibernate/search/FullTextSession.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/FullTextSession.java 2008-06-05 11:25:56 UTC (rev 14741)
+++ search/trunk/src/java/org/hibernate/search/FullTextSession.java 2008-06-05 21:40:13 UTC (rev 14742)
@@ -24,6 +24,7 @@
* Non indexable entities are ignored
*
* @param entity The entity to index - must not be <code>null</code>.
+ * @throws IllegalArgumentException if entity is null or not an @Indexed entity
*/
void index(Object entity);
@@ -37,6 +38,8 @@
*
* @param entityType
* @param id
+ *
+ * @throws IllegalArgumentException if entityType is null or not an @Indexed entity type
*/
public void purge(Class entityType, Serializable id);
@@ -44,6 +47,7 @@
* Remove all entities from a particular class of an index.
*
* @param entityType
+ * @throws IllegalArgumentException if entityType is null or not an @Indexed entity type
*/
public void purgeAll(Class entityType);
}
Modified: search/trunk/src/java/org/hibernate/search/impl/FullTextSessionImpl.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/impl/FullTextSessionImpl.java 2008-06-05 11:25:56 UTC (rev 14741)
+++ search/trunk/src/java/org/hibernate/search/impl/FullTextSessionImpl.java 2008-06-05 21:40:13 UTC (rev 14742)
@@ -43,6 +43,7 @@
import org.hibernate.search.FullTextQuery;
import org.hibernate.search.FullTextSession;
import org.hibernate.search.SearchFactory;
+import org.hibernate.search.SearchException;
import org.hibernate.search.backend.Work;
import org.hibernate.search.backend.WorkType;
import org.hibernate.search.engine.DocumentBuilder;
@@ -85,6 +86,7 @@
* Remove all entities from a particular class of an index.
*
* @param entityType
+ * @throws IllegalArgumentException if entityType is null or not an @Indexed entity type
*/
public void purgeAll(Class entityType) {
purge( entityType, null );
@@ -95,6 +97,8 @@
*
* @param entityType
* @param id
+ *
+ * @throws IllegalArgumentException if entityType is null or not an @Indexed entity type
*/
public void purge(Class entityType, Serializable id) {
if ( entityType == null ) return;
@@ -107,17 +111,15 @@
if ( builder == null ) {
throw new IllegalArgumentException( entityType.getName() + " is not a mapped entity (don't forget to add @Indexed)" );
}
+ WorkType type;
+ if ( id == null ) {
+ type = WorkType.PURGE_ALL;
+ }
else {
- WorkType type;
- if ( id == null ) {
- type = WorkType.PURGE_ALL;
- }
- else {
- type = WorkType.PURGE;
- }
- Work work = new Work(entityType, id, type);
- searchFactoryImplementor.getWorker().performWork( work, eventSource );
+ type = WorkType.PURGE;
}
+ Work work = new Work(entityType, id, type);
+ searchFactoryImplementor.getWorker().performWork( work, eventSource );
}
/**
@@ -126,19 +128,22 @@
* The entity must be associated with the session
*
* @param entity The entity to index - must not be <code>null</code>.
+ * @throws IllegalArgumentException if entity is null or not an @Indexed entity
*/
public void index(Object entity) {
- if (entity == null) return;
+ if (entity == null) throw new IllegalArgumentException("Entity to index should not be null");;
Class clazz = Hibernate.getClass( entity );
//TODO cache that at the FTSession level
SearchFactoryImplementor searchFactoryImplementor = getSearchFactoryImplementor();
//not strictly necessary but a small optimization
DocumentBuilder<Object> builder = searchFactoryImplementor.getDocumentBuilders().get( clazz );
- if ( builder != null ) {
- Serializable id = session.getIdentifier( entity );
- Work work = new Work(entity, id, WorkType.INDEX);
- searchFactoryImplementor.getWorker().performWork( work, eventSource );
+ if ( builder == null ) {
+ throw new IllegalArgumentException( "Entity to index not an @Indexed entity: " + entity.getClass().getName() );
}
+ Serializable id = session.getIdentifier( entity );
+ Work work = new Work(entity, id, WorkType.INDEX);
+ searchFactoryImplementor.getWorker().performWork( work, eventSource );
+
//TODO
//need to add elements in a queue kept at the Session level
//the queue will be processed by a Lucene(Auto)FlushEventListener
Modified: search/trunk/src/java/org/hibernate/search/jpa/FullTextEntityManager.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/jpa/FullTextEntityManager.java 2008-06-05 11:25:56 UTC (rev 14741)
+++ search/trunk/src/java/org/hibernate/search/jpa/FullTextEntityManager.java 2008-06-05 21:40:13 UTC (rev 14742)
@@ -22,6 +22,8 @@
/**
* Force the (re)indexing of a given <b>managed</b> object.
* Indexation is batched per transaction
+ *
+ * @throws IllegalArgumentException if entity is null or not an @Indexed entity
*/
void index(Object entity);
@@ -34,6 +36,8 @@
*
* @param entityType
* @param id
+ *
+ * @throws IllegalArgumentException if entityType is null or not an @Indexed entity type
*/
public void purge(Class entityType, Serializable id);
@@ -41,6 +45,8 @@
* Remove all entities from a particular class of an index.
*
* @param entityType
+ *
+ * @throws IllegalArgumentException if entityType is null or not an @Indexed entity type
*/
public void purgeAll(Class entityType);
16 years, 6 months
Hibernate SVN: r14741 - in annotations/trunk/src: java/org/hibernate/cfg/annotations and 2 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2008-06-05 07:25:56 -0400 (Thu, 05 Jun 2008)
New Revision: 14741
Added:
annotations/trunk/src/test/org/hibernate/test/annotations/namingstrategy/
annotations/trunk/src/test/org/hibernate/test/annotations/namingstrategy/Address.java
annotations/trunk/src/test/org/hibernate/test/annotations/namingstrategy/DummyNamingStrategy.java
annotations/trunk/src/test/org/hibernate/test/annotations/namingstrategy/NamingStrategyTest.java
annotations/trunk/src/test/org/hibernate/test/annotations/namingstrategy/Person.java
Modified:
annotations/trunk/src/java/org/hibernate/cfg/EJB3NamingStrategy.java
annotations/trunk/src/java/org/hibernate/cfg/annotations/EntityBinder.java
Log:
ANN-716:
- Added test harness
- In EntityBinder made sure that the realTable instead of table is used in the joins map
Modified: annotations/trunk/src/java/org/hibernate/cfg/EJB3NamingStrategy.java
===================================================================
--- annotations/trunk/src/java/org/hibernate/cfg/EJB3NamingStrategy.java 2008-06-05 09:10:41 UTC (rev 14740)
+++ annotations/trunk/src/java/org/hibernate/cfg/EJB3NamingStrategy.java 2008-06-05 11:25:56 UTC (rev 14741)
@@ -7,7 +7,7 @@
import org.hibernate.util.StringHelper;
/**
- * NAming strategy implementing the EJB3 standards
+ * Naming strategy implementing the EJB3 standards
*
* @author Emmanuel Bernard
*/
Modified: annotations/trunk/src/java/org/hibernate/cfg/annotations/EntityBinder.java
===================================================================
--- annotations/trunk/src/java/org/hibernate/cfg/annotations/EntityBinder.java 2008-06-05 09:10:41 UTC (rev 14740)
+++ annotations/trunk/src/java/org/hibernate/cfg/annotations/EntityBinder.java 2008-06-05 11:25:56 UTC (rev 14741)
@@ -667,8 +667,8 @@
createPrimaryColumnsToSecondaryTable( joinColumns, propertyHolder, join );
}
else {
- secondaryTables.put( table, join );
- secondaryTableJoins.put( table, joinColumns );
+ secondaryTables.put( realTable, join );
+ secondaryTableJoins.put( realTable, joinColumns );
}
return join;
}
Added: annotations/trunk/src/test/org/hibernate/test/annotations/namingstrategy/Address.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/namingstrategy/Address.java (rev 0)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/namingstrategy/Address.java 2008-06-05 11:25:56 UTC (rev 14741)
@@ -0,0 +1,34 @@
+// $Id:$
+package org.hibernate.test.annotations.namingstrategy;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.JoinTable;
+import javax.persistence.ManyToOne;
+
+@Entity
+public class Address {
+
+ @Id
+ private long id;
+
+ @ManyToOne
+ @JoinTable(name = "person_address")
+ private Person person;
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public Person getPerson() {
+ return person;
+ }
+
+ public void setPerson(Person person) {
+ this.person = person;
+ }
+}
Property changes on: annotations/trunk/src/test/org/hibernate/test/annotations/namingstrategy/Address.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: annotations/trunk/src/test/org/hibernate/test/annotations/namingstrategy/DummyNamingStrategy.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/namingstrategy/DummyNamingStrategy.java (rev 0)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/namingstrategy/DummyNamingStrategy.java 2008-06-05 11:25:56 UTC (rev 14741)
@@ -0,0 +1,13 @@
+// $Id:$
+package org.hibernate.test.annotations.namingstrategy;
+
+import org.hibernate.cfg.EJB3NamingStrategy;
+
+@SuppressWarnings("serial")
+public class DummyNamingStrategy extends EJB3NamingStrategy {
+
+ public String tableName(String tableName) {
+ return "T" + tableName;
+ }
+
+}
Property changes on: annotations/trunk/src/test/org/hibernate/test/annotations/namingstrategy/DummyNamingStrategy.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: annotations/trunk/src/test/org/hibernate/test/annotations/namingstrategy/NamingStrategyTest.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/namingstrategy/NamingStrategyTest.java (rev 0)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/namingstrategy/NamingStrategyTest.java 2008-06-05 11:25:56 UTC (rev 14741)
@@ -0,0 +1,52 @@
+// $Id:$
+package org.hibernate.test.annotations.namingstrategy;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+import junit.framework.TestCase;
+
+import org.hibernate.cfg.AnnotationConfiguration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Test harness for ANN-716.
+ *
+ * @author Hardy Ferentschik
+ */
+public class NamingStrategyTest extends TestCase {
+
+ private Logger log = LoggerFactory.getLogger(NamingStrategyTest.class);
+
+ public void testWithCustomNamingStrategy() throws Exception {
+ try {
+ AnnotationConfiguration config = new AnnotationConfiguration();
+ config.setNamingStrategy(new DummyNamingStrategy());
+ config.addAnnotatedClass(Address.class);
+ config.addAnnotatedClass(Person.class);
+ config.buildSessionFactory();
+ }
+ catch( Exception e ) {
+ StringWriter writer = new StringWriter();
+ e.printStackTrace(new PrintWriter(writer));
+ log.debug(writer.toString());
+ fail(e.getMessage());
+ }
+ }
+
+ public void testWithoutCustomNamingStrategy() throws Exception {
+ try {
+ AnnotationConfiguration config = new AnnotationConfiguration();
+ config.addAnnotatedClass(Address.class);
+ config.addAnnotatedClass(Person.class);
+ config.buildSessionFactory();
+ }
+ catch( Exception e ) {
+ StringWriter writer = new StringWriter();
+ e.printStackTrace(new PrintWriter(writer));
+ log.debug(writer.toString());
+ fail(e.getMessage());
+ }
+ }
+}
Property changes on: annotations/trunk/src/test/org/hibernate/test/annotations/namingstrategy/NamingStrategyTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: annotations/trunk/src/test/org/hibernate/test/annotations/namingstrategy/Person.java
===================================================================
--- annotations/trunk/src/test/org/hibernate/test/annotations/namingstrategy/Person.java (rev 0)
+++ annotations/trunk/src/test/org/hibernate/test/annotations/namingstrategy/Person.java 2008-06-05 11:25:56 UTC (rev 14741)
@@ -0,0 +1,35 @@
+// $Id:$
+package org.hibernate.test.annotations.namingstrategy;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+
+@Entity
+public class Person {
+
+ @Id
+ private long id;
+
+ @OneToMany(mappedBy = "person")
+ private Set<Address> addresses = new HashSet<Address>();
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public Set<Address> getAddresses() {
+ return addresses;
+ }
+
+ public void setAddresses(Set<Address> addresses) {
+ this.addresses = addresses;
+ }
+}
Property changes on: annotations/trunk/src/test/org/hibernate/test/annotations/namingstrategy/Person.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
16 years, 6 months