[hibernate-commits] Hibernate SVN: r20688 - in search/trunk: hibernate-search/src/test/java/org/hibernate/search/test and 2 other directories.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Thu Sep 23 06:47:20 EDT 2010


Author: hardy.ferentschik
Date: 2010-09-23 06:47:19 -0400 (Thu, 23 Sep 2010)
New Revision: 20688

Removed:
   search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/classloading/Animal.java
   search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/classloading/NoAnnotationsTest.java
Modified:
   search/trunk/hibernate-search-testing/src/main/java/org/hibernate/search/test/SearchTestCase.java
   search/trunk/hibernate-search/pom.xml
   search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/SearchTestCase.java
Log:
HSEARCH-592 Deleted test which was supposed to show that Search also works when no jpa is on the classpath. Given that JPA is always on the classpath it did not show anything

Modified: search/trunk/hibernate-search/pom.xml
===================================================================
--- search/trunk/hibernate-search/pom.xml	2010-09-23 10:46:26 UTC (rev 20687)
+++ search/trunk/hibernate-search/pom.xml	2010-09-23 10:47:19 UTC (rev 20688)
@@ -125,32 +125,11 @@
                     <forkMode>once</forkMode>
                     <redirectTestOutputToFile>true</redirectTestOutputToFile>
                     <systemProperties>
-                        <!--
-                                Following is the default jgroups mcast address. If you find the testsuite runs very slowly,
-                                there may be problems with multicast on the interface JGroups uses by default on
-                                your machine. You can try to resolve setting 'jgroups.bind_addr' as a system-property
-                                to the jvm launching maven and setting the value to an interface where you know multicast works
-                            -->
                         <property>
-                            <name>jgroups.bind_addr</name>
-                            <value>127.0.0.1</value>
-                        </property>
-                        <!-- There are problems with multicast and IPv6 on some OS/JDK combos, so we tell Java
-                                to use IPv4. If you have problems with multicast when running the tests you can
-                                try setting this to 'false', although typically that won't be helpful.
-                            -->
-                        <property>
-                            <name>java.net.preferIPv4Stack</name>
-                            <value>true</value>
-                        </property>
-                        <property>
                             <name>com.sun.management.jmxremote</name>
                             <value>true</value>
                         </property>
                     </systemProperties>
-                    <excludes>
-                        <exclude>**/classloading/*.java</exclude>
-                    </excludes>
                 </configuration>
             </plugin>
             <plugin>

Modified: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/SearchTestCase.java
===================================================================
--- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/SearchTestCase.java	2010-09-23 10:46:26 UTC (rev 20687)
+++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/SearchTestCase.java	2010-09-23 10:47:19 UTC (rev 20688)
@@ -26,6 +26,7 @@
 import java.io.File;
 import java.io.InputStream;
 import java.net.URL;
+import java.util.Properties;
 
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.KeywordAnalyzer;
@@ -95,6 +96,36 @@
 		log.debug( "Using {} as index directory.", indexDir.getAbsolutePath() );
 	}
 
+	// some system properties needed for JGroups
+	static {
+		Properties properties = System.getProperties();
+
+		// Following is the default jgroups mcast address. If you find the testsuite runs very slowly,
+		// there may be problems with multicast on the interface JGroups uses by default on
+		// your machine. You can try to resolve setting 'jgroups.bind_addr' as a system-property
+		// to the jvm launching maven and setting the value to an interface where you know multicast works
+		String ip4Stack = "java.net.preferIPv4Stack";
+		if ( properties.containsKey( ip4Stack ) ) {
+			log.debug( "Found explicit value for '" + ip4Stack + "' Using value: " + properties.get( ip4Stack ) );
+		}
+		else {
+			log.debug( "'" + ip4Stack + "' property not set. Setting it explicitly to 'true'" );
+			System.setProperty( ip4Stack, "true" );
+		}
+
+		// There are problems with multicast and IPv6 on some OS/JDK combos, so we tell Java
+        // to use IPv4. If you have problems with multicast when running the tests you can
+        // try setting this to 'false', although typically that won't be helpful.
+		String bindAddress = "jgroups.bind_addr";
+		if ( properties.containsKey( bindAddress ) ) {
+			log.debug( "Found explicit value for '" + bindAddress + "' Using value: " + properties.get( bindAddress ) );
+		}
+		else {
+			log.debug( "'" + bindAddress + "' property not set. Setting it explicitly to '127.0.0.1'" );
+			System.setProperty( "jgroups.bind_addr", "127.0.0.1" );
+		}
+	}
+
 	public SearchTestCase() {
 		super();
 	}

Deleted: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/classloading/Animal.java
===================================================================
--- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/classloading/Animal.java	2010-09-23 10:46:26 UTC (rev 20687)
+++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/classloading/Animal.java	2010-09-23 10:47:19 UTC (rev 20688)
@@ -1,61 +0,0 @@
-/* $Id$
- * 
- * Hibernate, Relational Persistence for Idiomatic Java
- * 
- * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors.  All third-party contributions are
- * distributed under license by Red Hat, Inc.
- * 
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- * 
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
- * for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA  02110-1301  USA
- */
-package org.hibernate.search.test.classloading;
-
-import org.hibernate.search.annotations.DocumentId;
-import org.hibernate.search.annotations.Field;
-import org.hibernate.search.annotations.Index;
-import org.hibernate.search.annotations.Indexed;
-
-/**
- * Test class which is configured via XML and does not depend on Hibernate Annotations.
- *
- * @author Hardy Ferentschik
- */
- at Indexed(index = "Animal")
-public class Animal {
-	@DocumentId
-	private Long id;
-
-	@Field(index = Index.TOKENIZED)
-	private String name;
-
-
-	public Long getId() {
-		return id;
-	}
-
-	public void setId(Long id) {
-		this.id = id;
-	}
-
-	public String getName() {
-		return name;
-	}
-
-	public void setName(String name) {
-		this.name = name;
-	}
-}

Deleted: search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/classloading/NoAnnotationsTest.java
===================================================================
--- search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/classloading/NoAnnotationsTest.java	2010-09-23 10:46:26 UTC (rev 20687)
+++ search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/classloading/NoAnnotationsTest.java	2010-09-23 10:47:19 UTC (rev 20688)
@@ -1,119 +0,0 @@
-/* $Id$
- * 
- * Hibernate, Relational Persistence for Idiomatic Java
- * 
- * Copyright (c) 2009, Red Hat, Inc. and/or its affiliates or third-party contributors as
- * indicated by the @author tags or express copyright attribution
- * statements applied by the authors.  All third-party contributions are
- * distributed under license by Red Hat, Inc.
- * 
- * This copyrighted material is made available to anyone wishing to use, modify,
- * copy, or redistribute it subject to the terms and conditions of the GNU
- * Lesser General Public License, as published by the Free Software Foundation.
- * 
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
- * for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public License
- * along with this distribution; if not, write to:
- * Free Software Foundation, Inc.
- * 51 Franklin Street, Fifth Floor
- * Boston, MA  02110-1301  USA
- */
-package org.hibernate.search.test.classloading;
-
-import java.io.InputStream;
-import java.util.List;
-
-import org.apache.lucene.index.Term;
-import org.apache.lucene.search.TermQuery;
-
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.cfg.Environment;
-import org.hibernate.search.Search;
-import org.hibernate.search.test.SearchTestCase;
-
-/**
- * @author Hardy Ferentschik
- */
-public class NoAnnotationsTest extends SearchTestCase {
-	/**
-	 * Tests that @DocumentId is optional. See HSEARCH-104.
-	 *
-	 * @throws Exception in case the test fails.
-	 */
-	public void testConfigurationWithoutAnnotations() throws Exception {
-		Animal dog = new Animal();
-		dog.setName( "Dog" );
-
-		Session s = openSession();
-		Transaction tx = s.beginTransaction();
-		s.save( dog );
-		tx.commit();
-		s.clear();
-
-		tx = s.beginTransaction();
-		List results = Search.getFullTextSession( s ).createFullTextQuery(
-				new TermQuery( new Term( "name", "dog" ) )
-		).list();
-		assertEquals( 1, results.size() );
-		tx.commit();
-		s.close();
-	}
-
-	public void testFlushListenerRegistrationWithoutAnnotations() throws Exception {
-		// This test should pass even if the flushListener is not registered,
-		// as a workaround is done in code (you'll see a warning in logs).
-		Animal pinguin = new Animal();
-		pinguin.setName( "Penguin" );
-
-		Session s = openSession();
-		s.save( pinguin );
-		s.flush();
-		s.clear();
-
-		Transaction tx = s.beginTransaction();
-		List results = Search.getFullTextSession( s ).createFullTextQuery(
-				new TermQuery( new Term( "name", "penguin" ) )
-		).list();
-		assertEquals( 1, results.size() );
-		tx.commit();
-		s.close();
-	}
-
-	protected void buildConfiguration() throws Exception {
-		if ( getSessions() != null ) {
-			getSessions().close();
-		}
-		try {
-			setCfg( new Configuration() );
-			configure( cfg );
-			if ( recreateSchema() ) {
-				cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
-			}
-			for ( String xmlFile : getXmlFiles() ) {
-				InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream( xmlFile );
-				getCfg().addInputStream( is );
-			}
-			setSessions( getCfg().buildSessionFactory() );
-		}
-		catch ( Exception e ) {
-			e.printStackTrace();
-			throw e;
-		}
-	}
-
-	protected String[] getXmlFiles() {
-		return new String[] {
-				"org/hibernate/search/test/classloading/Animal.hbm.xml"
-		};
-	}
-
-	protected Class<?>[] getAnnotatedClasses() {
-		return new Class[] { };
-	}
-}

Modified: search/trunk/hibernate-search-testing/src/main/java/org/hibernate/search/test/SearchTestCase.java
===================================================================
--- search/trunk/hibernate-search-testing/src/main/java/org/hibernate/search/test/SearchTestCase.java	2010-09-23 10:46:26 UTC (rev 20687)
+++ search/trunk/hibernate-search-testing/src/main/java/org/hibernate/search/test/SearchTestCase.java	2010-09-23 10:47:19 UTC (rev 20688)
@@ -26,6 +26,7 @@
 import java.io.File;
 import java.io.InputStream;
 import java.net.URL;
+import java.util.Properties;
 
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.KeywordAnalyzer;
@@ -95,6 +96,36 @@
 		log.debug( "Using {} as index directory.", indexDir.getAbsolutePath() );
 	}
 
+	// some system properties needed for JGroups
+	static {
+		Properties properties = System.getProperties();
+
+		// Following is the default jgroups mcast address. If you find the testsuite runs very slowly,
+		// there may be problems with multicast on the interface JGroups uses by default on
+		// your machine. You can try to resolve setting 'jgroups.bind_addr' as a system-property
+		// to the jvm launching maven and setting the value to an interface where you know multicast works
+		String ip4Stack = "java.net.preferIPv4Stack";
+		if ( properties.containsKey( ip4Stack ) ) {
+			log.debug( "Found explicit value for '" + ip4Stack + "' Using value: " + properties.get( ip4Stack ) );
+		}
+		else {
+			log.debug( "'" + ip4Stack + "' property not set. Setting it explicitly to 'true'" );
+			System.setProperty( ip4Stack, "true" );
+		}
+
+		// There are problems with multicast and IPv6 on some OS/JDK combos, so we tell Java
+        // to use IPv4. If you have problems with multicast when running the tests you can
+        // try setting this to 'false', although typically that won't be helpful.
+		String bindAddress = "jgroups.bind_addr";
+		if ( properties.containsKey( bindAddress ) ) {
+			log.debug( "Found explicit value for '" + bindAddress + "' Using value: " + properties.get( bindAddress ) );
+		}
+		else {
+			log.debug( "'" + bindAddress + "' property not set. Setting it explicitly to '127.0.0.1'" );
+			System.setProperty( "jgroups.bind_addr", "127.0.0.1" );
+		}
+	}
+
 	public SearchTestCase() {
 		super();
 	}



More information about the hibernate-commits mailing list