1

I have a JavaEE project which was not changed for several months. Tests were performed with this configuration:

<dependencies>
  <dependency>
     <groupId>org.jboss.arquillian.junit</groupId>
     <artifactId>arquillian-junit-container</artifactId>
     <scope>test</scope>
     <version>1.0.0.CR7</version>
  </dependency>
</dependencies>

<profile>
     <id>arq-jbossas-remote</id>
     <activation><activeByDefault>true</activeByDefault></activation>
     <dependencies>
        <dependency>
           <groupId>org.jboss.as</groupId>
           <artifactId>jboss-as-arquillian-container-remote</artifactId>
           <version>7.1.0.Final</version>
           <scope>test</scope>
        </dependency>
     </dependencies>
  </profile>

This is running fine with JBoss AS 7.1.1.Final "Brontes". No I want to update to a recent version of JBoss AS. When switching to JBoss EAP 6.1.0.GA (AS 7.2.0.Final-redhat-8) (and also newer versions) and changing the profile-version to 7.2.0.Final I realize that several tests (checking that duplicate type-code combinations are note allowed) were failing because of a constraint not created in the MySQL database.

@Entity
@Table(uniqueConstraints = @UniqueConstraint(columnNames = {"type","code"}))

I also tried the recent version 1.1.8.Final of arquillian-junit-container with the same effect.

Update1 I'm creating a @Deployment like this, the persistence.xml is a usual hibernate persistence-unit. Before each test cycle the test-database is dropped and created, the tables are created using hibernate.hbm2ddl.auto=create.

@Deployment public static Archive<?> createTestArchive()
{
  WebArchive wa = ShrinkWrap.create(WebArchive.class, "test.war");
  ...
  wa.addAsResource("test/persistence.xml", "META-INF/persistence.xml");
}

Update2 Here is the persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
  xmlns="http://java.sun.com/xml/ns/persistence"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"> 
<persistence-unit name="test">
  <jta-data-source>java:jboss/datasources/DsTest</jta-data-source>
  <properties>
     <property name="hibernate.show_sql" value="false"/>
     <property name="hibernate.hbm2ddl.auto" value="create"/>
     <property name="hibernate.max_fetch_depth" value="0" />
     <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect"/>
  </properties>
</persistence-unit>
</persistence>
4
  • I'm confused - what does arquillian have to do with database constraints? What do you use to generate your ddl and deploy it to your database for the test run?
    – John Ament
    May 31, 2015 at 13:09
  • You are right, arquillian does not create the database constraints, arquillian is only packaging the web archive and executing the tests (see update 1).
    – Thor
    May 31, 2015 at 16:23
  • Do you want to add your persistence.xml to the question?
    – John Ament
    May 31, 2015 at 16:27
  • Of course, see update 2!
    – Thor
    May 31, 2015 at 19:53

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.