| Commit in servicemix/base/src on MAIN | |||
| main/java/org/servicemix/jbi/nmr/Broker.java | +10 | -4 | 1.24 -> 1.25 |
| /SubscriptionManager.java | +2 | -2 | 1.4 -> 1.5 |
| test/java/org/servicemix/jbi/nmr/SubscriptionTest.java | +30 | -3 | 1.1 -> 1.2 |
| +42 | -9 | ||
Add more tests on subscriptions for different flow configurations
servicemix/base/src/main/java/org/servicemix/jbi/nmr
diff -u -r1.24 -r1.25 --- Broker.java 6 Oct 2005 15:47:11 -0000 1.24 +++ Broker.java 6 Oct 2005 16:35:33 -0000 1.25 @@ -54,7 +54,7 @@
/** * The Broker handles Nomalised Message Routing within ServiceMix *
- * @version $Revision: 1.24 $
+ * @version $Revision: 1.25 $
*/
public class Broker extends BaseLifeCycle {
private JBIContainer container;
@@ -125,9 +125,13 @@
this.flow.init(this);
SubscriptionManager sm = getSubscriptionManager();
if (sm != null){
- if (subscriptionFlowName == null || subscriptionFlowName.equals(flowName)){
- sm.setFlow(flow);
- }
+ if (sm.getFlow() == null && sm.getFlowName() == null) {
+ if (subscriptionFlowName == null || subscriptionFlowName.equals(flowName)){
+ sm.setFlow(flow);
+ } else {
+ sm.setFlowName(subscriptionFlowName);
+ }
+ }
sm.init(this, registry);
}
}
@@ -166,6 +170,7 @@
*/
public void start() throws JBIException {
flow.start();
+ subscriptionManager.getFlow().start();
super.start();
}
@@ -176,6 +181,7 @@
*/
public void stop() throws JBIException {
flow.stop();
+ subscriptionManager.getFlow().stop();
super.stop();
}
servicemix/base/src/main/java/org/servicemix/jbi/nmr
diff -u -r1.4 -r1.5 --- SubscriptionManager.java 5 Oct 2005 16:51:44 -0000 1.4 +++ SubscriptionManager.java 6 Oct 2005 16:35:33 -0000 1.5 @@ -38,7 +38,7 @@
public class SubscriptionManager {
private Registry registry;
- private String flowName = "seda";
+ private String flowName;
private Flow flow;
private IdGenerator idGenerator = new IdGenerator();
@@ -50,8 +50,8 @@
public void init(Broker broker,Registry registry) throws JBIException {
if (this.flow == null) {
this.flow = FlowProvider.getFlow(flowName);
- this.flow.init(broker);
}
+ this.flow.init(broker);
this.registry = registry;
}
servicemix/base/src/test/java/org/servicemix/jbi/nmr
diff -u -r1.1 -r1.2 --- SubscriptionTest.java 6 Oct 2005 15:47:11 -0000 1.1 +++ SubscriptionTest.java 6 Oct 2005 16:35:33 -0000 1.2 @@ -31,15 +31,42 @@
import org.servicemix.jbi.container.ActivationSpec; import org.servicemix.jbi.container.JBIContainer; import org.servicemix.jbi.container.SubscriptionSpec;
+import org.servicemix.jbi.nmr.flow.FlowProvider;
import EDU.oswego.cs.dl.util.concurrent.CopyOnWriteArrayList;
public class SubscriptionTest extends TestCase {
- public void test() throws Exception {
-
+ public void testStNull() throws Exception {
+ runTest("st", null);
+ }
+
+ public void testStSt() throws Exception {
+ runTest("st", "st");
+ }
+
+ public void testStSeda() throws Exception {
+ runTest("st", "seda");
+ }
+
+ public void testSedaNull() throws Exception {
+ runTest("seda", null);
+ }
+
+ public void testSedaSt() throws Exception {
+ runTest("seda", "st");
+ }
+
+ public void testSedaSeda() throws Exception {
+ runTest("seda", "seda");
+ }
+
+ private void runTest(String flowName, String subscriptionFlowName) throws Exception {
JBIContainer container = new JBIContainer();
- container.setFlowName("st");
+ container.getBroker().setFlow(FlowProvider.getFlow(flowName));
+ if (subscriptionFlowName != null) {
+ container.getBroker().getSubscriptionManager().setFlow(FlowProvider.getFlow(flowName));
+ }
container.init(); container.start();
