CCM NG: Bundle/WAR module for testing the module system etc.
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@3600 8810af33-2d31-482b-a856-94f89814c4dfpull/2/head
parent
a51c64e7b5
commit
d7be8b8d65
|
|
@ -8,7 +8,6 @@
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<!--<ccmVersion>3.0.0-SNAPSHOT</ccmVersion>-->
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
|
|
@ -114,7 +113,6 @@
|
||||||
<groupId>org.libreccm</groupId>
|
<groupId>org.libreccm</groupId>
|
||||||
<artifactId>ccm-testutils</artifactId>
|
<artifactId>ccm-testutils</artifactId>
|
||||||
<version>${project.parent.version}</version>
|
<version>${project.parent.version}</version>
|
||||||
<!--<version>7.0.0-SNAPSHOT</version>-->
|
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
@ -247,7 +245,7 @@
|
||||||
</rules>
|
</rules>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>de.jpdigital</groupId>
|
<groupId>de.jpdigital</groupId>
|
||||||
|
|
@ -284,7 +282,7 @@
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<!--<plugin>
|
||||||
<groupId>org.jboss.tattletale</groupId>
|
<groupId>org.jboss.tattletale</groupId>
|
||||||
<artifactId>tattletale-maven</artifactId>
|
<artifactId>tattletale-maven</artifactId>
|
||||||
<executions>
|
<executions>
|
||||||
|
|
@ -298,8 +296,7 @@
|
||||||
<source>${project.build.directory}</source>
|
<source>${project.build.directory}</source>
|
||||||
<destination>${project.build.directory}/tattletale</destination>
|
<destination>${project.build.directory}/tattletale</destination>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>-->
|
||||||
|
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
|
@ -1002,7 +999,6 @@
|
||||||
</groups>
|
</groups>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</profile>
|
</profile>
|
||||||
|
|
@ -1086,7 +1082,6 @@
|
||||||
</groups>
|
</groups>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</profile>
|
</profile>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,54 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2015 LibreCCM Foundation.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
* MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
package org.libreccm.core.modules;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.servlet.ServletContextEvent;
|
||||||
|
import javax.servlet.ServletContextListener;
|
||||||
|
import javax.servlet.annotation.WebListener;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.libreccm.core.modules.ModuleManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
@WebListener
|
||||||
|
public class CcmModuleContextListener implements ServletContextListener {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger(
|
||||||
|
CcmModuleContextListener.class);
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private transient ModuleManager moduleManager;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void contextInitialized(final ServletContextEvent event) {
|
||||||
|
LOGGER.info("ServletContext initalised. Initalising modules...");
|
||||||
|
moduleManager.initModules();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void contextDestroyed(final ServletContextEvent event) {
|
||||||
|
LOGGER.info("ServletContext destroyed. Shutting modules down...");
|
||||||
|
moduleManager.shutdownModules();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -47,7 +47,7 @@ public class Attachment implements Serializable {
|
||||||
private static final long serialVersionUID = 2063934721452863106L;
|
private static final long serialVersionUID = 2063934721452863106L;
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@Column(name = "message_id")
|
@Column(name = "attachment_id")
|
||||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||||
private long attachmentId;
|
private long attachmentId;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
);
|
);
|
||||||
|
|
||||||
create table ccm_core.attachments (
|
create table ccm_core.attachments (
|
||||||
message_id int8 not null,
|
attachment_id int8 not null,
|
||||||
attachment_data oid,
|
attachment_data oid,
|
||||||
description varchar(255),
|
description varchar(255),
|
||||||
mime_type varchar(255),
|
mime_type varchar(255),
|
||||||
|
|
@ -632,7 +632,7 @@
|
||||||
|
|
||||||
alter table ccm_core.attachments
|
alter table ccm_core.attachments
|
||||||
add constraint FK_r3hibvgfo1dmawqig8c563xau
|
add constraint FK_r3hibvgfo1dmawqig8c563xau
|
||||||
foreign key (message_id)
|
foreign key (attachment_id)
|
||||||
references ccm_core.messages;
|
references ccm_core.messages;
|
||||||
|
|
||||||
alter table ccm_core.categories
|
alter table ccm_core.categories
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
<h2>Hello World!</h2>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -51,6 +51,7 @@ import java.util.List;
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.persistence.PersistenceContext;
|
import javax.persistence.PersistenceContext;
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
|
import org.jboss.arquillian.persistence.CreateSchema;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
|
@ -58,10 +59,11 @@ import static org.junit.Assert.*;
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
*/
|
*/
|
||||||
@Category(IntegrationTest.class)
|
//@Category(IntegrationTest.class)
|
||||||
@RunWith(Arquillian.class)
|
@RunWith(Arquillian.class)
|
||||||
@PersistenceTest
|
@PersistenceTest
|
||||||
@Transactional(TransactionMode.COMMIT)
|
@Transactional(TransactionMode.COMMIT)
|
||||||
|
@CreateSchema({"clearup_schema.sql"})
|
||||||
public class CcmModulesTest {
|
public class CcmModulesTest {
|
||||||
|
|
||||||
@PersistenceContext(name = "LibreCCM")
|
@PersistenceContext(name = "LibreCCM")
|
||||||
|
|
@ -89,10 +91,10 @@ public class CcmModulesTest {
|
||||||
@Deployment
|
@Deployment
|
||||||
public static WebArchive createDeployment() {
|
public static WebArchive createDeployment() {
|
||||||
final PomEquippedResolveStage pom = Maven
|
final PomEquippedResolveStage pom = Maven
|
||||||
.resolver()
|
.resolver()
|
||||||
.loadPomFromFile("pom.xml");
|
.loadPomFromFile("pom.xml");
|
||||||
final PomEquippedResolveStage dependencies = pom
|
final PomEquippedResolveStage dependencies = pom
|
||||||
.importCompileAndRuntimeDependencies();
|
.importCompileAndRuntimeDependencies();
|
||||||
final File[] libs = dependencies.resolve().withTransitivity().asFile();
|
final File[] libs = dependencies.resolve().withTransitivity().asFile();
|
||||||
|
|
||||||
for (File lib : libs) {
|
for (File lib : libs) {
|
||||||
|
|
@ -101,40 +103,60 @@ public class CcmModulesTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
return ShrinkWrap
|
return ShrinkWrap
|
||||||
.create(WebArchive.class,
|
.create(WebArchive.class,
|
||||||
"LibreCCM-org.libreccm.core.modules.CcmModulesTest.war")
|
"LibreCCM-org.libreccm.core.modules.CcmModulesTest.war")
|
||||||
.addPackage(CcmCore.class.getPackage())
|
.addPackage(org.libreccm.auditing.CcmRevision.class.getPackage()).
|
||||||
.addPackage(CcmModule.class.getPackage())
|
addPackage(org.libreccm.categorization.Category.class.
|
||||||
.addPackage(org.libreccm.web.Application.class.getPackage())
|
getPackage())
|
||||||
.addPackage(org.libreccm.categorization.Category.class.
|
.addPackage(org.libreccm.cdi.utils.CdiUtil.class.getPackage())
|
||||||
getPackage())
|
.addPackage(org.libreccm.core.CcmCore.class.getPackage())
|
||||||
.addPackage(org.libreccm.l10n.LocalizedString.class.getPackage()).
|
.addPackage(org.libreccm.core.authentication.LoginManager.class.
|
||||||
addPackage(org.libreccm.jpa.EntityManagerProducer.class
|
getPackage())
|
||||||
.getPackage())
|
.addPackage(org.libreccm.core.modules.CcmModule.class.
|
||||||
.addPackage(org.libreccm.jpa.utils.MimeTypeConverter.class
|
getPackage())
|
||||||
.getPackage())
|
.addPackage(org.libreccm.formbuilder.Component.class.
|
||||||
.addPackage(org.libreccm.testutils.EqualsVerifier.class.
|
getPackage())
|
||||||
getPackage())
|
.addPackage(
|
||||||
.addPackage(org.libreccm.tests.categories.IntegrationTest.class
|
org.libreccm.formbuilder.actions.ConfirmEmailListener.class.
|
||||||
.getPackage())
|
getPackage())
|
||||||
.addAsLibraries(libs)
|
.addPackage(org.libreccm.jpa.EntityManagerProducer.class.
|
||||||
.addAsResource("test-persistence.xml",
|
getPackage())
|
||||||
"META-INF/persistence.xml")
|
.addPackage(org.libreccm.jpa.utils.MimeTypeConverter.class
|
||||||
.addAsWebInfResource("test-web.xml", "WEB-INF/web.xml")
|
.getPackage())
|
||||||
.addAsWebInfResource(EmptyAsset.INSTANCE, "WEB-INF/beans.xml")
|
.addPackage(org.libreccm.l10n.LocalizedString.class.getPackage()).
|
||||||
.addAsManifestResource(
|
addPackage(org.libreccm.messaging.Message.class.getPackage())
|
||||||
"META-INF/services/org.hibernate.integrator.spi.Integrator")
|
.addPackage(org.libreccm.notification.Notification.class.
|
||||||
.addAsManifestResource(
|
getPackage())
|
||||||
"META-INF/services/org.libreccm.core.modules.CcmModule")
|
.addPackage(org.libreccm.portal.Portal.class.getPackage())
|
||||||
.addAsResource("module-info/org.libreccm.core.CcmCore.properties")
|
.addPackage(org.libreccm.runtime.Initalizer.class.getPackage())
|
||||||
.addAsResource("ccm-core.config");
|
.addPackage(org.libreccm.search.lucene.Document.class.
|
||||||
|
getPackage())
|
||||||
|
.addPackage(org.libreccm.web.Application.class.getPackage())
|
||||||
|
.addPackage(org.libreccm.workflow.Workflow.class.getPackage())
|
||||||
|
.addPackage(org.libreccm.testutils.EqualsVerifier.class.
|
||||||
|
getPackage())
|
||||||
|
.addPackage(org.libreccm.tests.categories.IntegrationTest.class
|
||||||
|
.getPackage())
|
||||||
|
.addAsLibraries(libs)
|
||||||
|
.addAsResource("test-persistence.xml",
|
||||||
|
"META-INF/persistence.xml")
|
||||||
|
.addAsWebInfResource("test-web.xml", "web.xml")
|
||||||
|
.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
|
||||||
|
.addAsResource(
|
||||||
|
"META-INF/services/org.hibernate.integrator.spi.Integrator").
|
||||||
|
addAsResource(
|
||||||
|
"META-INF/services/org.libreccm.core.modules.CcmModule")
|
||||||
|
.addAsResource(
|
||||||
|
"module-info/org.libreccm.core.CcmCore.properties")
|
||||||
|
.addAsResource("db")
|
||||||
|
.addAsResource("ccm-core.config");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void verifyModules() throws SQLException {
|
public void verifyModules() throws SQLException {
|
||||||
final Object dataSourceObj = entityManager.getEntityManagerFactory()
|
final Object dataSourceObj = entityManager.getEntityManagerFactory()
|
||||||
.getProperties().get("javax.persistence.jtaDataSource");
|
.getProperties().get("javax.persistence.jtaDataSource");
|
||||||
|
|
||||||
assertThat(dataSourceObj, is(instanceOf(DataSource.class)));
|
assertThat(dataSourceObj, is(instanceOf(DataSource.class)));
|
||||||
|
|
||||||
|
|
@ -144,33 +166,34 @@ public class CcmModulesTest {
|
||||||
assertThat(connection, is(instanceOf(Connection.class)));
|
assertThat(connection, is(instanceOf(Connection.class)));
|
||||||
|
|
||||||
final ResultSet ccmObjectTable = connection.getMetaData()
|
final ResultSet ccmObjectTable = connection.getMetaData()
|
||||||
.getTables(null, "ccm_core", "ccm_objects", null);
|
.getTables(null, "ccm_core", "ccm_objects", null);
|
||||||
if (!ccmObjectTable.next()) {
|
if (!ccmObjectTable.next()) {
|
||||||
fail("No metadata for table ccm_core.ccm_objects returned. "
|
fail("No metadata for table ccm_core.ccm_objects returned. "
|
||||||
+ "Table does exist?");
|
+ "Table does not exist?");
|
||||||
}
|
}
|
||||||
|
|
||||||
final ResultSet installedModulesTable = connection.getMetaData()
|
final ResultSet installedModulesTable = connection.getMetaData()
|
||||||
.getTables(null, "ccm_core", "installed_modules", null);
|
.getTables(null, "ccm_core", "installed_modules", null);
|
||||||
if (!installedModulesTable.next()) {
|
if (!installedModulesTable.next()) {
|
||||||
fail("No metadata for table ccm_core.installed_modules returned. "
|
fail("No metadata for table ccm_core.installed_modules returned. "
|
||||||
+ "Table does not exist?");
|
+ "Table does not exist?");
|
||||||
}
|
}
|
||||||
|
|
||||||
final Statement statement = connection.createStatement();
|
final Statement statement = connection.createStatement();
|
||||||
final ResultSet installedModules = statement.executeQuery(
|
final ResultSet installedModules = statement.executeQuery(
|
||||||
"SELECT module_id, module_class_name, status "
|
"SELECT module_id, module_class_name, status "
|
||||||
+ "FROM ccm_core.installed_modules"
|
+ "FROM ccm_core.installed_modules"
|
||||||
+ " ORDER BY module_class_name");
|
+ " ORDER BY module_class_name");
|
||||||
final List<String[]> modulesList = new ArrayList<>();
|
final List<String[]> modulesList = new ArrayList<>();
|
||||||
while (installedModules.next()) {
|
while (installedModules.next()) {
|
||||||
createInstalledModuleListEntry(installedModules, modulesList);
|
createInstalledModuleListEntry(installedModules, modulesList);
|
||||||
}
|
}
|
||||||
|
|
||||||
assertThat(modulesList.size(), is(1));
|
assertThat(modulesList.size(), is(1));
|
||||||
|
|
||||||
assertThat(modulesList.get(0)[0],
|
assertThat(modulesList.get(0)[0],
|
||||||
is(equalTo(Integer.toString(CcmCore.class.getName().hashCode()))));
|
is(equalTo(Integer.toString(CcmCore.class.getName().
|
||||||
|
hashCode()))));
|
||||||
assertThat(modulesList.get(0)[1],
|
assertThat(modulesList.get(0)[1],
|
||||||
is(equalTo(CcmCore.class.getName())));
|
is(equalTo(CcmCore.class.getName())));
|
||||||
assertThat(modulesList.get(0)[2],
|
assertThat(modulesList.get(0)[2],
|
||||||
|
|
@ -179,14 +202,14 @@ public class CcmModulesTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createInstalledModuleListEntry(
|
private void createInstalledModuleListEntry(
|
||||||
final ResultSet resultSet, final List<String[]> modulesList)
|
final ResultSet resultSet, final List<String[]> modulesList)
|
||||||
throws SQLException {
|
throws SQLException {
|
||||||
|
|
||||||
final String[] moduleData = new String[3];
|
final String[] moduleData = new String[3];
|
||||||
moduleData[0] = Integer.toString(resultSet.getInt("module_id"));
|
moduleData[0] = Integer.toString(resultSet.getInt("module_id"));
|
||||||
moduleData[1] = resultSet.getString("module_class_name");
|
moduleData[1] = resultSet.getString("module_class_name");
|
||||||
moduleData[2] = resultSet.getString("status");
|
moduleData[2] = resultSet.getString("status");
|
||||||
|
|
||||||
modulesList.add(moduleData);
|
modulesList.add(moduleData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ CREATE SCHEMA ccm_core;
|
||||||
);
|
);
|
||||||
|
|
||||||
create table ccm_core.attachments (
|
create table ccm_core.attachments (
|
||||||
message_id bigint not null,
|
attachment_id bigint not null,
|
||||||
attachment_data blob,
|
attachment_data blob,
|
||||||
description varchar(255),
|
description varchar(255),
|
||||||
mime_type varchar(255),
|
mime_type varchar(255),
|
||||||
|
|
@ -635,7 +635,7 @@ CREATE SCHEMA ccm_core;
|
||||||
|
|
||||||
alter table ccm_core.attachments
|
alter table ccm_core.attachments
|
||||||
add constraint FK_r3hibvgfo1dmawqig8c563xau
|
add constraint FK_r3hibvgfo1dmawqig8c563xau
|
||||||
foreign key (message_id)
|
foreign key (attachment_id)
|
||||||
references ccm_core.messages;
|
references ccm_core.messages;
|
||||||
|
|
||||||
alter table ccm_core.categories
|
alter table ccm_core.categories
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
-- Used by the org.libreccm.core.modules.CcmModulesTest to clean up the
|
||||||
|
-- schema before the test
|
||||||
|
|
||||||
|
DROP SCHEMA IF EXISTS ccm_core;
|
||||||
|
|
||||||
|
DROP SEQUENCE IF EXISTS hibernate_sequence;
|
||||||
|
|
@ -19,7 +19,7 @@ CREATE SCHEMA ccm_core;
|
||||||
);
|
);
|
||||||
|
|
||||||
create table ccm_core.attachments (
|
create table ccm_core.attachments (
|
||||||
message_id int8 not null,
|
attachment_id int8 not null,
|
||||||
attachment_data oid,
|
attachment_data oid,
|
||||||
description varchar(255),
|
description varchar(255),
|
||||||
mime_type varchar(255),
|
mime_type varchar(255),
|
||||||
|
|
@ -635,7 +635,7 @@ CREATE SCHEMA ccm_core;
|
||||||
|
|
||||||
alter table ccm_core.attachments
|
alter table ccm_core.attachments
|
||||||
add constraint FK_r3hibvgfo1dmawqig8c563xau
|
add constraint FK_r3hibvgfo1dmawqig8c563xau
|
||||||
foreign key (message_id)
|
foreign key (attachment_id)
|
||||||
references ccm_core.messages;
|
references ccm_core.messages;
|
||||||
|
|
||||||
alter table ccm_core.categories
|
alter table ccm_core.categories
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ import javax.persistence.Table;
|
||||||
public class Shortcut implements Serializable {
|
public class Shortcut implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = -5674633339633714327L;
|
private static final long serialVersionUID = -5674633339633714327L;
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@Column(name = "shortcut_id")
|
@Column(name = "shortcut_id")
|
||||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,477 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
||||||
|
http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||||
|
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>org.libreccm</groupId>
|
||||||
|
<artifactId>libreccm-parent</artifactId>
|
||||||
|
<version>7.0.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<groupId>org.libreccm</groupId>
|
||||||
|
<artifactId>ccm-test-bundle</artifactId>
|
||||||
|
<!--<version>1.0.0-SNAPSHOT</version>-->
|
||||||
|
<packaging>war</packaging>
|
||||||
|
|
||||||
|
<name>LibreCCM Test Bundle</name>
|
||||||
|
<url>http://www.libreccm.org/test-bundle</url>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.libreccm</groupId>
|
||||||
|
<artifactId>ccm-core</artifactId>
|
||||||
|
<version>${project.parent.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.libreccm</groupId>
|
||||||
|
<artifactId>ccm-testutils</artifactId>
|
||||||
|
<version>${project.parent.version}</version>
|
||||||
|
<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.extension</groupId>
|
||||||
|
<artifactId>arquillian-persistence-dbunit</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jboss.arquillian.extension</groupId>
|
||||||
|
<artifactId>arquillian-transaction-impl-base</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jboss.shrinkwrap.resolver</groupId>
|
||||||
|
<artifactId>shrinkwrap-resolver-impl-maven</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<finalName>ccm-test-bundle</finalName>
|
||||||
|
|
||||||
|
<testResources>
|
||||||
|
<testResource>
|
||||||
|
<directory>src/test/resources</directory>
|
||||||
|
</testResource>
|
||||||
|
<testResource>
|
||||||
|
<directory>${project.build.directory}/generated-resources</directory>
|
||||||
|
</testResource>
|
||||||
|
</testResources>
|
||||||
|
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.3</version>
|
||||||
|
<configuration>
|
||||||
|
<source>1.7</source>
|
||||||
|
<target>1.7</target>
|
||||||
|
<optimize>true</optimize>
|
||||||
|
<debug>true</debug>
|
||||||
|
<encoding>${project.build.sourceEncoding}</encoding>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-war-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<overlays>
|
||||||
|
<overlay>
|
||||||
|
<groupId>org.libreccm</groupId>
|
||||||
|
<artifactId>ccm-core</artifactId>
|
||||||
|
<type>jar</type>
|
||||||
|
<includes>
|
||||||
|
<include>index.jsp</include>
|
||||||
|
</includes>
|
||||||
|
</overlay>
|
||||||
|
</overlays>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<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>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.jacoco</groupId>
|
||||||
|
<artifactId>jacoco-maven-plugin</artifactId>
|
||||||
|
<version>0.7.5.201505241946</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>default-prepare-agent</id>
|
||||||
|
<goals>
|
||||||
|
<goal>prepare-agent</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>default-report</id>
|
||||||
|
<phase>prepare-package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>report</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>default-check</id>
|
||||||
|
<goals>
|
||||||
|
<goal>check</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<rules>
|
||||||
|
<rule>
|
||||||
|
<element>BUNDLE</element>
|
||||||
|
<limits>
|
||||||
|
<limit>
|
||||||
|
<counter>COMPLEXITY</counter>
|
||||||
|
<value>COVEREDRATIO</value>
|
||||||
|
<minimum>0.60</minimum>
|
||||||
|
</limit>
|
||||||
|
</limits>
|
||||||
|
</rule>
|
||||||
|
</rules>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>de.jpdigital</groupId>
|
||||||
|
<artifactId>hibernate4-ddl-maven-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<dialects>
|
||||||
|
<param>h2</param>
|
||||||
|
<param>mysql5_innodb</param>
|
||||||
|
<param>oracle10g</param>
|
||||||
|
<param>postgresql9</param>
|
||||||
|
</dialects>
|
||||||
|
<packages>
|
||||||
|
<param>org.libreccm.categorization</param>
|
||||||
|
<param>org.libreccm.core</param>
|
||||||
|
<param>org.libreccm.formbuilder</param>
|
||||||
|
<param>org.libreccm.jpa</param>
|
||||||
|
<param>org.libreccm.l10n</param>
|
||||||
|
<param>org.libreccm.messaging</param>
|
||||||
|
<param>org.libreccm.notification</param>
|
||||||
|
<param>org.libreccm.portal</param>
|
||||||
|
<param>org.libreccm.runtime</param>
|
||||||
|
<param>org.libreccm.search.lucene</param>
|
||||||
|
<param>org.libreccm.web</param>
|
||||||
|
<param>org.libreccm.workflow</param>
|
||||||
|
</packages>
|
||||||
|
<useEnvers>true</useEnvers>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>gen-ddl</goal>
|
||||||
|
</goals>
|
||||||
|
<phase>process-classes</phase>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<reporting>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
|
<version>2.10.3</version>
|
||||||
|
<configuration>
|
||||||
|
<detectLinks>true</detectLinks>
|
||||||
|
<detectJavaApiLinks>true</detectJavaApiLinks>
|
||||||
|
<links>
|
||||||
|
<link>http://docs.oracle.com/javase/7/docs/api/</link>
|
||||||
|
<link>http://docs.oracle.com/javaee/7/api/</link>
|
||||||
|
<link>http://docs.jboss.org/hibernate/orm/4.3/javadocs/</link>
|
||||||
|
</links>
|
||||||
|
<show>private</show>
|
||||||
|
<docfilessubdirs>true</docfilessubdirs>
|
||||||
|
<charset>UTF-8</charset>
|
||||||
|
<encoding>UTF-8</encoding>
|
||||||
|
<docencoding>UTF-8</docencoding>
|
||||||
|
<breakiterator>true</breakiterator>
|
||||||
|
<version>true</version>
|
||||||
|
<author>true</author>
|
||||||
|
<keywords>true</keywords>
|
||||||
|
<failOnError>false</failOnError>
|
||||||
|
<doclet>org.jboss.apiviz.APIviz</doclet>
|
||||||
|
<docletArtifact>
|
||||||
|
<groupId>org.jboss.apiviz</groupId>
|
||||||
|
<artifactId>apiviz</artifactId>
|
||||||
|
<version>1.3.2.GA</version>
|
||||||
|
</docletArtifact>
|
||||||
|
<useStandardDocletOptions>true</useStandardDocletOptions>
|
||||||
|
<additionalparam>
|
||||||
|
-sourceclasspath ${project.build.outputDirectory}
|
||||||
|
</additionalparam>
|
||||||
|
<!--<additionalparam>-Xdoclint:none</additionalparam>-->
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-jxr-plugin</artifactId>
|
||||||
|
<version>2.5</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-report-plugin</artifactId>
|
||||||
|
<version>2.18.1</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.jacoco</groupId>
|
||||||
|
<artifactId>jacoco-maven-plugin</artifactId>
|
||||||
|
<version>0.7.5.201505241946</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>findbugs-maven-plugin</artifactId>
|
||||||
|
<version>3.0.1</version>
|
||||||
|
<configuration>
|
||||||
|
<excludeFilterFile>findbugs-exclude.xml</excludeFilterFile>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-pmd-plugin</artifactId>
|
||||||
|
<version>3.4</version>
|
||||||
|
<configuration>
|
||||||
|
<linkXref>true</linkXref>
|
||||||
|
<sourceEncoding>utf-8</sourceEncoding>
|
||||||
|
<targetJdk>1.7</targetJdk>
|
||||||
|
<rulesets>
|
||||||
|
<ruleset>/rulesets/java/basic.xml</ruleset>
|
||||||
|
<ruleset>/rulesets/java/braces.xml</ruleset>
|
||||||
|
<ruleset>/rulesets/java/clone.xml</ruleset>
|
||||||
|
<ruleset>/rulesets/java/codesize.xml</ruleset>
|
||||||
|
<ruleset>/rulesets/java/design.xml</ruleset>
|
||||||
|
<ruleset>/rulesets/java/empty.xml</ruleset>
|
||||||
|
<ruleset>/rulesets/java/finalizers.xml</ruleset>
|
||||||
|
<ruleset>/rulesets/java/imports.xml</ruleset>
|
||||||
|
<ruleset>/rulesets/java/javabeans.xml</ruleset>
|
||||||
|
<ruleset>/rulesets/java/junit.xml</ruleset>
|
||||||
|
<ruleset>/rulesets/java/naming.xml</ruleset>
|
||||||
|
<ruleset>/rulesets/java/optimizations.xml</ruleset>
|
||||||
|
<ruleset>/rulesets/java/strictexception.xml</ruleset>
|
||||||
|
<ruleset>/rulesets/java/strings.xml</ruleset>
|
||||||
|
<ruleset>/rulesets/java/sunsecure.xml</ruleset>
|
||||||
|
<ruleset>/rulesets/java/typeresolution.xml</ruleset>
|
||||||
|
<ruleset>/rulesets/java/unnecessary.xml</ruleset>
|
||||||
|
<ruleset>/rulesets/java/unusedcode.xml</ruleset>
|
||||||
|
</rulesets>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>javancss-maven-plugin</artifactId>
|
||||||
|
<version>2.1</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>jdepend-maven-plugin</artifactId>
|
||||||
|
<version>2.0</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>taglist-maven-plugin</artifactId>
|
||||||
|
<version>2.4</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-project-info-reports-plugin</artifactId>
|
||||||
|
<version>2.8</version>
|
||||||
|
<reportSets>
|
||||||
|
<reportSet>
|
||||||
|
<reports>
|
||||||
|
<report>dependencies</report>
|
||||||
|
<!--<report>project-team</report>
|
||||||
|
<report>mailing-list</report>
|
||||||
|
<report>cim</report>
|
||||||
|
<report>issue-tracking</report>-->
|
||||||
|
<report>license</report>
|
||||||
|
<!--<report>scm</report>-->
|
||||||
|
</reports>
|
||||||
|
</reportSet>
|
||||||
|
</reportSets>
|
||||||
|
<configuration>
|
||||||
|
<dependencyLocationsEnabled>false</dependencyLocationsEnabled>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</reporting>
|
||||||
|
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>wildfly8-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>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<testResources>
|
||||||
|
<testResource>
|
||||||
|
<directory>src/test/resources</directory>
|
||||||
|
</testResource>
|
||||||
|
<testResource>
|
||||||
|
<directory>src/test/resources-wildfly8-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.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>
|
||||||
|
|
||||||
|
<profile>
|
||||||
|
<id>wildfly8-remote-pgsql</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>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<testResources>
|
||||||
|
<testResource>
|
||||||
|
<directory>src/test/resources</directory>
|
||||||
|
</testResource>
|
||||||
|
<testResource>
|
||||||
|
<directory>src/test/resources-wildfly8-remote-pgsql</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.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>
|
||||||
|
</project>
|
||||||
|
|
@ -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-test-bundle/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>
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
-- Used by the org.libreccm.core.modules.CcmModulesTest to clean up the
|
||||||
|
-- schema before the test
|
||||||
|
|
||||||
|
DROP SCHEMA IF EXISTS ccm_core;
|
||||||
|
|
||||||
|
DROP SEQUENCE IF EXISTS hibernate_sequence;
|
||||||
|
|
@ -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-test-bundle/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,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>
|
||||||
|
|
||||||
|
<extension qualifier="persistence">
|
||||||
|
<property name="defaultDataSource">java:/comp/env/jdbc/org/libreccm/ccm-test-bundle/pgsql</property>
|
||||||
|
<!--<property name="javaVmArguments">
|
||||||
|
-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y
|
||||||
|
</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/pgsql-cleanup.sql</property>
|
||||||
|
</extension>-->
|
||||||
|
|
||||||
|
|
||||||
|
</arquillian>
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
-- Used by the org.libreccm.core.modules.CcmModulesTest to clean up the
|
||||||
|
-- schema before the test
|
||||||
|
|
||||||
|
DROP SCHEMA IF EXISTS ccm_core;
|
||||||
|
|
||||||
|
DROP SEQUENCE IF EXISTS hibernate_sequence;
|
||||||
|
|
@ -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-test-bundle/pgsql</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,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_3_0.xsd"
|
||||||
|
version="3.0">
|
||||||
|
|
||||||
|
<display-name>LibreCCM Test Bundle</display-name>
|
||||||
|
|
||||||
|
</web-app>
|
||||||
|
|
@ -0,0 +1,204 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2015 LibreCCM Foundation.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
* MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
package org.libreccm;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Statement;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import javax.persistence.EntityManager;
|
||||||
|
import javax.persistence.PersistenceContext;
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
|
import static org.hamcrest.CoreMatchers.*;
|
||||||
|
|
||||||
|
import org.jboss.arquillian.container.test.api.Deployment;
|
||||||
|
import org.jboss.arquillian.junit.Arquillian;
|
||||||
|
import org.jboss.arquillian.persistence.CreateSchema;
|
||||||
|
import org.jboss.arquillian.persistence.PersistenceTest;
|
||||||
|
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 static org.junit.Assert.*;
|
||||||
|
|
||||||
|
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.core.CcmCore;
|
||||||
|
import org.libreccm.core.modules.ModuleStatus;
|
||||||
|
import org.libreccm.tests.categories.IntegrationTest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
@Category(IntegrationTest.class)
|
||||||
|
@RunWith(Arquillian.class)
|
||||||
|
@PersistenceTest
|
||||||
|
@Transactional(TransactionMode.COMMIT)
|
||||||
|
@CreateSchema({"clean_schema.sql"})
|
||||||
|
public class CcmModulesTest {
|
||||||
|
|
||||||
|
@PersistenceContext(name = "LibreCCM")
|
||||||
|
private transient EntityManager entityManager;
|
||||||
|
|
||||||
|
public CcmModulesTest() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@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.CcmModulesTest.war")
|
||||||
|
.addAsLibraries(libs)
|
||||||
|
.addAsWebInfResource("web.xml")
|
||||||
|
.addAsWebInfResource("test-persistence.xml")
|
||||||
|
.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void verifyModules() throws SQLException {
|
||||||
|
final Object dataSourceObj = entityManager.getEntityManagerFactory()
|
||||||
|
.getProperties().get("javax.persistence.jtaDataSource");
|
||||||
|
assertThat(dataSourceObj, is(instanceOf(DataSource.class)));
|
||||||
|
|
||||||
|
final DataSource dataSource = (DataSource) dataSourceObj;
|
||||||
|
final Connection connection = dataSource.getConnection();
|
||||||
|
assertThat(connection, is(instanceOf(Connection.class)));
|
||||||
|
|
||||||
|
final ResultSet ccmObjectTable = connection.getMetaData()
|
||||||
|
.getTables(null, "ccm_core", "ccm_objects", null);
|
||||||
|
if (!ccmObjectTable.next()) {
|
||||||
|
fail("No metadata for table ccm_core.ccm_objects returned. "
|
||||||
|
+ "Table does not exist?");
|
||||||
|
}
|
||||||
|
|
||||||
|
final ResultSet installedModulesTable = connection.getMetaData()
|
||||||
|
.getTables(null, "ccm_core", "installed_modules", null);
|
||||||
|
if (!installedModulesTable.next()) {
|
||||||
|
fail("No metadata for table ccm_core.installed_modules returned. "
|
||||||
|
+ "Table does not exist?");
|
||||||
|
}
|
||||||
|
|
||||||
|
final Statement statement = connection.createStatement();
|
||||||
|
final ResultSet installedModules = statement.executeQuery(
|
||||||
|
"SELECT module_id, module_class_name, status "
|
||||||
|
+ "FROM ccm_core.installed_modules"
|
||||||
|
+ " ORDER BY module_class_name");
|
||||||
|
final List<InstalledModuleData> modulesData = new ArrayList<>();
|
||||||
|
while (installedModules.next()) {
|
||||||
|
createInstalledModuleListEntry(installedModules, modulesData);
|
||||||
|
}
|
||||||
|
|
||||||
|
assertThat(modulesData.size(), is(1));
|
||||||
|
|
||||||
|
assertThat(Integer.toString(modulesData.get(0).getModuleId()),
|
||||||
|
is(equalTo(Integer.toString(CcmCore.class.getName().
|
||||||
|
hashCode()))));
|
||||||
|
assertThat(modulesData.get(0).getModuleClassName(),
|
||||||
|
is(equalTo(CcmCore.class.getName())));
|
||||||
|
assertThat(modulesData.get(0).getStatus(),
|
||||||
|
is(equalTo(ModuleStatus.INSTALLED.toString())));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createInstalledModuleListEntry(
|
||||||
|
final ResultSet resultSet, final List<InstalledModuleData> modulesData)
|
||||||
|
throws SQLException {
|
||||||
|
|
||||||
|
final InstalledModuleData moduleData = new InstalledModuleData();
|
||||||
|
moduleData.setModuleId(resultSet.getInt("module_id"));
|
||||||
|
moduleData.setModuleClassName(resultSet.getString("module_class_name"));
|
||||||
|
moduleData.setStatus(resultSet.getString("status"));
|
||||||
|
|
||||||
|
modulesData.add(moduleData);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class InstalledModuleData {
|
||||||
|
|
||||||
|
private int moduleId;
|
||||||
|
private String moduleClassName;
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
public int getModuleId() {
|
||||||
|
return moduleId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setModuleId(final int moduleId) {
|
||||||
|
this.moduleId = moduleId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getModuleClassName() {
|
||||||
|
return moduleClassName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setModuleClassName(final String moduleClassName) {
|
||||||
|
this.moduleClassName = moduleClassName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(final String status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
8
pom.xml
8
pom.xml
|
|
@ -1,8 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
|
||||||
http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|
@ -42,7 +39,8 @@
|
||||||
<module>ccm-shortcuts</module>
|
<module>ccm-shortcuts</module>
|
||||||
<module>ccm-testutils</module>
|
<module>ccm-testutils</module>
|
||||||
<module>ccm-docrepo</module>
|
<module>ccm-docrepo</module>
|
||||||
</modules>
|
<module>ccm-test-bundle</module>
|
||||||
|
</modules>
|
||||||
|
|
||||||
<!--<repositories>
|
<!--<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue