From hibernate-commits at lists.jboss.org Mon Aug 11 10:53:01 2008 Content-Type: multipart/mixed; boundary="===============8226606726023110290==" MIME-Version: 1.0 From: hibernate-commits at lists.jboss.org To: hibernate-commits at lists.jboss.org Subject: [hibernate-commits] Hibernate SVN: r15032 - search/trunk/src/test/org/hibernate/search/test/id/providedId. Date: Mon, 11 Aug 2008 10:53:01 -0400 Message-ID: --===============8226606726023110290== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: epbernard Date: 2008-08-11 10:53:01 -0400 (Mon, 11 Aug 2008) New Revision: 15032 Modified: search/trunk/src/test/org/hibernate/search/test/id/providedId/ProvidedId= Test.java Log: Style improvements Modified: search/trunk/src/test/org/hibernate/search/test/id/providedId/Pro= videdIdTest.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- search/trunk/src/test/org/hibernate/search/test/id/providedId/ProvidedI= dTest.java 2008-08-11 13:27:31 UTC (rev 15031) +++ search/trunk/src/test/org/hibernate/search/test/id/providedId/ProvidedI= dTest.java 2008-08-11 14:53:01 UTC (rev 15032) @@ -1,68 +1,65 @@ 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.hibernate.Session; import org.hibernate.Transaction; -import org.hibernate.search.test.SearchTestCase; -import org.hibernate.search.Search; -import org.hibernate.search.FullTextSession; import org.hibernate.search.FullTextQuery; -import org.apache.lucene.search.Query; -import org.apache.lucene.queryParser.QueryParser; -import org.apache.lucene.queryParser.ParseException; -import org.apache.lucene.analysis.standard.StandardAnalyzer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.hibernate.search.FullTextSession; +import org.hibernate.search.Search; +import org.hibernate.search.test.SearchTestCase; = -import java.util.List; - /** * @author Navin Surtani (nsurtan= i(a)redhat.com) */ public class ProvidedIdTest extends SearchTestCase { = - JBossCachePerson person1, person2; + protected Class[] getMappings() { + return new Class[] { + JBossCachePerson.class + }; + } = - protected Class[] getMappings() { - return new Class[]{ - JBossCachePerson.class - }; - } + public void testProvidedId() throws ParseException { = - public void testProvidedId() throws ParseException { + JBossCachePerson person1 =3D new JBossCachePerson(); + person1.setName( "Big Goat" ); + person1.setBlurb( "Eats grass" ); = - person1 =3D new JBossCachePerson(); - person1.setName("Big Goat"); - person1.setBlurb("Eats grass"); + JBossCachePerson person2 =3D new JBossCachePerson(); + person2.setName( "Mini Goat" ); + person2.setBlurb( "Eats cheese" ); = - person2 =3D new JBossCachePerson(); - person2.setName("Mini Goat"); - person2.setBlurb("Eats cheese"); = + Session session =3D openSession(); + FullTextSession fullTextSession =3D Search.getFullTextSession( session ); + Transaction transaction =3D session.beginTransaction(); + session.persist( person1 ); + session.persist( person2 ); = - Session session =3D openSession(); - FullTextSession fullTextSession =3D Search.getFullTextSession(sessio= n); - Transaction transaction =3D session.beginTransaction(); - session.persist(person1); - session.persist(person2); + transaction.commit(); + session.clear(); = - transaction.commit(); - session.clear(); + transaction =3D fullTextSession.beginTransaction(); = - transaction =3D fullTextSession.beginTransaction(); - = - QueryParser parser =3D new QueryParser("name", new StandardAnalyzer(= )); - Query luceneQuery =3D parser.parse("Goat"); + QueryParser parser =3D new QueryParser( "name", new StandardAnalyzer() ); + Query luceneQuery =3D parser.parse( "Goat" ); = - FullTextQuery fullTextQuery =3D fullTextSession.createFullTextQuery(= luceneQuery, JBossCachePerson.class); + FullTextQuery fullTextQuery =3D fullTextSession.createFullTextQuery( luc= eneQuery, JBossCachePerson.class ); = = - List results =3D fullTextQuery.list(); + List results =3D fullTextQuery.list(); = - transaction.commit(); - session.close(); + transaction.commit(); + session.close(); = - assert results.size() =3D=3D 2; - } + assertEquals( 2, results.size() ); + } = = } --===============8226606726023110290==--