CCM NG: Basic structure for Arquillian tests in ccm-docrepo
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@3826 8810af33-2d31-482b-a856-94f89814c4dfpull/2/head
parent
73eef4aeb0
commit
2c72eb379c
|
|
@ -42,6 +42,13 @@
|
|||
<groupId>org.libreccm</groupId>
|
||||
<artifactId>ccm-core</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.libreccm</groupId>
|
||||
<artifactId>ccm-testutils</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
|
@ -125,7 +132,6 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.3</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
|
|
@ -138,7 +144,6 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.18.1</version>
|
||||
<configuration>
|
||||
<groups>org.libreccm.tests.categories.UnitTest</groups>
|
||||
</configuration>
|
||||
|
|
@ -147,7 +152,6 @@
|
|||
<plugin>
|
||||
<groupId>org.jacoco</groupId>
|
||||
<artifactId>jacoco-maven-plugin</artifactId>
|
||||
<version>0.7.5.201505241946</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>default-prepare-agent</id>
|
||||
|
|
@ -258,7 +262,7 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-report-plugin</artifactId>
|
||||
<version>2.18.1</version>
|
||||
<version>2.19.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.jacoco</groupId>
|
||||
|
|
@ -268,12 +272,12 @@
|
|||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>findbugs-maven-plugin</artifactId>
|
||||
<version>3.0.1</version>
|
||||
<version>3.0.3</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-pmd-plugin</artifactId>
|
||||
<version>3.4</version>
|
||||
<version>3.6</version>
|
||||
<configuration>
|
||||
<linkXref>true</linkXref>
|
||||
<sourceEncoding>utf-8</sourceEncoding>
|
||||
|
|
@ -299,15 +303,15 @@
|
|||
</rulesets>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<!--<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>javancss-maven-plugin</artifactId>
|
||||
<version>2.1</version>
|
||||
</plugin>
|
||||
</plugin>-->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-project-info-reports-plugin</artifactId>
|
||||
<version>2.8</version>
|
||||
<version>2.8.1</version>
|
||||
<reportSets>
|
||||
<reportSet>
|
||||
<reports>
|
||||
|
|
@ -329,4 +333,85 @@
|
|||
</plugins>
|
||||
</reporting>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>wildfly-remote-h2-mem</id>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.wildfly</groupId>
|
||||
<artifactId>wildfly-arquillian-container-remote</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jacoco</groupId>
|
||||
<artifactId>org.jacoco.core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jboss.arquillian.extension</groupId>
|
||||
<artifactId>arquillian-jacoco</artifactId>
|
||||
<version>1.0.0.Alpha8</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<testResources>
|
||||
<testResource>
|
||||
<directory>src/test/resources</directory>
|
||||
</testResource>
|
||||
<testResource>
|
||||
<directory>src/test/resources-wildfly-remote-h2-mem</directory>
|
||||
</testResource>
|
||||
<testResource>
|
||||
<directory>${project.build.directory}/generated-resources</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>org.libreccm</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.19.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>
|
||||
</systemPropertyVariables>
|
||||
<redirectTestOutputToFile>false</redirectTestOutputToFile>
|
||||
<groups>
|
||||
org.libreccm.tests.categories.UnitTest,
|
||||
org.libreccm.tests.categories.IntegrationTest
|
||||
</groups>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,129 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.libreccm.docrepo.portation;
|
||||
|
||||
import java.io.File;
|
||||
import javax.inject.Inject;
|
||||
import javax.persistence.EntityManager;
|
||||
import org.jboss.arquillian.container.test.api.Deployment;
|
||||
import org.jboss.arquillian.junit.Arquillian;
|
||||
import org.jboss.arquillian.junit.InSequence;
|
||||
import org.jboss.arquillian.persistence.CreateSchema;
|
||||
import org.jboss.arquillian.transaction.api.annotation.TransactionMode;
|
||||
import org.jboss.arquillian.transaction.api.annotation.Transactional;
|
||||
import org.jboss.shrinkwrap.api.ShrinkWrap;
|
||||
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
|
||||
import org.jboss.shrinkwrap.api.spec.WebArchive;
|
||||
import org.jboss.shrinkwrap.resolver.api.maven.Maven;
|
||||
import org.jboss.shrinkwrap.resolver.api.maven.PomEquippedResolveStage;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.libreccm.categorization.Categorization;
|
||||
import org.libreccm.core.CcmObject;
|
||||
import org.libreccm.core.CcmObjectRepository;
|
||||
import org.libreccm.jpa.EntityManagerProducer;
|
||||
import org.libreccm.jpa.utils.MimeTypeConverter;
|
||||
import org.libreccm.l10n.LocalizedString;
|
||||
import org.libreccm.security.Permission;
|
||||
import org.libreccm.tests.categories.IntegrationTest;
|
||||
import org.libreccm.testutils.EqualsVerifier;
|
||||
import org.libreccm.web.CcmApplication;
|
||||
import org.libreccm.workflow.Workflow;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@Category(IntegrationTest.class)
|
||||
@RunWith(Arquillian.class)
|
||||
@Transactional(TransactionMode.COMMIT)
|
||||
@CreateSchema({"create_ccm_docrepo_schema.sql"})
|
||||
public class ArquillianExampleTest {
|
||||
|
||||
@Inject
|
||||
private EntityManager entityManager;
|
||||
|
||||
@Inject
|
||||
private CcmObjectRepository ccmObjectRepository;
|
||||
|
||||
public ArquillianExampleTest() {
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpClass() {
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDownClass() {
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
}
|
||||
|
||||
@Deployment
|
||||
public static WebArchive createDeployment() {
|
||||
final PomEquippedResolveStage pom = Maven
|
||||
.resolver()
|
||||
.loadPomFromFile("pom.xml");
|
||||
final PomEquippedResolveStage dependencies = pom
|
||||
.importCompileAndRuntimeDependencies();
|
||||
final File[] libs = dependencies.resolve().withTransitivity().asFile();
|
||||
|
||||
for (File lib : libs) {
|
||||
System.err.printf("Adding file '%s' to test archive...%n",
|
||||
lib.getName());
|
||||
}
|
||||
|
||||
return ShrinkWrap
|
||||
.create(WebArchive.class,
|
||||
"LibreCCM-org.libreccm.docrepo.ArquillianExampleTest.war")
|
||||
.addPackage(org.libreccm.core.CcmObject.class.getPackage())
|
||||
.addPackage(org.libreccm.security.Permission.class.getPackage())
|
||||
.addPackage(org.libreccm.web.CcmApplication.class.getPackage())
|
||||
.addPackage(org.libreccm.categorization.Categorization.class.getPackage())
|
||||
.addPackage(LocalizedString.class.getPackage())
|
||||
.addPackage(Workflow.class.getPackage())
|
||||
.addPackage(EntityManagerProducer.class.getPackage())
|
||||
.addPackage(MimeTypeConverter.class.getPackage())
|
||||
.addPackage(EqualsVerifier.class.getPackage())
|
||||
.addPackage(IntegrationTest.class.getPackage())
|
||||
.addAsLibraries(libs)
|
||||
.addAsResource("test-persistence.xml",
|
||||
"META-INF/persistence.xml")
|
||||
.addAsWebInfResource("test-web.xml", "WEB-INF/web.xml")
|
||||
.addAsWebInfResource(EmptyAsset.INSTANCE, "WEB-INF/beans.xml");
|
||||
}
|
||||
|
||||
// TODO add test methods here.
|
||||
// The methods must be annotated with annotation @Test. For example:
|
||||
//
|
||||
// @Test
|
||||
// public void hello() {}
|
||||
@Test
|
||||
@InSequence(1)
|
||||
public void entityManagerIsInjected() {
|
||||
assertThat(entityManager, is(not(nullValue())));
|
||||
}
|
||||
|
||||
@Test
|
||||
@InSequence(2)
|
||||
public void repoIsInjected() {
|
||||
assertThat(ccmObjectRepository, is(not(nullValue())));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
<?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/org/libreccm/ccm-docrepo/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>
|
||||
<property name="qualifiedTableNames">true</property>
|
||||
</extension>
|
||||
|
||||
<extension qualifier="persistence-script">
|
||||
<property name="scriptsToExecuteAfterTest">scripts/h2-cleanup.sql</property>
|
||||
</extension>
|
||||
|
||||
|
||||
</arquillian>
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,40 @@
|
|||
<?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/org/libreccm/ccm-docrepo/h2-mem</jta-data-source>
|
||||
<properties>
|
||||
<property name="hibernate.hbm2ddl.auto" value=""/>
|
||||
<property name="hibernate.show_sql" value="true"/>
|
||||
<property name="hibernate.id.new_generator_mappings" value="true"/>
|
||||
<property name="hibernate.connection.autocommit" value="false" />
|
||||
|
||||
<!--
|
||||
Properties for Hibernate Envers
|
||||
We are using the ValidityAuditStrategy here because it is faster
|
||||
when querying data than the DefaultStrategy
|
||||
-->
|
||||
<property name="org.hibernate.envers.audit_strategy"
|
||||
value="org.hibernate.envers.strategy.ValidityAuditStrategy"/>
|
||||
</properties>
|
||||
</persistence-unit>
|
||||
|
||||
</persistence>
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
DELETE FROM ccm_core.settings_big_decimal;
|
||||
|
||||
DELETE FROM ccm_core.settings_boolean;
|
||||
|
||||
DELETE FROM ccm_core.settings_double;
|
||||
|
||||
DELETE FROM ccm_core.settings_enum_values;
|
||||
|
||||
DELETE FROM ccm_core.settings_enum;
|
||||
|
||||
DELETE FROM ccm_core.settings_l10n_string;
|
||||
|
||||
DELETE FROM ccm_core.settings_l10n_str_values;
|
||||
|
||||
DELETE FROM ccm_core.settings_long;
|
||||
|
||||
DELETE FROM ccm_core.settings_string;
|
||||
|
||||
DELETE FROM ccm_core.settings;
|
||||
|
||||
DELETE FROM ccm_core.categorizations;
|
||||
|
||||
DELETE FROM ccm_core.category_domains;
|
||||
|
||||
DELETE FROM ccm_core.categories;
|
||||
|
||||
DELETE FROM ccm_core.permissions;
|
||||
|
||||
DELETE FROM ccm_core.ccm_objects;
|
||||
|
||||
DELETE FROM ccm_core.role_memberships;
|
||||
|
||||
DELETE FROM ccm_core.group_memberships;
|
||||
|
||||
DELETE FROM ccm_core.groups;
|
||||
|
||||
DELETE FROM ccm_core.users;
|
||||
|
||||
DELETE FROM ccm_core.user_email_addresses;
|
||||
|
||||
DELETE FROM ccm_core.parties;
|
||||
|
||||
DELETE FROM ccm_core.ccm_roles;
|
||||
|
||||
ALTER SEQUENCE hibernate_sequence RESTART WITH 1;
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
|
||||
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
|
||||
version="2.5">
|
||||
|
||||
<display-name>CcmDocRepoTest</display-name>
|
||||
|
||||
</web-app>
|
||||
Loading…
Reference in New Issue