[ http://jira.codehaus.org/browse/SUREFIRE-515?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=145237#action_145237 ]
Thomas Diesler commented on SUREFIRE-515: ----------------------------------------- /* * JBoss, Home of Professional Open Source * Copyright 2005, JBoss Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This 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 software 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 software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.bpm.pattern.control.synchronization; // $Id: SynchronizationTest.java 1897 2008-08-15 08:46:48Z [EMAIL PROTECTED] $ import java.io.IOException; import org.jboss.bpm.client.SignalListener; import org.jboss.bpm.client.SignalManager; import org.jboss.bpm.model.EventBuilder; import org.jboss.bpm.model.Process; import org.jboss.bpm.model.ProcessBuilder; import org.jboss.bpm.model.ProcessBuilderFactory; import org.jboss.bpm.model.Signal; import org.jboss.bpm.model.Gateway.GatewayType; import org.jboss.bpm.model.Signal.SignalType; import org.jboss.bpm.runtime.ExecutionContext; import org.jboss.bpm.runtime.ExecutionHandler; import org.jboss.bpm.runtime.Token; import org.jboss.bpm.test.DefaultEngineTestCase; /** * Parallel gateway that that has multiple incoming sequence flows. Each token arriving from an incoming sequence flow * is stored in the gateway until a token has arrived from each incoming sequence flow. The tokens are merged together * and leave the gateway as a one. * * @author [EMAIL PROTECTED] * @since 06-Aug-2008 */ public class SynchronizationTest extends DefaultEngineTestCase { public void testSynchronization() throws Exception { Process proc = getProcess(); proc.startProcess(); // Add a signal listener that sends the other start trigger signal SignalManager signalManager = SignalManager.locateSignalManager(); Signal startTrigger = new Signal(getName(), SignalType.SYSTEM_START_TRIGGER, "B"); signalManager.addSignalListener(null, new MergeListener(proc.getName(), startTrigger)); // Send start trigger signal signalManager.throwSignal(proc.getName(), new Signal(getName(), SignalType.SYSTEM_START_TRIGGER, "A")); // Wait for the process to end proc.waitForEnd(); // Verify the result assertEquals("TaskA:TaskB", TaskC.taskValue); } public void testSynchronizationTimeout() throws Exception { Process proc = getProcess(); proc.startProcess(); // Send start trigger signal SignalManager signalManager = SignalManager.locateSignalManager(); signalManager.throwSignal(proc.getName(), new Signal(getName(), SignalType.SYSTEM_START_TRIGGER, "A")); // Wait for the process to end try { proc.waitForEnd(1000); fail("timeout expected"); } catch (RuntimeException rte) { // expected } } public void testSynchronizationInvalidToken() throws Exception { Process proc = getProcess(); proc.startProcess(); // Add a signal listener that sends the other start trigger signal SignalManager signalManager = SignalManager.locateSignalManager(); Signal startTrigger = new Signal(getName(), SignalType.SYSTEM_START_TRIGGER, "A"); signalManager.addSignalListener(null, new MergeListener(proc.getName(), startTrigger)); // Send start trigger signal signalManager.throwSignal(proc.getName(), new Signal(getName(), SignalType.SYSTEM_START_TRIGGER, "A")); try { proc.waitForEnd(); fail("Expected: Unexpected token from: SequenceFlow[TaskA->Merge]"); } catch (RuntimeException rte) { // expected } // Restart the process proc.startProcess(); // Add a signal listener that sends the other start trigger signal startTrigger = new Signal(getName(), SignalType.SYSTEM_START_TRIGGER, "B"); signalManager.addSignalListener(null, new MergeListener(proc.getName(), startTrigger)); // Send start trigger signal signalManager.throwSignal(proc.getName(), new Signal(getName(), SignalType.SYSTEM_START_TRIGGER, "A")); // Wait for the process to end proc.waitForEnd(); // Verify the result assertEquals("TaskA:TaskB", TaskC.taskValue); } public Process getProcess() throws IOException { ProcessBuilder procBuilder = ProcessBuilderFactory.newInstance().newProcessBuilder(); EventBuilder eventBuilder = procBuilder.addProcess(getName()).addStartEvent("StartA"); eventBuilder.addSignalTrigger(SignalType.SYSTEM_START_TRIGGER, "A").addSequenceFlow("TaskA"); procBuilder.addTask("TaskA").addExecutionHandler(TaskA.class).addSequenceFlow("Merge"); eventBuilder = procBuilder.addStartEvent("StartB"); eventBuilder.addSignalTrigger(SignalType.SYSTEM_START_TRIGGER, "B").addSequenceFlow("TaskB"); procBuilder.addTask("TaskB").addExecutionHandler(TaskB.class).addSequenceFlow("Merge"); procBuilder.addGateway("Merge", GatewayType.Parallel).addSequenceFlow("TaskC"); procBuilder.addTask("TaskC").addExecutionHandler(TaskC.class).addSequenceFlow("End"); procBuilder.addEndEvent("End"); Process proc = procBuilder.getProcess(); return proc; } public static class MergeListener implements SignalListener { private String fromRef; private Signal nextSignal; public MergeListener(String fromRef, Signal nextSignal) { this.fromRef = fromRef; this.nextSignal = nextSignal; } public void catchSignal(Signal signal) { if (signal.getSignalType() == SignalType.SYSTEM_GATEWAY_ENTER) { if (nextSignal != null) { SignalManager signalManager = SignalManager.locateSignalManager(); signalManager.throwSignal(fromRef, nextSignal); nextSignal = null; } } } } @SuppressWarnings("serial") public static class TaskA implements ExecutionHandler { public void execute(Token token) { ExecutionContext exContext = token.getExecutionContext(); exContext.addAttachment("taskA", "TaskA"); } } @SuppressWarnings("serial") public static class TaskB implements ExecutionHandler { public void execute(Token token) { ExecutionContext exContext = token.getExecutionContext(); exContext.addAttachment("taskB", "TaskB"); } } @SuppressWarnings("serial") public static class TaskC implements ExecutionHandler { public static Object taskValue; public void execute(Token token) { ExecutionContext exContext = token.getExecutionContext(); taskValue = exContext.getAttachment("taskA") + ":" + exContext.getAttachment("taskB"); } } } > Executes nested classes that are not tests > ------------------------------------------ > > Key: SUREFIRE-515 > URL: http://jira.codehaus.org/browse/SUREFIRE-515 > Project: Maven Surefire > Issue Type: Bug > Affects Versions: 2.4.3 > Reporter: Thomas Diesler > > When using excludes like this > <plugin> > <artifactId>maven-surefire-plugin</artifactId> > <configuration> > <excludes> > <exclude>org/jboss/bpm/pattern/**/*APITest.java</exclude> > </excludes> > <includes> > <include>org/jboss/bpm/pattern/**</include> > </includes> > </configuration> > </plugin> > surefire executes the nested classes > Running > org.jboss.bpm.pattern.control.synchronization.SynchronizationTest$TaskB > Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.003 sec > Running > org.jboss.bpm.pattern.control.synchronization.SynchronizationTest$TaskC > Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.002 sec -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira