[FEATURE]
- adds testclass for core import - adds testdata for core import git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4462 8810af33-2d31-482b-a856-94f89814c4dfpull/2/head
parent
3863a2f32f
commit
4a922246bc
|
|
@ -83,6 +83,25 @@ public abstract class AbstractMarshaller<P extends Portable> {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as {@code prepare}-methode above. Adds distinction between path
|
||||
* and filename.
|
||||
*
|
||||
* @param format The format of the ex-/import
|
||||
* @param folderPath The folderPath of the file exported to or imported
|
||||
* from
|
||||
* @param filename The filename of the file exported to or imported from
|
||||
* @param indentation whether or not indentation
|
||||
*/
|
||||
public void prepare(final Format format,
|
||||
String folderPath, String filename,
|
||||
boolean indentation) {
|
||||
File file = new File(folderPath);
|
||||
if (file.exists() || file.mkdirs()) {
|
||||
prepare(format, folderPath + "/" + filename, indentation);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Export routine for lists with the same object type {@code P}. Creates a
|
||||
|
|
|
|||
|
|
@ -47,8 +47,8 @@ public class Marshaller {
|
|||
@Any
|
||||
private Instance<AbstractMarshaller<? extends Portable>> marshallerInstances;
|
||||
|
||||
// Assigns lists with objects of the same type as values to their typ.
|
||||
// The type represents the key
|
||||
// Maps lists with objects of the same type to their typ.
|
||||
// The type represents the key, the lists the values
|
||||
private Map<Class<? extends Portable>, List<Portable>> classListMap;
|
||||
|
||||
/**
|
||||
|
|
@ -153,7 +153,7 @@ public class Marshaller {
|
|||
* @param format The import style
|
||||
* @param <P> The type of the current marshaller
|
||||
*/
|
||||
public <P extends Portable> void importObjects(
|
||||
public <P extends Portable> void importFiles(
|
||||
List<String> filenames, Format format) {
|
||||
for (String filename : filenames) {
|
||||
String[] splitFilename = filename.split("__");
|
||||
|
|
|
|||
|
|
@ -0,0 +1,184 @@
|
|||
/*
|
||||
* Copyright (C) 2015 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.portation;
|
||||
|
||||
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.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.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.tests.categories.IntegrationTest;
|
||||
|
||||
import static org.libreccm.testutils.DependenciesHelpers.getModuleDependencies;
|
||||
|
||||
|
||||
/**
|
||||
* Test class. Tests the import capabilities of the core module
|
||||
* {@code Portation} with data from the trunk implementations
|
||||
*
|
||||
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
|
||||
* @version created on 12/1/16
|
||||
*/
|
||||
@org.junit.experimental.categories.Category(IntegrationTest.class)
|
||||
@RunWith(Arquillian.class)
|
||||
@PersistenceTest
|
||||
@Transactional(TransactionMode.COMMIT)
|
||||
@CreateSchema({"create_ccm_core_schema.sql"})
|
||||
public class CoreDataImportTest {
|
||||
|
||||
public CoreDataImportTest() {
|
||||
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpClass() {
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void createResource() {
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDownClass() {
|
||||
}
|
||||
|
||||
@Deployment
|
||||
public static WebArchive createDeployment() {
|
||||
return ShrinkWrap
|
||||
.create(WebArchive.class,
|
||||
"LibreCCM-org.libreccm.portation." +
|
||||
"CoreDataImportTest.war")
|
||||
.addPackage(org.libreccm.categorization.Category
|
||||
.class.getPackage())
|
||||
.addPackage(org.libreccm.core.CcmObject.class.getPackage())
|
||||
.addPackage(org.libreccm.l10n.LocalizedString
|
||||
.class.getPackage())
|
||||
.addPackage(org.libreccm.portation.AbstractMarshaller
|
||||
.class.getPackage())
|
||||
.addPackage(org.libreccm.security.Group.class.getPackage())
|
||||
.addPackage(org.libreccm.workflow.AssignableTask
|
||||
.class.getPackage())
|
||||
.addPackage(org.libreccm.configuration.ConfigurationManager
|
||||
.class.getPackage())
|
||||
.addPackage(org.libreccm.tests.categories.IntegrationTest
|
||||
.class.getPackage())
|
||||
.addPackage(org.libreccm.testutils.EqualsVerifier
|
||||
.class.getPackage())
|
||||
.addAsLibraries(getModuleDependencies())
|
||||
.addAsResource("test-persistence.xml",
|
||||
"META-INF/persistence.xml")
|
||||
.addAsWebInfResource("test-web.xml", "WEB-INF/web.xml")
|
||||
.addAsWebInfResource(EmptyAsset.INSTANCE, "WEB-INF/beans.xml");
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
}
|
||||
|
||||
// TEST SECTION
|
||||
|
||||
@Test
|
||||
@InSequence(105)
|
||||
public void categoriesShouldBeImported() {
|
||||
ImportHelper.importCategories();
|
||||
}
|
||||
//
|
||||
// @Test
|
||||
// @InSequence(110)
|
||||
// public void categorizationsShouldBeImported() {
|
||||
// ImportHelper.importCategorizations();
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// @InSequence(115)
|
||||
// public void usersShouldBeImported() {
|
||||
// ImportHelper.importUsers();
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// @InSequence(120)
|
||||
// public void groupsShouldBeImported() {
|
||||
// ImportHelper.importGroups();
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// @InSequence(125)
|
||||
// public void groupMembershipsShouldBeImported() {
|
||||
// ImportHelper.importGroupMemberships();
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// @InSequence(130)
|
||||
// public void rolesShouldBeImported() {
|
||||
// ImportHelper.importRoles();
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// @InSequence(135)
|
||||
// public void roleMembershipsShouldBeImported() {
|
||||
// ImportHelper.importRoleMemberships();
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// @InSequence(140)
|
||||
// public void workflowTemplatesShouldBeImported() {
|
||||
// ImportHelper.importWorkflowTemplates();
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// @InSequence(145)
|
||||
// public void workflowsShouldBeImported() {
|
||||
// ImportHelper.importWorkflows();
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// @InSequence(150)
|
||||
// public void assignableTasksShouldBeImported() {
|
||||
// ImportHelper.importAssignableTasks();
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// @InSequence(155)
|
||||
// public void taskAssignmentsShouldBeImported() {
|
||||
// ImportHelper.importTaskAssignments();
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// @InSequence(160)
|
||||
// public void permissionsShouldBeImported() {
|
||||
// ImportHelper.importPermissions();
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,145 @@
|
|||
/*
|
||||
* Copyright (C) 2015 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.portation;
|
||||
|
||||
import org.libreccm.categorization.CategorizationMarshaller;
|
||||
import org.libreccm.categorization.Category;
|
||||
import org.libreccm.categorization.CategoryMarshaller;
|
||||
import org.libreccm.security.GroupMarshaller;
|
||||
import org.libreccm.security.GroupMembershipMarshaller;
|
||||
import org.libreccm.security.PermissionMarshaller;
|
||||
import org.libreccm.security.RoleMarshaller;
|
||||
import org.libreccm.security.RoleMembershipMarshaller;
|
||||
import org.libreccm.security.UserMarshaller;
|
||||
import org.libreccm.workflow.AssignableTaskMarshaller;
|
||||
import org.libreccm.workflow.TaskAssignmentMarshaller;
|
||||
import org.libreccm.workflow.WorkflowMarshaller;
|
||||
import org.libreccm.workflow.WorkflowTemplateMarshaller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Helper to implement the specifics for the importations. Makes source code
|
||||
* in the actual test class is shorter and more readable.
|
||||
*
|
||||
* @author <a href="mailto:tosmers@uni-bremen.de>Tobias Osmers</a>
|
||||
* @version created on 12/1/16
|
||||
*/
|
||||
class ImportHelper {
|
||||
private static String pathName =
|
||||
"/home/tosmers/Svn/libreccm/ccm-ng/ccm-core/src/test/resource" +
|
||||
"/portation/trunk-iaw-export";
|
||||
private static boolean indentation = false;
|
||||
|
||||
private static String blub = "Hallo";
|
||||
|
||||
static void importCategories() {
|
||||
CategoryMarshaller categoryMarshaller = new
|
||||
CategoryMarshaller();
|
||||
categoryMarshaller.prepare(Format.XML, pathName,
|
||||
"categories", indentation);
|
||||
List<Category> categories = categoryMarshaller.importFile();
|
||||
}
|
||||
|
||||
static void importCategorizations() {
|
||||
CategorizationMarshaller categorizationMarshaller = new
|
||||
CategorizationMarshaller();
|
||||
categorizationMarshaller.prepare(Format.XML, pathName,
|
||||
"categorizations", indentation);
|
||||
categorizationMarshaller.importFile();
|
||||
}
|
||||
|
||||
static void importUsers() {
|
||||
UserMarshaller userMarshaller = new UserMarshaller();
|
||||
userMarshaller.prepare(Format.XML, pathName,
|
||||
"users", indentation);
|
||||
userMarshaller.importFile();
|
||||
}
|
||||
|
||||
static void importGroups() {
|
||||
GroupMarshaller groupMarshaller = new GroupMarshaller();
|
||||
groupMarshaller.prepare(Format.XML, pathName,
|
||||
"groups", indentation);
|
||||
groupMarshaller.importFile();
|
||||
}
|
||||
|
||||
static void importGroupMemberships() {
|
||||
GroupMembershipMarshaller groupMembershipMarshaller = new
|
||||
GroupMembershipMarshaller();
|
||||
groupMembershipMarshaller.prepare(Format.XML, pathName,
|
||||
"groupMemberships", indentation);
|
||||
groupMembershipMarshaller.importFile();
|
||||
}
|
||||
|
||||
static void importRoles() {
|
||||
RoleMarshaller roleMarshaller = new RoleMarshaller();
|
||||
roleMarshaller.prepare(Format.XML, pathName,
|
||||
"roles", indentation);
|
||||
roleMarshaller.importFile();
|
||||
}
|
||||
|
||||
static void importRoleMemberships() {
|
||||
RoleMembershipMarshaller roleMembershipMarshaller = new
|
||||
RoleMembershipMarshaller();
|
||||
roleMembershipMarshaller.prepare(Format.XML, pathName,
|
||||
"roleMemberships", indentation);
|
||||
roleMembershipMarshaller.importFile();
|
||||
}
|
||||
|
||||
static void importWorkflowTemplates() {
|
||||
WorkflowTemplateMarshaller workflowTemplateMarshaller = new
|
||||
WorkflowTemplateMarshaller();
|
||||
workflowTemplateMarshaller.prepare(Format.XML, pathName,
|
||||
"workflowTemplates", indentation);
|
||||
workflowTemplateMarshaller.importFile();
|
||||
}
|
||||
|
||||
static void importWorkflows() {
|
||||
WorkflowMarshaller workflowMarshaller = new
|
||||
WorkflowMarshaller();
|
||||
workflowMarshaller.prepare(Format.XML, pathName,
|
||||
"workflows", indentation);
|
||||
workflowMarshaller.importFile();
|
||||
}
|
||||
|
||||
static void importAssignableTasks() {
|
||||
AssignableTaskMarshaller assignableTaskMarshaller = new
|
||||
AssignableTaskMarshaller();
|
||||
assignableTaskMarshaller.prepare(Format.XML, pathName,
|
||||
"assignableTasks", indentation);
|
||||
assignableTaskMarshaller.importFile();
|
||||
}
|
||||
|
||||
static void importTaskAssignments() {
|
||||
TaskAssignmentMarshaller taskAssignmentMarshaller = new
|
||||
TaskAssignmentMarshaller();
|
||||
taskAssignmentMarshaller.prepare(Format.XML, pathName,
|
||||
"taskAssignments", indentation);
|
||||
taskAssignmentMarshaller.importFile();
|
||||
}
|
||||
|
||||
static void importPermissions() {
|
||||
PermissionMarshaller permissionMarshaller = new
|
||||
PermissionMarshaller();
|
||||
permissionMarshaller.prepare(Format.XML, pathName,
|
||||
"permissions", indentation);
|
||||
permissionMarshaller.importFile();
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,8 @@
|
|||
<GroupMembership><membershipId>1</membershipId><marshaller/></GroupMembership>
|
||||
<GroupMembership><membershipId>2</membershipId><marshaller/></GroupMembership>
|
||||
<GroupMembership><membershipId>3</membershipId><marshaller/></GroupMembership>
|
||||
<GroupMembership><membershipId>4</membershipId><marshaller/></GroupMembership>
|
||||
<GroupMembership><membershipId>5</membershipId><marshaller/></GroupMembership>
|
||||
<GroupMembership><membershipId>6</membershipId><marshaller/></GroupMembership>
|
||||
<GroupMembership><membershipId>7</membershipId><marshaller/></GroupMembership>
|
||||
<GroupMembership><membershipId>8</membershipId><marshaller/></GroupMembership>
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
<Group><partyId>541003</partyId><name>projects Administration</name><memberships><membershipId>8</membershipId><marshaller/></memberships><marshaller/></Group>
|
||||
<Group><partyId>1061</partyId><name>content Administration</name><memberships><membershipId>6</membershipId><marshaller/></memberships><marshaller/></Group>
|
||||
<Group><partyId>541006</partyId><name>projects Viewers</name><marshaller/></Group>
|
||||
<Group><partyId>1064</partyId><name>content Viewers</name><marshaller/></Group>
|
||||
<Group><partyId>1339004</partyId><name>homepages Viewers</name><marshaller/></Group>
|
||||
<Group><partyId>3439036</partyId><name>publications Viewers</name><marshaller/></Group>
|
||||
<Group><partyId>5619069</partyId><name>euss Administration</name><marshaller/></Group>
|
||||
<Group><partyId>-300</partyId><name>Site-wide Administrators</name><roleMemberships><membershipId>112</membershipId><marshaller/></roleMemberships><roleMemberships><membershipId>109</membershipId><marshaller/></roleMemberships><roleMemberships><membershipId>130</membershipId><marshaller/></roleMemberships><roleMemberships><membershipId>140</membershipId><marshaller/></roleMemberships><roleMemberships><membershipId>136</membershipId><marshaller/></roleMemberships><roleMemberships><membershipId>152</membershipId><marshaller/></roleMemberships><roleMemberships><membershipId>153</membershipId><marshaller/></roleMemberships><roleMemberships><membershipId>158</membershipId><marshaller/></roleMemberships><roleMemberships><membershipId>116</membershipId><marshaller/></roleMemberships><roleMemberships><membershipId>157</membershipId><marshaller/></roleMemberships><roleMemberships><membershipId>154</membershipId><marshaller/></roleMemberships><roleMemberships><membershipId>123</membershipId><marshaller/></roleMemberships><memberships><membershipId>4</membershipId><marshaller/></memberships><memberships><membershipId>1</membershipId><marshaller/></memberships><memberships><membershipId>5</membershipId><marshaller/></memberships><memberships><membershipId>2</membershipId><marshaller/></memberships><memberships><membershipId>3</membershipId><marshaller/></memberships><marshaller/></Group>
|
||||
<Group><partyId>5619070</partyId><name>euss Viewers</name><marshaller/></Group>
|
||||
<Group><partyId>1339003</partyId><name>homepages Administration</name><marshaller/></Group>
|
||||
<Group><partyId>3439035</partyId><name>publications Administration</name><marshaller/></Group>
|
||||
<Group><partyId>1937037</partyId><name>research Viewers</name><marshaller/></Group>
|
||||
<Group><partyId>1937036</partyId><name>research Administration</name><marshaller/></Group>
|
||||
<Group><partyId>1271</partyId><name>Portal Workspace Groups</name><marshaller/></Group>
|
||||
<Group><partyId>1274</partyId><name>Portal Homepage</name><marshaller/></Group>
|
||||
<Group><partyId>1278</partyId><name>Portal Homepage</name><memberships><membershipId>7</membershipId><marshaller/></memberships><marshaller/></Group>
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -29,8 +29,6 @@ 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;
|
||||
|
|
@ -55,11 +53,10 @@ import java.util.List;
|
|||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.libreccm.testutils.DependenciesHelpers.*;
|
||||
import static org.libreccm.testutils.DependenciesHelpers.getCcmCoreDependencies;
|
||||
import static org.libreccm.testutils.DependenciesHelpers.getModuleDependencies;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
* @author <a href="mailto:tosmers@uni-bremen.de">Tobias Osmers</a>
|
||||
* @version 13/01/2016
|
||||
|
|
|
|||
Loading…
Reference in New Issue