CCM NG: Setup for registry
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@3835 8810af33-2d31-482b-a856-94f89814c4dfpull/2/head
parent
34907dfe89
commit
d2bfec2a1b
|
|
@ -0,0 +1,63 @@
|
||||||
|
<?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-bundle-devel-wildfly</artifactId>
|
||||||
|
<!--<version>7.0.0-SNAPSHOT</version>-->
|
||||||
|
<packaging>ear</packaging>
|
||||||
|
|
||||||
|
<name>LibreCCM Devel Bundle for Wildfly</name>
|
||||||
|
<url>http://www.libreccm.org/bundles/devel/wildfly</url>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.libreccm</groupId>
|
||||||
|
<artifactId>ccm-bundle-devel-wildfly-web</artifactId>
|
||||||
|
<version>${project.parent.version}</version>
|
||||||
|
<type>war</type>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<finalName>libreccm-devel-7.0.0-SNAPSHOT</finalName>
|
||||||
|
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-ear-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<!-- Tell Maven we are using Java EE 7 -->
|
||||||
|
<version>7</version>
|
||||||
|
<!-- Use Java EE ear libraries as needed. Java EE ear libraries
|
||||||
|
are in easy way to package any libraries needed in the ear, and automatically
|
||||||
|
have any modules (EJB-JARs and WARs) use them -->
|
||||||
|
<defaultLibBundleDir>lib</defaultLibBundleDir>
|
||||||
|
<fileNameMapping>no-version</fileNameMapping>
|
||||||
|
<modules>
|
||||||
|
<webModule>
|
||||||
|
<groupId>org.libreccm</groupId>
|
||||||
|
<artifactId>ccm-bundle-devel-wildfly-web</artifactId>
|
||||||
|
<contextRoot>/libreccm</contextRoot>
|
||||||
|
</webModule>
|
||||||
|
</modules>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
||||||
|
|
@ -0,0 +1,54 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2016 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.categorization;
|
||||||
|
|
||||||
|
import org.libreccm.configuration.ConfigurationConstants;
|
||||||
|
import org.libreccm.modules.InstallEvent;
|
||||||
|
|
||||||
|
import javax.persistence.EntityManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
public class RegistrySetup {
|
||||||
|
|
||||||
|
private final EntityManager entityManager;
|
||||||
|
|
||||||
|
public RegistrySetup(final InstallEvent event) {
|
||||||
|
this.entityManager = event.getEntityManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setup() {
|
||||||
|
final Domain registry = new Domain();
|
||||||
|
registry.setDomainKey(ConfigurationConstants.REGISTRY_DOMAIN);
|
||||||
|
registry.setVersion("1.0");
|
||||||
|
registry.setDisplayName(ConfigurationConstants.REGISTRY_DOMAIN);
|
||||||
|
|
||||||
|
final Category root = new Category();
|
||||||
|
root.setName(ConfigurationConstants.REGISTRY_DOMAIN + "-root");
|
||||||
|
root.setDisplayName(ConfigurationConstants.REGISTRY_DOMAIN + "-root");
|
||||||
|
|
||||||
|
registry.setRoot(root);
|
||||||
|
|
||||||
|
entityManager.persist(root);
|
||||||
|
entityManager.persist(registry);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,62 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2016 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.categorization;
|
||||||
|
|
||||||
|
import static org.libreccm.testutils.DatasetType.*;
|
||||||
|
|
||||||
|
import org.junit.experimental.categories.Category;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.junit.runners.Parameterized;
|
||||||
|
import org.libreccm.tests.categories.UnitTest;
|
||||||
|
import org.libreccm.testutils.DatasetType;
|
||||||
|
import org.libreccm.testutils.DatasetsVerifier;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
@RunWith(Parameterized.class)
|
||||||
|
@Category(UnitTest.class)
|
||||||
|
public class RegistrySetupDatasetsTest extends DatasetsVerifier {
|
||||||
|
|
||||||
|
@Parameterized.Parameters(name = "Dataset {0}")
|
||||||
|
public static Collection<String> data() {
|
||||||
|
return Arrays.asList(new String[]{
|
||||||
|
"/datasets/org/libreccm/categorization/RegistrySetupTest/after-setup.xml"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public RegistrySetupDatasetsTest(final String datasetPath) {
|
||||||
|
super(datasetPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] getSchemas() {
|
||||||
|
return new String[]{"ccm_core"};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DatasetType getDatasetType() {
|
||||||
|
return FLAT_XML;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,143 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2016 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.categorization;
|
||||||
|
|
||||||
|
import org.libreccm.categorization.RegistrySetup;
|
||||||
|
import com.example.TestConfiguration;
|
||||||
|
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.persistence.PersistenceTest;
|
||||||
|
import org.jboss.arquillian.persistence.ShouldMatchDataSet;
|
||||||
|
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.runner.RunWith;
|
||||||
|
import org.libreccm.categorization.Categorization;
|
||||||
|
import org.libreccm.core.CcmObject;
|
||||||
|
import org.libreccm.jpa.EntityManagerProducer;
|
||||||
|
import org.libreccm.jpa.utils.MimeTypeConverter;
|
||||||
|
import org.libreccm.l10n.LocalizedString;
|
||||||
|
import org.libreccm.modules.InstallEvent;
|
||||||
|
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 java.io.File;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.persistence.EntityManager;
|
||||||
|
|
||||||
|
import org.libreccm.configuration.Configuration;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
@org.junit.experimental.categories.Category(IntegrationTest.class)
|
||||||
|
@RunWith(Arquillian.class)
|
||||||
|
@PersistenceTest
|
||||||
|
@Transactional(TransactionMode.COMMIT)
|
||||||
|
@CreateSchema({"create_ccm_core_schema.sql"})
|
||||||
|
public class RegistrySetupTest {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private EntityManager entityManager;
|
||||||
|
|
||||||
|
public RegistrySetupTest() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@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.categorization.RegistrySetupTest.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(org.libreccm.configuration.Configuration.class.getPackage())
|
||||||
|
.addPackage(org.libreccm.l10n.LocalizedString.class.getPackage())
|
||||||
|
.addPackage(org.libreccm.workflow.Workflow.class.getPackage())
|
||||||
|
.addPackage(org.libreccm.jpa.EntityManagerProducer.class.getPackage())
|
||||||
|
.addPackage(org.libreccm.jpa.utils.MimeTypeConverter.class.getPackage())
|
||||||
|
.addPackage(org.libreccm.testutils.EqualsVerifier.class.getPackage())
|
||||||
|
.addPackage(org.libreccm.tests.categories.IntegrationTest.class.getPackage())
|
||||||
|
.addPackage(org.libreccm.modules.InstallEvent.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");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@ShouldMatchDataSet(value =
|
||||||
|
"datasets/org/libreccm/categorization/RegistrySetupTest/after-setup.xml",
|
||||||
|
excludeColumns = {"object_id", "root_category_id"})
|
||||||
|
@InSequence(100)
|
||||||
|
public void setupRegistry() {
|
||||||
|
final InstallEvent installEvent = new InstallEvent();
|
||||||
|
installEvent.setEntityManager(entityManager);
|
||||||
|
final RegistrySetup registrySetup = new RegistrySetup(installEvent);
|
||||||
|
registrySetup.setup();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<dataset>
|
||||||
|
<ccm_core.ccm_objects object_id="-10"
|
||||||
|
display_name="registry" />
|
||||||
|
<ccm_core.ccm_objects object_id="-20"
|
||||||
|
display_name="registry-root" />
|
||||||
|
<ccm_core.categories object_id="-20"
|
||||||
|
name="registry-root" />
|
||||||
|
<ccm_core.category_domains object_id="-10"
|
||||||
|
domain_key="registry"
|
||||||
|
root_category_id="-20" />
|
||||||
|
</dataset>
|
||||||
Loading…
Reference in New Issue