CCM NG: Some progress on the test bundle

git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@3602 8810af33-2d31-482b-a856-94f89814c4df
pull/2/head
jensp 2015-09-04 17:18:51 +00:00
parent abfa4c6ff7
commit 551c8c398d
11 changed files with 173 additions and 42 deletions

View File

@ -8,6 +8,8 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<timestamp>${maven.build.timestamp}</timestamp>
<maven.build.timestamp.format>yyyy-MM-dd'T'HH:mm:ss'Z'Z</maven.build.timestamp.format>
</properties>
<parent>
@ -164,6 +166,13 @@
</resource>
</resources>-->
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<testResources>
<testResource>
<directory>src/test/resources</directory>

View File

@ -32,8 +32,8 @@ import javax.persistence.EntityManager;
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@Module(entities = {org.libreccm.auditing.CcmRevision.class,
org.libreccm.categorization.Category.class,
org.libreccm.categorization.Categorization.class,
org.libreccm.categorization.Category.class,
org.libreccm.categorization.Domain.class,
org.libreccm.categorization.DomainOwnership.class,
org.libreccm.core.CcmObject.class,
@ -46,7 +46,41 @@ import javax.persistence.EntityManager;
org.libreccm.core.Role.class,
org.libreccm.core.Subject.class,
org.libreccm.core.User.class,
org.libreccm.core.modules.InstalledModule.class})
org.libreccm.core.modules.InstalledModule.class,
org.libreccm.formbuilder.Component.class,
org.libreccm.formbuilder.DataDrivenSelect.class,
org.libreccm.formbuilder.FormSection.class,
org.libreccm.formbuilder.Listener.class,
org.libreccm.formbuilder.MetaObject.class,
org.libreccm.formbuilder.ObjectType.class,
org.libreccm.formbuilder.Option.class,
org.libreccm.formbuilder.PersistentDataQuery.class,
org.libreccm.formbuilder.ProcessListener.class,
org.libreccm.formbuilder.Widget.class,
org.libreccm.formbuilder.WidgetLabel.class,
org.libreccm.formbuilder.actions.ConfirmEmailListener.class,
org.libreccm.formbuilder.actions.ConfirmRedirectListener.class,
org.libreccm.formbuilder.actions.RemoteServerPostListener.class,
org.libreccm.formbuilder.actions.SimpleEmailListener.class,
org.libreccm.formbuilder.actions.TemplateEmailListener.class,
org.libreccm.formbuilder.actions.XmlEmailListener.class,
org.libreccm.messaging.Attachment.class,
org.libreccm.messaging.Message.class,
org.libreccm.messaging.MessageThread.class,
org.libreccm.notification.Digest.class,
org.libreccm.notification.Notification.class,
org.libreccm.notification.QueueItem.class,
org.libreccm.portal.Portal.class,
org.libreccm.portal.Portlet.class,
org.libreccm.runtime.Initalizer.class,
org.libreccm.search.lucene.Document.class,
org.libreccm.search.lucene.Index.class,
org.libreccm.web.Application.class,
org.libreccm.web.ApplicationType.class,
org.libreccm.web.Host.class,
org.libreccm.workflow.Task.class,
org.libreccm.workflow.UserTask.class,
org.libreccm.workflow.Workflow.class})
public class CcmCore implements CcmModule {
@Override

View File

@ -150,9 +150,9 @@ public class CcmIntegrator implements Integrator {
if (newModule) {
final Statement statement = connection.createStatement();
statement.execute(String.format(
"INSERT INTO flyhydra_core.installed_modules "
"INSERT INTO ccm_core.installed_modules "
+ "(module_id, module_class_name, status) "
+ "VALUES (%d, %s', 'NEW')",
+ "VALUES (%d, '%s', 'NEW')",
module.getName().hashCode(),
module.getName()));
}
@ -187,7 +187,7 @@ public class CcmIntegrator implements Integrator {
final Statement query = connection.createStatement();
final ResultSet result = query.executeQuery(
String.format("SELECT module_class_name, status "
+ "FROM flyhydra_core.installed_modules "
+ "FROM ccm_core.installed_modules "
+ "WHERE module_class_name = '%s'",
module.getClass().getName()));
System.out.printf("Checking status of module %s...\n",
@ -208,7 +208,7 @@ public class CcmIntegrator implements Integrator {
final Statement statement = connection.createStatement();
statement.addBatch(String.format(
"DELETE FROM flyhydra_core.installed_modules "
"DELETE FROM ccm_core.installed_modules "
+ "WHERE module_class_name = '%s'",
module.getClass().getName()));
statement.executeBatch();

View File

@ -265,8 +265,7 @@ public class ModuleInfo {
return String.format("%s/%s",
moduleInfo.getProperty(GROUP_ID),
moduleInfo.
getProperty(ARTIFACT_ID).replace(
"-", "_"));
getProperty(ARTIFACT_ID));
} else {
LOGGER.warn("The module data package was specified by the module "
+ "annotation nore was an group id found in the module info"

View File

@ -42,7 +42,7 @@ public class ModuleManager {
ModuleManager.class
);
@PersistenceContext(name = "FlyHydra")
@PersistenceContext(name = "LibreCCM")
private EntityManager entityManager;
private List<TreeNode> moduleNodes;
@ -83,7 +83,8 @@ public class ModuleManager {
installEvent.setEntityManager(entityManager);
final InstalledModule installedModule = entityManager.find(
InstalledModule.class, node.getModule().getClass().getName());
InstalledModule.class,
node.getModule().getClass().getName().hashCode());
if (installedModule != null
&& installedModule.getStatus() == ModuleStatus.NEW) {
node.getModule().install(installEvent);
@ -198,4 +199,5 @@ public class ModuleManager {
}
}
}
}

View File

@ -1,6 +1,4 @@
create schema ccm_core;
create table ccm_core.application_types (
resource_type_id int8 not null,
container_group_id int8,

View File

@ -0,0 +1,42 @@
<?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/db</jta-data-source>
<properties>
<!-- Properties for Hibernate -->
<property name="hibernate.hbm2ddl.auto" value="verify"/>
<property name="hibernate.connection.autocommit" value="false" />
<property name="hibernate.id.new_generator_mappings" value="true"/>
<property name="hibernate.id.new_generator_mappings" value="true"/>
<!--
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>

View File

@ -0,0 +1,42 @@
<?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/db</jta-data-source>
<properties>
<!-- Properties for Hibernate -->
<property name="hibernate.hbm2ddl.auto" value="verify"/>
<property name="hibernate.connection.autocommit" value="false" />
<property name="hibernate.id.new_generator_mappings" value="true"/>
<property name="hibernate.id.new_generator_mappings" value="true"/>
<!--
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>

View File

@ -25,6 +25,7 @@ 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;
@ -33,6 +34,7 @@ import static org.hamcrest.CoreMatchers.*;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.persistence.CleanupUsingScript;
import org.jboss.arquillian.persistence.CreateSchema;
import org.jboss.arquillian.persistence.PersistenceTest;
import org.jboss.arquillian.transaction.api.annotation.TransactionMode;
@ -64,7 +66,7 @@ import org.libreccm.tests.categories.IntegrationTest;
@RunWith(Arquillian.class)
@PersistenceTest
@Transactional(TransactionMode.COMMIT)
@CreateSchema({"clean_schema.sql"})
//@CreateSchema({"clean_schema.sql"})
public class CcmModulesTest {
@PersistenceContext(name = "LibreCCM")
@ -108,12 +110,15 @@ public class CcmModulesTest {
.create(WebArchive.class,
"LibreCCM-org.libreccm.CcmModulesTest.war")
.addAsLibraries(libs)
.addPackage(IntegrationTest.class.getPackage())
.setWebXML(new File("src/main/webapp/WEB-INF/web.xml"))
.addAsWebInfResource("test-persistence.xml")
//.addAsWebInfResource("test-persistence.xml", "persistence.xml")
.addAsResource("test-persistence.xml", "META-INF/persistence.xml")
.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
}
@Test
@CleanupUsingScript("clean_schema.sql")
public void verifyModules() throws SQLException {
final Object dataSourceObj = entityManager.getEntityManagerFactory()
.getProperties().get("javax.persistence.jtaDataSource");

View File

@ -1,6 +1,6 @@
-- Used by the org.libreccm.core.modules.CcmModulesTest to clean up the
-- schema before the test
-- schema after the test
DROP SCHEMA IF EXISTS ccm_core;
DROP SCHEMA IF EXISTS ccm_core CASCADE;
DROP SEQUENCE IF EXISTS hibernate_sequence;