[hibernate-commits] Hibernate SVN: r11687 - trunk/HibernateExt/search/src/test/org/hibernate/search/test/query.
hibernate-commits at lists.jboss.org
hibernate-commits at lists.jboss.org
Wed Jun 13 15:52:17 EDT 2007
Author: epbernard
Date: 2007-06-13 15:52:17 -0400 (Wed, 13 Jun 2007)
New Revision: 11687
Modified:
trunk/HibernateExt/search/src/test/org/hibernate/search/test/query/Book.java
trunk/HibernateExt/search/src/test/org/hibernate/search/test/query/ProjectionQueryTest.java
Log:
Fix a test bug on projection
Modified: trunk/HibernateExt/search/src/test/org/hibernate/search/test/query/Book.java
===================================================================
--- trunk/HibernateExt/search/src/test/org/hibernate/search/test/query/Book.java 2007-06-13 18:31:11 UTC (rev 11686)
+++ trunk/HibernateExt/search/src/test/org/hibernate/search/test/query/Book.java 2007-06-13 19:52:17 UTC (rev 11687)
@@ -58,7 +58,8 @@
this.body = body;
}
- @Unstored
+ //@Unstored
+ @Field(index=Index.TOKENIZED, store=Store.NO)
public String getBody() {
return body;
}
Modified: trunk/HibernateExt/search/src/test/org/hibernate/search/test/query/ProjectionQueryTest.java
===================================================================
--- trunk/HibernateExt/search/src/test/org/hibernate/search/test/query/ProjectionQueryTest.java 2007-06-13 18:31:11 UTC (rev 11686)
+++ trunk/HibernateExt/search/src/test/org/hibernate/search/test/query/ProjectionQueryTest.java 2007-06-13 19:52:17 UTC (rev 11687)
@@ -9,6 +9,7 @@
import org.hibernate.Transaction;
import org.hibernate.search.FullTextSession;
import org.hibernate.search.Search;
+import org.hibernate.search.SearchException;
import org.hibernate.search.test.SearchTestCase;
/**
@@ -32,7 +33,7 @@
Query query = parser.parse( "summary:Festina" );
org.hibernate.search.FullTextQuery hibQuery = s.createFullTextQuery( query, Book.class );
- hibQuery.setIndexProjection( "id", "summary", "body", "mainAuthor.name");
+ hibQuery.setIndexProjection( "id", "summary", "mainAuthor.name");
List result = hibQuery.list();
assertNotNull( result );
@@ -40,10 +41,21 @@
Object[] projection = (Object[]) result.get( 0 );
assertEquals( "id", 1, projection[0] );
assertEquals( "summary", "La chute de la petite reine a travers les yeux de Festina", projection[1] );
- assertEquals( "body should be null (non projectable)", null, projection[2] );
- assertEquals( "mainAuthor.name (embedded objects)", "Emmanuel", projection[3] );
+ assertEquals( "mainAuthor.name (embedded objects)", "Emmanuel", projection[2] );
hibQuery = s.createFullTextQuery( query, Book.class );
+ hibQuery.setIndexProjection( "id", "body", "mainAuthor.name");
+
+ try {
+ result = hibQuery.list();
+ fail("Projecting an unstored field should raise an exception");
+ }
+ catch (SearchException e) {
+ //success
+ }
+
+
+ hibQuery = s.createFullTextQuery( query, Book.class );
hibQuery.setIndexProjection();
result = hibQuery.list();
assertNotNull( result );
More information about the hibernate-commits
mailing list