use of org.kie.internal.runtime.conf.DeploymentDescriptor in project jbpm by kiegroup.
the class DeploymentDescriptorMergerTest method testDeploymentDesciptorMergeOverrideEmpty.
@Test
public void testDeploymentDesciptorMergeOverrideEmpty() {
DeploymentDescriptor master = new DeploymentDescriptorImpl("org.jbpm.domain");
master.getBuilder().addMarshalingStrategy(new ObjectModel("org.jbpm.test.CustomStrategy", new Object[] { "param2" })).setLimitSerializationClasses(true);
assertNotNull(master);
assertEquals("org.jbpm.domain", master.getPersistenceUnit());
assertEquals("org.jbpm.domain", master.getAuditPersistenceUnit());
assertEquals(AuditMode.JPA, master.getAuditMode());
assertEquals(PersistenceMode.JPA, master.getPersistenceMode());
assertEquals(RuntimeStrategy.SINGLETON, master.getRuntimeStrategy());
assertEquals(1, master.getMarshallingStrategies().size());
assertEquals(0, master.getConfiguration().size());
assertEquals(0, master.getEnvironmentEntries().size());
assertEquals(0, master.getEventListeners().size());
assertEquals(0, master.getGlobals().size());
assertEquals(0, master.getTaskEventListeners().size());
assertEquals(0, master.getWorkItemHandlers().size());
assertTrue(master.getLimitSerializationClasses());
DeploymentDescriptor slave = new DeploymentDescriptorImpl("org.jbpm.domain");
slave.getBuilder().auditMode(AuditMode.JMS).persistenceMode(PersistenceMode.JPA).persistenceUnit(null).auditPersistenceUnit("");
assertNotNull(slave);
assertEquals(null, slave.getPersistenceUnit());
assertEquals("", slave.getAuditPersistenceUnit());
assertEquals(AuditMode.JMS, slave.getAuditMode());
assertEquals(PersistenceMode.JPA, slave.getPersistenceMode());
assertEquals(RuntimeStrategy.SINGLETON, slave.getRuntimeStrategy());
assertEquals(0, slave.getMarshallingStrategies().size());
assertEquals(0, slave.getConfiguration().size());
assertEquals(0, slave.getEnvironmentEntries().size());
assertEquals(0, slave.getEventListeners().size());
assertEquals(0, slave.getGlobals().size());
assertEquals(0, slave.getTaskEventListeners().size());
assertEquals(0, slave.getWorkItemHandlers().size());
((DeploymentDescriptorImpl) slave).setLimitSerializationClasses(null);
assertNull(slave.getLimitSerializationClasses());
// and now let's merge them
DeploymentDescriptorMerger merger = new DeploymentDescriptorMerger();
DeploymentDescriptor outcome = merger.merge(master, slave, MergeMode.OVERRIDE_EMPTY);
assertNotNull(outcome);
assertEquals("org.jbpm.domain", outcome.getPersistenceUnit());
assertEquals("org.jbpm.domain", outcome.getAuditPersistenceUnit());
assertEquals(AuditMode.JMS, outcome.getAuditMode());
assertEquals(PersistenceMode.JPA, outcome.getPersistenceMode());
assertEquals(RuntimeStrategy.SINGLETON, outcome.getRuntimeStrategy());
assertEquals(1, outcome.getMarshallingStrategies().size());
assertEquals(0, outcome.getConfiguration().size());
assertEquals(0, outcome.getEnvironmentEntries().size());
assertEquals(0, outcome.getEventListeners().size());
assertEquals(0, outcome.getGlobals().size());
assertEquals(0, outcome.getTaskEventListeners().size());
assertEquals(0, outcome.getWorkItemHandlers().size());
assertTrue(outcome.getLimitSerializationClasses());
}
use of org.kie.internal.runtime.conf.DeploymentDescriptor in project jbpm by kiegroup.
the class DeploymentDescriptorMergerTest method testDeploymentDesciptorMergeHierarchy.
@Test
public void testDeploymentDesciptorMergeHierarchy() {
DeploymentDescriptor master = new DeploymentDescriptorImpl("org.jbpm.domain");
master.getBuilder().addMarshalingStrategy(new ObjectModel("org.jbpm.test.CustomStrategy", new Object[] { "param2" }));
assertNotNull(master);
assertEquals("org.jbpm.domain", master.getPersistenceUnit());
assertEquals("org.jbpm.domain", master.getAuditPersistenceUnit());
assertEquals(AuditMode.JPA, master.getAuditMode());
assertEquals(PersistenceMode.JPA, master.getPersistenceMode());
assertEquals(RuntimeStrategy.SINGLETON, master.getRuntimeStrategy());
assertEquals(1, master.getMarshallingStrategies().size());
assertEquals(0, master.getConfiguration().size());
assertEquals(0, master.getEnvironmentEntries().size());
assertEquals(0, master.getEventListeners().size());
assertEquals(0, master.getGlobals().size());
assertEquals(0, master.getTaskEventListeners().size());
assertEquals(0, master.getWorkItemHandlers().size());
DeploymentDescriptor slave = new DeploymentDescriptorImpl("org.jbpm.domain");
slave.getBuilder().auditMode(AuditMode.NONE).persistenceMode(PersistenceMode.JPA).persistenceUnit("my.custom.unit").auditPersistenceUnit("my.custom.unit2");
assertNotNull(slave);
assertEquals("my.custom.unit", slave.getPersistenceUnit());
assertEquals("my.custom.unit2", slave.getAuditPersistenceUnit());
assertEquals(AuditMode.NONE, slave.getAuditMode());
assertEquals(PersistenceMode.JPA, slave.getPersistenceMode());
assertEquals(RuntimeStrategy.SINGLETON, slave.getRuntimeStrategy());
assertEquals(0, slave.getMarshallingStrategies().size());
assertEquals(0, slave.getConfiguration().size());
assertEquals(0, slave.getEnvironmentEntries().size());
assertEquals(0, slave.getEventListeners().size());
assertEquals(0, slave.getGlobals().size());
assertEquals(0, slave.getTaskEventListeners().size());
assertEquals(0, slave.getWorkItemHandlers().size());
DeploymentDescriptor slave2 = new DeploymentDescriptorImpl("org.jbpm.domain");
slave2.getBuilder().auditMode(AuditMode.JMS).persistenceMode(PersistenceMode.JPA).persistenceUnit("my.custom.unit2").auditPersistenceUnit("my.custom.altered").runtimeStrategy(RuntimeStrategy.PER_PROCESS_INSTANCE).addEnvironmentEntry(new NamedObjectModel("IS_JTA", "java.lang.Boolean", new Object[] { "false" }));
assertNotNull(slave2);
assertEquals("my.custom.unit2", slave2.getPersistenceUnit());
assertEquals("my.custom.altered", slave2.getAuditPersistenceUnit());
assertEquals(AuditMode.JMS, slave2.getAuditMode());
assertEquals(PersistenceMode.JPA, slave2.getPersistenceMode());
assertEquals(RuntimeStrategy.PER_PROCESS_INSTANCE, slave2.getRuntimeStrategy());
assertEquals(0, slave2.getMarshallingStrategies().size());
assertEquals(0, slave2.getConfiguration().size());
assertEquals(1, slave2.getEnvironmentEntries().size());
assertEquals(0, slave2.getEventListeners().size());
assertEquals(0, slave2.getGlobals().size());
assertEquals(0, slave2.getTaskEventListeners().size());
assertEquals(0, slave2.getWorkItemHandlers().size());
// assemble hierarchy
List<DeploymentDescriptor> hierarchy = new ArrayList<DeploymentDescriptor>();
hierarchy.add(slave2);
hierarchy.add(slave);
hierarchy.add(master);
// and now let's merge them
DeploymentDescriptorMerger merger = new DeploymentDescriptorMerger();
DeploymentDescriptor outcome = merger.merge(hierarchy, MergeMode.MERGE_COLLECTIONS);
assertNotNull(outcome);
assertEquals("my.custom.unit2", outcome.getPersistenceUnit());
assertEquals("my.custom.altered", outcome.getAuditPersistenceUnit());
assertEquals(AuditMode.JMS, outcome.getAuditMode());
assertEquals(PersistenceMode.JPA, outcome.getPersistenceMode());
assertEquals(RuntimeStrategy.PER_PROCESS_INSTANCE, outcome.getRuntimeStrategy());
assertEquals(1, outcome.getMarshallingStrategies().size());
assertEquals(0, outcome.getConfiguration().size());
assertEquals(1, outcome.getEnvironmentEntries().size());
assertEquals(0, outcome.getEventListeners().size());
assertEquals(0, outcome.getGlobals().size());
assertEquals(0, outcome.getTaskEventListeners().size());
assertEquals(0, outcome.getWorkItemHandlers().size());
}
use of org.kie.internal.runtime.conf.DeploymentDescriptor in project jbpm by kiegroup.
the class DeploymentDescriptorMergerTest method testDeploymentDesciptorMergeMergeCollectionsAvoidDuplicates.
@Test
public void testDeploymentDesciptorMergeMergeCollectionsAvoidDuplicates() {
DeploymentDescriptor master = new DeploymentDescriptorImpl("org.jbpm.domain");
master.getBuilder().addMarshalingStrategy(new ObjectModel("org.jbpm.test.CustomStrategy", new Object[] { "param2" }));
assertNotNull(master);
assertEquals("org.jbpm.domain", master.getPersistenceUnit());
assertEquals("org.jbpm.domain", master.getAuditPersistenceUnit());
assertEquals(AuditMode.JPA, master.getAuditMode());
assertEquals(PersistenceMode.JPA, master.getPersistenceMode());
assertEquals(RuntimeStrategy.SINGLETON, master.getRuntimeStrategy());
assertEquals(1, master.getMarshallingStrategies().size());
assertEquals(0, master.getConfiguration().size());
assertEquals(0, master.getEnvironmentEntries().size());
assertEquals(0, master.getEventListeners().size());
assertEquals(0, master.getGlobals().size());
assertEquals(0, master.getTaskEventListeners().size());
assertEquals(0, master.getWorkItemHandlers().size());
DeploymentDescriptor slave = new DeploymentDescriptorImpl("org.jbpm.domain");
slave.getBuilder().auditMode(AuditMode.JMS).persistenceMode(PersistenceMode.JPA).persistenceUnit(null).auditPersistenceUnit("").addMarshalingStrategy(new ObjectModel("org.jbpm.test.CustomStrategy", new Object[] { "param2" }));
assertNotNull(slave);
assertEquals(null, slave.getPersistenceUnit());
assertEquals("", slave.getAuditPersistenceUnit());
assertEquals(AuditMode.JMS, slave.getAuditMode());
assertEquals(PersistenceMode.JPA, slave.getPersistenceMode());
assertEquals(RuntimeStrategy.SINGLETON, slave.getRuntimeStrategy());
assertEquals(1, slave.getMarshallingStrategies().size());
assertEquals(0, slave.getConfiguration().size());
assertEquals(0, slave.getEnvironmentEntries().size());
assertEquals(0, slave.getEventListeners().size());
assertEquals(0, slave.getGlobals().size());
assertEquals(0, slave.getTaskEventListeners().size());
assertEquals(0, slave.getWorkItemHandlers().size());
// and now let's merge them
DeploymentDescriptorMerger merger = new DeploymentDescriptorMerger();
DeploymentDescriptor outcome = merger.merge(master, slave, MergeMode.MERGE_COLLECTIONS);
assertNotNull(outcome);
assertEquals("org.jbpm.domain", outcome.getPersistenceUnit());
assertEquals("org.jbpm.domain", outcome.getAuditPersistenceUnit());
assertEquals(AuditMode.JMS, outcome.getAuditMode());
assertEquals(PersistenceMode.JPA, outcome.getPersistenceMode());
assertEquals(RuntimeStrategy.SINGLETON, outcome.getRuntimeStrategy());
assertEquals(1, outcome.getMarshallingStrategies().size());
assertEquals(0, outcome.getConfiguration().size());
assertEquals(0, outcome.getEnvironmentEntries().size());
assertEquals(0, outcome.getEventListeners().size());
assertEquals(0, outcome.getGlobals().size());
assertEquals(0, outcome.getTaskEventListeners().size());
assertEquals(0, outcome.getWorkItemHandlers().size());
}
use of org.kie.internal.runtime.conf.DeploymentDescriptor in project jbpm by kiegroup.
the class DeploymentDescriptorTest method testWriteDeploymentDescriptorXmlWithTransientElements.
@Test
public void testWriteDeploymentDescriptorXmlWithTransientElements() {
DeploymentDescriptor descriptor = new DeploymentDescriptorImpl("org.jbpm.domain");
descriptor.getBuilder().addMarshalingStrategy(new TransientObjectModel("org.jbpm.testCustomStrategy", new Object[] { new ObjectModel("java.lang.String", new Object[] { "param1" }), "param2" })).addWorkItemHandler(new TransientNamedObjectModel("mvel", "Log", "new org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler()")).addRequiredRole("experts");
String deploymentDescriptorXml = descriptor.toXml();
assertNotNull(deploymentDescriptorXml);
logger.info(deploymentDescriptorXml);
ByteArrayInputStream stream = new ByteArrayInputStream(deploymentDescriptorXml.getBytes());
DeploymentDescriptor fromXml = DeploymentDescriptorIO.fromXml(stream);
assertNotNull(fromXml);
assertEquals("org.jbpm.domain", fromXml.getPersistenceUnit());
assertEquals("org.jbpm.domain", fromXml.getAuditPersistenceUnit());
assertEquals(AuditMode.JPA, fromXml.getAuditMode());
assertEquals(PersistenceMode.JPA, fromXml.getPersistenceMode());
assertEquals(RuntimeStrategy.SINGLETON, fromXml.getRuntimeStrategy());
assertEquals(0, fromXml.getMarshallingStrategies().size());
assertEquals(0, fromXml.getConfiguration().size());
assertEquals(0, fromXml.getEnvironmentEntries().size());
assertEquals(0, fromXml.getEventListeners().size());
assertEquals(0, fromXml.getGlobals().size());
assertEquals(0, fromXml.getTaskEventListeners().size());
assertEquals(0, fromXml.getWorkItemHandlers().size());
assertEquals(1, fromXml.getRequiredRoles().size());
}
use of org.kie.internal.runtime.conf.DeploymentDescriptor in project jbpm by kiegroup.
the class DeploymentDescriptorTest method testReadPartialDeploymentDescriptorFromXml.
@Test
public void testReadPartialDeploymentDescriptorFromXml() throws Exception {
InputStream input = this.getClass().getResourceAsStream("/deployment/partial-deployment-descriptor.xml");
DeploymentDescriptor descriptor = DeploymentDescriptorIO.fromXml(input);
assertNotNull(descriptor);
assertEquals("org.jbpm.domain", descriptor.getPersistenceUnit());
assertEquals("org.jbpm.domain", descriptor.getAuditPersistenceUnit());
assertEquals(AuditMode.JPA, descriptor.getAuditMode());
assertEquals(PersistenceMode.JPA, descriptor.getPersistenceMode());
assertEquals(RuntimeStrategy.PER_PROCESS_INSTANCE, descriptor.getRuntimeStrategy());
assertEquals(0, descriptor.getMarshallingStrategies().size());
assertEquals(0, descriptor.getConfiguration().size());
assertEquals(0, descriptor.getEnvironmentEntries().size());
assertEquals(0, descriptor.getEventListeners().size());
assertEquals(0, descriptor.getGlobals().size());
assertEquals(0, descriptor.getTaskEventListeners().size());
assertEquals(0, descriptor.getWorkItemHandlers().size());
assertEquals(0, descriptor.getRequiredRoles().size());
}
Aggregations