CCM NG: FilePortationTest now deploys without errors

git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@3977 8810af33-2d31-482b-a856-94f89814c4df
pull/2/head
jensp 2016-04-07 08:47:09 +00:00
parent 84e44321e6
commit 4e55d0279e
4 changed files with 109 additions and 101 deletions

View File

@ -18,6 +18,7 @@
*/ */
package org.libreccm.jpa; package org.libreccm.jpa;
import javax.enterprise.context.ApplicationScoped;
import org.hibernate.envers.AuditReader; import org.hibernate.envers.AuditReader;
import org.hibernate.envers.AuditReaderFactory; import org.hibernate.envers.AuditReaderFactory;
@ -29,6 +30,8 @@ import javax.persistence.EntityManager;
* *
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a> * @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/ */
@ApplicationScoped
@SuppressWarnings("PMD.UnusedPrivateField")
public class AuditReaderProducer { public class AuditReaderProducer {
@Inject @Inject

View File

@ -38,16 +38,7 @@ import org.junit.Before;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; 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.tests.categories.IntegrationTest;
import org.libreccm.testutils.EqualsVerifier;
import org.libreccm.web.CcmApplication;
import org.libreccm.workflow.Workflow;
import java.io.File; import java.io.File;
import java.math.BigDecimal; import java.math.BigDecimal;
@ -95,10 +86,10 @@ public class ConfigurationManagerTest {
@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) {
@ -107,29 +98,36 @@ public class ConfigurationManagerTest {
} }
return ShrinkWrap return ShrinkWrap
.create(WebArchive.class, .create(WebArchive.class,
"LibreCCM-org.libreccm.categorization.ConfigurationManagerTest.war") "LibreCCM-org.libreccm.categorization."
.addPackage(CcmObject.class.getPackage()) + "ConfigurationManagerTest.war")
.addPackage(Permission.class.getPackage()) .addPackage(org.libreccm.categorization.Categorization.class.
.addPackage(CcmApplication.class.getPackage()) getPackage())
.addPackage(Categorization.class.getPackage()) .addPackage(org.libreccm.configuration.Configuration.class.
.addPackage(Configuration.class.getPackage()) getPackage())
.addPackage(LocalizedString.class.getPackage()) .addPackage(org.libreccm.core.CcmObject.class.getPackage())
.addPackage(Workflow.class.getPackage()) .addPackage(org.libreccm.jpa.EntityManagerProducer.class.
.addPackage(EntityManagerProducer.class.getPackage()) getPackage())
.addPackage(MimeTypeConverter.class.getPackage()) .addPackage(org.libreccm.jpa.utils.MimeTypeConverter.class.
.addPackage(EqualsVerifier.class.getPackage()) getPackage())
.addPackage(IntegrationTest.class.getPackage()) .addPackage(org.libreccm.l10n.LocalizedString.class
.addPackage(TestConfiguration.class.getPackage()) .getPackage())
.addAsLibraries(libs) .addPackage(org.libreccm.security.Permission.class.getPackage())
.addAsResource("test-persistence.xml", .addPackage(org.libreccm.web.CcmApplication.class.getPackage())
"META-INF/persistence.xml") .addPackage(org.libreccm.workflow.Workflow.class.getPackage())
.addAsResource( .addPackage(org.libreccm.tests.categories.IntegrationTest.class.
"configs/org/libreccm/configuration/ConfigurationManagerTest/" getPackage())
+ "log4j2.xml", .addPackage(org.libreccm.testutils.EqualsVerifier.class.
"log4j2.xml") getPackage())
.addAsWebInfResource("test-web.xml", "WEB-INF/web.xml") .addAsLibraries(libs)
.addAsWebInfResource(EmptyAsset.INSTANCE, "WEB-INF/beans.xml"); .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 @Test
@ -140,7 +138,7 @@ public class ConfigurationManagerTest {
@Test @Test
@UsingDataSet( @UsingDataSet(
"datasets/org/libreccm/configuration/ConfigurationManagerTest/data.yml") "datasets/org/libreccm/configuration/ConfigurationManagerTest/data.yml")
@InSequence(2) @InSequence(2)
public void datasetOnly() { public void datasetOnly() {
System.out.println("Dataset loaded successfully."); System.out.println("Dataset loaded successfully.");
@ -148,11 +146,11 @@ public class ConfigurationManagerTest {
@Test @Test
@UsingDataSet( @UsingDataSet(
"datasets/org/libreccm/configuration/ConfigurationManagerTest/data.yml") "datasets/org/libreccm/configuration/ConfigurationManagerTest/data.yml")
@InSequence(1100) @InSequence(1100)
public void loadConfiguration() { public void loadConfiguration() {
final ExampleConfiguration configuration = configurationManager final ExampleConfiguration configuration = configurationManager
.findConfiguration(ExampleConfiguration.class); .findConfiguration(ExampleConfiguration.class);
assertThat(configuration, is(not(nullValue()))); assertThat(configuration, is(not(nullValue())));
assertThat(configuration.getPrice(), assertThat(configuration.getPrice(),
@ -169,14 +167,14 @@ public class ConfigurationManagerTest {
@Test @Test
@UsingDataSet( @UsingDataSet(
"datasets/org/libreccm/configuration/ConfigurationManagerTest/data.yml") "datasets/org/libreccm/configuration/ConfigurationManagerTest/data.yml")
@ShouldMatchDataSet( @ShouldMatchDataSet(
"datasets/org/libreccm/configuration/ConfigurationManagerTest/" "datasets/org/libreccm/configuration/ConfigurationManagerTest/"
+ "after-save-changed.yml") + "after-save-changed.yml")
@InSequence(1200) @InSequence(1200)
public void saveConfiguration() { public void saveConfiguration() {
final ExampleConfiguration configuration = configurationManager final ExampleConfiguration configuration = configurationManager
.findConfiguration(ExampleConfiguration.class); .findConfiguration(ExampleConfiguration.class);
configuration.setPrice(new BigDecimal("109.99")); configuration.setPrice(new BigDecimal("109.99"));
configuration.setItemsPerPage(30L); configuration.setItemsPerPage(30L);
@ -187,11 +185,11 @@ public class ConfigurationManagerTest {
@Test @Test
@UsingDataSet( @UsingDataSet(
"datasets/org/libreccm/configuration/ConfigurationManagerTest/data.yml") "datasets/org/libreccm/configuration/ConfigurationManagerTest/data.yml")
@InSequence(2100) @InSequence(2100)
public void loadNewConfiguration() { public void loadNewConfiguration() {
final TestConfiguration configuration = configurationManager final TestConfiguration configuration = configurationManager
.findConfiguration(TestConfiguration.class); .findConfiguration(TestConfiguration.class);
assertThat(configuration, is(not(nullValue()))); assertThat(configuration, is(not(nullValue())));
assertThat(configuration.getEnabled(), is(false)); assertThat(configuration.getEnabled(), is(false));
@ -200,11 +198,11 @@ public class ConfigurationManagerTest {
@Test @Test
@UsingDataSet( @UsingDataSet(
"datasets/org/libreccm/configuration/ConfigurationManagerTest/data.yml") "datasets/org/libreccm/configuration/ConfigurationManagerTest/data.yml")
@ShouldMatchDataSet( @ShouldMatchDataSet(
value = "datasets/org/libreccm/configuration/" value = "datasets/org/libreccm/configuration/"
+ "ConfigurationManagerTest/after-save-new.yml", + "ConfigurationManagerTest/after-save-new.yml",
excludeColumns = {"object_id", "uuid"}) excludeColumns = {"object_id", "uuid"})
@InSequence(2200) @InSequence(2200)
public void saveNewConfiguration() { public void saveNewConfiguration() {
configurationManager.saveConfiguration(new TestConfiguration()); configurationManager.saveConfiguration(new TestConfiguration());

View File

@ -18,16 +18,17 @@
*/ */
package org.libreccm.docrepo; package org.libreccm.docrepo;
import javax.enterprise.context.RequestScoped;
import org.libreccm.portation.Marshals; import org.libreccm.portation.Marshals;
import javax.faces.bean.RequestScoped;
import javax.inject.Inject; import javax.inject.Inject;
/** /**
* Marshaller class for importing and exporting {@code File}s from the * Marshaller class for importing and exporting {@code File}s from the
* system into a specified file and the other way around. * system into a specified file and the other way around.
* *
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a> * @author <a href="mailto:tosmers@uni-bremen.de">Tobias Osmers</a>
* @version created the 3/16/16 * @version created the 3/16/16
*/ */
@RequestScoped @RequestScoped

View File

@ -30,7 +30,6 @@ import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive; import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.shrinkwrap.resolver.api.maven.Maven; import org.jboss.shrinkwrap.resolver.api.maven.Maven;
import org.jboss.shrinkwrap.resolver.api.maven.PomEquippedResolveStage; import org.jboss.shrinkwrap.resolver.api.maven.PomEquippedResolveStage;
import org.jboss.shrinkwrap.resolver.api.maven.ScopeType;
import org.junit.After; import org.junit.After;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.Before; import org.junit.Before;
@ -40,19 +39,15 @@ import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.libreccm.docrepo.File; import org.libreccm.docrepo.File;
import org.libreccm.docrepo.FileMarshaller; 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.portation.Format;
import org.libreccm.tests.categories.IntegrationTest; import org.libreccm.tests.categories.IntegrationTest;
import org.libreccm.testutils.EqualsVerifier;
import org.libreccm.workflow.Workflow;
import javax.inject.Inject; import javax.inject.Inject;
import java.util.Collections; import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import org.libreccm.portation.Marshals;
import static org.hamcrest.CoreMatchers.*; import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.assertThat; import static org.junit.Assert.assertThat;
@ -70,14 +65,16 @@ import static org.junit.Assert.assertThat;
@CreateSchema({"create_ccm_docrepo_schema.sql"}) @CreateSchema({"create_ccm_docrepo_schema.sql"})
public class FilePortationTest { public class FilePortationTest {
private static final Logger log = Logger.getLogger(FilePortationTest.class); private static final Logger LOGGER = Logger.getLogger(
FilePortationTest.class);
@Inject @Inject
@Marshals(File.class)
private FileMarshaller fileMarshaller; private FileMarshaller fileMarshaller;
private static File file; private static File file;
private static String filePath private static String filePath
= "src/test/resources/datasets/org/libreccm/docrepo/FilePortationTest/"; = "src/test/resources/datasets/org/libreccm/docrepo/FilePortationTest/";
@BeforeClass @BeforeClass
public static void setUpClass() { public static void setUpClass() {
@ -108,12 +105,12 @@ public class FilePortationTest {
@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 java.io.File[] libs = dependencies.resolve().withTransitivity() final java.io.File[] libs = dependencies.resolve().withTransitivity()
.asFile(); .asFile();
for (java.io.File lib : libs) { for (java.io.File lib : libs) {
System.err.printf("Adding file '%s' to test archive...%n", System.err.printf("Adding file '%s' to test archive...%n",
@ -121,48 +118,62 @@ public class FilePortationTest {
} }
final PomEquippedResolveStage corePom = Maven.resolver() final PomEquippedResolveStage corePom = Maven.resolver()
.loadPomFromFile("../ccm-core/pom.xml"); .loadPomFromFile("../ccm-core/pom.xml");
final PomEquippedResolveStage coreDependencies = corePom final PomEquippedResolveStage coreDependencies = corePom
.importCompileAndRuntimeDependencies(); .importCompileAndRuntimeDependencies();
final java.io.File[] coreLibs = coreDependencies.resolve().withoutTransitivity().asFile(); final java.io.File[] coreLibs = coreDependencies.resolve().
for(java.io.File lib : coreLibs) { withTransitivity().asFile();
for (java.io.File lib : coreLibs) {
System.err.printf("Adding file '%s' to test archive...%n", System.err.printf("Adding file '%s' to test archive...%n",
lib.getName()); lib.getName());
} }
return ShrinkWrap return ShrinkWrap
.create(WebArchive.class, .create(WebArchive.class,
"LibreCCM-org.libreccm.docrepo.FilePortationTest.war") "LibreCCM-org.libreccm.docrepo.FilePortationTest.war")
.addPackage( .addPackage(
org.libreccm.auditing.AbstractAuditedEntityRepository.class org.libreccm.auditing.AbstractAuditedEntityRepository.class.
.getPackage()) getPackage())
.addPackage(org.libreccm.core.CcmObject.class.getPackage()) .addPackage(org.libreccm.categorization.Categorization.class
.addPackage(org.libreccm.categorization.Categorization.class .getPackage())
.getPackage()) .addPackage(
.addPackage(org.libreccm.docrepo.FileMarshaller.class.getPackage()) org.libreccm.configuration.ConfigurationManager.class
.addPackage(org.libreccm.jpa.EntityManagerProducer.class .getPackage())
.getPackage()) .addPackage(org.libreccm.core.CcmObject.class.getPackage())
.addPackage(org.libreccm.jpa.utils.MimeTypeConverter.class .addPackage(org.libreccm.docrepo.FileMarshaller.class.
.getPackage()) getPackage())
.addPackage(org.libreccm.l10n.LocalizedString.class.getPackage()) .addPackage(org.libreccm.jpa.EntityManagerProducer.class
.addPackage(org.libreccm.portal.Portlet.class.getPackage()) .getPackage())
.addPackage(org.libreccm.portation.AbstractMarshaller.class .addPackage(org.libreccm.jpa.utils.MimeTypeConverter.class
.getPackage()) .getPackage())
.addPackage(org.libreccm.security.Permission.class.getPackage()) .addPackage(org.libreccm.l10n.LocalizedString.class
.addPackage(org.libreccm.web.CcmApplication.class.getPackage()) .getPackage())
.addPackage(org.libreccm.workflow.Workflow.class.getPackage()) .addPackage(org.libreccm.portal.Portlet.class.getPackage())
.addPackage(org.libreccm.testutils.EqualsVerifier.class.getPackage()) .addPackage(org.libreccm.portation.AbstractMarshaller.class
.addPackage(org.libreccm.tests.categories.IntegrationTest.class .getPackage())
.getPackage()) .addPackage(org.libreccm.security.Permission.class.getPackage())
.addAsLibraries(libs) .addPackage(org.libreccm.web.CcmApplication.class.getPackage())
.addAsLibraries(coreLibs) .addPackage(org.libreccm.workflow.Workflow.class.getPackage())
.addAsResource("test-persistence.xml", .addPackage(org.libreccm.testutils.EqualsVerifier.class.
"META-INF/persistence.xml") getPackage())
.addAsWebInfResource("test-web.xml", "WEB-INF/web.xml") .addPackage(org.libreccm.tests.categories.IntegrationTest.class
.addAsWebInfResource(EmptyAsset.INSTANCE, "WEB-INF/beans.xml"); .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 @Test
@InSequence(10)
public void fileMarshallerIsInjected() {
assertThat(fileMarshaller, is(not(nullValue())));
}
@Test
@InSequence(100)
public void xmlShouldBeCreated() { public void xmlShouldBeCreated() {
fileMarshaller.prepare(Format.XML, filePath + "test1.xml"); fileMarshaller.prepare(Format.XML, filePath + "test1.xml");
List<File> fileList = Collections.singletonList(file); List<File> fileList = Collections.singletonList(file);
@ -171,14 +182,9 @@ public class FilePortationTest {
} }
@Test @Test
@InSequence(200)
public void docrepoFileShouldBeCreated() { public void docrepoFileShouldBeCreated() {
// TODO: test file import // TODO: test file import
} }
@Test
@InSequence(10)
public void repoIsInjected() {
assertThat(fileMarshaller, is(not(nullValue())));
}
} }