Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrbrooks2010-07-24 13:38:31 -0400
committerrbrooks2010-07-24 13:38:31 -0400
commit4081f04850d3eff9eb1bd7241763707bfbb43a45 (patch)
tree258620df94d4b24077ff103a6c4dea9cb78493fb /plugins/org.eclipse.osee.framework.messaging.test
parent4ed8bddc791fda93940f238c5135556a07041dc0 (diff)
downloadorg.eclipse.osee-4081f04850d3eff9eb1bd7241763707bfbb43a45.tar.gz
org.eclipse.osee-4081f04850d3eff9eb1bd7241763707bfbb43a45.tar.xz
org.eclipse.osee-4081f04850d3eff9eb1bd7241763707bfbb43a45.zip
applied Eclipse source cleanup
Diffstat (limited to 'plugins/org.eclipse.osee.framework.messaging.test')
-rw-r--r--plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/internal/BaseBrokerTesting.java45
-rw-r--r--plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/internal/DefaultNodeInfos.java29
-rw-r--r--plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/internal/IntegrationSuite.java9
-rw-r--r--plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/internal/MessageStatusTest.java113
-rw-r--r--plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/internal/TestBrokerServiceInterruptions.java95
-rw-r--r--plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/internal/TestMessages.java85
-rw-r--r--plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/internal/TestSendingAndRecieving.java174
-rw-r--r--plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/services/internal/BasicListener.java16
-rw-r--r--plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/services/internal/TestMessageServices.java452
-rw-r--r--plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/services/internal/TestMessageServicesMultipleConsumers.java137
-rw-r--r--plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/test/msg/ObjectFactory.java69
-rw-r--r--plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/test/msg/TestMessage.java100
12 files changed, 641 insertions, 683 deletions
diff --git a/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/internal/BaseBrokerTesting.java b/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/internal/BaseBrokerTesting.java
index 70b9640e2c..16d086b067 100644
--- a/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/internal/BaseBrokerTesting.java
+++ b/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/internal/BaseBrokerTesting.java
@@ -97,13 +97,15 @@ public class BaseBrokerTesting {
} else {
exe = "eclipse";
}
- ProcessBuilder builder = new ProcessBuilder(url.getPath() + exe, "-console", "-nosplash", "-application", "jms.activemq.launch.RunActiveMq", DefaultNodeInfos.OSEE_JMS_DEFAULT_PORT);
+ ProcessBuilder builder =
+ new ProcessBuilder(url.getPath() + exe, "-console", "-nosplash", "-application",
+ "jms.activemq.launch.RunActiveMq", DefaultNodeInfos.OSEE_JMS_DEFAULT_PORT);
builder.directory(new File(url.getPath()));
builder.redirectErrorStream(true);
Process process = builder.start();
Thread th = new Thread(new OutputReader(System.out, process.getInputStream()));
th.start();
-// threads = Lib.handleProcessNoWait(process, new PrintWriter(System.out));
+ // threads = Lib.handleProcessNoWait(process, new PrintWriter(System.out));
Thread.sleep(30000);
} catch (MalformedURLException ex) {
OseeLog.log(BaseBrokerTesting.class, Level.SEVERE, ex);
@@ -116,23 +118,24 @@ public class BaseBrokerTesting {
fail(ex.getMessage());
}
}
-
+
public class OutputReader implements Runnable {
- private PrintStream printStream;
- private InputStream input;
+ private final PrintStream printStream;
+ private final InputStream input;
public OutputReader(PrintStream printStream, InputStream input) {
super();
this.printStream = printStream;
this.input = input;
-
+
}
+ @Override
public void run() {
try {
- final byte[] buffer = new byte[4096];
- int size;
+ final byte[] buffer = new byte[4096];
+ int size;
while ((size = input.read(buffer)) != -1) {
printStream.print(new String(buffer, 0, size, "UTF-8"));
printStream.flush();
@@ -150,11 +153,10 @@ public class BaseBrokerTesting {
}
}
-
-
protected void stopBroker() {
try {
- getMessaging().get(DefaultNodeInfos.OSEE_JMS_DEFAULT).send(SystemTopic.KILL_TEST_JMS_BROKER, "kill", new MessageStatusTest(true));
+ getMessaging().get(DefaultNodeInfos.OSEE_JMS_DEFAULT).send(SystemTopic.KILL_TEST_JMS_BROKER, "kill",
+ new MessageStatusTest(true));
Thread.sleep(10000);
} catch (InterruptedException ex) {
OseeLog.log(BaseBrokerTesting.class, Level.SEVERE, ex);
@@ -196,23 +198,20 @@ public class BaseBrokerTesting {
status.waitForStatus(5000);
}
- protected void testJMSSubscribeShouldFail(MessageService messaging)
- throws OseeCoreException {
- MessageStatusTest status = new MessageStatusTest(false);
- OseeMessagingListener listener = new OseeMessagingListener(TestMessage.class) {
+ protected void testJMSSubscribeShouldFail(MessageService messaging) throws OseeCoreException {
+ MessageStatusTest status = new MessageStatusTest(false);
+ OseeMessagingListener listener = new OseeMessagingListener(TestMessage.class) {
@Override
- public void process(Object message,
- Map<String, Object> headers,
- ReplyConnection replyConnection) {
+ public void process(Object message, Map<String, Object> headers, ReplyConnection replyConnection) {
TestMessage msg = (TestMessage) message;
System.out.println(msg.getMessage());
}
};
-
- messaging.get(DefaultNodeInfos.OSEE_JMS_DEFAULT).subscribe(TestMessages.test2, listener, status);
- status.waitForStatus(5000);
- messaging.get(DefaultNodeInfos.OSEE_JMS_DEFAULT).unsubscribe(TestMessages.test2, listener, status);//we have to remove so we don't get a false fail later on
- }
+
+ messaging.get(DefaultNodeInfos.OSEE_JMS_DEFAULT).subscribe(TestMessages.test2, listener, status);
+ status.waitForStatus(5000);
+ messaging.get(DefaultNodeInfos.OSEE_JMS_DEFAULT).unsubscribe(TestMessages.test2, listener, status);//we have to remove so we don't get a false fail later on
+ }
protected void testJMSSubscribeShouldPass(MessageService messaging) throws OseeCoreException {
MessageStatusTest status = new MessageStatusTest(true);
diff --git a/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/internal/DefaultNodeInfos.java b/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/internal/DefaultNodeInfos.java
index 07314c4786..3ee2c78139 100644
--- a/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/internal/DefaultNodeInfos.java
+++ b/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/internal/DefaultNodeInfos.java
@@ -18,21 +18,20 @@ import org.eclipse.osee.framework.messaging.NodeInfo;
/**
* @author Andrew M. Finkbeiner
- *
*/
public class DefaultNodeInfos {
-
- public static String OSEE_JMS_DEFAULT_PORT = "61616";
- public static NodeInfo OSEE_JMS_DEFAULT;
- public static NodeInfo OSEE_VM;
-
- static{
- try {
- OSEE_JMS_DEFAULT = new NodeInfo("osee-jms", new URI("tcp://localhost:" + OSEE_JMS_DEFAULT_PORT));
- OSEE_VM = new NodeInfo("osee-vm", new URI("vm://localhost?broker.persistent=false"));
- } catch (URISyntaxException ex) {
- OseeLog.log(DefaultNodeInfos.class, Level.SEVERE, ex);
- }
- }
-
+
+ public static String OSEE_JMS_DEFAULT_PORT = "61616";
+ public static NodeInfo OSEE_JMS_DEFAULT;
+ public static NodeInfo OSEE_VM;
+
+ static {
+ try {
+ OSEE_JMS_DEFAULT = new NodeInfo("osee-jms", new URI("tcp://localhost:" + OSEE_JMS_DEFAULT_PORT));
+ OSEE_VM = new NodeInfo("osee-vm", new URI("vm://localhost?broker.persistent=false"));
+ } catch (URISyntaxException ex) {
+ OseeLog.log(DefaultNodeInfos.class, Level.SEVERE, ex);
+ }
+ }
+
}
diff --git a/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/internal/IntegrationSuite.java b/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/internal/IntegrationSuite.java
index 506a15a0d1..2da15d07ab 100644
--- a/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/internal/IntegrationSuite.java
+++ b/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/internal/IntegrationSuite.java
@@ -13,13 +13,8 @@ package org.eclipse.osee.framework.messaging.internal;
import org.eclipse.osee.framework.messaging.services.internal.TestMessageServices;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
-
+
@RunWith(Suite.class)
-@Suite.SuiteClasses({
- TestSendingAndRecieving.class,
- TestBrokerServiceInterruptions.class,
- TestMessageServices.class
-})
+@Suite.SuiteClasses({TestSendingAndRecieving.class, TestBrokerServiceInterruptions.class, TestMessageServices.class})
public class IntegrationSuite {
}
-
diff --git a/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/internal/MessageStatusTest.java b/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/internal/MessageStatusTest.java
index 771cb7d02f..cab9ec3bb7 100644
--- a/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/internal/MessageStatusTest.java
+++ b/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/internal/MessageStatusTest.java
@@ -14,69 +14,68 @@ import org.eclipse.osee.framework.messaging.OseeMessagingStatusCallback;
/**
* @author Andrew M. Finkbeiner
- *
*/
public class MessageStatusTest implements OseeMessagingStatusCallback {
- private volatile boolean isDone = false;
- private volatile boolean timedOut = false;
- private volatile boolean waitedOnStatus = false;
- private boolean shouldPass;
+ private volatile boolean isDone = false;
+ private volatile boolean timedOut = false;
+ private volatile boolean waitedOnStatus = false;
+ private final boolean shouldPass;
- public MessageStatusTest(boolean shouldPass){
- this.shouldPass = shouldPass;
- }
-
- @Override
- public void fail(Throwable th) {
- if(waitedOnStatus){
+ public MessageStatusTest(boolean shouldPass) {
+ this.shouldPass = shouldPass;
+ }
+
+ @Override
+ public void fail(Throwable th) {
+ if (waitedOnStatus) {
return;
}
-
- if(timedOut){
- return;
- }
- if(shouldPass){
- org.junit.Assert.fail(th.getMessage());
- } else {
- org.junit.Assert.assertTrue(true);
- }
- isDone = true;
- }
- @Override
- public void success() {
- if(waitedOnStatus){
- return;
- }
-
- if(timedOut){
- return;
- }
- if(shouldPass){
- org.junit.Assert.assertTrue(true);
- } else {
- org.junit.Assert.fail("We had a status of 'success'");
- }
- isDone = true;
- }
+ if (timedOut) {
+ return;
+ }
+ if (shouldPass) {
+ org.junit.Assert.fail(th.getMessage());
+ } else {
+ org.junit.Assert.assertTrue(true);
+ }
+ isDone = true;
+ }
+
+ @Override
+ public void success() {
+ if (waitedOnStatus) {
+ return;
+ }
- public void waitForStatus(int time) {
- long timeout = System.currentTimeMillis() + time;
- while (!isDone && System.currentTimeMillis() < timeout) {
- try {
- Thread.sleep(200);
- } catch (InterruptedException ex) {
- }
- }
- if (!isDone) {
- timedOut = true;
- if(shouldPass){
- org.junit.Assert.fail("We timed out waiting for status.");
- } else {
- org.junit.Assert.assertTrue(true);
- }
- }
- waitedOnStatus = true;
- }
+ if (timedOut) {
+ return;
+ }
+ if (shouldPass) {
+ org.junit.Assert.assertTrue(true);
+ } else {
+ org.junit.Assert.fail("We had a status of 'success'");
+ }
+ isDone = true;
+ }
+
+ public void waitForStatus(int time) {
+ long timeout = System.currentTimeMillis() + time;
+ while (!isDone && System.currentTimeMillis() < timeout) {
+ try {
+ Thread.sleep(200);
+ } catch (InterruptedException ex) {
+ }
+ }
+ if (!isDone) {
+ timedOut = true;
+ if (shouldPass) {
+ org.junit.Assert.fail("We timed out waiting for status.");
+ } else {
+ org.junit.Assert.assertTrue(true);
+ }
+ }
+ waitedOnStatus = true;
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/internal/TestBrokerServiceInterruptions.java b/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/internal/TestBrokerServiceInterruptions.java
index 60cac7d7b8..10236c81ac 100644
--- a/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/internal/TestBrokerServiceInterruptions.java
+++ b/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/internal/TestBrokerServiceInterruptions.java
@@ -15,52 +15,50 @@ import static org.junit.Assert.assertTrue;
import org.eclipse.osee.framework.messaging.ConnectionListener;
import org.eclipse.osee.framework.messaging.ConnectionNode;
-
/**
* @author Andrew M. Finkbeiner
*/
public class TestBrokerServiceInterruptions extends BaseBrokerTesting {
-// @Ignore
- @org.junit.Test
- public void testBrokerComesUpAfterAppsRunning() throws Exception {
- testJMSSendShouldFail(getMessaging());
- testJMSSubscribeShouldFail(getMessaging());
+ // @Ignore
+ @org.junit.Test
+ public void testBrokerComesUpAfterAppsRunning() throws Exception {
+ testJMSSendShouldFail(getMessaging());
+ testJMSSubscribeShouldFail(getMessaging());
+
+ startBroker();
+
+ testJMSSubscribeShouldPass(getMessaging());
+ testJMSSendShouldPass(getMessaging());
+
+ stopBroker();
+ }
+
+ // @Ignore
+ @org.junit.Test
+ public void testBrokerGoingDownTriggersConnectionEvent() throws Exception {
+ startBroker();
- startBroker();
+ testJMSSendShouldPass(getMessaging());
- testJMSSubscribeShouldPass(getMessaging());
- testJMSSendShouldPass(getMessaging());
+ ConnectionNode connectionNode = getMessaging().get(DefaultNodeInfos.OSEE_JMS_DEFAULT);
+ TestConnectionListener connectionListener = new TestConnectionListener();
+ connectionNode.addConnectionListener(connectionListener);
- stopBroker();
- }
+ assertTrue(connectionListener.isConnected());
-// @Ignore
- @org.junit.Test
- public void testBrokerGoingDownTriggersConnectionEvent() throws Exception {
- startBroker();
+ stopBroker();
- testJMSSendShouldPass(getMessaging());
+ testWait(65000);//currently we ping the broker every minute to see if it still exists, so we've allowed enough time for a timeout
+ assertFalse(connectionListener.isConnected());
- ConnectionNode connectionNode = getMessaging().get(DefaultNodeInfos.OSEE_JMS_DEFAULT);
- TestConnectionListener connectionListener = new TestConnectionListener();
- connectionNode.addConnectionListener(connectionListener);
+ }
- assertTrue(connectionListener.isConnected());
-
- stopBroker();
-
- testWait(65000);//currently we ping the broker every minute to see if it still exists, so we've allowed enough time for a timeout
-
- assertFalse(connectionListener.isConnected());
-
- }
+ private class TestConnectionListener implements ConnectionListener {
- private class TestConnectionListener implements ConnectionListener {
+ private boolean isConnected = false;
- private boolean isConnected = false;
-
@Override
public void connected(ConnectionNode node) {
System.out.println("connected from test listner");
@@ -76,31 +74,30 @@ public class TestBrokerServiceInterruptions extends BaseBrokerTesting {
System.out.println("not connected from test listener");
isConnected = false;
}
- }
-
+ }
-// @Ignore
- @org.junit.Test
- public void testBrokerGoingDownSendFails() throws Exception {
- startBroker();
+ // @Ignore
+ @org.junit.Test
+ public void testBrokerGoingDownSendFails() throws Exception {
+ startBroker();
- testJMSSendShouldPass(getMessaging());
+ testJMSSendShouldPass(getMessaging());
- stopBroker();
+ stopBroker();
- testJMSSendShouldFail(getMessaging());
- }
+ testJMSSendShouldFail(getMessaging());
+ }
-// @Ignore
- @org.junit.Test
- public void testBrokerGoingDownSubscribeFails() throws Exception {
- startBroker();
+ // @Ignore
+ @org.junit.Test
+ public void testBrokerGoingDownSubscribeFails() throws Exception {
+ startBroker();
- testJMSSubscribeShouldPass(getMessaging());
+ testJMSSubscribeShouldPass(getMessaging());
- stopBroker();
+ stopBroker();
- testJMSSubscribeShouldFail(getMessaging());
- }
+ testJMSSubscribeShouldFail(getMessaging());
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/internal/TestMessages.java b/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/internal/TestMessages.java
index 068ec41bba..2029c72a35 100644
--- a/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/internal/TestMessages.java
+++ b/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/internal/TestMessages.java
@@ -15,54 +15,53 @@ import org.eclipse.osee.framework.messaging.test.msg.TestMessage;
/**
* @author Andrew M. Finkbeiner
- *
*/
public enum TestMessages implements MessageID {
- TestTopic(true, "ABVlXX3B9UaWogL++MgA", "topic:someTopic", null),
- JMS_TOPIC(true, "ABWApt8OtWlAnz5CJXQA", "topic:test.topic.Mynewthing.removeme", TestMessage.class),
- VM_TOPIC(true, "ABWHSTHuTlQb5xWueMAA", "topic:inThisJVM", TestMessage.class),
- test(true, "ABWoNNdp0RnrO5T5bWwA", "test", null),
- test2(true, "ABWpvHZTpBTR+PhVrwgA","test2", null),
- replyTopic(true, "ABWswvHPoR6RpnW9oGAA","topic:someTopicThatNeedsAReply", null, true);
-
- private String name;
- private Class<?> clazz;
- boolean isReplyRequired;
- private String guid;
-
- TestMessages(boolean isTopic, String guid, String name, Class<?> clazz, boolean isReplyRequired){
- this.guid = guid;
- this.name = name;
- this.clazz = clazz;
- this.isReplyRequired = isReplyRequired;
- }
-
- TestMessages(boolean isTopic, String guid,String name, Class<?> clazz){
- this.name = name;
- this.clazz = clazz;
- this.isReplyRequired = false;
- this.guid = guid;
- }
-
- @Override
- public String getName() {
- return name;
- }
+ TestTopic(true, "ABVlXX3B9UaWogL++MgA", "topic:someTopic", null),
+ JMS_TOPIC(true, "ABWApt8OtWlAnz5CJXQA", "topic:test.topic.Mynewthing.removeme", TestMessage.class),
+ VM_TOPIC(true, "ABWHSTHuTlQb5xWueMAA", "topic:inThisJVM", TestMessage.class),
+ test(true, "ABWoNNdp0RnrO5T5bWwA", "test", null),
+ test2(true, "ABWpvHZTpBTR+PhVrwgA", "test2", null),
+ replyTopic(true, "ABWswvHPoR6RpnW9oGAA", "topic:someTopicThatNeedsAReply", null, true);
+
+ private String name;
+ private Class<?> clazz;
+ boolean isReplyRequired;
+ private String guid;
+
+ TestMessages(boolean isTopic, String guid, String name, Class<?> clazz, boolean isReplyRequired) {
+ this.guid = guid;
+ this.name = name;
+ this.clazz = clazz;
+ this.isReplyRequired = isReplyRequired;
+ }
- @Override
- public Class<?> getSerializationClass() {
- return clazz;
- }
+ TestMessages(boolean isTopic, String guid, String name, Class<?> clazz) {
+ this.name = name;
+ this.clazz = clazz;
+ this.isReplyRequired = false;
+ this.guid = guid;
+ }
- @Override
- public boolean isReplyRequired() {
- return isReplyRequired;
- }
+ @Override
+ public String getName() {
+ return name;
+ }
- @Override
- public String getId() {
- return guid;
- }
+ @Override
+ public Class<?> getSerializationClass() {
+ return clazz;
+ }
+
+ @Override
+ public boolean isReplyRequired() {
+ return isReplyRequired;
+ }
+
+ @Override
+ public String getId() {
+ return guid;
+ }
@Override
public boolean isTopic() {
diff --git a/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/internal/TestSendingAndRecieving.java b/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/internal/TestSendingAndRecieving.java
index 2fa9314d3b..64cfb5b06b 100644
--- a/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/internal/TestSendingAndRecieving.java
+++ b/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/internal/TestSendingAndRecieving.java
@@ -24,103 +24,93 @@ import org.eclipse.osee.framework.messaging.test.msg.TestMessage;
*/
public class TestSendingAndRecieving extends BaseBrokerTesting {
-
- private final int messagesToSend = 10;
- private int messagesReceived = 0;
+ private final int messagesToSend = 10;
+ private int messagesReceived = 0;
- @org.junit.Test
- public void testSendingAndRecievingUsingJMS() {
-// stopBroker();
- startBroker();
- try {
- messagesReceived = 0;
- MessageStatusTest status1 = new MessageStatusTest(true);
- getMessaging().get(DefaultNodeInfos.OSEE_JMS_DEFAULT).subscribe(
- TestMessages.JMS_TOPIC, new OseeMessagingListener(TestMessage.class) {
- @Override
- public void process(Object message,
- Map<String, Object> headers,
- ReplyConnection replyConnection) {
- TestMessage msg = (TestMessage) message;
- System.out.println(msg.getMessage());
- messagesReceived++;
- }
- }, status1);
- status1.waitForStatus(500);
- Thread sending = new Thread(new Runnable() {
- @Override
- public void run() {
- for (int i = 0; i < messagesToSend; i++) {
- MessageStatusTest status2 = new MessageStatusTest(true);
- try {
- TestMessage message = new TestMessage();
- message.setMessage("TestMessage " + i);
- getMessaging().get(
- DefaultNodeInfos.OSEE_JMS_DEFAULT).send(
- TestMessages.JMS_TOPIC, message, status2);
- System.out.println("sending " + i);
- } catch (OseeCoreException ex) {
- fail(ex.getMessage());
- }
- status2.waitForStatus(500);
+ @org.junit.Test
+ public void testSendingAndRecievingUsingJMS() {
+ // stopBroker();
+ startBroker();
+ try {
+ messagesReceived = 0;
+ MessageStatusTest status1 = new MessageStatusTest(true);
+ getMessaging().get(DefaultNodeInfos.OSEE_JMS_DEFAULT).subscribe(TestMessages.JMS_TOPIC,
+ new OseeMessagingListener(TestMessage.class) {
+ @Override
+ public void process(Object message, Map<String, Object> headers, ReplyConnection replyConnection) {
+ TestMessage msg = (TestMessage) message;
+ System.out.println(msg.getMessage());
+ messagesReceived++;
+ }
+ }, status1);
+ status1.waitForStatus(500);
+ Thread sending = new Thread(new Runnable() {
+ @Override
+ public void run() {
+ for (int i = 0; i < messagesToSend; i++) {
+ MessageStatusTest status2 = new MessageStatusTest(true);
+ try {
+ TestMessage message = new TestMessage();
+ message.setMessage("TestMessage " + i);
+ getMessaging().get(DefaultNodeInfos.OSEE_JMS_DEFAULT).send(TestMessages.JMS_TOPIC, message,
+ status2);
+ System.out.println("sending " + i);
+ } catch (OseeCoreException ex) {
+ fail(ex.getMessage());
+ }
+ status2.waitForStatus(500);
- }
- }
- });
- sending.start();
- Thread.sleep(10000);
+ }
+ }
+ });
+ sending.start();
+ Thread.sleep(10000);
- assertTrue(String.format("sent[%d] != recieved[%d]",
- messagesToSend, messagesReceived),
- messagesToSend == messagesReceived);
+ assertTrue(String.format("sent[%d] != recieved[%d]", messagesToSend, messagesReceived),
+ messagesToSend == messagesReceived);
- } catch (Exception ex) {
- ex.printStackTrace();
- fail(ex.getMessage());
- }
- stopBroker();
- }
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ fail(ex.getMessage());
+ }
+ stopBroker();
+ }
- @org.junit.Test
- public void testSendingAndRecievingUsingVM() {
- try {
- messagesReceived = 0;
- MessageStatusTest status1 = new MessageStatusTest(true);
- getMessaging().get(DefaultNodeInfos.OSEE_VM).subscribe(TestMessages.VM_TOPIC,
- new OseeMessagingListener() {
- @Override
- public void process(Object message,
- Map<String, Object> headers,
- ReplyConnection replyConnection) {
- messagesReceived++;
- }
- }, status1);
- Thread sending = new Thread(new Runnable() {
- @Override
- public void run() {
- for (int i = 0; i < messagesToSend; i++) {
- TestMessage message = new TestMessage();
- message.setMessage("TestMessage " + i);
- MessageStatusTest status2 = new MessageStatusTest(true);
- try {
- getMessaging().get(DefaultNodeInfos.OSEE_VM).send(
- TestMessages.VM_TOPIC, message, status2);
- } catch (OseeCoreException ex) {
- fail(ex.getMessage());
- }
- status2.waitForStatus(500);
- }
- }
- });
- sending.start();
- Thread.sleep(10000);
+ @org.junit.Test
+ public void testSendingAndRecievingUsingVM() {
+ try {
+ messagesReceived = 0;
+ MessageStatusTest status1 = new MessageStatusTest(true);
+ getMessaging().get(DefaultNodeInfos.OSEE_VM).subscribe(TestMessages.VM_TOPIC, new OseeMessagingListener() {
+ @Override
+ public void process(Object message, Map<String, Object> headers, ReplyConnection replyConnection) {
+ messagesReceived++;
+ }
+ }, status1);
+ Thread sending = new Thread(new Runnable() {
+ @Override
+ public void run() {
+ for (int i = 0; i < messagesToSend; i++) {
+ TestMessage message = new TestMessage();
+ message.setMessage("TestMessage " + i);
+ MessageStatusTest status2 = new MessageStatusTest(true);
+ try {
+ getMessaging().get(DefaultNodeInfos.OSEE_VM).send(TestMessages.VM_TOPIC, message, status2);
+ } catch (OseeCoreException ex) {
+ fail(ex.getMessage());
+ }
+ status2.waitForStatus(500);
+ }
+ }
+ });
+ sending.start();
+ Thread.sleep(10000);
- assertTrue(String.format("sent[%d] != recieved[%d]",
- messagesToSend, messagesReceived),
- messagesToSend == messagesReceived);
+ assertTrue(String.format("sent[%d] != recieved[%d]", messagesToSend, messagesReceived),
+ messagesToSend == messagesReceived);
- } catch (Exception ex) {
- assertFalse(ex.getMessage(), true);
- }
- }
+ } catch (Exception ex) {
+ assertFalse(ex.getMessage(), true);
+ }
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/services/internal/BasicListener.java b/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/services/internal/BasicListener.java
index 9539f210cf..056c6b148c 100644
--- a/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/services/internal/BasicListener.java
+++ b/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/services/internal/BasicListener.java
@@ -17,33 +17,33 @@ import org.eclipse.osee.framework.messaging.test.msg.TestMessage;
/**
* @author Andrew M. Finkbeiner
- *
*/
public class BasicListener extends OseeMessagingListener {
- private int id;
+ private final int id;
private boolean received = false;
-
+
public BasicListener(int id) {
this.id = id;
}
-
+
@Override
public Class<?> getClazz() {
return TestMessage.class;
}
-
+
@Override
public void process(Object message, Map<String, Object> headers, ReplyConnection replyConnection) {
System.out.println(message + " - " + id);
received = true;
}
- public boolean isReceived(){
+ public boolean isReceived() {
return received;
}
-
- public String toString(){
+
+ @Override
+ public String toString() {
return "BasicListener " + id;
}
}
diff --git a/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/services/internal/TestMessageServices.java b/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/services/internal/TestMessageServices.java
index edc8b5efdb..d5ace66e48 100644
--- a/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/services/internal/TestMessageServices.java
+++ b/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/services/internal/TestMessageServices.java
@@ -35,233 +35,239 @@ import org.eclipse.osee.framework.messaging.services.messages.ServiceHealth;
/**
* @author Andrew M. Finkbeiner
- *
*/
public class TestMessageServices extends BaseBrokerTesting {
- private static String BROKER_URI_SERVER = "tcp://localhost:61616";
- private static String BROKER_URI = "tcp://localhost:61616";
-
- @org.junit.Before
- public void startBroker(){
- try {
- startEmbeddedBroker("testBroker", BROKER_URI_SERVER);
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
-
- @org.junit.After
- public void stopBroker(){
- try {
- stopEmbeddedBroker("testBroker", BROKER_URI_SERVER);
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
-
-// @Ignore
- @org.junit.Test
- public void testServiceUpClientComesUp() throws Exception{
- ConnectionNode connection = getMessaging().get(new NodeInfo("osee-jms", new URI(BROKER_URI)));
- Assert.assertNotNull(connection);
- ScheduledExecutorService executor = Executors.newScheduledThreadPool(3);
-
- RemoteServiceRegistrar registrar = new RemoteServiceRegistrarImpl(connection, executor);
- RemoteServiceLookup lookup = new RemoteServiceLookupImpl(connection, executor);
- registrar.start();
- lookup.start();
-
- registrar.registerService("testService", "1002", "some.service.id", new URI("tcp://localhost:666"), new TestPopulator(), 30);
-
- TestNotification testNotification = new TestNotification();
- lookup.register("testService", "1002", testNotification);
-
- testWait(3000);
- Assert.assertTrue(testNotification.getServiceUpdates() >= 1);
- int currentNumberOfUpdates = testNotification.getServiceUpdates();
- testWait(35000);
-
- Assert.assertEquals(currentNumberOfUpdates + 1, testNotification.getServiceUpdates());
- Assert.assertTrue(registrar.unregisterService("testService", "1002", "some.service.id"));
-
- testWait(1000);
-
- Assert.assertEquals(1, testNotification.getServiceAway());//message from unregister
-
- testWait(90000);
-
- Assert.assertEquals(2, testNotification.getServiceAway());//service renewal timout
- Assert.assertEquals(currentNumberOfUpdates + 1, testNotification.getServiceUpdates());
- Assert.assertTrue(lookup.unregister("testService", "1002", testNotification));
-
- registrar.stop();
- lookup.stop();
- testWait(2000);
- }
-
-// @Ignore
- @org.junit.Test
- public void testClientUpServiceComesUp() throws Exception{
- ConnectionNode connection = getMessaging().get(new NodeInfo("osee-jms", new URI(BROKER_URI)));
- Assert.assertNotNull(connection);
- ScheduledExecutorService executor = Executors.newScheduledThreadPool(3);
- RemoteServiceRegistrar registrar = new RemoteServiceRegistrarImpl(connection, executor);
- registrar.start();
-
- RemoteServiceLookup lookup = new RemoteServiceLookupImpl(connection, executor);
- lookup.start();
-
- TestNotification testNotification = new TestNotification();
- lookup.register("testService", "1002", testNotification);
-
- registrar.registerService("testService", "1002", "some.service.id", new URI("tcp://localhost:666"), new TestPopulator(), 30);
- testWait(3000);
-
- Assert.assertTrue(testNotification.getServiceUpdates() >= 1);
- int currentNumberOfUpdates = testNotification.getServiceUpdates();
-
- testWait(35000);
-
- Assert.assertEquals(currentNumberOfUpdates + 1, testNotification.getServiceUpdates());
- Assert.assertTrue(registrar.unregisterService("testService", "1002", "some.service.id"));
-
- testWait(1000);
-
+ private static String BROKER_URI_SERVER = "tcp://localhost:61616";
+ private static String BROKER_URI = "tcp://localhost:61616";
+
+ @Override
+ @org.junit.Before
+ public void startBroker() {
+ try {
+ startEmbeddedBroker("testBroker", BROKER_URI_SERVER);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ @Override
+ @org.junit.After
+ public void stopBroker() {
+ try {
+ stopEmbeddedBroker("testBroker", BROKER_URI_SERVER);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ // @Ignore
+ @org.junit.Test
+ public void testServiceUpClientComesUp() throws Exception {
+ ConnectionNode connection = getMessaging().get(new NodeInfo("osee-jms", new URI(BROKER_URI)));
+ Assert.assertNotNull(connection);
+ ScheduledExecutorService executor = Executors.newScheduledThreadPool(3);
+
+ RemoteServiceRegistrar registrar = new RemoteServiceRegistrarImpl(connection, executor);
+ RemoteServiceLookup lookup = new RemoteServiceLookupImpl(connection, executor);
+ registrar.start();
+ lookup.start();
+
+ registrar.registerService("testService", "1002", "some.service.id", new URI("tcp://localhost:666"),
+ new TestPopulator(), 30);
+
+ TestNotification testNotification = new TestNotification();
+ lookup.register("testService", "1002", testNotification);
+
+ testWait(3000);
+ Assert.assertTrue(testNotification.getServiceUpdates() >= 1);
+ int currentNumberOfUpdates = testNotification.getServiceUpdates();
+ testWait(35000);
+
+ Assert.assertEquals(currentNumberOfUpdates + 1, testNotification.getServiceUpdates());
+ Assert.assertTrue(registrar.unregisterService("testService", "1002", "some.service.id"));
+
+ testWait(1000);
+
Assert.assertEquals(1, testNotification.getServiceAway());//message from unregister
-
+
testWait(90000);
-
+
Assert.assertEquals(2, testNotification.getServiceAway());//service renewal timout
-
- Assert.assertEquals(currentNumberOfUpdates + 1, testNotification.getServiceUpdates());
- Assert.assertTrue(lookup.unregister("testService", "1002", testNotification));
-
- lookup.stop();
- registrar.stop();
- testWait(2000);
- }
-
-// @Ignore
- @org.junit.Test
- public void testServiceComesUpClientGetsReply() throws Exception{
- ConnectionNode connection = getMessaging().get(new NodeInfo("osee-jms", new URI(BROKER_URI)));
- Assert.assertNotNull(connection);
- ScheduledExecutorService executor = Executors.newScheduledThreadPool(3);
-
- RemoteServiceRegistrar registrar = new RemoteServiceRegistrarImpl(connection, executor);
- registrar.start();
- registrar.registerService("testService", "1002", "some.service.id", new URI("tcp://localhost:666"), new TestPopulator(), 50000);
-
-
- testWait(2000);
- RemoteServiceLookup lookup = new RemoteServiceLookupImpl(connection, executor);
- lookup.start();
- TestNotification testNotification = new TestNotification();
- lookup.register("testService", "1002", testNotification);
- testWait(1000);
-
- Assert.assertEquals(1, testNotification.getServiceUpdates());
-
- Assert.assertTrue(lookup.unregister("testService", "1002", testNotification));
- Assert.assertTrue(registrar.unregisterService("testService", "1002", "some.service.id"));
-
- registrar.stop();
- lookup.stop();
- testWait(2000);
- }
-
-// @Ignore
- @org.junit.Test
- public void testReply() throws Exception{
- ConnectionNode connection = getMessaging().get(new NodeInfo("osee-jms", new URI(BROKER_URI)));
- TestReplyListener service = new TestReplyListener();
- TestReplyListener replyReciever = new TestReplyListener();
- connection.subscribe(TestMessages.replyTopic, service, new OseeMessagingStatusImpl("failed to subscribe", TestMessageServices.class));
- connection.subscribeToReply(TestMessages.replyTopic, replyReciever);
- testWait(1000);
- System.out.println(System.currentTimeMillis());
- connection.send(TestMessages.replyTopic, "test", new BasicOseeMessagingStatus());
- System.out.println(System.currentTimeMillis());
- testWait(5000);
- System.out.println(System.currentTimeMillis());
- Assert.assertEquals(1, service.sentReply);
- Assert.assertEquals(1, replyReciever.receivedReply);
- connection.unsubscribe(TestMessages.replyTopic, service, new OseeMessagingStatusImpl("failed to subscribe", TestMessageServices.class));
- }
-
- private class TestReplyListener extends OseeMessagingListener {
- int sentReply;
- int receivedReply;
- String msg = "back at ya";
- @Override
- public void process(Object message, Map<String, Object> headers,
- ReplyConnection replyConnection) {
- if(replyConnection.isReplyRequested()){
- try {
- System.out.println(System.currentTimeMillis());
- System.out.println(System.currentTimeMillis() +" reply requested - " + msg);
- replyConnection.send(msg, null, new BasicOseeMessagingStatus());
- sentReply++;
- } catch (OseeCoreException ex) {
- ex.printStackTrace();
- }
- } else {
- System.out.println(System.currentTimeMillis() +" got a reply - " + message);
- if(message.toString().equals(msg)){
- receivedReply++;
- }
- }
- }
- }
-
- private class BasicOseeMessagingStatus implements OseeMessagingStatusCallback {
- @Override
- public void fail(Throwable th) {
- th.printStackTrace();
- OseeLog.log(BasicOseeMessagingStatus.class, Level.SEVERE, th);
- }
- @Override
- public void success() {
- }
- }
-
- private class TestPopulator implements ServiceInfoPopulator {
-
- @Override
- public void updateServiceInfo(
- List<ServiceDescriptionPair> serviceDescription) {
- ServiceDescriptionPair pair1 = new ServiceDescriptionPair();
- pair1.setName("test");
- pair1.setValue("one");
- serviceDescription.add(pair1);
- }
-
- }
-
- private class TestNotification implements ServiceNotification {
-
- private int serviceUpdates = 0;
- private int serviceAway = 0;
-
- public int getServiceUpdates() {
- return serviceUpdates;
- }
- public int getServiceAway(){
- return serviceAway;
- }
-
- @Override
- public void onServiceGone(ServiceHealth serviceHealth) {
- serviceAway++;
- System.out.println("serviceAway " + serviceAway);
- }
-
- @Override
- public void onServiceUpdate(ServiceHealth serviceHealth) {
- serviceUpdates++;
- System.out.println("healthUpdates " + serviceUpdates);
- }
-
- }
+ Assert.assertEquals(currentNumberOfUpdates + 1, testNotification.getServiceUpdates());
+ Assert.assertTrue(lookup.unregister("testService", "1002", testNotification));
+
+ registrar.stop();
+ lookup.stop();
+ testWait(2000);
+ }
+
+ // @Ignore
+ @org.junit.Test
+ public void testClientUpServiceComesUp() throws Exception {
+ ConnectionNode connection = getMessaging().get(new NodeInfo("osee-jms", new URI(BROKER_URI)));
+ Assert.assertNotNull(connection);
+ ScheduledExecutorService executor = Executors.newScheduledThreadPool(3);
+ RemoteServiceRegistrar registrar = new RemoteServiceRegistrarImpl(connection, executor);
+ registrar.start();
+
+ RemoteServiceLookup lookup = new RemoteServiceLookupImpl(connection, executor);
+ lookup.start();
+
+ TestNotification testNotification = new TestNotification();
+ lookup.register("testService", "1002", testNotification);
+
+ registrar.registerService("testService", "1002", "some.service.id", new URI("tcp://localhost:666"),
+ new TestPopulator(), 30);
+ testWait(3000);
+
+ Assert.assertTrue(testNotification.getServiceUpdates() >= 1);
+ int currentNumberOfUpdates = testNotification.getServiceUpdates();
+
+ testWait(35000);
+
+ Assert.assertEquals(currentNumberOfUpdates + 1, testNotification.getServiceUpdates());
+ Assert.assertTrue(registrar.unregisterService("testService", "1002", "some.service.id"));
+
+ testWait(1000);
+
+ Assert.assertEquals(1, testNotification.getServiceAway());//message from unregister
+
+ testWait(90000);
+
+ Assert.assertEquals(2, testNotification.getServiceAway());//service renewal timout
+
+ Assert.assertEquals(currentNumberOfUpdates + 1, testNotification.getServiceUpdates());
+ Assert.assertTrue(lookup.unregister("testService", "1002", testNotification));
+
+ lookup.stop();
+ registrar.stop();
+ testWait(2000);
+ }
+
+ // @Ignore
+ @org.junit.Test
+ public void testServiceComesUpClientGetsReply() throws Exception {
+ ConnectionNode connection = getMessaging().get(new NodeInfo("osee-jms", new URI(BROKER_URI)));
+ Assert.assertNotNull(connection);
+ ScheduledExecutorService executor = Executors.newScheduledThreadPool(3);
+
+ RemoteServiceRegistrar registrar = new RemoteServiceRegistrarImpl(connection, executor);
+ registrar.start();
+ registrar.registerService("testService", "1002", "some.service.id", new URI("tcp://localhost:666"),
+ new TestPopulator(), 50000);
+
+ testWait(2000);
+ RemoteServiceLookup lookup = new RemoteServiceLookupImpl(connection, executor);
+ lookup.start();
+ TestNotification testNotification = new TestNotification();
+ lookup.register("testService", "1002", testNotification);
+ testWait(1000);
+
+ Assert.assertEquals(1, testNotification.getServiceUpdates());
+
+ Assert.assertTrue(lookup.unregister("testService", "1002", testNotification));
+ Assert.assertTrue(registrar.unregisterService("testService", "1002", "some.service.id"));
+
+ registrar.stop();
+ lookup.stop();
+ testWait(2000);
+ }
+
+ // @Ignore
+ @org.junit.Test
+ public void testReply() throws Exception {
+ ConnectionNode connection = getMessaging().get(new NodeInfo("osee-jms", new URI(BROKER_URI)));
+ TestReplyListener service = new TestReplyListener();
+ TestReplyListener replyReciever = new TestReplyListener();
+ connection.subscribe(TestMessages.replyTopic, service, new OseeMessagingStatusImpl("failed to subscribe",
+ TestMessageServices.class));
+ connection.subscribeToReply(TestMessages.replyTopic, replyReciever);
+ testWait(1000);
+ System.out.println(System.currentTimeMillis());
+ connection.send(TestMessages.replyTopic, "test", new BasicOseeMessagingStatus());
+ System.out.println(System.currentTimeMillis());
+ testWait(5000);
+ System.out.println(System.currentTimeMillis());
+ Assert.assertEquals(1, service.sentReply);
+ Assert.assertEquals(1, replyReciever.receivedReply);
+ connection.unsubscribe(TestMessages.replyTopic, service, new OseeMessagingStatusImpl("failed to subscribe",
+ TestMessageServices.class));
+ }
+
+ private class TestReplyListener extends OseeMessagingListener {
+ int sentReply;
+ int receivedReply;
+ String msg = "back at ya";
+
+ @Override
+ public void process(Object message, Map<String, Object> headers, ReplyConnection replyConnection) {
+ if (replyConnection.isReplyRequested()) {
+ try {
+ System.out.println(System.currentTimeMillis());
+ System.out.println(System.currentTimeMillis() + " reply requested - " + msg);
+ replyConnection.send(msg, null, new BasicOseeMessagingStatus());
+ sentReply++;
+ } catch (OseeCoreException ex) {
+ ex.printStackTrace();
+ }
+ } else {
+ System.out.println(System.currentTimeMillis() + " got a reply - " + message);
+ if (message.toString().equals(msg)) {
+ receivedReply++;
+ }
+ }
+ }
+ }
+
+ private class BasicOseeMessagingStatus implements OseeMessagingStatusCallback {
+ @Override
+ public void fail(Throwable th) {
+ th.printStackTrace();
+ OseeLog.log(BasicOseeMessagingStatus.class, Level.SEVERE, th);
+ }
+
+ @Override
+ public void success() {
+ }
+ }
+
+ private class TestPopulator implements ServiceInfoPopulator {
+
+ @Override
+ public void updateServiceInfo(List<ServiceDescriptionPair> serviceDescription) {
+ ServiceDescriptionPair pair1 = new ServiceDescriptionPair();
+ pair1.setName("test");
+ pair1.setValue("one");
+ serviceDescription.add(pair1);
+ }
+
+ }
+
+ private class TestNotification implements ServiceNotification {
+
+ private int serviceUpdates = 0;
+ private int serviceAway = 0;
+
+ public int getServiceUpdates() {
+ return serviceUpdates;
+ }
+
+ public int getServiceAway() {
+ return serviceAway;
+ }
+
+ @Override
+ public void onServiceGone(ServiceHealth serviceHealth) {
+ serviceAway++;
+ System.out.println("serviceAway " + serviceAway);
+ }
+
+ @Override
+ public void onServiceUpdate(ServiceHealth serviceHealth) {
+ serviceUpdates++;
+ System.out.println("healthUpdates " + serviceUpdates);
+ }
+
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/services/internal/TestMessageServicesMultipleConsumers.java b/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/services/internal/TestMessageServicesMultipleConsumers.java
index e4f83983cf..c128debea7 100644
--- a/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/services/internal/TestMessageServicesMultipleConsumers.java
+++ b/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/services/internal/TestMessageServicesMultipleConsumers.java
@@ -24,82 +24,83 @@ import org.eclipse.osee.framework.messaging.test.msg.TestMessage;
/**
* @author Andrew M. Finkbeiner
- *
*/
public class TestMessageServicesMultipleConsumers extends BaseBrokerTesting implements OseeMessagingStatusCallback {
- private static String BROKER_URI_SERVER = "tcp://localhost:61616";
- private static String BROKER_URI = "tcp://localhost:61616";
-
- @org.junit.Before
- public void startBroker(){
- try {
- startEmbeddedBroker("testBroker", BROKER_URI_SERVER);
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
-
- @org.junit.After
- public void stopBroker(){
- try {
- stopEmbeddedBroker("testBroker", BROKER_URI_SERVER);
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
-
- @org.junit.Test
- public void testMultipleConsumers() throws Exception{
- ConnectionNode connection = getMessaging().get(new NodeInfo("osee-jms", new URI(BROKER_URI)));
-
- List<BasicListener> listeners = new ArrayList<BasicListener>();
- for(int i = 0; i < 20; i++){
- BasicListener listener = new BasicListener(i);
- listeners.add(listener);
- connection.subscribe(TestMessages.JMS_TOPIC, listener, this);
- }
-
- TestMessage message = new TestMessage();
+ private static String BROKER_URI_SERVER = "tcp://localhost:61616";
+ private static String BROKER_URI = "tcp://localhost:61616";
+
+ @Override
+ @org.junit.Before
+ public void startBroker() {
+ try {
+ startEmbeddedBroker("testBroker", BROKER_URI_SERVER);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ @Override
+ @org.junit.After
+ public void stopBroker() {
+ try {
+ stopEmbeddedBroker("testBroker", BROKER_URI_SERVER);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ @org.junit.Test
+ public void testMultipleConsumers() throws Exception {
+ ConnectionNode connection = getMessaging().get(new NodeInfo("osee-jms", new URI(BROKER_URI)));
+
+ List<BasicListener> listeners = new ArrayList<BasicListener>();
+ for (int i = 0; i < 20; i++) {
+ BasicListener listener = new BasicListener(i);
+ listeners.add(listener);
+ connection.subscribe(TestMessages.JMS_TOPIC, listener, this);
+ }
+
+ TestMessage message = new TestMessage();
message.setMessage("TestMessage 1");
connection.send(TestMessages.JMS_TOPIC, message, this);
-
+
testWait(500);
- for(BasicListener listener:listeners){
+ for (BasicListener listener : listeners) {
assertTrue(listener.toString(), listener.isReceived());
}
- }
-
- @org.junit.Test
- public void testMultipleConsumersWithSelector() throws Exception{
- ConnectionNode connection = getMessaging().get(new NodeInfo("osee-jms", new URI(BROKER_URI)));
-
- List<BasicListener> listeners = new ArrayList<BasicListener>();
- for(int i = 0; i < 20; i++){
- BasicListener listener = new BasicListener(i);
- listeners.add(listener);
- connection.subscribe(TestMessages.JMS_TOPIC, listener, String.format("id = %d", i), this);
- }
-
- TestMessage message = new TestMessage();
- message.setMessage("TestMessage 1");
- Properties properties = new Properties();
- properties.put("id", 1);
- connection.send(TestMessages.JMS_TOPIC, message, properties, this);
-
- testWait(500);
-
- int receivedCount = 0;
- for(BasicListener listener:listeners){
- if(listener.isReceived()){
- receivedCount++;
- }
- }
-
- assertTrue(String.format("received %d messages", receivedCount), receivedCount == 1);
- }
-
+ }
+
+ @org.junit.Test
+ public void testMultipleConsumersWithSelector() throws Exception {
+ ConnectionNode connection = getMessaging().get(new NodeInfo("osee-jms", new URI(BROKER_URI)));
+
+ List<BasicListener> listeners = new ArrayList<BasicListener>();
+ for (int i = 0; i < 20; i++) {
+ BasicListener listener = new BasicListener(i);
+ listeners.add(listener);
+ connection.subscribe(TestMessages.JMS_TOPIC, listener, String.format("id = %d", i), this);
+ }
+
+ TestMessage message = new TestMessage();
+ message.setMessage("TestMessage 1");
+ Properties properties = new Properties();
+ properties.put("id", 1);
+ connection.send(TestMessages.JMS_TOPIC, message, properties, this);
+
+ testWait(500);
+
+ int receivedCount = 0;
+ for (BasicListener listener : listeners) {
+ if (listener.isReceived()) {
+ receivedCount++;
+ }
+ }
+
+ assertTrue(String.format("received %d messages", receivedCount), receivedCount == 1);
+ }
+
@Override
public void fail(Throwable th) {
assertTrue(th.getMessage(), false);
@@ -108,5 +109,5 @@ public class TestMessageServicesMultipleConsumers extends BaseBrokerTesting impl
@Override
public void success() {
}
-
+
}
diff --git a/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/test/msg/ObjectFactory.java b/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/test/msg/ObjectFactory.java
index 649b066570..7f268ab118 100644
--- a/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/test/msg/ObjectFactory.java
+++ b/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/test/msg/ObjectFactory.java
@@ -5,7 +5,6 @@
// Generated on: 2010.01.24 at 05:48:12 PM MST
//
-
package org.eclipse.osee.framework.messaging.test.msg;
import javax.xml.bind.JAXBElement;
@@ -13,48 +12,40 @@ import javax.xml.bind.annotation.XmlElementDecl;
import javax.xml.bind.annotation.XmlRegistry;
import javax.xml.namespace.QName;
-
/**
- * This object contains factory methods for each
- * Java content interface and Java element interface
- * generated in the org.eclipse.osee.framework.messaging.test.msg package.
- * <p>An ObjectFactory allows you to programatically
- * construct new instances of the Java representation
- * for XML content. The Java representation of XML
- * content can consist of schema derived interfaces
- * and classes representing the binding of schema
- * type definitions, element declarations and model
- * groups. Factory methods for each of these are
- * provided in this class.
- *
+ * This object contains factory methods for each Java content interface and Java element interface generated in the
+ * org.eclipse.osee.framework.messaging.test.msg package.
+ * <p>
+ * An ObjectFactory allows you to programatically construct new instances of the Java representation for XML content.
+ * The Java representation of XML content can consist of schema derived interfaces and classes representing the binding
+ * of schema type definitions, element declarations and model groups. Factory methods for each of these are provided in
+ * this class.
*/
@XmlRegistry
public class ObjectFactory {
- private final static QName _TestMessage_QNAME = new QName("", "TestMessage");
-
- /**
- * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.eclipse.osee.framework.messaging.test.msg
- *
- */
- public ObjectFactory() {
- }
-
- /**
- * Create an instance of {@link TestMessage }
- *
- */
- public TestMessage createTestMessage() {
- return new TestMessage();
- }
-
- /**
- * Create an instance of {@link JAXBElement }{@code <}{@link TestMessage }{@code >}}
- *
- */
- @XmlElementDecl(namespace = "", name = "TestMessage")
- public JAXBElement<TestMessage> createTestMessage(TestMessage value) {
- return new JAXBElement<TestMessage>(_TestMessage_QNAME, TestMessage.class, null, value);
- }
+ private final static QName _TestMessage_QNAME = new QName("", "TestMessage");
+
+ /**
+ * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package:
+ * org.eclipse.osee.framework.messaging.test.msg
+ */
+ public ObjectFactory() {
+ }
+
+ /**
+ * Create an instance of {@link TestMessage }
+ */
+ public TestMessage createTestMessage() {
+ return new TestMessage();
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link TestMessage }{@code >}
+ */
+ @XmlElementDecl(namespace = "", name = "TestMessage")
+ public JAXBElement<TestMessage> createTestMessage(TestMessage value) {
+ return new JAXBElement<TestMessage>(_TestMessage_QNAME, TestMessage.class, null, value);
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/test/msg/TestMessage.java b/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/test/msg/TestMessage.java
index 138ff33c41..8eb7ad5738 100644
--- a/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/test/msg/TestMessage.java
+++ b/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/test/msg/TestMessage.java
@@ -5,7 +5,6 @@
// Generated on: 2010.01.24 at 05:48:12 PM MST
//
-
package org.eclipse.osee.framework.messaging.test.msg;
import javax.xml.bind.annotation.XmlAccessType;
@@ -13,11 +12,11 @@ import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
-
/**
- * <p>Java class for TestMessage complex type.
- *
- * <p>The following schema fragment specifies the expected content contained within this class.
+ * <p>
+ * Java class for TestMessage complex type.
+ * <p>
+ * The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="TestMessage">
@@ -31,67 +30,50 @@ import javax.xml.bind.annotation.XmlType;
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
- *
- *
*/
@XmlAccessorType(XmlAccessType.FIELD)
-@XmlType(name = "TestMessage", propOrder = {
- "message",
- "anotherMessage"
-})
+@XmlType(name = "TestMessage", propOrder = {"message", "anotherMessage"})
public class TestMessage {
- @XmlElement(required = true)
- protected String message;
- @XmlElement(required = true)
- protected String anotherMessage;
+ @XmlElement(required = true)
+ protected String message;
+ @XmlElement(required = true)
+ protected String anotherMessage;
- /**
- * Gets the value of the message property.
- *
- * @return
- * possible object is
- * {@link String }
- *
- */
- public String getMessage() {
- return message;
- }
+ /**
+ * Gets the value of the message property.
+ *
+ * @return possible object is {@link String }
+ */
+ public String getMessage() {
+ return message;
+ }
- /**
- * Sets the value of the message property.
- *
- * @param value
- * allowed object is
- * {@link String }
- *
- */
- public void setMessage(String value) {
- this.message = value;
- }
+ /**
+ * Sets the value of the message property.
+ *
+ * @param value allowed object is {@link String }
+ */
+ public void setMessage(String value) {
+ this.message = value;
+ }
- /**
- * Gets the value of the anotherMessage property.
- *
- * @return
- * possible object is
- * {@link String }
- *
- */
- public String getAnotherMessage() {
- return anotherMessage;
- }
+ /**
+ * Gets the value of the anotherMessage property.
+ *
+ * @return possible object is {@link String }
+ */
+ public String getAnotherMessage() {
+ return anotherMessage;
+ }
- /**
- * Sets the value of the anotherMessage property.
- *
- * @param value
- * allowed object is
- * {@link String }
- *
- */
- public void setAnotherMessage(String value) {
- this.anotherMessage = value;
- }
+ /**
+ * Sets the value of the anotherMessage property.
+ *
+ * @param value allowed object is {@link String }
+ */
+ public void setAnotherMessage(String value) {
+ this.anotherMessage = value;
+ }
}

Back to the top