您好,我尝试在测试之前创建我的数据库方案,但它失败了:/这是我的脚本:
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)
);
当我尝试使用 squirell 和嵌入式 derby 运行该脚本时,它的工作原理。
- 首先我尝试在类测试之前使用注释 @CreateSchema("scripts/import.sql") :
- 下次尝试使用@ApplyScriptBefore
- 第二我尝试使用脚本:
属性名称="scriptsToExecuteBeforeTest" 脚本/import.sql 属性
但这一切都失败了...
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
这是我的 arquillian pom 导入:
<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>
和我的 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>
和 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>
那么那个 sql 脚本或我的配置有什么问题?