4 Replies Latest reply on Aug 14, 2008 4:07 AM by jhedden.jhedden.opsource.net

    Integration testing - HSQL and columnDefinition

    jhedden.jhedden.opsource.net

      My Dev/Stage/Prod Databases are all MySQL.  I am trying to create/run some in memory unit/integration tests using HSQLDB with the hopes of incorporating it into some sort of CI.


      Ant script for testing:


      <target name="test" depends="test:buildtest" description="Run the tests">
                      <taskdef resource="testngtasks" classpath="${testng.jar}" />
                      <path id="test.path">
                              <path path="${test.dir}" />
                              <fileset dir="${lib.dir}/test">
                                      <include name="*.jar"/>
                              </fileset>
                      <path path="${bootstrap.dir}" />
                      <path refid="build.classpath" />
                      </path>
                      <testng outputdir="${basedir}/test-report">
                              <classpath refid="test.path" />
                      <xmlfileset dir="${test.dir}" includes="testng.xml" />
                  </testng>
              </target>
              
              <target name="test:buildtest" depends="test:compiletest,test:copytestclasses" description="Build the tests">
                      <copy todir="${test.dir}">
                              <fileset dir="${basedir}/resources">
                                      <exclude name="META-INF/persistence*.xml"/>
                                      <exclude name="${project.name}-*-ds.xml"/>
                      </fileset>
                      </copy>
                      <copy tofile="${test.dir}/META-INF/persistence.xml" file="${basedir}/resources/META-INF/persistence-test.xml" overwrite="true"/>
                  <copy tofile="${test.dir}/import.sql" file="${basedir}/sql/import-test.sql" overwrite="true"/>
                  <copy todir="${test.dir}" flatten="true">
                      <fileset dir="${src.test.dir}">
                              <include name="**/testng.xml" />
                      </fileset>
                  </copy>
              </target>



      As you can see my persistence-test.xml gets copied to persistence.xml for testing.  Here is persistence-test.xml:


      <persistence-unit name="ooord">
              <provider>org.hibernate.ejb.HibernatePersistence</provider>
              <jta-data-source>java:/DefaultDS</jta-data-source>
              <properties>
                  <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
                  <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
                  <property name="hibernate.show_sql" value="true"/>
                  <property name="hibernate.format_sql" value="true"/>
                  <property name="jboss.entity.manager.factory.jndi.name" value="java:/ooordEntityManagerFactory"/>           
              </properties>
          </persistence-unit>



      Running this causes the following:


      [testng] ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] Unsuccessful: create table Contact (id integer generated by default as identity (start with 1), created_on date, updated_on date, user_name varchar(255), version integer, contact_type varchar(255) not null, email varchar(255) not null, fax varchar(255), first_name varchar(50) not null, last_name varchar(50) not null, on_email_list int(1), phone varchar(255), vpn_configured int(1), order_id integer, primary key (id))
         [testng] ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] Unexpected token in statement [create table Contact (id integer generated by default as identity (start with 1), created_on date, updated_on date, user_name varchar(255), version integer, contact_type varchar(255) not null, email varchar(255) not null, fax varchar(255), first_name varchar(50) not null, last_name varchar(50) not null, on_email_list int(1]
         


      Its bombing on the columnDefinition.  If i remove, all is sublime:


       @Column(name="on_email_list", columnDefinition="int(1)")
          public boolean isOnEmailList() {
                      return onEmailList;
              }



      I vaguely remember that columnDefinition is database specific.  If thats the reason why this is crapin out during testing then what am I to do?  Run my testing in MySQL? Not only do I have int but I have blobs, text, etc.