[junit] test cases are in a different project
authorAsier Lostalé <asier.lostale@openbravo.com>
Tue, 12 Aug 2014 21:16:35 +0200
changeset 24247 a0955a83d426
parent 24246 a007832a5c77
child 24248 ce5524b59abf
[junit] test cases are in a different project

- compilation is done separatelly
- jars need to be included in lib/test directory
- new eclipse project for tests
.classpath.template
build.xml
lib/build/hamcrest-all-1.3.jar
lib/build/junit.jar
lib/test/hamcrest-all-1.3.jar
lib/test/junit.jar
src-test/.classpath.template
src-test/.project
src-test/build.xml
src-test/log4j.lcf
src/build.xml
--- a/.classpath.template	Tue Aug 12 18:56:23 2014 +0000
+++ b/.classpath.template	Tue Aug 12 21:16:35 2014 +0200
@@ -21,7 +21,6 @@
 	<classpathentry kind="src" path="modules/org.openbravo.service.datasource/src"/>
 	<classpathentry kind="src" path="modules/org.openbravo.service.integration.openid/src"/>
 	<classpathentry kind="src" path="modules/org.openbravo.service.integration.google/src"/>
-	<classpathentry kind="src" path="src-test"/>
 	<classpathentry including="quartz.properties" kind="src" path="config"/>
 	<classpathentry kind="src" path="src-gen"/>
 	<classpathentry including="**/*.java" kind="src" path="srcAD"/>
--- a/build.xml	Tue Aug 12 18:56:23 2014 +0000
+++ b/build.xml	Tue Aug 12 21:16:35 2014 +0200
@@ -12,7 +12,7 @@
 * under the License.
 * The Original Code is Openbravo ERP.
 * The Initial Developer of the Original Code is Openbravo SLU
-* All portions are Copyright (C) 2001-2013 Openbravo SLU
+* All portions are Copyright (C) 2001-2014 Openbravo SLU
 * All Rights Reserved.
 * Contributor(s):  ______________________________________.
 ************************************************************************
@@ -250,12 +250,14 @@
     </fileset>
     <fileset dir="${base.lib}">
       <include name="**/*.jar" />
+      <exclude name="**/test/*.jar" />
     </fileset>
     <fileset dir="${base.db}/lib/">
       <include name="**/*.jar" />
     </fileset>
     <fileset dir="${base.modules}">
       <include name="*/lib/**" />
+       <exclude name="**/test/*.jar" />
     </fileset>
   </path>
 
@@ -575,20 +577,24 @@
     <ant dir="${base.src}" target="generate.entities.quick.forked" inheritAll="true" inheritRefs="true" />
   </target>
 
+  <target name="compile.test" depends="init">
+    <ant dir="${base.src.test}" target="compile.test" inheritAll="true" inheritRefs="true" />
+  </target>
+  
   <target name="run.tests" depends="init">
-    <ant dir="${base.src}" target="run.tests" inheritAll="true" inheritRefs="true" />
+    <ant dir="${base.src.test}" target="run.tests" inheritAll="true" inheritRefs="true" />
   </target>
 
   <target name="run.all.tests" depends="init">
-    <ant dir="${base.src}" target="run.all.tests" inheritAll="true" inheritRefs="true" />
+    <ant dir="${base.src.test}" target="run.all.tests" inheritAll="true" inheritRefs="true" />
   </target>
 
   <target name="run.webservice.tests" depends="init">
-      <ant dir="${base.src}" target="run.webservice.tests" inheritAll="true" inheritRefs="true" />
+      <ant dir="${base.src.test}" target="run.webservice.tests" inheritAll="true" inheritRefs="true" />
   </target>
 
   <target name="run.quick.tests" depends="init">
-    <ant dir="${base.src}" target="run.quick.tests" inheritAll="true" inheritRefs="true" />
+    <ant dir="${base.src.test}" target="run.quick.tests" inheritAll="true" inheritRefs="true" />
   </target>
 
   <target name="run.api.test.javascript">
Binary file lib/build/hamcrest-all-1.3.jar has changed
Binary file lib/build/junit.jar has changed
Binary file lib/test/hamcrest-all-1.3.jar has changed
Binary file lib/test/junit.jar has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/.classpath.template	Tue Aug 12 21:16:35 2014 +0200
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry combineaccessrules="false" kind="src" path="/openbravo"/>
+	<classpathentry excluding="build/**" kind="src" path=""/>
+	<classpathentry kind="lib" path="/openbravo/lib/test/junit.jar"/>
+	<classpathentry kind="lib" path="/openbravo/lib/test/hamcrest-all-1.3.jar"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container/openbravo"/>
+	<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v6.0"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/OpenbravoWAD"/>
+	<classpathentry kind="output" path="build/classes"/>
+</classpath>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/.project	Tue Aug 12 21:16:35 2014 +0200
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>OpenbravoTest</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/build.xml	Tue Aug 12 21:16:35 2014 +0200
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo Public License 
+ * Version 1.1 (the "License"), being the Mozilla Public License 
+ * version 1.1  with a permitted attribution clause ; you may not use 
+ * this file except in compliance with the License. 
+ * You may obtain a copy of the License at  
+ * http://www.openbravo.com/legal/license.txt 
+ * Software distributed under the License is distributed on an 
+ * "AS IS" basis, WITHOUT WARRANTY OF  ANY KIND, either express or 
+ * implied. See the License for the specific language governing rights 
+ * and  limitations under the License. 
+ * The Original Code is Openbravo ERP. 
+ * The Initial Developer of the Original Code is Openbravo SLU 
+ * All portions are Copyright (C) 2014 Openbravo SLU 
+ * All Rights Reserved. 
+ * Contributor(s): Openbravo S.L.U.
+ ************************************************************************
+-->
+
+<project name="openbravo" default="compile.complete" basedir="..">
+  <import file="../src/build.xml" />
+
+  <property name="build.test" location="${base.src.test}/build/classes" />
+
+  <path id="test-src-dirs">
+    <pathelement path="${base.src.test}" />
+    <dirset dir="${base.modules}">
+      <include name="*/src-test" />
+    </dirset>
+  </path>
+
+  <path id="test.class.path">
+    <path refid="project.class.path"/>
+    <fileset dir="${base.lib}">
+      <include name="**/test/*.jar" />
+    </fileset>
+    <fileset dir="${base.modules}">
+      <include name="**/test/*.jar" />
+    </fileset> 
+  </path>
+
+  <target name="compile.test" depends="compileSqlc,generate.entities.quick">
+  	 <mkdir dir="${build.test}"/>
+     <javac destdir="${build.test}" encoding="UTF-8" fork="true" memorymaximumsize="${build.maxmemory}" debug="true" debuglevel="lines,vars,source" nowarn="${friendlyWarnings}" includeantruntime="false">
+      <src refid="test-src-dirs"/>
+      <classpath refid="test.class.path" />
+    </javac>
+  </target>
+
+  <target name="copy.xml">
+    <copy todir="${build}">
+      <fileset dir="${base.src.test}" includes="**/*.xml" />
+    </copy>
+  </target>
+
+  <target name="run.tests" depends="compile.test, copy.xml">
+    <junit printsummary="yes" haltonfailure="yes">
+      <classpath refid="project.class.path" />
+      <formatter type="plain" usefile="no"/>
+      <test name="org.openbravo.test.AntTaskTests" haltonfailure="no"/>
+    </junit>
+  </target>
+
+  <target name="run.all.tests" depends="compile.test, copy.xml">
+    <junit printsummary="yes" haltonfailure="yes">
+      <classpath refid="project.class.path" />
+      <formatter type="plain" usefile="no"/>
+      <test name="org.openbravo.test.AllAntTaskTests" haltonfailure="no" outfile="../src/result">
+      <formatter type="xml" />
+    </test>
+    </junit>
+  </target>
+
+  <target name="run.quick.tests" depends="compile.test, copy.xml">
+    <junit printsummary="yes" haltonfailure="yes">
+      <classpath refid="project.class.path" />
+      <formatter type="plain" usefile="no"/>
+      <test name="org.openbravo.test.AllQuickAntTaskTests" haltonfailure="no"/>
+    </junit>
+  </target>
+
+  <target name="run.webservice.tests" depends="compile.test, copy.xml">
+    <junit printsummary="yes" haltonfailure="yes">
+      <classpath refid="project.class.path" />
+      <formatter type="plain" usefile="no"/>
+      <test name="org.openbravo.test.AllWebserviceTests" haltonfailure="no" outfile="../src/resultws">
+        <formatter type="xml" />
+      </test>
+    </junit>
+  </target>
+</project>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/log4j.lcf	Tue Aug 12 21:16:35 2014 +0200
@@ -0,0 +1,67 @@
+#*************************************************************************
+#* The contents of this file are subject to the Openbravo  Public  License
+#* Version  1.1  (the  "License"),  being   the  Mozilla   Public  License
+#* Version 1.1  with a permitted attribution clause; you may not  use this
+#* file except in compliance with the License. You  may  obtain  a copy of
+#* the License at http://www.openbravo.com/legal/license.html 
+#* Software distributed under the License  is  distributed  on  an "AS IS"
+#* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+#* License for the specific  language  governing  rights  and  limitations
+#* under the License. 
+#* The Original Code is Openbravo ERP. 
+#* The Initial Developer of the Original Code is Openbravo SLU 
+#* All portions are Copyright (C) 2014 Openbravo SLU 
+#* All Rights Reserved. 
+#* Contributor(s):  ______________________________________.
+#************************************************************************
+
+# File is used by ApplyModule and other ant tasks
+
+log4j.rootCategory=INFO, A1, O2
+
+# Additional Appender used for Improved Upgrade Process
+log4j.appender.O2=org.openbravo.utils.OBRebuildAppender
+
+# A1 is set to be a ConsoleAppender. 
+log4j.appender.A1=org.apache.log4j.ConsoleAppender
+  
+# A1 uses PatternLayout.
+log4j.appender.A1.layout=org.apache.log4j.PatternLayout
+log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c - %m%n
+
+log4j.category.org.openbravo.data.Sqlc=INFO
+log4j.category.org.openbravo.translate.Translate=INFO
+log4j.category.org.openbravo.wad=INFO
+#log4j.category.org.openbravo.translate=INFO
+
+log4j.category.org=WARN
+
+#****************************************************
+#Part added for hibernate
+#****************************************************
+log4j.logger.org.hibernate=error
+
+### log HQL query parser activity 
+#log4j.logger.org.hibernate.hql.ast.AST=error
+
+### log just the SQL
+log4j.logger.org.hibernate.SQL=error
+
+### log JDBC bind parameters ###
+log4j.logger.org.hibernate.type=error
+
+### log schema export/update ###
+log4j.logger.org.hibernate.tool.hbm2ddl=error
+
+### log HQL parse trees
+log4j.logger.org.hibernate.hql=error
+
+### log cache activity ###
+log4j.logger.org.hibernate.cache=error
+
+### log transaction activity
+log4j.logger.org.hibernate.transaction=error
+
+### log JDBC resource acquisition
+log4j.logger.org.hibernate.jdbc=error
+
--- a/src/build.xml	Tue Aug 12 18:56:23 2014 +0000
+++ b/src/build.xml	Tue Aug 12 21:16:35 2014 +0200
@@ -256,63 +256,7 @@
   <target name="generate.entities.quick.forked" depends="compile.src.gen">
     <taskdef name="workflow" classpathref="project.class.path" classname="org.openbravo.base.gen.GenerateEntitiesTask" />
     <workflow friendlyWarnings="${friendlyWarnings}" srcGenPath="${base.src.gen}" propertiesFile="${base.config}/Openbravo.properties" />
-  </target>
-
-  <target name="run.tests" depends="compileSqlc,generate.entities.quick">
-    
-    <copy todir="${build}">
-      <fileset dir="${base.src.test}" includes="**/*.xml" />
-    </copy>
-    
-    <junit printsummary="yes" haltonfailure="yes">
-      <classpath refid="project.class.path" />
-      <formatter type="plain" usefile="no"/>
-      <test name="org.openbravo.test.AntTaskTests" haltonfailure="no"/>
-    </junit>
-  </target>
-
-  <target name="run.all.tests" depends="compileSqlc,generate.entities.quick">
-    
-    <copy todir="${build}">
-      <fileset dir="${base.src.test}" includes="**/*.xml" />
-    </copy>
-
-    <junit printsummary="yes" haltonfailure="yes">
-      <classpath refid="project.class.path" />
-      <formatter type="plain" usefile="no"/>
-      <test name="org.openbravo.test.AllAntTaskTests" haltonfailure="no" outfile="result">
-	    <formatter type="xml" />
-	  </test>
-    </junit>
-  </target>
-
-  <target name="run.quick.tests" depends="compileSqlc,generate.entities.quick">
-    
-    <copy todir="${build}">
-      <fileset dir="${base.src.test}" includes="**/*.xml" />
-    </copy>
-    
-    <junit printsummary="yes" haltonfailure="yes">
-      <classpath refid="project.class.path" />
-      <formatter type="plain" usefile="no"/>
-      <test name="org.openbravo.test.AllQuickAntTaskTests" haltonfailure="no"/>
-    </junit>
-  </target>
-
-  <target name="run.webservice.tests" depends="compileSqlc,generate.entities.quick">
-    
-    <copy todir="${build}">
-      <fileset dir="${base.src.test}" includes="**/*.xml" />
-    </copy>
-
-    <junit printsummary="yes" haltonfailure="yes">
-      <classpath refid="project.class.path" />
-      <formatter type="plain" usefile="no"/>
-      <test name="org.openbravo.test.AllWebserviceTests" haltonfailure="no" outfile="resultws">
-        <formatter type="xml" />
-      </test>
-    </junit>
-  </target>
+  </target> 
 
   <target name="run.api.test.javascript">
   	<taskdef name="jstest" classname="org.openbravo.test.javascript.JavaScriptAntTest" classpathref="project.class.path" />
@@ -324,10 +268,8 @@
     <pathelement path="${basedir}" />
     <pathelement path="${build.sqlc}/src" />
     <pathelement path="${build.sqlc}/srcAD" />
-    <pathelement path="${base.src.test}" />
     <dirset dir="${base.modules}">
       <include name="*/src" />
-      <include name="*/src-test" />
     </dirset>
   </path>