CCM NG: Fixed some problems with Arquillian, dumping test data did not work. Disabled tempoarily. Fixed some minor issues in the CcmObjectRepository classes
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@3477 8810af33-2d31-482b-a856-94f89814c4dfpull/2/head
parent
cbe2b198fd
commit
09169249ea
|
|
@ -570,6 +570,87 @@
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</profile>
|
</profile>
|
||||||
|
|
||||||
|
<profile>
|
||||||
|
<id>wildfly8-remote-h2-mem</id>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wildfly</groupId>
|
||||||
|
<artifactId>wildfly-arquillian-container-remote</artifactId>
|
||||||
|
<version>8.2.0.Final</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jacoco</groupId>
|
||||||
|
<artifactId>org.jacoco.core</artifactId>
|
||||||
|
<version>0.7.4.201502262128</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jboss.arquillian.extension</groupId>
|
||||||
|
<artifactId>arquillian-jacoco</artifactId>
|
||||||
|
<version>1.0.0.Alpha7</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<testResources>
|
||||||
|
<testResource>
|
||||||
|
<directory>/src/test/resources</directory>
|
||||||
|
</testResource>
|
||||||
|
<testResource>
|
||||||
|
<directory>/src/test/resources-wildfly8-remote-h2-mem</directory>
|
||||||
|
</testResource>
|
||||||
|
</testResources>
|
||||||
|
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>de.jpdigital</groupId>
|
||||||
|
<artifactId>hibernate4-ddl-maven-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<dialects>
|
||||||
|
<param>h2</param>
|
||||||
|
<param>mysql5_innodb</param>
|
||||||
|
<param>postgresql9</param>
|
||||||
|
</dialects>
|
||||||
|
<packages>
|
||||||
|
<param>de.jpdigital.research.accessibilitystudy</param>
|
||||||
|
</packages>
|
||||||
|
<useEnvers>true</useEnvers>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>gen-ddl</goal>
|
||||||
|
</goals>
|
||||||
|
<phase>process-classes</phase>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<version>2.18.1</version>
|
||||||
|
<configuration>
|
||||||
|
<forkMode>always</forkMode>
|
||||||
|
<forkCount>999</forkCount>
|
||||||
|
<reuseForks>true</reuseForks>
|
||||||
|
<systemPropertyVariables>
|
||||||
|
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
|
||||||
|
<jboss.home>${project.basedir}/target/wildfly-8.2.0.Final</jboss.home>
|
||||||
|
<module.path>${project.basedir}/target/wildfly-8.2.0.Final/modules</module.path>
|
||||||
|
</systemPropertyVariables>
|
||||||
|
<redirectTestOutputToFile>false</redirectTestOutputToFile>
|
||||||
|
<groups>
|
||||||
|
org.libreccm.tests.categories.UnitTest,
|
||||||
|
org.libreccm.tests.categories.IntegrationTest
|
||||||
|
</groups>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</profile>
|
||||||
</profiles>
|
</profiles>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
@ -35,6 +35,9 @@ public class CcmObjectRepository extends AbstractEntityRepository<Long, CcmObjec
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isNew(final CcmObject entity) {
|
public boolean isNew(final CcmObject entity) {
|
||||||
|
if (entity == null) {
|
||||||
|
throw new IllegalArgumentException("Entity can't be null");
|
||||||
|
}
|
||||||
return entity.getObjectId() == 0;
|
return entity.getObjectId() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -104,19 +104,22 @@ public class CcmObjectRepositoryTest {
|
||||||
|
|
||||||
return ShrinkWrap
|
return ShrinkWrap
|
||||||
.create(WebArchive.class,
|
.create(WebArchive.class,
|
||||||
"LibreCCM-org.libreccm.core.CcmObjectRepositoryTest.war")
|
"LibreCCM-org.libreccm.core.CcmObjectRepositoryTest.war").
|
||||||
.addPackage(CcmObject.class.getPackage())
|
addPackage(CcmObject.class.getPackage())
|
||||||
.addPackage(org.libreccm.categorization.Category.class.getPackage())
|
.addPackage(org.libreccm.categorization.Category.class.
|
||||||
.addPackage(org.libreccm.l10n.LocalizedString.class.getPackage())
|
getPackage())
|
||||||
.addPackage(org.libreccm.jpa.EntityManagerProducer.class
|
.addPackage(org.libreccm.l10n.LocalizedString.class.getPackage()).
|
||||||
|
addPackage(org.libreccm.jpa.EntityManagerProducer.class
|
||||||
.getPackage())
|
.getPackage())
|
||||||
.addPackage(org.libreccm.jpa.utils.MimeTypeConverter.class
|
.addPackage(org.libreccm.jpa.utils.MimeTypeConverter.class
|
||||||
.getPackage())
|
.getPackage())
|
||||||
.addPackage(org.libreccm.testutils.EqualsVerifier.class.getPackage())
|
.addPackage(org.libreccm.testutils.EqualsVerifier.class.
|
||||||
|
getPackage())
|
||||||
.addPackage(org.libreccm.tests.categories.IntegrationTest.class
|
.addPackage(org.libreccm.tests.categories.IntegrationTest.class
|
||||||
.getPackage())
|
.getPackage())
|
||||||
.addAsLibraries(libs)
|
.addAsLibraries(libs)
|
||||||
.addAsResource("test-persistence.xml", "META-INF/persistence.xml")
|
.addAsResource("test-persistence.xml",
|
||||||
|
"META-INF/persistence.xml")
|
||||||
.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
|
.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -130,6 +133,22 @@ public class CcmObjectRepositoryTest {
|
||||||
assertThat(entityManager, is(not((nullValue()))));
|
assertThat(entityManager, is(not((nullValue()))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@UsingDataSet(
|
||||||
|
"datasets/org/libreccm/core/CcmObjectRepositoryTest/data.json")
|
||||||
|
@InSequence(4)
|
||||||
|
public void datasetOnly() {
|
||||||
|
System.out.println("Dataset loaded successfully.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@UsingDataSet(
|
||||||
|
"datasets/org/libreccm/core/CcmObjectRepositoryTest/after-save-changed.json")
|
||||||
|
@InSequence(4)
|
||||||
|
public void datasetOnly2() {
|
||||||
|
System.out.println("Dataset loaded successfully.");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@UsingDataSet(
|
@UsingDataSet(
|
||||||
"datasets/org/libreccm/core/CcmObjectRepositoryTest/data.json")
|
"datasets/org/libreccm/core/CcmObjectRepositoryTest/data.json")
|
||||||
|
|
@ -160,10 +179,14 @@ public class CcmObjectRepositoryTest {
|
||||||
"datasets/org/libreccm/core/CcmObjectRepositoryTest/data.json")
|
"datasets/org/libreccm/core/CcmObjectRepositoryTest/data.json")
|
||||||
@InSequence(6)
|
@InSequence(6)
|
||||||
public void entityManagerFindCcmObjectByLongClass() {
|
public void entityManagerFindCcmObjectByLongClass() {
|
||||||
final CcmObject obj1 = entityManager.find(CcmObject.class, new Long(-10L));
|
final CcmObject obj1 = entityManager.find(CcmObject.class,
|
||||||
final CcmObject obj2 = entityManager.find(CcmObject.class, new Long(-20L));
|
new Long(-10L));
|
||||||
final CcmObject obj3 = entityManager.find(CcmObject.class, new Long(-30L));
|
final CcmObject obj2 = entityManager.find(CcmObject.class,
|
||||||
final CcmObject none = entityManager.find(CcmObject.class, new Long(-999L));
|
new Long(-20L));
|
||||||
|
final CcmObject obj3 = entityManager.find(CcmObject.class,
|
||||||
|
new Long(-30L));
|
||||||
|
final CcmObject none = entityManager.find(CcmObject.class, new Long(
|
||||||
|
-999L));
|
||||||
|
|
||||||
assertThat(obj1, is(not(nullValue())));
|
assertThat(obj1, is(not(nullValue())));
|
||||||
assertThat(obj1.getObjectId(), is(-10L));
|
assertThat(obj1.getObjectId(), is(-10L));
|
||||||
|
|
@ -243,7 +266,7 @@ public class CcmObjectRepositoryTest {
|
||||||
ccmObjectRepository.save(obj);
|
ccmObjectRepository.save(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = EJBTransactionRolledbackException.class)
|
@Test(expected = IllegalArgumentException.class)
|
||||||
@ShouldThrowException(IllegalArgumentException.class)
|
@ShouldThrowException(IllegalArgumentException.class)
|
||||||
@InSequence(500)
|
@InSequence(500)
|
||||||
public void saveNullValue() {
|
public void saveNullValue() {
|
||||||
|
|
@ -263,7 +286,7 @@ public class CcmObjectRepositoryTest {
|
||||||
ccmObjectRepository.delete(obj);
|
ccmObjectRepository.delete(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = EJBTransactionRolledbackException.class)
|
@Test(expected = IllegalArgumentException.class)
|
||||||
@ShouldThrowException(IllegalArgumentException.class)
|
@ShouldThrowException(IllegalArgumentException.class)
|
||||||
@InSequence(700)
|
@InSequence(700)
|
||||||
public void deleteNullValue() {
|
public void deleteNullValue() {
|
||||||
|
|
|
||||||
|
|
@ -19,13 +19,6 @@
|
||||||
package org.libreccm.core;
|
package org.libreccm.core;
|
||||||
|
|
||||||
import org.dbunit.DatabaseUnitException;
|
import org.dbunit.DatabaseUnitException;
|
||||||
import org.dbunit.database.DatabaseConnection;
|
|
||||||
import org.dbunit.database.IDatabaseConnection;
|
|
||||||
import org.dbunit.dataset.IDataSet;
|
|
||||||
import org.dbunit.operation.DatabaseOperation;
|
|
||||||
import org.h2.tools.RunScript;
|
|
||||||
import org.jboss.arquillian.persistence.core.data.descriptor.Format;
|
|
||||||
import org.jboss.arquillian.persistence.dbunit.dataset.DataSetBuilder;
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
|
@ -34,18 +27,22 @@ import org.junit.Test;
|
||||||
import org.junit.experimental.categories.Category;
|
import org.junit.experimental.categories.Category;
|
||||||
import org.libreccm.tests.categories.UnitTest;
|
import org.libreccm.tests.categories.UnitTest;
|
||||||
|
|
||||||
import java.io.FileReader;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.DriverManager;
|
import java.sql.DriverManager;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import org.dbunit.database.DatabaseConnection;
|
||||||
|
import org.dbunit.database.IDatabaseConnection;
|
||||||
|
import org.dbunit.dataset.IDataSet;
|
||||||
|
import org.dbunit.operation.DatabaseOperation;
|
||||||
|
import org.h2.tools.RunScript;
|
||||||
|
import org.jboss.arquillian.persistence.core.data.descriptor.Format;
|
||||||
|
import org.jboss.arquillian.persistence.dbunit.dataset.DataSetBuilder;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ import org.dbunit.database.DatabaseConnection;
|
||||||
import org.dbunit.database.IDatabaseConnection;
|
import org.dbunit.database.IDatabaseConnection;
|
||||||
import org.dbunit.dataset.IDataSet;
|
import org.dbunit.dataset.IDataSet;
|
||||||
import org.dbunit.operation.DatabaseOperation;
|
import org.dbunit.operation.DatabaseOperation;
|
||||||
import org.h2.tools.RunScript;
|
//import org.h2.tools.RunScript;
|
||||||
import org.jboss.arquillian.persistence.core.data.descriptor.Format;
|
import org.jboss.arquillian.persistence.core.data.descriptor.Format;
|
||||||
import org.jboss.arquillian.persistence.dbunit.dataset.DataSetBuilder;
|
import org.jboss.arquillian.persistence.dbunit.dataset.DataSetBuilder;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
@ -36,6 +36,7 @@ import java.nio.file.Paths;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.DriverManager;
|
import java.sql.DriverManager;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import org.h2.tools.RunScript;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,9 @@
|
||||||
|
|
||||||
<extension qualifier="persistence">
|
<extension qualifier="persistence">
|
||||||
<property name="defaultDataSource">java:/jboss/datasources/ExampleDS</property>
|
<property name="defaultDataSource">java:/jboss/datasources/ExampleDS</property>
|
||||||
|
<!--<property name="javaVmArguments">
|
||||||
|
-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y
|
||||||
|
</property>-->
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
Disable automatic cleanup, does not work because of referential
|
Disable automatic cleanup, does not work because of referential
|
||||||
|
|
@ -17,7 +20,7 @@
|
||||||
-->
|
-->
|
||||||
<property name="defaultCleanupPhase">NONE</property>
|
<property name="defaultCleanupPhase">NONE</property>
|
||||||
|
|
||||||
<property name="dumpData">true</property>
|
<property name="dumpData">false</property>
|
||||||
<property name="dumpDirectory">target</property>
|
<property name="dumpDirectory">target</property>
|
||||||
</extension>
|
</extension>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<arquillian xmlns="http://jboss.org/schema/arquillian"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://jboss.org/schema/arquillian
|
||||||
|
http://jboss.org/schema/arquillian/arquillian_1_0.xsd" >
|
||||||
|
|
||||||
|
<engine>
|
||||||
|
<property name="deploymentExportPath">target/deployments</property>
|
||||||
|
</engine>
|
||||||
|
<defaultProtocol type="Servlet 3.0"/>
|
||||||
|
<!--<property name="javaVmArguments">
|
||||||
|
-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y
|
||||||
|
</property>-->
|
||||||
|
|
||||||
|
<extension qualifier="persistence">
|
||||||
|
<property name="defaultDataSource">java:/comp/env/jdbc/ccm-core-test/h2/mem</property>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Disable automatic cleanup, does not work because of referential
|
||||||
|
integrity constrains.
|
||||||
|
-->
|
||||||
|
<property name="defaultCleanupPhase">NONE</property>
|
||||||
|
|
||||||
|
<property name="dumpData">true</property>
|
||||||
|
<property name="dumpDirectory">target</property>
|
||||||
|
</extension>
|
||||||
|
|
||||||
|
<extension qualifier="persistence-dbunit">
|
||||||
|
<property name="defaultDataSetFormat">json</property>
|
||||||
|
<property name="datatypeFactory">org.dbunit.ext.h2.H2DataTypeFactory</property>
|
||||||
|
<property name="excludePoi">true</property>
|
||||||
|
</extension>
|
||||||
|
|
||||||
|
<extension qualifier="persistence-script">
|
||||||
|
<property name="scriptsToExecuteAfterTest">scripts/h2-cleanup.sql</property>
|
||||||
|
</extension>
|
||||||
|
|
||||||
|
|
||||||
|
</arquillian>
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
author: Jens Pelzetter
|
||||||
|
-->
|
||||||
|
|
||||||
|
<persistence
|
||||||
|
xmlns="http://xmlns.jcp.org/xml/ns/persistence"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
|
||||||
|
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
|
||||||
|
version="2.1">
|
||||||
|
|
||||||
|
<persistence-unit name="LibreCCM" transaction-type="JTA">
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Enforce JPA provider
|
||||||
|
Not really necessary here because we don't use any Hibernate
|
||||||
|
specific features, but makes it easier to manage to database
|
||||||
|
creation scripts.
|
||||||
|
-->
|
||||||
|
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
|
||||||
|
|
||||||
|
<jta-data-source>java:/comp/env/jdbc/ccm-core-test/h2/mem</jta-data-source>
|
||||||
|
<properties>
|
||||||
|
<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
|
||||||
|
<property name="hibernate.show_sql" value="true"/>
|
||||||
|
<property name="hibernate.id.new_generator_mappings" value="true"/>
|
||||||
|
<property name="hibernate.connection.autocommit" value="false" />
|
||||||
|
</properties>
|
||||||
|
</persistence-unit>
|
||||||
|
|
||||||
|
</persistence>
|
||||||
Loading…
Reference in New Issue