[hibernate-commits] Hibernate SVN: r15533 - in search/trunk: src/test/org/hibernate/search/test and 1 other directories.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Fri Nov 7 14:58:13 EST 2008


Author: hardy.ferentschik
Date: 2008-11-07 14:58:13 -0500 (Fri, 07 Nov 2008)
New Revision: 15533

Added:
   search/trunk/src/test/org/hibernate/search/test/TestCase.java
   search/trunk/src/test/org/hibernate/search/test/classloading/
   search/trunk/src/test/org/hibernate/search/test/classloading/Animal.hbm.xml
   search/trunk/src/test/org/hibernate/search/test/classloading/Animal.java
   search/trunk/src/test/org/hibernate/search/test/classloading/NoAnnotationsTest.java
Modified:
   search/trunk/build.xml
   search/trunk/common-build.xml
   search/trunk/src/test/org/hibernate/search/test/HANTestCase.java
Log:
HSEARCH-104
Changed the build so that some tests are run without the optional jar files. Added test that it is possible to use Hibernate Search without JPA.

Modified: search/trunk/build.xml
===================================================================
--- search/trunk/build.xml	2008-11-07 16:06:17 UTC (rev 15532)
+++ search/trunk/build.xml	2008-11-07 19:58:13 UTC (rev 15533)
@@ -8,163 +8,186 @@
 -->
 
 <project name="Hibernate Search" default="dist" basedir="."
-    xmlns:ivy="antlib:fr.jayasoft.ivy.ant">
+         xmlns:ivy="antlib:fr.jayasoft.ivy.ant">
 
     <!-- Give user a chance to override without editing this file
 		   (and without typing -D each time it compiles it) -->
-	<property file="build.properties"/>
-	<property file="${user.home}/.ant.properties"/>
+    <property file="build.properties"/>
+    <property file="${user.home}/.ant.properties"/>
 
-	<!-- Name of project and version, used to create filenames -->
-	<property name="Name" value="Hibernate Search"/>
-	<property name="name" value="hibernate-search"/>
-	<property name="version" value="3.1.0.Beta2"/>
-	<property name="javadoc.packagenames" value="org.hibernate.search.*"/>
-	<property name="copy.test" value="true"/>
-	<property name="javac.source" value="1.5"/>
-	<property name="javac.target" value="1.5"/>
+    <!-- Name of project and version, used to create filenames -->
+    <property name="Name" value="Hibernate Search"/>
+    <property name="name" value="hibernate-search"/>
+    <property name="version" value="3.1.0.Beta2"/>
+    <property name="javadoc.packagenames" value="org.hibernate.search.*"/>
+    <property name="copy.test" value="true"/>
+    <property name="javac.source" value="1.5"/>
+    <property name="javac.target" value="1.5"/>
     <property name="jdbc.dir" value="jdbc"/>
     <property name="common.dir" value="${basedir}"/>
 
-    <property name="ivy.dep.dir" value="${basedir}/build/lib" />
+    <property name="ivy.dep.dir" value="${basedir}/build/lib"/>
 
     <!-- ivy load -->
-	<property name="ivy.jar.dir" value="${basedir}/ivy" />
-    <property name="ivy.conf.dir" value="${basedir}" />
-	<path id="ivy.lib.path">
-		<fileset dir="${ivy.jar.dir}" includes="*.jar"/>
-	</path>
-	<taskdef resource="fr/jayasoft/ivy/ant/antlib.xml"
-			  uri="antlib:fr.jayasoft.ivy.ant" classpathref="ivy.lib.path"/>
+    <property name="ivy.jar.dir" value="${basedir}/ivy"/>
+    <property name="ivy.conf.dir" value="${basedir}"/>
+    <path id="ivy.lib.path">
+        <fileset dir="${ivy.jar.dir}" includes="*.jar"/>
+    </path>
+    <taskdef resource="fr/jayasoft/ivy/ant/antlib.xml"
+             uri="antlib:fr.jayasoft.ivy.ant" classpathref="ivy.lib.path"/>
 
     <import file="${common.dir}/common-build.xml"/>
 
     <property name="build.testresources.dir" value="${build.dir}/testresources"/>
     <property name="testresources.dir" value="${basedir}/src/test-resources"/>
 
-    <!-- override order for JBossXB to bootstrap properly -->
-    <path id="junit.classpath">
-           <fileset dir="${lib.dir}">
-                 <include name="*.jar"/>
-           </fileset>
-           <pathelement path="${classes.dir}"/>
-           <pathelement path="${testclasses.dir}"/>
-           <path refid="junit.moduleclasspath"/>
-           <path refid="lib.class.path"/>
-           <path location="${clover.jar}"/>
-    </path>
-	
-    <!-- override order for JBossXB to bootstrap properly -->
-    <path id="lib.class.path">
+
+    <path id="lib.class.path.required" description="Compile and runtime libraries. Required jars only.">
         <fileset dir="${ivy.dep.dir}/core">
             <include name="*.jar"/>
             <exclude name="xml-apis.jar"/>
             <exclude name="xerces*.jar"/>
+            <exclude name="solr*.jar"/>
+            <exclude name="ejb3-persistence.jar"/>
         </fileset>
         <fileset dir="${lib.dir}">
             <include name="*.jar"/>
         </fileset>
-		<pathelement path="${clover.jar}"/>
     </path>
-	
-	<path id="junit.moduleclasspath">
+
+    <path id="lib.class.path.optional" description="Compile and runtime libraries. Optional jars only.">
+        <fileset dir="${ivy.dep.dir}/core">
+            <include name="solr*.jar"/>
+            <include name="ejb3-persistence.jar"/>
+        </fileset>
+    </path>
+
+    <path id="lib.class.path" description="Compile and runtime libraries.">
+        <path refid="lib.class.path.required"/>
+        <path refid="lib.class.path.optional"/>
+    </path>
+
+    <path id="junit.moduleclasspath.required" description="Test classes. Optional jars excluded.">
         <!-- order matters for JBoss XB proper bootstrap -->
         <fileset dir="${lib.dir}/test">
-			<include name="*.jar"/>
-			<include name="*.zip"/>
-		</fileset>
+            <include name="*.jar"/>
+        </fileset>
         <pathelement location="${src.dir}"/>
-		<pathelement location="${test.dir}"/>
-		<!-- pathelement location="${annotations.jar}"/>
-        <pathelement location="${entitymanager.jar}"/ -->
+        <pathelement location="${test.dir}"/>
         <fileset dir="${ivy.dep.dir}/test">
-			<include name="*.jar"/>
-		</fileset>
+            <include name="*.jar"/>
+            <exclude name="annotations.jar"/>
+        </fileset>
         <fileset dir="${jdbc.dir}">
-			<include name="*.jar"/>
-			<include name="*.zip"/>
-		</fileset>
-	</path>
+            <include name="*.jar"/>
+            <include name="*.zip"/>
+        </fileset>
+    </path>
 
+    <path id="junit.moduleclasspath.optional" description="Optional test jars.">
+        <fileset dir="${ivy.dep.dir}/test">
+            <include name="annotations.jar"/>
+        </fileset>
+    </path>
+
+    <path id="junit.classpath.required.only"
+          description="Classpath containing all compile and test classes excluding the optional ones, eg Annotations, Solr, JPA">
+        <fileset dir="${lib.dir}">
+            <include name="*.jar"/>
+        </fileset>
+        <pathelement path="${classes.dir}"/>
+        <pathelement path="${testclasses.dir}"/>
+        <path refid="junit.moduleclasspath.required"/>
+        <path refid="lib.class.path.required"/>
+    </path>
+
+    <path id="junit.classpath"
+          description="Classpath containing all compile and test classes including the optional ones">
+        <path refid="junit.classpath.required.only"/>
+        <path refid="junit.moduleclasspath.optional"/>
+        <path refid="lib.class.path.optional"/>
+    </path>
+
     <target name="init">
-		<antcall target="common-build.init"/>
+        <antcall target="common-build.init"/>
         <tstamp>
             <format property="now" pattern="yyyyMMddhhmmss"/>
         </tstamp>
         <mkdir dir="${ivy.dep.dir}/core"/>
         <mkdir dir="${ivy.dep.dir}/test"/>
-        <ivy:configure file="${ivy.jar.dir}/ivyconf.xml" />
+        <ivy:configure file="${ivy.jar.dir}/ivyconf.xml"/>
         <mkdir dir="${lib.dir}/test"/>
         <mkdir dir="${build.testresources.dir}"/>
     </target>
 
     <target name="get.deps.core" depends="init" description="retrieve the core dependencies">
-        <ivy:resolve conf="default" />
-        <ivy:retrieve pattern="${ivy.dep.dir}/core/[artifact].[ext]" conf="default" />
+        <ivy:resolve conf="default"/>
+        <ivy:retrieve pattern="${ivy.dep.dir}/core/[artifact].[ext]" conf="default"/>
     </target>
 
     <target name="compile" depends="init,get.deps.core" description="Compile the Java source code">
         <available
-				classname="org.eclipse.core.launcher.Main"
-				property="build.compiler"
-				value="org.eclipse.jdt.core.JDTCompilerAdapter"
-				classpath="${java.class.path}"/>
-		<javac
-				srcdir="${src.dir}"
-				destdir="${classes.dir}"
-				classpathref="lib.class.path"
-				debug="${javac.debug}"
-				optimize="${javac.optimize}"
-				nowarn="on"
+                classname="org.eclipse.core.launcher.Main"
+                property="build.compiler"
+                value="org.eclipse.jdt.core.JDTCompilerAdapter"
+                classpath="${java.class.path}"/>
+        <javac
+                srcdir="${src.dir}"
+                destdir="${classes.dir}"
+                classpathref="lib.class.path"
+                debug="${javac.debug}"
+                optimize="${javac.optimize}"
+                nowarn="on"
                 source="${javac.source}"
                 target="${javac.target}">
-			<src path="${src.dir}"/>
-		</javac>
-		<copy todir="${classes.dir}">
-			<fileset dir="${src.dir}">
-				<include name="**/resources/*.properties"/>
-				<include name="**/*.xsd"/>
-			</fileset>
-		</copy>
-	</target>
+            <src path="${src.dir}"/>
+        </javac>
+        <copy todir="${classes.dir}">
+            <fileset dir="${src.dir}">
+                <include name="**/resources/*.properties"/>
+                <include name="**/*.xsd"/>
+            </fileset>
+        </copy>
+    </target>
 
-     <target name="get.deps.test" depends="init" description="retrieve the test dependencies">
-        <ivy:resolve conf="test" />
-        <ivy:retrieve pattern="${ivy.dep.dir}/test/[artifact].[ext]" conf="test" />
+    <target name="get.deps.test" depends="init" description="retrieve the test dependencies">
+        <ivy:resolve conf="test"/>
+        <ivy:retrieve pattern="${ivy.dep.dir}/test/[artifact].[ext]" conf="test"/>
     </target>
 
     <target name="compiletest" depends="init,get.deps.test,compile" description="Compile the tests">
         <available
-				classname="org.eclipse.core.launcher.Main"
-				property="build.compiler"
-				value="org.eclipse.jdt.core.JDTCompilerAdapter"
-				classpath="${java.class.path}"/>
-		<javac
-				destdir="${testclasses.dir}"
-				classpathref="junit.classpath"
-				debug="${javac.debug}"
-				optimize="${javac.optimize}"
-				nowarn="on"
+                classname="org.eclipse.core.launcher.Main"
+                property="build.compiler"
+                value="org.eclipse.jdt.core.JDTCompilerAdapter"
+                classpath="${java.class.path}"/>
+        <javac
+                destdir="${testclasses.dir}"
+                classpathref="junit.classpath"
+                debug="${javac.debug}"
+                optimize="${javac.optimize}"
+                nowarn="on"
                 source="${javac.source}"
                 target="${javac.target}">
-			<src refid="testsrc.path"/>
-		</javac>
-	</target>
+            <src refid="testsrc.path"/>
+        </javac>
+    </target>
 
     <target name="prepare-test-resources" depends="compiletest">
         <copy todir="${build.testresources.dir}">
             <fileset dir="${testresources.dir}">
                 <include name="**/*.*"/>
-				<exclude name="hibernate.properties"/>
+                <exclude name="hibernate.properties"/>
             </fileset>
         </copy>
         <mkdir dir="${build.testresources.dir}/jars"/>
-        <jar filesetmanifest="merge" jarfile="${build.testresources.dir}/jars/jms-slave.jar" >
+        <jar filesetmanifest="merge" jarfile="${build.testresources.dir}/jars/jms-slave.jar">
             <fileset dir="${testclasses.dir}">
                 <include name="org/hibernate/search/test/jms/slave/**.*"/>
             </fileset>
         </jar>
-        <jar filesetmanifest="merge" jarfile="${build.testresources.dir}/jars/jms-master.jar" >
+        <jar filesetmanifest="merge" jarfile="${build.testresources.dir}/jars/jms-master.jar">
             <fileset dir="${testclasses.dir}">
                 <include name="org/hibernate/search/test/jms/master/**.*"/>
             </fileset>
@@ -172,101 +195,123 @@
     </target>
 
     <target name="junit" depends="compiletest, prepare-test-resources">
-		<for list="${targetdb}" param="db">
-			<sequential>
-				<antcall target="test-resources">
-					<param name="db" value="@{db}"/>
-				</antcall>
-				<mkdir dir="${testreports.dir}/@{db}"/>
-				<echo>Running against db: @{db}</echo>
-				<junit forkmode="perBatch" printsummary="yes" haltonfailure="yes">
-					<classpath>
-						<path path="${build.testresources.dir}"/>
-						<path refid="junit.classpath"/>             
-						<fileset dir="${jdbc.dir}">
-							<include name="**/*.jar"/>
-							<include name="**/*.zip"/>
-						</fileset>
-					</classpath>
-					<sysproperty key="build.dir" value="${build.dir}"/>
-					<formatter type="plain"/>
-					<formatter type="xml"/>
-					<batchtest fork="yes" todir="${testreports.dir}/@{db}" haltonfailure="no">
-						<fileset dir="${testclasses.dir}">
-							<include name="**/*Test.class"/>
-							<exclude name="**/JMSSlaveTest.class"/>
-						</fileset>
-					</batchtest>
-					<test fork="yes" todir="${testreports.dir}/@{db}" haltonfailure="no" name="org.hibernate.search.test.jms.slave.JMSSlaveTest"/>	
-				</junit>
-			</sequential>
-		</for>		
+        <for list="${targetdb}" param="db">
+            <sequential>
+                <antcall target="test-resources">
+                    <param name="db" value="@{db}"/>
+                </antcall>
+                <mkdir dir="${testreports.dir}/@{db}"/>
+                <echo>Running against db: @{db}</echo>
+                <junit forkmode="perBatch" printsummary="yes" haltonfailure="yes">
+                    <classpath>
+                        <path path="${build.testresources.dir}"/>
+                        <path refid="junit.classpath"/>
+                        <fileset dir="${jdbc.dir}">
+                            <include name="**/*.jar"/>
+                            <include name="**/*.zip"/>
+                        </fileset>
+                    </classpath>
+                    <sysproperty key="build.dir" value="${build.dir}"/>
+                    <formatter type="plain"/>
+                    <formatter type="xml"/>
+                    <batchtest fork="yes" todir="${testreports.dir}/@{db}" haltonfailure="no">
+                        <fileset dir="${testclasses.dir}">
+                            <include name="**/*Test.class"/>
+                            <exclude name="**/JMSSlaveTest.class"/>
+                            <exclude name="**/classloading/**"/>
+                        </fileset>
+                    </batchtest>
+                    <test fork="yes"
+                          todir="${testreports.dir}/@{db}"
+                          haltonfailure="no"
+                          name="org.hibernate.search.test.jms.slave.JMSSlaveTest"/>
+                </junit>
+                <junit forkmode="perBatch" printsummary="yes" haltonfailure="yes">
+                    <classpath>
+                        <path path="${build.testresources.dir}"/>
+                        <path refid="junit.classpath.required.only"/>
+                        <fileset dir="${jdbc.dir}">
+                            <include name="**/*.jar"/>
+                            <include name="**/*.zip"/>
+                        </fileset>
+                    </classpath>
+                    <sysproperty key="build.dir" value="${build.dir}"/>
+                    <formatter type="plain"/>
+                    <formatter type="xml"/>
+                    <batchtest fork="yes" todir="${testreports.dir}/@{db}" haltonfailure="no">
+                        <fileset dir="${testclasses.dir}">
+                            <include name="**/classloading/**/*Test.class"/>
+                        </fileset>
+                    </batchtest>
+                </junit>
+            </sequential>
+        </for>
     </target>
 
-	<!-- Run a single unit test. -->
-	<target name="junitsingle" depends="compiletest"
-			description="Run a single test suite (requires testname and jdbc.driver properties)">
-		<for list="${targetdb}" param="db">
-			<sequential>
-				<antcall target="test-resources">
-					<param name="db" value="@{db}"/>
-				</antcall>
-				<mkdir dir="${testreports.dir}/@{db}"/>
-				<echo>Running against db: @{db}</echo>
-				<junit printsummary="yes" fork="yes" haltonfailure="yes">
-					<classpath>
-						<path path="${build.testresources.dir}"/>
-						<path refid="junit.classpath"/>             
-						<fileset dir="${jdbc.dir}">
-							<include name="**/*.jar"/>
-							<include name="**/*.zip"/>
-						</fileset>
-					</classpath>
-					<sysproperty key="build.dir" value="${build.dir}"/>
-					<formatter type="plain"/>
-					<formatter type="xml"/>
-					<test fork="yes" todir="${testreports.dir}/@{db}" haltonfailure="no" name="${testname}"/>
-				</junit>
-			</sequential>
-		</for>		
-	</target>
+    <!-- Run a single unit test. -->
+    <target name="junitsingle" depends="compiletest"
+            description="Run a single test suite (requires testname and jdbc.driver properties)">
+        <for list="${targetdb}" param="db">
+            <sequential>
+                <antcall target="test-resources">
+                    <param name="db" value="@{db}"/>
+                </antcall>
+                <mkdir dir="${testreports.dir}/@{db}"/>
+                <echo>Running against db: @{db}</echo>
+                <junit printsummary="yes" fork="yes" haltonfailure="yes">
+                    <classpath>
+                        <path path="${build.testresources.dir}"/>
+                        <path refid="junit.classpath"/>
+                        <fileset dir="${jdbc.dir}">
+                            <include name="**/*.jar"/>
+                            <include name="**/*.zip"/>
+                        </fileset>
+                    </classpath>
+                    <sysproperty key="build.dir" value="${build.dir}"/>
+                    <formatter type="plain"/>
+                    <formatter type="xml"/>
+                    <test fork="yes" todir="${testreports.dir}/@{db}" haltonfailure="no" name="${testname}"/>
+                </junit>
+            </sequential>
+        </for>
+    </target>
 
-	<target name="jar" depends="compile" description="Build the distribution .jar file">
-		<mkdir dir="${classes.dir}/META-INF"/>
-		<manifest file="${classes.dir}/META-INF/MANIFEST.MF">
-			<attribute name="Implementation-Title" value="${Name}"/>
-			<attribute name="Implementation-Version" value="${version}"/>
+    <target name="jar" depends="compile" description="Build the distribution .jar file">
+        <mkdir dir="${classes.dir}/META-INF"/>
+        <manifest file="${classes.dir}/META-INF/MANIFEST.MF">
+            <attribute name="Implementation-Title" value="${Name}"/>
+            <attribute name="Implementation-Version" value="${version}"/>
             <attribute name="Implementation-Vendor" value="hibernate.org"/>
             <attribute name="Implementation-Vendor-Id" value="hibernate.org"/>
             <attribute name="Implementation-URL" value="http://search.hibernate.org"/>
-		</manifest>
-		<antcall target="common-build.jar"/>
+        </manifest>
+        <antcall target="common-build.jar"/>
         <ivy:resolve conf="default"/>
         <ivy:publish artifactspattern="${dist.dir}/[artifact].[ext]"
-            resolver="local"
-            pubrevision="latest"
-            pubdate="${now}"
-            status="integration"
-        />
+                     resolver="local"
+                     pubrevision="latest"
+                     pubdate="${now}"
+                     status="integration"
+                />
     </target>
 
-	<!-- Some of this can probably be moved to common-build... -->
-	<target name="dist" depends="get.deps.core,get.deps.test,jar,jar,javadoc,copysource,copytest,copylib,extras"
-			description="Build everything">
+    <!-- Some of this can probably be moved to common-build... -->
+    <target name="dist" depends="get.deps.core,get.deps.test,jar,jar,javadoc,copysource,copytest,copylib,extras"
+            description="Build everything">
 
-		<ant inheritall="false" dir="${basedir}/doc/reference"/>
-		<copy todir="${dist.dir}/doc/reference" failonerror="false">
-			<fileset dir="${basedir}/doc/reference/build">
-				<include name="**/*.*"/>
+        <ant inheritall="false" dir="${basedir}/doc/reference"/>
+        <copy todir="${dist.dir}/doc/reference" failonerror="false">
+            <fileset dir="${basedir}/doc/reference/build">
+                <include name="**/*.*"/>
                 <exclude name="en/master.xml"/>
-			</fileset>
-		</copy>
+            </fileset>
+        </copy>
 
-		<copy todir="${dist.dir}" failonerror="false">
-			<fileset dir="${common.dir}">
-				<include name="common-build.xml"/>
-			</fileset>
-		</copy>
+        <copy todir="${dist.dir}" failonerror="false">
+            <fileset dir="${common.dir}">
+                <include name="common-build.xml"/>
+            </fileset>
+        </copy>
 
         <copy todir="${dist.dir}/test-resources" failonerror="false">
             <fileset dir="${testresources.dir}">
@@ -281,31 +326,32 @@
 
         <!-- copy dependencies -->
         <copy todir="${dist.lib.dir}" failonerror="false">
-			<!-- fileset file="${jpa-api.jar}"/>
-            <fileset file="${commons-annotations.jar}"/ -->
+            <!-- fileset file="${jpa-api.jar}"/>
+                        <fileset file="${commons-annotations.jar}"/ -->
             <fileset dir="${ivy.dep.dir}/core">
                 <include name="*.jar"/>
             </fileset>
         </copy>
         <mkdir dir="${dist.lib.dir}/test"/>
         <copy todir="${dist.lib.dir}/test" failonerror="false">
-			<fileset dir="${ivy.dep.dir}/test">
+            <fileset dir="${ivy.dep.dir}/test">
                 <include name="*.jar"/>
             </fileset>
         </copy>
         <copy todir="${dist.lib.dir}/test" failonerror="false">
-			<fileset file="${lib.dir}/test/*.jar"/>
+            <fileset file="${lib.dir}/test/*.jar"/>
         </copy>
 
         <mkdir dir="${dist.lib.dir}/build"/>
         <copy todir="${dist.lib.dir}/build" failonerror="false">
-			<fileset file="${lib.dir}/build/*.jar"/>
+            <fileset file="${lib.dir}/build/*.jar"/>
         </copy>
 
         <!-- ivy uses the module name without hibernate- (to mimic the directory names). Revert the situation -->
         <move file="${dist.lib.dir}/commons-annotations.jar" tofile="${dist.lib.dir}/hibernate-commons-annotations.jar"
               failonerror="false"/>
-        <move file="${dist.lib.dir}/test/commons-annotations.jar" tofile="${dist.lib.dir}/test/hibernate-commons-annotations.jar"
+        <move file="${dist.lib.dir}/test/commons-annotations.jar"
+              tofile="${dist.lib.dir}/test/hibernate-commons-annotations.jar"
               failonerror="false"/>
         <move file="${dist.lib.dir}/test/annotations.jar" tofile="${dist.lib.dir}/test/hibernate-annotations.jar"
               failonerror="false"/>
@@ -314,16 +360,16 @@
 
 
         <copy file="${basedir}/build.properties.dist" tofile="${dist.dir}/build.properties" failonerror="false">
-		</copy>
-		<antcall target="common-build.dist"/>
-	</target>
+        </copy>
+        <antcall target="common-build.dist"/>
+    </target>
 
     <target name="zip-dist" description="zip the dist">
-		<zip zipfile="${dist.dir}-${version}.zip">
-			<zipfileset prefix="${name}-${version}" dir="${dist.dir}"/>
-		</zip>
-		<tar compression="gzip" tarfile="${dist.dir}-${version}.tar.gz">
-			<tarfileset prefix="${name}-${version}" dir="${dist.dir}"/>
-		</tar>
-	</target>
+        <zip zipfile="${dist.dir}-${version}.zip">
+            <zipfileset prefix="${name}-${version}" dir="${dist.dir}"/>
+        </zip>
+        <tar compression="gzip" tarfile="${dist.dir}-${version}.tar.gz">
+            <tarfileset prefix="${name}-${version}" dir="${dist.dir}"/>
+        </tar>
+    </target>
 </project>

Modified: search/trunk/common-build.xml
===================================================================
--- search/trunk/common-build.xml	2008-11-07 16:06:17 UTC (rev 15532)
+++ search/trunk/common-build.xml	2008-11-07 19:58:13 UTC (rev 15533)
@@ -99,7 +99,6 @@
 	
 	<path id="lib.class.path">
 		<path refid="lib.moduleclass.path"/>
-		<pathelement path="${clover.jar}"/>
 	</path>
 	
 	<!-- overridable in modules -->
@@ -137,15 +136,7 @@
 	<path id="testsrc.path">
 		<pathelement location="${test.dir}"/>
 	</path>
-		
-	<path id="junit.classpath">
-		<pathelement path="${classes.dir}"/>
-		<pathelement path="${testclasses.dir}"/>
-		<path refid="lib.class.path"/>
-		<path refid="junit.moduleclasspath"/>
-		<path location="${clover.jar}"/>
-	</path>
-	
+			
 	<!-- Determine the database against which to run  tests-->
 	<if>
 		<equals arg1="${targetdb}" arg2="$${targetdb}"/>
@@ -155,30 +146,11 @@
 		</then>
 	</if>
 	
-	<!-- Clover tasks -->
-	<target name="with.clover">
-		<clover-setup initString="clover_coverage.db"/>
-	</target>
-	
-	<target name="cloverreport.html" depends="with.clover"
-		description="Generate a clover report from the current clover database.">
-		<clover-report>
-			<current outfile="${clover.out.dir}">
-				<format type="html"/>
-			</current>
-		</clover-report>
-	</target>
-	
-	<target name="cloverreport"
-		depends="with.clover,junitreport,cloverreport.html"
-		description="Run the tests and generate a clover report">
-	</target>
-	
+
 	<!-- Tasks -->
 	<target name="clean" description="Cleans up build and dist directories">
 		<delete dir="${build.dir}"/>
 		<delete dir="${dist.target.dir}"/>
-		<delete dir="${clover.out.dir}"/>
 	</target>
 	
 	<target name="init" description="Initialize the build">

Modified: search/trunk/src/test/org/hibernate/search/test/HANTestCase.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/HANTestCase.java	2008-11-07 16:06:17 UTC (rev 15532)
+++ search/trunk/src/test/org/hibernate/search/test/HANTestCase.java	2008-11-07 19:58:13 UTC (rev 15533)
@@ -3,27 +3,18 @@
 
 import java.io.InputStream;
 
-import org.hibernate.SessionFactory;
-import org.hibernate.Session;
-import org.hibernate.HibernateException;
-import org.hibernate.Interceptor;
-import org.hibernate.dialect.Dialect;
 import org.hibernate.cfg.AnnotationConfiguration;
 import org.hibernate.cfg.Environment;
-import org.hibernate.cfg.Configuration;
+import org.hibernate.dialect.Dialect;
 
 /**
- * copy from HAN
+ * Originally a copy from Hibernate Annotations.
+ *
  * @author Emmanuel Bernard
+ * @author Hardy Ferentschik
  */
-public abstract class HANTestCase extends junit.framework.TestCase {
+public abstract class HANTestCase extends TestCase {
 
-	private static SessionFactory sessions;
-	private static AnnotationConfiguration cfg;
-	private static Dialect dialect;
-	private static Class lastTestClass;
-	private Session session;
-
 	public HANTestCase() {
 		super();
 	}
@@ -33,28 +24,29 @@
 	}
 
 	protected void buildSessionFactory(Class[] classes, String[] packages, String[] xmlFiles) throws Exception {
-
-		if ( getSessions() != null ) getSessions().close();
+		if ( getSessions() != null ) {
+			getSessions().close();
+		}
 		try {
 			setCfg( new AnnotationConfiguration() );
 			configure( cfg );
 			if ( recreateSchema() ) {
 				cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
 			}
-			for ( int i = 0; i < packages.length; i++ ) {
-				getCfg().addPackage( packages[i] );
+			for ( String aPackage : packages ) {
+				( ( AnnotationConfiguration ) getCfg() ).addPackage( aPackage );
 			}
-			for ( int i = 0; i < classes.length; i++ ) {
-				getCfg().addAnnotatedClass( classes[i] );
+			for ( Class aClass : classes ) {
+				( ( AnnotationConfiguration ) getCfg() ).addAnnotatedClass( aClass );
 			}
-			for ( int i = 0; i < xmlFiles.length; i++ ) {
-				InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream( xmlFiles[i] );
+			for ( String xmlFile : xmlFiles ) {
+				InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream( xmlFile );
 				getCfg().addInputStream( is );
 			}
 			setDialect( Dialect.getDialect() );
 			setSessions( getCfg().buildSessionFactory( /*new TestInterceptor()*/ ) );
 		}
-		catch (Exception e) {
+		catch ( Exception e ) {
 			e.printStackTrace();
 			throw e;
 		}
@@ -67,92 +59,9 @@
 		}
 	}
 
-	protected void runTest() throws Throwable {
-		try {
-			super.runTest();
-			if ( session != null && session.isOpen() ) {
-				if ( session.isConnected() ) session.connection().rollback();
-				session.close();
-				session = null;
-				fail( "unclosed session" );
-			}
-			else {
-				session = null;
-			}
-		}
-		catch (Throwable e) {
-			try {
-				if ( session != null && session.isOpen() ) {
-					if ( session.isConnected() ) session.connection().rollback();
-					session.close();
-				}
-			}
-			catch (Exception ignore) {
-			}
-			try {
-				if ( sessions != null ) {
-					sessions.close();
-					sessions = null;
-				}
-			}
-			catch (Exception ignore) {
-			}
-			throw e;
-		}
-	}
-
-	public Session openSession() throws HibernateException {
-		session = getSessions().openSession();
-		return session;
-	}
-
-	public Session openSession(Interceptor interceptor) throws HibernateException {
-		session = getSessions().openSession( interceptor );
-		return session;
-	}
-
 	protected abstract Class[] getMappings();
 
 	protected String[] getAnnotatedPackages() {
-		return new String[]{};
+		return new String[] { };
 	}
-
-	protected String[] getXmlFiles() {
-		return new String[]{};
-	}
-
-	private void setSessions(SessionFactory sessions) {
-		HANTestCase.sessions = sessions;
-	}
-
-	protected SessionFactory getSessions() {
-		return sessions;
-	}
-
-	private void setDialect(Dialect dialect) {
-		HANTestCase.dialect = dialect;
-	}
-
-	protected Dialect getDialect() {
-		return dialect;
-	}
-
-	protected static void setCfg(AnnotationConfiguration cfg) {
-		HANTestCase.cfg = cfg;
-	}
-
-	protected static AnnotationConfiguration getCfg() {
-		return cfg;
-	}
-
-	protected void configure(Configuration cfg) {
-		//cfg.setNamingStrategy( AlternativeNamingStrategy.INSTANCE );
-		//cfg.getSessionEventListenerConfig().setFlushEventListener( new EJB3FlushEventListener() );
-		//cfg.getSessionEventListenerConfig().setAutoFlushEventListener( new EJB3AutoFlushEventListener() );
-	}
-
-	protected boolean recreateSchema() {
-		return true;
-	}
-
 }

Added: search/trunk/src/test/org/hibernate/search/test/TestCase.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/TestCase.java	                        (rev 0)
+++ search/trunk/src/test/org/hibernate/search/test/TestCase.java	2008-11-07 19:58:13 UTC (rev 15533)
@@ -0,0 +1,157 @@
+//$Id: HANTestCase.java 14687 2008-05-22 18:21:01Z epbernard $
+package org.hibernate.search.test;
+
+import java.io.InputStream;
+
+import org.apache.lucene.analysis.StopAnalyzer;
+
+import org.hibernate.HibernateException;
+import org.hibernate.Interceptor;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.search.store.RAMDirectoryProvider;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.Environment;
+import org.hibernate.dialect.Dialect;
+
+/**
+ * A modified base class for tests without annotations.
+ *
+ * @author Hardy Ferentschik
+ */
+public abstract class TestCase extends junit.framework.TestCase {
+
+	protected static SessionFactory sessions;
+	protected static Configuration cfg;
+	protected static Dialect dialect;
+	protected static Class lastTestClass;
+	protected Session session;
+
+	public TestCase() {
+		super();
+	}
+
+	public TestCase(String x) {
+		super( x );
+	}
+
+	protected void buildSessionFactory(String[] xmlFiles) 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 : xmlFiles ) {
+				InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream( xmlFile );
+				getCfg().addInputStream( is );
+			}
+			setDialect( Dialect.getDialect() );
+			setSessions( getCfg().buildSessionFactory() );
+		}
+		catch ( Exception e ) {
+			e.printStackTrace();
+			throw e;
+		}
+	}
+
+	protected void setUp() throws Exception {
+		if ( getSessions() == null || getSessions().isClosed() || lastTestClass != getClass() ) {
+			buildSessionFactory( getXmlFiles() );
+			lastTestClass = getClass();
+		}
+	}
+
+	protected void runTest() throws Throwable {
+		try {
+			super.runTest();
+			if ( session != null && session.isOpen() ) {
+				if ( session.isConnected() ) {
+					session.connection().rollback();
+				}
+				session.close();
+				session = null;
+				fail( "unclosed session" );
+			}
+			else {
+				session = null;
+			}
+		}
+		catch ( Throwable e ) {
+			try {
+				if ( session != null && session.isOpen() ) {
+					if ( session.isConnected() ) {
+						session.connection().rollback();
+					}
+					session.close();
+				}
+			}
+			catch ( Exception ignore ) {
+			}
+			try {
+				if ( sessions != null ) {
+					sessions.close();
+					sessions = null;
+				}
+			}
+			catch ( Exception ignore ) {
+			}
+			throw e;
+		}
+	}
+
+	public Session openSession() throws HibernateException {
+		session = getSessions().openSession();
+		return session;
+	}
+
+	public Session openSession(Interceptor interceptor) throws HibernateException {
+		session = getSessions().openSession( interceptor );
+		return session;
+	}
+
+	protected String[] getXmlFiles() {
+		return new String[] { };
+	}
+
+	protected void setSessions(SessionFactory sessions) {
+		TestCase.sessions = sessions;
+	}
+
+	protected SessionFactory getSessions() {
+		return sessions;
+	}
+
+	protected void setDialect(Dialect dialect) {
+		TestCase.dialect = dialect;
+	}
+
+	protected Dialect getDialect() {
+		return dialect;
+	}
+
+	protected static void setCfg(Configuration cfg) {
+		TestCase.cfg = cfg;
+	}
+
+	protected static Configuration getCfg() {
+		return cfg;
+	}
+
+	protected void configure(Configuration cfg) {
+		cfg.setListener( "post-update", "org.hibernate.search.event.FullTextIndexEventListener" );
+		cfg.setListener( "post-insert", "org.hibernate.search.event.FullTextIndexEventListener" );
+		cfg.setListener( "post-delete", "org.hibernate.search.event.FullTextIndexEventListener" );
+
+		cfg.setProperty( "hibernate.search.default.directory_provider", RAMDirectoryProvider.class.getName() );
+		cfg.setProperty( org.hibernate.search.Environment.ANALYZER_CLASS, StopAnalyzer.class.getName() );
+	}
+
+	protected boolean recreateSchema() {
+		return true;
+	}
+}
\ No newline at end of file

Added: search/trunk/src/test/org/hibernate/search/test/classloading/Animal.hbm.xml
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/classloading/Animal.hbm.xml	                        (rev 0)
+++ search/trunk/src/test/org/hibernate/search/test/classloading/Animal.hbm.xml	2008-11-07 19:58:13 UTC (rev 15533)
@@ -0,0 +1,13 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="org.hibernate.search.test.classloading">
+    <class name="Animal">
+        <id name="id" type="java.lang.Long">
+            <generator class="increment"/>
+        </id>
+        <property name="name"/>
+    </class>
+</hibernate-mapping>
\ No newline at end of file

Added: search/trunk/src/test/org/hibernate/search/test/classloading/Animal.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/classloading/Animal.java	                        (rev 0)
+++ search/trunk/src/test/org/hibernate/search/test/classloading/Animal.java	2008-11-07 19:58:13 UTC (rev 15533)
@@ -0,0 +1,54 @@
+// $Id:$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.search.test.classloading;
+
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Index;
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.DocumentId;
+
+/**
+ * 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;
+	}
+}
\ No newline at end of file

Added: search/trunk/src/test/org/hibernate/search/test/classloading/NoAnnotationsTest.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/classloading/NoAnnotationsTest.java	                        (rev 0)
+++ search/trunk/src/test/org/hibernate/search/test/classloading/NoAnnotationsTest.java	2008-11-07 19:58:13 UTC (rev 15533)
@@ -0,0 +1,48 @@
+// $Id: NoAnnotationsTest.java 15532 2008-11-07 16:06:17Z hardy.ferentschik $
+package org.hibernate.search.test.classloading;
+
+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.search.Search;
+
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class NoAnnotationsTest extends org.hibernate.search.test.TestCase {
+
+	/**
+	 * 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();
+	}
+
+	protected String[] getXmlFiles() {
+		return new String[] {
+				"org/hibernate/search/test/classloading/Animal.hbm.xml"
+		};
+	}
+}
\ No newline at end of file




More information about the hibernate-commits mailing list