test problems with docrepo
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@3982 8810af33-2d31-482b-a856-94f89814c4dfpull/2/head
parent
81fd867e31
commit
ad1ec92626
|
|
@ -18,8 +18,6 @@
|
||||||
*/
|
*/
|
||||||
package org.libreccm.security;
|
package org.libreccm.security;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.*;
|
|
||||||
|
|
||||||
import org.jboss.arquillian.container.test.api.Deployment;
|
import org.jboss.arquillian.container.test.api.Deployment;
|
||||||
import org.jboss.arquillian.container.test.api.ShouldThrowException;
|
import org.jboss.arquillian.container.test.api.ShouldThrowException;
|
||||||
import org.jboss.arquillian.junit.Arquillian;
|
import org.jboss.arquillian.junit.Arquillian;
|
||||||
|
|
@ -35,24 +33,20 @@ 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.junit.After;
|
import org.junit.*;
|
||||||
import org.junit.AfterClass;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.experimental.categories.Category;
|
import org.junit.experimental.categories.Category;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.libreccm.core.EmailAddress;
|
import org.libreccm.core.EmailAddress;
|
||||||
import org.libreccm.tests.categories.IntegrationTest;
|
import org.libreccm.tests.categories.IntegrationTest;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.persistence.PersistenceContext;
|
import javax.persistence.PersistenceContext;
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.hamcrest.Matchers.*;
|
||||||
|
import static org.junit.Assert.assertThat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -18,11 +18,11 @@
|
||||||
*/
|
*/
|
||||||
package org.libreccm.docrepo.portation;
|
package org.libreccm.docrepo.portation;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.jboss.arquillian.container.test.api.Deployment;
|
import org.jboss.arquillian.container.test.api.Deployment;
|
||||||
import org.jboss.arquillian.junit.Arquillian;
|
import org.jboss.arquillian.junit.Arquillian;
|
||||||
import org.jboss.arquillian.junit.InSequence;
|
import org.jboss.arquillian.junit.InSequence;
|
||||||
import org.jboss.arquillian.persistence.CreateSchema;
|
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.TransactionMode;
|
||||||
import org.jboss.arquillian.transaction.api.annotation.Transactional;
|
import org.jboss.arquillian.transaction.api.annotation.Transactional;
|
||||||
import org.jboss.shrinkwrap.api.ShrinkWrap;
|
import org.jboss.shrinkwrap.api.ShrinkWrap;
|
||||||
|
|
@ -30,27 +30,25 @@ 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.junit.After;
|
import org.junit.*;
|
||||||
import org.junit.AfterClass;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.BeforeClass;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.experimental.categories.Category;
|
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.docrepo.FileRepository;
|
||||||
import org.libreccm.portation.Format;
|
import org.libreccm.portation.Format;
|
||||||
import org.libreccm.tests.categories.IntegrationTest;
|
import org.libreccm.tests.categories.IntegrationTest;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
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;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -61,20 +59,22 @@ import static org.junit.Assert.assertThat;
|
||||||
*/
|
*/
|
||||||
@Category(IntegrationTest.class)
|
@Category(IntegrationTest.class)
|
||||||
@RunWith(Arquillian.class)
|
@RunWith(Arquillian.class)
|
||||||
|
@PersistenceTest
|
||||||
@Transactional(TransactionMode.COMMIT)
|
@Transactional(TransactionMode.COMMIT)
|
||||||
@CreateSchema({"create_ccm_docrepo_schema.sql"})
|
@CreateSchema({"create_ccm_docrepo_schema.sql"})
|
||||||
public class FilePortationTest {
|
public class FilePortationTest {
|
||||||
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(
|
|
||||||
FilePortationTest.class);
|
|
||||||
|
@Inject
|
||||||
|
private FileRepository fileRepository;
|
||||||
|
|
||||||
@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/";
|
"/home/tosmers/Svn/libreccm/ccm_ng/ccm-docrepo/src/test/resources/datasets/org/libreccm/docrepo/FilePortationTest/";
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUpClass() {
|
public static void setUpClass() {
|
||||||
|
|
@ -82,12 +82,6 @@ public class FilePortationTest {
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void createResource() {
|
public static void createResource() {
|
||||||
file = new File();
|
|
||||||
file.setName("testname");
|
|
||||||
file.setDescription("this is a text description");
|
|
||||||
file.setPath("test/path");
|
|
||||||
file.setCreationDate(new Date());
|
|
||||||
file.setLastModifiedDate(new Date());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
|
|
@ -96,6 +90,13 @@ public class FilePortationTest {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
|
file = new File();
|
||||||
|
file.setName("testname");
|
||||||
|
file.setDescription("this is a text description");
|
||||||
|
file.setPath("test/path");
|
||||||
|
file.setCreationDate(new Date());
|
||||||
|
file.setLastModifiedDate(new Date());
|
||||||
|
fileRepository.save(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
|
|
@ -107,61 +108,41 @@ public class FilePortationTest {
|
||||||
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().asFile();
|
||||||
final java.io.File[] libs = dependencies.resolve().withTransitivity()
|
|
||||||
.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", lib.getName());
|
||||||
lib.getName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final PomEquippedResolveStage corePom = Maven.resolver()
|
final PomEquippedResolveStage corePom = Maven.resolver().loadPomFromFile("../ccm-core/pom.xml");
|
||||||
.loadPomFromFile("../ccm-core/pom.xml");
|
final PomEquippedResolveStage coreDependencies = corePom.importCompileAndRuntimeDependencies();
|
||||||
final PomEquippedResolveStage coreDependencies = corePom
|
final java.io.File[] coreLibs = coreDependencies.resolve().withTransitivity().asFile();
|
||||||
.importCompileAndRuntimeDependencies();
|
|
||||||
final java.io.File[] coreLibs = coreDependencies.resolve().
|
|
||||||
withTransitivity().asFile();
|
|
||||||
for (java.io.File lib : coreLibs) {
|
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.getPackage())
|
||||||
org.libreccm.auditing.AbstractAuditedEntityRepository.class.
|
.addPackage(org.libreccm.categorization.Categorization.class.getPackage())
|
||||||
getPackage())
|
.addPackage(org.libreccm.configuration.ConfigurationManager.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.core.CcmObject.class.getPackage())
|
||||||
.addPackage(org.libreccm.docrepo.FileMarshaller.class.
|
.addPackage(org.libreccm.docrepo.FileMarshaller.class.getPackage())
|
||||||
getPackage())
|
.addPackage(org.libreccm.jpa.EntityManagerProducer.class.getPackage())
|
||||||
.addPackage(org.libreccm.jpa.EntityManagerProducer.class
|
.addPackage(org.libreccm.jpa.utils.MimeTypeConverter.class.getPackage())
|
||||||
.getPackage())
|
.addPackage(org.libreccm.l10n.LocalizedString.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.portal.Portlet.class.getPackage())
|
||||||
.addPackage(org.libreccm.portation.AbstractMarshaller.class
|
.addPackage(org.libreccm.portation.AbstractMarshaller.class.getPackage())
|
||||||
.getPackage())
|
|
||||||
.addPackage(org.libreccm.security.Permission.class.getPackage())
|
.addPackage(org.libreccm.security.Permission.class.getPackage())
|
||||||
.addPackage(org.libreccm.web.CcmApplication.class.getPackage())
|
.addPackage(org.libreccm.web.CcmApplication.class.getPackage())
|
||||||
.addPackage(org.libreccm.workflow.Workflow.class.getPackage())
|
.addPackage(org.libreccm.workflow.Workflow.class.getPackage())
|
||||||
.addPackage(org.libreccm.testutils.EqualsVerifier.class.
|
.addPackage(org.libreccm.testutils.EqualsVerifier.class.getPackage())
|
||||||
getPackage())
|
.addPackage(org.libreccm.tests.categories.IntegrationTest.class.getPackage())
|
||||||
.addPackage(org.libreccm.tests.categories.IntegrationTest.class
|
|
||||||
.getPackage())
|
|
||||||
.addAsLibraries(libs)
|
.addAsLibraries(libs)
|
||||||
.addAsLibraries(coreLibs)
|
.addAsLibraries(coreLibs)
|
||||||
.addAsResource("test-persistence.xml",
|
.addAsResource("test-persistence.xml", "META-INF/persistence.xml")
|
||||||
"META-INF/persistence.xml")
|
|
||||||
.addAsWebInfResource("test-web.xml", "WEB-INF/web.xml")
|
.addAsWebInfResource("test-web.xml", "WEB-INF/web.xml")
|
||||||
.addAsWebInfResource(EmptyAsset.INSTANCE, "WEB-INF/beans.xml");
|
.addAsWebInfResource(EmptyAsset.INSTANCE, "WEB-INF/beans.xml");
|
||||||
}
|
}
|
||||||
|
|
@ -169,22 +150,39 @@ public class FilePortationTest {
|
||||||
@Test
|
@Test
|
||||||
@InSequence(10)
|
@InSequence(10)
|
||||||
public void fileMarshallerIsInjected() {
|
public void fileMarshallerIsInjected() {
|
||||||
assertThat(fileMarshaller, is(not(nullValue())));
|
//assertThat(fileMarshaller, is(not(nullValue())));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@InSequence(20)
|
||||||
|
public void fileRepositoryIsInjected() {
|
||||||
|
// assertThat(fileRepository, is(not(nullValue())));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@InSequence(100)
|
@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);
|
||||||
|
//
|
||||||
fileMarshaller.exportList(fileList);
|
// fileMarshaller.exportList(fileList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@InSequence(200)
|
@InSequence(200)
|
||||||
public void docrepoFileShouldBeCreated() {
|
public void aFileShouldBeCreated() {
|
||||||
// TODO: test file import
|
// java.io.File file = new java.io.File(filePath + "test.txt");
|
||||||
|
// FileWriter fileWriter = null;
|
||||||
|
// try {
|
||||||
|
// fileWriter = new FileWriter(file);
|
||||||
|
// System.out.print("\n\n\n\n\n\n\n\n\n\n Fehler \n\n\n\n\n\n\n\n\n\n");
|
||||||
|
// fileWriter.write("bloß ein test! - tosmers");
|
||||||
|
// fileWriter.flush();
|
||||||
|
// fileWriter.close();
|
||||||
|
// } catch (IOException e) {
|
||||||
|
// System.out.print("\n\n\n\n\n\n\n\n\n\n Fehler \n\n\n\n\n\n\n\n\n\n");
|
||||||
|
// }
|
||||||
|
// assertTrue(file.exists());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue