Author: navssurtani
Date: 2008-08-18 13:36:38 -0400 (Mon, 18 Aug 2008)
New Revision: 15096
Added:
search/trunk/src/test/org/hibernate/search/test/id/providedId/ProvidedIdPerson.java
search/trunk/src/test/org/hibernate/search/test/id/providedId/ProvidedIdPersonSub.java
Removed:
search/trunk/src/test/org/hibernate/search/test/id/providedId/JBossCachePerson.java
Modified:
search/trunk/src/test/org/hibernate/search/test/id/providedId/ProvidedIdTest.java
Log:
Changed JBossCachePerson to ProvidedIdPerson and added subclass ...
Deleted:
search/trunk/src/test/org/hibernate/search/test/id/providedId/JBossCachePerson.java
===================================================================
---
search/trunk/src/test/org/hibernate/search/test/id/providedId/JBossCachePerson.java 2008-08-18
15:25:50 UTC (rev 15095)
+++
search/trunk/src/test/org/hibernate/search/test/id/providedId/JBossCachePerson.java 2008-08-18
17:36:38 UTC (rev 15096)
@@ -1,63 +0,0 @@
-package org.hibernate.search.test.id.providedId;
-
-import org.hibernate.search.annotations.*;
-import org.hibernate.search.bridge.builtin.LongBridge;
-
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.GeneratedValue;
-import java.io.Serializable;
-
-
-/**
- @author Navin Surtani (<a
href="mailto:nsurtani@redhat.com">nsurtani@redhat.com</a>)
- */
-@Entity
-@ProvidedId(bridge = @FieldBridge(impl = LongBridge.class))
-@Indexed
-public class JBossCachePerson implements Serializable
-{
-
- @Id
- @GeneratedValue
- private long id;
-
-
- @Field (index = Index.TOKENIZED, store = Store.YES)
- private String name;
- @Field (index = Index.TOKENIZED, store = Store.YES)
- private String blurb;
- @Field (index = Index.UN_TOKENIZED, store = Store.YES)
- private int age;
-
- public String getName()
- {
- return name;
- }
-
- public void setName(String name)
- {
- this.name = name;
- }
-
- public String getBlurb()
- {
- return blurb;
- }
-
- public void setBlurb(String blurb)
- {
- this.blurb = blurb;
- }
-
- public int getAge()
- {
- return age;
- }
-
- public void setAge(int age)
- {
- this.age = age;
- }
-
-}
Copied:
search/trunk/src/test/org/hibernate/search/test/id/providedId/ProvidedIdPerson.java (from
rev 15091,
search/trunk/src/test/org/hibernate/search/test/id/providedId/JBossCachePerson.java)
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/id/providedId/ProvidedIdPerson.java
(rev 0)
+++
search/trunk/src/test/org/hibernate/search/test/id/providedId/ProvidedIdPerson.java 2008-08-18
17:36:38 UTC (rev 15096)
@@ -0,0 +1,63 @@
+package org.hibernate.search.test.id.providedId;
+
+import org.hibernate.search.annotations.*;
+import org.hibernate.search.bridge.builtin.LongBridge;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.GeneratedValue;
+import java.io.Serializable;
+
+
+/**
+ @author Navin Surtani (<a
href="mailto:nsurtani@redhat.com">nsurtani@redhat.com</a>)
+ */
+@Entity
+@ProvidedId(bridge = @FieldBridge(impl = LongBridge.class))
+@Indexed
+public class ProvidedIdPerson implements Serializable
+{
+
+ @Id
+ @GeneratedValue
+ private long id;
+
+
+ @Field (index = Index.TOKENIZED, store = Store.YES)
+ private String name;
+ @Field (index = Index.TOKENIZED, store = Store.YES)
+ private String blurb;
+ @Field (index = Index.UN_TOKENIZED, store = Store.YES)
+ private int age;
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public String getBlurb()
+ {
+ return blurb;
+ }
+
+ public void setBlurb(String blurb)
+ {
+ this.blurb = blurb;
+ }
+
+ public int getAge()
+ {
+ return age;
+ }
+
+ public void setAge(int age)
+ {
+ this.age = age;
+ }
+
+}
Added:
search/trunk/src/test/org/hibernate/search/test/id/providedId/ProvidedIdPersonSub.java
===================================================================
---
search/trunk/src/test/org/hibernate/search/test/id/providedId/ProvidedIdPersonSub.java
(rev 0)
+++
search/trunk/src/test/org/hibernate/search/test/id/providedId/ProvidedIdPersonSub.java 2008-08-18
17:36:38 UTC (rev 15096)
@@ -0,0 +1,9 @@
+package org.hibernate.search.test.id.providedId;
+
+/**
+ * @author Navin Surtani (<a
href="mailto:nsurtani@redhat.com">nsurtani@redhat.com</a>)
+ */
+public class ProvidedIdPersonSub extends ProvidedIdPerson {
+
+
+}
Modified:
search/trunk/src/test/org/hibernate/search/test/id/providedId/ProvidedIdTest.java
===================================================================
---
search/trunk/src/test/org/hibernate/search/test/id/providedId/ProvidedIdTest.java 2008-08-18
15:25:50 UTC (rev 15095)
+++
search/trunk/src/test/org/hibernate/search/test/id/providedId/ProvidedIdTest.java 2008-08-18
17:36:38 UTC (rev 15096)
@@ -1,9 +1,6 @@
package org.hibernate.search.test.id.providedId;
-import java.util.List;
-
import org.apache.lucene.analysis.standard.StandardAnalyzer;
-import org.apache.lucene.queryParser.ParseException;
import org.apache.lucene.queryParser.QueryParser;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.IndexSearcher;
@@ -11,7 +8,6 @@
import org.hibernate.Session;
import org.hibernate.Transaction;
-import org.hibernate.search.FullTextQuery;
import org.hibernate.search.FullTextSession;
import org.hibernate.search.Search;
import org.hibernate.search.store.DirectoryProvider;
@@ -24,28 +20,32 @@
protected Class[] getMappings() {
return new Class[] {
- JBossCachePerson.class
+ ProvidedIdPerson.class
};
}
public void testProvidedId() throws Exception {
- JBossCachePerson person1 = new JBossCachePerson();
+ ProvidedIdPerson person1 = new ProvidedIdPerson();
person1.setName( "Big Goat" );
person1.setBlurb( "Eats grass" );
- JBossCachePerson person2 = new JBossCachePerson();
+ ProvidedIdPerson person2 = new ProvidedIdPerson();
person2.setName( "Mini Goat" );
person2.setBlurb( "Eats cheese" );
+ ProvidedIdPersonSub person3 = new ProvidedIdPersonSub();
+ person3.setName ( "Regular goat" );
+ person3.setBlurb ( "Is anorexic" );
- Session session = openSession();
+ Session session = openSession();
FullTextSession fullTextSession = Search.getFullTextSession( session );
Transaction transaction = session.beginTransaction();
session.persist( person1 );
session.persist( person2 );
+ session.persist( person3 );
- transaction.commit();
+ transaction.commit();
session.clear();
transaction = fullTextSession.beginTransaction();
@@ -57,14 +57,14 @@
//needs it. So we use plain Lucene
//we know there is only one DP
- DirectoryProvider provider = fullTextSession.getSearchFactory().getDirectoryProviders(
JBossCachePerson.class )[0];
+ DirectoryProvider provider = fullTextSession.getSearchFactory().getDirectoryProviders(
ProvidedIdPerson.class )[0];
IndexSearcher searcher = new IndexSearcher( provider.getDirectory() );
Hits hits = searcher.search( luceneQuery );
searcher.close();
transaction.commit();
session.close();
- assertEquals( 2, hits.length() );
+ assertEquals( 3, hits.length() );
}
Show replies by date