0

Hello i try to create my database schem before tests but its fail :/ this is my script:

CREATE TABLE OFCONVERSATION
(
  CONVERSATIONID integer NOT NULL,
  ROOM character varying(1024),
  ISEXTERNAL smallint NOT NULL,
  STARTDATE bigint NOT NULL,
  LASTACTIVITY bigint NOT NULL,
  MESSAGECOUNT integer NOT NULL,
  CONSTRAINT OFCONVERSATION_PK PRIMARY KEY (CONVERSATIONID)
);

and its working when i try to run that script using squirell and embedded derby.

  1. first i try using annotation @CreateSchema("scripts/import.sql") before class test:
  2. next try to using @ApplyScriptBefore
  3. second i try using script:

property name="scriptsToExecuteBeforeTest" scripts/import.sql property

but its all fails ...

Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 9.816 sec <<< FAILURE!
getPairChat(com.test.ejb.im.service.impl.PairChatTest)  Time elapsed: 0.451 sec  <<< ERROR!
org.jboss.arquillian.persistence.dbunit.exception.DBUnitDataSetHandlingException: Unable to execute statement: CREATE TABLE OFCONVERSATION
(
CONVERSATIONID integer NOT NULL,
ROOM character varying(1024),
ISEXTERNAL smallint NOT NULL,
STARTDATE bigint NOT NULL,
LASTACTIVITY bigint NOT NULL,
MESSAGECOUNT integer NOT NULL,
CONSTRAINT OFCONVERSATION_PK PRIMARY KEY (CONVERSATIONID)
);
    at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
    at org.apache.derby.impl.sql.compile.ParserImpl.parseStatement(Unknown Source)
    at org.apache.derby.impl.sql.GenericStatement.prepMinion(Unknown Source)
    at org.apache.derby.impl.sql.GenericStatement.prepare(Unknown Source)
    at org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(Unknown Source)
    at org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown Source)
    at org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown Source

this is my arquillian pom import:

    <dependency>
      <groupId>org.glassfish.main.extras</groupId>
      <artifactId>glassfish-embedded-all</artifactId>
      <version>${glassfish-embedded-all.version}</version>
      <type>jar</type>
      <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.jboss.arquillian.junit</groupId>
        <artifactId>arquillian-junit-container</artifactId>
        <scope>test</scope>
    </dependency>  

    <dependency>
        <groupId>org.jboss.arquillian.container</groupId>
        <artifactId>arquillian-glassfish-embedded-3.1</artifactId>
        <version>1.0.0.CR3</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.jboss.arquillian.extension</groupId>
        <artifactId>arquillian-persistence-impl</artifactId>
        <version>1.0.0.Alpha6</version>
        <scope>test</scope>
    </dependency>

and my test-persistence.xml:

 <persistence-unit name="test-ejb" transaction-type="JTA">
  <jta-data-source>test-ds</jta-data-source>
  <exclude-unlisted-classes>false</exclude-unlisted-classes>      
  <properties>
      <property name="eclipselink.target-database" value="DERBY"/>
      <property name="eclipselink.platform.class.name" value="org.eclipse.persistence.platform.database.DerbyPlatform"/>
       <!-- <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/> --> 
      <property name="eclipselink.logging.level" value="ALL"/>
      <property name="eclipselink.jpa.uppercase-column-names" value="true" />
  </properties>
  </persistence-unit>

and glassfish-resources.xml:

<resources>
    <jdbc-connection-pool name="test-pool"
        res-type="javax.sql.DataSource" datasource-classname="org.apache.derby.jdbc.EmbeddedDataSource"
        ping="true">
        <property name="ConnectionAttributes" value="create=true" />
        <property name="DatabaseName" value="./target/derbydb" />
        <property name="Password" value="" />
        <property name="User" value="" />
    </jdbc-connection-pool>
    <jdbc-resource jndi-name="test-ds" pool-name="test-pool" />
</resources>

So what is wrong with that sql scripts or with my config ?

Łukasz Woźniczka
  • 1,625
  • 3
  • 28
  • 51

2 Answers2

0

If you get (or something similar as you're using Derby):

Caused by: java.sql.SQLException: ORA-00911: invalid character

further down in your stack trace then you may have stumbled on a broken feature in Alpha6.

BoneGoat
  • 554
  • 5
  • 9
0

This would help you as I have removed special characters (Carriage Return , Line feed ...)

CREATE TABLE OFCONVERSATION(  CONVERSATIONID integer NOT NULL,  ROOM character varying(1024),  ISEXTERNAL smallint NOT NULL,  STARTDATE bigint NOT NULL,  LASTACTIVITY bigint NOT NULL,  MESSAGECOUNT integer NOT NULL,  CONSTRAINT OFCONVERSATION_PK PRIMARY KEY (CONVERSATIONID))
rogue lad
  • 2,413
  • 2
  • 29
  • 32