Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2012-07-19 04:22:04 -0400
committerEike Stepper2012-07-19 04:22:04 -0400
commit1460904fd3c193ffaf809913b2983a400fce9d94 (patch)
tree72f3a17b75fedba3ae1060df1d32c9c7889be954 /plugins/org.eclipse.net4j.jms.tests
parent5f360965ae87478e0681899bf310a210cafc2c44 (diff)
downloadcdo-1460904fd3c193ffaf809913b2983a400fce9d94.tar.gz
cdo-1460904fd3c193ffaf809913b2983a400fce9d94.tar.xz
cdo-1460904fd3c193ffaf809913b2983a400fce9d94.zip
Fix line endings in master (dos2unix)
Diffstat (limited to 'plugins/org.eclipse.net4j.jms.tests')
-rw-r--r--plugins/org.eclipse.net4j.jms.tests/.settings/org.eclipse.core.resources.prefs6
-rw-r--r--plugins/org.eclipse.net4j.jms.tests/config/org.eclipse.net4j.jms.server.jdbc.properties30
-rw-r--r--plugins/org.eclipse.net4j.jms.tests/copyright.txt14
-rw-r--r--plugins/org.eclipse.net4j.jms.tests/plugin.properties22
-rw-r--r--plugins/org.eclipse.net4j.jms.tests/src/org/eclipse/net4j/jms/tests/JMSSeparatedTest.java294
-rw-r--r--plugins/org.eclipse.net4j.jms.tests/src/org/eclipse/net4j/jms/tests/JMSTest.java264
6 files changed, 315 insertions, 315 deletions
diff --git a/plugins/org.eclipse.net4j.jms.tests/.settings/org.eclipse.core.resources.prefs b/plugins/org.eclipse.net4j.jms.tests/.settings/org.eclipse.core.resources.prefs
index 182f196415..73cb07cd04 100644
--- a/plugins/org.eclipse.net4j.jms.tests/.settings/org.eclipse.core.resources.prefs
+++ b/plugins/org.eclipse.net4j.jms.tests/.settings/org.eclipse.core.resources.prefs
@@ -1,3 +1,3 @@
-#Mon Jul 04 12:55:53 CEST 2011
-eclipse.preferences.version=1
-encoding//model/org.eclipse.emf.cdo.defs.ecorediag=UTF-8
+#Mon Jul 04 12:55:53 CEST 2011
+eclipse.preferences.version=1
+encoding//model/org.eclipse.emf.cdo.defs.ecorediag=UTF-8
diff --git a/plugins/org.eclipse.net4j.jms.tests/config/org.eclipse.net4j.jms.server.jdbc.properties b/plugins/org.eclipse.net4j.jms.tests/config/org.eclipse.net4j.jms.server.jdbc.properties
index da2a631d82..644309a4db 100644
--- a/plugins/org.eclipse.net4j.jms.tests/config/org.eclipse.net4j.jms.server.jdbc.properties
+++ b/plugins/org.eclipse.net4j.jms.tests/config/org.eclipse.net4j.jms.server.jdbc.properties
@@ -1,15 +1,15 @@
-# Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Eike Stepper - initial API and implementation
-
-store.instanceID = TEST0001
-store.dbAdapter = derby
-
-datasource.class = org.apache.derby.jdbc.EmbeddedDataSource
-datasource.databaseName = C:/temp/jmsdb
-datasource.createDatabase = create
+# Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Eike Stepper - initial API and implementation
+
+store.instanceID = TEST0001
+store.dbAdapter = derby
+
+datasource.class = org.apache.derby.jdbc.EmbeddedDataSource
+datasource.databaseName = C:/temp/jmsdb
+datasource.createDatabase = create
diff --git a/plugins/org.eclipse.net4j.jms.tests/copyright.txt b/plugins/org.eclipse.net4j.jms.tests/copyright.txt
index 8f6328980e..0a0f67e6d7 100644
--- a/plugins/org.eclipse.net4j.jms.tests/copyright.txt
+++ b/plugins/org.eclipse.net4j.jms.tests/copyright.txt
@@ -1,8 +1,8 @@
-Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Eclipse Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/epl-v10.html
-
-Contributors:
+Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+All rights reserved. This program and the accompanying materials
+are made available under the terms of the Eclipse Public License v1.0
+which accompanies this distribution, and is available at
+http://www.eclipse.org/legal/epl-v10.html
+
+Contributors:
Eike Stepper - initial API and implementation \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.jms.tests/plugin.properties b/plugins/org.eclipse.net4j.jms.tests/plugin.properties
index 104669f754..f71abbe0a6 100644
--- a/plugins/org.eclipse.net4j.jms.tests/plugin.properties
+++ b/plugins/org.eclipse.net4j.jms.tests/plugin.properties
@@ -1,11 +1,11 @@
-# Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Eike Stepper - initial API and implementation
-
-pluginName = Net4j JMS Provider Tests (Experimental)
-providerName = Eclipse Modeling Project
+# Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# Eike Stepper - initial API and implementation
+
+pluginName = Net4j JMS Provider Tests (Experimental)
+providerName = Eclipse Modeling Project
diff --git a/plugins/org.eclipse.net4j.jms.tests/src/org/eclipse/net4j/jms/tests/JMSSeparatedTest.java b/plugins/org.eclipse.net4j.jms.tests/src/org/eclipse/net4j/jms/tests/JMSSeparatedTest.java
index b774c18023..0f84f27fb2 100644
--- a/plugins/org.eclipse.net4j.jms.tests/src/org/eclipse/net4j/jms/tests/JMSSeparatedTest.java
+++ b/plugins/org.eclipse.net4j.jms.tests/src/org/eclipse/net4j/jms/tests/JMSSeparatedTest.java
@@ -1,147 +1,147 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.net4j.jms.tests;
-
-import org.eclipse.net4j.Net4jUtil;
-import org.eclipse.net4j.connector.IConnector;
-import org.eclipse.net4j.db.IDBAdapter;
-import org.eclipse.net4j.db.derby.EmbeddedDerbyAdapter;
-import org.eclipse.net4j.jms.JMSInitialContext;
-import org.eclipse.net4j.jms.admin.IJMSAdmin;
-import org.eclipse.net4j.jms.admin.JMSAdminUtil;
-import org.eclipse.net4j.jms.internal.server.Server;
-import org.eclipse.net4j.jms.server.IStore;
-import org.eclipse.net4j.jms.server.JMSServerUtil;
-import org.eclipse.net4j.jms.server.jdbc.JDBCUtil;
-import org.eclipse.net4j.tcp.TCPUtil;
-import org.eclipse.net4j.util.concurrent.ConcurrencyUtil;
-import org.eclipse.net4j.util.container.IManagedContainer;
-import org.eclipse.net4j.util.container.ManagedContainer;
-import org.eclipse.net4j.util.io.IOUtil;
-import org.eclipse.net4j.util.om.OMPlatform;
-import org.eclipse.net4j.util.om.log.PrintLogHandler;
-import org.eclipse.net4j.util.om.trace.PrintTraceHandler;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.ObjectMessage;
-import javax.jms.Session;
-import javax.naming.Context;
-import javax.naming.NamingException;
-
-public class JMSSeparatedTest
-{
- public static void main(String[] args) throws Exception
- {
- try
- {
- Context context = init();
- ConnectionFactory connectionFactory = (ConnectionFactory)context.lookup("net4j.jms.ConnectionFactory"); //$NON-NLS-1$
- Destination destination = (Destination)context.lookup("StockTopic"); //$NON-NLS-1$
-
- Connection connection = connectionFactory.createConnection();
- Session session = connection.createSession(true, 0);
-
- MessageProducer publisher = session.createProducer(destination);
- MessageConsumer subscriber1 = session.createConsumer(destination);
- MessageConsumer subscriber2 = session.createConsumer(destination);
- subscriber1.setMessageListener(new MessageLogger("subscriber1")); //$NON-NLS-1$
- subscriber2.setMessageListener(new MessageLogger("subscriber2")); //$NON-NLS-1$
-
- connection.start();
-
- publisher.send(session.createObjectMessage("Message 1")); //$NON-NLS-1$
- publisher.send(session.createObjectMessage("Message 2")); //$NON-NLS-1$
- publisher.send(session.createObjectMessage("Message 3")); //$NON-NLS-1$
- publisher.send(session.createObjectMessage("Message 4")); //$NON-NLS-1$
-
- session.commit();
- }
- finally
- {
- ConcurrencyUtil.sleep(500);
- Server.INSTANCE.deactivate();
- }
- }
-
- private static Context init() throws Exception
- {
- OMPlatform.INSTANCE.addLogHandler(PrintLogHandler.CONSOLE);
- OMPlatform.INSTANCE.addTraceHandler(PrintTraceHandler.CONSOLE);
- OMPlatform.INSTANCE.setDebugging(true);
-
- initServer();
- return initClient();
- }
-
- private static void initServer() throws Exception
- {
- IDBAdapter.REGISTRY.put(EmbeddedDerbyAdapter.NAME, new EmbeddedDerbyAdapter());
- IStore store = JDBCUtil.getStore();
- Server.INSTANCE.setStore(store);
- Server.INSTANCE.activate();
-
- IManagedContainer serverContainer = new ManagedContainer();
- Net4jUtil.prepareContainer(serverContainer);
- TCPUtil.prepareContainer(serverContainer);
- JMSServerUtil.prepareContainer(serverContainer);
-
- TCPUtil.getAcceptor(serverContainer, null);
- }
-
- private static Context initClient() throws NamingException
- {
- IManagedContainer clientContainer = new ManagedContainer();
- Net4jUtil.prepareContainer(clientContainer);
- TCPUtil.prepareContainer(clientContainer);
-
- IConnector connector = TCPUtil.getConnector(clientContainer, "localhost"); //$NON-NLS-1$
-
- IJMSAdmin admin = JMSAdminUtil.createAdmin(connector);
- admin.createQueue("StockQueue"); //$NON-NLS-1$
- admin.createTopic("StockTopic"); //$NON-NLS-1$
-
- return new JMSInitialContext(clientContainer);
- }
-
- /**
- * @author Eike Stepper
- */
- private static final class MessageLogger implements MessageListener
- {
- private String name;
-
- public MessageLogger(String name)
- {
- this.name = name;
- }
-
- public void onMessage(Message message)
- {
- try
- {
- Object object = ((ObjectMessage)message).getObject();
- IOUtil.OUT().println("\n------> MESSAGE for " + name + ": " + object + "\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- message.acknowledge();
- }
- catch (JMSException ex)
- {
- IOUtil.print(ex);
- }
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.jms.tests;
+
+import org.eclipse.net4j.Net4jUtil;
+import org.eclipse.net4j.connector.IConnector;
+import org.eclipse.net4j.db.IDBAdapter;
+import org.eclipse.net4j.db.derby.EmbeddedDerbyAdapter;
+import org.eclipse.net4j.jms.JMSInitialContext;
+import org.eclipse.net4j.jms.admin.IJMSAdmin;
+import org.eclipse.net4j.jms.admin.JMSAdminUtil;
+import org.eclipse.net4j.jms.internal.server.Server;
+import org.eclipse.net4j.jms.server.IStore;
+import org.eclipse.net4j.jms.server.JMSServerUtil;
+import org.eclipse.net4j.jms.server.jdbc.JDBCUtil;
+import org.eclipse.net4j.tcp.TCPUtil;
+import org.eclipse.net4j.util.concurrent.ConcurrencyUtil;
+import org.eclipse.net4j.util.container.IManagedContainer;
+import org.eclipse.net4j.util.container.ManagedContainer;
+import org.eclipse.net4j.util.io.IOUtil;
+import org.eclipse.net4j.util.om.OMPlatform;
+import org.eclipse.net4j.util.om.log.PrintLogHandler;
+import org.eclipse.net4j.util.om.trace.PrintTraceHandler;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
+import javax.jms.MessageProducer;
+import javax.jms.ObjectMessage;
+import javax.jms.Session;
+import javax.naming.Context;
+import javax.naming.NamingException;
+
+public class JMSSeparatedTest
+{
+ public static void main(String[] args) throws Exception
+ {
+ try
+ {
+ Context context = init();
+ ConnectionFactory connectionFactory = (ConnectionFactory)context.lookup("net4j.jms.ConnectionFactory"); //$NON-NLS-1$
+ Destination destination = (Destination)context.lookup("StockTopic"); //$NON-NLS-1$
+
+ Connection connection = connectionFactory.createConnection();
+ Session session = connection.createSession(true, 0);
+
+ MessageProducer publisher = session.createProducer(destination);
+ MessageConsumer subscriber1 = session.createConsumer(destination);
+ MessageConsumer subscriber2 = session.createConsumer(destination);
+ subscriber1.setMessageListener(new MessageLogger("subscriber1")); //$NON-NLS-1$
+ subscriber2.setMessageListener(new MessageLogger("subscriber2")); //$NON-NLS-1$
+
+ connection.start();
+
+ publisher.send(session.createObjectMessage("Message 1")); //$NON-NLS-1$
+ publisher.send(session.createObjectMessage("Message 2")); //$NON-NLS-1$
+ publisher.send(session.createObjectMessage("Message 3")); //$NON-NLS-1$
+ publisher.send(session.createObjectMessage("Message 4")); //$NON-NLS-1$
+
+ session.commit();
+ }
+ finally
+ {
+ ConcurrencyUtil.sleep(500);
+ Server.INSTANCE.deactivate();
+ }
+ }
+
+ private static Context init() throws Exception
+ {
+ OMPlatform.INSTANCE.addLogHandler(PrintLogHandler.CONSOLE);
+ OMPlatform.INSTANCE.addTraceHandler(PrintTraceHandler.CONSOLE);
+ OMPlatform.INSTANCE.setDebugging(true);
+
+ initServer();
+ return initClient();
+ }
+
+ private static void initServer() throws Exception
+ {
+ IDBAdapter.REGISTRY.put(EmbeddedDerbyAdapter.NAME, new EmbeddedDerbyAdapter());
+ IStore store = JDBCUtil.getStore();
+ Server.INSTANCE.setStore(store);
+ Server.INSTANCE.activate();
+
+ IManagedContainer serverContainer = new ManagedContainer();
+ Net4jUtil.prepareContainer(serverContainer);
+ TCPUtil.prepareContainer(serverContainer);
+ JMSServerUtil.prepareContainer(serverContainer);
+
+ TCPUtil.getAcceptor(serverContainer, null);
+ }
+
+ private static Context initClient() throws NamingException
+ {
+ IManagedContainer clientContainer = new ManagedContainer();
+ Net4jUtil.prepareContainer(clientContainer);
+ TCPUtil.prepareContainer(clientContainer);
+
+ IConnector connector = TCPUtil.getConnector(clientContainer, "localhost"); //$NON-NLS-1$
+
+ IJMSAdmin admin = JMSAdminUtil.createAdmin(connector);
+ admin.createQueue("StockQueue"); //$NON-NLS-1$
+ admin.createTopic("StockTopic"); //$NON-NLS-1$
+
+ return new JMSInitialContext(clientContainer);
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private static final class MessageLogger implements MessageListener
+ {
+ private String name;
+
+ public MessageLogger(String name)
+ {
+ this.name = name;
+ }
+
+ public void onMessage(Message message)
+ {
+ try
+ {
+ Object object = ((ObjectMessage)message).getObject();
+ IOUtil.OUT().println("\n------> MESSAGE for " + name + ": " + object + "\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ message.acknowledge();
+ }
+ catch (JMSException ex)
+ {
+ IOUtil.print(ex);
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.jms.tests/src/org/eclipse/net4j/jms/tests/JMSTest.java b/plugins/org.eclipse.net4j.jms.tests/src/org/eclipse/net4j/jms/tests/JMSTest.java
index 03722161c1..912c0a047b 100644
--- a/plugins/org.eclipse.net4j.jms.tests/src/org/eclipse/net4j/jms/tests/JMSTest.java
+++ b/plugins/org.eclipse.net4j.jms.tests/src/org/eclipse/net4j/jms/tests/JMSTest.java
@@ -1,132 +1,132 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.net4j.jms.tests;
-
-import org.eclipse.net4j.Net4jUtil;
-import org.eclipse.net4j.connector.IConnector;
-import org.eclipse.net4j.db.IDBAdapter;
-import org.eclipse.net4j.db.derby.EmbeddedDerbyAdapter;
-import org.eclipse.net4j.jms.JMSInitialContext;
-import org.eclipse.net4j.jms.admin.IJMSAdmin;
-import org.eclipse.net4j.jms.admin.JMSAdminUtil;
-import org.eclipse.net4j.jms.internal.server.Server;
-import org.eclipse.net4j.jms.server.IStore;
-import org.eclipse.net4j.jms.server.JMSServerUtil;
-import org.eclipse.net4j.jms.server.jdbc.JDBCUtil;
-import org.eclipse.net4j.tcp.TCPUtil;
-import org.eclipse.net4j.util.concurrent.ConcurrencyUtil;
-import org.eclipse.net4j.util.container.IManagedContainer;
-import org.eclipse.net4j.util.container.ManagedContainer;
-import org.eclipse.net4j.util.io.IOUtil;
-import org.eclipse.net4j.util.om.OMPlatform;
-import org.eclipse.net4j.util.om.log.PrintLogHandler;
-import org.eclipse.net4j.util.om.trace.PrintTraceHandler;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.ObjectMessage;
-import javax.jms.Session;
-import javax.naming.Context;
-
-public class JMSTest
-{
- public static void main(String[] args) throws Exception
- {
- try
- {
- Context context = init();
- ConnectionFactory connectionFactory = (ConnectionFactory)context.lookup("net4j.jms.ConnectionFactory"); //$NON-NLS-1$
- Destination destination = (Destination)context.lookup("StockTopic"); //$NON-NLS-1$
-
- Connection connection = connectionFactory.createConnection();
- Session session = connection.createSession(true, 0);
-
- MessageProducer publisher = session.createProducer(destination);
- MessageConsumer subscriber1 = session.createConsumer(destination);
- MessageConsumer subscriber2 = session.createConsumer(destination);
- subscriber1.setMessageListener(new MessageLogger("subscriber1")); //$NON-NLS-1$
- subscriber2.setMessageListener(new MessageLogger("subscriber2")); //$NON-NLS-1$
-
- connection.start();
-
- publisher.send(session.createObjectMessage("Message 1")); //$NON-NLS-1$
- publisher.send(session.createObjectMessage("Message 2")); //$NON-NLS-1$
- publisher.send(session.createObjectMessage("Message 3")); //$NON-NLS-1$
- publisher.send(session.createObjectMessage("Message 4")); //$NON-NLS-1$
-
- session.commit();
- }
- finally
- {
- ConcurrencyUtil.sleep(500);
- Server.INSTANCE.deactivate();
- }
- }
-
- private static Context init() throws Exception
- {
- OMPlatform.INSTANCE.addLogHandler(PrintLogHandler.CONSOLE);
- OMPlatform.INSTANCE.addTraceHandler(PrintTraceHandler.CONSOLE);
- OMPlatform.INSTANCE.setDebugging(true);
-
- IDBAdapter.REGISTRY.put(EmbeddedDerbyAdapter.NAME, new EmbeddedDerbyAdapter());
- IStore store = JDBCUtil.getStore();
- Server.INSTANCE.setStore(store);
- Server.INSTANCE.activate();
-
- IManagedContainer container = new ManagedContainer();
- Net4jUtil.prepareContainer(container);
- TCPUtil.prepareContainer(container);
- JMSServerUtil.prepareContainer(container);
-
- TCPUtil.getAcceptor(container, null);
- IConnector connector = TCPUtil.getConnector(container, "localhost"); //$NON-NLS-1$
-
- IJMSAdmin admin = JMSAdminUtil.createAdmin(connector);
- admin.createQueue("StockQueue"); //$NON-NLS-1$
- admin.createTopic("StockTopic"); //$NON-NLS-1$
-
- return new JMSInitialContext(container);
- }
-
- /**
- * @author Eike Stepper
- */
- private static final class MessageLogger implements MessageListener
- {
- private String name;
-
- public MessageLogger(String name)
- {
- this.name = name;
- }
-
- public void onMessage(Message message)
- {
- try
- {
- Object object = ((ObjectMessage)message).getObject();
- IOUtil.OUT().println("\n------> MESSAGE for " + name + ": " + object + "\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- message.acknowledge();
- }
- catch (JMSException ex)
- {
- IOUtil.print(ex);
- }
- }
- }
-}
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.jms.tests;
+
+import org.eclipse.net4j.Net4jUtil;
+import org.eclipse.net4j.connector.IConnector;
+import org.eclipse.net4j.db.IDBAdapter;
+import org.eclipse.net4j.db.derby.EmbeddedDerbyAdapter;
+import org.eclipse.net4j.jms.JMSInitialContext;
+import org.eclipse.net4j.jms.admin.IJMSAdmin;
+import org.eclipse.net4j.jms.admin.JMSAdminUtil;
+import org.eclipse.net4j.jms.internal.server.Server;
+import org.eclipse.net4j.jms.server.IStore;
+import org.eclipse.net4j.jms.server.JMSServerUtil;
+import org.eclipse.net4j.jms.server.jdbc.JDBCUtil;
+import org.eclipse.net4j.tcp.TCPUtil;
+import org.eclipse.net4j.util.concurrent.ConcurrencyUtil;
+import org.eclipse.net4j.util.container.IManagedContainer;
+import org.eclipse.net4j.util.container.ManagedContainer;
+import org.eclipse.net4j.util.io.IOUtil;
+import org.eclipse.net4j.util.om.OMPlatform;
+import org.eclipse.net4j.util.om.log.PrintLogHandler;
+import org.eclipse.net4j.util.om.trace.PrintTraceHandler;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
+import javax.jms.MessageProducer;
+import javax.jms.ObjectMessage;
+import javax.jms.Session;
+import javax.naming.Context;
+
+public class JMSTest
+{
+ public static void main(String[] args) throws Exception
+ {
+ try
+ {
+ Context context = init();
+ ConnectionFactory connectionFactory = (ConnectionFactory)context.lookup("net4j.jms.ConnectionFactory"); //$NON-NLS-1$
+ Destination destination = (Destination)context.lookup("StockTopic"); //$NON-NLS-1$
+
+ Connection connection = connectionFactory.createConnection();
+ Session session = connection.createSession(true, 0);
+
+ MessageProducer publisher = session.createProducer(destination);
+ MessageConsumer subscriber1 = session.createConsumer(destination);
+ MessageConsumer subscriber2 = session.createConsumer(destination);
+ subscriber1.setMessageListener(new MessageLogger("subscriber1")); //$NON-NLS-1$
+ subscriber2.setMessageListener(new MessageLogger("subscriber2")); //$NON-NLS-1$
+
+ connection.start();
+
+ publisher.send(session.createObjectMessage("Message 1")); //$NON-NLS-1$
+ publisher.send(session.createObjectMessage("Message 2")); //$NON-NLS-1$
+ publisher.send(session.createObjectMessage("Message 3")); //$NON-NLS-1$
+ publisher.send(session.createObjectMessage("Message 4")); //$NON-NLS-1$
+
+ session.commit();
+ }
+ finally
+ {
+ ConcurrencyUtil.sleep(500);
+ Server.INSTANCE.deactivate();
+ }
+ }
+
+ private static Context init() throws Exception
+ {
+ OMPlatform.INSTANCE.addLogHandler(PrintLogHandler.CONSOLE);
+ OMPlatform.INSTANCE.addTraceHandler(PrintTraceHandler.CONSOLE);
+ OMPlatform.INSTANCE.setDebugging(true);
+
+ IDBAdapter.REGISTRY.put(EmbeddedDerbyAdapter.NAME, new EmbeddedDerbyAdapter());
+ IStore store = JDBCUtil.getStore();
+ Server.INSTANCE.setStore(store);
+ Server.INSTANCE.activate();
+
+ IManagedContainer container = new ManagedContainer();
+ Net4jUtil.prepareContainer(container);
+ TCPUtil.prepareContainer(container);
+ JMSServerUtil.prepareContainer(container);
+
+ TCPUtil.getAcceptor(container, null);
+ IConnector connector = TCPUtil.getConnector(container, "localhost"); //$NON-NLS-1$
+
+ IJMSAdmin admin = JMSAdminUtil.createAdmin(connector);
+ admin.createQueue("StockQueue"); //$NON-NLS-1$
+ admin.createTopic("StockTopic"); //$NON-NLS-1$
+
+ return new JMSInitialContext(container);
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private static final class MessageLogger implements MessageListener
+ {
+ private String name;
+
+ public MessageLogger(String name)
+ {
+ this.name = name;
+ }
+
+ public void onMessage(Message message)
+ {
+ try
+ {
+ Object object = ((ObjectMessage)message).getObject();
+ IOUtil.OUT().println("\n------> MESSAGE for " + name + ": " + object + "\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ message.acknowledge();
+ }
+ catch (JMSException ex)
+ {
+ IOUtil.print(ex);
+ }
+ }
+ }
+}

Back to the top