diff --git a/ccm-core/src/main/java/org/libreccm/jpa/AuditReaderProducer.java b/ccm-core/src/main/java/org/libreccm/jpa/AuditReaderProducer.java
index a3beff037..9cb8deaa2 100644
--- a/ccm-core/src/main/java/org/libreccm/jpa/AuditReaderProducer.java
+++ b/ccm-core/src/main/java/org/libreccm/jpa/AuditReaderProducer.java
@@ -18,6 +18,7 @@
*/
package org.libreccm.jpa;
+import javax.enterprise.context.ApplicationScoped;
import org.hibernate.envers.AuditReader;
import org.hibernate.envers.AuditReaderFactory;
@@ -29,6 +30,8 @@ import javax.persistence.EntityManager;
*
* @author Jens Pelzetter
*/
+@ApplicationScoped
+@SuppressWarnings("PMD.UnusedPrivateField")
public class AuditReaderProducer {
@Inject
diff --git a/ccm-core/src/test/java/org/libreccm/configuration/ConfigurationManagerTest.java b/ccm-core/src/test/java/org/libreccm/configuration/ConfigurationManagerTest.java
index 0c68a2f13..8c3cf2c14 100644
--- a/ccm-core/src/test/java/org/libreccm/configuration/ConfigurationManagerTest.java
+++ b/ccm-core/src/test/java/org/libreccm/configuration/ConfigurationManagerTest.java
@@ -38,16 +38,7 @@ 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.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 java.math.BigDecimal;
@@ -95,10 +86,10 @@ public class ConfigurationManagerTest {
@Deployment
public static WebArchive createDeployment() {
final PomEquippedResolveStage pom = Maven
- .resolver()
- .loadPomFromFile("pom.xml");
+ .resolver()
+ .loadPomFromFile("pom.xml");
final PomEquippedResolveStage dependencies = pom
- .importCompileAndRuntimeDependencies();
+ .importCompileAndRuntimeDependencies();
final File[] libs = dependencies.resolve().withTransitivity().asFile();
for (File lib : libs) {
@@ -107,29 +98,36 @@ public class ConfigurationManagerTest {
}
return ShrinkWrap
- .create(WebArchive.class,
- "LibreCCM-org.libreccm.categorization.ConfigurationManagerTest.war")
- .addPackage(CcmObject.class.getPackage())
- .addPackage(Permission.class.getPackage())
- .addPackage(CcmApplication.class.getPackage())
- .addPackage(Categorization.class.getPackage())
- .addPackage(Configuration.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())
- .addPackage(TestConfiguration.class.getPackage())
- .addAsLibraries(libs)
- .addAsResource("test-persistence.xml",
- "META-INF/persistence.xml")
- .addAsResource(
- "configs/org/libreccm/configuration/ConfigurationManagerTest/"
- + "log4j2.xml",
- "log4j2.xml")
- .addAsWebInfResource("test-web.xml", "WEB-INF/web.xml")
- .addAsWebInfResource(EmptyAsset.INSTANCE, "WEB-INF/beans.xml");
+ .create(WebArchive.class,
+ "LibreCCM-org.libreccm.categorization."
+ + "ConfigurationManagerTest.war")
+ .addPackage(org.libreccm.categorization.Categorization.class.
+ getPackage())
+ .addPackage(org.libreccm.configuration.Configuration.class.
+ getPackage())
+ .addPackage(org.libreccm.core.CcmObject.class.getPackage())
+ .addPackage(org.libreccm.jpa.EntityManagerProducer.class.
+ getPackage())
+ .addPackage(org.libreccm.jpa.utils.MimeTypeConverter.class.
+ getPackage())
+ .addPackage(org.libreccm.l10n.LocalizedString.class
+ .getPackage())
+ .addPackage(org.libreccm.security.Permission.class.getPackage())
+ .addPackage(org.libreccm.web.CcmApplication.class.getPackage())
+ .addPackage(org.libreccm.workflow.Workflow.class.getPackage())
+ .addPackage(org.libreccm.tests.categories.IntegrationTest.class.
+ getPackage())
+ .addPackage(org.libreccm.testutils.EqualsVerifier.class.
+ getPackage())
+ .addAsLibraries(libs)
+ .addAsResource("test-persistence.xml",
+ "META-INF/persistence.xml")
+ .addAsResource(
+ "configs/org/libreccm/configuration/ConfigurationManagerTest/"
+ + "log4j2.xml",
+ "log4j2.xml")
+ .addAsWebInfResource("test-web.xml", "WEB-INF/web.xml")
+ .addAsWebInfResource(EmptyAsset.INSTANCE, "WEB-INF/beans.xml");
}
@Test
@@ -140,7 +138,7 @@ public class ConfigurationManagerTest {
@Test
@UsingDataSet(
- "datasets/org/libreccm/configuration/ConfigurationManagerTest/data.yml")
+ "datasets/org/libreccm/configuration/ConfigurationManagerTest/data.yml")
@InSequence(2)
public void datasetOnly() {
System.out.println("Dataset loaded successfully.");
@@ -148,11 +146,11 @@ public class ConfigurationManagerTest {
@Test
@UsingDataSet(
- "datasets/org/libreccm/configuration/ConfigurationManagerTest/data.yml")
+ "datasets/org/libreccm/configuration/ConfigurationManagerTest/data.yml")
@InSequence(1100)
public void loadConfiguration() {
final ExampleConfiguration configuration = configurationManager
- .findConfiguration(ExampleConfiguration.class);
+ .findConfiguration(ExampleConfiguration.class);
assertThat(configuration, is(not(nullValue())));
assertThat(configuration.getPrice(),
@@ -169,14 +167,14 @@ public class ConfigurationManagerTest {
@Test
@UsingDataSet(
- "datasets/org/libreccm/configuration/ConfigurationManagerTest/data.yml")
+ "datasets/org/libreccm/configuration/ConfigurationManagerTest/data.yml")
@ShouldMatchDataSet(
- "datasets/org/libreccm/configuration/ConfigurationManagerTest/"
- + "after-save-changed.yml")
+ "datasets/org/libreccm/configuration/ConfigurationManagerTest/"
+ + "after-save-changed.yml")
@InSequence(1200)
public void saveConfiguration() {
final ExampleConfiguration configuration = configurationManager
- .findConfiguration(ExampleConfiguration.class);
+ .findConfiguration(ExampleConfiguration.class);
configuration.setPrice(new BigDecimal("109.99"));
configuration.setItemsPerPage(30L);
@@ -187,11 +185,11 @@ public class ConfigurationManagerTest {
@Test
@UsingDataSet(
- "datasets/org/libreccm/configuration/ConfigurationManagerTest/data.yml")
+ "datasets/org/libreccm/configuration/ConfigurationManagerTest/data.yml")
@InSequence(2100)
public void loadNewConfiguration() {
final TestConfiguration configuration = configurationManager
- .findConfiguration(TestConfiguration.class);
+ .findConfiguration(TestConfiguration.class);
assertThat(configuration, is(not(nullValue())));
assertThat(configuration.getEnabled(), is(false));
@@ -200,11 +198,11 @@ public class ConfigurationManagerTest {
@Test
@UsingDataSet(
- "datasets/org/libreccm/configuration/ConfigurationManagerTest/data.yml")
+ "datasets/org/libreccm/configuration/ConfigurationManagerTest/data.yml")
@ShouldMatchDataSet(
- value = "datasets/org/libreccm/configuration/"
- + "ConfigurationManagerTest/after-save-new.yml",
- excludeColumns = {"object_id", "uuid"})
+ value = "datasets/org/libreccm/configuration/"
+ + "ConfigurationManagerTest/after-save-new.yml",
+ excludeColumns = {"object_id", "uuid"})
@InSequence(2200)
public void saveNewConfiguration() {
configurationManager.saveConfiguration(new TestConfiguration());
diff --git a/ccm-docrepo/src/main/java/org/libreccm/docrepo/FileMarshaller.java b/ccm-docrepo/src/main/java/org/libreccm/docrepo/FileMarshaller.java
index 1bfe2a39a..564114c6a 100644
--- a/ccm-docrepo/src/main/java/org/libreccm/docrepo/FileMarshaller.java
+++ b/ccm-docrepo/src/main/java/org/libreccm/docrepo/FileMarshaller.java
@@ -18,16 +18,17 @@
*/
package org.libreccm.docrepo;
+import javax.enterprise.context.RequestScoped;
import org.libreccm.portation.Marshals;
-import javax.faces.bean.RequestScoped;
+
import javax.inject.Inject;
/**
* Marshaller class for importing and exporting {@code File}s from the
* system into a specified file and the other way around.
*
- * @author Tobias Osmers
* @version created the 3/16/16
*/
@RequestScoped
diff --git a/ccm-docrepo/src/test/java/org/libreccm/docrepo/portation/FilePortationTest.java b/ccm-docrepo/src/test/java/org/libreccm/docrepo/portation/FilePortationTest.java
index 6b5865c81..caf6e91c8 100644
--- a/ccm-docrepo/src/test/java/org/libreccm/docrepo/portation/FilePortationTest.java
+++ b/ccm-docrepo/src/test/java/org/libreccm/docrepo/portation/FilePortationTest.java
@@ -30,7 +30,6 @@ 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.jboss.shrinkwrap.resolver.api.maven.ScopeType;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
@@ -40,19 +39,15 @@ import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.libreccm.docrepo.File;
import org.libreccm.docrepo.FileMarshaller;
-import org.libreccm.jpa.EntityManagerProducer;
-import org.libreccm.jpa.utils.MimeTypeConverter;
-import org.libreccm.l10n.LocalizedString;
import org.libreccm.portation.Format;
import org.libreccm.tests.categories.IntegrationTest;
-import org.libreccm.testutils.EqualsVerifier;
-import org.libreccm.workflow.Workflow;
import javax.inject.Inject;
import java.util.Collections;
import java.util.Date;
import java.util.List;
+import org.libreccm.portation.Marshals;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.assertThat;
@@ -70,14 +65,16 @@ import static org.junit.Assert.assertThat;
@CreateSchema({"create_ccm_docrepo_schema.sql"})
public class FilePortationTest {
- private static final Logger log = Logger.getLogger(FilePortationTest.class);
+ private static final Logger LOGGER = Logger.getLogger(
+ FilePortationTest.class);
@Inject
+ @Marshals(File.class)
private FileMarshaller fileMarshaller;
private static File file;
private static String filePath
- = "src/test/resources/datasets/org/libreccm/docrepo/FilePortationTest/";
+ = "src/test/resources/datasets/org/libreccm/docrepo/FilePortationTest/";
@BeforeClass
public static void setUpClass() {
@@ -108,12 +105,12 @@ public class FilePortationTest {
@Deployment
public static WebArchive createDeployment() {
final PomEquippedResolveStage pom = Maven
- .resolver()
- .loadPomFromFile("pom.xml");
+ .resolver()
+ .loadPomFromFile("pom.xml");
final PomEquippedResolveStage dependencies = pom
- .importCompileAndRuntimeDependencies();
+ .importCompileAndRuntimeDependencies();
final java.io.File[] libs = dependencies.resolve().withTransitivity()
- .asFile();
+ .asFile();
for (java.io.File lib : libs) {
System.err.printf("Adding file '%s' to test archive...%n",
@@ -121,48 +118,62 @@ public class FilePortationTest {
}
final PomEquippedResolveStage corePom = Maven.resolver()
- .loadPomFromFile("../ccm-core/pom.xml");
+ .loadPomFromFile("../ccm-core/pom.xml");
final PomEquippedResolveStage coreDependencies = corePom
- .importCompileAndRuntimeDependencies();
- final java.io.File[] coreLibs = coreDependencies.resolve().withoutTransitivity().asFile();
- for(java.io.File lib : coreLibs) {
+ .importCompileAndRuntimeDependencies();
+ final java.io.File[] coreLibs = coreDependencies.resolve().
+ withTransitivity().asFile();
+ for (java.io.File lib : coreLibs) {
System.err.printf("Adding file '%s' to test archive...%n",
lib.getName());
}
return ShrinkWrap
- .create(WebArchive.class,
- "LibreCCM-org.libreccm.docrepo.FilePortationTest.war")
- .addPackage(
- org.libreccm.auditing.AbstractAuditedEntityRepository.class
- .getPackage())
- .addPackage(org.libreccm.core.CcmObject.class.getPackage())
- .addPackage(org.libreccm.categorization.Categorization.class
- .getPackage())
- .addPackage(org.libreccm.docrepo.FileMarshaller.class.getPackage())
- .addPackage(org.libreccm.jpa.EntityManagerProducer.class
- .getPackage())
- .addPackage(org.libreccm.jpa.utils.MimeTypeConverter.class
- .getPackage())
- .addPackage(org.libreccm.l10n.LocalizedString.class.getPackage())
- .addPackage(org.libreccm.portal.Portlet.class.getPackage())
- .addPackage(org.libreccm.portation.AbstractMarshaller.class
- .getPackage())
- .addPackage(org.libreccm.security.Permission.class.getPackage())
- .addPackage(org.libreccm.web.CcmApplication.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)
- .addAsLibraries(coreLibs)
- .addAsResource("test-persistence.xml",
- "META-INF/persistence.xml")
- .addAsWebInfResource("test-web.xml", "WEB-INF/web.xml")
- .addAsWebInfResource(EmptyAsset.INSTANCE, "WEB-INF/beans.xml");
+ .create(WebArchive.class,
+ "LibreCCM-org.libreccm.docrepo.FilePortationTest.war")
+ .addPackage(
+ org.libreccm.auditing.AbstractAuditedEntityRepository.class.
+ getPackage())
+ .addPackage(org.libreccm.categorization.Categorization.class
+ .getPackage())
+ .addPackage(
+ org.libreccm.configuration.ConfigurationManager.class
+ .getPackage())
+ .addPackage(org.libreccm.core.CcmObject.class.getPackage())
+ .addPackage(org.libreccm.docrepo.FileMarshaller.class.
+ getPackage())
+ .addPackage(org.libreccm.jpa.EntityManagerProducer.class
+ .getPackage())
+ .addPackage(org.libreccm.jpa.utils.MimeTypeConverter.class
+ .getPackage())
+ .addPackage(org.libreccm.l10n.LocalizedString.class
+ .getPackage())
+ .addPackage(org.libreccm.portal.Portlet.class.getPackage())
+ .addPackage(org.libreccm.portation.AbstractMarshaller.class
+ .getPackage())
+ .addPackage(org.libreccm.security.Permission.class.getPackage())
+ .addPackage(org.libreccm.web.CcmApplication.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)
+ .addAsLibraries(coreLibs)
+ .addAsResource("test-persistence.xml",
+ "META-INF/persistence.xml")
+ .addAsWebInfResource("test-web.xml", "WEB-INF/web.xml")
+ .addAsWebInfResource(EmptyAsset.INSTANCE, "WEB-INF/beans.xml");
}
@Test
+ @InSequence(10)
+ public void fileMarshallerIsInjected() {
+ assertThat(fileMarshaller, is(not(nullValue())));
+ }
+
+ @Test
+ @InSequence(100)
public void xmlShouldBeCreated() {
fileMarshaller.prepare(Format.XML, filePath + "test1.xml");
List fileList = Collections.singletonList(file);
@@ -171,14 +182,9 @@ public class FilePortationTest {
}
@Test
+ @InSequence(200)
public void docrepoFileShouldBeCreated() {
// TODO: test file import
}
- @Test
- @InSequence(10)
- public void repoIsInjected() {
- assertThat(fileMarshaller, is(not(nullValue())));
- }
-
}