Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrescobar2010-03-12 13:27:25 -0500
committerrescobar2010-03-12 13:27:25 -0500
commit205aa057fa925d37a3a5375aa8418b9567e99c6d (patch)
treed33f80b9f727c479b8031aeb352494c38ad9878d /plugins/org.eclipse.osee.framework.messaging.test
parent0e6d2b595cfb4d54eccdf3479e7c5d74d9c736a5 (diff)
downloadorg.eclipse.osee-205aa057fa925d37a3a5375aa8418b9567e99c6d.tar.gz
org.eclipse.osee-205aa057fa925d37a3a5375aa8418b9567e99c6d.tar.xz
org.eclipse.osee-205aa057fa925d37a3a5375aa8418b9567e99c6d.zip
Diffstat (limited to 'plugins/org.eclipse.osee.framework.messaging.test')
-rw-r--r--plugins/org.eclipse.osee.framework.messaging.test/.classpath7
-rw-r--r--plugins/org.eclipse.osee.framework.messaging.test/.project28
-rw-r--r--plugins/org.eclipse.osee.framework.messaging.test/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--plugins/org.eclipse.osee.framework.messaging.test/META-INF/MANIFEST.MF12
-rw-r--r--plugins/org.eclipse.osee.framework.messaging.test/Messaging_IntegrationSuite.launch15
-rw-r--r--plugins/org.eclipse.osee.framework.messaging.test/Messaging_TestBrokerServiceInterruptions.launch15
-rw-r--r--plugins/org.eclipse.osee.framework.messaging.test/Messaging_TestMessageServices.launch15
-rw-r--r--plugins/org.eclipse.osee.framework.messaging.test/Messaging_TestSendingAndRecieving.launch15
-rw-r--r--plugins/org.eclipse.osee.framework.messaging.test/README_JUNIT.txt9
-rw-r--r--plugins/org.eclipse.osee.framework.messaging.test/build.properties4
-rw-r--r--plugins/org.eclipse.osee.framework.messaging.test/jaxb/testMessages.xsd15
-rw-r--r--plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/internal/BaseBrokerTesting.java224
-rw-r--r--plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/internal/DefaultNodeInfos.java33
-rw-r--r--plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/internal/IntegrationSuite.java20
-rw-r--r--plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/internal/MessageStatusTest.java77
-rw-r--r--plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/internal/TestBrokerServiceInterruptions.java101
-rw-r--r--plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/internal/TestMessages.java82
-rw-r--r--plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/internal/TestSendingAndRecieving.java121
-rw-r--r--plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/services/internal/TestMessageServices.java262
-rw-r--r--plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/test/msg/ObjectFactory.java60
-rw-r--r--plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/test/msg/TestMessage.java97
21 files changed, 1219 insertions, 0 deletions
diff --git a/plugins/org.eclipse.osee.framework.messaging.test/.classpath b/plugins/org.eclipse.osee.framework.messaging.test/.classpath
new file mode 100644
index 0000000000..ad32c83a78
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.messaging.test/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.osee.framework.messaging.test/.project b/plugins/org.eclipse.osee.framework.messaging.test/.project
new file mode 100644
index 0000000000..d3ff2b3c04
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.messaging.test/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.osee.framework.messaging.test</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.osee.framework.messaging.test/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.osee.framework.messaging.test/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000000..42875f32e0
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.messaging.test/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+#Thu Jul 30 07:58:59 MST 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/plugins/org.eclipse.osee.framework.messaging.test/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.messaging.test/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..cbfbc0dccf
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.messaging.test/META-INF/MANIFEST.MF
@@ -0,0 +1,12 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Test Fragment
+Bundle-SymbolicName: org.eclipse.osee.framework.messaging.test;singleton:=true
+Bundle-Version: 0.9.0.qualifier
+Fragment-Host: org.eclipse.osee.framework.messaging;bundle-version="0.9.0.qualifier"
+Require-Bundle: org.junit4;bundle-version="4.5.0",
+ org.eclipse.osee.framework.jdk.core
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-ActivationPolicy: lazy
+Bundle-Vendor: Eclipse.org
+Import-Package: org.eclipse.osee.framework.jdk.core.util
diff --git a/plugins/org.eclipse.osee.framework.messaging.test/Messaging_IntegrationSuite.launch b/plugins/org.eclipse.osee.framework.messaging.test/Messaging_IntegrationSuite.launch
new file mode 100644
index 0000000000..3b98f7567b
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.messaging.test/Messaging_IntegrationSuite.launch
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/internal/IntegrationSuite.java"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="1"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
+<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
+<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
+<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.osee.framework.messaging.internal.IntegrationSuite"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.osee.framework.messaging.test"/>
+</launchConfiguration>
diff --git a/plugins/org.eclipse.osee.framework.messaging.test/Messaging_TestBrokerServiceInterruptions.launch b/plugins/org.eclipse.osee.framework.messaging.test/Messaging_TestBrokerServiceInterruptions.launch
new file mode 100644
index 0000000000..0be3d1170c
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.messaging.test/Messaging_TestBrokerServiceInterruptions.launch
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/internal/TestBrokerServiceInterruptions.java"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="1"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
+<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
+<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
+<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.osee.framework.messaging.internal.TestBrokerServiceInterruptions"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.osee.framework.messaging.test"/>
+</launchConfiguration>
diff --git a/plugins/org.eclipse.osee.framework.messaging.test/Messaging_TestMessageServices.launch b/plugins/org.eclipse.osee.framework.messaging.test/Messaging_TestMessageServices.launch
new file mode 100644
index 0000000000..b916d5d033
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.messaging.test/Messaging_TestMessageServices.launch
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/services/internal/TestMessageServices.java"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="1"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
+<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
+<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
+<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.osee.framework.messaging.services.internal.TestMessageServices"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.osee.framework.messaging.test"/>
+</launchConfiguration>
diff --git a/plugins/org.eclipse.osee.framework.messaging.test/Messaging_TestSendingAndRecieving.launch b/plugins/org.eclipse.osee.framework.messaging.test/Messaging_TestSendingAndRecieving.launch
new file mode 100644
index 0000000000..feb3f9c7a9
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.messaging.test/Messaging_TestSendingAndRecieving.launch
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/internal/TestSendingAndRecieving.java"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="1"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
+<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
+<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
+<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.osee.framework.messaging.internal.TestSendingAndRecieving"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.osee.framework.messaging.test"/>
+</launchConfiguration>
diff --git a/plugins/org.eclipse.osee.framework.messaging.test/README_JUNIT.txt b/plugins/org.eclipse.osee.framework.messaging.test/README_JUNIT.txt
new file mode 100644
index 0000000000..ffdb0c462e
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.messaging.test/README_JUNIT.txt
@@ -0,0 +1,9 @@
+The tests in this package require the following bundles to be INSTALLED.
+
+jms.activemq.launch
+jms.libraries
+
+They can be checked out from svn then exported and put into the '<eclipse_install>/dropins' folder.
+
+These bundles allow us to easily start and stop a message broker using an eclipse application.
+This is required to run several of our tests. \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.messaging.test/build.properties b/plugins/org.eclipse.osee.framework.messaging.test/build.properties
new file mode 100644
index 0000000000..41eb6ade2b
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.messaging.test/build.properties
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/plugins/org.eclipse.osee.framework.messaging.test/jaxb/testMessages.xsd b/plugins/org.eclipse.osee.framework.messaging.test/jaxb/testMessages.xsd
new file mode 100644
index 0000000000..91b56e4b36
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.messaging.test/jaxb/testMessages.xsd
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
+ jxb:version="2.0">
+
+<xsd:element name="TestMessage" type="TestMessage"/>
+
+<xsd:complexType name="TestMessage">
+ <xsd:sequence>
+ <xsd:element name="message" type="xsd:string"/>
+ <xsd:element name="anotherMessage" type="xsd:string"/>
+ </xsd:sequence>
+</xsd:complexType>
+
+</xsd:schema>
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
new file mode 100644
index 0000000000..f641cf31b8
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/internal/BaseBrokerTesting.java
@@ -0,0 +1,224 @@
+/*
+ * Created on Jul 30, 2009
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.framework.messaging.internal;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.logging.Level;
+import org.apache.activemq.broker.BrokerService;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.jdk.core.util.Lib;
+import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.messaging.ConnectionNode;
+import org.eclipse.osee.framework.messaging.MessageService;
+import org.eclipse.osee.framework.messaging.OseeMessagingListener;
+import org.eclipse.osee.framework.messaging.ReplyConnection;
+import org.eclipse.osee.framework.messaging.SystemTopic;
+import org.eclipse.osee.framework.messaging.test.msg.TestMessage;
+
+/**
+ * @author b1528444
+ */
+public class BaseBrokerTesting {
+
+ private MessageServiceProviderImpl messageServiceProviderImpl = null;
+ private ConcurrentHashMap<String, BrokerService> brokers;
+ private Thread[] threads;
+
+ @org.junit.Before
+ public void beforeTest() {
+ messageServiceProviderImpl = new MessageServiceProviderImpl(Thread.currentThread().getContextClassLoader());
+ brokers = new ConcurrentHashMap<String, BrokerService>();
+ try {
+ messageServiceProviderImpl.start();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+
+ }
+
+ @org.junit.After
+ public void afterTest() {
+ try {
+ messageServiceProviderImpl.stop();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ protected void startEmbeddedBroker(String brokerName, String brokerURI) throws Exception {
+ BrokerService broker = new BrokerService();
+ broker.setBrokerName(brokerName);
+ broker.setPersistent(false);
+ broker.setUseShutdownHook(true);
+ broker.addConnector(brokerURI);
+ broker.start();
+ brokers.put(brokerURI, broker);
+ }
+
+ public void testWait(long timeMS) {
+ try {
+ Thread.sleep(timeMS);
+ } catch (InterruptedException ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ protected void stopEmbeddedBroker(String brokerName, String brokerURI) throws Exception {
+ BrokerService broker = brokers.get(brokerURI);
+ if (broker != null) {
+ broker.stop();
+ }
+ }
+
+ protected void startBroker() {
+ try {
+ String really = "file:C:\\Program Files\\OSEE_3.5.1\\0_9_0\\";// System.getProperty("eclipse.home.location");
+ URL url = new URL(really);
+ String exe = null;
+ if (Lib.isWindows()) {
+ exe = "eclipse.exe";
+ } else {
+ exe = "eclipse";
+ }
+ 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));
+ Thread.sleep(30000);
+ } catch (MalformedURLException ex) {
+ OseeLog.log(BaseBrokerTesting.class, Level.SEVERE, ex);
+ fail(ex.getMessage());
+ } catch (IOException ex) {
+ OseeLog.log(BaseBrokerTesting.class, Level.SEVERE, ex);
+ fail(ex.getMessage());
+ } catch (InterruptedException ex) {
+ OseeLog.log(BaseBrokerTesting.class, Level.SEVERE, ex);
+ fail(ex.getMessage());
+ }
+ }
+
+ public class OutputReader implements Runnable {
+
+ private PrintStream printStream;
+ private InputStream input;
+
+ public OutputReader(PrintStream printStream, InputStream input) {
+ super();
+ this.printStream = printStream;
+ this.input = input;
+
+ }
+
+ public void run() {
+ try {
+ 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();
+ }
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ } finally {
+ try {
+ input.close();
+ printStream.flush();
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+ }
+ }
+ }
+
+
+
+ protected void stopBroker() {
+ try {
+ 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);
+ // fail(ex.getMessage());
+ } catch (OseeCoreException ex) {
+ OseeLog.log(BaseBrokerTesting.class, Level.SEVERE, ex);
+ // fail(ex.getMessage());
+ }
+ }
+
+ protected final MessageService getMessaging() {
+ MessageService messaging = null;
+ try {
+ messaging = messageServiceProviderImpl.getMessageService();
+ } catch (OseeCoreException ex) {
+ fail("Failed to get messaging service. " + ex.getMessage());
+ }
+ assertTrue(messaging != null);
+ return messaging;
+ }
+
+ protected void testJMSSendShouldFail(MessageService messaging) {
+ MessageStatusTest status = new MessageStatusTest(false);
+ try {
+ messaging.get(DefaultNodeInfos.OSEE_JMS_DEFAULT).send(TestMessages.test, "test", status);
+ } catch (OseeCoreException ex) {
+ OseeLog.log(BaseBrokerTesting.class, Level.SEVERE, ex);
+ }
+ status.waitForStatus(5000);
+ }
+
+ protected void testJMSSendShouldPass(MessageService messaging) {
+ MessageStatusTest status = new MessageStatusTest(true);
+ try {
+ messaging.get(DefaultNodeInfos.OSEE_JMS_DEFAULT).send(TestMessages.test, "test", status);
+ } catch (OseeCoreException ex) {
+ OseeLog.log(BaseBrokerTesting.class, Level.SEVERE, ex);
+ }
+ status.waitForStatus(5000);
+ }
+
+ 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) {
+ 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
+ }
+
+ protected void testJMSSubscribeShouldPass(MessageService messaging) throws OseeCoreException {
+ MessageStatusTest status = new MessageStatusTest(true);
+ ConnectionNode node = messaging.get(DefaultNodeInfos.OSEE_JMS_DEFAULT);
+ node.subscribe(TestMessages.test2, 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());
+ }
+ }, status);
+ status.waitForStatus(5000);
+ }
+}
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
new file mode 100644
index 0000000000..10cf3503b3
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/internal/DefaultNodeInfos.java
@@ -0,0 +1,33 @@
+/*
+ * Created on Jan 20, 2010
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.framework.messaging.internal;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.logging.Level;
+import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.messaging.NodeInfo;
+
+/**
+ * @author b1528444
+ *
+ */
+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);
+ }
+ }
+
+}
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
new file mode 100644
index 0000000000..71ffb07ca1
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/internal/IntegrationSuite.java
@@ -0,0 +1,20 @@
+/*
+ * Created on Oct 20, 2009
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+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
+})
+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
new file mode 100644
index 0000000000..367fc77b69
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/internal/MessageStatusTest.java
@@ -0,0 +1,77 @@
+/*
+ * Created on Oct 19, 2009
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.framework.messaging.internal;
+
+import org.eclipse.osee.framework.messaging.OseeMessagingStatusCallback;
+
+/**
+ * @author b1528444
+ *
+ */
+public class MessageStatusTest implements OseeMessagingStatusCallback {
+
+ private volatile boolean isDone = false;
+ private volatile boolean timedOut = false;
+ private volatile boolean waitedOnStatus = false;
+ private boolean shouldPass;
+
+ 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;
+ }
+
+ 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
new file mode 100644
index 0000000000..06d608be7d
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/internal/TestBrokerServiceInterruptions.java
@@ -0,0 +1,101 @@
+/*
+ * Created on Jul 30, 2009
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.framework.messaging.internal;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import org.eclipse.osee.framework.messaging.ConnectionListener;
+import org.eclipse.osee.framework.messaging.ConnectionNode;
+
+
+/**
+ * @author b1528444
+ */
+public class TestBrokerServiceInterruptions extends BaseBrokerTesting {
+
+// @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();
+
+ testJMSSendShouldPass(getMessaging());
+
+
+ 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 boolean isConnected = false;
+
+ @Override
+ public void connected(ConnectionNode node) {
+ System.out.println("connected from test listner");
+ isConnected = true;
+ }
+
+ public boolean isConnected() {
+ return isConnected;
+ }
+
+ @Override
+ public void notConnected(ConnectionNode node) {
+ System.out.println("not connected from test listener");
+ isConnected = false;
+ }
+ }
+
+
+// @Ignore
+ @org.junit.Test
+ public void testBrokerGoingDownSendFails() throws Exception {
+ startBroker();
+
+ testJMSSendShouldPass(getMessaging());
+
+ stopBroker();
+
+ testJMSSendShouldFail(getMessaging());
+ }
+
+// @Ignore
+ @org.junit.Test
+ public void testBrokerGoingDownSubscribeFails() throws Exception {
+ startBroker();
+
+ testJMSSubscribeShouldPass(getMessaging());
+
+ stopBroker();
+
+ 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
new file mode 100644
index 0000000000..0c2b378e9d
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/internal/TestMessages.java
@@ -0,0 +1,82 @@
+/*
+ * Created on Jan 25, 2010
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.framework.messaging.internal;
+
+import org.eclipse.osee.framework.messaging.MessageID;
+import org.eclipse.osee.framework.messaging.test.msg.TestMessage;
+
+/**
+ * @author b1528444
+ *
+ */
+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;
+ private String destination;
+
+ TestMessages(boolean isTopic, String guid, String name, Class<?> clazz, boolean isReplyRequired){
+ this.guid = guid;
+ this.name = name;
+ this.clazz = clazz;
+ this.isReplyRequired = isReplyRequired;
+ if(isTopic){
+ destination = "topic:"+guid;
+ } else {
+ destination = guid;
+ }
+ }
+
+ TestMessages(boolean isTopic, String guid,String name, Class<?> clazz){
+ this.name = name;
+ this.clazz = clazz;
+ this.isReplyRequired = false;
+ this.guid = guid;
+ if(isTopic){
+ destination = "topic:"+guid;
+ } else {
+ destination = guid;
+ }
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public Class<?> getSerializationClass() {
+ return clazz;
+ }
+
+ @Override
+ public boolean isReplyRequired() {
+ return isReplyRequired;
+ }
+
+ @Override
+ public String getGuid() {
+ return guid;
+ }
+
+ @Override
+ public String getMessageDestination() {
+ return destination;
+ }
+
+ @Override
+ public boolean isTopic() {
+ return true;
+ }
+}
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
new file mode 100644
index 0000000000..98bf710081
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/internal/TestSendingAndRecieving.java
@@ -0,0 +1,121 @@
+/*
+ * Created on Jul 30, 2009
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.framework.messaging.internal;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import java.util.Map;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.messaging.OseeMessagingListener;
+import org.eclipse.osee.framework.messaging.ReplyConnection;
+import org.eclipse.osee.framework.messaging.test.msg.TestMessage;
+
+/**
+ * @author b1528444
+ */
+public class TestSendingAndRecieving extends BaseBrokerTesting {
+
+
+ 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);
+
+ }
+ }
+ });
+ sending.start();
+ Thread.sleep(10000);
+
+ assertTrue(String.format("sent[%d] != recieved[%d]",
+ messagesToSend, messagesReceived),
+ messagesToSend == messagesReceived);
+
+ } 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);
+
+ assertTrue(String.format("sent[%d] != recieved[%d]",
+ messagesToSend, messagesReceived),
+ messagesToSend == messagesReceived);
+
+ } 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/TestMessageServices.java b/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/services/internal/TestMessageServices.java
new file mode 100644
index 0000000000..b3521c5a50
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/services/internal/TestMessageServices.java
@@ -0,0 +1,262 @@
+/*
+ * Created on Jan 26, 2010
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.framework.messaging.services.internal;
+
+import java.net.URI;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.logging.Level;
+import junit.framework.Assert;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.messaging.ConnectionNode;
+import org.eclipse.osee.framework.messaging.NodeInfo;
+import org.eclipse.osee.framework.messaging.OseeMessagingListener;
+import org.eclipse.osee.framework.messaging.OseeMessagingStatusCallback;
+import org.eclipse.osee.framework.messaging.ReplyConnection;
+import org.eclipse.osee.framework.messaging.internal.BaseBrokerTesting;
+import org.eclipse.osee.framework.messaging.internal.TestMessages;
+import org.eclipse.osee.framework.messaging.services.RemoteServiceLookup;
+import org.eclipse.osee.framework.messaging.services.RemoteServiceRegistrar;
+import org.eclipse.osee.framework.messaging.services.ServiceInfoPopulator;
+import org.eclipse.osee.framework.messaging.services.ServiceNotification;
+import org.eclipse.osee.framework.messaging.services.messages.ServiceDescriptionPair;
+import org.eclipse.osee.framework.messaging.services.messages.ServiceHealth;
+
+/**
+ * @author b1528444
+ *
+ */
+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);
+
+ 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/test/msg/ObjectFactory.java b/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/test/msg/ObjectFactory.java
new file mode 100644
index 0000000000..18ff904d25
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/test/msg/ObjectFactory.java
@@ -0,0 +1,60 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2010.01.24 at 05:48:12 PM MST
+//
+
+
+package org.eclipse.osee.framework.messaging.test.msg;
+
+import javax.xml.bind.JAXBElement;
+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.
+ *
+ */
+@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);
+ }
+
+}
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
new file mode 100644
index 0000000000..bcb99017dd
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.messaging.test/src/org/eclipse/osee/framework/messaging/test/msg/TestMessage.java
@@ -0,0 +1,97 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vJAXB 2.1.10 in JDK 6
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// 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;
+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.
+ *
+ * <pre>
+ * &lt;complexType name="TestMessage">
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="message" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * &lt;element name="anotherMessage" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "TestMessage", propOrder = {
+ "message",
+ "anotherMessage"
+})
+public class TestMessage {
+
+ @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;
+ }
+
+ /**
+ * 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;
+ }
+
+ /**
+ * 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