[hibernate-commits] Hibernate SVN: r12869 - trunk/HibernateExt/search/src/test/org/hibernate/search/test/session.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Tue Jul 31 13:54:39 EDT 2007


Author: epbernard
Date: 2007-07-31 13:54:39 -0400 (Tue, 31 Jul 2007)
New Revision: 12869

Modified:
   trunk/HibernateExt/search/src/test/org/hibernate/search/test/session/MassIndexTest.java
Log:
style

Modified: trunk/HibernateExt/search/src/test/org/hibernate/search/test/session/MassIndexTest.java
===================================================================
--- trunk/HibernateExt/search/src/test/org/hibernate/search/test/session/MassIndexTest.java	2007-07-31 17:41:01 UTC (rev 12868)
+++ trunk/HibernateExt/search/src/test/org/hibernate/search/test/session/MassIndexTest.java	2007-07-31 17:54:39 UTC (rev 12869)
@@ -3,20 +3,20 @@
 
 import java.util.List;
 
-import org.hibernate.search.test.SearchTestCase;
-import org.hibernate.search.impl.FullTextSessionImpl;
-import org.hibernate.search.FullTextSession;
-import org.hibernate.search.Search;
-import org.hibernate.search.Environment;
-import org.hibernate.Transaction;
-import org.hibernate.Session;
-import org.hibernate.ScrollMode;
-import org.hibernate.ScrollableResults;
+import org.apache.lucene.analysis.StopAnalyzer;
+import org.apache.lucene.index.Term;
 import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.analysis.StopAnalyzer;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.TermQuery;
-import org.apache.lucene.index.Term;
+import org.hibernate.ScrollMode;
+import org.hibernate.ScrollableResults;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.search.Environment;
+import org.hibernate.search.FullTextSession;
+import org.hibernate.search.Search;
+import org.hibernate.search.impl.FullTextSessionImpl;
+import org.hibernate.search.test.SearchTestCase;
 
 /**
  * @author Emmanuel Bernard
@@ -27,9 +27,9 @@
 		FullTextSession s = Search.createFullTextSession( openSession() );
 		Transaction tx = s.beginTransaction();
 		int loop = 14;
-		for (int i = 0 ; i < loop; i++) {
+		for (int i = 0; i < loop; i++) {
 			s.connection().createStatement().executeUpdate( "insert into Email(id, title, body, header) values( + "
-				+ (i+1) + ", 'Bob Sponge', 'Meet the guys who create the software', 'nope')");
+					+ ( i + 1 ) + ", 'Bob Sponge', 'Meet the guys who create the software', 'nope')" );
 		}
 		tx.commit();
 		s.close();
@@ -39,15 +39,15 @@
 		tx = s.beginTransaction();
 		ScrollableResults results = s.createCriteria( Email.class ).scroll( ScrollMode.FORWARD_ONLY );
 		int index = 0;
-		while( results.next() ) {
+		while ( results.next() ) {
 			index++;
-			s.index( results.get(0) );
-			if (index % 5 == 0) s.clear();
+			s.index( results.get( 0 ) );
+			if ( index % 5 == 0 ) s.clear();
 		}
 		tx.commit();
 		s.clear();
 		tx = s.beginTransaction();
-		QueryParser parser = new QueryParser("id", new StopAnalyzer() );
+		QueryParser parser = new QueryParser( "id", new StopAnalyzer() );
 		List result = s.createFullTextQuery( parser.parse( "body:create" ) ).list();
 		assertEquals( 14, result.size() );
 		for (Object object : result) {
@@ -61,11 +61,11 @@
 		FullTextSession s = Search.createFullTextSession( openSession() );
 		Transaction tx = s.beginTransaction();
 		int loop = 4;
-		for (int i = 0 ; i < loop; i++) {
+		for (int i = 0; i < loop; i++) {
 			Email email = new Email();
-			email.setId( (long)i+1 );
+			email.setId( (long) i + 1 );
 			email.setTitle( "JBoss World Berlin" );
-			email.setBody( "Meet the guys who wrote the software");
+			email.setBody( "Meet the guys who wrote the software" );
 			s.persist( email );
 		}
 		tx.commit();
@@ -74,7 +74,7 @@
 		//check non created object does get found!!1
 		s = new FullTextSessionImpl( openSession() );
 		tx = s.beginTransaction();
-		QueryParser parser = new QueryParser("id", new StopAnalyzer() );
+		QueryParser parser = new QueryParser( "id", new StopAnalyzer() );
 		List result = s.createFullTextQuery( parser.parse( "body:create" ) ).list();
 		assertEquals( 0, result.size() );
 		tx.commit();
@@ -82,25 +82,25 @@
 
 		s = new FullTextSessionImpl( openSession() );
 		s.getTransaction().begin();
-		s.connection().createStatement().executeUpdate( "update Email set body='Meet the guys who write the software'");
+		s.connection().createStatement().executeUpdate( "update Email set body='Meet the guys who write the software'" );
 		//insert an object never indexed
 		s.connection().createStatement().executeUpdate( "insert into Email(id, title, body, header) values( + "
-				+ (loop+1) + ", 'Bob Sponge', 'Meet the guys who create the software', 'nope')");
+				+ ( loop + 1 ) + ", 'Bob Sponge', 'Meet the guys who create the software', 'nope')" );
 		s.getTransaction().commit();
 		s.close();
 
 		s = new FullTextSessionImpl( openSession() );
 		tx = s.beginTransaction();
-		parser = new QueryParser("id", new StopAnalyzer() );
+		parser = new QueryParser( "id", new StopAnalyzer() );
 		result = s.createFullTextQuery( parser.parse( "body:write" ) ).list();
 		assertEquals( 0, result.size() );
 		result = s.createCriteria( Email.class ).list();
-		for (int i = 0 ; i < loop/2 ; i++)
+		for (int i = 0; i < loop / 2; i++)
 			s.index( result.get( i ) );
 		tx.commit(); //do the process
-		s.index( result.get(loop/2) ); //do the process out of tx
+		s.index( result.get( loop / 2 ) ); //do the process out of tx
 		tx = s.beginTransaction();
-		for (int i = loop/2+1 ; i < loop; i++)
+		for (int i = loop / 2 + 1; i < loop; i++)
 			s.index( result.get( i ) );
 		tx.commit(); //do the process
 		s.close();
@@ -108,7 +108,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, new Long( loop + 1 ) );
 		s.index( email );
 		tx.commit();
 		s.close();
@@ -123,31 +123,31 @@
 	}
 
 	public void testLazyLoading() throws Exception {
-		Categorie cat = new Categorie("Livre");
-		Entite ent = new Entite( "Le temple des songes", cat);
-		Session s = openSession( );
+		Categorie cat = new Categorie( "Livre" );
+		Entite ent = new Entite( "Le temple des songes", cat );
+		Session s = openSession();
 		Transaction tx = s.beginTransaction();
 		s.persist( cat );
 		s.persist( ent );
 		tx.commit();
 		s.close();
 
-		s = openSession( );
+		s = openSession();
 		FullTextSession session = Search.createFullTextSession( s );
-		Query luceneQuery = new TermQuery( new Term("categorie.nom", "livre") );
+		Query luceneQuery = new TermQuery( new Term( "categorie.nom", "livre" ) );
 		List result = session.createFullTextQuery( luceneQuery, Entite.class ).list();
 		assertEquals( 1, result.size() );
 		s.close();
 
-		s = openSession( );
+		s = openSession();
 		ent = (Entite) s.get( Entite.class, ent.getId() );
 		session = Search.createFullTextSession( s );
 		session.index( ent );
 		s.close();
 
-		s = openSession( );
+		s = openSession();
 		session = Search.createFullTextSession( s );
-		luceneQuery = new TermQuery( new Term("categorie.nom", "livre") );
+		luceneQuery = new TermQuery( new Term( "categorie.nom", "livre" ) );
 		result = session.createFullTextQuery( luceneQuery, Entite.class ).list();
 		assertEquals( "test lazy loading and indexing", 1, result.size() );
 		ent = (Entite) result.get( 0 );




More information about the hibernate-commits mailing list