JBoss hornetq SVN: r7923 - in trunk/tests/src/org/hornetq/tests: util and 1 other directory.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2009-08-27 10:22:20 -0400 (Thu, 27 Aug 2009)
New Revision: 7923
Modified:
trunk/tests/src/org/hornetq/tests/integration/jms/largemessage/JMSLargeMessageTest.java
trunk/tests/src/org/hornetq/tests/util/JMSTestBase.java
Log:
small tweak
Modified: trunk/tests/src/org/hornetq/tests/integration/jms/largemessage/JMSLargeMessageTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/jms/largemessage/JMSLargeMessageTest.java 2009-08-27 13:54:23 UTC (rev 7922)
+++ trunk/tests/src/org/hornetq/tests/integration/jms/largemessage/JMSLargeMessageTest.java 2009-08-27 14:22:20 UTC (rev 7923)
@@ -59,11 +59,9 @@
protected void setUp() throws Exception
{
super.setUp();
- jmsServer.createQueue("queue1", "/jms/queue1", null, true);
-
- queue1 = (Queue)context.lookup("/jms/queue1");
+ queue1 = createQueue("queue1");
}
-
+
protected void tearDown() throws Exception
{
queue1 = null;
Modified: trunk/tests/src/org/hornetq/tests/util/JMSTestBase.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/util/JMSTestBase.java 2009-08-27 13:54:23 UTC (rev 7922)
+++ trunk/tests/src/org/hornetq/tests/util/JMSTestBase.java 2009-08-27 14:22:20 UTC (rev 7923)
@@ -37,6 +37,8 @@
import java.util.List;
import javax.jms.ConnectionFactory;
+import javax.jms.Queue;
+import javax.naming.NamingException;
import org.hornetq.core.config.Configuration;
import org.hornetq.core.config.TransportConfiguration;
@@ -94,6 +96,18 @@
{
return false;
}
+
+ /**
+ * @throws Exception
+ * @throws NamingException
+ */
+ protected Queue createQueue(String name) throws Exception, NamingException
+ {
+ jmsServer.createQueue(name, "/jms/" + name, null, true);
+
+ return (Queue)context.lookup("/jms/" + name);
+ }
+
@Override
protected void setUp() throws Exception
@@ -156,12 +170,6 @@
private void registerConnectionFactory() throws Exception
{
- int retryInterval = 1000;
- double retryIntervalMultiplier = 1.0;
- int reconnectAttempts = -1;
- boolean failoverOnServerShutdown = true;
- int callTimeout = 30000;
-
List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs = new ArrayList<Pair<TransportConfiguration, TransportConfiguration>>();
connectorConfigs.add(new Pair<TransportConfiguration, TransportConfiguration>(new TransportConfiguration(NettyConnectorFactory.class.getName()),
null));
@@ -169,6 +177,26 @@
List<String> jndiBindings = new ArrayList<String>();
jndiBindings.add("/cf");
+ createCF(connectorConfigs, jndiBindings);
+
+ cf = (ConnectionFactory)context.lookup("/cf");
+
+ }
+
+ /**
+ * @param connectorConfigs
+ * @param jndiBindings
+ * @throws Exception
+ */
+ protected void createCF(List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs,
+ List<String> jndiBindings) throws Exception
+ {
+ int retryInterval = 1000;
+ double retryIntervalMultiplier = 1.0;
+ int reconnectAttempts = -1;
+ boolean failoverOnServerShutdown = true;
+ int callTimeout = 30000;
+
jmsServer.createConnectionFactory("ManualReconnectionToSingleServerTest",
connectorConfigs,
null,
@@ -198,9 +226,6 @@
reconnectAttempts,
failoverOnServerShutdown,
jndiBindings);
-
- cf = (ConnectionFactory)context.lookup("/cf");
-
}
}
15 years, 4 months
JBoss hornetq SVN: r7922 - in trunk: src/main/org/hornetq/core/cluster and 2 other directories.
by do-not-reply@jboss.org
Author: jmesnil
Date: 2009-08-27 09:54:23 -0400 (Thu, 27 Aug 2009)
New Revision: 7922
Modified:
trunk/build-hornetq.xml
trunk/src/main/org/hornetq/core/cluster/DiscoveryGroup.java
trunk/src/main/org/hornetq/core/config/Configuration.java
trunk/src/main/org/hornetq/core/config/impl/ConfigurationImpl.java
Log:
cleaned up core client jar dependencies
* DiscoveryGroup and Configuration no longer extends HornetQComponent
* import only management API
* import remoting API + spi & impl subpackages
Modified: trunk/build-hornetq.xml
===================================================================
--- trunk/build-hornetq.xml 2009-08-27 10:45:09 UTC (rev 7921)
+++ trunk/build-hornetq.xml 2009-08-27 13:54:23 UTC (rev 7922)
@@ -661,23 +661,23 @@
<include name="org/hornetq/core/client/**/*.class"/>
<include name="org/hornetq/core/filter/**/*.class"/>
<include name="org/hornetq/core/buffers/**/*.class"/>
+ <include name="org/hornetq/core/config/**/*.class"/>
<include name="org/hornetq/core/exception/**/*.class"/>
<include name="org/hornetq/core/logging/**/*.class"/>
- <include name="org/hornetq/core/remoting/**/*.class"/>
+ <include name="org/hornetq/core/remoting/*.class"/>
+ <include name="org/hornetq/core/remoting/spi/*.class"/>
+ <include name="org/hornetq/core/remoting/impl/**/*.class"/>
<include name="org/hornetq/utils/**/*.class"/>
<include name="org/hornetq/core/cluster/**/*.class"/>
- <include name="org/hornetq/core/config/**/*.class"/>
<include name="org/hornetq/core/list/**/*.class"/>
<include name="org/hornetq/core/message/**/*.class"/>
<include name="org/hornetq/core/version/**/*.class"/>
- <include name="org/hornetq/core/management/**/*.class"/>
+ <include name="org/hornetq/core/management/*.class"/>
<include name="org/hornetq/core/transaction/impl/XidImpl.class"/>
-
- <!-- FIXME - why are these classes in the client jar ??? -->
- <include name="org/hornetq/core/server/HornetQComponent.class"/>
- <include name="org/hornetq/core/server/JournalType.class"/>
- <include name="org/hornetq/core/journal/EncodingSupport.class"/>
- <include name="org/hornetq/core/server/ServerMessage.class"/>
+
+ <!-- required by SessionSendMessage -->
+ <include name="org/hornetq/core/server/ServerMessage.class"/>
+ <include name="org/hornetq/core/journal/EncodingSupport.class"/>
</fileset>
</jar>
Modified: trunk/src/main/org/hornetq/core/cluster/DiscoveryGroup.java
===================================================================
--- trunk/src/main/org/hornetq/core/cluster/DiscoveryGroup.java 2009-08-27 10:45:09 UTC (rev 7921)
+++ trunk/src/main/org/hornetq/core/cluster/DiscoveryGroup.java 2009-08-27 13:54:23 UTC (rev 7922)
@@ -17,7 +17,6 @@
import java.util.Map;
import org.hornetq.core.management.NotificationService;
-import org.hornetq.core.server.HornetQComponent;
/**
* A DiscoveryGroup
@@ -28,7 +27,7 @@
*
*
*/
-public interface DiscoveryGroup extends HornetQComponent
+public interface DiscoveryGroup
{
void setNotificationService(NotificationService notificationService);
@@ -36,6 +35,12 @@
Map<String, DiscoveryEntry> getDiscoveryEntryMap();
+ void start() throws Exception;
+
+ void stop() throws Exception;
+
+ boolean isStarted();
+
boolean waitForBroadcast(long timeout);
void registerListener(final DiscoveryListener listener);
Modified: trunk/src/main/org/hornetq/core/config/Configuration.java
===================================================================
--- trunk/src/main/org/hornetq/core/config/Configuration.java 2009-08-27 10:45:09 UTC (rev 7921)
+++ trunk/src/main/org/hornetq/core/config/Configuration.java 2009-08-27 13:54:23 UTC (rev 7922)
@@ -24,7 +24,6 @@
import org.hornetq.core.config.cluster.DiscoveryGroupConfiguration;
import org.hornetq.core.config.cluster.DivertConfiguration;
import org.hornetq.core.config.cluster.QueueConfiguration;
-import org.hornetq.core.server.HornetQComponent;
import org.hornetq.core.server.JournalType;
import org.hornetq.utils.SimpleString;
@@ -35,8 +34,15 @@
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
*
*/
-public interface Configuration extends Serializable, HornetQComponent
+public interface Configuration extends Serializable
{
+ public void start() throws Exception;
+
+ public void stop() throws Exception;
+
+ public boolean isStarted();
+
+
// General attributes -------------------------------------------------------------------
boolean isClustered();
Modified: trunk/src/main/org/hornetq/core/config/impl/ConfigurationImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/config/impl/ConfigurationImpl.java 2009-08-27 10:45:09 UTC (rev 7921)
+++ trunk/src/main/org/hornetq/core/config/impl/ConfigurationImpl.java 2009-08-27 13:54:23 UTC (rev 7922)
@@ -283,8 +283,9 @@
protected long serverDumpInterval = DEFAULT_SERVER_DUMP_INTERVAL;
- // HornetQComponent implementation ----------------------------------------------
+ // Public -------------------------------------------------------------------------
+
public void start() throws Exception
{
}
@@ -298,8 +299,6 @@
return true;
}
- // Public -------------------------------------------------------------------------
-
public boolean isClustered()
{
return clustered;
15 years, 4 months
JBoss hornetq SVN: r7921 - in trunk: src/main/org/hornetq/integration/transports/netty and 1 other directory.
by do-not-reply@jboss.org
Author: timfox
Date: 2009-08-27 06:45:09 -0400 (Thu, 27 Aug 2009)
New Revision: 7921
Modified:
trunk/build-hornetq.xml
trunk/src/main/org/hornetq/integration/transports/netty/HornetQChannelHandler.java
Log:
https://jira.jboss.org/jira/browse/HORNETQ-114
Modified: trunk/build-hornetq.xml
===================================================================
--- trunk/build-hornetq.xml 2009-08-27 09:22:16 UTC (rev 7920)
+++ trunk/build-hornetq.xml 2009-08-27 10:45:09 UTC (rev 7921)
@@ -665,18 +665,19 @@
<include name="org/hornetq/core/logging/**/*.class"/>
<include name="org/hornetq/core/remoting/**/*.class"/>
<include name="org/hornetq/utils/**/*.class"/>
- <include name="org/hornetq/core/cluster/**/*.class"/>
+ <include name="org/hornetq/core/cluster/**/*.class"/>
<include name="org/hornetq/core/config/**/*.class"/>
<include name="org/hornetq/core/list/**/*.class"/>
<include name="org/hornetq/core/message/**/*.class"/>
<include name="org/hornetq/core/version/**/*.class"/>
- <include name="org/hornetq/core/management/**/*.class"/>
+ <include name="org/hornetq/core/management/**/*.class"/>
+ <include name="org/hornetq/core/transaction/impl/XidImpl.class"/>
+
<!-- FIXME - why are these classes in the client jar ??? -->
<include name="org/hornetq/core/server/HornetQComponent.class"/>
<include name="org/hornetq/core/server/JournalType.class"/>
<include name="org/hornetq/core/journal/EncodingSupport.class"/>
- <include name="org/hornetq/core/server/ServerMessage.class"/>
- <include name="org/hornetq/core/ping/**/*.class"/>
+ <include name="org/hornetq/core/server/ServerMessage.class"/>
</fileset>
</jar>
Modified: trunk/src/main/org/hornetq/integration/transports/netty/HornetQChannelHandler.java
===================================================================
--- trunk/src/main/org/hornetq/integration/transports/netty/HornetQChannelHandler.java 2009-08-27 09:22:16 UTC (rev 7920)
+++ trunk/src/main/org/hornetq/integration/transports/netty/HornetQChannelHandler.java 2009-08-27 10:45:09 UTC (rev 7921)
@@ -94,6 +94,8 @@
return;
}
+ log.error("Got exception on Netty channel", e.getCause());
+
HornetQException me = new HornetQException(HornetQException.INTERNAL_ERROR, "Netty exception");
me.initCause(e.getCause());
try
15 years, 4 months
JBoss hornetq SVN: r7920 - trunk/src/main/org/hornetq/utils.
by do-not-reply@jboss.org
Author: jmesnil
Date: 2009-08-27 05:22:16 -0400 (Thu, 27 Aug 2009)
New Revision: 7920
Modified:
trunk/src/main/org/hornetq/utils/HornetQThreadFactory.java
Log:
attach the thread to a group only if there is no security manager
* when sandboxed, the code does not have the RuntimePermission modifyThreadGroup and it will
fail to create new Thread attached to a group
Modified: trunk/src/main/org/hornetq/utils/HornetQThreadFactory.java
===================================================================
--- trunk/src/main/org/hornetq/utils/HornetQThreadFactory.java 2009-08-27 09:02:32 UTC (rev 7919)
+++ trunk/src/main/org/hornetq/utils/HornetQThreadFactory.java 2009-08-27 09:22:16 UTC (rev 7920)
@@ -48,10 +48,17 @@
public Thread newThread(final Runnable command)
{
- Thread t = new Thread(group, command, "Thread-" + threadCount.getAndIncrement() +
- " (group:" +
- group.getName() +
- ")");
+ Thread t = null;
+ // attach the thread to a group only if there is no security manager:
+ // when sandboxed, the code does not have the RuntimePermission modifyThreadGroup
+ if (System.getSecurityManager() == null)
+ {
+ t = new Thread(group, command, "Thread-" + threadCount.getAndIncrement() +
+ " (group:" + group.getName() + ")");
+ } else
+ {
+ t = new Thread(command, "Thread-" + threadCount.getAndIncrement());
+ }
t.setDaemon(daemon);
t.setPriority(threadPriority);
15 years, 4 months
JBoss hornetq SVN: r7919 - trunk/tests/src/org/hornetq/tests/integration/jms.
by do-not-reply@jboss.org
Author: jmesnil
Date: 2009-08-27 05:02:32 -0400 (Thu, 27 Aug 2009)
New Revision: 7919
Modified:
trunk/tests/src/org/hornetq/tests/integration/jms/ManualReconnectionToSingleServerTest.java
Log:
added traces to find the cause of intermittent failures on hudson
Modified: trunk/tests/src/org/hornetq/tests/integration/jms/ManualReconnectionToSingleServerTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/jms/ManualReconnectionToSingleServerTest.java 2009-08-26 14:21:01 UTC (rev 7918)
+++ trunk/tests/src/org/hornetq/tests/integration/jms/ManualReconnectionToSingleServerTest.java 2009-08-27 09:02:32 UTC (rev 7919)
@@ -101,7 +101,7 @@
{
receivedMessagesAfterRestart = true;
}
- System.out.println(msg);
+ System.out.println(receivedMessagesAfterRestart + " " + msg);
}
};
@@ -112,6 +112,7 @@
exceptionLatch.countDown();
disconnect();
connect();
+ reconnectionLatch.countDown();
}
};
@@ -139,7 +140,7 @@
connect();
- int num = 10;
+ int num = 20;
for (int i = 0; i < num; i++)
{
try
@@ -159,14 +160,15 @@
Thread.sleep(5000);
restartServer();
afterRestart = true;
- boolean clientReconnected = reconnectionLatch.await(10, SECONDS);
- assertTrue("client did not reconnect after server was restarted", clientReconnected);
}
}
boolean gotException = exceptionLatch.await(10, SECONDS);
assertTrue(gotException);
+ boolean clientReconnected = reconnectionLatch.await(10, SECONDS);
+ assertTrue("client did not reconnect after server was restarted", clientReconnected);
+
assertTrue(receivedMessagesAfterRestart);
connection.close();
@@ -328,10 +330,11 @@
connection.setExceptionListener(exceptionListener);
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
producer = session.createProducer(topic);
+ System.out.println("creating consumer");
consumer = session.createConsumer(topic);
consumer.setMessageListener(listener);
connection.start();
- reconnectionLatch.countDown();
+ System.out.println("started new connection");
}
catch (Exception e)
{
15 years, 4 months
JBoss hornetq SVN: r7918 - in trunk: examples/common and 8 other directories.
by do-not-reply@jboss.org
Author: jmesnil
Date: 2009-08-26 10:21:01 -0400 (Wed, 26 Aug 2009)
New Revision: 7918
Added:
trunk/examples/jms/applet/
trunk/examples/jms/applet/applet.html
trunk/examples/jms/applet/build.xml
trunk/examples/jms/applet/readme.html
trunk/examples/jms/applet/server0/
trunk/examples/jms/applet/server0/hornetq-beans.xml
trunk/examples/jms/applet/server0/hornetq-configuration.xml
trunk/examples/jms/applet/server0/hornetq-jms.xml
trunk/examples/jms/applet/server0/hornetq-users.xml
trunk/examples/jms/applet/src/
trunk/examples/jms/applet/src/org/
trunk/examples/jms/applet/src/org/hornetq/
trunk/examples/jms/applet/src/org/hornetq/jms/
trunk/examples/jms/applet/src/org/hornetq/jms/example/
trunk/examples/jms/applet/src/org/hornetq/jms/example/AppletExample.java
trunk/examples/jms/applet/src/org/hornetq/jms/example/HttpStaticFileServer.java
trunk/examples/jms/applet/src/org/hornetq/jms/example/HttpStaticFileServerHandler.java
trunk/examples/jms/applet/src/org/hornetq/jms/example/HttpStaticFileServerPipelineFactory.java
Modified:
trunk/.classpath
trunk/examples/common/build.xml
Log:
HORNETQ-113: Applet example
* added example to send/receive messages from an applet.
* example is manual and is not executed by "ant all" from common directory
Modified: trunk/.classpath
===================================================================
--- trunk/.classpath 2009-08-26 11:11:08 UTC (rev 7917)
+++ trunk/.classpath 2009-08-26 14:21:01 UTC (rev 7918)
@@ -17,6 +17,7 @@
<classpathentry kind="src" path="examples/core/microcontainer/src"/>
<classpathentry kind="src" path="examples/core/embedded-remote/src"/>
<classpathentry kind="src" path="examples/core/perf/src"/>
+ <classpathentry kind="src" path="examples/jms/applet/src"/>
<classpathentry kind="src" path="examples/jms/application-layer-failover/src"/>
<classpathentry kind="src" path="examples/jms/automatic-failover/src"/>
<classpathentry kind="src" path="examples/jms/bridge/src"/>
Modified: trunk/examples/common/build.xml
===================================================================
--- trunk/examples/common/build.xml 2009-08-26 11:11:08 UTC (rev 7917)
+++ trunk/examples/common/build.xml 2009-08-26 14:21:01 UTC (rev 7918)
@@ -187,9 +187,12 @@
<include name="jms/*/build.xml"/>
<exclude name="common/build.xml"/>
<exclude name="core/perf/build.xml"/>
+ <exclude name="jms/applet/build.xml"/>
<exclude name="jms/perf/build.xml"/>
</fileset>
</subant>
+
+ <echo message="Do not forget to run jms/applet example manually!" />
</target>
</project>
Property changes on: trunk/examples/jms/applet
___________________________________________________________________
Name: svn:ignore
+ build
Added: trunk/examples/jms/applet/applet.html
===================================================================
--- trunk/examples/jms/applet/applet.html (rev 0)
+++ trunk/examples/jms/applet/applet.html 2009-08-26 14:21:01 UTC (rev 7918)
@@ -0,0 +1,17 @@
+<html>
+ <head>
+ <title>HornetQ Applet Example</title>
+ </head>
+ <body>
+ <h1>HornetQ Applet Example</h1>
+
+ <p>The Applet will connect to HornetQ server running on localhost and
+ publishes messages on a topic <code>exampleTopic</code> when "Send" is pressed.</p>
+ <p>The Applet is also a MessageListener and will display messages received from the topic</p>
+
+ <applet code="org.hornetq.jms.example.AppletExample.class"
+ codebase="build/classes/"
+ archive="hornetq-core-client.jar,hornetq-jms-client.jar,jboss-jms-api.jar,hornetq-transports.jar,netty.jar"
+ width="640" height="480"></applet>
+ </body>
+</html>
\ No newline at end of file
Added: trunk/examples/jms/applet/build.xml
===================================================================
--- trunk/examples/jms/applet/build.xml (rev 0)
+++ trunk/examples/jms/applet/build.xml 2009-08-26 14:21:01 UTC (rev 7918)
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE project [
+ <!ENTITY libraries SYSTEM "../../../thirdparty/libraries.ent">
+ ]>
+<!--
+ ~ Copyright 2009 Red Hat, Inc.
+ ~ Red Hat licenses this file to you under the Apache License, version
+ ~ 2.0 (the "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ ~ implied. See the License for the specific language governing
+ ~ permissions and limitations under the License.
+ -->
+
+<project default="run" name="HornetQ Applet Example">
+
+ <import file="../../common/build.xml"/>
+
+ <path id="extra.classpath">
+ <fileset file="${jars.dir}/org/jboss/netty/lib/netty.jar" />
+ </path>
+
+ <path id="applet.classpath">
+ <fileset dir="build/classes" />
+ <fileset dir="build/classes">
+ <include name="**/*.jar"/>
+ </fileset>
+ </path>
+
+ <target name="init">
+ <mkdir dir="build/classes" />
+ <copy todir="build/classes">
+ <fileset dir="${hornetq.jars.dir}">
+ <include name="hornetq-core-client.jar"/>
+ <include name="hornetq-jms-client.jar"/>
+ <include name="hornetq-transports.jar"/>
+ </fileset>
+ <fileset file="${jars.dir}/org/jboss/netty/lib/netty.jar" />
+ <fileset file="${jars.dir}/org/jboss/javaee/lib/jboss-jms-api.jar" />
+ </copy>
+ </target>
+
+ <target name="run" depends="init">
+ <antcall target="runExample">
+ <param name="example.classname" value="org.hornetq.jms.example.HttpStaticFileServer"/>
+ </antcall>
+ </target>
+</project>
Added: trunk/examples/jms/applet/readme.html
===================================================================
--- trunk/examples/jms/applet/readme.html (rev 0)
+++ trunk/examples/jms/applet/readme.html 2009-08-26 14:21:01 UTC (rev 7918)
@@ -0,0 +1,20 @@
+<html>
+ <head>
+ <title>HornetQ Applet Example</title>
+ <link rel="stylesheet" type="text/css" href="../../common/common.css">
+ </head>
+ <body>
+ <h1>Applet Example</h1>
+ <br>
+ <p>This example shows you how to send and receive JMS messages from an Applet.</p>
+
+ <h2>Example step-by-step</h2>
+
+ <p><i>To run the example, simply type <code>ant</code> from this directory</i> to start
+ HornetQ server and a HTTP server.</p>
+
+ <p>Then, go to <a href="http://127.0.0.1:8088/applet.html">http://127.0.0.1:8088/applet.html</a> to load
+ and use the applet.</p>
+
+ </body>
+</html>
\ No newline at end of file
Property changes on: trunk/examples/jms/applet/server0
___________________________________________________________________
Name: svn:ignore
+ data
Added: trunk/examples/jms/applet/server0/hornetq-beans.xml
===================================================================
--- trunk/examples/jms/applet/server0/hornetq-beans.xml (rev 0)
+++ trunk/examples/jms/applet/server0/hornetq-beans.xml 2009-08-26 14:21:01 UTC (rev 7918)
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="Naming" class="org.jnp.server.NamingBeanImpl"/>
+
+ <!-- JNDI server. Disable this if you don't want JNDI -->
+ <bean name="JNDIServer" class="org.jnp.server.Main">
+ <property name="namingInfo">
+ <inject bean="Naming"/>
+ </property>
+ <property name="port">1099</property>
+ <property name="bindAddress">localhost</property>
+ <property name="rmiPort">1098</property>
+ <property name="rmiBindAddress">localhost</property>
+ </bean>
+
+ <!-- MBean server -->
+ <bean name="MBeanServer" class="javax.management.MBeanServer">
+ <constructor factoryClass="java.lang.management.ManagementFactory"
+ factoryMethod="getPlatformMBeanServer"/>
+ </bean>
+
+ <!-- The core configuration -->
+ <bean name="Configuration" class="org.hornetq.core.config.impl.FileConfiguration"/>
+
+ <!-- The security manager -->
+ <bean name="HornetQSecurityManager" class="org.hornetq.core.security.impl.HornetQSecurityManagerImpl">
+ <start ignored="true"/>
+ <stop ignored="true"/>
+ </bean>
+
+ <!-- The core server -->
+ <bean name="HornetQServer" class="org.hornetq.core.server.impl.HornetQServerImpl">
+ <constructor>
+ <parameter>
+ <inject bean="Configuration"/>
+ </parameter>
+ <parameter>
+ <inject bean="MBeanServer"/>
+ </parameter>
+ <parameter>
+ <inject bean="HornetQSecurityManager"/>
+ </parameter>
+ </constructor>
+ <start ignored="true"/>
+ <stop ignored="true"/>
+ </bean>
+
+ <!-- The JMS server -->
+ <bean name="JMSServerManager" class="org.hornetq.jms.server.impl.JMSServerManagerImpl">
+ <constructor>
+ <parameter>
+ <inject bean="HornetQServer"/>
+ </parameter>
+ </constructor>
+ </bean>
+
+</deployment>
Added: trunk/examples/jms/applet/server0/hornetq-configuration.xml
===================================================================
--- trunk/examples/jms/applet/server0/hornetq-configuration.xml (rev 0)
+++ trunk/examples/jms/applet/server0/hornetq-configuration.xml 2009-08-26 14:21:01 UTC (rev 7918)
@@ -0,0 +1,33 @@
+<configuration xmlns="urn:hornetq"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:hornetq /schema/hornetq-configuration.xsd">
+
+ <!-- Connectors -->
+ <connectors>
+ <connector name="netty-connector">
+ <factory-class>org.hornetq.integration.transports.netty.NettyConnectorFactory</factory-class>
+ </connector>
+ </connectors>
+
+ <!-- Acceptors -->
+ <acceptors>
+ <acceptor name="netty-acceptor">
+ <factory-class>org.hornetq.integration.transports.netty.NettyAcceptorFactory</factory-class>
+ </acceptor>
+ </acceptors>
+
+ <!-- Other config -->
+
+ <security-settings>
+ <!--security for example topic-->
+ <security-setting match="jms.topic.exampleTopic">
+ <permission type="createDurableQueue" roles="guest"/>
+ <permission type="deleteDurableQueue" roles="guest"/>
+ <permission type="createTempQueue" roles="guest"/>
+ <permission type="deleteTempQueue" roles="guest"/>
+ <permission type="consume" roles="guest"/>
+ <permission type="send" roles="guest"/>
+ </security-setting>
+ </security-settings>
+
+</configuration>
Added: trunk/examples/jms/applet/server0/hornetq-jms.xml
===================================================================
--- trunk/examples/jms/applet/server0/hornetq-jms.xml (rev 0)
+++ trunk/examples/jms/applet/server0/hornetq-jms.xml 2009-08-26 14:21:01 UTC (rev 7918)
@@ -0,0 +1,17 @@
+<configuration xmlns="urn:hornetq"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:hornetq /schema/hornetq-jms.xsd">
+ <!--the connection factory used by the example-->
+ <connection-factory name="ConnectionFactory">
+ <connector-ref connector-name="netty-connector"/>
+ <entries>
+ <entry name="ConnectionFactory"/>
+ </entries>
+ </connection-factory>
+
+ <!--the topic used by the example-->
+ <topic name="exampleTopic">
+ <entry name="/topic/exampleTopic"/>
+ </topic>
+
+</configuration>
\ No newline at end of file
Added: trunk/examples/jms/applet/server0/hornetq-users.xml
===================================================================
--- trunk/examples/jms/applet/server0/hornetq-users.xml (rev 0)
+++ trunk/examples/jms/applet/server0/hornetq-users.xml 2009-08-26 14:21:01 UTC (rev 7918)
@@ -0,0 +1,7 @@
+<configuration xmlns="urn:hornetq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:hornetq /schema/hornetq-users.xsd">
+ <!-- the default user. this is used where username is null-->
+ <defaultuser name="guest" password="guest">
+ <role name="guest"/>
+ </defaultuser>
+</configuration>
\ No newline at end of file
Added: trunk/examples/jms/applet/src/org/hornetq/jms/example/AppletExample.java
===================================================================
--- trunk/examples/jms/applet/src/org/hornetq/jms/example/AppletExample.java (rev 0)
+++ trunk/examples/jms/applet/src/org/hornetq/jms/example/AppletExample.java 2009-08-26 14:21:01 UTC (rev 7918)
@@ -0,0 +1,286 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.jms.example;
+
+import java.awt.Color;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+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.Session;
+import javax.jms.TextMessage;
+import javax.swing.BorderFactory;
+import javax.swing.JApplet;
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+import javax.swing.SwingUtilities;
+
+import org.hornetq.core.client.impl.ClientSessionFactoryImpl;
+import org.hornetq.core.config.TransportConfiguration;
+import org.hornetq.integration.transports.netty.NettyConnectorFactory;
+import org.hornetq.jms.HornetQQueue;
+import org.hornetq.jms.HornetQTopic;
+import org.hornetq.jms.client.HornetQConnectionFactory;
+
+/**
+ * A AppletExample
+ *
+ * @author <a href="mailto:jmesnil@redaht.com>Jeff Mesnil</a>
+ *
+ *
+ */
+public class AppletExample extends JApplet implements ActionListener
+{
+
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ private Destination destination;
+
+ private Connection connection;
+
+ private MessageProducer producer;
+
+ private MessageConsumer consumer;
+
+ private JTextArea display;
+
+ private JButton sendButton;
+
+ private Session session;
+
+ @Override
+ public void init()
+ {
+ super.init();
+
+ try
+ {
+ SwingUtilities.invokeAndWait(new Runnable()
+ {
+ public void run()
+ {
+ createGUI();
+ }
+ });
+ }
+ catch (Exception e)
+ {
+ System.err.println("createGUI didn't successfully complete");
+ }
+
+ Map<String, Object> params = new HashMap<String, Object>();
+ TransportConfiguration connector = new TransportConfiguration(NettyConnectorFactory.class.getName(), params);
+ ClientSessionFactoryImpl sf = new ClientSessionFactoryImpl(connector);
+ ConnectionFactory cf = new HornetQConnectionFactory(sf);
+ destination = new HornetQTopic("exampleTopic");
+
+ try
+ {
+ connection = cf.createConnection();
+ session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ producer = session.createProducer(destination);
+ consumer = session.createConsumer(destination);
+ consumer.setMessageListener(new MessageListener()
+ {
+ public void onMessage(final Message msg)
+ {
+ try
+ {
+ SwingUtilities.invokeAndWait(new Runnable()
+ {
+ public void run()
+ {
+ try
+ {
+ display.setText(display.getText() + "\n" + ((TextMessage)msg).getText());
+ }
+ catch (JMSException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ });
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ });
+ }
+ catch (JMSException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void start()
+ {
+ super.start();
+
+ try
+ {
+ connection.start();
+ }
+ catch (JMSException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void stop()
+ {
+ System.out.println("close connection");
+ if (connection != null)
+ {
+ try
+ {
+ connection.close();
+ }
+ catch (JMSException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ super.stop();
+
+ }
+
+ // Public --------------------------------------------------------
+
+ public static void main(String[] args)
+ {
+
+ final AppletExample applet = new AppletExample();
+ applet.init();
+
+ JFrame frame = new JFrame("Applet Example");
+ frame.getContentPane().add(applet);
+
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ frame.pack();
+ frame.setVisible(true);
+
+ applet.start();
+ Runtime.getRuntime().addShutdownHook(new Thread()
+ {
+ @Override
+ public void run()
+ {
+ applet.stop();
+ }
+ });
+ }
+
+ public void actionPerformed(ActionEvent e)
+ {
+ try
+ {
+ producer.send(session.createTextMessage((new Date()).toString()));
+ }
+ catch (JMSException e1)
+ {
+ e1.printStackTrace();
+ }
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ private void createGUI()
+ {
+ JPanel contentPane = new JPanel(new GridBagLayout());
+ GridBagConstraints c = new GridBagConstraints();
+ int numColumns = 3;
+
+ JLabel l1 = new JLabel("Received Messages:", JLabel.CENTER);
+ c.gridx = 0;
+ c.gridy = 0;
+ c.anchor = GridBagConstraints.SOUTH;
+ c.gridwidth = numColumns;
+ contentPane.add(l1, c);
+
+ display = new JTextArea(5, 20);
+ JScrollPane scrollPane = new JScrollPane(display);
+ display.setEditable(false);
+ display.setForeground(Color.gray);
+ c.gridy = 1;
+ c.gridwidth = numColumns;
+ c.anchor = GridBagConstraints.CENTER;
+ c.weighty = 1.0;
+ c.fill = GridBagConstraints.BOTH;
+ contentPane.add(scrollPane, c);
+
+ sendButton = new JButton("Send");
+ c.gridy = 2;
+ c.gridwidth = 1;
+ c.anchor = GridBagConstraints.SOUTH;
+ c.weighty = 0.0;
+ c.fill = GridBagConstraints.NONE;
+ contentPane.add(sendButton, c);
+
+ sendButton.addActionListener(this);
+
+ JButton clearButton = new JButton("Clear");
+ c.gridx = 2;
+ c.weightx = 0.0;
+ c.anchor = GridBagConstraints.SOUTHEAST;
+ c.fill = GridBagConstraints.NONE;
+ contentPane.add(clearButton, c);
+
+ clearButton.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ display.setText("");
+ }
+ });
+
+ // Finish setting up the content pane and its border.
+ contentPane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.black),
+ BorderFactory.createEmptyBorder(5, 20, 5, 10)));
+ setContentPane(contentPane);
+ }
+
+ // Inner classes -------------------------------------------------
+
+}
Added: trunk/examples/jms/applet/src/org/hornetq/jms/example/HttpStaticFileServer.java
===================================================================
--- trunk/examples/jms/applet/src/org/hornetq/jms/example/HttpStaticFileServer.java (rev 0)
+++ trunk/examples/jms/applet/src/org/hornetq/jms/example/HttpStaticFileServer.java 2009-08-26 14:21:01 UTC (rev 7918)
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.jms.example;
+
+import java.net.InetSocketAddress;
+import java.util.concurrent.Executors;
+
+import org.hornetq.common.example.HornetQExample;
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
+
+/**
+ * A HttpServer
+ *
+ * * @author The Netty Project (netty-dev(a)lists.jboss.org)
+ * @author Trustin Lee (tlee(a)redhat.com)
+ * @author <a href="mailto:jmesnil@redhat.com>Jeff Mesnil</a>
+ *
+ *
+ */
+public class HttpStaticFileServer extends HornetQExample
+{
+
+ public static void main(String[] args)
+ {
+ new HttpStaticFileServer().run(args);
+ }
+
+ @Override
+ public boolean runExample() throws Exception
+ {
+ // Configure the server.
+ ServerBootstrap bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(Executors.newCachedThreadPool(),
+ Executors.newCachedThreadPool()));
+ // Set up the event pipeline factory.
+ bootstrap.setPipelineFactory(new HttpStaticFileServerPipelineFactory());
+ // Bind and start to accept incoming connections.
+ bootstrap.bind(new InetSocketAddress(8088));
+
+ System.out.println("HTTP server ready to server on 8088");
+
+ System.out.println("open http://127.0.0.1:8088/applet.html to use the Applet");
+
+ while (true)
+ {
+ Thread.sleep(100);
+ }
+
+ }
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Added: trunk/examples/jms/applet/src/org/hornetq/jms/example/HttpStaticFileServerHandler.java
===================================================================
--- trunk/examples/jms/applet/src/org/hornetq/jms/example/HttpStaticFileServerHandler.java (rev 0)
+++ trunk/examples/jms/applet/src/org/hornetq/jms/example/HttpStaticFileServerHandler.java 2009-08-26 14:21:01 UTC (rev 7918)
@@ -0,0 +1,170 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.jms.example;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.RandomAccessFile;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.jboss.netty.channel.Channel;
+import org.jboss.netty.channel.ChannelFuture;
+import org.jboss.netty.channel.ChannelFutureListener;
+import org.jboss.netty.channel.ChannelHandlerContext;
+import org.jboss.netty.channel.ChannelPipelineCoverage;
+import org.jboss.netty.channel.ExceptionEvent;
+import org.jboss.netty.channel.MessageEvent;
+import org.jboss.netty.channel.SimpleChannelUpstreamHandler;
+import org.jboss.netty.handler.codec.frame.TooLongFrameException;
+import org.jboss.netty.handler.codec.http.DefaultHttpResponse;
+import org.jboss.netty.handler.codec.http.HttpHeaders;
+import org.jboss.netty.handler.codec.http.HttpMethod;
+import org.jboss.netty.handler.codec.http.HttpRequest;
+import org.jboss.netty.handler.codec.http.HttpResponse;
+import org.jboss.netty.handler.codec.http.HttpResponseStatus;
+import org.jboss.netty.handler.codec.http.HttpVersion;
+import org.jboss.netty.handler.stream.ChunkedFile;
+
+/**
+ * A HttpStaticFileServerHandler
+ *
+ * @author The Netty Project (netty-dev(a)lists.jboss.org)
+ * @author Trustin Lee (tlee(a)redhat.com)
+ * @author <a href="mailto:jmesnil@redhat.com>Jeff Mesnil</a>
+ *
+ *
+ */
+@ChannelPipelineCoverage("one")
+ public class HttpStaticFileServerHandler extends SimpleChannelUpstreamHandler {
+
+ @Override
+ public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
+ HttpRequest request = (HttpRequest) e.getMessage();
+ if (request.getMethod() != HttpMethod.GET) {
+ sendError(ctx, HttpResponseStatus.METHOD_NOT_ALLOWED);
+ return;
+ }
+
+ if (request.isChunked()) {
+ sendError(ctx, HttpResponseStatus.BAD_REQUEST);
+ return;
+ }
+
+ String path = sanitizeUri(request.getUri());
+ if (path == null) {
+ sendError(ctx, HttpResponseStatus.FORBIDDEN);
+ return;
+ }
+
+ File file = new File(path);
+ if (file.isHidden() || !file.exists()) {
+ sendError(ctx, HttpResponseStatus.NOT_FOUND);
+ return;
+ }
+ if (!file.isFile()) {
+ sendError(ctx, HttpResponseStatus.FORBIDDEN);
+ return;
+ }
+
+ RandomAccessFile raf;
+ try {
+ raf = new RandomAccessFile(file, "r");
+ } catch (FileNotFoundException fnfe) {
+ sendError(ctx, HttpResponseStatus.NOT_FOUND);
+ return;
+ }
+ long fileLength = raf.length();
+
+ HttpResponse response = new DefaultHttpResponse(
+ HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
+ response.setHeader(
+ HttpHeaders.Names.CONTENT_LENGTH, String.valueOf(fileLength));
+
+ Channel ch = e.getChannel();
+
+ // Write the initial line and the header.
+ ch.write(response);
+
+ // Write the content.
+ ChannelFuture writeFuture = ch.write(new ChunkedFile(raf, 0, fileLength, 8192));
+
+ // Decide whether to close the connection or not.
+ boolean close =
+ HttpHeaders.Values.CLOSE.equalsIgnoreCase(request.getHeader(HttpHeaders.Names.CONNECTION)) ||
+ request.getProtocolVersion().equals(HttpVersion.HTTP_1_0) &&
+ !HttpHeaders.Values.KEEP_ALIVE.equalsIgnoreCase(request.getHeader(HttpHeaders.Names.CONNECTION));
+
+ if (close) {
+ // Close the connection when the whole content is written out.
+ writeFuture.addListener(ChannelFutureListener.CLOSE);
+ }
+ }
+
+ @Override
+ public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
+ throws Exception {
+ Channel ch = e.getChannel();
+ Throwable cause = e.getCause();
+ if (cause instanceof TooLongFrameException) {
+ sendError(ctx, HttpResponseStatus.BAD_REQUEST);
+ return;
+ }
+
+ cause.printStackTrace();
+ if (ch.isConnected()) {
+ sendError(ctx, HttpResponseStatus.INTERNAL_SERVER_ERROR);
+ }
+ }
+
+ private String sanitizeUri(String uri) {
+ // Decode the path.
+ try {
+ uri = URLDecoder.decode(uri, "UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ try {
+ uri = URLDecoder.decode(uri, "ISO-8859-1");
+ } catch (UnsupportedEncodingException e1) {
+ throw new Error();
+ }
+ }
+
+ // Convert file separators.
+ uri = uri.replace('/', File.separatorChar);
+
+ // Simplistic dumb security check.
+ // You will have to do something serious in the production environment.
+ if (uri.contains(File.separator + ".") ||
+ uri.contains("." + File.separator) ||
+ uri.startsWith(".") || uri.endsWith(".")) {
+ return null;
+ }
+
+ // Convert to absolute path.
+ return System.getProperty("user.dir") + File.separator + uri;
+ }
+
+ private void sendError(ChannelHandlerContext ctx, HttpResponseStatus status) {
+ HttpResponse response = new DefaultHttpResponse(
+ HttpVersion.HTTP_1_1, status);
+ response.setHeader(
+ HttpHeaders.Names.CONTENT_TYPE, "text/plain; charset=UTF-8");
+ response.setContent(ChannelBuffers.copiedBuffer(
+ "Failure: " + status.toString() + "\r\n", "UTF-8"));
+
+ // Close the connection as soon as the error message is sent.
+ ctx.getChannel().write(response).addListener(ChannelFutureListener.CLOSE);
+ }
+}
\ No newline at end of file
Added: trunk/examples/jms/applet/src/org/hornetq/jms/example/HttpStaticFileServerPipelineFactory.java
===================================================================
--- trunk/examples/jms/applet/src/org/hornetq/jms/example/HttpStaticFileServerPipelineFactory.java (rev 0)
+++ trunk/examples/jms/applet/src/org/hornetq/jms/example/HttpStaticFileServerPipelineFactory.java 2009-08-26 14:21:01 UTC (rev 7918)
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.jms.example;
+
+import static org.jboss.netty.channel.Channels.pipeline;
+
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.channel.ChannelPipelineFactory;
+import org.jboss.netty.handler.codec.http.HttpRequestDecoder;
+import org.jboss.netty.handler.codec.http.HttpResponseEncoder;
+import org.jboss.netty.handler.stream.ChunkedWriteHandler;
+
+/**
+ * A HttpStaticFileServerPipelineFactory
+ *
+ * @author The Netty Project (netty-dev(a)lists.jboss.org)
+ * @author Trustin Lee (tlee(a)redhat.com)
+ * @author <a href="mailto:jmesnil@redhat.com>Jeff Mesnil</a>
+ *
+ *
+ */
+public class HttpStaticFileServerPipelineFactory implements ChannelPipelineFactory
+{
+ public ChannelPipeline getPipeline() throws Exception
+ {
+ // Create a default pipeline implementation.
+ ChannelPipeline pipeline = pipeline();
+
+ pipeline.addLast("decoder", new HttpRequestDecoder());
+ pipeline.addLast("encoder", new HttpResponseEncoder());
+ pipeline.addLast("chunkedWriter", new ChunkedWriteHandler());
+
+ pipeline.addLast("handler", new HttpStaticFileServerHandler());
+ return pipeline;
+ }
+
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
15 years, 4 months
JBoss hornetq SVN: r7917 - in trunk/docs: user-manual/en and 1 other directory.
by do-not-reply@jboss.org
Author: timfox
Date: 2009-08-26 07:11:08 -0400 (Wed, 26 Aug 2009)
New Revision: 7917
Modified:
trunk/docs/quickstart-guide/en/about.xml
trunk/docs/user-manual/en/preface.xml
Log:
tweak on docs
Modified: trunk/docs/quickstart-guide/en/about.xml
===================================================================
--- trunk/docs/quickstart-guide/en/about.xml 2009-08-25 23:36:13 UTC (rev 7916)
+++ trunk/docs/quickstart-guide/en/about.xml 2009-08-26 11:11:08 UTC (rev 7917)
@@ -32,9 +32,6 @@
/>.</para>
</listitem>
<listitem>
- <para>HornetQ is Red Hat's flagship Java messaging system.</para>
- </listitem>
- <listitem>
<para>For answers to more questions about what HornetQ is and isn't please visit
the <ulink url="http://www.jboss.org/community/wiki/HornetQGeneralFAQs">FAQs wiki
page</ulink>.</para>
Modified: trunk/docs/user-manual/en/preface.xml
===================================================================
--- trunk/docs/user-manual/en/preface.xml 2009-08-25 23:36:13 UTC (rev 7916)
+++ trunk/docs/user-manual/en/preface.xml 2009-08-26 11:11:08 UTC (rev 7917)
@@ -30,9 +30,6 @@
/>.</para>
</listitem>
<listitem>
- <para>HornetQ is Red Hat's flagship Java messaging system.</para>
- </listitem>
- <listitem>
<para>For answers to more questions about what HornetQ is and isn't please visit
the <ulink url="http://www.jboss.org/community/wiki/HornetQGeneralFAQs">FAQs wiki
page</ulink>.</para>
15 years, 4 months
JBoss hornetq SVN: r7916 - trunk/tests/src/org/hornetq/tests/integration/jms/largemessage.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2009-08-25 19:36:13 -0400 (Tue, 25 Aug 2009)
New Revision: 7916
Modified:
trunk/tests/src/org/hornetq/tests/integration/jms/largemessage/JMSLargeMessageTest.java
Log:
tweak
Modified: trunk/tests/src/org/hornetq/tests/integration/jms/largemessage/JMSLargeMessageTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/jms/largemessage/JMSLargeMessageTest.java 2009-08-25 23:35:52 UTC (rev 7915)
+++ trunk/tests/src/org/hornetq/tests/integration/jms/largemessage/JMSLargeMessageTest.java 2009-08-25 23:36:13 UTC (rev 7916)
@@ -14,7 +14,6 @@
package org.hornetq.tests.integration.jms.largemessage;
import java.io.IOException;
-import java.io.InputStream;
import java.io.OutputStream;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicInteger;
@@ -29,7 +28,6 @@
import javax.jms.Session;
import javax.jms.TextMessage;
-import org.hornetq.jms.tests.JMSTestCase;
import org.hornetq.tests.util.JMSTestBase;
/**
15 years, 4 months
JBoss hornetq SVN: r7915 - in trunk/tests/src/org/hornetq/tests: integration/jms/consumer and 2 other directories.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2009-08-25 19:35:52 -0400 (Tue, 25 Aug 2009)
New Revision: 7915
Modified:
trunk/tests/src/org/hornetq/tests/integration/jms/connection/CloseConnectionOnGCTest.java
trunk/tests/src/org/hornetq/tests/integration/jms/consumer/ConsumerTest.java
trunk/tests/src/org/hornetq/tests/integration/jms/largemessage/JMSLargeMessageTest.java
trunk/tests/src/org/hornetq/tests/util/JMSTestBase.java
Log:
few tweaks on JMSTestBase and modifying some tests to use it
Modified: trunk/tests/src/org/hornetq/tests/integration/jms/connection/CloseConnectionOnGCTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/jms/connection/CloseConnectionOnGCTest.java 2009-08-25 23:30:51 UTC (rev 7914)
+++ trunk/tests/src/org/hornetq/tests/integration/jms/connection/CloseConnectionOnGCTest.java 2009-08-25 23:35:52 UTC (rev 7915)
@@ -24,6 +24,7 @@
import org.hornetq.jms.client.HornetQConnectionFactory;
import org.hornetq.jms.server.impl.JMSServerManagerImpl;
import org.hornetq.tests.integration.jms.server.management.NullInitialContext;
+import org.hornetq.tests.util.JMSTestBase;
import org.hornetq.tests.util.UnitTestCase;
/**
@@ -34,31 +35,15 @@
*
*
*/
-public class CloseConnectionOnGCTest extends UnitTestCase
+public class CloseConnectionOnGCTest extends JMSTestBase
{
- private HornetQServer server;
-
- private JMSServerManagerImpl jmsServer;
-
private HornetQConnectionFactory cf;
- private static final String Q_NAME = "ConnectionTestQueue";
-
@Override
protected void setUp() throws Exception
{
super.setUp();
-
- Configuration conf = new ConfigurationImpl();
- conf.setSecurityEnabled(false);
- conf.setJMXManagementEnabled(true);
- conf.getAcceptorConfigurations()
- .add(new TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory"));
- server = HornetQ.newHornetQServer(conf, false);
- jmsServer = new JMSServerManagerImpl(server);
- jmsServer.setContext(new NullInitialContext());
- jmsServer.start();
- jmsServer.createQueue(Q_NAME, Q_NAME, null, true);
+
cf = new HornetQConnectionFactory(new TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMConnectorFactory"));
cf.setBlockOnPersistentSend(true);
cf.setPreAcknowledge(true);
@@ -67,26 +52,8 @@
@Override
protected void tearDown() throws Exception
{
- jmsServer.stop();
cf = null;
- if (server != null && server.isStarted())
- {
- try
- {
- server.stop();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- server = null;
-
- }
- server = null;
- jmsServer = null;
- cf = null;
-
super.tearDown();
}
Modified: trunk/tests/src/org/hornetq/tests/integration/jms/consumer/ConsumerTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/jms/consumer/ConsumerTest.java 2009-08-25 23:30:51 UTC (rev 7914)
+++ trunk/tests/src/org/hornetq/tests/integration/jms/consumer/ConsumerTest.java 2009-08-25 23:35:52 UTC (rev 7915)
@@ -21,31 +21,19 @@
import javax.jms.Session;
import javax.jms.TextMessage;
-import org.hornetq.core.config.Configuration;
import org.hornetq.core.config.TransportConfiguration;
-import org.hornetq.core.config.impl.ConfigurationImpl;
-import org.hornetq.core.server.HornetQ;
-import org.hornetq.core.server.HornetQServer;
import org.hornetq.core.server.Queue;
import org.hornetq.jms.HornetQQueue;
import org.hornetq.jms.client.HornetQConnectionFactory;
import org.hornetq.jms.client.HornetQSession;
-import org.hornetq.jms.server.impl.JMSServerManagerImpl;
-import org.hornetq.tests.integration.jms.server.management.NullInitialContext;
-import org.hornetq.tests.util.UnitTestCase;
+import org.hornetq.tests.util.JMSTestBase;
import org.hornetq.utils.SimpleString;
/**
* @author <a href="mailto:andy.taylor@jboss.org">Andy Taylor</a>
*/
-public class ConsumerTest extends UnitTestCase
+public class ConsumerTest extends JMSTestBase
{
- private HornetQServer server;
-
- private JMSServerManagerImpl jmsServer;
-
- private HornetQConnectionFactory cf;
-
private static final String Q_NAME = "ConsumerTestQueue";
private HornetQQueue jBossQueue;
@@ -55,45 +43,15 @@
{
super.setUp();
- Configuration conf = new ConfigurationImpl();
- conf.setSecurityEnabled(false);
- conf.setJMXManagementEnabled(true);
- conf.getAcceptorConfigurations()
- .add(new TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory"));
- server = HornetQ.newHornetQServer(conf, false);
- jmsServer = new JMSServerManagerImpl(server);
- jmsServer.setContext(new NullInitialContext());
- jmsServer.start();
jmsServer.createQueue(Q_NAME, Q_NAME, null, true);
cf = new HornetQConnectionFactory(new TransportConfiguration("org.hornetq.core.remoting.impl.invm.InVMConnectorFactory"));
- cf.setBlockOnPersistentSend(true);
- cf.setPreAcknowledge(true);
}
@Override
protected void tearDown() throws Exception
{
- jmsServer.stop();
-
cf = null;
- if (server != null && server.isStarted())
- {
- try
- {
- server.stop();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- server = null;
- }
- server = null;
- jmsServer = null;
- cf = null;
- jBossQueue = null;
-
super.tearDown();
}
@@ -167,7 +125,7 @@
consumer.setMessageListener(null);
consumer.receiveNoWait();
}
-
+
public void testCantReceiveWhenListenerIsSet() throws Exception
{
Connection conn = cf.createConnection();
@@ -188,7 +146,7 @@
}
catch (JMSException e)
{
- //Ok
+ // Ok
}
}
}
Modified: trunk/tests/src/org/hornetq/tests/integration/jms/largemessage/JMSLargeMessageTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/jms/largemessage/JMSLargeMessageTest.java 2009-08-25 23:30:51 UTC (rev 7914)
+++ trunk/tests/src/org/hornetq/tests/integration/jms/largemessage/JMSLargeMessageTest.java 2009-08-25 23:35:52 UTC (rev 7915)
@@ -61,7 +61,7 @@
protected void setUp() throws Exception
{
super.setUp();
- serverManager.createQueue("queue1", "/jms/queue1", null, true);
+ jmsServer.createQueue("queue1", "/jms/queue1", null, true);
queue1 = (Queue)context.lookup("/jms/queue1");
}
Modified: trunk/tests/src/org/hornetq/tests/util/JMSTestBase.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/util/JMSTestBase.java 2009-08-25 23:30:51 UTC (rev 7914)
+++ trunk/tests/src/org/hornetq/tests/util/JMSTestBase.java 2009-08-25 23:35:52 UTC (rev 7915)
@@ -60,7 +60,7 @@
protected HornetQServer server;
- protected JMSServerManagerImpl serverManager;
+ protected JMSServerManagerImpl jmsServer;
protected ConnectionFactory cf;
@@ -108,34 +108,34 @@
server = HornetQ.newHornetQServer(conf, false);
- serverManager = new JMSServerManagerImpl(server);
+ jmsServer = new JMSServerManagerImpl(server);
context = new InVMContext();
- serverManager.setContext(context);
- serverManager.start();
- serverManager.activated();
+ jmsServer.setContext(context);
+ jmsServer.start();
+ jmsServer.activated();
registerConnectionFactory();
}
protected void restartServer() throws Exception
{
- serverManager.start();
- serverManager.activated();
+ jmsServer.start();
+ jmsServer.activated();
context = new InVMContext();
- serverManager.setContext(context);
+ jmsServer.setContext(context);
registerConnectionFactory();
}
protected void killServer() throws Exception
{
- serverManager.stop();
+ jmsServer.stop();
}
@Override
protected void tearDown() throws Exception
{
- serverManager.stop();
+ jmsServer.stop();
server.stop();
@@ -143,7 +143,7 @@
server = null;
- serverManager = null;
+ jmsServer = null;
context = null;
@@ -169,7 +169,7 @@
List<String> jndiBindings = new ArrayList<String>();
jndiBindings.add("/cf");
- serverManager.createConnectionFactory("ManualReconnectionToSingleServerTest",
+ jmsServer.createConnectionFactory("ManualReconnectionToSingleServerTest",
connectorConfigs,
null,
DEFAULT_CLIENT_FAILURE_CHECK_PERIOD,
15 years, 4 months
JBoss hornetq SVN: r7914 - in trunk/tests: src/org/hornetq/tests/integration/jms and 2 other directories.
by do-not-reply@jboss.org
Author: clebert.suconic(a)jboss.com
Date: 2009-08-25 19:30:51 -0400 (Tue, 25 Aug 2009)
New Revision: 7914
Added:
trunk/tests/src/org/hornetq/tests/integration/jms/largemessage/
trunk/tests/src/org/hornetq/tests/integration/jms/largemessage/JMSLargeMessageTest.java
trunk/tests/src/org/hornetq/tests/util/JMSTestBase.java
Removed:
trunk/tests/jms-tests/src/org/hornetq/jms/tests/message/LargeMessageTest.java
Log:
https://jira.jboss.org/jira/browse/HORNETQ-107 - Move JMS test added by accident to integration-tests
Deleted: trunk/tests/jms-tests/src/org/hornetq/jms/tests/message/LargeMessageTest.java
===================================================================
--- trunk/tests/jms-tests/src/org/hornetq/jms/tests/message/LargeMessageTest.java 2009-08-25 20:13:48 UTC (rev 7913)
+++ trunk/tests/jms-tests/src/org/hornetq/jms/tests/message/LargeMessageTest.java 2009-08-25 23:30:51 UTC (rev 7914)
@@ -1,371 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat licenses this file to you under the Apache License, version
- * 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package org.hornetq.jms.tests.message;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicLong;
-
-import javax.jms.BytesMessage;
-import javax.jms.Connection;
-import javax.jms.JMSException;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-
-import org.hornetq.jms.tests.JMSTestCase;
-
-/**
- *
- * @author <a href="mailto:clebert.suconic@feodorov.com">Clebert Suconic</a>
- * @version <tt>$Revision: 6220 $</tt>
- *
- * $Id: MessageHeaderTest.java 6220 2009-03-30 19:38:11Z timfox $
- */
-public class LargeMessageTest extends JMSTestCase
-{
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- public void testSimpleLargeMessage() throws Exception
- {
- Connection conn = null;
-
- try
- {
- conn = cf.createConnection();
-
- Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageProducer prod = session.createProducer(queue1);
-
- BytesMessage m = session.createBytesMessage();
-
- m.setObjectProperty("JMS_HQ_InputStream", createFakeLargeStream(1024 * 1024));
-
- prod.send(m);
-
- conn.close();
-
- conn = cf.createConnection();
-
- session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageConsumer cons = session.createConsumer(queue1);
-
- conn.start();
-
- BytesMessage rm = (BytesMessage)cons.receive(10000);
-
- byte data[] = new byte[1024];
-
- System.out.println("Message = " + rm);
-
- for (int i = 0; i < 1024 * 1024; i += 1024)
- {
- int numberOfBytes = rm.readBytes(data);
- assertEquals(1024, numberOfBytes);
- for (int j = 0; j < 1024; j++)
- {
- assertEquals(getSamplebyte(i + j), data[j]);
- }
- }
-
- assertNotNull(rm);
-
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- }
-
- }
-
- public void testSimpleLargeMessage2() throws Exception
- {
- Connection conn = null;
-
- try
- {
- conn = cf.createConnection();
-
- Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageProducer prod = session.createProducer(queue1);
-
- BytesMessage m = session.createBytesMessage();
-
- m.setObjectProperty("JMS_HQ_InputStream", createFakeLargeStream(10));
-
- prod.send(m);
-
- conn.close();
-
- conn = cf.createConnection();
-
- session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageConsumer cons = session.createConsumer(queue1);
-
- conn.start();
-
- BytesMessage rm = (BytesMessage)cons.receive(10000);
-
- byte data[] = new byte[1024];
-
- System.out.println("Message = " + rm);
-
- int numberOfBytes = rm.readBytes(data);
- assertEquals(10, numberOfBytes);
- for (int j = 0; j < numberOfBytes; j++)
- {
- assertEquals(getSamplebyte(j), data[j]);
- }
-
- assertNotNull(rm);
-
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- }
-
- }
-
- public void testExceptionsOnSettingNonStreaming() throws Exception
- {
- Connection conn = null;
-
- try
- {
- conn = cf.createConnection();
-
- Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- TextMessage msg = session.createTextMessage();
-
- try
- {
- msg.setObjectProperty("JMS_HQ_InputStream", createFakeLargeStream(10));
- fail("Exception was expected");
- }
- catch (JMSException e)
- {
- }
-
- msg.setText("hello");
-
- MessageProducer prod = session.createProducer(queue1);
-
- prod.send(msg);
-
- conn.close();
-
- conn = cf.createConnection();
-
- session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageConsumer cons = session.createConsumer(queue1);
-
- conn.start();
-
- TextMessage rm = (TextMessage)cons.receive(10000);
-
- try
- {
- rm.setObjectProperty("JMS_HQ_OutputStream", new OutputStream()
- {
- @Override
- public void write(int b) throws IOException
- {
- System.out.println("b = " + b);
- }
-
- });
- fail("Exception was expected");
- }
- catch (JMSException e)
- {
- }
-
-
- assertEquals("hello", rm.getText());
-
- assertNotNull(rm);
-
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- }
-
- }
-
- public void testWaitOnOutputStream() throws Exception
- {
- int msgSize = 1024 * 1024;
-
- Connection conn = null;
-
- try
- {
- conn = cf.createConnection();
-
- Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageProducer prod = session.createProducer(queue1);
-
- BytesMessage m = session.createBytesMessage();
-
- m.setObjectProperty("JMS_HQ_InputStream", createFakeLargeStream(msgSize));
-
- prod.send(m);
-
- conn.close();
-
- conn = cf.createConnection();
-
- session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageConsumer cons = session.createConsumer(queue1);
-
- conn.start();
-
- BytesMessage rm = (BytesMessage)cons.receive(10000);
- assertNotNull(rm);
-
- final AtomicLong numberOfBytes = new AtomicLong(0);
-
- final AtomicInteger numberOfErrors = new AtomicInteger(0);
-
- OutputStream out = new OutputStream()
- {
-
- int position = 0;
-
- @Override
- public void write(int b) throws IOException
- {
- numberOfBytes.incrementAndGet();
- if (getSamplebyte(position++) != b)
- {
- System.out.println("Wrong byte at position " + position);
- numberOfErrors.incrementAndGet();
- }
- }
-
- };
-
- rm.setObjectProperty("JMS_HQ_SaveStream", out);
-
- assertEquals(msgSize, numberOfBytes.get());
-
- assertEquals(0, numberOfErrors.get());
-
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- }
-
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- protected byte getSamplebyte(final long position)
- {
- return (byte)('a' + (position) % ('z' - 'a' + 1));
- }
-
- // Creates a Fake LargeStream without using a real file
- protected InputStream createFakeLargeStream(final long size) throws Exception
- {
- return new InputStream()
- {
- private long count;
-
- private boolean closed = false;
-
- @Override
- public void close() throws IOException
- {
- super.close();
- System.out.println("Sent " + count + " bytes over fakeOutputStream, while size = " + size);
- closed = true;
- }
-
- @Override
- public int read() throws IOException
- {
- if (closed)
- {
- throw new IOException("Stream was closed");
- }
- if (count++ < size)
- {
- return getSamplebyte(count - 1);
- }
- else
- {
- return -1;
- }
- }
- };
-
- }
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
- class ThreadReader extends Thread
- {
- CountDownLatch latch;
-
- ThreadReader(CountDownLatch latch)
- {
- this.latch = latch;
- }
-
- public void run()
- {
- }
- }
-
-}
Copied: trunk/tests/src/org/hornetq/tests/integration/jms/largemessage/JMSLargeMessageTest.java (from rev 7912, trunk/tests/jms-tests/src/org/hornetq/jms/tests/message/LargeMessageTest.java)
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/jms/largemessage/JMSLargeMessageTest.java (rev 0)
+++ trunk/tests/src/org/hornetq/tests/integration/jms/largemessage/JMSLargeMessageTest.java 2009-08-25 23:30:51 UTC (rev 7914)
@@ -0,0 +1,352 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.tests.integration.jms.largemessage;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicLong;
+
+import javax.jms.BytesMessage;
+import javax.jms.Connection;
+import javax.jms.JMSException;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+import org.hornetq.jms.tests.JMSTestCase;
+import org.hornetq.tests.util.JMSTestBase;
+
+/**
+ *
+ * @author <a href="mailto:clebert.suconic@feodorov.com">Clebert Suconic</a>
+ * @version <tt>$Revision: 6220 $</tt>
+ *
+ * $Id: MessageHeaderTest.java 6220 2009-03-30 19:38:11Z timfox $
+ */
+public class JMSLargeMessageTest extends JMSTestBase
+{
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ Queue queue1;
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ protected boolean usePersistence()
+ {
+ return true;
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ serverManager.createQueue("queue1", "/jms/queue1", null, true);
+
+ queue1 = (Queue)context.lookup("/jms/queue1");
+ }
+
+ protected void tearDown() throws Exception
+ {
+ queue1 = null;
+ super.tearDown();
+ }
+
+ public void testSimpleLargeMessage() throws Exception
+ {
+ Connection conn = null;
+
+ try
+ {
+ conn = cf.createConnection();
+
+ Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageProducer prod = session.createProducer(queue1);
+
+ BytesMessage m = session.createBytesMessage();
+
+ m.setObjectProperty("JMS_HQ_InputStream", createFakeLargeStream(1024 * 1024));
+
+ prod.send(m);
+
+ conn.close();
+
+ conn = cf.createConnection();
+
+ session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageConsumer cons = session.createConsumer(queue1);
+
+ conn.start();
+
+ BytesMessage rm = (BytesMessage)cons.receive(10000);
+
+ byte data[] = new byte[1024];
+
+ System.out.println("Message = " + rm);
+
+ for (int i = 0; i < 1024 * 1024; i += 1024)
+ {
+ int numberOfBytes = rm.readBytes(data);
+ assertEquals(1024, numberOfBytes);
+ for (int j = 0; j < 1024; j++)
+ {
+ assertEquals(getSamplebyte(i + j), data[j]);
+ }
+ }
+
+ assertNotNull(rm);
+
+ }
+ finally
+ {
+ if (conn != null)
+ {
+ conn.close();
+ }
+ }
+
+ }
+
+ public void testSimpleLargeMessage2() throws Exception
+ {
+ Connection conn = null;
+
+ try
+ {
+ conn = cf.createConnection();
+
+ Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageProducer prod = session.createProducer(queue1);
+
+ BytesMessage m = session.createBytesMessage();
+
+ m.setObjectProperty("JMS_HQ_InputStream", createFakeLargeStream(10));
+
+ prod.send(m);
+
+ conn.close();
+
+ conn = cf.createConnection();
+
+ session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageConsumer cons = session.createConsumer(queue1);
+
+ conn.start();
+
+ BytesMessage rm = (BytesMessage)cons.receive(10000);
+
+ byte data[] = new byte[1024];
+
+ System.out.println("Message = " + rm);
+
+ int numberOfBytes = rm.readBytes(data);
+ assertEquals(10, numberOfBytes);
+ for (int j = 0; j < numberOfBytes; j++)
+ {
+ assertEquals(getSamplebyte(j), data[j]);
+ }
+
+ assertNotNull(rm);
+
+ }
+ finally
+ {
+ if (conn != null)
+ {
+ conn.close();
+ }
+ }
+
+ }
+
+ public void testExceptionsOnSettingNonStreaming() throws Exception
+ {
+ Connection conn = null;
+
+ try
+ {
+ conn = cf.createConnection();
+
+ Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ TextMessage msg = session.createTextMessage();
+
+ try
+ {
+ msg.setObjectProperty("JMS_HQ_InputStream", createFakeLargeStream(10));
+ fail("Exception was expected");
+ }
+ catch (JMSException e)
+ {
+ }
+
+ msg.setText("hello");
+
+ MessageProducer prod = session.createProducer(queue1);
+
+ prod.send(msg);
+
+ conn.close();
+
+ conn = cf.createConnection();
+
+ session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageConsumer cons = session.createConsumer(queue1);
+
+ conn.start();
+
+ TextMessage rm = (TextMessage)cons.receive(10000);
+
+ try
+ {
+ rm.setObjectProperty("JMS_HQ_OutputStream", new OutputStream()
+ {
+ @Override
+ public void write(int b) throws IOException
+ {
+ System.out.println("b = " + b);
+ }
+
+ });
+ fail("Exception was expected");
+ }
+ catch (JMSException e)
+ {
+ }
+
+
+ assertEquals("hello", rm.getText());
+
+ assertNotNull(rm);
+
+ }
+ finally
+ {
+ if (conn != null)
+ {
+ conn.close();
+ }
+ }
+
+ }
+
+ public void testWaitOnOutputStream() throws Exception
+ {
+ int msgSize = 1024 * 1024;
+
+ Connection conn = null;
+
+ try
+ {
+ conn = cf.createConnection();
+
+ Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageProducer prod = session.createProducer(queue1);
+
+ BytesMessage m = session.createBytesMessage();
+
+ m.setObjectProperty("JMS_HQ_InputStream", createFakeLargeStream(msgSize));
+
+ prod.send(m);
+
+ conn.close();
+
+ conn = cf.createConnection();
+
+ session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageConsumer cons = session.createConsumer(queue1);
+
+ conn.start();
+
+ BytesMessage rm = (BytesMessage)cons.receive(10000);
+ assertNotNull(rm);
+
+ final AtomicLong numberOfBytes = new AtomicLong(0);
+
+ final AtomicInteger numberOfErrors = new AtomicInteger(0);
+
+ OutputStream out = new OutputStream()
+ {
+
+ int position = 0;
+
+ @Override
+ public void write(int b) throws IOException
+ {
+ numberOfBytes.incrementAndGet();
+ if (getSamplebyte(position++) != b)
+ {
+ System.out.println("Wrong byte at position " + position);
+ numberOfErrors.incrementAndGet();
+ }
+ }
+
+ };
+
+ rm.setObjectProperty("JMS_HQ_SaveStream", out);
+
+ assertEquals(msgSize, numberOfBytes.get());
+
+ assertEquals(0, numberOfErrors.get());
+
+ }
+ finally
+ {
+ if (conn != null)
+ {
+ conn.close();
+ }
+ }
+
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+ class ThreadReader extends Thread
+ {
+ CountDownLatch latch;
+
+ ThreadReader(CountDownLatch latch)
+ {
+ this.latch = latch;
+ }
+
+ public void run()
+ {
+ }
+ }
+
+}
Added: trunk/tests/src/org/hornetq/tests/util/JMSTestBase.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/util/JMSTestBase.java (rev 0)
+++ trunk/tests/src/org/hornetq/tests/util/JMSTestBase.java 2009-08-25 23:30:51 UTC (rev 7914)
@@ -0,0 +1,206 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.tests.util;
+
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_ACK_BATCH_SIZE;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_AUTO_GROUP;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_ACKNOWLEDGE;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_BLOCK_ON_PERSISTENT_SEND;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CACHE_LARGE_MESSAGE_CLIENT;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CLIENT_FAILURE_CHECK_PERIOD;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONNECTION_TTL;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONSUMER_MAX_RATE;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_CONSUMER_WINDOW_SIZE;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MAX_CONNECTIONS;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_MIN_LARGE_MESSAGE_SIZE;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRE_ACKNOWLEDGE;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRODUCER_MAX_RATE;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_PRODUCER_WINDOW_SIZE;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_THREAD_POOL_MAX_SIZE;
+import static org.hornetq.core.client.impl.ClientSessionFactoryImpl.DEFAULT_USE_GLOBAL_POOLS;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jms.ConnectionFactory;
+
+import org.hornetq.core.config.Configuration;
+import org.hornetq.core.config.TransportConfiguration;
+import org.hornetq.core.server.HornetQ;
+import org.hornetq.core.server.HornetQServer;
+import org.hornetq.integration.transports.netty.NettyAcceptorFactory;
+import org.hornetq.integration.transports.netty.NettyConnectorFactory;
+import org.hornetq.jms.server.impl.JMSServerManagerImpl;
+import org.hornetq.tests.unit.util.InVMContext;
+import org.hornetq.utils.Pair;
+
+/**
+ * A JMSBaseTest
+ *
+ * @author <mailto:clebert.suconic@jboss.org">Clebert Suconic</a>
+ *
+ *
+ */
+public class JMSTestBase extends ServiceTestBase
+{
+
+ protected HornetQServer server;
+
+ protected JMSServerManagerImpl serverManager;
+
+ protected ConnectionFactory cf;
+
+ protected InVMContext context;
+
+ // Static --------------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // TestCase overrides -------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ protected boolean useSecurity()
+ {
+ return false;
+ }
+
+ protected boolean useJMX()
+ {
+ return true;
+ }
+
+ protected boolean usePersistence()
+ {
+ return false;
+ }
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ Configuration conf = createDefaultConfig(false);
+ conf.setSecurityEnabled(false);
+ conf.setJMXManagementEnabled(true);
+
+ conf.getAcceptorConfigurations().add(new TransportConfiguration(NettyAcceptorFactory.class.getName()));
+
+ server = HornetQ.newHornetQServer(conf, false);
+
+ serverManager = new JMSServerManagerImpl(server);
+ context = new InVMContext();
+ serverManager.setContext(context);
+ serverManager.start();
+ serverManager.activated();
+
+ registerConnectionFactory();
+ }
+
+ protected void restartServer() throws Exception
+ {
+ serverManager.start();
+ serverManager.activated();
+ context = new InVMContext();
+ serverManager.setContext(context);
+ registerConnectionFactory();
+ }
+
+ protected void killServer() throws Exception
+ {
+ serverManager.stop();
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+
+ serverManager.stop();
+
+ server.stop();
+
+ context.close();
+
+ server = null;
+
+ serverManager = null;
+
+ context = null;
+
+ super.tearDown();
+ }
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+ private void registerConnectionFactory() throws Exception
+ {
+ int retryInterval = 1000;
+ double retryIntervalMultiplier = 1.0;
+ int reconnectAttempts = -1;
+ boolean failoverOnServerShutdown = true;
+ int callTimeout = 30000;
+
+ List<Pair<TransportConfiguration, TransportConfiguration>> connectorConfigs = new ArrayList<Pair<TransportConfiguration, TransportConfiguration>>();
+ connectorConfigs.add(new Pair<TransportConfiguration, TransportConfiguration>(new TransportConfiguration(NettyConnectorFactory.class.getName()),
+ null));
+
+ List<String> jndiBindings = new ArrayList<String>();
+ jndiBindings.add("/cf");
+
+ serverManager.createConnectionFactory("ManualReconnectionToSingleServerTest",
+ connectorConfigs,
+ null,
+ DEFAULT_CLIENT_FAILURE_CHECK_PERIOD,
+ DEFAULT_CONNECTION_TTL,
+ callTimeout,
+ DEFAULT_MAX_CONNECTIONS,
+ DEFAULT_CACHE_LARGE_MESSAGE_CLIENT,
+ DEFAULT_MIN_LARGE_MESSAGE_SIZE,
+ DEFAULT_CONSUMER_WINDOW_SIZE,
+ DEFAULT_CONSUMER_MAX_RATE,
+ DEFAULT_PRODUCER_WINDOW_SIZE,
+ DEFAULT_PRODUCER_MAX_RATE,
+ DEFAULT_BLOCK_ON_ACKNOWLEDGE,
+ DEFAULT_BLOCK_ON_PERSISTENT_SEND,
+ DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND,
+ DEFAULT_AUTO_GROUP,
+ DEFAULT_PRE_ACKNOWLEDGE,
+ DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
+ DEFAULT_ACK_BATCH_SIZE,
+ DEFAULT_ACK_BATCH_SIZE,
+ DEFAULT_USE_GLOBAL_POOLS,
+ DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE,
+ DEFAULT_THREAD_POOL_MAX_SIZE,
+ retryInterval,
+ retryIntervalMultiplier,
+ reconnectAttempts,
+ failoverOnServerShutdown,
+ jndiBindings);
+
+ cf = (ConnectionFactory)context.lookup("/cf");
+
+ }
+
+}
15 years, 4 months