public void testLockUnlock() throws UnsupportedEncodingException, MalformedIdentifierException, ActivityConfigurationException, EditException, InterruptedException { testLock(); System.out.println("Unlock (should produce both tokens) :"); Thread.sleep(200); WorkflowDataToken token2 = new WorkflowDataToken("outerProcess1", new int[0], Literal.buildLiteral("Another string"),context); p1.getInputPorts().get(0).receiveEvent(token2); assertTrue(deh2.getEventCount() == 1); }
@Test public synchronized void singleDataTokenBehaviour() throws MalformedIdentifierException, EditException, JDOMException, IOException, ActivityConfigurationException, InterruptedException { // System.out.println("Single token, 'A string'"); // Build an input data token WorkflowDataToken token = new WorkflowDataToken("outerProcess1", new int[0], Literal.buildLiteral("A string"), context); processor.getInputPorts().get(0).receiveEvent(token); Thread.sleep(250); assertEquals(1, deh.getEventCount()); }
public void testLockUnlockWithDifferentProcess() throws UnsupportedEncodingException, MalformedIdentifierException, ActivityConfigurationException, EditException, InterruptedException { testLock(); System.out.println("Unlock with diffent process, only output from p1 :"); Thread.sleep(200); WorkflowDataToken token2 = new WorkflowDataToken("outerProcess2", new int[0], Literal.buildLiteral("Another string"),context); p1.getInputPorts().get(0).receiveEvent(token2); assertTrue(deh2.getEventCount() == 0); assertTrue(deh1.getEventCount() == 1); }
public void testLock() throws UnsupportedEncodingException, MalformedIdentifierException, ActivityConfigurationException, EditException { create(); System.out.println("Lock (should produce no output) :"); WorkflowDataToken token = new WorkflowDataToken("outerProcess1", new int[0], Literal.buildLiteral("A string"), context); p2.getInputPorts().get(0).receiveEvent(token); // p1.getInputPorts().get(0).receiveEvent(token); assertTrue(deh2.getEventCount() == 0); }
@Test public void singleEmptyListDataTokenBehaviour() throws MalformedIdentifierException, EditException, JDOMException, IOException, ActivityConfigurationException, InterruptedException { // System.out.println("Empty list"); EntityIdentifier listIdentifier = dManager.registerEmptyList(1); // Build an input data token of a single list WorkflowDataToken token = new WorkflowDataToken("outerProcess2", new int[0], listIdentifier, context); // This is not a public API! We're using it here because we need some // way to push the configuration data into the processor that would // normally be created during the typecheck operation. In this case // we're declaring that we've given a list to the processor where it // wanted a single item and that it therefore has a wrapping level of 1 // after the iteration strategy has been applied. processor.resultWrappingDepth = 1; processor.getInputPorts().get(0).receiveEvent(token); // This shouldn't do anything as we've got the filter by default set to // 0 so it ignores this list which has depth 1. It will now, however, // correctly iterate over what it thinks is an empty set and return a // single empty result on the output Thread.sleep(100); assertEquals(1, deh.getEventCount()); }
@Test public void topLevelEmptyCollection() throws EditException, JDOMException, IOException, ActivityConfigurationException, MalformedIdentifierException, InterruptedException { // System.out.println("Top level empty list (depth 2)"); EntityIdentifier listIdentifier = dManager .registerEmptyList(2); ((ProcessorInputPortImpl) (processor.getInputPorts().get(0))) .setFilterDepth(0); WorkflowDataToken token = new WorkflowDataToken("outerProcess4", new int[0], listIdentifier, context); // This is not a public API! We're using it here because we need some // way to push the configuration data into the processor that would // normally be created during the typecheck operation. In this case // we're declaring that we've given a list of lists to the processor // where it wanted a single item and that it therefore has a wrapping // level of 2 after the iteration strategy has been applied. processor.resultWrappingDepth = 2; processor.getInputPorts().get(0).receiveEvent(token); Thread.sleep(100); assertEquals(1, deh.getEventCount()); }
@Test public void singleListDataTokenWithFilterConfigured() throws EditException, JDOMException, IOException, ActivityConfigurationException, MalformedIdentifierException, InterruptedException { // System.out.println("List with two items, 'foo' and 'bar'"); EntityIdentifier listIdentifier = dManager .registerList(new EntityIdentifier[] { Literal.buildLiteral("foo"), Literal.buildLiteral("bar") }); WorkflowDataToken token = new WorkflowDataToken("outerProcess3", new int[0], listIdentifier, context); // Reconfigure processor to set the filter to level 1, i.e. consume // lists and iterate over them using the data manager's traversal // functionality ((ProcessorInputPortImpl) (processor.getInputPorts().get(0))) .setFilterDepth(1); processor.getInputPorts().get(0).receiveEvent(token); // Should produce two outputs followed by a collection Thread.sleep(100); assertEquals(3, deh.getEventCount()); }
@Test public void testPartiallyEmptyCollection() throws EditException, JDOMException, IOException, ActivityConfigurationException, MalformedIdentifierException, InterruptedException { EntityIdentifier emptyListIdentifier = dManager.registerEmptyList(1); // System.out.println("Partially empty collection : {{}{foo, bar}}"); EntityIdentifier populatedListIdentifier = dManager .registerList(new EntityIdentifier[] { Literal.buildLiteral("foo"), Literal.buildLiteral("bar") }); EntityIdentifier listIdentifier = dManager .registerList(new EntityIdentifier[] { emptyListIdentifier, populatedListIdentifier }); ((ProcessorInputPortImpl) (processor.getInputPorts().get(0))) .setFilterDepth(2); WorkflowDataToken token = new WorkflowDataToken("outerProcess5", new int[0], listIdentifier, context); // This is not a public API! We're using it here because we need some // way to push the configuration data into the processor that would // normally be created during the typecheck operation. In this case // we're declaring that we've given a list of lists to the processor // where it wanted a single item and that it therefore has a wrapping // level of 2 after the iteration strategy has been applied. processor.resultWrappingDepth = 2; processor.getInputPorts().get(0).receiveEvent(token); Thread.sleep(COMPLETION_SLEEP); assertEquals(5, deh.getEventCount()); }