[jboss-cvs] JBoss Messaging SVN: r2264 - in branches/Branch_1_0: docs and 47 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sun Feb 11 08:16:26 EST 2007
Author: ovidiu.feodorov at jboss.com
Date: 2007-02-11 08:16:25 -0500 (Sun, 11 Feb 2007)
New Revision: 2264
Added:
branches/Branch_1_0/docs/examples/mdb-failure/
branches/Branch_1_0/docs/examples/mdb-failure/README.html
branches/Branch_1_0/docs/examples/mdb-failure/build.xml
branches/Branch_1_0/docs/examples/mdb-failure/do-not-distribute.properties
branches/Branch_1_0/docs/examples/mdb-failure/etc/
branches/Branch_1_0/docs/examples/mdb-failure/etc/META-INF/
branches/Branch_1_0/docs/examples/mdb-failure/etc/META-INF/ejb-jar.xml
branches/Branch_1_0/docs/examples/mdb-failure/etc/META-INF/jboss.xml
branches/Branch_1_0/docs/examples/mdb-failure/etc/jndi.properties
branches/Branch_1_0/docs/examples/mdb-failure/etc/log4j.xml
branches/Branch_1_0/docs/examples/mdb-failure/src/
branches/Branch_1_0/docs/examples/mdb-failure/src/org/
branches/Branch_1_0/docs/examples/mdb-failure/src/org/jboss/
branches/Branch_1_0/docs/examples/mdb-failure/src/org/jboss/example/
branches/Branch_1_0/docs/examples/mdb-failure/src/org/jboss/example/jms/
branches/Branch_1_0/docs/examples/mdb-failure/src/org/jboss/example/jms/mdbfailure/
branches/Branch_1_0/docs/examples/mdb-failure/src/org/jboss/example/jms/mdbfailure/MDBFailureExample.java
branches/Branch_1_0/docs/examples/mdb-failure/src/org/jboss/example/jms/mdbfailure/Sender.java
branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/ClientExitTest.java
branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/ClientInRestrictedSecurityEnvironmentTest.java
branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/DuplicateClientIDTest.java
branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/GracefulClient.java
branches/Branch_1_0/tests/src/org/jboss/test/messaging/tools/misc/
branches/Branch_1_0/tests/src/org/jboss/test/messaging/tools/misc/ConfigurableSecurityManager.java
branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/
branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/jbosssx/
branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/jbosssx/SecurityAssociationTest.java
branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/
branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/ClientInvokerTimeoutTest.java
branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/LazySubsystem.java
branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/RemotingTest.java
branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/TestClientInvoker.java
branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/util/
branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystem.java
branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystemService.java
branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystemServiceMBean.java
branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/util/SimpleConnectionListener.java
branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/util/TestableSubsystem.java
Removed:
branches/Branch_1_0/docs/examples/mdb-failure/README.html
branches/Branch_1_0/docs/examples/mdb-failure/build.xml
branches/Branch_1_0/docs/examples/mdb-failure/do-not-distribute.properties
branches/Branch_1_0/docs/examples/mdb-failure/etc/
branches/Branch_1_0/docs/examples/mdb-failure/etc/META-INF/
branches/Branch_1_0/docs/examples/mdb-failure/etc/META-INF/ejb-jar.xml
branches/Branch_1_0/docs/examples/mdb-failure/etc/META-INF/jboss.xml
branches/Branch_1_0/docs/examples/mdb-failure/etc/jndi.properties
branches/Branch_1_0/docs/examples/mdb-failure/etc/log4j.xml
branches/Branch_1_0/docs/examples/mdb-failure/src/
branches/Branch_1_0/docs/examples/mdb-failure/src/org/
branches/Branch_1_0/docs/examples/mdb-failure/src/org/jboss/
branches/Branch_1_0/docs/examples/mdb-failure/src/org/jboss/example/
branches/Branch_1_0/docs/examples/mdb-failure/src/org/jboss/example/jms/
branches/Branch_1_0/docs/examples/mdb-failure/src/org/jboss/example/jms/mdbfailure/
branches/Branch_1_0/docs/examples/mdb-failure/src/org/jboss/example/jms/mdbfailure/MDBFailureExample.java
branches/Branch_1_0/docs/examples/mdb-failure/src/org/jboss/example/jms/mdbfailure/Sender.java
branches/Branch_1_0/tests/src/org/jboss/test/messaging/tools/misc/ConfigurableSecurityManager.java
branches/Branch_1_0/tests/src/org/jboss/test/messaging/util/RemotingTest.java
branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/jbosssx/
branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/jbosssx/SecurityAssociationTest.java
branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/
branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/ClientInvokerTimeoutTest.java
branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/LazySubsystem.java
branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/RemotingTest.java
branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/TestClientInvoker.java
branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/util/
branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystem.java
branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystemService.java
branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystemServiceMBean.java
branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/util/SimpleConnectionListener.java
branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/util/TestableSubsystem.java
Modified:
branches/Branch_1_0/build-messaging.xml
branches/Branch_1_0/build-thirdparty.xml
branches/Branch_1_0/docs/README.html
branches/Branch_1_0/docs/examples/stateless/build.xml
branches/Branch_1_0/lib/README.txt
branches/Branch_1_0/lib/jbosssx.jar
branches/Branch_1_0/messaging.iml
branches/Branch_1_0/src/main/org/jboss/jms/client/JBossConnectionFactory.java
branches/Branch_1_0/src/main/org/jboss/jms/client/JBossQueueBrowser.java
branches/Branch_1_0/src/main/org/jboss/jms/client/container/SessionAspect.java
branches/Branch_1_0/src/main/org/jboss/jms/client/delegate/ClientBrowserDelegate.java
branches/Branch_1_0/src/main/org/jboss/jms/client/remoting/ClientSocketWrapper.java
branches/Branch_1_0/src/main/org/jboss/jms/client/state/SessionState.java
branches/Branch_1_0/src/main/org/jboss/jms/server/ConnectionManager.java
branches/Branch_1_0/src/main/org/jboss/jms/server/SecurityManager.java
branches/Branch_1_0/src/main/org/jboss/jms/server/ServerPeer.java
branches/Branch_1_0/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactoryJNDIMapper.java
branches/Branch_1_0/src/main/org/jboss/jms/server/connectionmanager/SimpleConnectionManager.java
branches/Branch_1_0/src/main/org/jboss/jms/server/container/SecurityAspect.java
branches/Branch_1_0/src/main/org/jboss/jms/server/endpoint/BrowserEndpoint.java
branches/Branch_1_0/src/main/org/jboss/jms/server/endpoint/ServerBrowserEndpoint.java
branches/Branch_1_0/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java
branches/Branch_1_0/src/main/org/jboss/jms/server/endpoint/ServerConnectionFactoryEndpoint.java
branches/Branch_1_0/src/main/org/jboss/jms/server/endpoint/ServerSessionEndpoint.java
branches/Branch_1_0/src/main/org/jboss/jms/server/endpoint/advised/BrowserAdvised.java
branches/Branch_1_0/src/main/org/jboss/jms/server/plugin/JDBCChannelMapper.java
branches/Branch_1_0/src/main/org/jboss/jms/server/remoting/ServerSocketWrapper.java
branches/Branch_1_0/src/main/org/jboss/jms/server/security/SecurityMetadataStore.java
branches/Branch_1_0/src/main/org/jboss/jms/tx/MessagingXAResource.java
branches/Branch_1_0/src/main/org/jboss/messaging/core/ChannelSupport.java
branches/Branch_1_0/src/main/org/jboss/messaging/core/plugin/JDBCPersistenceManager.java
branches/Branch_1_0/tests/bin/stop-rmi-server
branches/Branch_1_0/tests/build.xml
branches/Branch_1_0/tests/etc/log4j.info.xml
branches/Branch_1_0/tests/etc/log4j.trace.xml
branches/Branch_1_0/tests/etc/log4j.xml
branches/Branch_1_0/tests/smoke/build.xml
branches/Branch_1_0/tests/src/org/jboss/test/messaging/core/paging/PagingStateTestBase.java
branches/Branch_1_0/tests/src/org/jboss/test/messaging/core/paging/SingleChannel_NP_2PCTest.java
branches/Branch_1_0/tests/src/org/jboss/test/messaging/core/paging/SingleChannel_NP_NTTest.java
branches/Branch_1_0/tests/src/org/jboss/test/messaging/core/paging/SingleChannel_NP_TTest.java
branches/Branch_1_0/tests/src/org/jboss/test/messaging/core/plugin/JDBCPersistenceManagerTest.java
branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/BrowserTest.java
branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/ConnectionFactoryTest.java
branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/DurableSubscriberTest.java
branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/JCAWrapperTest.java
branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/JMSTest.java
branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/MessageConsumerTest.java
branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/QueueTest.java
branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/XATest.java
branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/server/plugin/JDBCChannelMapperTest.java
branches/Branch_1_0/tests/src/org/jboss/test/messaging/tools/jmx/MockJBossSecurityManager.java
branches/Branch_1_0/tests/src/org/jboss/test/messaging/util/XMLUtilTest.java
branches/Branch_1_0/util/do-not-distribute.properties
Log:
merging Branch_1_0_1_SP -r 1693:2261
Modified: branches/Branch_1_0/build-messaging.xml
===================================================================
--- branches/Branch_1_0/build-messaging.xml 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/build-messaging.xml 2007-02-11 13:16:25 UTC (rev 2264)
@@ -745,6 +745,7 @@
<ant dir="./docs/examples/queue" antfile="build.xml" inheritAll="false" target="clean"/>
<ant dir="./docs/examples/topic" antfile="build.xml" inheritAll="false" target="clean"/>
<ant dir="./docs/examples/mdb" antfile="build.xml" inheritAll="false" target="clean"/>
+ <ant dir="./docs/examples/mdb-failure" antfile="build.xml" inheritAll="false" target="clean"/>
<ant dir="./docs/examples/stateless" antfile="build.xml" inheritAll="false" target="clean"/>
<ant dir="./docs/examples/ejb3mdb" antfile="build.xml" inheritAll="false" target="clean"/>
<ant dir="./docs/examples/secure-socket" antfile="build.xml" inheritAll="false" target="clean"/>
Modified: branches/Branch_1_0/build-thirdparty.xml
===================================================================
--- branches/Branch_1_0/build-thirdparty.xml 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/build-thirdparty.xml 2007-02-11 13:16:25 UTC (rev 2264)
@@ -92,7 +92,7 @@
<componentref name="jboss/common-logging-spi" version="2.0.2.GA"/>
<componentref name="jboss/aop" version="1.5.0.GA"/>
<componentref name="jboss/serialization" version="1.0.3.GA"/>
- <componentref name="jboss/remoting" version="2.2.0.Alpha3"/>
+ <componentref name="jboss/remoting" version="2.2.0.Alpha7"/>
<componentref name="jboss/jbossts" version="4.2.2.GA"/>
<!-- Need this otherwise project doesn't build in Eclipse -->
Modified: branches/Branch_1_0/docs/README.html
===================================================================
--- branches/Branch_1_0/docs/README.html 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/docs/README.html 2007-02-11 13:16:25 UTC (rev 2264)
@@ -7,9 +7,9 @@
</head>
<body>
<h1><br>
-JBoss Messaging 1.0.1.SP2 Release Notes</h1>
+JBoss Messaging 1.0.1.SP4 Release Notes</h1>
<br>
-December 02, 2006<br>
+February 11, 2007<br>
<br>
<h2>Installation</h2>
<br>
@@ -26,35 +26,84 @@
<br>
<br>
<h2>Summary of Changes</h2>
+This service pack fixes several major bugs present in 1.0.1.SP2 and
+previous releases.<br>
<br>
-This is a bug fix release. It fixes a major concurrency bug (<a
- href="http://jira.jboss.org/jira/browse/JBMESSAGING-660">JBMESSAGING-660</a>),
-and also adds some DLQ handling improvements.<br>
+The most serious is <a
+ href="http://jira.jboss.org/jira/browse/JBMESSAGING-721">http://jira.jboss.org/jira/browse/JBMESSAGING-721</a>,
+which was causing message redelivery not to function properly. This bug
+fix alone should justify an upgrade to 1.0.1.SP4, especially if you use
+Message Driven Beans and Container Managed Transactions.<br>
<br>
-<h2>Release Notes </h2>
-<big></big>
-<h3> </h3>
-<h2 style="margin-left: 40px;">Bug</h2>
+Another potentially dangerous misbehavior is
+<a href="http://jira.jboss.org/jira/browse/JBMESSAGING-787">http://jira.jboss.org/jira/browse/JBMESSAGING-787</a>
+that was causing
+long-running invocations (such as sending a large transaction to the
+server) to time out inadvertently. The root cause was identified to be
+<a href="http://jira.jboss.org/jira/browse/JBREM-691">http://jira.jboss.org/jira/browse/JBREM-691</a>.
+The new
+Remoting library incorporated by 1.0.1.SP4 contains the fix for this
+bug.<br>
+<br>
+Other bugs fixes address the following 1.0.1.SP2 problems:<br>
+<ul>
+ <li>Broken QueueBrowser behavior (<a
+ href="http://jira.jboss.org/jira/browse/JBMESSAGING-803">http://jira.jboss.org/jira/browse/JBMESSAGING-803</a>)</li>
+ <li>Non-compliant client ID behavior - the previous version
+allowed simultaneous clients with same client ID
+(<a href="http://jira.jboss.org/jira/browse/JBMESSAGING-791">http://jira.jboss.org/jira/browse/JBMESSAGING-791</a>)</li>
+ <li>Incorrect handling of the replyTo property for persistent
+messages
+in some situations (<a
+ href="http://jira.jboss.org/jira/browse/JBMESSAGING-757">http://jira.jboss.org/jira/browse/JBMESSAGING-757</a>)</li>
+ <li>Corruption of the security context in managed environment (<a
+ href="http://jira.jboss.org/jira/browse/JBMESSAGING-807">http://jira.jboss.org/jira/browse/JBMESSAGING-807</a>)</li>
+ <li>Potential deadlock during the client initialization (<a
+ href="http://jira.jboss.org/jira/browse/JBMESSAGING-800">http://jira.jboss.org/jira/browse/JBMESSAGING-800</a>)</li>
+ <li>Memory leaks (<a
+ href="http://jira.jboss.org/jira/browse/JBMESSAGING-638">http://jira.jboss.org/jira/browse/JBMESSAGING-638</a>)</li>
+</ul>
+<br>
+<h2>Release Notes</h2>
+<h2 style="margin-left: 40px;">Bugs</h2>
<ul style="margin-left: 40px;">
- <li>[<a href="http://jira.jboss.com/jira/browse/JBMESSAGING-644">JBMESSAGING-644</a>]
-- Lease fails with a NPE if server is restarted and client still running</li>
- <li>[<a href="http://jira.jboss.com/jira/browse/JBMESSAGING-660">JBMESSAGING-660</a>]
-- Race Condition Between Session.close and Session.commit or
-Session.rollback</li>
- <li>[<a href="http://jira.jboss.com/jira/browse/JBMESSAGING-665">JBMESSAGING-665</a>]
-- 4.0.5.GA ejb3 smoke test fails</li>
+ <li>[<a href="http://jira.jboss.com/jira/browse/JBMESSAGING-417">JBMESSAGING-417</a>]
+- JMS Client does not exit</li>
+ <li>[<a href="http://jira.jboss.com/jira/browse/JBMESSAGING-638">JBMESSAGING-638</a>]
+- Potential memory leak when using 2pc via JCA adapter.</li>
+ <li>[<a href="http://jira.jboss.com/jira/browse/JBMESSAGING-664">JBMESSAGING-664</a>]
+- The 4.0.5.GA jnlp installer smoke test fails</li>
+ <li>[<a href="http://jira.jboss.com/jira/browse/JBMESSAGING-721">JBMESSAGING-721</a>]
+- Message redelivery doesn't work </li>
+ <li>[<a href="http://jira.jboss.com/jira/browse/JBMESSAGING-757">JBMESSAGING-757</a>]
+- JDBCPersistenceManager incorrectly detects if a replytoId was null
+when restoring a message from a ResultSet</li>
+ <li>[<a href="http://jira.jboss.com/jira/browse/JBMESSAGING-787">JBMESSAGING-787</a>]
+- Invocations time out because remoting mismanages client invokers,
+sending bussines traffic over client invokers with small timeout</li>
+ <li>[<a href="http://jira.jboss.com/jira/browse/JBMESSAGING-791">JBMESSAGING-791</a>]
+- Duplicates clientIDs are not throwing InvalidClientIDException</li>
+ <li>[<a href="http://jira.jboss.com/jira/browse/JBMESSAGING-800">JBMESSAGING-800</a>]
+- Deadlock in aop stack deployment</li>
+ <li>[<a href="http://jira.jboss.com/jira/browse/JBMESSAGING-803">JBMESSAGING-803</a>]
+- QueueBrowser doesn't refresh the content of its Enumeration on the
+second getEnumeration() call</li>
+ <li>[<a href="http://jira.jboss.com/jira/browse/JBMESSAGING-807">JBMESSAGING-807</a>]
+- security context switch after sending a message</li>
+ <li>[<a href="http://jira.jboss.com/jira/browse/JBMESSAGING-821">JBMESSAGING-821</a>]
+- org.jboss.test.messaging.core.paging tests fail in-VM on Linux</li>
+ <li>[<a href="http://jira.jboss.com/jira/browse/JBMESSAGING-824">JBMESSAGING-824</a>]
+- queue smoke test fails</li>
</ul>
-<h2 style="margin-left: 40px;">Sub-task</h2>
-<div style="margin-left: 40px;">
-<ul>
- <li>[<a href="http://jira.jboss.org/jira/browse/JBMESSAGING-666">JBMESSAGING-666</a>]
-- Basic DLQ functionality</li>
+<h2 style="margin-left: 40px;">Tasks</h2>
+<ul style="margin-left: 40px;">
+ <li>[<a href="http://jira.jboss.com/jira/browse/JBMESSAGING-755">JBMESSAGING-755</a>]
+- Bring mdb-failure's README.html up to date</li>
+ <li>[<a href="http://jira.jboss.com/jira/browse/JBMESSAGING-756">JBMESSAGING-756</a>]
+- Enable mdb-failure smoke test so it will run with the smoke test suite<br>
+ </li>
</ul>
-</div>
<br>
-<h2 style="margin-left: 40px;"><br>
-</h2>
-<br>
<hr style="width: 100%; height: 2px;">
</body>
</html>
Copied: branches/Branch_1_0/docs/examples/mdb-failure (from rev 2261, branches/Branch_1_0_1_SP/docs/examples/mdb-failure)
Deleted: branches/Branch_1_0/docs/examples/mdb-failure/README.html
===================================================================
--- branches/Branch_1_0_1_SP/docs/examples/mdb-failure/README.html 2007-02-11 09:04:09 UTC (rev 2261)
+++ branches/Branch_1_0/docs/examples/mdb-failure/README.html 2007-02-11 13:16:25 UTC (rev 2264)
@@ -1,180 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
-<head>
- <meta content="text/html; charset=ISO-8859-1"
- http-equiv="content-type">
- <title>JBoss Messaging Example - Message Driven Bean Failure</title>
-</head>
-<body>
-<br>
-<h1>Message Driven Bean Behavior on Failure Example</h1>
-$Revision: 1459 $
-<h2>Overview</h2>
-<br>
-This example deploys a simple Message Driven Bean that processes
-messages sent to a test queue. The Message Driven Bean is coded in such
-a way that upon the first arrival of a message, it throws a
-RuntimeException, simulating a runtime processing failure. <br>
-<br>
-The expected behavior of the MDB Container is to try to redeliver the
-message, which is what it hopefully does. Since the example framework
-took the precaution to insure that there is only one single type of MDB
-container listening on the example queue, the messages will be
-redelivered to an MDB of the same type. Upon the second arrival, the
-MDB
-instance will "let the message pass", will correctly "process" it and
-forward the result to temporary queue created by the sender for exactly
-this purpose. The
-example is considered successful if the sender receives the
-acknowledgment message. The successful example proves that message
-redelivery on failure works.<br>
-<br>
-This example relies on having access to a running JBoss Messaging
-instance.
-The JBoss Messaging instance must be installed and started according to
-the
-"Installation" paragraph from the release documentation. However,
-the example will automatically deploy its own queue, unless a queue
-with the same name is already deployed.<br>
-<br>
-This example also relies on having access to <span
- style="font-family: monospace;">jboss-messaging-client.jar</span>
-archive that comes with the release bundle. If you run this example
-from
-an unzipped installation bundle, the example run script is correctly
-configured to find the client jar. Otherwise, you must modify example's
-<span style="font-family: monospace;">build.xml</span>
-accordingly. <br>
-<br>
-<span style="font-style: italic;">The example was designed to deploy
-its server-side artifacts </span><span
- style="font-family: monospace; font-style: italic;"></span><span
- style="font-style: italic;">under a JBoss' </span><span
- style="font-family: monospace; font-style: italic;">messaging</span><span
- style="font-style: italic;">
-configuration. If you intend to use the script with a JBoss
-configuration that is named differently, please modify the
-example's</span><span
- style="font-family: monospace; font-style: italic;"> build.xml</span><span
- style="font-style: italic;">
-accordingly.</span><span style="font-style: italic;"></span><br>
-<br>
-<h2>Running the example</h2>
-1. Set up the JBOSS_HOME environment variable to point to the JBoss
-instance you deployed JBoss Messaging into. For example, if you
-deployed JBoss Messaging in <span style="font-family: monospace;">C:\jboss-4.0.3SP1\server\default\deploy,</span>
-then your JBOSS_HOME value should be <span
- style="font-family: monospace;">C:\</span><span
- style="font-family: monospace;">jboss-4.0.3SP1.</span><br>
-<span style="font-family: monospace;"></span><br>
-2. Go to the example's home directory<br>
-<br>
-<div style="margin-left: 40px;"><span style="font-family: monospace;">cd
-...\examples\mdb-failure</span><br>
-</div>
-<br>
-3. Run the example:<br>
-<br>
-<div style="margin-left: 40px;"><span style="font-family: monospace;">ant</span>
-<br>
-<br>
-<br>
-</div>
-The output of a successful run should be similar to:<br>
-<div style="margin-left: 40px;"><br>
-</div>
-<table
- style="width: 90%; text-align: left; font-family: monospace; background-color: rgb(204, 204, 204); margin-left: 40px;"
- border="1" cellpadding="2" cellspacing="2">
- <tbody>
- <tr>
- <td style="vertical-align: top;">
- <div style="margin-left: 40px;"><br>
- </div>
-$ ant<br>
-Buildfile: build.xml<br>
- <br>
-identify:<br>
- [echo]
-###########################################################################<br>
- [echo]
-#
-Running the MDB Failure
-example
-#<br>
- [echo]
-###########################################################################<br>
- [echo] The
-queue: testQueue<br>
- [echo] The client jar:
-../../../output/lib/jboss-messaging-client.jar<br>
- <br>
-sanity-check:<br>
- <br>
-init:<br>
- [mkdir] Created dir:
-C:\work\src\svn\messaging-Branch_1_0_1_SP\docs\examples\mdb-failure\output\classes\META-INF<br>
- [mkdir] Created dir:
-C:\work\src\svn\messaging-Branch_1_0_1_SP\docs\examples\mdb-failure\output\lib\META-INF<br>
- [mkdir] Created dir:
-C:\work\src\svn\messaging-Branch_1_0_1_SP\docs\examples\common\output<br>
- <br>
-compile:<br>
- [javac] Compiling 2 source files to
-C:\work\src\svn\messaging-Branch_1_0_1_SP\docs\examples\common\output<br>
- [javac] Compiling 2 source files to
-C:\work\src\svn\messaging-Branch_1_0_1_SP\docs\examples\mdb-failure\output\classes<br>
- <br>
-jar:<br>
- [copy] Copying 2 files to
-C:\work\src\svn\messaging-Branch_1_0_1_SP\docs\examples\mdb-failure\output\classes\META-INF<br>
- [jar] Building jar:
-C:\work\src\svn\messaging-Branch_1_0_1_SP\docs\examples\mdb-failure\output\lib\mdb-failure-example.jar<br>
- <br>
-deploy:<br>
- [copy] Copying 1 file to
-C:\work\src\jboss-4.0.5.GA-src\build\output\jboss-4.0.5.GA\server\messaging\deploy<br>
- <br>
-sleep:<br>
- [echo] Sleeping for 5 seconds ...<br>
- <br>
-run:<br>
- <br>
-send:<br>
- [java] Queue /queue/testQueue exists<br>
- [java] The "Hello!" message was successfully
-sent to the testQueue queue<br>
- [java] Received message: !olleH<br>
- [java] The example connected to JBoss
-Messaging version 1.0.1.SP4 (1.0)<br>
- <br>
- [java] #####################<br>
- [java] ###
-SUCCESS! ###<br>
- [java] #####################<br>
- <br>
-undeploy:<br>
- [delete] Deleting:
-C:\work\src\jboss-4.0.5.GA-src\build\output\jboss-4.0.5.GA\server\messaging\deploy\mdb-failure-example.jar<br>
- <br>
-BUILD SUCCESSFUL<br>
-Total time: 9 seconds<br>
- <br>
- <br>
- <br>
- </td>
- </tr>
- </tbody>
-</table>
-<br>
-<br style="font-family: courier new,courier,monospace;">
-<hr
- style="width: 100%; height: 2px; font-family: courier new,courier,monospace;"><br>
-<br>
-<br>
-<br>
-<br>
-<br>
-<br>
-</body>
-</html>
Copied: branches/Branch_1_0/docs/examples/mdb-failure/README.html (from rev 2261, branches/Branch_1_0_1_SP/docs/examples/mdb-failure/README.html)
===================================================================
--- branches/Branch_1_0/docs/examples/mdb-failure/README.html (rev 0)
+++ branches/Branch_1_0/docs/examples/mdb-failure/README.html 2007-02-11 13:16:25 UTC (rev 2264)
@@ -0,0 +1,180 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <meta content="text/html; charset=ISO-8859-1"
+ http-equiv="content-type">
+ <title>JBoss Messaging Example - Message Driven Bean Failure</title>
+</head>
+<body>
+<br>
+<h1>Message Driven Bean Behavior on Failure Example</h1>
+$Revision: 1459 $
+<h2>Overview</h2>
+<br>
+This example deploys a simple Message Driven Bean that processes
+messages sent to a test queue. The Message Driven Bean is coded in such
+a way that upon the first arrival of a message, it throws a
+RuntimeException, simulating a runtime processing failure. <br>
+<br>
+The expected behavior of the MDB Container is to try to redeliver the
+message, which is what it hopefully does. Since the example framework
+took the precaution to insure that there is only one single type of MDB
+container listening on the example queue, the messages will be
+redelivered to an MDB of the same type. Upon the second arrival, the
+MDB
+instance will "let the message pass", will correctly "process" it and
+forward the result to temporary queue created by the sender for exactly
+this purpose. The
+example is considered successful if the sender receives the
+acknowledgment message. The successful example proves that message
+redelivery on failure works.<br>
+<br>
+This example relies on having access to a running JBoss Messaging
+instance.
+The JBoss Messaging instance must be installed and started according to
+the
+"Installation" paragraph from the release documentation. However,
+the example will automatically deploy its own queue, unless a queue
+with the same name is already deployed.<br>
+<br>
+This example also relies on having access to <span
+ style="font-family: monospace;">jboss-messaging-client.jar</span>
+archive that comes with the release bundle. If you run this example
+from
+an unzipped installation bundle, the example run script is correctly
+configured to find the client jar. Otherwise, you must modify example's
+<span style="font-family: monospace;">build.xml</span>
+accordingly. <br>
+<br>
+<span style="font-style: italic;">The example was designed to deploy
+its server-side artifacts </span><span
+ style="font-family: monospace; font-style: italic;"></span><span
+ style="font-style: italic;">under a JBoss' </span><span
+ style="font-family: monospace; font-style: italic;">messaging</span><span
+ style="font-style: italic;">
+configuration. If you intend to use the script with a JBoss
+configuration that is named differently, please modify the
+example's</span><span
+ style="font-family: monospace; font-style: italic;"> build.xml</span><span
+ style="font-style: italic;">
+accordingly.</span><span style="font-style: italic;"></span><br>
+<br>
+<h2>Running the example</h2>
+1. Set up the JBOSS_HOME environment variable to point to the JBoss
+instance you deployed JBoss Messaging into. For example, if you
+deployed JBoss Messaging in <span style="font-family: monospace;">C:\jboss-4.0.3SP1\server\default\deploy,</span>
+then your JBOSS_HOME value should be <span
+ style="font-family: monospace;">C:\</span><span
+ style="font-family: monospace;">jboss-4.0.3SP1.</span><br>
+<span style="font-family: monospace;"></span><br>
+2. Go to the example's home directory<br>
+<br>
+<div style="margin-left: 40px;"><span style="font-family: monospace;">cd
+...\examples\mdb-failure</span><br>
+</div>
+<br>
+3. Run the example:<br>
+<br>
+<div style="margin-left: 40px;"><span style="font-family: monospace;">ant</span>
+<br>
+<br>
+<br>
+</div>
+The output of a successful run should be similar to:<br>
+<div style="margin-left: 40px;"><br>
+</div>
+<table
+ style="width: 90%; text-align: left; font-family: monospace; background-color: rgb(204, 204, 204); margin-left: 40px;"
+ border="1" cellpadding="2" cellspacing="2">
+ <tbody>
+ <tr>
+ <td style="vertical-align: top;">
+ <div style="margin-left: 40px;"><br>
+ </div>
+$ ant<br>
+Buildfile: build.xml<br>
+ <br>
+identify:<br>
+ [echo]
+###########################################################################<br>
+ [echo]
+#
+Running the MDB Failure
+example
+#<br>
+ [echo]
+###########################################################################<br>
+ [echo] The
+queue: testQueue<br>
+ [echo] The client jar:
+../../../output/lib/jboss-messaging-client.jar<br>
+ <br>
+sanity-check:<br>
+ <br>
+init:<br>
+ [mkdir] Created dir:
+C:\work\src\svn\messaging-Branch_1_0_1_SP\docs\examples\mdb-failure\output\classes\META-INF<br>
+ [mkdir] Created dir:
+C:\work\src\svn\messaging-Branch_1_0_1_SP\docs\examples\mdb-failure\output\lib\META-INF<br>
+ [mkdir] Created dir:
+C:\work\src\svn\messaging-Branch_1_0_1_SP\docs\examples\common\output<br>
+ <br>
+compile:<br>
+ [javac] Compiling 2 source files to
+C:\work\src\svn\messaging-Branch_1_0_1_SP\docs\examples\common\output<br>
+ [javac] Compiling 2 source files to
+C:\work\src\svn\messaging-Branch_1_0_1_SP\docs\examples\mdb-failure\output\classes<br>
+ <br>
+jar:<br>
+ [copy] Copying 2 files to
+C:\work\src\svn\messaging-Branch_1_0_1_SP\docs\examples\mdb-failure\output\classes\META-INF<br>
+ [jar] Building jar:
+C:\work\src\svn\messaging-Branch_1_0_1_SP\docs\examples\mdb-failure\output\lib\mdb-failure-example.jar<br>
+ <br>
+deploy:<br>
+ [copy] Copying 1 file to
+C:\work\src\jboss-4.0.5.GA-src\build\output\jboss-4.0.5.GA\server\messaging\deploy<br>
+ <br>
+sleep:<br>
+ [echo] Sleeping for 5 seconds ...<br>
+ <br>
+run:<br>
+ <br>
+send:<br>
+ [java] Queue /queue/testQueue exists<br>
+ [java] The "Hello!" message was successfully
+sent to the testQueue queue<br>
+ [java] Received message: !olleH<br>
+ [java] The example connected to JBoss
+Messaging version 1.0.1.SP4 (1.0)<br>
+ <br>
+ [java] #####################<br>
+ [java] ###
+SUCCESS! ###<br>
+ [java] #####################<br>
+ <br>
+undeploy:<br>
+ [delete] Deleting:
+C:\work\src\jboss-4.0.5.GA-src\build\output\jboss-4.0.5.GA\server\messaging\deploy\mdb-failure-example.jar<br>
+ <br>
+BUILD SUCCESSFUL<br>
+Total time: 9 seconds<br>
+ <br>
+ <br>
+ <br>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<br>
+<br style="font-family: courier new,courier,monospace;">
+<hr
+ style="width: 100%; height: 2px; font-family: courier new,courier,monospace;"><br>
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+</body>
+</html>
Deleted: branches/Branch_1_0/docs/examples/mdb-failure/build.xml
===================================================================
--- branches/Branch_1_0_1_SP/docs/examples/mdb-failure/build.xml 2007-02-11 09:04:09 UTC (rev 2261)
+++ branches/Branch_1_0/docs/examples/mdb-failure/build.xml 2007-02-11 13:16:25 UTC (rev 2264)
@@ -1,143 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-
- To run the example, set JBOSS_HOME and run ant (with no parameters)
-
- $Id: build.xml 974 2006-05-23 03:35:38Z ovidiu $
-
- -->
-
-<project name="MDBFailureExample" default="run">
-
- <property environment="ENV"/>
-
- <!--
- If you don't find this file in the current directory, it's ok, it's intended to provide
- defaults for in-workarea testing and it's not meant for distribution with the example bundle.
- -->
- <property file="do-not-distribute.properties"/>
- <property name="undeploy.quiet" value="false"/>
- <property name="undeploy.failonerror" value="true"/>
-
- <!-- These properties may be overriden by calling ants when this example is used in a smoke test -->
- <property name="messaging.client.jar.path" value="../.."/>
- <property name="messaging.client.jar.name" value="jboss-messaging-client.jar"/>
- <property name="jboss.home" value="${ENV.JBOSS_HOME}"/>
- <property name="jboss.configuration" value="messaging"/>
- <property name="example.queue.name" value="testQueue"/>
-
- <path id="common.compilation.classpath">
- <fileset file="${jboss.home}/client/jboss-j2ee.jar"/>
- <fileset file="${jboss.home}/client/jboss-j2se.jar"/>
- </path>
-
- <path id="example.compilation.classpath">
- <path refid="common.compilation.classpath"/>
- <pathelement path="../common/output"/>
- </path>
-
- <path id="execution.classpath">
- <pathelement path="./etc"/>
- <pathelement path="../common/output"/>
- <pathelement path="./output"/>
- <pathelement path="./output/classes"/>
- <fileset file="${messaging.client.jar.path}/${messaging.client.jar.name}"/>
-
- <!--
- If you want to run the example with JBossMQ, comment the line above, uncomment the line
- below, and use a "default" configuration.
- -->
- <!--
- <fileset file="${jboss.home}/client/jbossall-client.jar"/>
- -->
- </path>
-
- <target name="identify">
- <echo message="###########################################################################"/>
- <echo message="# Running the MDB Failure example #"/>
- <echo message="###########################################################################"/>
- <echo message="The queue: ${example.queue.name}"/>
- <echo message="The client jar: ${messaging.client.jar.path}/${messaging.client.jar.name}"/>
- </target>
-
- <target name="sanity-check" depends="identify">
- <available property="client.jar.present" file="${messaging.client.jar.path}/${messaging.client.jar.name}"/>
- <fail message="Could not find client jar ${messaging.client.jar.path}/${messaging.client.jar.name}"
- unless="client.jar.present"/>
- </target>
-
- <target name="init" depends="sanity-check">
- <mkdir dir="./output/classes/META-INF"/>
- <mkdir dir="./output/lib/META-INF"/>
- <mkdir dir="../common/output"/>
- </target>
-
- <target name="compile" depends="init">
- <javac destdir="../common/output" debug="on" debuglevel="lines,vars,source">
- <src path="../common/src"/>
- <classpath refid="common.compilation.classpath"/>
- </javac>
- <javac destdir="./output/classes" debug="on" debuglevel="lines,vars,source">
- <src path="./src"/>
- <classpath refid="example.compilation.classpath"/>
- </javac>
- </target>
-
- <target name="jar" depends="compile">
- <copy todir="./output/classes/META-INF" filtering="true">
- <fileset dir="./etc/META-INF" includes="*"/>
- <filterset>
- <filter token="QUEUE_NAME" value="${example.queue.name}"/>
- </filterset>
- </copy>
- <jar destfile="./output/lib/mdb-failure-example.jar"
- basedir="./output/classes"
- includes="META-INF/**,org/jboss/example/**/MDBFailureExample.class"/>
- </target>
-
- <target name="deploy" depends="jar">
- <copy file="./output/lib/mdb-failure-example.jar"
- todir="${jboss.home}/server/${jboss.configuration}/deploy"/>
- <antcall target="sleep"><param name="sleep.interval" value="5"/></antcall>
- </target>
-
- <target name="run" depends="deploy">
- <antcall target="send"/>
- <antcall target="sleep"><param name="sleep.interval" value="15"/></antcall>
- <antcall target="undeploy">
- <param name="undeploy.quiet" value="false"/>
- <param name="undeploy.failonerror" value="true"/>
- </antcall>
- </target>
-
- <target name="send">
- <!-- MDBFailureExample expects to find the name of the queue to connect to as value of the
- 'example.queue.name' property, which *may* be defined by calling ants when this example
- is used in a smoke test -->
- <java classname="org.jboss.example.jms.mdbfailure.Sender"
- classpathref="execution.classpath" fork="yes" failonerror="true">
- <sysproperty key="example.queue.name" value="${example.queue.name}"/>
- <!--
- <jvmarg line="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_shmem,server=y,suspend=y,address=example"/>
- -->
- </java>
- </target>
-
- <target name="undeploy">
- <delete file="${jboss.home}/server/${jboss.configuration}/deploy/mdb-failure-example.jar"
- quiet="${undeploy.quiet}" failonerror="${undeploy.failonerror}"/>
- </target>
-
- <target name="clean" depends="undeploy">
- <delete dir="./output" quiet="true"/>
- <delete dir="../common/output" quiet="true"/>
- </target>
-
- <target name="sleep">
- <echo message="Sleeping for ${sleep.interval} seconds ..."/>
- <sleep seconds="${sleep.interval}"/>
- </target>
-
-</project>
-
Copied: branches/Branch_1_0/docs/examples/mdb-failure/build.xml (from rev 2261, branches/Branch_1_0_1_SP/docs/examples/mdb-failure/build.xml)
===================================================================
--- branches/Branch_1_0/docs/examples/mdb-failure/build.xml (rev 0)
+++ branches/Branch_1_0/docs/examples/mdb-failure/build.xml 2007-02-11 13:16:25 UTC (rev 2264)
@@ -0,0 +1,143 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+
+ To run the example, set JBOSS_HOME and run ant (with no parameters)
+
+ $Id: build.xml 974 2006-05-23 03:35:38Z ovidiu $
+
+ -->
+
+<project name="MDBFailureExample" default="run">
+
+ <property environment="ENV"/>
+
+ <!--
+ If you don't find this file in the current directory, it's ok, it's intended to provide
+ defaults for in-workarea testing and it's not meant for distribution with the example bundle.
+ -->
+ <property file="do-not-distribute.properties"/>
+ <property name="undeploy.quiet" value="false"/>
+ <property name="undeploy.failonerror" value="true"/>
+
+ <!-- These properties may be overriden by calling ants when this example is used in a smoke test -->
+ <property name="messaging.client.jar.path" value="../.."/>
+ <property name="messaging.client.jar.name" value="jboss-messaging-client.jar"/>
+ <property name="jboss.home" value="${ENV.JBOSS_HOME}"/>
+ <property name="jboss.configuration" value="messaging"/>
+ <property name="example.queue.name" value="testQueue"/>
+
+ <path id="common.compilation.classpath">
+ <fileset file="${jboss.home}/client/jboss-j2ee.jar"/>
+ <fileset file="${jboss.home}/client/jboss-j2se.jar"/>
+ </path>
+
+ <path id="example.compilation.classpath">
+ <path refid="common.compilation.classpath"/>
+ <pathelement path="../common/output"/>
+ </path>
+
+ <path id="execution.classpath">
+ <pathelement path="./etc"/>
+ <pathelement path="../common/output"/>
+ <pathelement path="./output"/>
+ <pathelement path="./output/classes"/>
+ <fileset file="${messaging.client.jar.path}/${messaging.client.jar.name}"/>
+
+ <!--
+ If you want to run the example with JBossMQ, comment the line above, uncomment the line
+ below, and use a "default" configuration.
+ -->
+ <!--
+ <fileset file="${jboss.home}/client/jbossall-client.jar"/>
+ -->
+ </path>
+
+ <target name="identify">
+ <echo message="###########################################################################"/>
+ <echo message="# Running the MDB Failure example #"/>
+ <echo message="###########################################################################"/>
+ <echo message="The queue: ${example.queue.name}"/>
+ <echo message="The client jar: ${messaging.client.jar.path}/${messaging.client.jar.name}"/>
+ </target>
+
+ <target name="sanity-check" depends="identify">
+ <available property="client.jar.present" file="${messaging.client.jar.path}/${messaging.client.jar.name}"/>
+ <fail message="Could not find client jar ${messaging.client.jar.path}/${messaging.client.jar.name}"
+ unless="client.jar.present"/>
+ </target>
+
+ <target name="init" depends="sanity-check">
+ <mkdir dir="./output/classes/META-INF"/>
+ <mkdir dir="./output/lib/META-INF"/>
+ <mkdir dir="../common/output"/>
+ </target>
+
+ <target name="compile" depends="init">
+ <javac destdir="../common/output" debug="on" debuglevel="lines,vars,source">
+ <src path="../common/src"/>
+ <classpath refid="common.compilation.classpath"/>
+ </javac>
+ <javac destdir="./output/classes" debug="on" debuglevel="lines,vars,source">
+ <src path="./src"/>
+ <classpath refid="example.compilation.classpath"/>
+ </javac>
+ </target>
+
+ <target name="jar" depends="compile">
+ <copy todir="./output/classes/META-INF" filtering="true">
+ <fileset dir="./etc/META-INF" includes="*"/>
+ <filterset>
+ <filter token="QUEUE_NAME" value="${example.queue.name}"/>
+ </filterset>
+ </copy>
+ <jar destfile="./output/lib/mdb-failure-example.jar"
+ basedir="./output/classes"
+ includes="META-INF/**,org/jboss/example/**/MDBFailureExample.class"/>
+ </target>
+
+ <target name="deploy" depends="jar">
+ <copy file="./output/lib/mdb-failure-example.jar"
+ todir="${jboss.home}/server/${jboss.configuration}/deploy"/>
+ <antcall target="sleep"><param name="sleep.interval" value="5"/></antcall>
+ </target>
+
+ <target name="run" depends="deploy">
+ <antcall target="send"/>
+ <antcall target="sleep"><param name="sleep.interval" value="15"/></antcall>
+ <antcall target="undeploy">
+ <param name="undeploy.quiet" value="false"/>
+ <param name="undeploy.failonerror" value="true"/>
+ </antcall>
+ </target>
+
+ <target name="send">
+ <!-- MDBFailureExample expects to find the name of the queue to connect to as value of the
+ 'example.queue.name' property, which *may* be defined by calling ants when this example
+ is used in a smoke test -->
+ <java classname="org.jboss.example.jms.mdbfailure.Sender"
+ classpathref="execution.classpath" fork="yes" failonerror="true">
+ <sysproperty key="example.queue.name" value="${example.queue.name}"/>
+ <!--
+ <jvmarg line="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_shmem,server=y,suspend=y,address=example"/>
+ -->
+ </java>
+ </target>
+
+ <target name="undeploy">
+ <delete file="${jboss.home}/server/${jboss.configuration}/deploy/mdb-failure-example.jar"
+ quiet="${undeploy.quiet}" failonerror="${undeploy.failonerror}"/>
+ </target>
+
+ <target name="clean" depends="undeploy">
+ <delete dir="./output" quiet="true"/>
+ <delete dir="../common/output" quiet="true"/>
+ </target>
+
+ <target name="sleep">
+ <echo message="Sleeping for ${sleep.interval} seconds ..."/>
+ <sleep seconds="${sleep.interval}"/>
+ </target>
+
+</project>
+
Deleted: branches/Branch_1_0/docs/examples/mdb-failure/do-not-distribute.properties
===================================================================
--- branches/Branch_1_0_1_SP/docs/examples/mdb-failure/do-not-distribute.properties 2007-02-11 09:04:09 UTC (rev 2261)
+++ branches/Branch_1_0/docs/examples/mdb-failure/do-not-distribute.properties 2007-02-11 13:16:25 UTC (rev 2264)
@@ -1,9 +0,0 @@
-#
-# This file provides values for in-workarea example testing.
-# DO NOT DISTRIBUTE!
-#
-messaging.client.jar.path=../../../output/lib
-messaging.client.jar.name=jboss-messaging-client.jar
-#jboss.configuration=default
-jboss.configuration=messaging
-
Copied: branches/Branch_1_0/docs/examples/mdb-failure/do-not-distribute.properties (from rev 2261, branches/Branch_1_0_1_SP/docs/examples/mdb-failure/do-not-distribute.properties)
===================================================================
--- branches/Branch_1_0/docs/examples/mdb-failure/do-not-distribute.properties (rev 0)
+++ branches/Branch_1_0/docs/examples/mdb-failure/do-not-distribute.properties 2007-02-11 13:16:25 UTC (rev 2264)
@@ -0,0 +1,9 @@
+#
+# This file provides values for in-workarea example testing.
+# DO NOT DISTRIBUTE!
+#
+messaging.client.jar.path=../../../output/lib
+messaging.client.jar.name=jboss-messaging-client.jar
+#jboss.configuration=default
+jboss.configuration=messaging
+
Copied: branches/Branch_1_0/docs/examples/mdb-failure/etc (from rev 2261, branches/Branch_1_0_1_SP/docs/examples/mdb-failure/etc)
Copied: branches/Branch_1_0/docs/examples/mdb-failure/etc/META-INF (from rev 2261, branches/Branch_1_0_1_SP/docs/examples/mdb-failure/etc/META-INF)
Deleted: branches/Branch_1_0/docs/examples/mdb-failure/etc/META-INF/ejb-jar.xml
===================================================================
--- branches/Branch_1_0_1_SP/docs/examples/mdb-failure/etc/META-INF/ejb-jar.xml 2007-02-11 09:04:09 UTC (rev 2261)
+++ branches/Branch_1_0/docs/examples/mdb-failure/etc/META-INF/ejb-jar.xml 2007-02-11 13:16:25 UTC (rev 2264)
@@ -1,26 +0,0 @@
-<?xml version='1.0' encoding='UTF-8' ?>
-<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
- "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
-
-<ejb-jar>
- <enterprise-beans>
- <message-driven>
- <ejb-name>MDBFailureExample</ejb-name>
- <ejb-class>org.jboss.example.jms.mdbfailure.MDBFailureExample</ejb-class>
- <transaction-type>Container</transaction-type>
- <message-driven-destination>
- <destination-type>javax.jms.Queue</destination-type>
- </message-driven-destination>
- </message-driven>
- </enterprise-beans>
-
- <assembly-descriptor>
- <container-transaction>
- <method>
- <ejb-name>MDBFailureExample</ejb-name>
- <method-name>*</method-name>
- </method>
- <trans-attribute>Required</trans-attribute>
- </container-transaction>
- </assembly-descriptor>
-</ejb-jar>
\ No newline at end of file
Copied: branches/Branch_1_0/docs/examples/mdb-failure/etc/META-INF/ejb-jar.xml (from rev 2261, branches/Branch_1_0_1_SP/docs/examples/mdb-failure/etc/META-INF/ejb-jar.xml)
===================================================================
--- branches/Branch_1_0/docs/examples/mdb-failure/etc/META-INF/ejb-jar.xml (rev 0)
+++ branches/Branch_1_0/docs/examples/mdb-failure/etc/META-INF/ejb-jar.xml 2007-02-11 13:16:25 UTC (rev 2264)
@@ -0,0 +1,26 @@
+<?xml version='1.0' encoding='UTF-8' ?>
+<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
+ "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
+
+<ejb-jar>
+ <enterprise-beans>
+ <message-driven>
+ <ejb-name>MDBFailureExample</ejb-name>
+ <ejb-class>org.jboss.example.jms.mdbfailure.MDBFailureExample</ejb-class>
+ <transaction-type>Container</transaction-type>
+ <message-driven-destination>
+ <destination-type>javax.jms.Queue</destination-type>
+ </message-driven-destination>
+ </message-driven>
+ </enterprise-beans>
+
+ <assembly-descriptor>
+ <container-transaction>
+ <method>
+ <ejb-name>MDBFailureExample</ejb-name>
+ <method-name>*</method-name>
+ </method>
+ <trans-attribute>Required</trans-attribute>
+ </container-transaction>
+ </assembly-descriptor>
+</ejb-jar>
\ No newline at end of file
Deleted: branches/Branch_1_0/docs/examples/mdb-failure/etc/META-INF/jboss.xml
===================================================================
--- branches/Branch_1_0_1_SP/docs/examples/mdb-failure/etc/META-INF/jboss.xml 2007-02-11 09:04:09 UTC (rev 2261)
+++ branches/Branch_1_0/docs/examples/mdb-failure/etc/META-INF/jboss.xml 2007-02-11 13:16:25 UTC (rev 2264)
@@ -1,14 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE jboss PUBLIC
- "-//JBoss//DTD JBOSS 3.0//EN"
- "http://www.jboss.org/j2ee/dtd/jboss_3_0.dtd">
-<jboss>
-
- <enterprise-beans>
- <message-driven>
- <ejb-name>MDBFailureExample</ejb-name>
- <destination-jndi-name>queue/@QUEUE_NAME@</destination-jndi-name>
- </message-driven>
- </enterprise-beans>
-
-</jboss>
Copied: branches/Branch_1_0/docs/examples/mdb-failure/etc/META-INF/jboss.xml (from rev 2261, branches/Branch_1_0_1_SP/docs/examples/mdb-failure/etc/META-INF/jboss.xml)
===================================================================
--- branches/Branch_1_0/docs/examples/mdb-failure/etc/META-INF/jboss.xml (rev 0)
+++ branches/Branch_1_0/docs/examples/mdb-failure/etc/META-INF/jboss.xml 2007-02-11 13:16:25 UTC (rev 2264)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE jboss PUBLIC
+ "-//JBoss//DTD JBOSS 3.0//EN"
+ "http://www.jboss.org/j2ee/dtd/jboss_3_0.dtd">
+<jboss>
+
+ <enterprise-beans>
+ <message-driven>
+ <ejb-name>MDBFailureExample</ejb-name>
+ <destination-jndi-name>queue/@QUEUE_NAME@</destination-jndi-name>
+ </message-driven>
+ </enterprise-beans>
+
+</jboss>
Deleted: branches/Branch_1_0/docs/examples/mdb-failure/etc/jndi.properties
===================================================================
--- branches/Branch_1_0_1_SP/docs/examples/mdb-failure/etc/jndi.properties 2007-02-11 09:04:09 UTC (rev 2261)
+++ branches/Branch_1_0/docs/examples/mdb-failure/etc/jndi.properties 2007-02-11 13:16:25 UTC (rev 2264)
@@ -1,4 +0,0 @@
-### JBossNS properties
-java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
-java.naming.provider.url=jnp://localhost:1099
-java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
Copied: branches/Branch_1_0/docs/examples/mdb-failure/etc/jndi.properties (from rev 2261, branches/Branch_1_0_1_SP/docs/examples/mdb-failure/etc/jndi.properties)
===================================================================
--- branches/Branch_1_0/docs/examples/mdb-failure/etc/jndi.properties (rev 0)
+++ branches/Branch_1_0/docs/examples/mdb-failure/etc/jndi.properties 2007-02-11 13:16:25 UTC (rev 2264)
@@ -0,0 +1,4 @@
+### JBossNS properties
+java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+java.naming.provider.url=jnp://localhost:1099
+java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
Deleted: branches/Branch_1_0/docs/examples/mdb-failure/etc/log4j.xml
===================================================================
--- branches/Branch_1_0_1_SP/docs/examples/mdb-failure/etc/log4j.xml 2007-02-11 09:04:09 UTC (rev 2261)
+++ branches/Branch_1_0/docs/examples/mdb-failure/etc/log4j.xml 2007-02-11 13:16:25 UTC (rev 2264)
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
-
-<!-- $Id: log4j.xml 536 2005-12-22 06:28:39Z ovidiu $ -->
-
-<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
-
- <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
- <param name="Target" value="System.out"/>
- <param name="Threshold" value="INFO"/>
- <layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p @%t [%c{1}] %m%n"/>
- </layout>
- </appender>
-
- <root>
- <appender-ref ref="CONSOLE"/>
- </root>
-
-</log4j:configuration>
Copied: branches/Branch_1_0/docs/examples/mdb-failure/etc/log4j.xml (from rev 2261, branches/Branch_1_0_1_SP/docs/examples/mdb-failure/etc/log4j.xml)
===================================================================
--- branches/Branch_1_0/docs/examples/mdb-failure/etc/log4j.xml (rev 0)
+++ branches/Branch_1_0/docs/examples/mdb-failure/etc/log4j.xml 2007-02-11 13:16:25 UTC (rev 2264)
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<!-- $Id: log4j.xml 536 2005-12-22 06:28:39Z ovidiu $ -->
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+ <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out"/>
+ <param name="Threshold" value="INFO"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p @%t [%c{1}] %m%n"/>
+ </layout>
+ </appender>
+
+ <root>
+ <appender-ref ref="CONSOLE"/>
+ </root>
+
+</log4j:configuration>
Copied: branches/Branch_1_0/docs/examples/mdb-failure/src (from rev 2261, branches/Branch_1_0_1_SP/docs/examples/mdb-failure/src)
Copied: branches/Branch_1_0/docs/examples/mdb-failure/src/org (from rev 2261, branches/Branch_1_0_1_SP/docs/examples/mdb-failure/src/org)
Copied: branches/Branch_1_0/docs/examples/mdb-failure/src/org/jboss (from rev 2261, branches/Branch_1_0_1_SP/docs/examples/mdb-failure/src/org/jboss)
Copied: branches/Branch_1_0/docs/examples/mdb-failure/src/org/jboss/example (from rev 2261, branches/Branch_1_0_1_SP/docs/examples/mdb-failure/src/org/jboss/example)
Copied: branches/Branch_1_0/docs/examples/mdb-failure/src/org/jboss/example/jms (from rev 2261, branches/Branch_1_0_1_SP/docs/examples/mdb-failure/src/org/jboss/example/jms)
Copied: branches/Branch_1_0/docs/examples/mdb-failure/src/org/jboss/example/jms/mdbfailure (from rev 2261, branches/Branch_1_0_1_SP/docs/examples/mdb-failure/src/org/jboss/example/jms/mdbfailure)
Deleted: branches/Branch_1_0/docs/examples/mdb-failure/src/org/jboss/example/jms/mdbfailure/MDBFailureExample.java
===================================================================
--- branches/Branch_1_0_1_SP/docs/examples/mdb-failure/src/org/jboss/example/jms/mdbfailure/MDBFailureExample.java 2007-02-11 09:04:09 UTC (rev 2261)
+++ branches/Branch_1_0/docs/examples/mdb-failure/src/org/jboss/example/jms/mdbfailure/MDBFailureExample.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -1,198 +0,0 @@
-/**
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.example.jms.mdbfailure;
-
-import javax.jms.*;
-import javax.ejb.MessageDrivenBean;
-import javax.ejb.MessageDrivenContext;
-import javax.ejb.EJBException;
-import javax.naming.InitialContext;
-import java.util.Set;
-import java.util.HashSet;
-
-/**
- * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
- * @version <tt>$Revision: 849 $</tt>
-
- * $Id: MDBFailureExample.java 849 2006-03-31 17:17:09Z ltexier $
- */
-public class MDBFailureExample implements MessageDrivenBean, MessageListener
-{
-
- private MessageDrivenContext ctx;
-
- private ConnectionFactory cf = null;
-
- private static Set messageIDs = new HashSet();
-
- public void onMessage(Message m)
- {
- Session session = null;
- Connection conn = null;
-
- try
- {
-
- TextMessage tm = (TextMessage)m;
-
- String text = tm.getText();
-
- System.out.println("message " + text + " received");
-
- System.out.println("message " + (tm.getJMSRedelivered() ? "" : "NOT ")+ "marked as \"redelivered\"");
-
-
- // if it is the first time any of the MDB instances from the pool sees the message, the
- // message will cause the MDB instance to "crash"
-
- synchronized(messageIDs)
- {
- if (!messageIDs.contains(tm.getJMSMessageID()))
- {
- messageIDs.add(m.getJMSMessageID());
-
- System.out.println("The message has \"broken\" our MDB ...");
-
- // "crashing" the MDB. The exception won't be caught by our catch clause and it will
- // bubble up
-
- throw new RuntimeException("Unfortunate events happen ...");
-
- }
- else
- {
- System.out.println("The message is already \"known\", so let it be processed");
- }
- }
-
- String result = process(text);
- System.out.println("message processed, result: " + result);
-
- conn = getConnection();
- session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- Destination replyTo = m.getJMSReplyTo();
- MessageProducer producer = session.createProducer(replyTo);
- TextMessage reply = session.createTextMessage(result);
-
- producer.send(reply);
- producer.close();
-
- }
- catch(JMSException e)
- {
- ctx.setRollbackOnly();
- e.printStackTrace();
- System.out.println("The Message Driven Bean failed!");
- }
- finally
- {
- if (conn != null)
- {
- try
- {
- closeConnection(conn);
- }
- catch(Exception e)
- {
- System.out.println("Could not close the connection!" +e);
- }
- }
- }
- }
-
- private String process(String text)
- {
- // flip the string
-
- String result = "";
-
- for(int i = 0; i < text.length(); i++)
- {
- result = text.charAt(i) + result;
- }
- return result;
- }
-
- public Connection getConnection() throws JMSException
- {
-
- Connection connection = null;
-
- try
- {
- connection = cf.createConnection();
- connection.start();
-
- }
- catch(JMSException e)
- {
- if(connection != null)
- {
- closeConnection(connection);
- }
- System.out.println("Failed to get connection... exception is " + e);
- throw e;
- }
-
- return connection;
- }
-
- public void closeConnection(Connection con) throws JMSException
- {
-
- try
- {
- con.close();
-
- }
- catch(JMSException jmse)
- {
- System.out.println("Could not close connection " + con +" exception was " +jmse);
- throw jmse;
- }
- }
-
- public void ejbCreate()
- {
- try
- {
- InitialContext ic = new InitialContext();
-
- cf = (ConnectionFactory)ic.lookup("java:/JmsXA");
-
- ic.close();
- }
- catch(Exception e)
- {
- e.printStackTrace();
- throw new EJBException("Failure to get connection factory: " + e.getMessage());
- }
- }
-
- public void ejbRemove() throws EJBException
- {
- try
- {
- if(cf != null)
- {
- cf = null;
- }
- }
- catch(Exception e)
- {
- throw new EJBException("ejbRemove", e);
- }
- }
-
- public void setMessageDrivenContext(MessageDrivenContext ctx)
- {
- this.ctx = ctx;
- }
-
-
-}
Copied: branches/Branch_1_0/docs/examples/mdb-failure/src/org/jboss/example/jms/mdbfailure/MDBFailureExample.java (from rev 2261, branches/Branch_1_0_1_SP/docs/examples/mdb-failure/src/org/jboss/example/jms/mdbfailure/MDBFailureExample.java)
===================================================================
--- branches/Branch_1_0/docs/examples/mdb-failure/src/org/jboss/example/jms/mdbfailure/MDBFailureExample.java (rev 0)
+++ branches/Branch_1_0/docs/examples/mdb-failure/src/org/jboss/example/jms/mdbfailure/MDBFailureExample.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -0,0 +1,198 @@
+/**
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.example.jms.mdbfailure;
+
+import javax.jms.*;
+import javax.ejb.MessageDrivenBean;
+import javax.ejb.MessageDrivenContext;
+import javax.ejb.EJBException;
+import javax.naming.InitialContext;
+import java.util.Set;
+import java.util.HashSet;
+
+/**
+ * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
+ * @version <tt>$Revision: 849 $</tt>
+
+ * $Id: MDBFailureExample.java 849 2006-03-31 17:17:09Z ltexier $
+ */
+public class MDBFailureExample implements MessageDrivenBean, MessageListener
+{
+
+ private MessageDrivenContext ctx;
+
+ private ConnectionFactory cf = null;
+
+ private static Set messageIDs = new HashSet();
+
+ public void onMessage(Message m)
+ {
+ Session session = null;
+ Connection conn = null;
+
+ try
+ {
+
+ TextMessage tm = (TextMessage)m;
+
+ String text = tm.getText();
+
+ System.out.println("message " + text + " received");
+
+ System.out.println("message " + (tm.getJMSRedelivered() ? "" : "NOT ")+ "marked as \"redelivered\"");
+
+
+ // if it is the first time any of the MDB instances from the pool sees the message, the
+ // message will cause the MDB instance to "crash"
+
+ synchronized(messageIDs)
+ {
+ if (!messageIDs.contains(tm.getJMSMessageID()))
+ {
+ messageIDs.add(m.getJMSMessageID());
+
+ System.out.println("The message has \"broken\" our MDB ...");
+
+ // "crashing" the MDB. The exception won't be caught by our catch clause and it will
+ // bubble up
+
+ throw new RuntimeException("Unfortunate events happen ...");
+
+ }
+ else
+ {
+ System.out.println("The message is already \"known\", so let it be processed");
+ }
+ }
+
+ String result = process(text);
+ System.out.println("message processed, result: " + result);
+
+ conn = getConnection();
+ session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ Destination replyTo = m.getJMSReplyTo();
+ MessageProducer producer = session.createProducer(replyTo);
+ TextMessage reply = session.createTextMessage(result);
+
+ producer.send(reply);
+ producer.close();
+
+ }
+ catch(JMSException e)
+ {
+ ctx.setRollbackOnly();
+ e.printStackTrace();
+ System.out.println("The Message Driven Bean failed!");
+ }
+ finally
+ {
+ if (conn != null)
+ {
+ try
+ {
+ closeConnection(conn);
+ }
+ catch(Exception e)
+ {
+ System.out.println("Could not close the connection!" +e);
+ }
+ }
+ }
+ }
+
+ private String process(String text)
+ {
+ // flip the string
+
+ String result = "";
+
+ for(int i = 0; i < text.length(); i++)
+ {
+ result = text.charAt(i) + result;
+ }
+ return result;
+ }
+
+ public Connection getConnection() throws JMSException
+ {
+
+ Connection connection = null;
+
+ try
+ {
+ connection = cf.createConnection();
+ connection.start();
+
+ }
+ catch(JMSException e)
+ {
+ if(connection != null)
+ {
+ closeConnection(connection);
+ }
+ System.out.println("Failed to get connection... exception is " + e);
+ throw e;
+ }
+
+ return connection;
+ }
+
+ public void closeConnection(Connection con) throws JMSException
+ {
+
+ try
+ {
+ con.close();
+
+ }
+ catch(JMSException jmse)
+ {
+ System.out.println("Could not close connection " + con +" exception was " +jmse);
+ throw jmse;
+ }
+ }
+
+ public void ejbCreate()
+ {
+ try
+ {
+ InitialContext ic = new InitialContext();
+
+ cf = (ConnectionFactory)ic.lookup("java:/JmsXA");
+
+ ic.close();
+ }
+ catch(Exception e)
+ {
+ e.printStackTrace();
+ throw new EJBException("Failure to get connection factory: " + e.getMessage());
+ }
+ }
+
+ public void ejbRemove() throws EJBException
+ {
+ try
+ {
+ if(cf != null)
+ {
+ cf = null;
+ }
+ }
+ catch(Exception e)
+ {
+ throw new EJBException("ejbRemove", e);
+ }
+ }
+
+ public void setMessageDrivenContext(MessageDrivenContext ctx)
+ {
+ this.ctx = ctx;
+ }
+
+
+}
Deleted: branches/Branch_1_0/docs/examples/mdb-failure/src/org/jboss/example/jms/mdbfailure/Sender.java
===================================================================
--- branches/Branch_1_0_1_SP/docs/examples/mdb-failure/src/org/jboss/example/jms/mdbfailure/Sender.java 2007-02-11 09:04:09 UTC (rev 2261)
+++ branches/Branch_1_0/docs/examples/mdb-failure/src/org/jboss/example/jms/mdbfailure/Sender.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -1,142 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.example.jms.mdbfailure;
-
-import org.jboss.example.jms.common.ExampleSupport;
-
-import javax.naming.InitialContext;
-import javax.jms.ConnectionFactory;
-import javax.jms.Connection;
-import javax.jms.Session;
-import javax.jms.MessageProducer;
-import javax.jms.TextMessage;
-import javax.jms.Queue;
-import javax.jms.MessageConsumer;
-
-/**
- * This example deploys a simple Message Driven Bean that processes messages sent to a test queue.
- * The MDB container is configured to use CMT.
- *
- * We send a special tagged message (we do this by adding a custom property to the message) to the
- * MDB. The MDB is programmed to "fail" when handling such a message, by throwing a
- * RuntimeException, but not before "clearing" the failure-inducing tag.
- *
- * The expected behavior for the JMS provider is to redeliver the message, this time without the
- * "failure tag". The MDB is supposed to process it and put it on response queue, from were it will
- * be read by the client.
- *
- * The example is considered successful if the client receives the "processed" message.
- *
- * Since this example is also used by the smoke test, it is essential that the VM exits with exit
- * code 0 in case of successful execution and a non-zero value on failure.
- *
- * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
- * @version <tt>$Revision: 884 $</tt>
- *
- * $Id: Sender.java 884 2006-04-12 01:04:10Z ovidiu $
- */
-public class Sender extends ExampleSupport
-{
- public void example() throws Exception
- {
-
- String destinationName = getDestinationJNDIName();
-
- InitialContext ic = new InitialContext();
-
- ConnectionFactory cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
- Queue queue = (Queue)ic.lookup(destinationName);
-
-
-
- log("Queue " + destinationName + " exists");
-
-
-
- Connection connection = cf.createConnection();
- Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageProducer sender = session.createProducer(queue);
-
-
-
- Queue temporaryQueue = session.createTemporaryQueue();
- MessageConsumer consumer = session.createConsumer(temporaryQueue);
-
-
-
- TextMessage message = session.createTextMessage("Hello!");
- message.setJMSReplyTo(temporaryQueue);
-
-
-
- sender.send(message);
-
-
-
- log("The \"" + message.getText() + "\" message was successfully sent to the " + queue.getQueueName() + " queue");
-
-
-
- connection.start();
-
-
-
- message = (TextMessage)consumer.receive(5000);
-
-
- if (message == null)
- {
- throw new Exception("Have not received any reply. The example failed!");
- }
-
-
- log("Received message: " + message.getText());
-
-
-
- assertEquals("!olleH", message.getText());
-
-
-
- displayProviderInfo(connection.getMetaData());
-
-
- connection.close();
- }
-
-
-
-
- protected boolean isQueueExample()
- {
- return true;
- }
-
-
-
-
- public static void main(String[] args)
- {
- new Sender().run();
- }
-
-}
Copied: branches/Branch_1_0/docs/examples/mdb-failure/src/org/jboss/example/jms/mdbfailure/Sender.java (from rev 2261, branches/Branch_1_0_1_SP/docs/examples/mdb-failure/src/org/jboss/example/jms/mdbfailure/Sender.java)
===================================================================
--- branches/Branch_1_0/docs/examples/mdb-failure/src/org/jboss/example/jms/mdbfailure/Sender.java (rev 0)
+++ branches/Branch_1_0/docs/examples/mdb-failure/src/org/jboss/example/jms/mdbfailure/Sender.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -0,0 +1,142 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.example.jms.mdbfailure;
+
+import org.jboss.example.jms.common.ExampleSupport;
+
+import javax.naming.InitialContext;
+import javax.jms.ConnectionFactory;
+import javax.jms.Connection;
+import javax.jms.Session;
+import javax.jms.MessageProducer;
+import javax.jms.TextMessage;
+import javax.jms.Queue;
+import javax.jms.MessageConsumer;
+
+/**
+ * This example deploys a simple Message Driven Bean that processes messages sent to a test queue.
+ * The MDB container is configured to use CMT.
+ *
+ * We send a special tagged message (we do this by adding a custom property to the message) to the
+ * MDB. The MDB is programmed to "fail" when handling such a message, by throwing a
+ * RuntimeException, but not before "clearing" the failure-inducing tag.
+ *
+ * The expected behavior for the JMS provider is to redeliver the message, this time without the
+ * "failure tag". The MDB is supposed to process it and put it on response queue, from were it will
+ * be read by the client.
+ *
+ * The example is considered successful if the client receives the "processed" message.
+ *
+ * Since this example is also used by the smoke test, it is essential that the VM exits with exit
+ * code 0 in case of successful execution and a non-zero value on failure.
+ *
+ * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
+ * @version <tt>$Revision: 884 $</tt>
+ *
+ * $Id: Sender.java 884 2006-04-12 01:04:10Z ovidiu $
+ */
+public class Sender extends ExampleSupport
+{
+ public void example() throws Exception
+ {
+
+ String destinationName = getDestinationJNDIName();
+
+ InitialContext ic = new InitialContext();
+
+ ConnectionFactory cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
+ Queue queue = (Queue)ic.lookup(destinationName);
+
+
+
+ log("Queue " + destinationName + " exists");
+
+
+
+ Connection connection = cf.createConnection();
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageProducer sender = session.createProducer(queue);
+
+
+
+ Queue temporaryQueue = session.createTemporaryQueue();
+ MessageConsumer consumer = session.createConsumer(temporaryQueue);
+
+
+
+ TextMessage message = session.createTextMessage("Hello!");
+ message.setJMSReplyTo(temporaryQueue);
+
+
+
+ sender.send(message);
+
+
+
+ log("The \"" + message.getText() + "\" message was successfully sent to the " + queue.getQueueName() + " queue");
+
+
+
+ connection.start();
+
+
+
+ message = (TextMessage)consumer.receive(5000);
+
+
+ if (message == null)
+ {
+ throw new Exception("Have not received any reply. The example failed!");
+ }
+
+
+ log("Received message: " + message.getText());
+
+
+
+ assertEquals("!olleH", message.getText());
+
+
+
+ displayProviderInfo(connection.getMetaData());
+
+
+ connection.close();
+ }
+
+
+
+
+ protected boolean isQueueExample()
+ {
+ return true;
+ }
+
+
+
+
+ public static void main(String[] args)
+ {
+ new Sender().run();
+ }
+
+}
Modified: branches/Branch_1_0/docs/examples/stateless/build.xml
===================================================================
--- branches/Branch_1_0/docs/examples/stateless/build.xml 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/docs/examples/stateless/build.xml 2007-02-11 13:16:25 UTC (rev 2264)
@@ -87,7 +87,7 @@
<target name="deploy" depends="jar">
<copy file="./output/lib/stateless-example.jar"
todir="${jboss.home}/server/${jboss.configuration}/deploy"/>
- <antcall target="sleep"><param name="sleep.interval" value="5"/></antcall>
+ <antcall target="sleep"><param name="sleep.interval" value="10"/></antcall>
</target>
<target name="run" depends="deploy">
Modified: branches/Branch_1_0/lib/README.txt
===================================================================
--- branches/Branch_1_0/lib/README.txt 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/lib/README.txt 2007-02-11 13:16:25 UTC (rev 2264)
@@ -1,2 +1,2 @@
-jboss-remoting.jar 2.0.0.Beta2 (locally built with minor fix in TimerUtil.java to make Timer daemon, and bound connection pool fix and removal of log.isTraceEnabled in MicroSockectClientInvoker)
-jboss-serialization.jar snapshot
+jbosssx.jar JBoss 4.0.5.GA
+
Modified: branches/Branch_1_0/lib/jbosssx.jar
===================================================================
(Binary files differ)
Modified: branches/Branch_1_0/messaging.iml
===================================================================
--- branches/Branch_1_0/messaging.iml 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/messaging.iml 2007-02-11 13:16:25 UTC (rev 2264)
@@ -35,17 +35,6 @@
<orderEntry type="module-library">
<library>
<CLASSES>
- <root url="jar://$MODULE_DIR$/thirdparty/jboss/common/lib/jboss-common.jar!/" />
- </CLASSES>
- <JAVADOC />
- <SOURCES>
- <root url="file://$MODULE_DIR$/../common/src/main" />
- </SOURCES>
- </library>
- </orderEntry>
- <orderEntry type="module-library">
- <library>
- <CLASSES>
<root url="jar://$MODULE_DIR$/thirdparty/javassist/lib/javassist.jar!/" />
</CLASSES>
<JAVADOC />
@@ -188,7 +177,47 @@
<SOURCES />
</library>
</orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/apache-log4j/lib/log4j.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/jboss/common-core/lib/jboss-common-core.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/jboss/common-logging-log4j/lib/jboss-logging-log4j.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/thirdparty/jboss/common-logging-spi/lib/jboss-logging-spi.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
<orderEntryProperties />
</component>
+ <component name="VcsManagerConfiguration">
+ <option name="ACTIVE_VCS_NAME" value="svn" />
+ <option name="USE_PROJECT_VCS" value="false" />
+ </component>
</module>
Modified: branches/Branch_1_0/src/main/org/jboss/jms/client/JBossConnectionFactory.java
===================================================================
--- branches/Branch_1_0/src/main/org/jboss/jms/client/JBossConnectionFactory.java 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/src/main/org/jboss/jms/client/JBossConnectionFactory.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -40,6 +40,7 @@
import javax.naming.Reference;
import org.jboss.aop.Advised;
+import org.jboss.aop.AspectManager;
import org.jboss.jms.client.container.JmsClientAspectXMLLoader;
import org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate;
import org.jboss.jms.delegate.ConnectionDelegate;
@@ -226,20 +227,24 @@
{
if (!configLoaded)
{
- // Load the client side aspect stack configuration from the server and apply it
-
- delegate.init();
-
- byte[] clientAOPConfig = delegate.getClientAOPConfig();
-
- // Remove interceptor since we don't want it on the front of the stack
- ((Advised)delegate)._getInstanceAdvisor().removeInterceptor(delegate.getName());
-
- JmsClientAspectXMLLoader loader = new JmsClientAspectXMLLoader();
-
- loader.deployXML(clientAOPConfig);
-
- configLoaded = true;
+ // Need to synchronize due to http://jira.jboss.com/jira/browse/JBMESSAGING-797
+ synchronized (AspectManager.instance())
+ {
+ // Load the client side aspect stack configuration from the server and apply it
+
+ delegate.init();
+
+ byte[] clientAOPConfig = delegate.getClientAOPConfig();
+
+ // Remove interceptor since we don't want it on the front of the stack
+ ((Advised)delegate)._getInstanceAdvisor().removeInterceptor(delegate.getName());
+
+ JmsClientAspectXMLLoader loader = new JmsClientAspectXMLLoader();
+
+ loader.deployXML(clientAOPConfig);
+
+ configLoaded = true;
+ }
}
}
}
Modified: branches/Branch_1_0/src/main/org/jboss/jms/client/JBossQueueBrowser.java
===================================================================
--- branches/Branch_1_0/src/main/org/jboss/jms/client/JBossQueueBrowser.java 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/src/main/org/jboss/jms/client/JBossQueueBrowser.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -49,8 +49,6 @@
private Queue queue;
private String messageSelector;
- private BrowserEnumeration enumeration = new BrowserEnumeration();
-
// Constructors --------------------------------------------------
JBossQueueBrowser(Queue queue, String messageSelector, BrowserDelegate delegate)
@@ -69,8 +67,9 @@
}
public Enumeration getEnumeration() throws JMSException
- {
- return enumeration;
+ {
+ delegate.reset();
+ return new BrowserEnumeration();
}
public String getMessageSelector() throws JMSException
Modified: branches/Branch_1_0/src/main/org/jboss/jms/client/container/SessionAspect.java
===================================================================
--- branches/Branch_1_0/src/main/org/jboss/jms/client/container/SessionAspect.java 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/src/main/org/jboss/jms/client/container/SessionAspect.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -132,11 +132,9 @@
if (ackMode == Session.CLIENT_ACKNOWLEDGE ||
ackMode == Session.AUTO_ACKNOWLEDGE ||
- ackMode == Session.DUPS_OK_ACKNOWLEDGE ||
- state.getCurrentTxId() == null)
+ ackMode == Session.DUPS_OK_ACKNOWLEDGE)
{
- // We collect acknowledgments (and not transact them) for CLIENT, AUTO and DUPS_OK, and
- // also for XA sessions not enrolled in a global transaction.
+ // We collect acknowledgments (and not transact them) for CLIENT, AUTO and DUPS_OK
SessionDelegate del = (SessionDelegate)mi.getTargetObject();
@@ -186,11 +184,10 @@
}
if (ackMode == Session.AUTO_ACKNOWLEDGE ||
- ackMode == Session.DUPS_OK_ACKNOWLEDGE ||
- ackMode != Session.CLIENT_ACKNOWLEDGE && state.getCurrentTxId() == null)
+ ackMode == Session.DUPS_OK_ACKNOWLEDGE)
{
// We acknowledge immediately on a non-transacted session that does not want to
- // CLIENT_ACKNOWLEDGE, or an XA session not enrolled in a global transaction.
+ // CLIENT_ACKNOWLEDGE
SessionDelegate sd = (SessionDelegate)mi.getTargetObject();
Modified: branches/Branch_1_0/src/main/org/jboss/jms/client/delegate/ClientBrowserDelegate.java
===================================================================
--- branches/Branch_1_0/src/main/org/jboss/jms/client/delegate/ClientBrowserDelegate.java 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/src/main/org/jboss/jms/client/delegate/ClientBrowserDelegate.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -80,6 +80,11 @@
throw new IllegalStateException("This invocation should not be handled here!");
}
+ public void reset() throws JMSException
+ {
+ throw new IllegalStateException("This invocation should not be handled here!");
+ }
+
public boolean hasNextMessage() throws JMSException
{
throw new IllegalStateException("This invocation should not be handled here!");
Modified: branches/Branch_1_0/src/main/org/jboss/jms/client/remoting/ClientSocketWrapper.java
===================================================================
--- branches/Branch_1_0/src/main/org/jboss/jms/client/remoting/ClientSocketWrapper.java 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/src/main/org/jboss/jms/client/remoting/ClientSocketWrapper.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -25,7 +25,9 @@
import org.jboss.remoting.InvokerLocator;
import org.jboss.remoting.serialization.SerializationStreamFactory;
+import org.jboss.remoting.serialization.SerializationManager;
import org.jboss.remoting.transport.socket.SocketWrapper;
+import org.jboss.logging.Logger;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
@@ -44,16 +46,20 @@
*/
public class ClientSocketWrapper extends SocketWrapper
{
- // Constants -----------------------------------------------------
+ // Constants ------------------------------------------------------------------------------------
- // Static --------------------------------------------------------
+ private static final Logger log = Logger.getLogger(ClientSocketWrapper.class);
- // Attributes ----------------------------------------------------
+ // Static ---------------------------------------------------------------------------------------
+ private static boolean trace = log.isTraceEnabled();
+
+ // Attributes -----------------------------------------------------------------------------------
+
private ObjectInputStream in;
private ObjectOutputStream out;
- // Constructors --------------------------------------------------
+ // Constructors ---------------------------------------------------------------------------------
public ClientSocketWrapper(Socket socket) throws IOException
{
@@ -67,7 +73,7 @@
createStreams(socket, metadata);
}
- // Public --------------------------------------------------------
+ // Public ---------------------------------------------------------------------------------------
public OutputStream getOutputStream()
{
@@ -90,12 +96,13 @@
in.readByte();
}
- // Package protected ---------------------------------------------
+ // Package protected ----------------------------------------------------------------------------
- // Protected -----------------------------------------------------
+ // Protected ------------------------------------------------------------------------------------
protected void createStreams(Socket socket, Map metadata) throws IOException
{
+ if (trace) { log.trace(this + " creating streams for " + socket); }
String serializationType = "jboss"; // hardcoding to default to jboss serialization
@@ -119,20 +126,35 @@
protected ObjectInputStream createInputStream(String serializationType, Socket socket)
throws IOException
{
+ if (trace) { log.trace(this + " creating input stream"); }
+
BufferedInputStream bin = new BufferedInputStream(socket.getInputStream());
- return SerializationStreamFactory.getManagerInstance(serializationType).
- createInput(bin, null);
+ SerializationManager sm = SerializationStreamFactory.getManagerInstance(serializationType);
+
+ ObjectInputStream ois = sm.createInput(bin, null);
+
+ if (trace) { log.trace(this + " created and returned " + ois); }
+
+ return ois;
}
protected ObjectOutputStream createOutputStream(String serializationType, Socket socket)
throws IOException
{
+ if (trace) { log.trace(this + " creating output stream"); }
+
BufferedOutputStream bout = new BufferedOutputStream(socket.getOutputStream());
- return SerializationStreamFactory.getManagerInstance(serializationType).createOutput(bout);
+ SerializationManager sm = SerializationStreamFactory.getManagerInstance(serializationType);
+
+ ObjectOutputStream oos = sm.createOutput(bout);
+
+ if (trace) { log.trace(this + " created and returned " + oos); }
+
+ return oos;
}
- // Private -------------------------------------------------------
+ // Private --------------------------------------------------------------------------------------
- // Inner classes -------------------------------------------------
+ // Inner classes --------------------------------------------------------------------------------
}
Modified: branches/Branch_1_0/src/main/org/jboss/jms/client/state/SessionState.java
===================================================================
--- branches/Branch_1_0/src/main/org/jboss/jms/client/state/SessionState.java 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/src/main/org/jboss/jms/client/state/SessionState.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -80,13 +80,13 @@
xaResource = new MessagingXAResource(parent.getResourceManager(), this);
}
- // If session is transacted and XA, the currentTxId will be updated when the XAResource will
- // be enrolled with a global transaction.
+ // Note we create the transaction even if XA - XA transactions must behave like
+ // local tx when not enlisted in a global tx
- if (transacted & !xa)
+ if (transacted)
{
// Create a local tx
- currentTxId = parent.getResourceManager().createLocalTx();
+ currentTxId = parent.getResourceManager().createLocalTx();
}
executor = new QueuedExecutor(new LinkedQueue());
Modified: branches/Branch_1_0/src/main/org/jboss/jms/server/ConnectionManager.java
===================================================================
--- branches/Branch_1_0/src/main/org/jboss/jms/server/ConnectionManager.java 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/src/main/org/jboss/jms/server/ConnectionManager.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -23,7 +23,9 @@
import org.jboss.jms.server.endpoint.ConnectionEndpoint;
+import java.util.List;
+
/**
* @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
@@ -40,9 +42,17 @@
* @return null if there is no such connection.
*/
ConnectionEndpoint unregisterConnection(String jmsClientVMId, String remotingClientSessionID);
-
+
void handleClientFailure(String remotingSessionID);
-
+
boolean containsSession(String remotingClientSessionID);
+ /**
+ * Returns a list of active connection endpoints currently maintained by an instance of this
+ * manager. The implementation should make a copy of the list to avoid
+ * ConcurrentModificationException. The list could be empty, but never null.
+ *
+ * @return List<ConnectionEndpoint>
+ */
+ List getActiveConnections();
}
Modified: branches/Branch_1_0/src/main/org/jboss/jms/server/SecurityManager.java
===================================================================
--- branches/Branch_1_0/src/main/org/jboss/jms/server/SecurityManager.java 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/src/main/org/jboss/jms/server/SecurityManager.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -49,6 +49,11 @@
* Authenticate the specified user with the given password. Implementations are most likely to
* delegates to a JBoss AuthenticationManager.
*
+ * Successful autentication will place a new SubjectContext on thread local, which will be used
+ * in the authorization process. However, we need to make sure we clean up thread local
+ * immediately after we used the information, otherwise some other people security my be screwed
+ * up, on account of thread local security stack being corrupted.
+ *
* @throws JMSSecurityException if the user is not authenticated
*/
Subject authenticate(String user, String password) throws JMSSecurityException;
Modified: branches/Branch_1_0/src/main/org/jboss/jms/server/ServerPeer.java
===================================================================
--- branches/Branch_1_0/src/main/org/jboss/jms/server/ServerPeer.java 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/src/main/org/jboss/jms/server/ServerPeer.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -24,8 +24,11 @@
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.net.URL;
+import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import java.util.Set;
+import javax.jms.InvalidClientIDException;
import javax.management.Attribute;
import javax.management.MBeanServer;
import javax.management.ObjectName;
@@ -35,6 +38,7 @@
import org.jboss.jms.server.connectionfactory.ConnectionFactoryJNDIMapper;
import org.jboss.jms.server.connectionmanager.SimpleConnectionManager;
import org.jboss.jms.server.connectormanager.SimpleConnectorManager;
+import org.jboss.jms.server.endpoint.ServerConnectionEndpoint;
import org.jboss.jms.server.endpoint.ServerConsumerEndpoint;
import org.jboss.jms.server.plugin.contract.ChannelMapper;
import org.jboss.jms.server.remoting.JMSServerInvocationHandler;
@@ -619,6 +623,31 @@
{
return queuedExecutorPool;
}
+
+ public void checkClientID(String clientID) throws Exception
+ {
+ // verify the clientID is unique
+
+ // JMS 1.1 Specifications, Section 4.3.2:
+ // "By definition, the client state identified by a client identifier can be 'in use' by
+ // only one client at a time. A JMS provider must prevent concurrently executing clients
+ // from using it."
+
+ if (clientID != null)
+ {
+ List conns = connectionManager.getActiveConnections();
+
+ for(Iterator i = conns.iterator(); i.hasNext(); )
+ {
+ ServerConnectionEndpoint sce = (ServerConnectionEndpoint)i.next();
+ if (clientID != null && clientID.equals(sce.getClientID()))
+ {
+ throw new InvalidClientIDException(
+ "Client ID '" + clientID + "' already used by " + sce);
+ }
+ }
+ }
+ }
public String toString()
{
@@ -633,6 +662,8 @@
private void initializeRemoting(MBeanServer mbeanServer) throws Exception
{
+ log.trace("using " + mbeanServer);
+
// We explicitly associate the datatype "jms" with the java SerializationManager
// This is vital for performance reasons.
SerializationStreamFactory.setManagerClassName(
Modified: branches/Branch_1_0/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactoryJNDIMapper.java
===================================================================
--- branches/Branch_1_0/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactoryJNDIMapper.java 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactoryJNDIMapper.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -29,6 +29,7 @@
import javax.naming.Context;
import javax.naming.InitialContext;
+import org.jboss.aop.AspectManager;
import org.jboss.jms.client.JBossConnectionFactory;
import org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate;
import org.jboss.jms.server.ConnectionFactoryManager;
@@ -93,8 +94,14 @@
new ClientConnectionFactoryDelegate(id, locatorURI, serverPeer.getVersion(),
serverPeer.getServerPeerID(), clientPing);
- ConnectionFactoryAdvised connFactoryAdvised = new ConnectionFactoryAdvised(endpoint);
+ ConnectionFactoryAdvised connFactoryAdvised;
+ // Need to synchronize due to http://jira.jboss.com/jira/browse/JBMESSAGING-797
+ synchronized (AspectManager.instance())
+ {
+ connFactoryAdvised = new ConnectionFactoryAdvised(endpoint);
+ }
+
JMSDispatcher.instance.registerTarget(new Integer(id), connFactoryAdvised);
endpoints.put(new Integer(id), endpoint);
Modified: branches/Branch_1_0/src/main/org/jboss/jms/server/connectionmanager/SimpleConnectionManager.java
===================================================================
--- branches/Branch_1_0/src/main/org/jboss/jms/server/connectionmanager/SimpleConnectionManager.java 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/src/main/org/jboss/jms/server/connectionmanager/SimpleConnectionManager.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -27,6 +27,8 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Set;
+import java.util.HashSet;
import javax.jms.JMSException;
@@ -59,17 +61,22 @@
// Attributes ----------------------------------------------------
+ // Map<jmsClientVMID<String> - Map<remotingClientSessionID<String> - ConnectionEndpoint>>
protected Map jmsClients;
-
+
+ // Map<remotingClientSessionID<String> - jmsClientVMID<String>
protected Map sessions;
-
+
+ // Set<ConnectionEndpoint>
+ protected Set activeConnectionEndpoints;
+
// Constructors --------------------------------------------------
public SimpleConnectionManager()
{
jmsClients = new HashMap();
-
sessions = new HashMap();
+ activeConnectionEndpoints = new HashSet();
}
// ConnectionManager ---------------------------------------------
@@ -87,6 +94,8 @@
endpoints.put(remotingClientSessionID, endpoint);
sessions.put(remotingClientSessionID, jmsClientVMId);
+
+ activeConnectionEndpoints.add(endpoint);
log.debug("registered connection " + endpoint + " as " +
Util.guidToString(remotingClientSessionID));
@@ -99,7 +108,13 @@
if (endpoints != null)
{
ConnectionEndpoint e = (ConnectionEndpoint)endpoints.remove(remotingClientSessionID);
-
+
+ if (e != null)
+ {
+ endpoints.remove(e);
+ activeConnectionEndpoints.remove(e);
+ }
+
log.debug("unregistered connection " + e + " with remoting session ID " +
Util.guidToString(remotingClientSessionID));
@@ -170,7 +185,15 @@
}
}
}
-
+
+ public synchronized List getActiveConnections()
+ {
+ // I will make a copy to avoid ConcurrentModification
+ ArrayList list = new ArrayList();
+ list.addAll(activeConnectionEndpoints);
+ return list;
+ }
+
/*
* Used in testing only
*/
Modified: branches/Branch_1_0/src/main/org/jboss/jms/server/container/SecurityAspect.java
===================================================================
--- branches/Branch_1_0/src/main/org/jboss/jms/server/container/SecurityAspect.java 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/src/main/org/jboss/jms/server/container/SecurityAspect.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -39,6 +39,7 @@
import org.jboss.jms.server.endpoint.advised.SessionAdvised;
import org.jboss.jms.server.security.SecurityMetadata;
import org.jboss.logging.Logger;
+import org.jboss.security.SecurityAssociation;
/**
* This aspect enforces the JBossMessaging JMS security policy.
@@ -53,6 +54,7 @@
* milliseconds later.
*
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
* @version <tt>$Revision 1.1 $</tt>
*
* $Id$
@@ -64,138 +66,138 @@
private static final Logger log = Logger.getLogger(SecurityAspect.class);
// Static --------------------------------------------------------
-
+
// Attributes ----------------------------------------------------
-
+
private boolean trace = log.isTraceEnabled();
-
+
private Set readCache;
-
+
private Set writeCache;
-
+
private Set createCache;
-
+
//TODO Make this configurable
private static final long INVALIDATION_INTERVAL = 15000;
-
+
private long lastCheck;
-
+
// Constructors --------------------------------------------------
-
+
// Public --------------------------------------------------------
public SecurityAspect()
{
readCache = new HashSet();
-
+
writeCache = new HashSet();
-
+
createCache = new HashSet();
}
-
+
public Object handleCreateConsumerDelegate(Invocation invocation) throws Throwable
{
MethodInvocation mi = (MethodInvocation)invocation;
-
+
// read permission required on the destination
Destination dest = (Destination)mi.getArguments()[0];
-
+
SessionAdvised del = (SessionAdvised)invocation.getTargetObject();
ServerSessionEndpoint sess = (ServerSessionEndpoint)del.getEndpoint();
-
+
check(dest, CheckType.READ, sess.getConnectionEndpoint());
-
+
// if creating a durable subscription then need create permission
-
+
String subscriptionName = (String)mi.getArguments()[3];
if (subscriptionName != null)
{
// durable
check(dest, CheckType.CREATE, sess.getConnectionEndpoint());
}
-
+
return invocation.invokeNext();
- }
-
+ }
+
public Object handleCreateBrowserDelegate(Invocation invocation) throws Throwable
{
// read permission required on the destination
-
+
MethodInvocation mi = (MethodInvocation)invocation;
-
+
Destination dest = (Destination)mi.getArguments()[0];
-
+
SessionAdvised del = (SessionAdvised)invocation.getTargetObject();
ServerSessionEndpoint sess = (ServerSessionEndpoint)del.getEndpoint();
-
+
check(dest, CheckType.READ, sess.getConnectionEndpoint());
-
+
return invocation.invokeNext();
}
-
+
public Object handleSend(Invocation invocation) throws Throwable
{
// anonymous producer - if destination is not null then write permissions required
-
+
MethodInvocation mi = (MethodInvocation)invocation;
-
+
Message m = (Message)mi.getArguments()[0];
Destination dest = m.getJMSDestination();
SessionAdvised del = (SessionAdvised)invocation.getTargetObject();
ServerSessionEndpoint se = (ServerSessionEndpoint)del.getEndpoint();
ServerConnectionEndpoint ce = se.getConnectionEndpoint();
-
+
check(dest, CheckType.WRITE, ce);
-
+
return invocation.invokeNext();
- }
-
+ }
+
public Object handleGetMessageNow(Invocation invocation) throws Throwable
- {
+ {
checkConsumerAccess(invocation);
-
+
return invocation.invokeNext();
- }
-
+ }
+
public Object handleActivate(Invocation invocation) throws Throwable
- {
+ {
checkConsumerAccess(invocation);
-
+
return invocation.invokeNext();
- }
-
+ }
+
protected void checkConsumerAccess(Invocation invocation) throws Throwable
{
ConsumerAdvised del = (ConsumerAdvised)invocation.getTargetObject();
ServerConsumerEndpoint cons = (ServerConsumerEndpoint)del.getEndpoint();
ServerConnectionEndpoint conn = cons.getSessionEndpoint().getConnectionEndpoint();
JBossDestination dest = cons.getDestination();
-
+
check(dest, CheckType.READ, conn);
}
-
+
// Package protected ---------------------------------------------
-
+
// Protected -----------------------------------------------------
-
+
// Private -------------------------------------------------------
-
+
private boolean checkCached(Destination dest, CheckType checkType)
{
long now = System.currentTimeMillis();
-
+
boolean granted = false;
-
+
if (now - lastCheck > INVALIDATION_INTERVAL)
{
readCache.clear();
-
+
writeCache.clear();
-
- createCache.clear();
+
+ createCache.clear();
}
else
- {
+ {
switch (checkType.type)
{
case CheckType.TYPE_READ:
@@ -219,20 +221,20 @@
}
}
}
-
+
lastCheck = now;
-
+
return granted;
}
-
+
private void check(Destination dest, CheckType checkType, ServerConnectionEndpoint conn)
throws JMSSecurityException
{
if (trace) { log.trace("checking access permissions to " + dest); }
-
+
if (checkCached(dest, checkType))
{
- //Ok
+ // OK
return;
}
@@ -248,27 +250,38 @@
throw new JMSSecurityException("No security configuration avaliable for " + name);
}
- // Authenticate
+ // Authenticate. Successful autentication will place a new SubjectContext on thread local,
+ // which will be used in the authorization process. However, we need to make sure we clean up
+ // thread local immediately after we used the information, otherwise some other people
+ // security my be screwed up, on account of thread local security stack being corrupted.
+
sm.authenticate(conn.getUsername(), conn.getPassword());
// Authorize
Set principals = checkType == CheckType.READ ? securityMetadata.getReadPrincipals() :
checkType == CheckType.WRITE ? securityMetadata.getWritePrincipals() :
securityMetadata.getCreatePrincipals();
-
- if (!sm.authorize(conn.getUsername(), principals))
+ try
{
- String msg = "User: " + conn.getUsername() +
- " is not authorized to " +
- (checkType == CheckType.READ ? "read from" :
- checkType == CheckType.WRITE ? "write to" : "create durable sub on") +
- " destination " + name;
-
- throw new JMSSecurityException(msg);
+ if (!sm.authorize(conn.getUsername(), principals))
+ {
+ String msg = "User: " + conn.getUsername() +
+ " is not authorized to " +
+ (checkType == CheckType.READ ? "read from" :
+ checkType == CheckType.WRITE ? "write to" : "create durable sub on") +
+ " destination " + name;
+
+ throw new JMSSecurityException(msg);
+ }
}
-
+ finally
+ {
+ // pop the Messaging SecurityContext, it did its job
+ SecurityAssociation.popSubjectContext();
+ }
+
// if we get here we're granted, add to the cache
-
+
switch (checkType.type)
{
case CheckType.TYPE_READ:
@@ -290,31 +303,31 @@
{
throw new IllegalArgumentException("Invalid checkType:" + checkType);
}
- }
+ }
}
-
+
// Inner classes -------------------------------------------------
-
+
private static class CheckType
{
private int type;
private CheckType(int type)
{
this.type = type;
- }
+ }
public static final int TYPE_READ = 0;
public static final int TYPE_WRITE = 1;
public static final int TYPE_CREATE = 2;
public static CheckType READ = new CheckType(TYPE_READ);
public static CheckType WRITE = new CheckType(TYPE_WRITE);
- public static CheckType CREATE = new CheckType(TYPE_CREATE);
+ public static CheckType CREATE = new CheckType(TYPE_CREATE);
public boolean equals(Object other)
{
if (!(other instanceof CheckType)) return false;
CheckType ct = (CheckType)other;
return ct.type == this.type;
}
- public int hashCode()
+ public int hashCode()
{
return type;
}
Modified: branches/Branch_1_0/src/main/org/jboss/jms/server/endpoint/BrowserEndpoint.java
===================================================================
--- branches/Branch_1_0/src/main/org/jboss/jms/server/endpoint/BrowserEndpoint.java 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/src/main/org/jboss/jms/server/endpoint/BrowserEndpoint.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -31,12 +31,20 @@
* of the methods are handled in the advice stack.
*
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
* @version <tt>$Revision$</tt>
*
* $Id$
*/
public interface BrowserEndpoint extends Closeable
-{
+{
+ /**
+ * Reset the internal state of the browser endpoint so the following
+ * nextMessage()/hasNextMessage()/nextMessageBlock() invocations would reflect the state of the
+ * queue at the moment of the reset.
+ */
+ void reset() throws JMSException;
+
Message nextMessage() throws JMSException;
boolean hasNextMessage() throws JMSException;
Modified: branches/Branch_1_0/src/main/org/jboss/jms/server/endpoint/ServerBrowserEndpoint.java
===================================================================
--- branches/Branch_1_0/src/main/org/jboss/jms/server/endpoint/ServerBrowserEndpoint.java 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/src/main/org/jboss/jms/server/endpoint/ServerBrowserEndpoint.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -39,6 +39,7 @@
* Concrete implementation of BrowserEndpoint.
*
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
* @version <tt>$Revision$</tt>
*
* $Id$
@@ -55,14 +56,16 @@
private boolean trace = log.isTraceEnabled();
- private Iterator iterator;
-
private ServerSessionEndpoint session;
private int id;
private boolean closed;
+ private Channel destination;
+ private Filter filter;
+ private Iterator iterator;
+
// Constructors --------------------------------------------------
protected ServerBrowserEndpoint(ServerSessionEndpoint session, int id,
@@ -72,25 +75,41 @@
this.session = session;
this.id = id;
+
+ this.destination = destination;
- Filter filter = null;
-
if (messageSelector != null)
{
filter = new Selector(messageSelector);
}
-
- iterator = destination.browse(filter).iterator();
}
// BrowserEndpoint implementation --------------------------------
+ public void reset() throws JMSException
+ {
+ if (closed)
+ {
+ throw new IllegalStateException("Browser is closed");
+ }
+
+ log.debug(this + " is being resetted");
+
+ iterator = createIterator();
+ }
+
public boolean hasNextMessage() throws JMSException
{
if (closed)
{
throw new IllegalStateException("Browser is closed");
}
+
+ if (iterator == null)
+ {
+ iterator = createIterator();
+ }
+
return iterator.hasNext();
}
@@ -100,6 +119,12 @@
{
throw new IllegalStateException("Browser is closed");
}
+
+ if (iterator == null)
+ {
+ iterator = createIterator();
+ }
+
Routable r = (Routable)iterator.next();
if (trace) { log.trace("returning the message corresponding to " + r); }
@@ -121,7 +146,12 @@
{
throw new IllegalArgumentException("maxMessages must be >=2 otherwise use nextMessage");
}
-
+
+ if (iterator == null)
+ {
+ iterator = createIterator();
+ }
+
ArrayList messages = new ArrayList(maxMessages);
int i = 0;
while (i < maxMessages)
@@ -173,6 +203,11 @@
// Private -------------------------------------------------------
+ private Iterator createIterator()
+ {
+ return destination.browse(filter).iterator();
+ }
+
// Inner classes -------------------------------------------------
}
Modified: branches/Branch_1_0/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java
===================================================================
--- branches/Branch_1_0/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -32,6 +32,7 @@
import javax.jms.JMSException;
import javax.transaction.xa.Xid;
+import org.jboss.aop.AspectManager;
import org.jboss.jms.client.delegate.ClientSessionDelegate;
import org.jboss.jms.client.remoting.CallbackServerFactory;
import org.jboss.jms.delegate.SessionDelegate;
@@ -187,8 +188,16 @@
// connection endpoint instance
ServerSessionEndpoint ep = new ServerSessionEndpoint(sessionID, this);
putSessionDelegate(sessionID, ep);
- SessionAdvised sessionAdvised = new SessionAdvised(ep);
- JMSDispatcher.instance.registerTarget(new Integer(sessionID), sessionAdvised);
+
+ SessionAdvised advised;
+
+ // Need to synchronize due to http://jira.jboss.com/jira/browse/JBMESSAGING-797
+ synchronized (AspectManager.instance())
+ {
+ advised = new SessionAdvised(ep);
+ }
+
+ JMSDispatcher.instance.registerTarget(new Integer(sessionID), advised);
ClientSessionDelegate d = new ClientSessionDelegate(sessionID);
@@ -227,19 +236,24 @@
{
throw new IllegalStateException("Connection is closed");
}
- if (trace) { log.trace("setClientID:" + clientID); }
+
if (this.clientID != null)
{
- throw new IllegalStateException("Cannot set clientID, already set as:" + this.clientID);
+ throw new IllegalStateException("Cannot set clientID, already set as " + this.clientID);
}
+
+ serverPeer.checkClientID(clientID);
+
+ log.debug(this + "setting client ID to " + clientID);
+
this.clientID = clientID;
}
catch (Throwable t)
{
throw ExceptionUtil.handleJMSInvocation(t, this + " setClientID");
- }
+ }
}
-
+
public void start() throws JMSException
{
try
Modified: branches/Branch_1_0/src/main/org/jboss/jms/server/endpoint/ServerConnectionFactoryEndpoint.java
===================================================================
--- branches/Branch_1_0/src/main/org/jboss/jms/server/endpoint/ServerConnectionFactoryEndpoint.java 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/src/main/org/jboss/jms/server/endpoint/ServerConnectionFactoryEndpoint.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -23,6 +23,7 @@
import javax.jms.JMSException;
+import org.jboss.aop.AspectManager;
import org.jboss.jms.client.delegate.ClientConnectionDelegate;
import org.jboss.jms.delegate.ConnectionDelegate;
import org.jboss.jms.server.ServerPeer;
@@ -32,6 +33,7 @@
import org.jboss.jms.util.ExceptionUtil;
import org.jboss.logging.Logger;
import org.jboss.messaging.core.plugin.IdBlock;
+import org.jboss.security.SecurityAssociation;
/**
* Concrete implementation of ConnectionFactoryEndpoint
@@ -49,26 +51,26 @@
private static final Logger log = Logger.getLogger(ServerConnectionFactoryEndpoint.class);
// Static --------------------------------------------------------
-
+
// Attributes ----------------------------------------------------
private ServerPeer serverPeer;
-
+
private String clientID;
-
+
private int id;
-
+
private JNDIBindings jndiBindings;
-
+
private int prefetchSize;
-
+
protected int defaultTempQueueFullSize;
-
+
protected int defaultTempQueuePageSize;
-
+
protected int defaultTempQueueDownCacheSize;
-
+
// Constructors --------------------------------------------------
/**
@@ -94,42 +96,58 @@
}
// ConnectionFactoryDelegate implementation ----------------------
-
+
public ConnectionDelegate createConnectionDelegate(String username, String password)
throws JMSException
{
try
{
log.debug("creating a new connection for user " + username);
-
- // authenticate the user
+
+ // Authenticate. Successful autentication will place a new SubjectContext on thread local,
+ // which will be used in the authorization process. However, we need to make sure we clean
+ // up thread local immediately after we used the information, otherwise some other people
+ // security my be screwed up, on account of thread local security stack being corrupted.
+
serverPeer.getSecurityManager().authenticate(username, password);
-
+
+ // We don't need the SubjectContext on thread local anymore, clean it up
+ SecurityAssociation.popSubjectContext();
+
// see if there is a preconfigured client id for the user
if (username != null)
{
String preconfClientID =
serverPeer.getChannelMapperDelegate().getPreConfiguredClientID(username);
-
+
if (preconfClientID != null)
{
clientID = preconfClientID;
}
}
-
+
+ serverPeer.checkClientID(clientID);
+
// create the corresponding "server-side" connection endpoint and register it with the
// server peer's ClientManager
ServerConnectionEndpoint endpoint =
new ServerConnectionEndpoint(serverPeer, clientID, username, password, prefetchSize,
- defaultTempQueueFullSize, defaultTempQueuePageSize, defaultTempQueueDownCacheSize);
-
+ defaultTempQueueFullSize, defaultTempQueuePageSize, defaultTempQueueDownCacheSize);
+
int connectionID = endpoint.getConnectionID();
-
- ConnectionAdvised connAdvised = new ConnectionAdvised(endpoint);
- JMSDispatcher.instance.registerTarget(new Integer(connectionID), connAdvised);
-
+
+ ConnectionAdvised advised;
+
+ // Need to synchronize due to http://jira.jboss.com/jira/browse/JBMESSAGING-797
+ synchronized (AspectManager.instance())
+ {
+ advised = new ConnectionAdvised(endpoint);
+ }
+
+ JMSDispatcher.instance.registerTarget(new Integer(connectionID), advised);
+
log.debug("created and registered " + endpoint);
-
+
return new ClientConnectionDelegate(connectionID);
}
catch (Throwable t)
@@ -137,7 +155,7 @@
throw ExceptionUtil.handleJMSInvocation(t, this + " createConnectionDelegate");
}
}
-
+
public byte[] getClientAOPConfig() throws JMSException
{
try
@@ -164,7 +182,7 @@
// Public --------------------------------------------------------
-
+
public int getID()
{
return id;
@@ -176,10 +194,10 @@
}
// Package protected ---------------------------------------------
-
+
// Protected -----------------------------------------------------
-
+
// Private -------------------------------------------------------
-
+
// Inner classes -------------------------------------------------
}
Modified: branches/Branch_1_0/src/main/org/jboss/jms/server/endpoint/ServerSessionEndpoint.java
===================================================================
--- branches/Branch_1_0/src/main/org/jboss/jms/server/endpoint/ServerSessionEndpoint.java 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/src/main/org/jboss/jms/server/endpoint/ServerSessionEndpoint.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -33,6 +33,7 @@
import javax.jms.InvalidDestinationException;
import javax.jms.JMSException;
+import org.jboss.aop.AspectManager;
import org.jboss.jms.client.delegate.ClientBrowserDelegate;
import org.jboss.jms.client.delegate.ClientConsumerDelegate;
import org.jboss.jms.delegate.BrowserDelegate;
@@ -265,9 +266,16 @@
subscription == null ? (Channel)coreDestination : subscription,
this, selector, noLocal, jmsDestination, prefetchSize, dlq);
- JMSDispatcher.instance.registerTarget(new Integer(consumerID), new ConsumerAdvised(ep));
-
+ ConsumerAdvised advised;
+ // Need to synchronize due to http://jira.jboss.com/jira/browse/JBMESSAGING-797
+ synchronized (AspectManager.instance())
+ {
+ advised = new ConsumerAdvised(ep);
+ }
+
+ JMSDispatcher.instance.registerTarget(new Integer(consumerID), advised);
+
ClientConsumerDelegate stub = new ClientConsumerDelegate(consumerID, prefetchSize, maxDeliveryAttempts);
if (subscription != null)
@@ -321,8 +329,16 @@
new ServerBrowserEndpoint(this, browserID, (Channel)destination, messageSelector);
putBrowserDelegate(browserID, ep);
+
+ BrowserAdvised advised;
+
+ // Need to synchronize due to http://jira.jboss.com/jira/browse/JBMESSAGING-797
+ synchronized (AspectManager.instance())
+ {
+ advised = new BrowserAdvised(ep);
+ }
- JMSDispatcher.instance.registerTarget(new Integer(browserID), new BrowserAdvised(ep));
+ JMSDispatcher.instance.registerTarget(new Integer(browserID), advised);
ClientBrowserDelegate stub = new ClientBrowserDelegate(browserID);
Modified: branches/Branch_1_0/src/main/org/jboss/jms/server/endpoint/advised/BrowserAdvised.java
===================================================================
--- branches/Branch_1_0/src/main/org/jboss/jms/server/endpoint/advised/BrowserAdvised.java 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/src/main/org/jboss/jms/server/endpoint/advised/BrowserAdvised.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -70,6 +70,11 @@
return endpoint.isClosed();
}
+ public void reset() throws JMSException
+ {
+ endpoint.reset();
+ }
+
public boolean hasNextMessage() throws JMSException
{
return endpoint.hasNextMessage();
Modified: branches/Branch_1_0/src/main/org/jboss/jms/server/plugin/JDBCChannelMapper.java
===================================================================
--- branches/Branch_1_0/src/main/org/jboss/jms/server/plugin/JDBCChannelMapper.java 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/src/main/org/jboss/jms/server/plugin/JDBCChannelMapper.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -23,7 +23,6 @@
import java.util.Map;
import java.util.Properties;
import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
import javax.jms.JMSException;
import javax.management.MBeanServerInvocationHandler;
@@ -58,6 +57,7 @@
import EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap;
import EDU.oswego.cs.dl.util.concurrent.QueuedExecutor;
+import EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap;
/**
* JDBC Implementation of ChannelMapper
@@ -72,107 +72,107 @@
public class JDBCChannelMapper extends ServiceMBeanSupport implements ChannelMapper
{
// Constants -----------------------------------------------------
-
+
private static final Logger log = Logger.getLogger(JDBCChannelMapper.class);
-
+
protected static final char TYPE_QUEUE = 'Q';
-
+
protected static final char TYPE_TOPIC = 'T';
-
+
protected static final char TYPE_DURABLE_SUB = 'D';
-
+
//========================================
-
+
//FIXME - user-role table management should be handled by a different service
//It doesn't belong here
-
+
private String createUserTable =
"CREATE TABLE JMS_USER (USERID VARCHAR(32) NOT NULL, PASSWD VARCHAR(32) NOT NULL, CLIENTID VARCHAR(128),"
+ " PRIMARY KEY(USERID))";
-
+
private String createRoleTable = "CREATE TABLE JMS_ROLE (ROLEID VARCHAR(32) NOT NULL, USERID VARCHAR(32) NOT NULL,"
+ " PRIMARY KEY(USERID, ROLEID))";
-
- private String selectPreConfClientId =
+
+ private String selectPreConfClientId =
"SELECT CLIENTID FROM JMS_USER WHERE USERID=?";
-
-
+
+
// =============================================================================
-
- private String createMappingTable =
+
+ private String createMappingTable =
"CREATE TABLE JMS_CHANNEL_MAPPING (ID BIGINT, TYPE CHAR(1), " +
"JMS_DEST_NAME VARCHAR(1024), JMS_SUB_NAME VARCHAR(1024), " +
"CLIENT_ID VARCHAR(128), SELECTOR VARCHAR(1024), NO_LOCAL CHAR(1), PRIMARY KEY(ID))";
-
- private String insertMapping =
+
+ private String insertMapping =
"INSERT INTO JMS_CHANNEL_MAPPING (ID, TYPE, JMS_DEST_NAME, JMS_SUB_NAME, CLIENT_ID, SELECTOR, NO_LOCAL) " +
"VALUES (?, ?, ?, ?, ?, ?, ?)";
-
+
private String deleteMapping =
"DELETE FROM JMS_CHANNEL_MAPPING WHERE ID = ?";
-
- private String selectIdForDestination =
+
+ private String selectIdForDestination =
"SELECT ID FROM JMS_CHANNEL_MAPPING WHERE TYPE=? AND JMS_DEST_NAME=?";
-
- private String selectDurableSub =
+
+ private String selectDurableSub =
"SELECT JMS_DEST_NAME, ID, SELECTOR, NO_LOCAL FROM JMS_CHANNEL_MAPPING WHERE CLIENT_ID=? AND JMS_SUB_NAME=?";
-
- private String selectSubscriptionsForTopic =
+
+ private String selectSubscriptionsForTopic =
"SELECT ID, CLIENT_ID, JMS_SUB_NAME, SELECTOR, NO_LOCAL FROM JMS_CHANNEL_MAPPING WHERE TYPE='D' AND J" +
"MS_DEST_NAME=?";
-
+
// Static --------------------------------------------------------
-
+
// Attributes ----------------------------------------------------
-
+
// Map<clientID - Map<subscriptionName - CoreDurableSubscription>>
protected Map subscriptions;
-
+
protected Map channelIdSubMap;
-
+
// Map<name - Queue>
protected Map queues;
-
+
// Map<name - Topic>
protected Map topics;
-
+
// Map<id - JBossDestination>
protected Map idMap;
-
+
protected String dataSourceJNDIName;
protected DataSource ds;
protected ObjectName tmObjectName;
protected IdManager channelIDManager;
-
+
protected boolean createTablesOnStartup = true;
protected Properties sqlProperties;
protected List populateTables;
-
+
protected QueuedExecutorPool queuedExecutorPool;
// Constructors --------------------------------------------------
-
+
public JDBCChannelMapper()
{
subscriptions = new ConcurrentReaderHashMap();
-
+
queues = new ConcurrentReaderHashMap();
-
+
topics = new ConcurrentReaderHashMap();
-
+
idMap = new ConcurrentReaderHashMap();
-
+
channelIdSubMap = new ConcurrentHashMap();
-
+
sqlProperties = new Properties();
-
+
populateTables = new ArrayList();
}
-
+
/*
- * Only to be used by tests to create an instance
- */
+ * Only to be used by tests to create an instance
+ */
public JDBCChannelMapper(DataSource ds, TransactionManager tm)
{
this();
@@ -183,23 +183,23 @@
}
//Injection
-
+
//TODO
//Since channel mapper requires knowledge of the persistence manager anyway so it can get ids for new channels
//there seems to me no reason why channel mapper should handle it's own persistence
//IMHO all persistence should be handled by the pm
public void setPersistenceManager(PersistenceManager pm) throws Exception
- {
+ {
this.channelIDManager = new IdManager("CHANNEL_ID", 10, pm);
}
-
+
public void setQueuedExecutorPool(QueuedExecutorPool pool) throws Exception
{
this.queuedExecutorPool = pool;
}
-
+
// ServiceMBeanSupport overrides ---------------------------------
-
+
protected void startService() throws Exception
{
try
@@ -210,73 +210,73 @@
ds = (DataSource)ic.lookup(dataSourceJNDIName);
ic.close();
}
-
+
if (ds == null)
{
throw new IllegalStateException("No DataSource found. This service dependencies must " +
"have not been enforced correctly!");
}
-
+
initSqlProperties();
-
+
if (createTablesOnStartup)
{
createSchema();
}
-
+
log.debug(this + " started");
}
catch (Throwable t)
{
throw ExceptionUtil.handleJMXInvocation(t, this + " startService");
- }
+ }
}
-
+
protected void stopService() throws Exception
{
log.debug(this + " stopped");
}
-
+
// DurableSubscriptionStore implementation ---------------
-
+
public Object getInstance()
{
return this;
}
-
+
public CoreDestination getCoreDestination(JBossDestination jbDest)
{
return getCoreDestinationInternal(jbDest.isQueue(), jbDest.getName());
}
-
+
public JBossDestination getJBossDestination(long coreDestinationId)
{
return (JBossDestination)idMap.get(new Long(coreDestinationId));
- }
-
+ }
+
public CoreSubscription getDurableSubscription(long channelID)
{
return (CoreSubscription)channelIdSubMap.get(new Long(channelID));
-
+
}
-
- public void deployCoreDestination(boolean isQueue,
+
+ public void deployCoreDestination(boolean isQueue,
String destName,
- MessageStore ms,
+ MessageStore ms,
PersistenceManager pm,
MemoryManager mm,
- int fullSize,
- int pageSize,
+ int fullSize,
+ int pageSize,
int downCacheSize) throws Exception
- {
+ {
if (log.isTraceEnabled()) { log.trace("creating core destination for " + destName); }
-
+
CoreDestination cd = getCoreDestinationInternal(isQueue, destName);
if (cd != null)
{
throw new JMSException("Destination " + destName + " already deployed");
}
-
+
// Might already be in db
long id;
Long l = getIdForDestination(isQueue, destName);
@@ -284,7 +284,7 @@
{
// Not in db - insert a new mapping row
id = this.getNextId();
-
+
insertMappingRow(id, isQueue ? TYPE_QUEUE : TYPE_TOPIC, destName, null, null, null, null);
}
@@ -292,15 +292,30 @@
{
id = l.longValue();
}
-
+
+ // Put in id map too
+
+ JBossDestination jbd ;
+
+ if (isQueue)
+ {
+ jbd = new JBossQueue(destName);
+ }
+ else
+ {
+ jbd = new JBossTopic(destName);
+ }
+
+ idMap.put(new Long(id), jbd);
+
// TODO I am using LocalQueues for the time being, switch to distributed Queues
if (isQueue)
{
// We allocate an executor for the queue from the rotating pool
QueuedExecutor executor = (QueuedExecutor)queuedExecutorPool.get(destName);
-
+
cd = new Queue(id, ms, pm, mm, true, fullSize, pageSize, downCacheSize, executor);
-
+
try
{
// we load the queue with any state it might have in the db
@@ -314,22 +329,22 @@
e2.initCause(e);
throw e2;
}
-
+
queues.put(destName, cd);
}
else
{
// TODO I am using LocalTopics for the time being, switch to distributed Topics
cd = new Topic(id, fullSize, pageSize, downCacheSize);
-
+
topics.put(destName, cd);
-
+
// TODO: The following piece of code may be better placed either in the Topic itself or in
// the DurableSubscriptionStore - I'm not sure it really belongs here
-
+
// Load any durable subscriptions for the Topic
List durableSubs = loadDurableSubscriptionsForTopic(destName, ms, pm, mm);
-
+
Iterator iter = durableSubs.iterator();
while (iter.hasNext())
{
@@ -351,138 +366,123 @@
sub.connect();
}
}
-
- // Put in id map too
-
- JBossDestination jbd ;
-
- if (isQueue)
- {
- jbd = new JBossQueue(destName);
- }
- else
- {
- jbd = new JBossTopic(destName);
- }
-
- idMap.put(new Long(id), jbd);
log.debug("core destination " + cd + " (fullSize=" + fullSize + ", pageSize=" +
pageSize + ", downCacheSize=" + downCacheSize + ") deployed");
}
-
+
public CoreDestination undeployCoreDestination(boolean isQueue, String destName)
throws Exception
{
Map m = isQueue ? queues : topics;
-
+
CoreDestination dest = (CoreDestination)m.remove(destName);
-
+
if (dest != null)
- {
+ {
idMap.remove(new Long(dest.getId()));
-
+
//If topic need to remove durable subs from map too
-
+
if (!isQueue)
{
Topic topic = (Topic)dest;
-
+
Iterator iter = topic.iterator();
-
+
while (iter.hasNext())
{
CoreSubscription sub = (CoreSubscription)iter.next();
-
+
if (sub.isRecoverable())
{
DurableSubscription dursub = (DurableSubscription)sub;
-
+
String clientID = dursub.getClientID();
-
+
String name = dursub.getName();
-
+
removeDurableSubscriptionInMemory(clientID, name);
}
}
}
-
+
}
-
+
return dest;
}
-
-
- public void deployTemporaryCoreDestination(boolean isQueue,
- String destName,
- long id,
- MessageStore ms,
- PersistenceManager pm,
- MemoryManager mm,
- int fullSize,
- int pageSize,
- int downCacheSize) throws Exception
- {
+
+
+ public void deployTemporaryCoreDestination(boolean isQueue,
+ String destName,
+ long id,
+ MessageStore ms,
+ PersistenceManager pm,
+ MemoryManager mm,
+ int fullSize,
+ int pageSize,
+ int downCacheSize) throws Exception
+ {
if (log.isTraceEnabled()) { log.trace("creating temporary core destination for " + destName); }
-
+
+ //Put in id map too
+
+ JBossDestination jbd ;
+
+ if (isQueue)
+ {
+ jbd = new JBossQueue(destName);
+ }
+ else
+ {
+ jbd = new JBossTopic(destName);
+ }
+
+ idMap.put(new Long(id), jbd);
+
CoreDestination cd = getCoreDestinationInternal(isQueue, destName);
if (cd != null)
{
throw new JMSException("Destination " + destName + " already deployed");
- }
-
+ }
+
if (isQueue)
{
//We allocate an executor for the queue from the rotating pool
QueuedExecutor executor = (QueuedExecutor)queuedExecutorPool.get(destName);
-
- cd = new Queue(id, ms, pm, mm, false, fullSize, pageSize, downCacheSize, executor);
-
+
+ cd = new Queue(id, ms, pm, mm, false, fullSize, pageSize, downCacheSize, executor);
+
queues.put(destName, cd);
}
else
{
cd = new Topic(id, fullSize, pageSize, downCacheSize);
-
- topics.put(destName, cd);
+
+ topics.put(destName, cd);
}
-
- //Put in id map too
-
- JBossDestination jbd ;
-
- if (isQueue)
- {
- jbd = new JBossQueue(destName);
- }
- else
- {
- jbd = new JBossTopic(destName);
- }
-
- idMap.put(new Long(id), jbd);
log.debug("core destination " + cd + " (fullSize=" + fullSize + ", pageSize=" +
pageSize + ", downCacheSize=" + downCacheSize + ") deployed");
}
-
+
public CoreDestination undeployTemporaryCoreDestination(boolean isQueue, String destName)
throws Exception
{
Map m = isQueue ? queues : topics;
-
+
CoreDestination dest = (CoreDestination)m.remove(destName);
-
+
if (dest != null)
- {
- idMap.remove(new Long(dest.getId()));
+ {
+ idMap.remove(new Long(dest.getId()));
}
-
+
return dest;
}
-
+
public DurableSubscription getDurableSubscription(String clientID,
- String subscriptionName,
+ String subscriptionName,
MessageStore ms,
PersistenceManager pm,
MemoryManager mm)
@@ -490,29 +490,29 @@
{
// look in memory first
DurableSubscription sub = getDurableSubscription(clientID, subscriptionName);
-
+
if (sub != null)
{
return sub;
}
-
+
// now look in the db
Connection conn = null;
PreparedStatement ps = null;
ResultSet rs = null;
TransactionWrapper wrap = new TransactionWrapper();
-
+
try
{
conn = ds.getConnection();
-
+
ps = conn.prepareStatement(selectDurableSub);
-
+
ps.setString(1, clientID);
ps.setString(2, subscriptionName);
-
+
boolean exists = false;
-
+
try
{
rs = ps.executeQuery();
@@ -526,29 +526,29 @@
log.trace(s + (rs == null ? " failed!" : (exists ? " returned rows" : " did NOT return rows")));
}
}
-
+
if (exists)
{
String topicName = rs.getString(1);
long id = rs.getLong(2);
String selector = rs.getString(3);
boolean noLocal = rs.getString(4).equals("Y");
-
+
Selector sel = selector == null ? null : new Selector(selector);
-
+
Map subs = (Map)subscriptions.get(clientID);
if (subs == null)
{
subs = new ConcurrentReaderHashMap();
subscriptions.put(clientID, subs);
}
-
+
//The subscription might be in the database, but the Topic which owns the subscription
//might not be deployed.
//In this case the user needs to make sure the Topic is deployed
-
+
Topic topic = (Topic)getCoreDestinationInternal(false, topicName);
-
+
if (topic == null)
{
throw new MessagingJMSException("Unable to get subscription: " + subscriptionName
@@ -556,16 +556,16 @@
+ clientID + " which belongs to topic: " + topicName
+ " since this topic is not currently deployed. Please deploy the topic and try again");
}
-
-
+
+
// create in memory
sub = createDurableSubscriptionInternal(id, topicName, clientID, subscriptionName, sel,
noLocal, ms, pm, mm);
-
+
// load its state
sub.load();
}
-
+
return sub;
}
finally
@@ -583,7 +583,7 @@
conn.close();
}
wrap.end();
- }
+ }
}
public DurableSubscription createDurableSubscription(String topicName,
@@ -596,17 +596,17 @@
MemoryManager mm) throws Exception
{
Selector sel = selector == null ? null : new Selector(selector);
-
+
long id;
// first insert a row in the db
id = this.getNextId();
-
+
insertMappingRow(id, TYPE_DURABLE_SUB, topicName, subscriptionName, clientID,
selector, new Boolean(noLocal));
-
+
return createDurableSubscriptionInternal(id, topicName, clientID, subscriptionName, sel,
- noLocal, ms, pm, mm);
+ noLocal, ms, pm, mm);
}
public Subscription createSubscription(String topicName, String selector, boolean noLocal,
@@ -617,9 +617,9 @@
Selector sel = selector == null ? null : new Selector(selector);
long id = this.getNextId();
-
+
Topic topic = (Topic)getCoreDestinationInternal(false, topicName);
-
+
if (topic == null)
{
throw new javax.jms.IllegalStateException("Topic " + topicName + " is not loaded");
@@ -628,24 +628,24 @@
//We allocate an executor for the subscription from the rotating pool
//Currently all subscriptions for the same topic share the same executor
QueuedExecutor executor = (QueuedExecutor)queuedExecutorPool.get(topicName);
-
+
return new Subscription(id, topic, ms, pm, mm,
topic.getFullSize(), topic.getPageSize(),
topic.getDownCacheSize(), executor, sel, noLocal);
}
-
-
-
+
+
+
public boolean removeDurableSubscription(String clientID, String subscriptionName)
throws Exception
{
DurableSubscription removed = removeDurableSubscriptionInMemory(clientID, subscriptionName);
-
+
if (removed != null)
{
//Now remove from db
deleteMappingRow(removed.getChannelID());
-
+
return true;
}
else
@@ -653,7 +653,7 @@
return false;
}
}
-
+
//FIXME - This doesn't belong here
public String getPreConfiguredClientID(String username) throws Exception
{
@@ -663,24 +663,24 @@
PreparedStatement ps = null;
ResultSet rs = null;
TransactionWrapper wrap = new TransactionWrapper();
-
+
try
{
conn = ds.getConnection();
-
+
ps = conn.prepareStatement(selectPreConfClientId);
-
+
ps.setString(1, username);
-
+
rs = ps.executeQuery();
-
+
String clientID = null;
-
+
if (rs.next())
{
clientID = rs.getString(1);
}
-
+
return clientID;
}
catch (SQLException e)
@@ -715,11 +715,11 @@
throw e2;
}
}
-
-
-
+
+
+
// MBean operations ----------------------------------------------
-
+
public String getSqlProperties()
{
try
@@ -733,25 +733,25 @@
return "";
}
}
-
+
public void setSqlProperties(String value)
{
try
{
-
+
ByteArrayInputStream is = new ByteArrayInputStream(value.getBytes());
sqlProperties = new Properties();
sqlProperties.load(is);
-
+
}
catch (IOException shouldnothappen)
{
log.error("Caught IOException", shouldnothappen);
}
}
-
+
// Public --------------------------------------------------------
-
+
/**
* Managed attribute.
*/
@@ -759,7 +759,7 @@
{
this.dataSourceJNDIName = dataSourceJNDIName;
}
-
+
/**
* Managed attribute.
*/
@@ -767,7 +767,7 @@
{
return dataSourceJNDIName;
}
-
+
/**
* Managed attribute.
*/
@@ -775,7 +775,7 @@
{
this.tmObjectName = tmObjectName;
}
-
+
/**
* Managed attribute.
*/
@@ -799,7 +799,7 @@
{
createTablesOnStartup = b;
}
-
+
/**
* @return a Set<String>. It may return an empty Set, but never null.
*/
@@ -815,77 +815,77 @@
result.addAll(m.keySet());
return result;
}
-
+
public String toString()
{
return "JDBCChannelMapper[" + Integer.toHexString(hashCode()) + "]";
}
-
+
// Package protected ---------------------------------------------
-
+
// Protected -----------------------------------------------------
-
+
protected DurableSubscription removeDurableSubscriptionInMemory(String clientID, String subscriptionName)
throws JMSException
{
if (log.isTraceEnabled()) { log.trace("removing durable subscription " + subscriptionName); }
-
+
if (clientID == null)
{
throw new JMSException("Client ID must be set for connection!");
}
-
+
Map subs = (Map)subscriptions.get(clientID);
-
+
if (subs == null)
{
return null;
}
-
+
if (log.isTraceEnabled()) { log.trace("removing durable subscription " + subscriptionName); }
-
+
DurableSubscription removed = (DurableSubscription)subs.remove(subscriptionName);
-
+
if (removed == null)
{
return null;
}
-
+
this.channelIdSubMap.remove(new Long(removed.getChannelID()));
-
+
if (subs.size() == 0)
{
subscriptions.remove(clientID);
}
-
+
return removed;
}
-
- protected List loadDurableSubscriptionsForTopic(String topicName,
+
+ protected List loadDurableSubscriptionsForTopic(String topicName,
MessageStore ms,
PersistenceManager pm,
MemoryManager mm) throws Exception
- {
+ {
List result = new ArrayList();
-
+
Connection conn = null;
PreparedStatement ps = null;
ResultSet rs = null;
TransactionWrapper wrap = new TransactionWrapper();
int rowCount = -1;
-
+
try
{
conn = ds.getConnection();
ps = conn.prepareStatement(selectSubscriptionsForTopic);
-
+
ps.setString(1, topicName);
-
+
rs = ps.executeQuery();
-
+
rowCount = 0;
-
+
while (rs.next())
{
rowCount ++;
@@ -894,21 +894,21 @@
String subName = rs.getString(3);
String selector = rs.getString(4);
boolean noLocal = rs.getString(5).equals("Y");
-
+
Selector sel = selector == null ? null : new Selector(selector);
-
+
DurableSubscription sub = getDurableSubscription(clientId, subName);
-
+
if (sub == null)
{
sub = createDurableSubscriptionInternal(id, topicName,
- clientId,
- subName,
- sel,
- noLocal,
- ms, pm, mm);
+ clientId,
+ subName,
+ sel,
+ noLocal,
+ ms, pm, mm);
result.add(sub);
- }
+ }
}
}
catch (SQLException e)
@@ -922,7 +922,7 @@
{
String s = JDBCUtil.statementToString(selectSubscriptionsForTopic, topicName);
log.trace(s + " returned " + rowCount + " rows");
- }
+ }
if (rs != null)
{
rs.close();
@@ -937,12 +937,12 @@
}
wrap.end();
}
-
+
return result;
}
-
+
protected void insertMappingRow(long id, char type, String jmsDestName, String jmsSubName, String clientID,
String selector, Boolean noLocal) throws Exception
{
@@ -950,27 +950,27 @@
PreparedStatement ps = null;
ResultSet rs = null;
TransactionWrapper wrap = new TransactionWrapper();
-
+
boolean failed = true;
-
+
try
{
conn = ds.getConnection();
-
+
ps = conn.prepareStatement(insertMapping);
-
+
ps.setLong(1, id);
-
- ps.setString(2, String.valueOf(type));
-
+
+ ps.setString(2, String.valueOf(type));
+
ps.setString(3, jmsDestName);
-
+
ps.setString(4, jmsSubName);
-
+
ps.setString(5, clientID);
-
+
ps.setString(6, selector);
-
+
if (noLocal == null)
{
ps.setNull(7, Types.VARCHAR);
@@ -979,14 +979,14 @@
{
ps.setString(7, noLocal.booleanValue() ? "Y" : "N");
}
-
+
int rows = ps.executeUpdate();
-
+
failed = rows != 1;
-
+
ps.close();
-
- ps = null;
+
+ ps = null;
}
finally
{
@@ -994,10 +994,10 @@
{
String s = JDBCUtil.
statementToString(insertMapping, null, String.valueOf(type), jmsDestName, jmsSubName,
- clientID, selector, noLocal);
+ clientID, selector, noLocal);
log.trace(s + (failed ? " failed!" : " executed successfully"));
}
-
+
if (rs != null)
{
try
@@ -1028,26 +1028,26 @@
wrap.end();
}
}
-
+
protected Long getIdForDestination(boolean isQueue, String destName) throws Exception
{
Connection conn = null;
PreparedStatement ps = null;
ResultSet rs = null;
TransactionWrapper wrap = new TransactionWrapper();
-
+
try
{
conn = ds.getConnection();
-
+
ps = conn.prepareStatement(selectIdForDestination);
-
+
ps.setString(1, String.valueOf(isQueue ? TYPE_QUEUE : TYPE_TOPIC));
-
+
ps.setString(2, destName);
-
- rs = ps.executeQuery();
-
+
+ rs = ps.executeQuery();
+
if (rs.next())
{
return new Long(rs.getLong(1));
@@ -1055,7 +1055,7 @@
else
{
return null;
- }
+ }
}
finally
{
@@ -1089,26 +1089,26 @@
wrap.end();
}
}
-
-
+
+
protected boolean deleteMappingRow(long id) throws Exception
{
Connection conn = null;
PreparedStatement ps = null;
TransactionWrapper wrap = new TransactionWrapper();
-
+
boolean failed = true;
-
+
try
{
conn = ds.getConnection();
-
+
ps = conn.prepareStatement(deleteMapping);
-
+
ps.setLong(1, id);
-
- failed = ps.executeUpdate() != -1;
-
+
+ failed = ps.executeUpdate() != -1;
+
return !failed;
}
finally
@@ -1139,7 +1139,7 @@
wrap.end();
}
}
-
+
protected DurableSubscription getDurableSubscription(String clientID,
String subscriptionName) throws JMSException
{
@@ -1164,100 +1164,100 @@
subs = new ConcurrentReaderHashMap();
subscriptions.put(clientID, subs);
}
-
+
Topic topic = (Topic)getCoreDestinationInternal(false, topicName);
-
+
if (topic == null)
{
throw new javax.jms.IllegalStateException("Topic " + topicName + " is not loaded");
}
-
+
// We allocate an executor for the subscription from the rotating pool.
// Currently all subscriptions for the same topic share the same executor.
QueuedExecutor executor = (QueuedExecutor)queuedExecutorPool.get(topicName);
-
+
DurableSubscription subscription =
new DurableSubscription(id, topic, ms, pm, mm,
- topic.getFullSize(), topic.getPageSize(), topic.getDownCacheSize(),
- executor, selector,
- noLocal, subscriptionName, clientID);
-
+ topic.getFullSize(), topic.getPageSize(), topic.getDownCacheSize(),
+ executor, selector,
+ noLocal, subscriptionName, clientID);
+
subs.put(subscriptionName, subscription);
-
+
channelIdSubMap.put(new Long(id), subscription);
-
+
return subscription;
- }
-
+ }
+
protected CoreDestination getCoreDestinationInternal(boolean isQueue, String destName)
{
Map m = isQueue ? queues : topics;
-
+
return (CoreDestination)m.get(destName);
}
-
+
protected void initSqlProperties()
{
createUserTable = sqlProperties.getProperty("CREATE_USER_TABLE", createUserTable);
createRoleTable = sqlProperties.getProperty("CREATE_ROLE_TABLE", createRoleTable);
- selectPreConfClientId = sqlProperties.getProperty("SELECT_PRECONF_CLIENTID", selectPreConfClientId);
+ selectPreConfClientId = sqlProperties.getProperty("SELECT_PRECONF_CLIENTID", selectPreConfClientId);
createMappingTable = sqlProperties.getProperty("CREATE_MAPPING_TABLE", createMappingTable);
insertMapping = sqlProperties.getProperty("INSERT_MAPPING", insertMapping);
deleteMapping = sqlProperties.getProperty("DELETE_MAPPING", deleteMapping);
selectIdForDestination = sqlProperties.getProperty("SELECT_ID_FOR_DESTINATION", selectIdForDestination);
selectDurableSub = sqlProperties.getProperty("SELECT_DURABLE_SUB", selectDurableSub);
selectSubscriptionsForTopic = sqlProperties.getProperty("SELECT_SUBSCRIPTIONS_FOR_TOPIC", selectSubscriptionsForTopic);
-
+
for (Iterator i = sqlProperties.entrySet().iterator(); i.hasNext();)
{
Map.Entry entry = (Map.Entry) i.next();
String key = (String) entry.getKey();
if (key.startsWith("POPULATE.TABLES."))
populateTables.add(entry.getValue());
- }
+ }
}
-
+
protected void createSchema() throws Exception
- {
- Connection conn = null;
+ {
+ Connection conn = null;
TransactionWrapper tx = new TransactionWrapper();
-
+
try
{
conn = ds.getConnection();
-
+
try
{
- if (log.isTraceEnabled()) { log.trace("Creating JMS_USERS table"); }
+ if (log.isTraceEnabled()) { log.trace("Creating JMS_USERS table"); }
conn.createStatement().executeUpdate(createUserTable);
}
- catch (SQLException e)
+ catch (SQLException e)
{
log.debug("Failed to create users table: " + createUserTable, e);
}
-
+
try
{
if (log.isTraceEnabled()) { log.trace("Creating JMS_ROLES table"); }
conn.createStatement().executeUpdate(createRoleTable);
}
- catch (SQLException e)
+ catch (SQLException e)
{
log.debug("Failed to create roles table: " + createRoleTable, e);
}
-
+
try
{
if (log.isTraceEnabled()) { log.trace("Creating JMS_SUBSCRIPTIONS table"); }
conn.createStatement().
executeUpdate(createMappingTable);
}
- catch (SQLException e)
+ catch (SQLException e)
{
log.debug("Failed to create subscriptions table: " + createMappingTable, e);
}
-
-
+
+
//Insert user-role data
Iterator iter = populateTables.iterator();
String nextQry = null;
@@ -1266,8 +1266,8 @@
Statement st = null;
try
{
- nextQry = (String) iter.next();
- st = conn.createStatement();
+ nextQry = (String) iter.next();
+ st = conn.createStatement();
st.executeUpdate(nextQry);
}
catch (SQLException ignored)
@@ -1282,12 +1282,12 @@
{
st.close();
}
- catch (Throwable ignored)
+ catch (Throwable ignored)
{}
}
}
}
-
+
}
finally
{
@@ -1302,14 +1302,14 @@
}
tx.end();
}
-
+
}
-
+
protected long getNextId() throws Exception
{
return channelIDManager.getId();
}
-
+
// Private -------------------------------------------------------
// never access directly
@@ -1331,23 +1331,23 @@
}
// Inner classes -------------------------------------------------
-
+
/*
- * TODO This inner class is duplicated from HSQLPersistenceManager - need to avoid code duplication
- */
+ * TODO This inner class is duplicated from HSQLPersistenceManager - need to avoid code duplication
+ */
class TransactionWrapper
{
private javax.transaction.Transaction oldTx;
-
+
private TransactionWrapper() throws Exception
{
TransactionManager tm = getTransactionManagerReference();
oldTx = tm.suspend();
-
+
tm.begin();
}
-
+
private void end() throws Exception
{
TransactionManager tm = getTransactionManagerReference();
@@ -1371,11 +1371,11 @@
}
}
}
-
+
private void exceptionOccurred() throws Exception
{
getTransactionManagerReference().setRollbackOnly();
}
}
-
+
}
Modified: branches/Branch_1_0/src/main/org/jboss/jms/server/remoting/ServerSocketWrapper.java
===================================================================
--- branches/Branch_1_0/src/main/org/jboss/jms/server/remoting/ServerSocketWrapper.java 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/src/main/org/jboss/jms/server/remoting/ServerSocketWrapper.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -34,6 +34,7 @@
import org.jboss.jms.client.remoting.ClientSocketWrapper;
import org.jboss.logging.Logger;
import org.jboss.remoting.serialization.SerializationStreamFactory;
+import org.jboss.remoting.serialization.SerializationManager;
/**
* @author <a href="mailto:tom.elrod at jboss.com">Tom Elrod</a>
@@ -42,29 +43,33 @@
*/
public class ServerSocketWrapper extends ClientSocketWrapper
{
- // Constants -----------------------------------------------------
+ // Constants ------------------------------------------------------------------------------------
final static private Logger log = Logger.getLogger(ServerSocketWrapper.class);
- // Static --------------------------------------------------------
+ // Static ---------------------------------------------------------------------------------------
- // Attributes ----------------------------------------------------
+ // Attributes -----------------------------------------------------------------------------------
- private boolean trace = log.isTraceEnabled();
+ private static boolean trace = log.isTraceEnabled();
- // Constructors --------------------------------------------------
+ // Constructors ---------------------------------------------------------------------------------
public ServerSocketWrapper(Socket socket) throws Exception
{
super(socket);
+
+ log.debug(this + " constructed");
}
public ServerSocketWrapper(Socket socket, Map metadata, Integer timeout) throws Exception
{
super(socket, metadata, timeout);
+
+ log.debug(this + " constructed using a timeout of " + timeout + " ms");
}
- // Public --------------------------------------------------------
+ // Public ---------------------------------------------------------------------------------------
public void checkConnection() throws IOException
{
@@ -98,32 +103,53 @@
out.reset();
}
+ public String toString()
+ {
+ return "ServerSocketWrapper[" + getSocket() + "]";
+ }
- // Package protected ---------------------------------------------
+ // Package protected ----------------------------------------------------------------------------
- // Protected -----------------------------------------------------
+ // Protected ------------------------------------------------------------------------------------
protected ObjectInputStream createInputStream(String serializationType, Socket socket)
throws IOException
{
+ if (trace) { log.trace(this + " creating input stream"); }
+
BufferedInputStream bin = new BufferedInputStream(socket.getInputStream());
- return SerializationStreamFactory.getManagerInstance(serializationType).
- createInput(bin, null);
+ SerializationManager sm = SerializationStreamFactory.getManagerInstance(serializationType);
+
+ if (trace) { log.trace(this + " creating input stream using " + sm); }
+
+ ObjectInputStream ois = sm.createInput(bin, null);
+
+ if (trace) { log.trace(this + " created and returned " + ois); }
+
+ return ois;
}
protected ObjectOutputStream createOutputStream(String serializationType, Socket socket)
throws IOException
{
+ if (trace) { log.trace(this + " creating output stream"); }
+
BufferedOutputStream bout = new BufferedOutputStream(socket.getOutputStream());
- ObjectOutputStream oout = SerializationStreamFactory.getManagerInstance(serializationType).
- createOutput(bout);
+ SerializationManager sm = SerializationStreamFactory.getManagerInstance(serializationType);
- oout.flush();
- return oout;
+ if (trace) { log.trace(this + " creating output stream using " + sm); }
+
+ ObjectOutputStream oos = sm.createOutput(bout);
+
+ oos.flush();
+
+ if (trace) { log.trace(this + " created and returned " + oos); }
+
+ return oos;
}
- // Private -------------------------------------------------------
+ // Private --------------------------------------------------------------------------------------
- // Inner classes -------------------------------------------------
+ // Inner classes --------------------------------------------------------------------------------
}
Modified: branches/Branch_1_0/src/main/org/jboss/jms/server/security/SecurityMetadataStore.java
===================================================================
--- branches/Branch_1_0/src/main/org/jboss/jms/server/security/SecurityMetadataStore.java 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/src/main/org/jboss/jms/server/security/SecurityMetadataStore.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -162,6 +162,8 @@
if (authenticationManager.isValid(principal, passwordChars, subject))
{
+ // Warning! This "taints" thread local. Make sure you pop it off the stack as soon as
+ // you're done with it.
SecurityActions.pushSubjectContext(principal, passwordChars, subject);
return subject;
}
Modified: branches/Branch_1_0/src/main/org/jboss/jms/tx/MessagingXAResource.java
===================================================================
--- branches/Branch_1_0/src/main/org/jboss/jms/tx/MessagingXAResource.java 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/src/main/org/jboss/jms/tx/MessagingXAResource.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -27,6 +27,7 @@
import org.jboss.jms.client.state.SessionState;
import org.jboss.jms.delegate.ConnectionDelegate;
+import org.jboss.jms.util.MessagingXAException;
import org.jboss.logging.Logger;
import org.jboss.messaging.core.tx.XidImpl;
@@ -121,11 +122,6 @@
xid = new XidImpl(xid.getBranchQualifier(), xid.getFormatId(), xid.getGlobalTransactionId());
rm.commit(xid, onePhase, connection);
-
- // leave the session in a 'clean' state, the currentTxId will be set when the XAResource will
- // be enrolled with a new transaction.
-
- setCurrentTransactionId(null);
}
public void end(Xid xid, int flags) throws XAException
@@ -137,23 +133,24 @@
if (!(xid instanceof XidImpl))
xid = new XidImpl(xid.getBranchQualifier(), xid.getFormatId(), xid.getGlobalTransactionId());
+ unsetCurrentTransactionId(xid);
+
synchronized (this)
- {
+ {
switch (flags)
{
- case TMSUSPEND :
- unsetCurrentTransactionId(xid);
+ case TMSUSPEND :
rm.suspendTx(xid);
break;
case TMFAIL :
- unsetCurrentTransactionId(xid);
rm.endTx(xid, false);
break;
case TMSUCCESS :
- unsetCurrentTransactionId(xid);
rm.endTx(xid, true);
break;
- }
+ default :
+ throw new MessagingXAException(XAException.XAER_PROTO, "Invalid flags: " + flags);
+ }
}
}
@@ -212,17 +209,23 @@
boolean convertTx = false;
- if (sessionState.getCurrentTxId() != null)
+ Object currentXid = sessionState.getCurrentTxId();
+
+ // Sanity check
+ if (currentXid == null)
{
- if (flags == TMNOFLAGS && sessionState.getCurrentTxId() instanceof LocalTx)
- {
- convertTx = true;
- }
+ throw new MessagingXAException(XAException.XAER_RMFAIL, "Current xid is not set");
}
+
+ if (flags == TMNOFLAGS && sessionState.getCurrentTxId() instanceof LocalTx)
+ {
+ convertTx = true;
+
+ if (trace) { log.trace("Converting local tx into global tx branch"); }
+ }
synchronized (this)
{
-
switch (flags)
{
case TMNOFLAGS :
@@ -233,6 +236,8 @@
// session in a new tx. If the session has any listeners then in that period,
// messages can be received asychronously but we want them to be received in the
// context of a tx, so we convert.
+ // Also for an transacted delivery in a MDB we need to do this as discussed
+ // in fallbackToLocalTx()
setCurrentTransactionId(rm.convertTx((LocalTx)sessionState.getCurrentTxId(), xid));
}
else
@@ -246,6 +251,8 @@
case TMRESUME :
setCurrentTransactionId(rm.resumeTx(xid));
break;
+ default:
+ throw new MessagingXAException(XAException.XAER_PROTO, "Invalid flags: " + flags);
}
}
}
@@ -274,14 +281,14 @@
// Private -------------------------------------------------------
- private void setCurrentTransactionId(final Xid xid)
+ private void setCurrentTransactionId(Object xid)
{
if (trace) { log.trace(this + " setting current xid to " + xid + ", previous " + sessionState.getCurrentTxId()); }
sessionState.setCurrentTxId(xid);
}
- private void unsetCurrentTransactionId(final Xid xid)
+ private void unsetCurrentTransactionId(Object xid)
{
if (xid == null)
{
@@ -294,6 +301,15 @@
// recycled
if (xid.equals(sessionState.getCurrentTxId()))
{
+ // When a transaction association ends we fall back to acting as if in a local tx
+ // This is because for MDBs, the message is received before the global tx
+ // has started. Therefore we receive it in a local tx, then convert the work
+ // done into the global tx branch when the resource is enlisted.
+ // See Mark Little's book "Java Transaction Processing" Chapter 5 for
+ // a full explanation
+ // So in other words - when the session is not enlisted in a global tx
+ // it will always have a local xid set
+
sessionState.setCurrentTxId(rm.createLocalTx());
}
}
Modified: branches/Branch_1_0/src/main/org/jboss/messaging/core/ChannelSupport.java
===================================================================
--- branches/Branch_1_0/src/main/org/jboss/messaging/core/ChannelSupport.java 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/src/main/org/jboss/messaging/core/ChannelSupport.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -1298,8 +1298,7 @@
+ messages.size());
}
- // Create references for these messages and add them to the reference
- // map
+ // Create references for these messages and add them to the reference map
iter = messages.iterator();
while (iter.hasNext())
Modified: branches/Branch_1_0/src/main/org/jboss/messaging/core/plugin/JDBCPersistenceManager.java
===================================================================
--- branches/Branch_1_0/src/main/org/jboss/messaging/core/plugin/JDBCPersistenceManager.java 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/src/main/org/jboss/messaging/core/plugin/JDBCPersistenceManager.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -615,27 +615,24 @@
{
return getMessageChannelPair(selectMessageIdForRef, transactionId);
}
-
+
public List getMessageChannelPairAcksForTx(long transactionId) throws Exception
{
return getMessageChannelPair(selectMessageIdForAck, transactionId);
}
-
+
public ChannelMapper getChannels()
{
return cm;
}
-
-
- /*
- * Retrieve a List of messages corresponding to the specified List of message ids.
- * The implementation here for HSQLDB does this by using a PreparedStatment with an IN clause
- * with a maximum of 100 elements.
- * If there are more than maxParams message to retrieve this is repeated a number of times.
- * For "Enterprise" databases (Oracle, DB2, Sybase etc) a more sophisticated technique should be used
- * e.g. Oracle ARRAY types in Oracle which can be submitted as a param to an Oracle prepared statement
- * Although this would all be DB specific.
+ /**
+ * Retrieve a List of messages corresponding to the specified List of message ids. The
+ * implementation here for HSQLDB does this by using a PreparedStatment with an IN clause with a
+ * maximum of 100 elements. If there are more than maxParams message to retrieve this is repeated
+ * a number of times. For "Enterprise" databases (Oracle, DB2, Sybase etc) a more sophisticated
+ * technique should be used e.g. Oracle ARRAY types in Oracle which can be submitted as a param
+ * to an Oracle prepared statement. Although this would all be DB specific.
*/
public List getMessages(List messageIds) throws Exception
{
@@ -643,30 +640,30 @@
{
log.trace("Getting batch of messages for " + messageIds);
}
-
+
Connection conn = null;
PreparedStatement ps = null;
ResultSet rs = null;
TransactionWrapper wrap = new TransactionWrapper();
-
+
try
{
conn = ds.getConnection();
-
+
Iterator iter = messageIds.iterator();
-
+
int size = messageIds.size();
-
+
int count = 0;
-
+
List msgs = new ArrayList();
-
+
while (iter.hasNext())
{
if (ps == null)
{
- //PreparedStatements are cached in the JCA layer so we will never actually have more than
- //100 distinct ones
+ // PreparedStatements are cached in the JCA layer so we will never actually have more
+ // than 100 distinct ones
int numParams;
if (count < (size / maxParams) * maxParams)
{
@@ -688,23 +685,23 @@
}
buff.append(")");
ps = conn.prepareStatement(buff.toString());
-
+
if (trace)
{
log.trace(buff.toString());
}
}
-
+
long msgId = ((Long)iter.next()).longValue();
-
+
ps.setLong((count % maxParams) + 1, msgId);
-
+
count++;
-
+
if (!iter.hasNext() || count % maxParams == 0)
{
rs = ps.executeQuery();
-
+
while (rs.next())
{
long messageId = rs.getLong(1);
@@ -716,16 +713,16 @@
HashMap coreHeaders = bytesToMap(bytes);
byte[] payload = getBytes(rs, 7);
int persistentChannelCount = rs.getInt(8);
-
+
//FIXME - We are mixing concerns here
- //The basic JDBCPersistencManager should *only* know about core messages - not
+ //The basic JDBCPersistencManager should *only* know about core messages - not
//JBossMessages - we should subclass JBDCPersistenceManager and the JBossMessage
//specific code in a subclass
-
+
byte type = rs.getByte(9);
-
+
Message m;
-
+
if (type != CoreMessage.TYPE)
{
//JBossMessage
@@ -734,12 +731,12 @@
byte[] correlationIDBytes = rs.getBytes(12);
long destinationId = rs.getLong(13);
long replyToId = rs.getLong(14);
- boolean replyToExists = rs.wasNull();
+ boolean replyToExists = !rs.wasNull();
bytes = getBytes(rs, 15);
HashMap jmsProperties = bytesToMap(bytes);
JBossDestination dest = cm.getJBossDestination(destinationId);
JBossDestination replyTo = replyToExists ? cm.getJBossDestination(replyToId) : null;
-
+
m = MessageFactory.createJBossMessage(messageId, reliable, expiration, timestamp, priority,
coreHeaders, payload, persistentChannelCount,
type, jmsType, correlationID, correlationIDBytes, dest, replyTo,
@@ -751,18 +748,18 @@
m = MessageFactory.createCoreMessage(messageId, reliable, expiration, timestamp, priority,
coreHeaders, payload, persistentChannelCount);
}
-
+
msgs.add(m);
}
-
+
rs.close();
rs = null;
-
+
ps.close();
ps = null;
}
}
-
+
if (trace)
{
log.trace("Loaded " + msgs.size() + " messages in total");
@@ -809,57 +806,57 @@
}
wrap.end();
}
- }
-
-
-
+ }
+
+
+
public void addReferences(long channelID, List references, boolean loaded) throws Exception
- {
+ {
Connection conn = null;
- PreparedStatement psInsertReference = null;
+ PreparedStatement psInsertReference = null;
PreparedStatement psInsertMessage = null;
PreparedStatement psUpdateMessage = null;
TransactionWrapper wrap = new TransactionWrapper();
-
+
//First we order the references in message order
orderReferences(references);
-
+
List addsToReverse = new ArrayList();
-
+
try
{
//Now we get a lock on all the messages. Since we have ordered the refs we should avoid deadlock
getLocks(references);
-
+
conn = ds.getConnection();
-
+
Iterator iter = references.iterator();
-
+
boolean messageInsertsInBatch = false;
boolean messageUpdatesInBatch = false;
-
+
if (usingBatchUpdates)
{
psInsertReference = conn.prepareStatement(insertMessageRef);
psInsertMessage = conn.prepareStatement(insertMessage);
psUpdateMessage = conn.prepareStatement(updateMessageChannelCount);
}
-
+
while (iter.hasNext())
{
- //We may need to persist the message itself
+ //We may need to persist the message itself
MessageReference ref = (MessageReference) iter.next();
-
+
//For non reliable refs we insert the ref (and maybe the message) itself
-
+
if (!usingBatchUpdates)
{
psInsertReference = conn.prepareStatement(insertMessageRef);
}
-
+
//Now store the reference
addReference(channelID, ref, psInsertReference, loaded);
-
+
if (usingBatchUpdates)
{
psInsertReference.addBatch();
@@ -867,45 +864,45 @@
else
{
int rows = updateWithRetry(psInsertReference);
-
+
if (trace)
{
log.trace("Inserted " + rows + " rows");
}
-
+
psInsertReference.close();
psInsertReference = null;
}
-
+
if (!usingBatchUpdates)
{
psInsertMessage = conn.prepareStatement(insertMessage);
psUpdateMessage = conn.prepareStatement(updateMessageChannelCount);
}
-
+
//Maybe we need to persist the message itself
Message m = ref.getMessage();
-
+
m.incPersistentChannelCount();
-
+
addsToReverse.add(ref);
-
+
boolean added;
if (m.getPersistentChannelCount() == 1)
{
//Hasn't been persisted before so need to persist the message
storeMessage(m, psInsertMessage);
-
+
added = true;
}
else
{
//Update the message with the new channel count
updateMessageChannelCount(m, psUpdateMessage);
-
+
added = false;
}
-
+
if (usingBatchUpdates)
{
if (added)
@@ -924,7 +921,7 @@
if (added)
{
int rows = updateWithRetry(psInsertMessage);
-
+
if (trace)
{
log.trace("Inserted " + rows + " rows");
@@ -933,7 +930,7 @@
else
{
int rows = updateWithRetry(psUpdateMessage);
-
+
if (trace)
{
log.trace("Updated " + rows + " rows");
@@ -943,22 +940,22 @@
psInsertMessage = null;
psUpdateMessage.close();
psUpdateMessage = null;
- }
- }
-
+ }
+ }
+
if (usingBatchUpdates)
{
int[] rowsReference = updateWithRetryBatch(psInsertReference);
-
+
if (trace)
{
logBatchUpdate(insertMessageRef, rowsReference, "inserted");
}
-
+
if (messageInsertsInBatch)
{
int[] rowsMessage = updateWithRetryBatch(psInsertMessage);
-
+
if (trace)
{
logBatchUpdate(insertMessage, rowsMessage, "inserted");
@@ -967,20 +964,20 @@
if (messageUpdatesInBatch)
{
int[] rowsMessage = updateWithRetryBatch(psUpdateMessage);
-
+
if (trace)
{
logBatchUpdate(updateMessageChannelCount, rowsMessage, "updated");
}
}
-
+
psInsertReference.close();
psInsertReference = null;
psInsertMessage.close();
psInsertMessage = null;
psUpdateMessage.close();
psUpdateMessage = null;
- }
+ }
}
catch (Exception e)
{
@@ -1032,67 +1029,67 @@
}
try
{
- wrap.end();
+ wrap.end();
}
finally
- {
+ {
if (wrap.failed)
{
//Reverse the incs
this.decPersistentCounts(addsToReverse);
}
-
+
//And then release locks
this.releaseLocks(references);
- }
- }
+ }
+ }
}
-
+
public void removeReferences(long channelID, List references) throws Exception
{
if (trace) { log.trace(this + " Removing " + references.size() + " refs from channel " + channelID); }
-
+
Connection conn = null;
- PreparedStatement psDeleteReference = null;
+ PreparedStatement psDeleteReference = null;
PreparedStatement psDeleteMessage = null;
PreparedStatement psUpdateMessage = null;
TransactionWrapper wrap = new TransactionWrapper();
-
+
//We order the references
orderReferences(references);
-
+
List removesToReverse = new ArrayList();
-
+
try
{
//We get locks on all the messages - since they are ordered we avoid deadlock
getLocks(references);
-
+
conn = ds.getConnection();
-
+
Iterator iter = references.iterator();
-
+
boolean messageDeletionsInBatch = false;
boolean messageUpdatesInBatch = false;
-
+
if (usingBatchUpdates)
{
psDeleteReference = conn.prepareStatement(deleteMessageRef);
psDeleteMessage = conn.prepareStatement(deleteMessage);
psUpdateMessage = conn.prepareStatement(updateMessageChannelCount);
}
-
+
while (iter.hasNext())
{
MessageReference ref = (MessageReference) iter.next();
-
+
if (!usingBatchUpdates)
{
psDeleteReference = conn.prepareStatement(deleteMessageRef);
}
-
+
removeReference(channelID, ref, psDeleteReference);
-
+
if (usingBatchUpdates)
{
psDeleteReference.addBatch();
@@ -1100,46 +1097,46 @@
else
{
int rows = updateWithRetry(psDeleteReference);
-
+
if (trace)
{
log.trace("Deleted " + rows + " rows");
}
-
+
psDeleteReference.close();
psDeleteReference = null;
}
-
+
if (!usingBatchUpdates)
{
psDeleteMessage = conn.prepareStatement(deleteMessage);
psUpdateMessage = conn.prepareStatement(updateMessageChannelCount);
}
-
+
Message m = ref.getMessage();
-
+
//Maybe we need to delete the message itself
-
+
m.decPersistentChannelCount();
-
+
removesToReverse.add(ref);
-
+
boolean removed;
if (m.getPersistentChannelCount() == 0)
{
//No more refs so remove the message
removeMessage(m, psDeleteMessage);
-
+
removed = true;
}
else
{
//Update the message with the new channel count
updateMessageChannelCount(m, psUpdateMessage);
-
+
removed = false;
}
-
+
if (usingBatchUpdates)
{
if (removed)
@@ -1158,7 +1155,7 @@
if (removed)
{
int rows = updateWithRetry(psDeleteMessage);
-
+
if (trace)
{
log.trace("Deleted " + rows + " rows");
@@ -1167,7 +1164,7 @@
else
{
int rows = updateWithRetry(psUpdateMessage);
-
+
if (trace)
{
log.trace("Updated " + rows + " rows");
@@ -1177,22 +1174,22 @@
psDeleteMessage = null;
psUpdateMessage.close();
psUpdateMessage = null;
- }
- }
-
+ }
+ }
+
if (usingBatchUpdates)
{
int[] rowsReference = updateWithRetryBatch(psDeleteReference);
-
+
if (trace)
{
logBatchUpdate(deleteMessageRef, rowsReference, "deleted");
}
-
+
if (messageDeletionsInBatch)
{
int[] rowsMessage = updateWithRetryBatch(psDeleteMessage);
-
+
if (trace)
{
logBatchUpdate(deleteMessage, rowsMessage, "deleted");
@@ -1201,20 +1198,20 @@
if (messageUpdatesInBatch)
{
int[] rowsMessage = updateWithRetryBatch(psUpdateMessage);
-
+
if (trace)
{
logBatchUpdate(updateMessageChannelCount, rowsMessage, "updated");
}
}
-
+
psDeleteReference.close();
psDeleteReference = null;
psDeleteMessage.close();
psDeleteMessage = null;
psUpdateMessage.close();
psUpdateMessage = null;
- }
+ }
}
catch (Exception e)
{
@@ -1268,52 +1265,52 @@
wrap.end();
}
finally
- {
+ {
if (wrap.failed)
{
//Reverse the decs
this.incPersistentCounts(removesToReverse);
}
-
+
//And then release locks
this.releaseLocks(references);
- }
- }
+ }
+ }
}
-
+
public long getMinOrdering(long channelID) throws Exception
- {
+ {
if (trace)
{
log.trace("Getting min ordering for channel " + channelID);
}
-
+
Connection conn = null;
PreparedStatement ps = null;
ResultSet rs = null;
TransactionWrapper wrap = new TransactionWrapper();
-
+
try
{
conn = ds.getConnection();
-
+
//First get the min ordering
ps = conn.prepareStatement(selectMinOrdering);
-
+
ps.setLong(1, channelID);
-
+
rs = ps.executeQuery();
-
+
rs.next();
-
+
long minOrdering = rs.getLong(1);
-
+
if (rs.wasNull())
{
minOrdering = 0;
}
-
- return minOrdering;
+
+ return minOrdering;
}
catch (Exception e)
{
@@ -1354,14 +1351,14 @@
}
wrap.end();
}
-
- }
-
-
+
+ }
+
+
/*
* Load some refs from the channel.
* It is very difficult for the channel to maintain an absolute ordering of message references
- * without holes, since messages can be acknowledged or cancelled in a different order to the
+ * without holes, since messages can be acknowledged or cancelled in a different order to the
* delivery order
* Consequently loading only the first x messages from the channel becomes difficult.
* A naive implementation might select all the refs in ordering order and only take the first x
@@ -1370,67 +1367,67 @@
* When there are many refs in the channel this could provide a performance problem.
* We take the following approach:
* We select references where ordering < min_ordering + x
- * This might not select any references due to holes, in which case we double x and repeat until
+ * This might not select any references due to holes, in which case we double x and repeat until
* we find refs.
* We store the multiplier for next time so it self adjusts
- */
+ */
public List getReferenceInfos(long channelID, long minOrdering, int number) throws Exception
- {
+ {
if (trace)
{
log.trace("loading message reference info for channel " + channelID + " for " + number + " refs");
}
-
+
List refs = new ArrayList();
-
+
if (number == 0)
{
return refs;
}
-
+
//Start with a reasonable multiplier
double multiplier = 1.15;
-
+
Double d = (Double)channelMultipliers.get(new Long(channelID));
-
+
if (d != null)
{
multiplier = d.doubleValue();
}
-
+
final int MAX_TRIES = 20;
-
+
final double SCALING = 2;
-
+
double size = multiplier * number;
-
+
Connection conn = null;
PreparedStatement ps = null;
ResultSet rs = null;
TransactionWrapper wrap = new TransactionWrapper();
-
+
try
{
conn = ds.getConnection();
-
+
int tries = 0;
long lastOrdering = 0;
-
+
do
- {
-
-
+ {
+
+
ps = conn.prepareStatement(loadReferenceInfo);
-
+
ps.setLong(1, channelID);
-
+
ps.setLong(2, minOrdering);
-
+
ps.setLong(3, minOrdering + (int)size - 1);
-
+
rs = ps.executeQuery();
-
+
int count = 0;
while (rs.next() && count < number)
{
@@ -1438,20 +1435,20 @@
long ordering = rs.getLong(2);
int deliveryCount = rs.getInt(3);
boolean reliable = rs.getString(4).equals("Y");
-
+
ReferenceInfo ri = new ReferenceInfo(msgId, ordering, deliveryCount, reliable);
-
- refs.add(ri);
-
+
+ refs.add(ri);
+
count++;
-
+
lastOrdering = ordering;
}
size *= SCALING;
-
+
tries++;
-
+
if (refs.size() < number)
{
//Query again
@@ -1463,27 +1460,27 @@
if (trace)
{
log.trace("Could not find sufficient refs in one query, trying again");
- }
- }
+ }
+ }
}
while (refs.size() < number && tries < MAX_TRIES);
-
+
if (tries == MAX_TRIES)
{
//HIghly unlikely to happen
throw new IllegalStateException("Could not find sufficient references after trying " + tries + " times");
- }
-
- //We now adjust the multiplier so it 'learns' how many tries it needs which should aid performance
+ }
+
+ //We now adjust the multiplier so it 'learns' how many tries it needs which should aid performance
long actSize = lastOrdering - minOrdering + 1;
-
+
double idealMultiplier = (double)actSize / number;
-
+
//Give 15% leeway
idealMultiplier *= 1.15;
-
+
channelMultipliers.put(new Long(channelID), new Double(idealMultiplier));
-
+
return refs;
}
catch (Exception e)
@@ -1526,42 +1523,42 @@
wrap.end();
}
}
-
+
public void updateReferencesNotLoaded(long channelID, List references) throws Exception
{
Connection conn = null;
- PreparedStatement psUpdateReference = null;
+ PreparedStatement psUpdateReference = null;
TransactionWrapper wrap = new TransactionWrapper();
-
+
if (trace)
{
log.trace("Updating references to not loaded for channel:" + channelID);
}
-
+
try
{
conn = ds.getConnection();
-
+
Iterator iter = references.iterator();
-
+
if (usingBatchUpdates)
{
psUpdateReference = conn.prepareStatement(updateMessageRefNotLoaded);
}
-
+
while (iter.hasNext())
{
MessageReference ref = (MessageReference) iter.next();
-
+
if (!usingBatchUpdates)
{
psUpdateReference = conn.prepareStatement(updateMessageRefNotLoaded);
}
-
+
psUpdateReference.setLong(1, ref.getMessageID());
-
+
psUpdateReference.setLong(2, channelID);
-
+
if (usingBatchUpdates)
{
psUpdateReference.addBatch();
@@ -1569,26 +1566,26 @@
else
{
int rows = updateWithRetry(psUpdateReference);
-
+
if (trace)
{
log.trace("Updated " + rows + " rows");
}
-
+
psUpdateReference.close();
psUpdateReference = null;
}
}
-
+
if (usingBatchUpdates)
{
int[] rowsReference = updateWithRetryBatch(psUpdateReference);
-
+
if (trace)
{
logBatchUpdate(updateMessageRefNotLoaded, rowsReference, "updated");
}
-
+
psUpdateReference.close();
psUpdateReference = null;
}
@@ -1621,11 +1618,11 @@
}
}
wrap.end();
- }
+ }
}
-
+
public void addReference(long channelID, MessageReference ref, Transaction tx) throws Exception
- {
+ {
if (tx != null)
{
// We are in a transaction so we just add the ref in the tx in memory for now
@@ -1635,60 +1632,60 @@
if (trace) { log.trace(this + " added " + ref + " to database transactional callback, in transaction: " + tx); }
}
else
- {
+ {
//No tx so add the ref directly in the db
-
+
TransactionWrapper wrap = new TransactionWrapper();
-
+
PreparedStatement psReference = null;
PreparedStatement psMessage = null;
-
+
Connection conn = ds.getConnection();
-
- Message m = ref.getMessage();
-
+
+ Message m = ref.getMessage();
+
boolean incremented = false;
-
+
try
- {
+ {
// Get lock on message
LockMap.instance.obtainLock(m);
-
+
psReference = conn.prepareStatement(insertMessageRef);
-
+
// Add the reference
addReference(channelID, ref, psReference, true);
-
+
int rows = updateWithRetry(psReference);
-
+
if (trace)
{
log.trace("Inserted " + rows + " rows");
}
-
+
m.incPersistentChannelCount();
incremented = true;
-
+
if (m.getPersistentChannelCount() == 1)
{
// First time so persist the message
psMessage = conn.prepareStatement(insertMessage);
-
- storeMessage(m, psMessage);
+
+ storeMessage(m, psMessage);
}
else
{
//Update the message's channel count
psMessage = conn.prepareStatement(updateMessageChannelCount);
-
+
updateMessageChannelCount(m, psMessage);
}
-
+
rows = updateWithRetry(psMessage);
if (trace)
{
log.trace("Inserted/updated " + rows + " rows");
- }
+ }
}
catch (Exception e)
{
@@ -1732,39 +1729,39 @@
wrap.end();
}
finally
- {
+ {
if (wrap.failed && incremented)
{
- //reverse the inc
- m.decPersistentChannelCount();
+ //reverse the inc
+ m.decPersistentChannelCount();
}
-
+
//Release Lock
LockMap.instance.releaseLock(m);
}
- }
+ }
}
}
-
+
public void updateDeliveryCount(long channelID, MessageReference ref) throws Exception
{
TransactionWrapper wrap = new TransactionWrapper();
-
+
PreparedStatement psReference = null;
-
+
Connection conn = ds.getConnection();
-
+
try
- {
+ {
psReference = conn.prepareStatement(updateDeliveryCount);
-
+
psReference.setInt(1, ref.getDeliveryCount());
-
+
psReference.setLong(2, channelID);
-
+
psReference.setLong(3, ref.getMessageID());
-
- int rows = updateWithRetry(psReference);
+
+ updateWithRetry(psReference);
}
catch (Exception e)
{
Modified: branches/Branch_1_0/tests/bin/stop-rmi-server
===================================================================
--- branches/Branch_1_0/tests/bin/stop-rmi-server 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/tests/bin/stop-rmi-server 2007-02-11 13:16:25 UTC (rev 2264)
@@ -31,6 +31,8 @@
shift
done
+JAVA_OPTS="$JAVA_OPTS -Dmodule.output=$reldir/../output/logs -Dtest.logfile.suffix=stop-rmi-server"
+
if [ "$USE_EXISTENT_TEST_CLASSPATH_FILE" = "true" ]; then
CLASSPATH_FILE="$reldir/.test.execution.classpath"
else
@@ -47,3 +49,4 @@
java $JAVA_OPTS -cp $CLASSPATH -Dtest.bind.address=localhost \
org.jboss.test.messaging.tools.jmx.rmi.StopRMIServer
+
Modified: branches/Branch_1_0/tests/build.xml
===================================================================
--- branches/Branch_1_0/tests/build.xml 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/tests/build.xml 2007-02-11 13:16:25 UTC (rev 2264)
@@ -57,7 +57,7 @@
Functional tests.
-->
- <property name="functional.tests.database" value="hsqldb"/>
+ <property name="functional.tests.database" value="mysql"/>
<property name="functional.tests.serialization" value="jboss"/>
<!--
@@ -291,7 +291,10 @@
<target name="stop-rmi-server" depends="init"
description="Stops the RMI server used by remote tests">
<java classname="org.jboss.test.messaging.tools.jmx.rmi.StopRMIServer"
- classpathref="test.execution.classpath"/>
+ classpathref="test.execution.classpath">
+ <sysproperty key="module.output" value="${tests.output}"/>
+ <sysproperty key="remote.test.suffix" value="stop-rmi-server"/>
+ </java>
</target>
<!-- ======================================================================================== -->
@@ -347,6 +350,7 @@
-->
<include name="**/messaging/core/**/*Test.class"/>
<include name="**/messaging/jms/**/*Test.class"/>
+ <include name="**/thirdparty/jbosssx/*Test.class"/>
<exclude name="**/jms/stress/**"/>
<exclude name="**/jms/crash/*Test.class"/>
<exclude name="**/jms/MemLeakTest.class"/>
@@ -535,6 +539,7 @@
<include name="org/jboss/test/messaging/jms/JMSTest.class"/>
-->
<include name="org/jboss/test/messaging/jms/**/*Test.class"/>
+ <include name="**/thirdparty/**/*Test.class"/>
<exclude name="org/jboss/test/messaging/jms/stress/**"/>
<exclude name="org/jboss/test/messaging/jms/server/**"/>
<exclude name="org/jboss/test/messaging/jms/persistence/**"/>
@@ -545,6 +550,7 @@
<exclude name="org/jboss/test/messaging/jms/MemLeakTest.class"/>
<exclude name="org/jboss/test/messaging/jms/ManifestTest.class"/>
<exclude name="org/jboss/test/messaging/jms/JCAWrapperTest.class"/>
+ <exclude name="org/jboss/test/thirdparty/jbosssx/SecurityAssociationTest.class"/>
</fileset>
</batchtest>
</junit>
Modified: branches/Branch_1_0/tests/etc/log4j.info.xml
===================================================================
--- branches/Branch_1_0/tests/etc/log4j.info.xml 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/tests/etc/log4j.info.xml 2007-02-11 13:16:25 UTC (rev 2264)
@@ -19,7 +19,7 @@
<param name="Append" value="true"/>
<layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern" value="%d %-5r %-5p [%c] @%t %m%n"/>
+ <param name="ConversionPattern" value="%d %-5p @%t [%c{1}] %m%n"/>
</layout>
</appender>
Modified: branches/Branch_1_0/tests/etc/log4j.trace.xml
===================================================================
--- branches/Branch_1_0/tests/etc/log4j.trace.xml 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/tests/etc/log4j.trace.xml 2007-02-11 13:16:25 UTC (rev 2264)
@@ -19,7 +19,7 @@
<param name="Append" value="true"/>
<layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern" value="%d %-5r %-5p [%c] @%t %m%n"/>
+ <param name="ConversionPattern" value="%d %-5p @%t [%c] %m%n"/>
</layout>
</appender>
Modified: branches/Branch_1_0/tests/etc/log4j.xml
===================================================================
--- branches/Branch_1_0/tests/etc/log4j.xml 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/tests/etc/log4j.xml 2007-02-11 13:16:25 UTC (rev 2264)
@@ -19,7 +19,7 @@
<param name="Append" value="true"/>
<layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern" value="%d %-5r %-5p [%c] @%t %m%n"/>
+ <param name="ConversionPattern" value="%d %-5p @%t [%c] %m%n"/>
</layout>
</appender>
@@ -70,6 +70,11 @@
<priority value="DEBUG"/>
</category>
+ <category name="org.jboss.remoting">
+ <!-- <priority value="TRACE" class="org.jboss.logging.XLevel"/> -->
+ <priority value="DEBUG"/>
+ </category>
+
<root>
<appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE"/>
Modified: branches/Branch_1_0/tests/smoke/build.xml
===================================================================
--- branches/Branch_1_0/tests/smoke/build.xml 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/tests/smoke/build.xml 2007-02-11 13:16:25 UTC (rev 2264)
@@ -28,6 +28,7 @@
<property name="run.queue.example" value="true"/>
<property name="run.topic.example" value="true"/>
<property name="run.mdb.example" value="true"/>
+ <property name="run.mdb-failure.example" value="true"/>
<property name="run.stateless.example" value="true"/>
<property name="run.ejb3mdb.example" value="false"/>
<property name="run.secure-socket.example" value="true"/>
@@ -124,6 +125,7 @@
<param name="jboss.home" value="${jboss403SP1.home}"/>
<param name="release.admin.target" value="standalone"/>
<param name="run.mdb.example" value="false"/>
+ <param name="run.mdb-failure.example" value="false"/>
<param name="run.stateless.example" value="false"/>
<param name="run.secure-socket.example" value="false"/>
</antcall>
@@ -144,6 +146,7 @@
<param name="jboss.home" value="${jboss404GA.home}"/>
<param name="release.admin.target" value="standalone"/>
<param name="run.mdb.example" value="false"/>
+ <param name="run.mdb-failure.example" value="false"/>
<param name="run.stateless.example" value="false"/>
<param name="run.secure-socket.example" value="false"/>
</antcall>
@@ -155,15 +158,16 @@
<antcall target="installation-test">
<param name="jboss.home" value="${jboss405GA.home}"/>
</antcall>
- <!--
+
<antcall target="installation-test">
<param name="jboss.home" value="${jboss405GA-installer.home}"/>
</antcall>
- -->
+
<antcall target="installation-test">
<param name="jboss.home" value="${jboss405GA.home}"/>
<param name="release.admin.target" value="standalone"/>
<param name="run.mdb.example" value="false"/>
+ <param name="run.mdb-failure.example" value="false"/>
<param name="run.stateless.example" value="false"/>
<param name="run.secure-socket.example" value="false"/>
</antcall>
@@ -340,6 +344,12 @@
</antcall>
<antcall target="run-example">
+ <param name="example.name" value="mdb-failure"/>
+ <param name="example.queue.name" value="SmokeTestQueue"/>
+ <param name="jboss.home" value="${jboss.home}"/>
+ </antcall>
+
+ <antcall target="run-example">
<param name="example.name" value="stateless"/>
<param name="example.queue.name" value="SmokeTestQueue"/>
<param name="jboss.home" value="${jboss.home}"/>
@@ -390,6 +400,10 @@
<istrue value="${run.mdb.example}"/>
</and>
<and>
+ <equals arg1="${example.name}" arg2="mdb-failure"/>
+ <istrue value="${run.mdb-failure.example}"/>
+ </and>
+ <and>
<equals arg1="${example.name}" arg2="stateless"/>
<istrue value="${run.stateless.example}"/>
</and>
@@ -703,6 +717,8 @@
<arg value="WARN [org.jboss.system.ServiceController] Problem creating service jboss.aop:service=AspectManager"/>
<arg value="ERROR [org.jboss.deployment.scanner.URLDeploymentScanner] Incomplete Deployment listing:"/>
<arg value="ERROR [org.jboss.aop.deployment.AspectDeployer] failed to stop"/>
+ <arg value="ERROR [org.jboss.ejb.plugins.LogInterceptor] TransactionRolledbackLocalException in method: public abstract void javax.jms.MessageListener.onMessage(javax.jms.Message), causedBy:"/>
+ <arg value="ERROR [org.jboss.ejb.plugins.jms.JMSContainerInvoker] Exception in JMSCI message listener"/>
<arg value="restart will delete it"/>
<arg value="web-console.war/"/> <!-- Only on JBoss 5 -->
<arg value="jmx-console.war/"/> <!-- Only on JBoss 5 -->
Modified: branches/Branch_1_0/tests/src/org/jboss/test/messaging/core/paging/PagingStateTestBase.java
===================================================================
--- branches/Branch_1_0/tests/src/org/jboss/test/messaging/core/paging/PagingStateTestBase.java 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/tests/src/org/jboss/test/messaging/core/paging/PagingStateTestBase.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -420,7 +420,6 @@
Thread.sleep(500);
}
-
protected List getReferenceIds(long channelId) throws Exception
{
InitialContext ctx = new InitialContext();
Modified: branches/Branch_1_0/tests/src/org/jboss/test/messaging/core/paging/SingleChannel_NP_2PCTest.java
===================================================================
--- branches/Branch_1_0/tests/src/org/jboss/test/messaging/core/paging/SingleChannel_NP_2PCTest.java 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/tests/src/org/jboss/test/messaging/core/paging/SingleChannel_NP_2PCTest.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -830,7 +830,7 @@
}
//Cancel is asynch, so need to wait a bit
- Thread.sleep(250);
+ Thread.sleep(500);
//This should cause the refs corresponding to the deliveries to go the front of the in memory quuee
//and the oldest refs in memory evicted off the end into the down cache
@@ -866,7 +866,7 @@
}
// Cancel is asynch, so need to wait a bit
- Thread.sleep(250);
+ Thread.sleep(500);
//This should cause the down cache to be flushed
@@ -903,7 +903,7 @@
}
// Cancel is asynch, so need to wait a bit
- Thread.sleep(250);
+ Thread.sleep(500);
//This should cause the down cache to be flushed
Modified: branches/Branch_1_0/tests/src/org/jboss/test/messaging/core/paging/SingleChannel_NP_NTTest.java
===================================================================
--- branches/Branch_1_0/tests/src/org/jboss/test/messaging/core/paging/SingleChannel_NP_NTTest.java 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/tests/src/org/jboss/test/messaging/core/paging/SingleChannel_NP_NTTest.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -51,14 +51,13 @@
super(name);
}
- // Public --------------------------------------------------------
+ // Public ---------------------------------------------------------------------------------------
public void setUp() throws Exception
{
super.setUp();
}
-
-
+
public void tearDown() throws Exception
{
super.tearDown();
@@ -68,12 +67,11 @@
{
ChannelSupport queue = new Queue(1, ms, pm, null, true, 100, 20, 10, new QueuedExecutor());
+ MessageReference[] refs = new MessageReference[241];
Message[] msgs = new Message[241];
+
+ // send 99
- MessageReference[] refs = new MessageReference[241];
-
- //Send 99
-
for (int i = 0; i < 99; i++)
{
msgs[i] = MessageFactory.createCoreMessage(i, false, null);
@@ -82,63 +80,64 @@
refs[i].releaseMemoryReference();
}
- //verify no refs in storage
+ // verify no refs in storage
List refIds = getReferenceIds(queue.getChannelID());
assertTrue(refIds.isEmpty());
- //Verify no msgs in storage
+ // verify no msgs in storage
List msgIds = getMessageIds();
assertTrue(msgIds.isEmpty());
- //Verify 99 msgs in store
+ // verify 99 msgs in store
assertEquals(99, ms.size());
- //Verify 99 refs in queue
+ // verify 99 refs in queue
assertEquals(99, queue.memoryRefCount());
- //Verify 0 refs in downcache
+ // verify 0 refs in downcache
assertEquals(0, queue.downCacheCount());
- //Verify not paging
+ // verify not paging
assertFalse(queue.isPaging());
- //Verify no deliveries
+ // verify no deliveries
assertEquals(0, queue.memoryDeliveryCount());
+
+ // send one more ref
-
- //Send one more ref
-
msgs[99] = MessageFactory.createCoreMessage(99, false, null);
refs[99] = ms.reference(msgs[99]);
+
queue.handle(null, refs[99], null);
+
refs[99].releaseMemoryReference();
- //verify no refs in storage
+ // verify no refs in storage
refIds = getReferenceIds(queue.getChannelID());
assertTrue(refIds.isEmpty());
- //Verify no msgs in storage
+ // verify no msgs in storage
msgIds = getMessageIds();
assertTrue(msgIds.isEmpty());
- //Verify 100 msgs in store
+ // verify 100 msgs in store
assertEquals(100, ms.size());
- //Verify 100 refs in queue
+ // verify 100 refs in queue
assertEquals(100, queue.memoryRefCount());
- //Verify 0 refs in downcache
+ // verify 0 refs in downcache
assertEquals(0, queue.downCacheCount());
- //Verify paging
+ // verify queue is paging
assertTrue(queue.isPaging());
- //Verify no deliveries
+ // verify no deliveries
assertEquals(0, queue.memoryDeliveryCount());
- //Send 9 more
+ // send 9 more
for (int i = 100; i < 109; i++)
{
@@ -148,105 +147,99 @@
refs[i].releaseMemoryReference();
}
- //verify no refs in storage
+ // verify no refs in storage
refIds = getReferenceIds(queue.getChannelID());
assertTrue(refIds.isEmpty());
- //Verify no msgs in storage
+ // verify no msgs in storage
msgIds = getMessageIds();
assertTrue(msgIds.isEmpty());
- //Verify 100 msgs in store
+ // verify 109 msgs in store
assertEquals(109, ms.size());
- //Verify 100 refs in queue
+ // verify 100 refs in queue
assertEquals(100, queue.memoryRefCount());
- //Verify 9 refs in downcache
+ // verify 9 refs in downcache
assertEquals(9, queue.downCacheCount());
- //Verify paging
+ // verify paging
assertTrue(queue.isPaging());
- //Verify no deliveries
+ // verify no deliveries
assertEquals(0, queue.memoryDeliveryCount());
-
+
+ // send one more ref - should clear the down cache
-
-
- //Send one more ref - should clear the down cache
-
msgs[109] = MessageFactory.createCoreMessage(109, false, null);
refs[109] = ms.reference(msgs[109]);
queue.handle(null, refs[109], null);
refs[109].releaseMemoryReference();
- //verify 10 refs in storage
-
+ // verify 10 refs in storage
refIds = getReferenceIds(queue.getChannelID());
assertEquals(10, refIds.size());
assertSameIds(refIds, refs, 100, 109);
- //Verify 10 msgs in storage
+ // verify 10 msgs in storage
msgIds = getMessageIds();
assertEquals(10, msgIds.size());
assertSameIds(msgIds, refs, 100, 109);
- //Verify 100 msgs in store
+ // verify 100 msgs in store
assertEquals(100, ms.size());
- //Verify 100 refs in queue
+ // verify 100 refs in queue
assertEquals(100, queue.memoryRefCount());
- //Verify 0 refs in downcache
+ // verify 0 refs in downcache
assertEquals(0, queue.downCacheCount());
- //Verify paging
+ // verify paging
assertTrue(queue.isPaging());
- //Verify no deliveries
+ // verify no deliveries
assertEquals(0, queue.memoryDeliveryCount());
-
+
+ // send one more ref
-
- //Send one more ref
-
msgs[110] = MessageFactory.createCoreMessage(110, false, null);
refs[110] = ms.reference(msgs[110]);
+
queue.handle(null, refs[110], null);
+
refs[110].releaseMemoryReference();
- //verify 10 refs in storage
+ // verify 10 refs in storage
refIds = getReferenceIds(queue.getChannelID());
assertEquals(10, refIds.size());
assertSameIds(refIds, refs, 100, 109);
- //Verify 10 msgs in storage
+ // verify 10 msgs in storage
msgIds = getMessageIds();
assertEquals(10, msgIds.size());
assertSameIds(msgIds, refs, 100, 109);
- //Verify 101 msgs in store
+ // verify 101 msgs in store
assertEquals(101, ms.size());
- //Verify 100 refs in queue
+ // verify 100 refs in queue
assertEquals(100, queue.memoryRefCount());
- //Verify 1 refs in downcache
+ // verify 1 refs in downcache
assertEquals(1, queue.downCacheCount());
- //Verify paging
+ // verify paging
assertTrue(queue.isPaging());
- //Verify no deliveries
+ // verify no deliveries
assertEquals(0, queue.memoryDeliveryCount());
-
+
+ // send 9 more refs
-
- //Send 9 more refs
-
for (int i = 111; i < 120; i++)
{
msgs[i] = MessageFactory.createCoreMessage(i, false, null);
@@ -255,37 +248,34 @@
refs[i].releaseMemoryReference();
}
- //verify 20 refs in storage
+ // verify 20 refs in storage
refIds = getReferenceIds(queue.getChannelID());
assertEquals(20, refIds.size());
assertSameIds(refIds, refs, 100, 119);
- //Verify 20 msgs in storage
+ // verify 20 msgs in storage
msgIds = getMessageIds();
assertEquals(20, msgIds.size());
assertSameIds(msgIds, refs, 100, 119);
- //Verify 100 msgs in store
+ // verify 100 msgs in store
assertEquals(100, ms.size());
- //Verify 100 refs in queue
+ // verify 100 refs in queue
assertEquals(100, queue.memoryRefCount());
- //Verify 0 refs in downcache
+ // verify 0 refs in downcache
assertEquals(0, queue.downCacheCount());
- //Verify paging
+ // verify paging
assertTrue(queue.isPaging());
- //Verify no deliveries
+ // verify no deliveries
assertEquals(0, queue.memoryDeliveryCount());
-
+
+ // send 10 more refs
-
-
- //Send 10 more refs
-
for (int i = 120; i < 130; i++)
{
msgs[i] = MessageFactory.createCoreMessage(i, false, null);
@@ -294,37 +284,34 @@
refs[i].releaseMemoryReference();
}
- //verify 30 refs in storage
+ // verify 30 refs in storage
refIds = getReferenceIds(queue.getChannelID());
assertEquals(30, refIds.size());
assertSameIds(refIds, refs, 100, 129);
- //Verify 30 msgs in storage
+ // verify 30 msgs in storage
msgIds = getMessageIds();
assertEquals(30, msgIds.size());
assertSameIds(msgIds, refs, 100, 129);
- //Verify 100 msgs in store
+ // verify 100 msgs in store
assertEquals(100, ms.size());
- //Verify 100 refs in queue
+ // verify 100 refs in queue
assertEquals(100, queue.memoryRefCount());
- //Verify 0 refs in downcache
+ // verify 0 refs in downcache
assertEquals(0, queue.downCacheCount());
- //Verify paging
+ // verify paging
assertTrue(queue.isPaging());
- //Verify no deliveries
+ // verify no deliveries
assertEquals(0, queue.memoryDeliveryCount());
-
+
+ // send 10 more refs
-
-
- //Send 10 more refs
-
for (int i = 130; i < 140; i++)
{
msgs[i] = MessageFactory.createCoreMessage(i, false, null);
@@ -333,37 +320,34 @@
refs[i].releaseMemoryReference();
}
- //verify 40 refs in storage
+ // verify 40 refs in storage
refIds = getReferenceIds(queue.getChannelID());
assertEquals(40, refIds.size());
assertSameIds(refIds, refs, 100, 139);
- //Verify 40 msgs in storage
+ // verify 40 msgs in storage
msgIds = getMessageIds();
assertEquals(40, msgIds.size());
assertSameIds(msgIds, refs, 100, 139);
- //Verify 100 msgs in store
+ // verify 100 msgs in store
assertEquals(100, ms.size());
- //Verify 100 refs in queue
+ // verify 100 refs in queue
assertEquals(100, queue.memoryRefCount());
- //Verify 0 refs in downcache
+ // verify 0 refs in downcache
assertEquals(0, queue.downCacheCount());
- //Verify paging
+ // verify paging
assertTrue(queue.isPaging());
- //Verify no deliveries
+ // verify no deliveries
assertEquals(0, queue.memoryDeliveryCount());
+ // send one more ref
-
-
- //Send one more ref
-
msgs[140] = MessageFactory.createCoreMessage(140, false, null);
refs[140] = ms.reference(msgs[140]);
queue.handle(null, refs[140], null);
@@ -782,7 +766,7 @@
}
// Cancel is asynch, so need to wait a bit
- Thread.sleep(250);
+ Thread.sleep(500);
//This should cause the refs corresponding to the deliveries to go the front of the in memory quuee
//and the oldest refs in memory evicted off the end into the down cache
@@ -818,7 +802,7 @@
}
// Cancel is asynch, so need to wait a bit
- Thread.sleep(250);
+ Thread.sleep(500);
//This should cause the down cache to be flushed
@@ -854,7 +838,7 @@
dels[i].cancel();
}
// Cancel is asynch, so need to wait a bit
- Thread.sleep(250);
+ Thread.sleep(500);
//consumeCount += 20;
Modified: branches/Branch_1_0/tests/src/org/jboss/test/messaging/core/paging/SingleChannel_NP_TTest.java
===================================================================
--- branches/Branch_1_0/tests/src/org/jboss/test/messaging/core/paging/SingleChannel_NP_TTest.java 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/tests/src/org/jboss/test/messaging/core/paging/SingleChannel_NP_TTest.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -820,7 +820,7 @@
}
// Cancel is asynch, so need to wait a bit
- Thread.sleep(250);
+ Thread.sleep(500);
//This should cause the refs corresponding to the deliveries to go the front of the in memory quuee
//and the oldest refs in memory evicted off the end into the down cache
@@ -856,7 +856,7 @@
}
// Cancel is asynch, so need to wait a bit
- Thread.sleep(250);
+ Thread.sleep(500);
//This should cause the down cache to be flushed
@@ -894,7 +894,7 @@
// Cancel is asynch, so need to wait a bit
- Thread.sleep(250);
+ Thread.sleep(500);
//This should cause the down cache to be flushed
Modified: branches/Branch_1_0/tests/src/org/jboss/test/messaging/core/plugin/JDBCPersistenceManagerTest.java
===================================================================
--- branches/Branch_1_0/tests/src/org/jboss/test/messaging/core/plugin/JDBCPersistenceManagerTest.java 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/tests/src/org/jboss/test/messaging/core/plugin/JDBCPersistenceManagerTest.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -54,7 +54,6 @@
import org.jboss.tm.TransactionManagerService;
import org.jboss.util.id.GUID;
-
/**
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
* @author <a href="mailto:juha at jboss.org">Juha Lindfors</a>
@@ -68,12 +67,12 @@
// Attributes ----------------------------------------------------
protected ServiceContainer sc;
-
+
protected JDBCPersistenceManager pm;
-
+
protected MessageStore ms;
-
-
+
+
// Constructors --------------------------------------------------
public JDBCPersistenceManagerTest(String name)
@@ -91,17 +90,17 @@
super.setUp();
sc = new ServiceContainer("all");
- sc.start();
-
+ sc.start();
+
}
-
+
protected void doSetup(boolean batch) throws Throwable
{
- pm = createPM();
- pm.setUsingBatchUpdates(batch);
- ms = new SimpleMessageStore("s0");
+ pm = createPM();
+ pm.setUsingBatchUpdates(batch);
+ ms = new SimpleMessageStore("s0");
}
-
+
protected JDBCPersistenceManager createPM() throws Throwable
{
JDBCPersistenceManager p = new JDBCPersistenceManager(sc.getDataSource(), sc.getTransactionManager());
@@ -119,17 +118,17 @@
pm.stop();
super.tearDown();
}
-
+
public void testGetMinOrdering() throws Throwable
{
doSetup(false);
-
+
Channel channel = new SimpleChannel(0, ms);
-
+
Message[] m = createMessages(10);
-
+
List refs = new ArrayList();
-
+
MessageReference ref1 = ms.reference(m[0]);
ref1.setOrdering(11);
MessageReference ref2 = ms.reference(m[1]);
@@ -150,7 +149,7 @@
ref9.setOrdering(678);
MessageReference ref10 = ms.reference(m[9]);
ref10.setOrdering(890);
-
+
refs.add(ref1);
refs.add(ref2);
refs.add(ref3);
@@ -161,9 +160,9 @@
refs.add(ref8);
refs.add(ref9);
refs.add(ref10);
-
+
pm.addReferences(channel.getChannelID(), refs, false);
-
+
List refIds = getReferenceIds(channel.getChannelID());
assertNotNull(refIds);
assertEquals(10, refIds.size());
@@ -177,7 +176,7 @@
assertTrue(refIds.contains(new Long(ref8.getMessageID())));
assertTrue(refIds.contains(new Long(ref9.getMessageID())));
assertTrue(refIds.contains(new Long(ref10.getMessageID())));
-
+
List msgs = getMessageIds();
assertNotNull(msgs);
assertEquals(10, msgs.size());
@@ -191,15 +190,15 @@
assertTrue(msgs.contains(new Long(ref8.getMessageID())));
assertTrue(msgs.contains(new Long(ref9.getMessageID())));
assertTrue(msgs.contains(new Long(ref10.getMessageID())));
-
+
long minOrdering = pm.getMinOrdering(channel.getChannelID());
-
+
assertEquals(11, minOrdering);
-
+
pm.removeReferences(channel.getChannelID(), refs);
-
+
pm.addReferences(channel.getChannelID(), refs, true);
-
+
refIds = getReferenceIds(channel.getChannelID());
assertNotNull(refIds);
assertEquals(10, refIds.size());
@@ -213,7 +212,7 @@
assertTrue(refIds.contains(new Long(ref8.getMessageID())));
assertTrue(refIds.contains(new Long(ref9.getMessageID())));
assertTrue(refIds.contains(new Long(ref10.getMessageID())));
-
+
msgs = getMessageIds();
assertNotNull(msgs);
assertEquals(10, msgs.size());
@@ -227,19 +226,19 @@
assertTrue(msgs.contains(new Long(ref8.getMessageID())));
assertTrue(msgs.contains(new Long(ref9.getMessageID())));
assertTrue(msgs.contains(new Long(ref10.getMessageID())));
-
+
minOrdering = pm.getMinOrdering(channel.getChannelID());
-
+
assertEquals(0, minOrdering);
-
+
}
-
+
public void testGetNumberOfReferences() throws Throwable
{
doSetup(false);
-
+
Channel channel = new SimpleChannel(0, ms);
-
+
Message m0 = this.createMessage((byte)0, false);
Message m1 = this.createMessage((byte)1, false);
Message m2 = this.createMessage((byte)2, false);
@@ -250,14 +249,14 @@
Message m7 = this.createMessage((byte)7, false);
Message m8 = this.createMessage((byte)8, false);
Message m9 = this.createMessage((byte)9, false);
-
+
Message m10 = this.createMessage((byte)10, true);
Message m11 = this.createMessage((byte)11, true);
Message m12 = this.createMessage((byte)12, true);
Message m13 = this.createMessage((byte)13, true);
Message m14 = this.createMessage((byte)14, true);
-
- MessageReference ref1 = ms.reference(m0);
+
+ MessageReference ref1 = ms.reference(m0);
ref1.setOrdering(0);
MessageReference ref2 = ms.reference(m1);
ref2.setOrdering(1);
@@ -277,7 +276,7 @@
ref9.setOrdering(8);
MessageReference ref10 = ms.reference(m9);
ref10.setOrdering(9);
-
+
MessageReference ref11 = ms.reference(m10);
ref11.setOrdering(10);
MessageReference ref12 = ms.reference(m11);
@@ -288,8 +287,8 @@
ref14.setOrdering(13);
MessageReference ref15 = ms.reference(m14);
ref15.setOrdering(14);
-
-
+
+
pm.addReference(channel.getChannelID(), ref1, null);
pm.addReference(channel.getChannelID(), ref2, null);
pm.addReference(channel.getChannelID(), ref3, null);
@@ -305,7 +304,7 @@
pm.addReference(channel.getChannelID(), ref13, null);
pm.addReference(channel.getChannelID(), ref14, null);
pm.addReference(channel.getChannelID(), ref15, null);
-
+
List refIds = getReferenceIds(channel.getChannelID());
assertNotNull(refIds);
assertEquals(15, refIds.size());
@@ -324,7 +323,7 @@
assertTrue(refIds.contains(new Long(ref13.getMessageID())));
assertTrue(refIds.contains(new Long(ref14.getMessageID())));
assertTrue(refIds.contains(new Long(ref15.getMessageID())));
-
+
List msgs = getMessageIds();
assertNotNull(msgs);
assertEquals(15, msgs.size());
@@ -343,42 +342,42 @@
assertTrue(msgs.contains(new Long(ref13.getMessageID())));
assertTrue(msgs.contains(new Long(ref14.getMessageID())));
assertTrue(msgs.contains(new Long(ref15.getMessageID())));
-
+
int numberOfReferences = pm.getNumberOfUnloadedReferences(channel.getChannelID());
-
+
//getNumberOfReferences only returns refs with loaded = 'N' - these will be 'Y'
assertEquals(0, numberOfReferences);
-
+
List refs = new ArrayList();
-
+
refs.add(ref8);
refs.add(ref9);
refs.add(ref10);
refs.add(ref11);
refs.add(ref12);
refs.add(ref13);
-
+
pm.updateReferencesNotLoaded(channel.getChannelID(), refs);
-
+
numberOfReferences = pm.getNumberOfUnloadedReferences(channel.getChannelID());
-
+
assertEquals(6, numberOfReferences);
-
+
pm.updateReliableReferencesLoadedInRange(channel.getChannelID(), 8, 11);
-
+
numberOfReferences = pm.getNumberOfUnloadedReferences(channel.getChannelID());
-
- assertEquals(4, numberOfReferences);
+
+ assertEquals(4, numberOfReferences);
}
-
+
public void testGetReferenceInfos() throws Throwable
{
doSetup(false);
-
+
Channel channel = new SimpleChannel(0, ms);
-
+
Message[] m = createMessages(10);
-
+
MessageReference ref1 = ms.reference(m[0]);
ref1.setOrdering(0);
MessageReference ref2 = ms.reference(m[1]);
@@ -399,9 +398,9 @@
ref9.setOrdering(1001);
MessageReference ref10 = ms.reference(m[9]);
ref10.setOrdering(1002);
-
+
List refs = new ArrayList();
-
+
refs.add(ref1);
refs.add(ref2);
refs.add(ref3);
@@ -412,13 +411,13 @@
refs.add(ref8);
refs.add(ref9);
refs.add(ref10);
-
+
pm.addReferences(channel.getChannelID(), refs, false);
-
+
List refIds = getReferenceIds(channel.getChannelID());
assertNotNull(refIds);
assertEquals(10, refIds.size());
-
+
assertTrue(refIds.contains(new Long(ref1.getMessageID())));
assertTrue(refIds.contains(new Long(ref2.getMessageID())));
assertTrue(refIds.contains(new Long(ref3.getMessageID())));
@@ -429,7 +428,7 @@
assertTrue(refIds.contains(new Long(ref8.getMessageID())));
assertTrue(refIds.contains(new Long(ref9.getMessageID())));
assertTrue(refIds.contains(new Long(ref10.getMessageID())));
-
+
List msgs = getMessageIds();
assertNotNull(msgs);
assertEquals(10, msgs.size());
@@ -443,19 +442,19 @@
assertTrue(msgs.contains(new Long(ref8.getMessageID())));
assertTrue(msgs.contains(new Long(ref9.getMessageID())));
assertTrue(msgs.contains(new Long(ref10.getMessageID())));
-
+
List refInfos = pm.getReferenceInfos(channel.getChannelID(), 0, 0);
-
+
assertNotNull(refInfos);
assertEquals(0, refInfos.size());
-
+
refInfos = pm.getReferenceInfos(channel.getChannelID(), 0, 3);
assertNotNull(refInfos);
assertEquals(3, refInfos.size());
assertEquals(ref1.getMessageID(), ((PersistenceManager.ReferenceInfo)refInfos.get(0)).getMessageId());
assertEquals(ref2.getMessageID(), ((PersistenceManager.ReferenceInfo)refInfos.get(1)).getMessageId());
assertEquals(ref3.getMessageID(), ((PersistenceManager.ReferenceInfo)refInfos.get(2)).getMessageId());
-
+
refInfos = pm.getReferenceInfos(channel.getChannelID(), 0, 10);
assertNotNull(refInfos);
assertEquals(10, refInfos.size());
@@ -472,7 +471,7 @@
refInfos = pm.getReferenceInfos(channel.getChannelID(), 2, 6);
assertNotNull(refInfos);
- assertEquals(6, refInfos.size());
+ assertEquals(6, refInfos.size());
assertEquals(ref3.getMessageID(), ((PersistenceManager.ReferenceInfo)refInfos.get(0)).getMessageId());
assertEquals(ref4.getMessageID(), ((PersistenceManager.ReferenceInfo)refInfos.get(1)).getMessageId());
assertEquals(ref5.getMessageID(), ((PersistenceManager.ReferenceInfo)refInfos.get(2)).getMessageId());
@@ -490,16 +489,15 @@
//ok - there are not this many refs
}
}
-
-
+
public void testGetMessages() throws Throwable
{
doSetup(false);
-
+
Channel channel = new SimpleChannel(0, ms);
-
+
Message[] m = createMessages(10);
-
+
MessageReference ref1 = ms.reference(m[0]);
MessageReference ref2 = ms.reference(m[1]);
MessageReference ref3 = ms.reference(m[2]);
@@ -510,7 +508,7 @@
MessageReference ref8 = ms.reference(m[7]);
MessageReference ref9 = ms.reference(m[8]);
MessageReference ref10 = ms.reference(m[9]);
-
+
pm.addReference(channel.getChannelID(), ref1, null);
pm.addReference(channel.getChannelID(), ref2, null);
pm.addReference(channel.getChannelID(), ref3, null);
@@ -521,7 +519,7 @@
pm.addReference(channel.getChannelID(), ref8, null);
pm.addReference(channel.getChannelID(), ref9, null);
pm.addReference(channel.getChannelID(), ref10, null);
-
+
List refIds = getReferenceIds(channel.getChannelID());
assertNotNull(refIds);
assertEquals(10, refIds.size());
@@ -535,7 +533,7 @@
assertTrue(refIds.contains(new Long(ref8.getMessageID())));
assertTrue(refIds.contains(new Long(ref9.getMessageID())));
assertTrue(refIds.contains(new Long(ref10.getMessageID())));
-
+
List msgs = getMessageIds();
assertNotNull(msgs);
assertEquals(10, msgs.size());
@@ -549,26 +547,26 @@
assertTrue(msgs.contains(new Long(ref8.getMessageID())));
assertTrue(msgs.contains(new Long(ref9.getMessageID())));
assertTrue(msgs.contains(new Long(ref10.getMessageID())));
-
+
List msgIds = new ArrayList();
msgIds.add(new Long(ref3.getMessageID()));
msgIds.add(new Long(ref4.getMessageID()));
msgIds.add(new Long(ref7.getMessageID()));
msgIds.add(new Long(ref9.getMessageID()));
msgIds.add(new Long(ref1.getMessageID()));
-
+
List ms = pm.getMessages(msgIds);
assertNotNull(ms);
assertEquals(5, ms.size());
-
+
assertTrue(containsMessage(ms, ref3.getMessageID()));
assertTrue(containsMessage(ms, ref4.getMessageID()));
assertTrue(containsMessage(ms, ref7.getMessageID()));
assertTrue(containsMessage(ms, ref9.getMessageID()));
assertTrue(containsMessage(ms, ref1.getMessageID()));
-
+
}
-
+
protected boolean containsMessage(List msgs, long msgId)
{
Iterator iter = msgs.iterator();
@@ -578,21 +576,21 @@
if (m.getMessageID() == msgId)
{
return true;
- }
+ }
}
return false;
}
-
+
public void testGetMessagesMaxParams() throws Throwable
{
doSetup(false);
-
+
pm.setMaxParams(5);
-
+
Channel channel = new SimpleChannel(0, ms);
-
+
Message[] m = createMessages(10);
-
+
MessageReference ref1 = ms.reference(m[0]);
MessageReference ref2 = ms.reference(m[1]);
MessageReference ref3 = ms.reference(m[2]);
@@ -603,7 +601,7 @@
MessageReference ref8 = ms.reference(m[7]);
MessageReference ref9 = ms.reference(m[8]);
MessageReference ref10 = ms.reference(m[9]);
-
+
pm.addReference(channel.getChannelID(), ref1, null);
pm.addReference(channel.getChannelID(), ref2, null);
pm.addReference(channel.getChannelID(), ref3, null);
@@ -614,7 +612,7 @@
pm.addReference(channel.getChannelID(), ref8, null);
pm.addReference(channel.getChannelID(), ref9, null);
pm.addReference(channel.getChannelID(), ref10, null);
-
+
List refIds = getReferenceIds(channel.getChannelID());
assertNotNull(refIds);
assertEquals(10, refIds.size());
@@ -628,7 +626,7 @@
assertTrue(refIds.contains(new Long(ref8.getMessageID())));
assertTrue(refIds.contains(new Long(ref9.getMessageID())));
assertTrue(refIds.contains(new Long(ref10.getMessageID())));
-
+
List msgs = getMessageIds();
assertNotNull(msgs);
assertEquals(10, msgs.size());
@@ -642,14 +640,14 @@
assertTrue(msgs.contains(new Long(ref8.getMessageID())));
assertTrue(msgs.contains(new Long(ref9.getMessageID())));
assertTrue(msgs.contains(new Long(ref10.getMessageID())));
-
+
List msgIds = new ArrayList();
msgIds.add(new Long(ref3.getMessageID()));
msgIds.add(new Long(ref4.getMessageID()));
msgIds.add(new Long(ref7.getMessageID()));
msgIds.add(new Long(ref9.getMessageID()));
msgIds.add(new Long(ref1.getMessageID()));
-
+
List ms = pm.getMessages(msgIds);
assertNotNull(ms);
assertEquals(5, ms.size());
@@ -657,29 +655,29 @@
assertTrue(containsMessage(ms, ref4.getMessageID()));
assertTrue(containsMessage(ms, ref7.getMessageID()));
assertTrue(containsMessage(ms, ref9.getMessageID()));
- assertTrue(containsMessage(ms, ref1.getMessageID()));
+ assertTrue(containsMessage(ms, ref1.getMessageID()));
}
-
+
public void testaddRemoveGetReferences_Batch() throws Throwable
{
addRemoveGetReferences(true);
}
-
+
public void testaddRemoveGetReferences_NoBatch() throws Throwable
{
addRemoveGetReferences(false);
}
-
+
protected void addRemoveGetReferences(boolean batch) throws Throwable
{
doSetup(false);
-
+
Channel channel1 = new SimpleChannel(0, ms);
-
+
Channel channel2 = new SimpleChannel(1, ms);
-
+
Message[] m = createMessages(10);
-
+
MessageReference ref1 = ms.reference(m[0]);
MessageReference ref2 = ms.reference(m[1]);
MessageReference ref3 = ms.reference(m[2]);
@@ -690,13 +688,13 @@
MessageReference ref8 = ms.reference(m[7]);
MessageReference ref9 = ms.reference(m[8]);
MessageReference ref10 = ms.reference(m[9]);
-
+
MessageReference ref11 = ms.reference(m[0]);
MessageReference ref12 = ms.reference(m[1]);
MessageReference ref13 = ms.reference(m[2]);
MessageReference ref14 = ms.reference(m[3]);
MessageReference ref15 = ms.reference(m[4]);
-
+
List refs = new ArrayList();
refs.add(ref1);
refs.add(ref2);
@@ -708,18 +706,18 @@
refs.add(ref8);
refs.add(ref9);
refs.add(ref10);
-
+
pm.addReferences(channel1.getChannelID(), refs, true);
-
+
refs = new ArrayList();
refs.add(ref11);
refs.add(ref12);
refs.add(ref13);
refs.add(ref14);
refs.add(ref15);
-
+
pm.addReferences(channel2.getChannelID(), refs, true);
-
+
List refIds = getReferenceIds(channel1.getChannelID());
assertNotNull(refIds);
assertEquals(10, refIds.size());
@@ -733,7 +731,7 @@
assertTrue(refIds.contains(new Long(ref8.getMessageID())));
assertTrue(refIds.contains(new Long(ref9.getMessageID())));
assertTrue(refIds.contains(new Long(ref10.getMessageID())));
-
+
refIds = getReferenceIds(channel2.getChannelID());
assertNotNull(refIds);
assertEquals(5, refIds.size());
@@ -742,8 +740,8 @@
assertTrue(refIds.contains(new Long(ref13.getMessageID())));
assertTrue(refIds.contains(new Long(ref14.getMessageID())));
assertTrue(refIds.contains(new Long(ref15.getMessageID())));
-
-
+
+
List msgs = getMessageIds();
assertNotNull(msgs);
assertEquals(10, msgs.size());
@@ -757,14 +755,14 @@
assertTrue(msgs.contains(new Long(ref8.getMessageID())));
assertTrue(msgs.contains(new Long(ref9.getMessageID())));
assertTrue(msgs.contains(new Long(ref10.getMessageID())));
-
+
List msgIds = new ArrayList();
msgIds.add(new Long(ref3.getMessageID()));
msgIds.add(new Long(ref4.getMessageID()));
msgIds.add(new Long(ref7.getMessageID()));
msgIds.add(new Long(ref9.getMessageID()));
msgIds.add(new Long(ref1.getMessageID()));
-
+
List ms = pm.getMessages(msgIds);
assertNotNull(ms);
assertEquals(5, ms.size());
@@ -773,24 +771,24 @@
assertTrue(containsMessage(ms, ref7.getMessageID()));
assertTrue(containsMessage(ms, ref9.getMessageID()));
assertTrue(containsMessage(ms, ref1.getMessageID()));
-
+
refs = new ArrayList();
refs.add(ref12);
refs.add(ref13);
refs.add(ref14);
refs.add(ref15);
pm.removeReferences(channel2.getChannelID(), refs);
-
+
refIds = getReferenceIds(channel2.getChannelID());
assertNotNull(refIds);
assertEquals(1, refIds.size());
assertTrue(refIds.contains(new Long(ref11.getMessageID())));
-
+
ms = getMessageIds();
assertNotNull(ms);
assertEquals(10, ms.size());
-
+
assertTrue(msgs.contains(new Long(ref1.getMessageID())));
assertTrue(msgs.contains(new Long(ref2.getMessageID())));
assertTrue(msgs.contains(new Long(ref3.getMessageID())));
@@ -801,14 +799,14 @@
assertTrue(msgs.contains(new Long(ref8.getMessageID())));
assertTrue(msgs.contains(new Long(ref9.getMessageID())));
assertTrue(msgs.contains(new Long(ref10.getMessageID())));
-
-
+
+
refs = new ArrayList();
refs.add(ref1);
refs.add(ref2);
refs.add(ref3);
pm.removeReferences(channel1.getChannelID(), refs);
-
+
refIds = getReferenceIds(channel1.getChannelID());
assertNotNull(refIds);
assertEquals(7, refIds.size());
@@ -819,13 +817,13 @@
assertTrue(refIds.contains(new Long(ref8.getMessageID())));
assertTrue(refIds.contains(new Long(ref9.getMessageID())));
assertTrue(refIds.contains(new Long(ref10.getMessageID())));
-
-
+
+
ms = getMessageIds();
-
+
assertNotNull(ms);
assertEquals(8, ms.size());
-
+
assertTrue(msgs.contains(new Long(ref1.getMessageID())));
assertTrue(msgs.contains(new Long(ref4.getMessageID())));
assertTrue(msgs.contains(new Long(ref5.getMessageID())));
@@ -834,11 +832,11 @@
assertTrue(msgs.contains(new Long(ref8.getMessageID())));
assertTrue(msgs.contains(new Long(ref9.getMessageID())));
assertTrue(msgs.contains(new Long(ref10.getMessageID())));
-
+
refs = new ArrayList();
refs.add(ref11);
pm.removeReferences(channel2.getChannelID(), refs);
-
+
refs = new ArrayList();
refs.add(ref4);
refs.add(ref5);
@@ -848,139 +846,139 @@
refs.add(ref9);
refs.add(ref10);
pm.removeReferences(channel1.getChannelID(), refs);
-
+
ms = getMessageIds();
assertNotNull(ms);
assertEquals(0, ms.size());
}
-
-
-
-
+
+
+
+
public void testAddRemoveReference() throws Throwable
{
doSetup(false);
-
+
Channel channel1 = new SimpleChannel(0, ms);
Channel channel2 = new SimpleChannel(1, ms);
- Message[] messages = createMessages(10);
-
+ Message[] messages = createMessages(10);
+
for (int i = 0; i < 5; i++)
{
Message m1 = messages[i * 2];
Message m2 = messages[i * 2 + 1];
-
+
MessageReference ref1_1 = ms.reference(m1);
MessageReference ref1_2 = ms.reference(m1);
-
+
MessageReference ref2_1 = ms.reference(m2);
MessageReference ref2_2 = ms.reference(m2);
-
+
pm.addReference(channel1.getChannelID(), ref1_1, null);
- pm.addReference(channel1.getChannelID(), ref2_1, null);
-
+ pm.addReference(channel1.getChannelID(), ref2_1, null);
+
pm.addReference(channel2.getChannelID(), ref1_2, null);
pm.addReference(channel2.getChannelID(), ref2_2, null);
-
+
List refs = getReferenceIds(channel1.getChannelID());
-
+
assertNotNull(refs);
assertEquals(2, refs.size());
assertTrue(refs.contains(new Long(m1.getMessageID())));
assertTrue(refs.contains(new Long(m2.getMessageID())));
-
+
refs = getReferenceIds(channel2.getChannelID());
-
+
assertNotNull(refs);
assertEquals(2, refs.size());
assertTrue(refs.contains(new Long(m1.getMessageID())));
assertTrue(refs.contains(new Long(m2.getMessageID())));
-
+
List msgs = getMessageIds();
assertNotNull(msgs);
assertEquals(2, msgs.size());
assertTrue(msgs.contains(new Long(m1.getMessageID())));
assertTrue(msgs.contains(new Long(m2.getMessageID())));
-
+
pm.removeReference(channel1.getChannelID(), ref1_1, null);
-
+
refs = getReferenceIds(channel1.getChannelID());
assertNotNull(refs);
assertEquals(1, refs.size());
assertTrue(refs.contains(new Long(m2.getMessageID())));
-
+
refs = getReferenceIds(channel2.getChannelID());
assertNotNull(refs);
assertEquals(2, refs.size());
assertTrue(refs.contains(new Long(m1.getMessageID())));
assertTrue(refs.contains(new Long(m2.getMessageID())));
-
+
msgs = getMessageIds();
assertNotNull(msgs);
assertEquals(2, msgs.size());
assertTrue(msgs.contains(new Long(m1.getMessageID())));
assertTrue(msgs.contains(new Long(m2.getMessageID())));
-
+
pm.removeReference(channel2.getChannelID(), ref1_2, null);
-
+
refs = getReferenceIds(channel1.getChannelID());
assertNotNull(refs);
assertEquals(1, refs.size());
assertTrue(refs.contains(new Long(m2.getMessageID())));
-
+
refs = getReferenceIds(channel2.getChannelID());
assertNotNull(refs);
- assertEquals(1, refs.size());
+ assertEquals(1, refs.size());
assertTrue(refs.contains(new Long(m2.getMessageID())));
-
+
msgs = getMessageIds();
assertNotNull(msgs);
assertEquals(1, msgs.size());
assertTrue(msgs.contains(new Long(m2.getMessageID())));
-
+
pm.removeReference(channel1.getChannelID(), ref2_1, null);
-
+
refs = getReferenceIds(channel1.getChannelID());
assertNotNull(refs);
assertTrue(refs.isEmpty());
-
+
refs = getReferenceIds(channel2.getChannelID());
assertNotNull(refs);
- assertEquals(1, refs.size());
+ assertEquals(1, refs.size());
assertTrue(refs.contains(new Long(m2.getMessageID())));
-
+
msgs = getMessageIds();
assertNotNull(msgs);
assertEquals(1, msgs.size());
assertTrue(msgs.contains(new Long(m2.getMessageID())));
-
+
pm.removeReference(channel2.getChannelID(), ref2_2, null);
-
+
refs = getReferenceIds(channel1.getChannelID());
assertNotNull(refs);
assertTrue(refs.isEmpty());
-
+
refs = getReferenceIds(channel2.getChannelID());
assertNotNull(refs);
assertTrue(refs.isEmpty());
-
+
msgs = getMessageIds();
assertNotNull(msgs);
assertTrue(msgs.isEmpty());
-
+
}
}
-
-
-
+
+
+
//non batch
-
+
public void testCommit_NotXA_Long_NB() throws Throwable
{
doTransactionCommit(false, false);
}
-
+
public void testCommit_XA_Long_NB() throws Throwable
{
doTransactionCommit(true, false);
@@ -990,20 +988,20 @@
{
doTransactionRollback(false, false);
}
-
+
public void testRollback_XA_Long_NB() throws Throwable
{
doTransactionRollback(true, false);
}
-
+
//batch
-
+
public void testCommit_NotXA_Long_B() throws Throwable
{
doTransactionCommit(false, true);
}
-
+
public void testCommit_XA_Long_B() throws Throwable
{
doTransactionCommit(true, true);
@@ -1013,36 +1011,36 @@
{
doTransactionRollback(false, true);
}
-
+
public void testRollback_XA_Long_B() throws Throwable
{
doTransactionRollback(true, true);
}
-
+
public void testRetrievePreparedTransactions() throws Throwable
{
doSetup(false);
-
+
Channel channel = new SimpleChannel(0, ms);
-
+
TransactionRepository txRep = new TransactionRepository();
txRep.start(pm, ms);
Message[] messages = createMessages(10);
-
+
Xid[] xids = new Xid[messages.length];
Transaction[] txs = new Transaction[messages.length];
-
+
for (int i = 0; i < messages.length; i++)
- {
+ {
xids[i] = new MockXid();
txs[i] = txRep.createTransaction(xids[i]);
MessageReference ref = ms.reference(messages[i]);
pm.addReference(channel.getChannelID(), ref, txs[i]);
txs[i].prepare();
}
-
+
List txList = pm.retrievePreparedTransactions();
assertNotNull(txList);
assertEquals(messages.length, txList.size());
@@ -1057,14 +1055,14 @@
Xid xid = xids[i];
assertTrue(retrievedXids.contains(xid));
}
-
+
//rollback the txs
for (int i = 0; i < txs.length; i++)
{
txs[i].rollback();
- }
+ }
}
-
+
protected Message createMessage(byte i, boolean reliable) throws Throwable
{
Map headers = generateFilledMap(true);
@@ -1078,30 +1076,30 @@
headers,
i % 2 == 0 ? new WibblishObject() : null);
}
-
+
protected Message[] createMessages(int num) throws Throwable
{
//Generate some messages with a good range of attribute values
Message[] messages = new Message[num];
for (int i = 0; i < num; i++)
- {
+ {
messages[i] = createMessage((byte)i, true);
}
return messages;
}
-
+
protected void checkEquivalent(Message m1, Message m2) throws Throwable
{
if (m1 == m2)
{
fail();
}
-
+
if (m1 == null || m2 == null)
{
fail();
}
-
+
//Attributes from org.jboss.messaging.core.Message
assertEquals(m1.getMessageID(), m2.getMessageID());
assertEquals(m1.isReference(), m2.isReference());
@@ -1115,7 +1113,7 @@
Map m2Headers = m2.getHeaders();
checkMapsEquivalent(m1Headers, m2Headers);
checkMapsEquivalent(m2Headers, m1Headers);
-
+
if (m1.getPayload() instanceof byte[] && m2.getPayload() instanceof byte[])
{
this.checkByteArraysEqual((byte[])m1.getPayload(), (byte[])m2.getPayload());
@@ -1129,12 +1127,12 @@
this.checkListsEquivalent((List)m1.getPayload(), (List)m2.getPayload());
}
else
- {
+ {
assertEquals(m1.getPayload(), m2.getPayload());
}
-
+
}
-
+
protected void checkMapsEquivalent(Map headers1, Map headers2)
{
Iterator iter = headers1.entrySet().iterator();
@@ -1153,16 +1151,16 @@
}
}
}
-
+
protected void checkListsEquivalent(List l1, List l2)
- {
+ {
Iterator iter1 = l1.iterator();
Iterator iter2 = l2.iterator();
while (iter1.hasNext())
{
Object o1 = iter1.next();
Object o2 = iter2.next();
-
+
if (o1 instanceof byte[])
{
checkByteArraysEqual((byte[])o1, (byte[])o2);
@@ -1173,7 +1171,7 @@
}
}
}
-
+
public static class WibblishObject implements Serializable
{
private static final long serialVersionUID = -822739710811857027L;
@@ -1192,7 +1190,7 @@
return oo.wibble.equals(this.wibble);
}
}
-
+
protected HashMap generateFilledMap(boolean useObject)
{
HashMap headers = new HashMap();
@@ -1208,7 +1206,7 @@
{
k = j % 10;
}
-
+
switch (k)
{
case 0:
@@ -1232,47 +1230,47 @@
case 9:
headers.put(new GUID().toString(), randByteArray(500));
case 10:
- headers.put(new GUID().toString(), new WibblishObject());
+ headers.put(new GUID().toString(), new WibblishObject());
}
}
return headers;
}
-
+
protected Byte randByte()
{
return new Byte((byte)(Math.random() * (2^8 - 1) - (2^7)));
}
-
+
protected Short randShort()
{
return new Short((short)(Math.random() * (2^16 - 1) - (2^15)));
}
-
+
protected Integer randInt()
{
return new Integer((int)(Math.random() * (2^32 - 1) - (2^31)));
}
-
+
protected Long randLong()
{
return new Long((long)(Math.random() * (2^64 - 1) - (2^64)));
}
-
+
protected Boolean randBool()
{
return new Boolean(Math.random() > 0.5);
}
-
+
protected Float randFloat()
{
return new Float((float)(Math.random() * 1000000));
}
-
+
protected Double randDouble()
{
return new Double(Math.random() * 1000000);
}
-
+
protected String randString(int length)
{
StringBuffer buf = new StringBuffer(length);
@@ -1282,18 +1280,18 @@
}
return buf.toString();
}
-
+
protected byte[] randByteArray(int size)
{
String s = randString(size / 2);
return s.getBytes();
}
-
+
protected Character randChar()
{
return new Character((char)randShort().shortValue());
}
-
+
protected void checkByteArraysEqual(byte[] b1, byte[] b2)
{
if (b1 == null || b2 == null)
@@ -1304,20 +1302,20 @@
{
fail();
}
-
+
for (int i = 0; i < b1.length; i++)
{
assertEquals(b1[i], b2[i]);
}
-
+
}
-
+
protected class MockXid implements Xid
{
byte[] branchQual;
int formatID;
byte[] globalTxId;
-
+
protected MockXid()
{
branchQual = new GUID().toString().getBytes();
@@ -1339,7 +1337,7 @@
{
return globalTxId;
}
-
+
public boolean equals(Object other)
{
if (!(other instanceof Xid))
@@ -1377,9 +1375,9 @@
}
return true;
}
-
+
}
-
+
protected void doTransactionCommit(boolean xa, boolean batch) throws Throwable
{
doSetup(batch);
@@ -1391,35 +1389,35 @@
log.debug("transaction log started");
Message[] messages = createMessages(10);
-
+
Message m1 = messages[0];
Message m2 = messages[1];
- Message m3 = messages[2];
+ Message m3 = messages[2];
Message m4 = messages[3];
Message m5 = messages[4];
Transaction tx = null;
if (xa)
- {
+ {
tx = txRep.createTransaction(new MockXid());
}
else
{
tx = txRep.createTransaction();
}
-
+
if (xa)
{
- assertEquals(1,txRep.getNumberOfRegisteredTransactions());
+ assertEquals(1,txRep.getNumberOfRegisteredTransactions());
}
else
{
- assertEquals(0,txRep.getNumberOfRegisteredTransactions());
+ assertEquals(0,txRep.getNumberOfRegisteredTransactions());
}
-
+
MessageReference ref1 = ms.reference(m1);
- MessageReference ref2 = ms.reference(m2);
- MessageReference ref3 = ms.reference(m3);
+ MessageReference ref2 = ms.reference(m2);
+ MessageReference ref3 = ms.reference(m3);
MessageReference ref4 = ms.reference(m4);
MessageReference ref5 = ms.reference(m5);
@@ -1428,14 +1426,14 @@
// Add first two refs non transactionally
pm.addReference(channel.getChannelID(), ref1, null);
pm.addReference(channel.getChannelID(), ref2, null);
-
+
//check they're there
List refs = getReferenceIds(channel.getChannelID());
assertNotNull(refs);
assertEquals(2, refs.size());
assertTrue(refs.contains(new Long(ref1.getMessageID())));
assertTrue(refs.contains(new Long(ref2.getMessageID())));
-
+
List msgs = getMessageIds();
assertNotNull(msgs);
assertEquals(2, msgs.size());
@@ -1448,37 +1446,37 @@
pm.addReference(channel.getChannelID(), ref3, tx);
pm.addReference(channel.getChannelID(), ref4, tx);
pm.addReference(channel.getChannelID(), ref5, tx);
-
+
//Remove the other 2 transactionally
pm.removeReference(channel.getChannelID(), ref1, tx);
pm.removeReference(channel.getChannelID(), ref2, tx);
-
+
//Check the changes aren't visible
refs = getReferenceIds(channel.getChannelID());
assertNotNull(refs);
assertEquals(2, refs.size());
assertTrue(refs.contains(new Long(ref1.getMessageID())));
- assertTrue(refs.contains(new Long(ref2.getMessageID())));
-
+ assertTrue(refs.contains(new Long(ref2.getMessageID())));
+
msgs = getMessageIds();
assertNotNull(msgs);
assertEquals(2, msgs.size());
assertTrue(msgs.contains(new Long(ref1.getMessageID())));
assertTrue(msgs.contains(new Long(ref2.getMessageID())));
-
+
//commit transaction
tx.commit();
assertEquals("numberOfRegisteredTransactions",0,txRep.getNumberOfRegisteredTransactions());
-
+
//check we can see only the last 3 refs
refs = getReferenceIds(channel.getChannelID());
assertNotNull(refs);
- assertEquals(3, refs.size());
+ assertEquals(3, refs.size());
assertTrue(refs.contains(new Long(ref3.getMessageID())));
- assertTrue(refs.contains(new Long(ref4.getMessageID())));
+ assertTrue(refs.contains(new Long(ref4.getMessageID())));
assertTrue(refs.contains(new Long(ref5.getMessageID())));
-
+
msgs = getMessageIds();
assertNotNull(msgs);
assertEquals(3, msgs.size());
@@ -1486,7 +1484,7 @@
assertTrue(msgs.contains(new Long(ref4.getMessageID())));
assertTrue(msgs.contains(new Long(ref5.getMessageID())));
}
-
+
protected void doTransactionRollback(boolean xa, boolean batch) throws Throwable
{
doSetup(batch);
@@ -1494,16 +1492,16 @@
Channel channel = new SimpleChannel(0, ms);
TransactionRepository txRep = new TransactionRepository();
txRep.start(pm, ms);
-
- Message[] messages = createMessages(10);
-
+
+ Message[] messages = createMessages(10);
+
Message m1 = messages[0];
Message m2 = messages[1];
- Message m3 = messages[2];
+ Message m3 = messages[2];
Message m4 = messages[3];
Message m5 = messages[4];
-
+
Transaction tx = null;
if (xa)
{
@@ -1513,77 +1511,77 @@
{
tx = txRep.createTransaction();
}
-
+
MessageReference ref1 = ms.reference(m1);
- MessageReference ref2 = ms.reference(m2);
- MessageReference ref3 = ms.reference(m3);
+ MessageReference ref2 = ms.reference(m2);
+ MessageReference ref3 = ms.reference(m3);
MessageReference ref4 = ms.reference(m4);
- MessageReference ref5 = ms.reference(m5);
+ MessageReference ref5 = ms.reference(m5);
//Add first two refs non transactionally
pm.addReference(channel.getChannelID(), ref1, null);
pm.addReference(channel.getChannelID(), ref2, null);
-
+
//check they're there
List refs = getReferenceIds(channel.getChannelID());
assertNotNull(refs);
assertEquals(2, refs.size());
assertTrue(refs.contains(new Long(ref1.getMessageID())));
- assertTrue(refs.contains(new Long(ref2.getMessageID())));
-
+ assertTrue(refs.contains(new Long(ref2.getMessageID())));
+
List msgs = getMessageIds();
assertNotNull(msgs);
assertEquals(2, msgs.size());
assertTrue(msgs.contains(new Long(ref1.getMessageID())));
assertTrue(msgs.contains(new Long(ref2.getMessageID())));
-
-
-
+
+
+
//Add the next 3 refs transactionally
pm.addReference(channel.getChannelID(), ref3, tx);
pm.addReference(channel.getChannelID(), ref4, tx);
pm.addReference(channel.getChannelID(), ref5, tx);
-
+
//Remove the other 2 transactionally
pm.removeReference(channel.getChannelID(), ref1, tx);
pm.removeReference(channel.getChannelID(), ref2, tx);
-
+
//Check the changes aren't visible
refs = getReferenceIds(channel.getChannelID());
assertNotNull(refs);
assertEquals(2, refs.size());
assertTrue(refs.contains(new Long(ref1.getMessageID())));
- assertTrue(refs.contains(new Long(ref2.getMessageID())));
-
+ assertTrue(refs.contains(new Long(ref2.getMessageID())));
+
msgs = getMessageIds();
assertNotNull(msgs);
assertEquals(2, msgs.size());
assertTrue(msgs.contains(new Long(ref1.getMessageID())));
assertTrue(msgs.contains(new Long(ref2.getMessageID())));
-
+
//rollback transaction
tx.rollback();
-
+
refs = getReferenceIds(channel.getChannelID());
assertNotNull(refs);
assertEquals(2, refs.size());
assertTrue(refs.contains(new Long(ref1.getMessageID())));
- assertTrue(refs.contains(new Long(ref2.getMessageID())));
-
+ assertTrue(refs.contains(new Long(ref2.getMessageID())));
+
msgs = getMessageIds();
assertNotNull(msgs);
assertEquals(2, msgs.size());
assertTrue(msgs.contains(new Long(ref1.getMessageID())));
- assertTrue(msgs.contains(new Long(ref2.getMessageID())));
+ assertTrue(msgs.contains(new Long(ref2.getMessageID())));
}
-
+
protected List getReferenceIds(long channelId) throws Throwable
{
InitialContext ctx = new InitialContext();
TransactionManager mgr = (TransactionManager)ctx.lookup(TransactionManagerService.JNDI_NAME);
DataSource ds = (DataSource)ctx.lookup("java:/DefaultDS");
-
+
javax.transaction.Transaction txOld = mgr.suspend();
mgr.begin();
@@ -1591,11 +1589,11 @@
String sql = "SELECT MESSAGEID FROM JMS_MESSAGE_REFERENCE WHERE CHANNELID=? ORDER BY ORD";
PreparedStatement ps = conn.prepareStatement(sql);
ps.setLong(1, channelId);
-
+
ResultSet rs = ps.executeQuery();
-
+
List msgIds = new ArrayList();
-
+
while (rs.next())
{
long msgId = rs.getLong(1);
@@ -1611,28 +1609,28 @@
{
mgr.resume(txOld);
}
-
+
return msgIds;
}
-
+
protected List getMessageIds() throws Throwable
{
InitialContext ctx = new InitialContext();
TransactionManager mgr = (TransactionManager)ctx.lookup(TransactionManagerService.JNDI_NAME);
DataSource ds = (DataSource)ctx.lookup("java:/DefaultDS");
-
+
javax.transaction.Transaction txOld = mgr.suspend();
mgr.begin();
Connection conn = ds.getConnection();
String sql = "SELECT MESSAGEID FROM JMS_MESSAGE ORDER BY MESSAGEID";
PreparedStatement ps = conn.prepareStatement(sql);
-
+
ResultSet rs = ps.executeQuery();
-
+
List msgIds = new ArrayList();
-
+
while (rs.next())
{
long msgId = rs.getLong(1);
@@ -1648,10 +1646,10 @@
{
mgr.resume(txOld);
}
-
+
return msgIds;
}
-
+
}
Modified: branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/BrowserTest.java
===================================================================
--- branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/BrowserTest.java 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/BrowserTest.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -32,6 +32,7 @@
import javax.jms.QueueBrowser;
import javax.jms.Session;
import javax.jms.Topic;
+import javax.jms.TextMessage;
import javax.naming.InitialContext;
import org.jboss.jms.client.JBossConnectionFactory;
@@ -89,6 +90,8 @@
ServerManagement.deployQueue("Queue");
queue = (Queue)initialContext.lookup("/queue/Queue");
+
+ drainDestination(cf, queue);
connection = cf.createConnection();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
@@ -241,10 +244,47 @@
}
assertEquals(70, count);
}
+
+ public void testGetEnumeration() throws Exception
+ {
+ // send a message to the queue
+
+ Message m = session.createTextMessage("A");
+ producer.send(m);
+
+ // make sure we can browse it
+
+ QueueBrowser browser = session.createBrowser(queue);
+
+ Enumeration en = browser.getEnumeration();
+
+ assertTrue(en.hasMoreElements());
+
+ TextMessage rm = (TextMessage)en.nextElement();
+
+ assertNotNull(rm);
+ assertEquals("A", rm.getText());
+
+ assertFalse(en.hasMoreElements());
+
+ // create a *new* enumeration, that should reset it
+
+ en = browser.getEnumeration();
+
+ assertTrue(en.hasMoreElements());
+
+ rm = (TextMessage)en.nextElement();
+
+ assertNotNull(rm);
+ assertEquals("A", rm.getText());
+
+ assertFalse(en.hasMoreElements());
+ }
+
+
+
+ // Package protected ---------------------------------------------
-
- // Package protected ---------------------------------------------
-
// Protected -----------------------------------------------------
// Private -------------------------------------------------------
Copied: branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/ClientExitTest.java (from rev 2261, branches/Branch_1_0_1_SP/tests/src/org/jboss/test/messaging/jms/ClientExitTest.java)
===================================================================
--- branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/ClientExitTest.java (rev 0)
+++ branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/ClientExitTest.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -0,0 +1,268 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.messaging.jms;
+
+import org.jboss.test.messaging.MessagingTestCase;
+import org.jboss.test.messaging.tools.jmx.rmi.Server;
+import org.jboss.test.messaging.tools.jmx.rmi.LocalTestServer;
+import org.jboss.test.messaging.tools.ServerManagement;
+import org.jboss.logging.Logger;
+
+import javax.naming.InitialContext;
+import javax.jms.ConnectionFactory;
+import javax.jms.Queue;
+import javax.jms.Connection;
+import javax.jms.Session;
+import javax.jms.MessageConsumer;
+import javax.jms.TextMessage;
+import java.io.ObjectOutputStream;
+import java.io.FileOutputStream;
+import java.io.File;
+
+/**
+ * A test that makes sure that a Messaging client gracefully exists after the last connection is
+ * closed. Test for http://jira.jboss.org/jira/browse/JBMESSAGING-417.
+ *
+ * This is not technically a crash test, but it uses the same type of topology as the crash tests
+ * (local server, remote VM client).
+ *
+ * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
+ * @version 1.1
+ *
+ * $Id$
+ */
+public class ClientExitTest extends MessagingTestCase
+{
+ // Constants ------------------------------------------------------------------------------------
+
+ public static final String SERIALIZED_CF_FILE_NAME = "CFandQueue.ser";
+ public static final String MESSAGE_TEXT = "kolowalu";
+
+ // Static ---------------------------------------------------------------------------------------
+
+ private static final Logger log = Logger.getLogger(ClientExitTest.class);
+
+ // Attributes -----------------------------------------------------------------------------------
+
+ // Constructors ---------------------------------------------------------------------------------
+
+ public ClientExitTest(String name)
+ {
+ super(name);
+ }
+
+ // Public ---------------------------------------------------------------------------------------
+
+ public void testGracefulClientExit() throws Exception
+ {
+ if (ServerManagement.isRemote())
+ {
+ // doesn't make any sense to run in remote mode, since we'll start our won external VM
+ return;
+ }
+
+ Server localServer = null;
+ File serialized = null;
+
+ try
+ {
+ localServer = new LocalTestServer();
+
+ localServer.start("all");
+ localServer.deployQueue("Queue", null);
+
+ // lookup the connection factory and the queue which we'll send to the client VM via a
+ // serialized instances saved in file
+
+ InitialContext ic = new InitialContext(ServerManagement.getJNDIEnvironment());
+ ConnectionFactory cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
+ Queue queue = (Queue)ic.lookup("/queue/Queue");
+
+ serialized = writeToFile(cf, queue);
+
+ // spawn a JVM that creates a JMS client, which sends a test message
+
+ Process p = spawnVM(serialized);
+
+ // read the message from the queue
+
+ Connection conn = cf.createConnection();
+ conn.start();
+ Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageConsumer cons = sess.createConsumer(queue);
+ TextMessage tm = (TextMessage)cons.receive(5000);
+
+ assertNotNull(tm);
+ assertEquals(MESSAGE_TEXT, tm.getText());
+
+ // the client VM should exit by itself. If it doesn't, that means we have a problem
+ // and the test will timeout
+ log.info("waiting for the client VM to exit ...");
+ p.waitFor();
+
+ assertEquals(0, p.exitValue());
+
+ }
+ finally
+ {
+ // TODO delete the file
+ if (serialized != null)
+ {
+ serialized.delete();
+ }
+
+ localServer.undeployDestination(true, "Queue");
+ localServer.stopServerPeer();
+ localServer.stop();
+ }
+ }
+
+ // Package protected ----------------------------------------------------------------------------
+
+ // Protected ------------------------------------------------------------------------------------
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
+ // Private --------------------------------------------------------------------------------------
+
+ private Process spawnVM(File serialized) throws Exception
+ {
+ StringBuffer sb = new StringBuffer();
+
+ sb.append("java").append(' ');
+
+ String classPath = System.getProperty("java.class.path");
+
+ if (System.getProperty("os.name").equals("Linux"))
+ {
+ sb.append("-cp").append(" ").append(classPath).append(" ");
+ }
+ else
+ {
+ sb.append("-cp").append(" \"").append(classPath).append("\" ");
+ }
+
+ sb.append("org.jboss.test.messaging.jms.GracefulClient ");
+
+ // the first argument
+ sb.append(serialized.getAbsolutePath());
+
+ String commandLine = sb.toString();
+
+ //System.out.println(commandLine);
+
+ Process process = Runtime.getRuntime().exec(commandLine);
+
+ log.trace("process: " + process);
+
+// final boolean verbose = true;
+//
+// final BufferedReader rs = new BufferedReader(new InputStreamReader(process.getInputStream()));
+// final BufferedReader re = new BufferedReader(new InputStreamReader(process.getErrorStream()));
+//
+// new Thread(new Runnable()
+// {
+// public void run()
+// {
+// try
+// {
+// String line;
+//
+// while((line = rs.readLine()) != null)
+// {
+// if (verbose)
+// {
+// System.out.println("GRACEFUL CLIENT STDOUT: " + line);
+// }
+// }
+// }
+// catch(Exception e)
+// {
+// log.error("exception", e);
+// }
+// }
+//
+// }, "GRACEFUL CLIENT STDOUT reader thread").start();
+//
+// new Thread(new Runnable()
+// {
+// public void run()
+// {
+// try
+// {
+// String line;
+//
+// while((line = re.readLine()) != null)
+// {
+// if (verbose)
+// {
+// System.out.println("GRACEFUL CLIENT STDERR: " + line);
+// }
+// }
+// }
+// catch(Exception e)
+// {
+// log.error("exception", e);
+// }
+// }
+//
+// }, "GRACEFUL CLIENT STDERR reader thread").start();
+
+ return process;
+ }
+
+ private File writeToFile(ConnectionFactory cf, Queue queue) throws Exception
+ {
+ String moduleOutput = System.getProperty("module.output");
+ if (moduleOutput == null)
+ {
+ throw new Exception("Can't find 'module.output'");
+ }
+ File dir = new File(moduleOutput);
+
+ if (!dir.isDirectory() || !dir.canWrite())
+ {
+ throw new Exception(dir + " is either not a directory or not writable");
+ }
+
+ File file = new File(dir, SERIALIZED_CF_FILE_NAME);
+
+ ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(file));
+ oos.writeObject(cf);
+ oos.writeObject(queue);
+ oos.flush();
+ oos.close();
+
+ return file;
+ }
+
+ // Inner classes --------------------------------------------------------------------------------
+
+}
Copied: branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/ClientInRestrictedSecurityEnvironmentTest.java (from rev 2261, branches/Branch_1_0_1_SP/tests/src/org/jboss/test/messaging/jms/ClientInRestrictedSecurityEnvironmentTest.java)
===================================================================
--- branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/ClientInRestrictedSecurityEnvironmentTest.java (rev 0)
+++ branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/ClientInRestrictedSecurityEnvironmentTest.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -0,0 +1,171 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.messaging.jms;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.naming.InitialContext;
+
+import org.jboss.jms.client.JBossConnectionFactory;
+import org.jboss.test.messaging.MessagingTestCase;
+import org.jboss.test.messaging.tools.ServerManagement;
+import org.jboss.test.messaging.tools.misc.ConfigurableSecurityManager;
+
+import java.net.SocketPermission;
+
+/**
+ * This test runs the JMS client in a restricted security environments.
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ */
+public class ClientInRestrictedSecurityEnvironmentTest extends MessagingTestCase
+{
+ // Constants ------------------------------------------------------------------------------------
+
+ // Static ---------------------------------------------------------------------------------------
+
+ // Attributes -----------------------------------------------------------------------------------
+
+ private InitialContext ic;
+ private SecurityManager oldSM;
+ private ConfigurableSecurityManager configurableSecurityManager;
+
+ // Constructors ---------------------------------------------------------------------------------
+
+ public ClientInRestrictedSecurityEnvironmentTest(String name)
+ {
+ super(name);
+ }
+
+ // Public ---------------------------------------------------------------------------------------
+
+ /**
+ * Test case for http://jira.jboss.org/jira/browse/JBMESSAGING-806
+ */
+ public void testGetSystemProperties() throws Exception
+ {
+ // TODO (ovidiu) Will be uncommented in 1.0.1.SP5 and 1.2.0.CR1
+ // See http://jira.jboss.org/jira/browse/JBMESSAGING-806
+
+// if (ServerManagement.isRemote())
+// {
+// // don't run in a remote configuration, so we won't have to open server sockets and
+// // interfere with those permissions (or lack of)
+// return;
+// }
+//
+// // make sure our security manager disallows getProperty()
+// configurableSecurityManager.dissalow(new PropertyPermission("does not matter", "read"));
+//
+// ConnectionFactory cf = (JBossConnectionFactory)ic.lookup("/ConnectionFactory");
+// Queue queue = (Queue)ic.lookup("/queue/TestQueue");
+//
+// Connection conn = null;
+//
+// try
+// {
+// conn = cf.createConnection();
+//
+// Session s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+//
+// MessageProducer p = s.createProducer(queue);
+// MessageConsumer c = s.createConsumer(queue);
+//
+// conn.start();
+//
+// p.send(s.createTextMessage("payload"));
+//
+// TextMessage m = (TextMessage)c.receive();
+//
+// assertEquals("payload", m.getText());
+//
+// }
+// finally
+// {
+// if (conn != null)
+// {
+// conn.close();
+// }
+// }
+ }
+
+ // Package protected ----------------------------------------------------------------------------
+
+ // MessagingTestCase overrides ------------------------------------------------------------------
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ ServerManagement.start("all");
+
+ ServerManagement.undeployQueue("TestQueue");
+ ServerManagement.deployQueue("TestQueue");
+
+ ic = new InitialContext(ServerManagement.getJNDIEnvironment());
+
+ // install our own security manager
+
+ configurableSecurityManager = new ConfigurableSecurityManager();
+
+ oldSM = System.getSecurityManager();
+ System.setSecurityManager(configurableSecurityManager);
+
+ log.info("SecurityManager is now " + System.getSecurityManager());
+ log.debug("setup done");
+ }
+
+ protected void tearDown() throws Exception
+ {
+ configurableSecurityManager.clear();
+ configurableSecurityManager = null;
+
+ System.setSecurityManager(oldSM);
+
+ if (ic != null)
+ {
+ ic.close();
+ }
+
+ ServerManagement.undeployQueue("TestQueue");
+
+ ServerManagement.stop();
+ super.tearDown();
+ }
+
+ // Protected ------------------------------------------------------------------------------------
+
+ // Private --------------------------------------------------------------------------------------
+
+ // Inner classes --------------------------------------------------------------------------------
+}
+
+
+
Modified: branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/ConnectionFactoryTest.java
===================================================================
--- branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/ConnectionFactoryTest.java 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/ConnectionFactoryTest.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -23,6 +23,7 @@
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
+import javax.jms.JMSException;
import javax.jms.QueueConnection;
import javax.jms.QueueConnectionFactory;
import javax.jms.TopicConnection;
@@ -123,6 +124,46 @@
{
// OK
}
+
+ //Now try and deploy another one with the same client id
+
+ mbeanConfig =
+ "<mbean code=\"org.jboss.jms.server.connectionfactory.ConnectionFactory\"\n" +
+ " name=\"jboss.messaging.destination:service=TestConnectionFactory2\"\n" +
+ " xmbean-dd=\"xmdesc/ConnectionFactory-xmbean.xml\">\n" +
+ " <constructor>\n" +
+ " <arg type=\"java.lang.String\" value=\"sofiavergara\"/>\n" +
+ " </constructor>\n" +
+ " <depends optional-attribute-name=\"ServerPeer\">jboss.messaging:service=ServerPeer</depends>\n" +
+ " <depends optional-attribute-name=\"Connector\">jboss.messaging:service=Connector,transport=socket</depends>\n" +
+ " <attribute name=\"JNDIBindings\">\n" +
+ " <bindings>\n" +
+ " <binding>/TestConnectionFactory2</binding>\n" +
+ " </bindings>\n" +
+ " </attribute>\n" +
+ " </mbean>";
+
+ ObjectName on2 = ServerManagement.deploy(mbeanConfig);
+ ServerManagement.invoke(on2, "create", new Object[0], new String[0]);
+ ServerManagement.invoke(on2, "start", new Object[0], new String[0]);
+
+
+ ServerManagement.invoke(on2, "stop", new Object[0], new String[0]);
+ ServerManagement.invoke(on2, "destroy", new Object[0], new String[0]);
+ ServerManagement.undeploy(on2);
+
+ cf = (ConnectionFactory)initialContext.lookup("/TestConnectionFactory");
+ Connection c2 = null;
+ try
+ {
+ c2 = cf.createConnection();
+ }
+ catch (JMSException e)
+ {
+ //Ok
+ }
+
+ if (c2 != null) c2.close();
c.close();
@@ -145,11 +186,11 @@
ObjectName c2 = deployConnector(1235, name2);
ObjectName c3 = deployConnector(1236, name3);
- ObjectName cf1 = deployConnectionFactory("jboss.messaging.destination:service=TestConnectionFactory1", name1, "/TestConnectionFactory1");
- ObjectName cf2 = deployConnectionFactory("jboss.messaging.destination:service=TestConnectionFactory2", name2, "/TestConnectionFactory2");
- ObjectName cf3 = deployConnectionFactory("jboss.messaging.destination:service=TestConnectionFactory3", name3, "/TestConnectionFactory3");
+ ObjectName cf1 = deployConnectionFactory("jboss.messaging.destination:service=TestConnectionFactory1", name1, "/TestConnectionFactory1", "clientid1");
+ ObjectName cf2 = deployConnectionFactory("jboss.messaging.destination:service=TestConnectionFactory2", name2, "/TestConnectionFactory2", "clientid2");
+ ObjectName cf3 = deployConnectionFactory("jboss.messaging.destination:service=TestConnectionFactory3", name3, "/TestConnectionFactory3", "clientid3");
//Last one shares the same connector
- ObjectName cf4 = deployConnectionFactory("jboss.messaging.destination:service=TestConnectionFactory4", name3, "/TestConnectionFactory4");
+ ObjectName cf4 = deployConnectionFactory("jboss.messaging.destination:service=TestConnectionFactory4", name3, "/TestConnectionFactory4", "clientid4");
JBossConnectionFactory f1 = (JBossConnectionFactory)initialContext.lookup("/TestConnectionFactory1");
@@ -216,8 +257,8 @@
// set the client id immediately after the connection is created
- c.setClientID("sofiavergara");
- assertEquals("sofiavergara", c.getClientID());
+ c.setClientID("sofiavergara2");
+ assertEquals("sofiavergara2", c.getClientID());
c.close();
}
@@ -285,14 +326,14 @@
return on;
}
- private ObjectName deployConnectionFactory(String name, String connectorName, String binding) throws Exception
+ private ObjectName deployConnectionFactory(String name, String connectorName, String binding, String clientID) throws Exception
{
String mbeanConfig =
"<mbean code=\"org.jboss.jms.server.connectionfactory.ConnectionFactory\"\n" +
" name=\"" + name + "\"\n" +
" xmbean-dd=\"xmdesc/ConnectionFactory-xmbean.xml\">\n" +
" <constructor>\n" +
- " <arg type=\"java.lang.String\" value=\"sofiavergara\"/>\n" +
+ " <arg type=\"java.lang.String\" value=\"" + clientID + "\"/>\n" +
" </constructor>\n" +
" <depends optional-attribute-name=\"ServerPeer\">jboss.messaging:service=ServerPeer</depends>\n" +
" <depends optional-attribute-name=\"Connector\">" + connectorName + "</depends>\n" +
Copied: branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/DuplicateClientIDTest.java (from rev 2261, branches/Branch_1_0_1_SP/tests/src/org/jboss/test/messaging/jms/DuplicateClientIDTest.java)
===================================================================
--- branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/DuplicateClientIDTest.java (rev 0)
+++ branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/DuplicateClientIDTest.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -0,0 +1,158 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.messaging.jms;
+
+import org.jboss.test.messaging.MessagingTestCase;
+import org.jboss.test.messaging.tools.ServerManagement;
+import javax.naming.InitialContext;
+import javax.jms.ConnectionFactory;
+import javax.jms.Connection;
+import javax.jms.InvalidClientIDException;
+
+/**
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ * @version <tt>$Revision$</tt>
+ * $Id$
+ */
+public class DuplicateClientIDTest extends MessagingTestCase
+{
+
+ // Constants ------------------------------------------------------------------------------------
+
+ // Attributes -----------------------------------------------------------------------------------
+
+ protected InitialContext ic;
+ protected ConnectionFactory cf;
+
+ // Static ---------------------------------------------------------------------------------------
+
+ // Constructors ---------------------------------------------------------------------------------
+
+ public DuplicateClientIDTest(String name)
+ {
+ super(name);
+ }
+
+ // Public ---------------------------------------------------------------------------------------
+
+ public void testDuplicate() throws Exception
+ {
+
+ Connection c1 = null;
+ Connection c2 = null;
+ try
+ {
+
+ c1 = cf.createConnection();
+ c1.setClientID("Duplicated");
+
+ try
+ {
+ c2 = cf.createConnection();
+ c2.setClientID("Duplicated");
+ fail("JBossMessaging is allowing duplicate clients!");
+ }
+ catch (InvalidClientIDException e)
+ {
+ }
+ }
+ finally
+ {
+ if (c1 != null) c1.close();
+ if (c2 != null) c2.close();
+ }
+
+ }
+
+ public void testPreconfiguredDuplicateClientID() throws Exception
+ {
+ Connection c1 = null;
+ Connection c2 = null;
+ try
+ {
+
+ c1 = cf.createConnection("john", "needle");
+ c1.setClientID("Duplicated");
+
+ try
+ {
+ c2 = cf.createConnection("john", "needle");
+ c2.setClientID("Duplicated");
+ fail("JBossMessaging is allowing duplicate clients!");
+ }
+ catch (InvalidClientIDException e)
+ {
+ }
+ }
+ finally
+ {
+ if (c1 != null) c1.close();
+ if (c2 != null) c2.close();
+ }
+ }
+
+ public void testNotDuplicateClientID() throws Exception
+ {
+ Connection c1 = null;
+ Connection c2 = null;
+ try
+ {
+
+ c1 = cf.createConnection();
+
+ c2 = cf.createConnection();
+ }
+ finally
+ {
+ if (c1 != null) c1.close();
+ if (c2 != null) c2.close();
+ }
+ }
+
+ // Package protected ----------------------------------------------------------------------------
+
+ // Protected ------------------------------------------------------------------------------------
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ ServerManagement.start("all");
+
+ ic = new InitialContext(ServerManagement.getJNDIEnvironment());
+
+ cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
+
+
+ }
+
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
+ // Private --------------------------------------------------------------------------------------
+
+ // Inner classes --------------------------------------------------------------------------------
+
+}
Modified: branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/DurableSubscriberTest.java
===================================================================
--- branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/DurableSubscriberTest.java 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/DurableSubscriberTest.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -147,6 +147,8 @@
Message m = durable.receive(1000);
assertNull(m);
+
+ conn.close();
}
/**
@@ -193,6 +195,8 @@
ServerManagement.undeployTopic("CompletelyNewTopic");
ServerManagement.undeployTopic("CompletelyNewTopic2");
+
+ conn.close();
}
/**
@@ -267,6 +271,8 @@
assertNull(m);
ServerManagement.undeployTopic("CompletelyNewTopic2");
+
+ conn.close();
}
/**
@@ -318,6 +324,8 @@
// the durable subscription is destroyed and re-created. "Message Two" stored by the previous
// durable subscription is lost and (hopefully) garbage collected.
assertNull(m);
+
+ conn.close();
}
public void testDurableSubscriptionOnTemporaryTopic() throws Exception
@@ -337,6 +345,8 @@
{
// OK
}
+
+ conn.close();
}
/**
@@ -469,6 +479,8 @@
{
// OK
}
+
+ c.close();
}
//See JMS 1.1. spec sec 6.11
Copied: branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/GracefulClient.java (from rev 2261, branches/Branch_1_0_1_SP/tests/src/org/jboss/test/messaging/jms/GracefulClient.java)
===================================================================
--- branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/GracefulClient.java (rev 0)
+++ branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/GracefulClient.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -0,0 +1,113 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.messaging.jms;
+
+import javax.jms.Connection;
+import javax.jms.Session;
+import javax.jms.MessageProducer;
+import javax.jms.MessageConsumer;
+import javax.jms.ConnectionFactory;
+import javax.jms.Queue;
+import java.io.ObjectInputStream;
+import java.io.FileInputStream;
+
+/**
+ * Code to be run in an external VM, via main().
+ *
+ * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
+ * @version <tt>$Revision$</tt>
+ *
+ * $Id$
+ */
+public class GracefulClient
+{
+ // Constants ------------------------------------------------------------------------------------
+
+ // Static ---------------------------------------------------------------------------------------
+
+ public static void main(String[] args) throws Exception
+ {
+
+ String serializedFileName = args[0];
+
+ // we don't want to mess with JNDI, read the connection factory and the queue from their
+ // serialized format, from disk
+ ObjectInputStream ois =
+ new ObjectInputStream(new FileInputStream(serializedFileName));
+ ConnectionFactory cf =(ConnectionFactory)ois.readObject();
+ Queue queue = (Queue)ois.readObject();
+
+ ois.close();
+
+ Connection conn = cf.createConnection();
+ Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageProducer prod = sess.createProducer(queue);
+ MessageConsumer cons = sess.createConsumer(queue);
+
+ prod.send(sess.createTextMessage(ClientExitTest.MESSAGE_TEXT));
+
+ conn.start();
+
+ // block in receiving for 5 secs, we won't receive anything
+
+ cons.receive(5000);
+
+ // this should silence any non-daemon thread and allow for graceful exit
+ conn.close();
+
+// new Thread(new Runnable()
+// {
+// public void run()
+// {
+// // spin around in circles
+// while(true)
+// {
+// try
+// {
+// Thread.sleep(1000);
+// }
+// catch(Exception e)
+// {
+// // OK
+// }
+// }
+// }
+// }, "Spinner").start();
+ }
+
+ // Attributes -----------------------------------------------------------------------------------
+
+ // Constructors ---------------------------------------------------------------------------------
+
+ // Command implementation -----------------------------------------------------------------------
+
+ // Public ---------------------------------------------------------------------------------------
+
+ // Package protected ----------------------------------------------------------------------------
+
+ // Protected ------------------------------------------------------------------------------------
+
+ // Private --------------------------------------------------------------------------------------
+
+ // Inner classes --------------------------------------------------------------------------------
+
+}
Modified: branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/JCAWrapperTest.java
===================================================================
--- branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/JCAWrapperTest.java 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/JCAWrapperTest.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -28,12 +28,9 @@
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.TextMessage;
-import javax.jms.DeliveryMode;
-import javax.jms.MessageConsumer;
import javax.naming.InitialContext;
import javax.transaction.Transaction;
import javax.transaction.UserTransaction;
-import javax.management.ObjectName;
import org.jboss.test.messaging.MessagingTestCase;
import org.jboss.test.messaging.tools.ServerManagement;
@@ -158,209 +155,8 @@
}
}
- /**
- * Test case for http://jira.jboss.org/jira/browse/JBMESSAGING-410.
- */
- public void testSendNoGlobalTransaction() throws Exception
- {
- Transaction suspended = null;
+
- try
- {
- ServerManagement.deployQueue("MyQueue");
-
- // make sure there's no active JTA transaction
-
- suspended = TransactionManagerLocator.getInstance().locate().suspend();
-
- // send a message to the queue, using a JCA wrapper
-
- Queue queue = (Queue)ic.lookup("queue/MyQueue");
-
- ConnectionFactory mcf = (ConnectionFactory)ic.lookup("java:/JCAConnectionFactory");
-
- Connection conn = mcf.createConnection();
-
- Session s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageProducer p = s.createProducer(queue);
- p.setDeliveryMode(DeliveryMode.PERSISTENT);
- Message m = s.createTextMessage("one");
-
- p.send(m);
-
- log.debug("message sent");
-
- conn.close();
-
- // receive the message
- ConnectionFactory cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
- conn = cf.createConnection();
- conn.start();
- s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageConsumer c = s.createConsumer(queue);
- TextMessage rm = (TextMessage)c.receive(1000);
-
- assertEquals("one", rm.getText());
-
- conn.close();
- }
- finally
- {
- ServerManagement.undeployQueue("MyQueue");
-
- if (suspended != null)
- {
- TransactionManagerLocator.getInstance().locate().resume(suspended);
- }
- }
- }
-
- /**
- * Test case for http://jira.jboss.org/jira/browse/JBMESSAGING-410. Use a cached connection that
- * was initally enroled in a global transaction.
- */
- public void testSendNoGlobalTransaction2() throws Exception
- {
-
- Transaction suspended = TransactionManagerLocator.getInstance().locate().suspend();
-
- try
- {
-
- ConnectionFactory mcf = (ConnectionFactory)ic.lookup("java:/JCAConnectionFactory");
- Connection conn = mcf.createConnection();
- conn.start();
-
- UserTransaction ut = ServerManagement.getUserTransaction();
-
- ut.begin();
-
- Session s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageProducer p = s.createProducer(queue);
- Message m = s.createTextMessage("one");
-
- p.send(m);
-
- ut.commit();
-
- conn.close();
-
- ConnectionFactory cf = (ConnectionFactory)ic.lookup("ConnectionFactory");
- conn = cf.createConnection();
- s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
- conn.start();
-
- TextMessage rm = (TextMessage)s.createConsumer(queue).receive(500);
-
- assertEquals("one", rm.getText());
-
- conn.close();
-
- // make sure there's no active JTA transaction
-
- assertNull(TransactionManagerLocator.getInstance().locate().getTransaction());
-
- // send a message to the queue, using a JCA wrapper
-
- mcf = (ConnectionFactory)ic.lookup("java:/JCAConnectionFactory");
-
- conn = mcf.createConnection();
-
- s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
- p = s.createProducer(queue);
- p.setDeliveryMode(DeliveryMode.PERSISTENT);
- m = s.createTextMessage("one");
-
- p.send(m);
-
- conn.close();
-
- // receive the message
- cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
- conn = cf.createConnection();
- conn.start();
- s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageConsumer c = s.createConsumer(queue);
- rm = (TextMessage)c.receive(1000);
-
- assertEquals("one", rm.getText());
-
- conn.close();
- }
- finally
- {
- if (suspended != null)
- {
- TransactionManagerLocator.getInstance().locate().resume(suspended);
- }
- }
- }
-
- /**
- * Test case for http://jira.jboss.org/jira/browse/JBMESSAGING-520.
- */
- public void testReceiveNoGlobalTransaction() throws Exception
- {
- try
- {
- ServerManagement.deployQueue("MyQueue2");
-
- // send a message to the queue
-
- ConnectionFactory cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
- Queue queue = (Queue)ic.lookup("queue/MyQueue2");
- Connection conn = cf.createConnection();
- Session s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageProducer p = s.createProducer(queue);
- p.setDeliveryMode(DeliveryMode.PERSISTENT);
- Message m = s.createTextMessage("one");
- p.send(m);
- conn.close();
-
- // make sure there's no active JTA transaction
-
- Transaction suspended = TransactionManagerLocator.getInstance().locate().suspend();
-
- try
- {
- // using a JCA wrapper
-
- ConnectionFactory mcf = (ConnectionFactory)ic.lookup("java:/JCAConnectionFactory");
- conn = mcf.createConnection();
- conn.start();
-
- // no active JTA transaction here
-
- s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageConsumer c = s.createConsumer(queue);
-
- // this method should send an untransacted acknowledgment that should clear the delivery
- TextMessage rm = (TextMessage)c.receive(1000);
-
- assertEquals("one", rm.getText());
-
- conn.close();
-
- // now the queue should be empty
- ObjectName on = new ObjectName("jboss.messaging.destination:service=Queue,name=MyQueue2");
- Integer count = (Integer)ServerManagement.getAttribute(on, "MessageCount");
- assertEquals(0, count.intValue());
- }
- finally
- {
-
- if (suspended != null)
- {
- TransactionManagerLocator.getInstance().locate().resume(suspended);
- }
- }
- }
- finally
- {
- ServerManagement.undeployQueue("MyQueue2");
- }
- }
-
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
Modified: branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/JMSTest.java
===================================================================
--- branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/JMSTest.java 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/JMSTest.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -49,22 +49,22 @@
*/
public class JMSTest extends MessagingTestCase
{
- // Constants -----------------------------------------------------
+ // Constants ------------------------------------------------------------------------------------
- // Static --------------------------------------------------------
+ // Static ---------------------------------------------------------------------------------------
- // Attributes ----------------------------------------------------
+ // Attributes -----------------------------------------------------------------------------------
InitialContext ic;
- // Constructors --------------------------------------------------
+ // Constructors ---------------------------------------------------------------------------------
public JMSTest(String name)
{
super(name);
}
- // Public --------------------------------------------------------
+ // Public ---------------------------------------------------------------------------------------
public void setUp() throws Exception
{
@@ -87,6 +87,41 @@
super.tearDown();
}
+
+
+ public void testSimplest() throws Exception
+ {
+ ConnectionFactory cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
+ Queue queue = (Queue)ic.lookup("/queue/JMSTestQueue");
+
+ Connection conn = null;
+
+ try
+ {
+ conn = cf.createConnection();
+ conn.start();
+
+ Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageProducer prod = session.createProducer(queue);
+ MessageConsumer cons = session.createConsumer(queue);
+
+ TextMessage m = session.createTextMessage("simplest");
+
+ prod.send(m);
+
+ TextMessage rm = (TextMessage)cons.receive(5000);
+
+ assertEquals("simplest", rm.getText());
+ }
+ finally
+ {
+ if (conn != null)
+ {
+ conn.close();
+ }
+ }
+ }
public void test_NonPersistent_NonTransactional() throws Exception
{
@@ -232,7 +267,6 @@
conn.close();
}
-
public void test_NonPersistent_Transactional_Acknowledgment() throws Exception
{
ConnectionFactory cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
@@ -402,14 +436,12 @@
conn.close();
}
+ // Package protected ----------------------------------------------------------------------------
+ // Protected ------------------------------------------------------------------------------------
- // Package protected ---------------------------------------------
+ // Private --------------------------------------------------------------------------------------
- // Protected -----------------------------------------------------
+ // Inner classes --------------------------------------------------------------------------------
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
}
Modified: branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/MessageConsumerTest.java
===================================================================
--- branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/MessageConsumerTest.java 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/MessageConsumerTest.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -2589,6 +2589,8 @@
Message m = durable4.receive(1000);
assertNull(m);
+
+ conn3.close();
}
finally
Modified: branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/QueueTest.java
===================================================================
--- branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/QueueTest.java 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/QueueTest.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -43,39 +43,39 @@
public class QueueTest extends MessagingTestCase
{
// Constants -----------------------------------------------------
-
+
// Static --------------------------------------------------------
-
+
// Attributes ----------------------------------------------------
protected InitialContext ic;
protected ConnectionFactory cf;
// Constructors --------------------------------------------------
-
+
public QueueTest(String name)
{
super(name);
}
-
+
// TestCase overrides -------------------------------------------
-
+
public void setUp() throws Exception
{
- super.setUp();
-
+ super.setUp();
+
ServerManagement.start("all");
-
-
+
+
ic = new InitialContext(ServerManagement.getJNDIEnvironment());
cf = (JBossConnectionFactory)ic.lookup("/ConnectionFactory");
-
+
ServerManagement.undeployQueue("TestQueue");
ServerManagement.deployQueue("TestQueue");
log.debug("setup done");
}
-
+
public void tearDown() throws Exception
{
ServerManagement.undeployQueue("TestQueue");
@@ -83,8 +83,8 @@
log.debug("tear down done");
}
-
-
+
+
// Public --------------------------------------------------------
/**
@@ -117,6 +117,62 @@
}
}
+ /**
+ * The simplest possible queue test.
+ */
+ public void testRedeployQueue() throws Exception
+ {
+ Queue queue = (Queue)ic.lookup("/queue/TestQueue");
+
+ Connection conn = cf.createConnection();
+
+ try
+ {
+ Session s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageProducer p = s.createProducer(queue);
+ MessageConsumer c = s.createConsumer(queue);
+ conn.start();
+
+ for (int i = 0; i < 500; i++)
+ {
+ p.send(s.createTextMessage("payload " + i));
+ }
+
+ //ServerManagement.undeployQueue("TestQueue");
+
+ log.info("Stopping server");
+ ServerManagement.stopServerPeer();
+
+ log.info("Starting server");
+ ServerManagement.startServerPeer();
+ ServerManagement.deployQueue("TestQueue");
+
+ ic = new InitialContext(ServerManagement.getJNDIEnvironment());
+ cf = (JBossConnectionFactory)ic.lookup("/ConnectionFactory");
+
+ conn = cf.createConnection();
+ s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ p = s.createProducer(queue);
+ c = s.createConsumer(queue);
+ conn.start();
+
+ for (int i = 0; i < 500; i++)
+ {
+ TextMessage message = (TextMessage)c.receive(3000);
+ assertNotNull(message);
+ assertNotNull(message.getJMSDestination());
+ }
+
+ }
+ finally
+ {
+ if (conn != null)
+ {
+ conn.close();
+ }
+ }
+ }
+
public void testQueueName() throws Exception
{
Queue queue = (Queue)ic.lookup("/queue/TestQueue");
@@ -124,12 +180,12 @@
}
// Package protected ---------------------------------------------
-
+
// Protected -----------------------------------------------------
-
+
// Private -------------------------------------------------------
-
+
// Inner classes -------------------------------------------------
-
+
}
Modified: branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/XATest.java
===================================================================
--- branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/XATest.java 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/XATest.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -38,8 +38,12 @@
import javax.transaction.xa.XAResource;
import javax.transaction.xa.Xid;
+import org.jboss.jms.client.JBossConnection;
import org.jboss.jms.client.JBossConnectionFactory;
+import org.jboss.jms.client.delegate.ClientConnectionDelegate;
+import org.jboss.jms.client.state.ConnectionState;
import org.jboss.jms.tx.MessagingXAResource;
+import org.jboss.jms.tx.ResourceManager;
import org.jboss.test.messaging.MessagingTestCase;
import org.jboss.test.messaging.util.TransactionManagerLocator;
import org.jboss.test.messaging.tools.ServerManagement;
@@ -58,11 +62,11 @@
*/
public class XATest extends MessagingTestCase
{
- // Constants -----------------------------------------------------
+ // Constants ------------------------------------------------------------------------------------
- // Static --------------------------------------------------------
+ // Static ---------------------------------------------------------------------------------------
- // Attributes ----------------------------------------------------
+ // Attributes -----------------------------------------------------------------------------------
protected InitialContext initialContext;
@@ -72,14 +76,14 @@
protected Transaction suspendedTx;
- // Constructors --------------------------------------------------
+ // Constructors ---------------------------------------------------------------------------------
public XATest(String name)
{
super(name);
}
- // TestCase overrides -------------------------------------------
+ // TestCase overrides --------------------------------------------------------------------------
public void setUp() throws Exception
{
@@ -137,13 +141,14 @@
- // Public --------------------------------------------------------
+ // Public ---------------------------------------------------------------------------------------
//http://jira.jboss.com/jira/browse/JBMESSAGING-721
public void testConvertFromLocalTx() throws Exception
{
if (ServerManagement.isRemote()) return;
+
Connection conn = null;
XAConnection xaConn = null;
@@ -196,7 +201,6 @@
//Now we enlist the session in an xa transaction
- log.info("enlisting");
XAResource res = xaSession.getXAResource();
tm.begin();
@@ -204,18 +208,20 @@
Transaction tx = tm.getTransaction();
tx.enlistResource(res);
- //This should cause the work done previously to be converted into work done in the xa transaction
- //this is what an MDB does
- //There is a difficulty in transactional delivery with an MDB.
- //The message is received from the destination and then sent to the mdb container so
- //it can call onMessage.
- //For transactional delivery the receipt of the message should be in a transaction but by the time
- //the mdb container is invoked the message has already been received it is too late - the message
- //has already been received and passed on (see page 199 (chapter 5 JMS and Transactions, section "Application Server Integration"
- //of Mark Little's book Java Transaction processing
- //for a discussion of how different app serves deal with this)
- //The way jboss messaging (and jboss mq) deals with this is to convert any work done
- //prior to when the xasession is enlisted in the tx, into work done in the xa tx
+ // This should cause the work done previously to be converted into work done in the XA
+ // transaction. This is what an MDB does. There is a difficulty in transactional delivery
+ // with an MDB. The message is received from the destination and then sent to the MDB
+ // container so it can call onMessage().
+ // For transactional delivery the receipt of the message should be in a transaction but by
+ // the time the MDB container is invoked the message has already been received it is too
+ // late - the message has already been received and passed on (see page 199 (chapter 5 JMS
+ // and Transactions, section "Application Server Integration" of Mark Little's book Java
+ // Transaction processing for a discussion of how different app serves deal with this).
+ // The way JBoss Messaging (and JBossMQ) deals with this is to convert any work done prior
+ // to when the XASession is enlisted in the transaction, into work done in the XA
+ // transaction
+
+ tx.delistResource(res, XAResource.TMSUCCESS);
//Now rollback the tx - this should cause redelivery of the two messages
tx.rollback();
@@ -255,6 +261,7 @@
{
if (ServerManagement.isRemote()) return;
+
Connection conn = null;
XAConnection xaConn = null;
@@ -289,7 +296,6 @@
//Now we enlist the session in an xa transaction
- log.info("enlisting");
XAResource res = xaSession.getXAResource();
tm.begin();
@@ -297,21 +303,13 @@
Transaction tx = tm.getTransaction();
tx.enlistResource(res);
+ tx.delistResource(res, XAResource.TMSUCCESS);
+
//Then we do a commit
tm.commit();
+
+ //Then we receive the messages outside the tx
- //And enlist again
-
- tx = tm.getTransaction();
-
-
- tm.begin();
-
- tx = tm.getTransaction();
- tx.enlistResource(res);
-
- //Then we receive the messages
-
TextMessage rm1 = (TextMessage)cons.receive(1000);
assertNotNull(rm1);
@@ -327,6 +325,18 @@
Message rm3 = cons.receive(1000);
assertNull(rm3);
+
+ //And enlist again - this should convert the work done in the local tx
+ //into the global branch
+
+ tx = tm.getTransaction();
+
+ tm.begin();
+
+ tx = tm.getTransaction();
+ tx.enlistResource(res);
+
+ tx.delistResource(res, XAResource.TMSUCCESS);
//Now rollback the tx - this should cause redelivery of the two messages
tx.rollback();
@@ -367,6 +377,7 @@
{
if (ServerManagement.isRemote()) return;
+
Connection conn = null;
XAConnection xaConn = null;
@@ -401,26 +412,19 @@
//Now we enlist the session in an xa transaction
- log.info("enlisting");
XAResource res = xaSession.getXAResource();
tm.begin();
Transaction tx = tm.getTransaction();
tx.enlistResource(res);
+ tx.delistResource(res, XAResource.TMSUCCESS);
//Then we do a rollback
- tm.rollback();
+ tm.rollback();
- tm.begin();
-
- //And enlist again
+ //Then we receive the messages outside the global tx
- tx = tm.getTransaction();
- tx.enlistResource(res);
-
- //Then we receive the messages
-
TextMessage rm1 = (TextMessage)cons.receive(1000);
assertNotNull(rm1);
@@ -436,6 +440,16 @@
Message rm3 = cons.receive(1000);
assertNull(rm3);
+
+ tm.begin();
+
+ //And enlist again - the work should then be converted into the global tx branch
+
+ tx = tm.getTransaction();
+
+ tx.enlistResource(res);
+
+ tx.delistResource(res, XAResource.TMSUCCESS);
//Now rollback the tx - this should cause redelivery of the two messages
tx.rollback();
@@ -470,8 +484,72 @@
}
}
-
-
+
+ //See http://jira.jboss.com/jira/browse/JBMESSAGING-638
+ public void testResourceManagerMemoryLeakOnRollback() throws Exception
+ {
+ if (ServerManagement.isRemote()) return;
+
+
+ XAConnection xaConn = null;
+
+ try
+ {
+ xaConn = cf.createXAConnection();
+
+ JBossConnection jbConn = (JBossConnection)xaConn;
+
+ ClientConnectionDelegate del = (ClientConnectionDelegate)jbConn.getDelegate();
+
+ ConnectionState state = (ConnectionState)del.getState();
+
+ ResourceManager rm = state.getResourceManager();
+
+ XASession xaSession = xaConn.createXASession();
+
+ xaConn.start();
+
+ XAResource res = xaSession.getXAResource();
+
+ XAResource dummy = new DummyXAResource();
+
+ for (int i = 0; i < 100; i++)
+ {
+ tm.begin();
+
+ Transaction tx = tm.getTransaction();
+
+ tx.enlistResource(res);
+
+ tx.enlistResource(dummy);
+
+ assertEquals(1, rm.size());
+
+ tx.delistResource(res, XAResource.TMSUCCESS);
+
+ tx.delistResource(dummy, XAResource.TMSUCCESS);
+
+ tm.rollback();
+ }
+
+ assertEquals(1, rm.size());
+
+ xaConn.close();
+
+ xaConn = null;
+
+ assertEquals(0, rm.size());
+
+ }
+ finally
+ {
+ if (xaConn != null)
+ {
+ xaConn.close();
+ }
+ }
+ }
+
public void test2PCSendCommit1PCOptimization() throws Exception
{
if (ServerManagement.isRemote()) return;
@@ -1399,6 +1477,8 @@
TextMessage r3 = (TextMessage)cons.receive(MIN_TIMEOUT);
assertNull(r3);
+
+
}
finally
{
@@ -2562,13 +2642,13 @@
}
- // Package protected ---------------------------------------------
+ // Package protected ----------------------------------------------------------------------------
- // Protected -----------------------------------------------------
+ // Protected ------------------------------------------------------------------------------------
- // Private -------------------------------------------------------
+ // Private --------------------------------------------------------------------------------------
- // Inner classes -------------------------------------------------
+ // Inner classes --------------------------------------------------------------------------------
static class DummyXAResource implements XAResource
{
Modified: branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/server/plugin/JDBCChannelMapperTest.java
===================================================================
--- branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/server/plugin/JDBCChannelMapperTest.java 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/server/plugin/JDBCChannelMapperTest.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -23,6 +23,9 @@
import java.sql.Connection;
import java.sql.PreparedStatement;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.HashMap;
import javax.naming.InitialContext;
import javax.sql.DataSource;
@@ -35,13 +38,18 @@
import org.jboss.jms.server.DestinationManager;
import org.jboss.jms.server.plugin.contract.ChannelMapper;
import org.jboss.jms.server.subscription.DurableSubscription;
+import org.jboss.jms.message.JBossTextMessage;
import org.jboss.messaging.core.local.CoreDestination;
import org.jboss.messaging.core.local.Queue;
import org.jboss.messaging.core.local.Topic;
import org.jboss.messaging.core.persistence.JDBCUtil;
import org.jboss.messaging.core.plugin.contract.MessageStore;
import org.jboss.messaging.core.plugin.contract.PersistenceManager;
+import org.jboss.messaging.core.Channel;
+import org.jboss.messaging.core.Message;
+import org.jboss.messaging.core.MessageReference;
import org.jboss.test.messaging.MessagingTestCase;
+import org.jboss.test.messaging.core.SimpleChannel;
import org.jboss.test.messaging.tools.ServerManagement;
import org.jboss.tm.TransactionManagerService;
import org.jboss.util.id.GUID;
@@ -50,9 +58,10 @@
* These tests must not be run in remote mode!
*
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>1.1</tt>
+ * @author <a href="mailto:Galder.Zamarreno at jboss.com">Galder Zamarreno</a>
+ * @version <tt>$Release$</tt>
*
- * JDBCChannelMapperTest.java,v 1.1 2006/02/28 16:48:15 timfox Exp
+ * $Id$
*/
public class JDBCChannelMapperTest extends MessagingTestCase
{
@@ -99,6 +108,54 @@
super.tearDown();
}
+ // I had to place this test as the firs one one the list..
+ // it's dependent on the channelMapper empty..
+ // It won't affect the other tests
+ public void testSendRedeployAndConsume() throws Throwable
+ {
+ /* Deploy 'paradise' as destination queue */
+ channelMapper.deployCoreDestination(true, "paradise", ms, pm, null, 100, 20, 10);
+ /* Deploy 'earth' as queue to reply to */
+ channelMapper.deployCoreDestination(true, "earth", ms, pm, null, 100, 20, 10);
+
+ Channel channel = new SimpleChannel(0, ms);
+ /* Create a message for 'paradise' queue destination */
+ Message[] m = createMessages(1);
+ List refs = new ArrayList();
+ MessageReference ref1 = ms.reference(m[0]);
+
+ ref1.setOrdering(11);
+ refs.add(ref1);
+
+ /* We persist the message */
+ pm.addReferences(channel.getChannelID(), refs, false);
+
+ /* Delete the message from memory so that on redeployment, messaging is forced
+ * to retrieve it from the database */
+ ms.forgetMessage(0);
+
+ log.info("********************** UnDeploying coreDestination");
+ channelMapper.undeployCoreDestination(true, "paradise");
+ channelMapper.undeployCoreDestination(true, "earth");
+
+ log.info("********************** Deploying coreDestination");
+
+ /* We redeploy the target destination which will load the message from the database */
+ channelMapper.deployCoreDestination(true, "paradise", ms, pm, null, 100, 20, 10);
+
+ JBossDestination jd = channelMapper.getJBossDestination(0);
+ Queue q = (Queue) channelMapper.getCoreDestination(jd);
+
+ /* Browse the pending messages */
+ List l = q.browse();
+ JBossTextMessage message = (JBossTextMessage)l.get(0);
+ /* Browse the pending messages. There's only one and its destination should not be
+ * null, in fact, it should be 'paradise' */
+ assertNotNull(message.getJMSDestination());
+ assertEquals("Destination should be 'paradise'","paradise",
+ ((JBossDestination)message.getJMSDestination()).getName());
+ }
+
public void testCreateGetRemoveDurableSubscription() throws Exception
{
String topicName = new GUID().toString();
@@ -340,14 +397,41 @@
assertEquals(cd4.getId(), cd2.getId());
}
-
-
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
// Private -------------------------------------------------------
+ private Message[] createMessages(int num) throws Throwable
+ {
+ //Generate some messages with a good range of attribute values
+ Message[] messages = new Message[num];
+ for (int i = 0; i < num; i++)
+ {
+ messages[i] = createMessage((byte)i, true);
+ }
+ return messages;
+ }
+
+ private Message createMessage(byte i, boolean reliable) throws Throwable
+ {
+ return new JBossTextMessage(i,
+ reliable,
+ System.currentTimeMillis() + 1000 * 60 * 60,
+ System.currentTimeMillis(),
+ (byte)(i % 10),
+ new HashMap(),
+ "hello".getBytes(),
+ 0,
+ "msg",
+ "1",
+ "1".getBytes(),
+ new JBossQueue("paradise"),
+ new JBossQueue("earth"),
+ new HashMap());
+ }
+
// Inner classes -------------------------------------------------
}
Property changes on: branches/Branch_1_0/tests/src/org/jboss/test/messaging/jms/server/plugin/JDBCChannelMapperTest.java
___________________________________________________________________
Name: svn:keywords
+ Id LastChangedDate Author Revision
Modified: branches/Branch_1_0/tests/src/org/jboss/test/messaging/tools/jmx/MockJBossSecurityManager.java
===================================================================
--- branches/Branch_1_0/tests/src/org/jboss/test/messaging/tools/jmx/MockJBossSecurityManager.java 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/tests/src/org/jboss/test/messaging/tools/jmx/MockJBossSecurityManager.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -22,29 +22,39 @@
package org.jboss.test.messaging.tools.jmx;
import java.security.Principal;
+import java.security.acl.Group;
import java.util.Iterator;
import java.util.Set;
+import java.util.HashSet;
import javax.security.auth.Subject;
import org.jboss.logging.Logger;
import org.jboss.security.AuthenticationManager;
import org.jboss.security.RealmMapping;
+import org.jboss.security.SecurityAssociation;
+import org.jboss.security.NobodyPrincipal;
+import org.jboss.security.AnybodyPrincipal;
+import org.jboss.security.SimpleGroup;
+import org.jboss.security.SimplePrincipal;
-/* Mock Security manager for testing JMS security.
- *
- *
+/**
+ * Mock Security manager for testing JMS security.
+ *
* @author <a href="tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
*
*/
public class MockJBossSecurityManager implements AuthenticationManager, RealmMapping
{
public static final String TEST_SECURITY_DOMAIN = "messaging-securitydomain";
-
+
private static final Logger log = Logger.getLogger(MockJBossSecurityManager.class);
-
+
+ private boolean simulateJBossJaasSecurityManager;
+
//Authentication Manager Implementation
-
+
public String getSecurityDomain()
{
return TEST_SECURITY_DOMAIN;
@@ -55,50 +65,94 @@
throw new UnsupportedOperationException();
}
- public boolean isValid(Principal principal, Object credential,
- Subject activeSubject)
+ public boolean isValid(Principal principal, Object credential, Subject activeSubject)
{
if (log.isTraceEnabled()) { log.trace("principal:" + principal + " credential:" + credential); }
-
+
+ boolean isValid = false;
+
String username = principal == null ? null : principal.getName();
char[] passwordChars = (char[])credential;
String password = passwordChars == null ? null : new String(passwordChars);
-
+
if (username == null)
{
- return true;
- }
+ isValid = true;
+
+ if (isValid && simulateJBossJaasSecurityManager)
+ {
+ // modify the activeSubject, need to add to it its current roles
+ // TODO: this is currently impmented in a messy way, this and doesUserHaveRole()
+ // implementation must be coalesced
+ addRole(activeSubject, "guest");
+ }
+ }
else if ("guest".equals(username))
{
- return "guest".equals(password);
+ isValid = "guest".equals(password);
+
+ if (isValid && simulateJBossJaasSecurityManager)
+ {
+ // modify the activeSubject, need to add to it its current roles
+ // TODO: this is currently impmented in a messy way, this and doesUserHaveRole()
+ // implementation must be coalesced
+ addRole(activeSubject, "guest");
+ }
}
else if ("john".equals(username))
{
- return "needle".equals(password);
+ isValid = "needle".equals(password);
+
+ if (isValid && simulateJBossJaasSecurityManager)
+ {
+ // modify the activeSubject, need to add to it its current roles
+ // TODO: this is currently impmented in a messy way, this and doesUserHaveRole()
+ // implementation must be coalesced
+ addRole(activeSubject, "publisher");
+ addRole(activeSubject, "durpublisher");
+ addRole(activeSubject, "def");
+ }
}
else if ("nobody".equals(username))
{
- return "nobody".equals(password);
+ isValid = "nobody".equals(password);
+
+ if (isValid && simulateJBossJaasSecurityManager)
+ {
+ // modify the activeSubject, need to add to it its current roles
+ // TODO: this is currently impmented in a messy way, this and doesUserHaveRole()
+ // implementation must be coalesced
+ addRole(activeSubject, "noacc");
+ }
}
else if ("dynsub".equals(username))
{
- return "dynsub".equals(password);
+ isValid = "dynsub".equals(password);
+
+ if (isValid && simulateJBossJaasSecurityManager)
+ {
+ // modify the activeSubject, need to add to it its current roles
+ // TODO: this is currently impmented in a messy way, this and doesUserHaveRole()
+ // implementation must be coalesced
+ addRole(activeSubject, "publisher");
+ addRole(activeSubject, "durpublisher");
+ }
}
else
{
- return false;
+ isValid = false;
}
+
+ return isValid;
}
-
public Subject getActiveSubject()
{
throw new UnsupportedOperationException();
}
+ // RealmMapping implementation
- //RealmMapping implementation
-
public Principal getPrincipal(Principal principal)
{
throw new UnsupportedOperationException();
@@ -117,47 +171,163 @@
}
return false;
}
-
-
+
public boolean doesUserHaveRole(Principal principal, Set roles)
- {
- String username = principal == null ? "guest" : principal.getName();
-
- if (log.isTraceEnabled())
+ {
+ // introduced the possiblity to "simulate" JaasSecurityManager behavior, which is ingnoring
+ // the principal passed as argument and looking at thread context for active subject; this
+ // would allow us to catch some problems earlier at functional testsuite level, and not
+ // wait for integration or smoke test. However, the "correct" place for this kind of test
+ // is at integration testsuite level.
+
+ if (simulateJBossJaasSecurityManager)
{
- log.trace("doesUserHaveRole:" + username);
- }
-
- if ("guest".equals(username))
- {
- return containsRole("guest", roles);
+ boolean hasRole = false;
+ // check that the caller is authenticated to the current thread
+ Subject subject = SecurityAssociation.getSubject();
+
+ if (subject != null)
+ {
+ // Check the caller's roles
+ Group subjectRoles = getSubjectRoles(subject);
+ if (subjectRoles != null)
+ {
+ Iterator iter = roles.iterator();
+ while (!hasRole && iter.hasNext())
+ {
+ Principal role = (Principal)iter.next();
+ hasRole = doesRoleGroupHaveRole(role, subjectRoles);
+ }
+ }
+ }
+ return hasRole;
}
- else if ("john".equals(username))
+ else
{
- return containsRole("publisher", roles) ||
- containsRole("durpublisher", roles) ||
- containsRole("def", roles);
- }
- else if ("dynsub".equals(username))
- {
- return containsRole("publisher", roles)||
+ // "alternate" MockJBossSecurityManager behavior, we actually look at 'principal' passed as
+ // parameter
+
+ String username = principal == null ? "guest" : principal.getName();
+
+ if (log.isTraceEnabled())
+ {
+ log.trace("doesUserHaveRole:" + username);
+ }
+
+ if ("guest".equals(username))
+ {
+ return containsRole("guest", roles);
+ }
+ else if ("john".equals(username))
+ {
+ return containsRole("publisher", roles) ||
+ containsRole("durpublisher", roles) ||
+ containsRole("def", roles);
+ }
+ else if ("dynsub".equals(username))
+ {
+ return containsRole("publisher", roles)||
containsRole("durpublisher", roles);
+ }
+ else if ("nobody".equals(username))
+ {
+ return containsRole("noacc", roles);
+ }
+ else
+ {
+ return false;
+ }
}
- else if ("nobody".equals(username))
+ }
+
+ public Set getUserRoles(Principal principal)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setSimulateJBossJaasSecurityManager(boolean b)
+ {
+ simulateJBossJaasSecurityManager = b;
+ }
+
+ public boolean isSimulateJBossJaasSecurityManager()
+ {
+ return simulateJBossJaasSecurityManager;
+ }
+
+ /**
+ * Copied from JaasSecurityManager.
+ */
+ private Group getSubjectRoles(Subject subject)
+ {
+ Set subjectGroups = subject.getPrincipals(Group.class);
+ Iterator iter = subjectGroups.iterator();
+ Group roles = null;
+ while (iter.hasNext())
{
- return containsRole("noacc", roles);
+ Group grp = (Group)iter.next();
+ String name = grp.getName();
+ if (name.equals("Roles"))
+ {
+ roles = grp;
+ }
}
- else
+ return roles;
+ }
+
+ /**
+ * Copied from JaasSecurityManager.
+ */
+ private boolean doesRoleGroupHaveRole(Principal role, Group userRoles)
+ {
+ // First check that role is not a NobodyPrincipal
+ if (role instanceof NobodyPrincipal)
{
return false;
}
-
+
+ // Check for inclusion in the user's role set
+ boolean isMember = userRoles.isMember(role);
+ if (!isMember)
+ {
+ // Check the AnybodyPrincipal special cases
+ isMember = (role instanceof AnybodyPrincipal);
+ }
+
+ return isMember;
}
-
- public Set getUserRoles(Principal principal)
+ private void addRole(Subject subject, String role)
{
- throw new UnsupportedOperationException();
+ Set groups = subject.getPrincipals(Group.class);
+
+ if(groups == null || groups.isEmpty())
+ {
+ Group g = new SimpleGroup("Roles");
+ subject.getPrincipals().add(g);
+ groups = new HashSet();
+ groups.add(g);
+ }
+
+ Group roles = null;
+
+ for(Iterator i = groups.iterator(); i.hasNext(); )
+ {
+ Group g = (Group)i.next();
+ if ("Roles".equals(g.getName()))
+ {
+ roles = g;
+ }
+ }
+
+ if (roles == null)
+ {
+ roles = new SimpleGroup("Roles");
+ subject.getPrincipals().add(roles);
+ }
+
+ roles.addMember(new SimplePrincipal(role));
+
}
}
\ No newline at end of file
Copied: branches/Branch_1_0/tests/src/org/jboss/test/messaging/tools/misc (from rev 2261, branches/Branch_1_0_1_SP/tests/src/org/jboss/test/messaging/tools/misc)
Deleted: branches/Branch_1_0/tests/src/org/jboss/test/messaging/tools/misc/ConfigurableSecurityManager.java
===================================================================
--- branches/Branch_1_0_1_SP/tests/src/org/jboss/test/messaging/tools/misc/ConfigurableSecurityManager.java 2007-02-11 09:04:09 UTC (rev 2261)
+++ branches/Branch_1_0/tests/src/org/jboss/test/messaging/tools/misc/ConfigurableSecurityManager.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -1,143 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-
-package org.jboss.test.messaging.tools.misc;
-
-import java.security.Permission;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.StringTokenizer;
-
-/**
- * A configurable SecurityManager, that, once installed, can selectively allow or disallow various
- * permissions.
- *
- * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
- * @version <tt>$Revision$</tt>
- * $Id$
- */
-public class ConfigurableSecurityManager extends SecurityManager
-{
- // Constants ------------------------------------------------------------------------------------
-
- // Static ---------------------------------------------------------------------------------------
-
- // Attributes -----------------------------------------------------------------------------------
-
- private List disallowing;
-
- // Constructors ---------------------------------------------------------------------------------
-
- public ConfigurableSecurityManager()
- {
- disallowing = new ArrayList();
- }
-
- // SecurityManager overrides --------------------------------------------------------------------
-
- public void checkPermission(Permission perm)
- {
- for(Iterator i = disallowing.iterator(); i.hasNext(); )
- {
- PermissionActionHolder pat = (PermissionActionHolder)i.next();
- Class deniedPermissionClass = pat.getPermissionClass();
- String deniedAction = pat.getAction();
-
- if (!deniedPermissionClass.isAssignableFrom(perm.getClass()))
- {
- continue;
- }
-
- StringTokenizer st = new StringTokenizer(perm.getActions(), ", ");
-
- if (!st.hasMoreTokens())
- {
- throw new SecurityException(this + " does not allow " + perm);
- }
-
- for(; st.hasMoreTokens(); )
- {
- String action = st.nextToken();
- if (deniedAction.equals(action))
- {
- throw new SecurityException(
- this + " does not allow " + perm + ", action " + action);
- }
- }
- }
- }
-
- // Public ---------------------------------------------------------------------------------------
-
- public void dissalow(Class permissionClass, String action)
- {
- if (!Permission.class.isAssignableFrom(permissionClass))
- {
- throw new IllegalArgumentException(permissionClass + " is not a Permission");
- }
-
- disallowing.add(new PermissionActionHolder(permissionClass, action));
- }
-
- public void clear()
- {
- disallowing.clear();
- }
-
- public String toString()
- {
- return "ConfigurableSecurityManager[" +
- Integer.toHexString(System.identityHashCode(this)) + "]";
- }
-
- // Package protected ----------------------------------------------------------------------------
-
- // Protected ------------------------------------------------------------------------------------
-
- // Private --------------------------------------------------------------------------------------
-
- // Inner classes --------------------------------------------------------------------------------
-
- private class PermissionActionHolder
- {
- private Class permissionClass;
- private String action;
-
- public PermissionActionHolder(Class permissionClass, String action)
- {
- this.permissionClass = permissionClass;
- this.action = action;
- }
-
- public Class getPermissionClass()
- {
- return permissionClass;
- }
-
- public String getAction()
- {
- return action;
- }
- }
-
-}
Copied: branches/Branch_1_0/tests/src/org/jboss/test/messaging/tools/misc/ConfigurableSecurityManager.java (from rev 2261, branches/Branch_1_0_1_SP/tests/src/org/jboss/test/messaging/tools/misc/ConfigurableSecurityManager.java)
===================================================================
--- branches/Branch_1_0/tests/src/org/jboss/test/messaging/tools/misc/ConfigurableSecurityManager.java (rev 0)
+++ branches/Branch_1_0/tests/src/org/jboss/test/messaging/tools/misc/ConfigurableSecurityManager.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -0,0 +1,143 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+
+package org.jboss.test.messaging.tools.misc;
+
+import java.security.Permission;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.StringTokenizer;
+
+/**
+ * A configurable SecurityManager, that, once installed, can selectively allow or disallow various
+ * permissions.
+ *
+ * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
+ * @version <tt>$Revision$</tt>
+ * $Id$
+ */
+public class ConfigurableSecurityManager extends SecurityManager
+{
+ // Constants ------------------------------------------------------------------------------------
+
+ // Static ---------------------------------------------------------------------------------------
+
+ // Attributes -----------------------------------------------------------------------------------
+
+ private List disallowing;
+
+ // Constructors ---------------------------------------------------------------------------------
+
+ public ConfigurableSecurityManager()
+ {
+ disallowing = new ArrayList();
+ }
+
+ // SecurityManager overrides --------------------------------------------------------------------
+
+ public void checkPermission(Permission perm)
+ {
+ for(Iterator i = disallowing.iterator(); i.hasNext(); )
+ {
+ PermissionActionHolder pat = (PermissionActionHolder)i.next();
+ Class deniedPermissionClass = pat.getPermissionClass();
+ String deniedAction = pat.getAction();
+
+ if (!deniedPermissionClass.isAssignableFrom(perm.getClass()))
+ {
+ continue;
+ }
+
+ StringTokenizer st = new StringTokenizer(perm.getActions(), ", ");
+
+ if (!st.hasMoreTokens())
+ {
+ throw new SecurityException(this + " does not allow " + perm);
+ }
+
+ for(; st.hasMoreTokens(); )
+ {
+ String action = st.nextToken();
+ if (deniedAction.equals(action))
+ {
+ throw new SecurityException(
+ this + " does not allow " + perm + ", action " + action);
+ }
+ }
+ }
+ }
+
+ // Public ---------------------------------------------------------------------------------------
+
+ public void dissalow(Class permissionClass, String action)
+ {
+ if (!Permission.class.isAssignableFrom(permissionClass))
+ {
+ throw new IllegalArgumentException(permissionClass + " is not a Permission");
+ }
+
+ disallowing.add(new PermissionActionHolder(permissionClass, action));
+ }
+
+ public void clear()
+ {
+ disallowing.clear();
+ }
+
+ public String toString()
+ {
+ return "ConfigurableSecurityManager[" +
+ Integer.toHexString(System.identityHashCode(this)) + "]";
+ }
+
+ // Package protected ----------------------------------------------------------------------------
+
+ // Protected ------------------------------------------------------------------------------------
+
+ // Private --------------------------------------------------------------------------------------
+
+ // Inner classes --------------------------------------------------------------------------------
+
+ private class PermissionActionHolder
+ {
+ private Class permissionClass;
+ private String action;
+
+ public PermissionActionHolder(Class permissionClass, String action)
+ {
+ this.permissionClass = permissionClass;
+ this.action = action;
+ }
+
+ public Class getPermissionClass()
+ {
+ return permissionClass;
+ }
+
+ public String getAction()
+ {
+ return action;
+ }
+ }
+
+}
Deleted: branches/Branch_1_0/tests/src/org/jboss/test/messaging/util/RemotingTest.java
===================================================================
--- branches/Branch_1_0/tests/src/org/jboss/test/messaging/util/RemotingTest.java 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/tests/src/org/jboss/test/messaging/util/RemotingTest.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -1,403 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.messaging.util;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.Destination;
-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.management.MBeanServer;
-import javax.naming.InitialContext;
-
-import org.jboss.logging.Logger;
-import org.jboss.remoting.Client;
-import org.jboss.remoting.ConnectionListener;
-import org.jboss.remoting.InvocationRequest;
-import org.jboss.remoting.InvokerLocator;
-import org.jboss.remoting.ServerInvocationHandler;
-import org.jboss.remoting.ServerInvoker;
-import org.jboss.remoting.callback.InvokerCallbackHandler;
-import org.jboss.remoting.transport.Connector;
-import org.jboss.test.messaging.MessagingTestCase;
-import org.jboss.test.messaging.tools.ServerManagement;
-
-import EDU.oswego.cs.dl.util.concurrent.Slot;
-
-/**
- * @author <a href="tim.fox at jboss.com">Tim Fox</a>
- * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
- *
- * @version 1.1
- *
- * RemotingTest.java,v 1.1 2006/03/28 14:26:20 timfox Exp
- */
-public class RemotingTest extends MessagingTestCase
-{
- // Constants -----------------------------------------------------
-
- private static final Logger log = Logger.getLogger(RemotingTest.class);
-
- // Static --------------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- InitialContext ic;
- private boolean connListenerCalled;
-
- // Constructors --------------------------------------------------
-
- public RemotingTest(String name)
- {
- super(name);
- }
-
- // Public --------------------------------------------------------
-
- public void testInvokerThreadSafety() throws Exception
- {
- Connector serverConnector = new Connector();
-
- InvokerLocator serverLocator = new InvokerLocator("socket://localhost:9099");
-
- serverConnector.setInvokerLocator(serverLocator.getLocatorURI());
-
- serverConnector.create();
-
- SimpleServerInvocationHandler invocationHandler = new SimpleServerInvocationHandler();
-
- serverConnector.addInvocationHandler("JMS", invocationHandler);
-
- serverConnector.start();
-
- // Create n clients each firing requests in their own thread, using the same locator
-
- try
- {
-
- final int NUM_CLIENTS = 3;
-
- Thread[] threads = new Thread[NUM_CLIENTS];
- Invoker[] invokers = new Invoker[NUM_CLIENTS];
-
- Object obj = new Object();
-
- for (int i = 0; i < NUM_CLIENTS; i++)
- {
- invokers[i] = new Invoker(serverLocator, obj);
- threads[i] = new Thread(invokers[i]);
- threads[i].start();
- }
-
- synchronized (obj)
- {
- obj.wait();
- }
-
- for (int i = 0; i < NUM_CLIENTS; i++)
- {
- if (invokers[i].failed)
- {
- fail();
- for (int j = 0; j < NUM_CLIENTS; j++)
- {
- threads[j].interrupt();
- }
- }
- }
-
- for (int i = 0; i < NUM_CLIENTS; i++)
- {
- threads[i].join();
- }
-
- for (int i = 0; i < NUM_CLIENTS; i++)
- {
- if (invokers[i].failed)
- {
- fail();
- }
- }
- }
- finally
- {
- serverConnector.stop();
- serverConnector.destroy();
- }
- }
-
- /**
- * TODO: Commented out until fixed. See http://jira.jboss.org/jira/browse/JBMESSAGING-287
- */
-// public void testConnectionListener() throws Throwable
-// {
-// // Start a server
-//
-// Connector serverConnector = new Connector();
-//
-// InvokerLocator serverLocator = new InvokerLocator("socket://localhost:9099");
-//
-// serverConnector.setInvokerLocator(serverLocator.getLocatorURI());
-//
-// serverConnector.create();
-//
-// SimpleServerInvocationHandler invocationHandler = new SimpleServerInvocationHandler();
-//
-// serverConnector.addInvocationHandler("JMS", invocationHandler);
-//
-// serverConnector.setLeasePeriod(1000);
-//
-// serverConnector.addConnectionListener(new SimpleConnectionListener());
-//
-// serverConnector.start();
-//
-// try
-// {
-// Client client = new Client(serverLocator);
-//
-// client.connect();
-//
-// Thread.sleep(5000);
-//
-// client.disconnect();
-//
-// // Connection Listener should now be called
-//
-// Thread.sleep(5000);
-//
-// assertTrue(connListenerCalled);
-// }
-// finally
-// {
-// serverConnector.stop();
-// serverConnector.destroy();
-// }
-//
-// }
-
- /**
- * JIRA issue: http://jira.jboss.org/jira/browse/JBMESSAGING-371
- */
- public void testMessageListenerTimeout() throws Exception
- {
- ConnectionFactory cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
- Destination topic = (Destination)ic.lookup("/topic/ATopic");
-
- Connection conn = cf.createConnection();
- Slot slot = new Slot();
-
- Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageConsumer consumer = session.createConsumer(topic);
- consumer.setMessageListener(new SimpleMessageListener(slot));
-
- conn.start();
-
- Connection conn2 = cf.createConnection();
- Session session2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageProducer prod = session2.createProducer(topic);
- Message m = session.createTextMessage("blah");
-
- prod.send(m);
-
- TextMessage rm = (TextMessage)slot.poll(5000);
-
- assertEquals("blah", rm.getText());
-
- // Only for JBoss Remoting > 2.0.0.Beta1
- long sleepTime = ServerInvoker.DEFAULT_TIMEOUT_PERIOD + 60000;
- log.info("sleeping " + (sleepTime / 60000) + " minutes");
-
- Thread.sleep(sleepTime);
-
- log.info("after sleep");
-
- // send the second message. In case of remoting timeout, the callback server won't forward
- // this message to the MessageCallbackHandler, and the test will fail
-
- Message m2 = session.createTextMessage("blah2");
- prod.send(m2);
-
- TextMessage rm2 = (TextMessage)slot.poll(5000);
-
- assertEquals("blah2", rm2.getText());
-
- conn.close();
- conn2.close();
- }
-
-
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- protected void setUp() throws Exception
- {
- super.setUp();
-
- ServerManagement.start("all");
-
- ic = new InitialContext(ServerManagement.getJNDIEnvironment());
-
- ServerManagement.deployTopic("ATopic");
-
- log.debug("setup done");
-
- }
-
- protected void tearDown() throws Exception
- {
- ServerManagement.undeployTopic("ATopic");
-
- ic.close();
-
- super.tearDown();
- }
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
-
- class Invoker implements Runnable
- {
- boolean failed;
- InvokerLocator locator;
- Object o;
- Invoker(InvokerLocator locator, Object o)
- {
- this.locator = locator;
- this.o = o;
- }
- public void run()
- {
- try
- {
- for (int i = 0; i < 5000; i++)
- {
- Client cl = new Client(locator);
- cl.connect();
- cl.invoke("aardvark");
- cl.disconnect();
- }
- synchronized (o)
- {
- o.notify();
- }
- }
- catch (Throwable t)
- {
- failed = true;
- log.error("Caught throwable", t);
- synchronized (o)
- {
- o.notify();
- }
- }
- }
- }
-
- class SimpleConnectionListener implements ConnectionListener
- {
- public void handleConnectionException(Throwable t, Client client)
- {
- connListenerCalled = true;
- }
- }
-
- class SimpleServerInvocationHandler implements ServerInvocationHandler
- {
- InvokerCallbackHandler handler;
-
-
- public void addListener(InvokerCallbackHandler callbackHandler)
- {
- this.handler = callbackHandler;
-
- }
-
- public Object invoke(InvocationRequest invocation) throws Throwable
- {
- //log.info("Received invocation:" + invocation);
-
- return "Sausages";
- }
-
- public void removeListener(InvokerCallbackHandler callbackHandler)
- {
- // FIXME removeListener
-
- }
-
- public void setInvoker(ServerInvoker invoker)
- {
- // FIXME setInvoker
-
- }
-
- public void setMBeanServer(MBeanServer server)
- {
- // FIXME setMBeanServer
-
- }
- }
-
-
- private class SimpleMessageListener implements MessageListener
- {
- private Slot slot;
- private boolean failure;
-
- public SimpleMessageListener(Slot slot)
- {
- this.slot = slot;
- failure = false;
- }
-
- public void onMessage(Message m)
- {
- log.info("received " + m);
- try
- {
- slot.put(m);
- }
- catch(Exception e)
- {
- log.error("failed to put message in slot", e);
- failure = true;
- }
- }
-
- public boolean isFailure()
- {
- return failure;
- }
- }
-
-}
-
-
-
Modified: branches/Branch_1_0/tests/src/org/jboss/test/messaging/util/XMLUtilTest.java
===================================================================
--- branches/Branch_1_0/tests/src/org/jboss/test/messaging/util/XMLUtilTest.java 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/tests/src/org/jboss/test/messaging/util/XMLUtilTest.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -247,6 +247,4 @@
XMLUtil.assertEquivalent(e, convertedAgain);
}
-
-
}
Copied: branches/Branch_1_0/tests/src/org/jboss/test/thirdparty (from rev 2261, branches/Branch_1_0_1_SP/tests/src/org/jboss/test/thirdparty)
Copied: branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/jbosssx (from rev 2261, branches/Branch_1_0_1_SP/tests/src/org/jboss/test/thirdparty/jbosssx)
Deleted: branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/jbosssx/SecurityAssociationTest.java
===================================================================
--- branches/Branch_1_0_1_SP/tests/src/org/jboss/test/thirdparty/jbosssx/SecurityAssociationTest.java 2007-02-11 09:04:09 UTC (rev 2261)
+++ branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/jbosssx/SecurityAssociationTest.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -1,363 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.test.thirdparty.jbosssx;
-
-import org.jboss.test.messaging.MessagingTestCase;
-import org.jboss.test.messaging.tools.ServerManagement;
-import org.jboss.test.messaging.tools.jmx.MockJBossSecurityManager;
-import org.jboss.security.SecurityAssociation;
-import org.jboss.security.SimplePrincipal;
-
-import javax.naming.InitialContext;
-import javax.jms.ConnectionFactory;
-import javax.jms.Queue;
-import javax.jms.Connection;
-import javax.jms.Session;
-import javax.jms.MessageProducer;
-import javax.jms.MessageConsumer;
-import javax.jms.TextMessage;
-import javax.security.auth.Subject;
-import java.security.Principal;
-import java.util.Set;
-import java.util.HashSet;
-import java.util.Collections;
-
-/**
- * Set of tests to insure consistent behavior relative to the JBoss AS security infrastructure.
- * This is just a safety layer, full fledged security tests should be present in the integration
- * test suite.
- *
- * Tests contained by this class are supposed to run only in local environment.
- *
- * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
- * @version <tt>$Revision$</tt>
- * $Id$
- */
-public class SecurityAssociationTest extends MessagingTestCase
-{
- // Constants ------------------------------------------------------------------------------------
-
- // Static ---------------------------------------------------------------------------------------
-
- // Attributes -----------------------------------------------------------------------------------
-
- private InitialContext ic;
-
- // Constructors ---------------------------------------------------------------------------------
-
- public SecurityAssociationTest(String name)
- {
- super(name);
- }
-
- // Public ---------------------------------------------------------------------------------------
-
- /**
- * Test for http://jira.jboss.org/jira/browse/JBMESSAGING-807
- */
- public void testSecurityAssociation() throws Exception
- {
- if(ServerManagement.isRemote())
- {
- fail("This test is supposed to be run in a local configuration");
- }
-
- ConnectionFactory cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
- Queue queue = (Queue)ic.lookup("/queue/TestQueue");
-
- Principal nabopolassar = new SimplePrincipal("nabopolassar");
- Set principals = new HashSet();
- principals.add(nabopolassar);
- Subject subject =
- new Subject(false, principals, Collections.EMPTY_SET, Collections.EMPTY_SET);
- Principal nebuchadrezzar = new SimplePrincipal("nebuchadrezzar");
-
- SecurityAssociation.pushSubjectContext(subject, nebuchadrezzar, "xexe");
-
- Connection conn = null;
-
- try
- {
- conn = cf.createConnection();
- conn.start();
-
- Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageProducer prod = session.createProducer(queue);
- MessageConsumer cons = session.createConsumer(queue);
-
- TextMessage m = session.createTextMessage("floccinaucinihilipilification");
-
- prod.send(m);
-
- TextMessage rm = (TextMessage)cons.receive(5000);
-
- assertEquals("floccinaucinihilipilification", rm.getText());
-
- SecurityAssociation.SubjectContext context = SecurityAssociation.popSubjectContext();
-
- Subject s = context.getSubject();
- assertNotNull(s);
- Set ps = s.getPrincipals();
- assertNotNull(ps);
- assertEquals(1, ps.size());
- Principal p = (Principal)ps.iterator().next();
- assertTrue(p instanceof SimplePrincipal);
- assertEquals("nabopolassar", ((SimplePrincipal)p).getName());
-
- p = context.getPrincipal();
- assertNotNull(p);
- assertTrue(p instanceof SimplePrincipal);
- assertEquals("nebuchadrezzar", ((SimplePrincipal)p).getName());
-
- Object o = context.getCredential();
- assertNotNull(o);
- assertEquals("xexe", o);
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- }
- }
-
- /**
- * Test for http://jira.jboss.org/jira/browse/JBMESSAGING-824
- *
- * Send a message to a queue that requires write permissions, and make sure the thread local
- * SecurityContext stack is correctly cleaned up after that. We're using a test security
- * manager that simulates a JBoss JaasSecurityManager.
- *
- */
- public void testGuestAuthorizedSend() throws Exception
- {
- if(ServerManagement.isRemote())
- {
- fail("This test is supposed to be run in a local configuration");
- }
-
- MockJBossSecurityManager sm =
- (MockJBossSecurityManager)ic.lookup(MockJBossSecurityManager.TEST_SECURITY_DOMAIN);
- assertTrue(sm.isSimulateJBossJaasSecurityManager());
-
- ConnectionFactory cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
- Queue queue = (Queue)ic.lookup("/queue/SecureTestQueue");
-
- Principal nabopolassar = new SimplePrincipal("nabopolassar");
- Set principals = new HashSet();
- principals.add(nabopolassar);
- Subject subject =
- new Subject(false, principals, Collections.EMPTY_SET, Collections.EMPTY_SET);
- Principal nebuchadrezzar = new SimplePrincipal("nebuchadrezzar");
-
- SecurityAssociation.pushSubjectContext(subject, nebuchadrezzar, "xexe");
-
- Connection conn = null;
-
- try
- {
- conn = cf.createConnection();
- conn.start();
-
- Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageProducer prod = session.createProducer(queue);
- MessageConsumer cons = session.createConsumer(queue);
-
- TextMessage m = session.createTextMessage("floccinaucinihilipilification");
-
- prod.send(m);
-
- TextMessage rm = (TextMessage)cons.receive(5000);
-
- assertEquals("floccinaucinihilipilification", rm.getText());
-
- SecurityAssociation.SubjectContext context = SecurityAssociation.popSubjectContext();
-
- Subject s = context.getSubject();
- assertNotNull(s);
- Set ps = s.getPrincipals();
- assertNotNull(ps);
- assertEquals(1, ps.size());
- Principal p = (Principal)ps.iterator().next();
- assertTrue(p instanceof SimplePrincipal);
- assertEquals("nabopolassar", ((SimplePrincipal)p).getName());
-
- p = context.getPrincipal();
- assertNotNull(p);
- assertTrue(p instanceof SimplePrincipal);
- assertEquals("nebuchadrezzar", ((SimplePrincipal)p).getName());
-
- Object o = context.getCredential();
- assertNotNull(o);
- assertEquals("xexe", o);
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- }
- }
-
- /**
- * Test for http://jira.jboss.org/jira/browse/JBMESSAGING-824
- *
- * Send a message to a queue that requires write permissions, and make sure the thread local
- * SecurityContext stack is correctly cleaned up after that. We're using a test security
- * manager that simulates a JBoss JaasSecurityManager.
- */
- public void testAuthorizedSend() throws Exception
- {
- if(ServerManagement.isRemote())
- {
- fail("This test is supposed to be run in a local configuration");
- }
-
- MockJBossSecurityManager sm =
- (MockJBossSecurityManager)ic.lookup(MockJBossSecurityManager.TEST_SECURITY_DOMAIN);
- assertTrue(sm.isSimulateJBossJaasSecurityManager());
-
- ConnectionFactory cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
- Queue queue = (Queue)ic.lookup("/queue/SecureTestQueue");
-
- Principal nabopolassar = new SimplePrincipal("nabopolassar");
- Set principals = new HashSet();
- principals.add(nabopolassar);
- Subject subject =
- new Subject(false, principals, Collections.EMPTY_SET, Collections.EMPTY_SET);
- Principal nebuchadrezzar = new SimplePrincipal("nebuchadrezzar");
-
- SecurityAssociation.pushSubjectContext(subject, nebuchadrezzar, "xexe");
-
- Connection conn = null;
-
- try
- {
- conn = cf.createConnection("john", "needle");
- conn.start();
-
- Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageProducer prod = session.createProducer(queue);
- MessageConsumer cons = session.createConsumer(queue);
-
- TextMessage m = session.createTextMessage("floccinaucinihilipilification");
-
- prod.send(m);
-
- TextMessage rm = (TextMessage)cons.receive(5000);
-
- assertEquals("floccinaucinihilipilification", rm.getText());
-
- SecurityAssociation.SubjectContext context = SecurityAssociation.popSubjectContext();
-
- Subject s = context.getSubject();
- assertNotNull(s);
- Set ps = s.getPrincipals();
- assertNotNull(ps);
- assertEquals(1, ps.size());
- Principal p = (Principal)ps.iterator().next();
- assertTrue(p instanceof SimplePrincipal);
- assertEquals("nabopolassar", ((SimplePrincipal)p).getName());
-
- p = context.getPrincipal();
- assertNotNull(p);
- assertTrue(p instanceof SimplePrincipal);
- assertEquals("nebuchadrezzar", ((SimplePrincipal)p).getName());
-
- Object o = context.getCredential();
- assertNotNull(o);
- assertEquals("xexe", o);
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- }
- }
-
- // Package protected ----------------------------------------------------------------------------
-
- // Protected ------------------------------------------------------------------------------------
-
- protected void setUp() throws Exception
- {
- if(ServerManagement.isRemote())
- {
- fail("This test is supposed to be run in a local configuration");
- }
-
- super.setUp();
-
- ServerManagement.start("all");
-
- ic = new InitialContext(ServerManagement.getJNDIEnvironment());
-
- ServerManagement.deployQueue("TestQueue");
-
- ServerManagement.deployQueue("SecureTestQueue");
-
- final String secureQueueConfig =
- "<security>" +
- "<role name=\"publisher\" read=\"true\" write=\"true\" create=\"false\"/>" +
- "<role name=\"guest\" read=\"true\" write=\"true\" create=\"false\"/>" +
- "</security>";
- ServerManagement.configureSecurityForDestination("SecureTestQueue", secureQueueConfig);
-
- // make MockSecurityManager simulate JaasSecurityManager behavior. This is the whole point
- // of this test, to catch JBoss AS integreation failure before the integration test suite
- // does. However, this MUST NOT be a replacement for integration tests, it's just an
- // additional safety layer.
-
- MockJBossSecurityManager sm =
- (MockJBossSecurityManager)ic.lookup(MockJBossSecurityManager.TEST_SECURITY_DOMAIN);
-
- sm.setSimulateJBossJaasSecurityManager(true);
-
- log.debug("setup done");
- }
-
- protected void tearDown() throws Exception
- {
- ServerManagement.undeployQueue("TestQueue");
- ServerManagement.undeployQueue("SecureTestQueue");
-
- MockJBossSecurityManager sm =
- (MockJBossSecurityManager)ic.lookup(MockJBossSecurityManager.TEST_SECURITY_DOMAIN);
-
- sm.setSimulateJBossJaasSecurityManager(false);
-
- ic.close();
-
- super.tearDown();
- }
-
- // Private --------------------------------------------------------------------------------------
-
- // Inner classes --------------------------------------------------------------------------------
-}
Copied: branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/jbosssx/SecurityAssociationTest.java (from rev 2261, branches/Branch_1_0_1_SP/tests/src/org/jboss/test/thirdparty/jbosssx/SecurityAssociationTest.java)
===================================================================
--- branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/jbosssx/SecurityAssociationTest.java (rev 0)
+++ branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/jbosssx/SecurityAssociationTest.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -0,0 +1,363 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.thirdparty.jbosssx;
+
+import org.jboss.test.messaging.MessagingTestCase;
+import org.jboss.test.messaging.tools.ServerManagement;
+import org.jboss.test.messaging.tools.jmx.MockJBossSecurityManager;
+import org.jboss.security.SecurityAssociation;
+import org.jboss.security.SimplePrincipal;
+
+import javax.naming.InitialContext;
+import javax.jms.ConnectionFactory;
+import javax.jms.Queue;
+import javax.jms.Connection;
+import javax.jms.Session;
+import javax.jms.MessageProducer;
+import javax.jms.MessageConsumer;
+import javax.jms.TextMessage;
+import javax.security.auth.Subject;
+import java.security.Principal;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Collections;
+
+/**
+ * Set of tests to insure consistent behavior relative to the JBoss AS security infrastructure.
+ * This is just a safety layer, full fledged security tests should be present in the integration
+ * test suite.
+ *
+ * Tests contained by this class are supposed to run only in local environment.
+ *
+ * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
+ * @version <tt>$Revision$</tt>
+ * $Id$
+ */
+public class SecurityAssociationTest extends MessagingTestCase
+{
+ // Constants ------------------------------------------------------------------------------------
+
+ // Static ---------------------------------------------------------------------------------------
+
+ // Attributes -----------------------------------------------------------------------------------
+
+ private InitialContext ic;
+
+ // Constructors ---------------------------------------------------------------------------------
+
+ public SecurityAssociationTest(String name)
+ {
+ super(name);
+ }
+
+ // Public ---------------------------------------------------------------------------------------
+
+ /**
+ * Test for http://jira.jboss.org/jira/browse/JBMESSAGING-807
+ */
+ public void testSecurityAssociation() throws Exception
+ {
+ if(ServerManagement.isRemote())
+ {
+ fail("This test is supposed to be run in a local configuration");
+ }
+
+ ConnectionFactory cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
+ Queue queue = (Queue)ic.lookup("/queue/TestQueue");
+
+ Principal nabopolassar = new SimplePrincipal("nabopolassar");
+ Set principals = new HashSet();
+ principals.add(nabopolassar);
+ Subject subject =
+ new Subject(false, principals, Collections.EMPTY_SET, Collections.EMPTY_SET);
+ Principal nebuchadrezzar = new SimplePrincipal("nebuchadrezzar");
+
+ SecurityAssociation.pushSubjectContext(subject, nebuchadrezzar, "xexe");
+
+ Connection conn = null;
+
+ try
+ {
+ conn = cf.createConnection();
+ conn.start();
+
+ Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageProducer prod = session.createProducer(queue);
+ MessageConsumer cons = session.createConsumer(queue);
+
+ TextMessage m = session.createTextMessage("floccinaucinihilipilification");
+
+ prod.send(m);
+
+ TextMessage rm = (TextMessage)cons.receive(5000);
+
+ assertEquals("floccinaucinihilipilification", rm.getText());
+
+ SecurityAssociation.SubjectContext context = SecurityAssociation.popSubjectContext();
+
+ Subject s = context.getSubject();
+ assertNotNull(s);
+ Set ps = s.getPrincipals();
+ assertNotNull(ps);
+ assertEquals(1, ps.size());
+ Principal p = (Principal)ps.iterator().next();
+ assertTrue(p instanceof SimplePrincipal);
+ assertEquals("nabopolassar", ((SimplePrincipal)p).getName());
+
+ p = context.getPrincipal();
+ assertNotNull(p);
+ assertTrue(p instanceof SimplePrincipal);
+ assertEquals("nebuchadrezzar", ((SimplePrincipal)p).getName());
+
+ Object o = context.getCredential();
+ assertNotNull(o);
+ assertEquals("xexe", o);
+ }
+ finally
+ {
+ if (conn != null)
+ {
+ conn.close();
+ }
+ }
+ }
+
+ /**
+ * Test for http://jira.jboss.org/jira/browse/JBMESSAGING-824
+ *
+ * Send a message to a queue that requires write permissions, and make sure the thread local
+ * SecurityContext stack is correctly cleaned up after that. We're using a test security
+ * manager that simulates a JBoss JaasSecurityManager.
+ *
+ */
+ public void testGuestAuthorizedSend() throws Exception
+ {
+ if(ServerManagement.isRemote())
+ {
+ fail("This test is supposed to be run in a local configuration");
+ }
+
+ MockJBossSecurityManager sm =
+ (MockJBossSecurityManager)ic.lookup(MockJBossSecurityManager.TEST_SECURITY_DOMAIN);
+ assertTrue(sm.isSimulateJBossJaasSecurityManager());
+
+ ConnectionFactory cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
+ Queue queue = (Queue)ic.lookup("/queue/SecureTestQueue");
+
+ Principal nabopolassar = new SimplePrincipal("nabopolassar");
+ Set principals = new HashSet();
+ principals.add(nabopolassar);
+ Subject subject =
+ new Subject(false, principals, Collections.EMPTY_SET, Collections.EMPTY_SET);
+ Principal nebuchadrezzar = new SimplePrincipal("nebuchadrezzar");
+
+ SecurityAssociation.pushSubjectContext(subject, nebuchadrezzar, "xexe");
+
+ Connection conn = null;
+
+ try
+ {
+ conn = cf.createConnection();
+ conn.start();
+
+ Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageProducer prod = session.createProducer(queue);
+ MessageConsumer cons = session.createConsumer(queue);
+
+ TextMessage m = session.createTextMessage("floccinaucinihilipilification");
+
+ prod.send(m);
+
+ TextMessage rm = (TextMessage)cons.receive(5000);
+
+ assertEquals("floccinaucinihilipilification", rm.getText());
+
+ SecurityAssociation.SubjectContext context = SecurityAssociation.popSubjectContext();
+
+ Subject s = context.getSubject();
+ assertNotNull(s);
+ Set ps = s.getPrincipals();
+ assertNotNull(ps);
+ assertEquals(1, ps.size());
+ Principal p = (Principal)ps.iterator().next();
+ assertTrue(p instanceof SimplePrincipal);
+ assertEquals("nabopolassar", ((SimplePrincipal)p).getName());
+
+ p = context.getPrincipal();
+ assertNotNull(p);
+ assertTrue(p instanceof SimplePrincipal);
+ assertEquals("nebuchadrezzar", ((SimplePrincipal)p).getName());
+
+ Object o = context.getCredential();
+ assertNotNull(o);
+ assertEquals("xexe", o);
+ }
+ finally
+ {
+ if (conn != null)
+ {
+ conn.close();
+ }
+ }
+ }
+
+ /**
+ * Test for http://jira.jboss.org/jira/browse/JBMESSAGING-824
+ *
+ * Send a message to a queue that requires write permissions, and make sure the thread local
+ * SecurityContext stack is correctly cleaned up after that. We're using a test security
+ * manager that simulates a JBoss JaasSecurityManager.
+ */
+ public void testAuthorizedSend() throws Exception
+ {
+ if(ServerManagement.isRemote())
+ {
+ fail("This test is supposed to be run in a local configuration");
+ }
+
+ MockJBossSecurityManager sm =
+ (MockJBossSecurityManager)ic.lookup(MockJBossSecurityManager.TEST_SECURITY_DOMAIN);
+ assertTrue(sm.isSimulateJBossJaasSecurityManager());
+
+ ConnectionFactory cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
+ Queue queue = (Queue)ic.lookup("/queue/SecureTestQueue");
+
+ Principal nabopolassar = new SimplePrincipal("nabopolassar");
+ Set principals = new HashSet();
+ principals.add(nabopolassar);
+ Subject subject =
+ new Subject(false, principals, Collections.EMPTY_SET, Collections.EMPTY_SET);
+ Principal nebuchadrezzar = new SimplePrincipal("nebuchadrezzar");
+
+ SecurityAssociation.pushSubjectContext(subject, nebuchadrezzar, "xexe");
+
+ Connection conn = null;
+
+ try
+ {
+ conn = cf.createConnection("john", "needle");
+ conn.start();
+
+ Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageProducer prod = session.createProducer(queue);
+ MessageConsumer cons = session.createConsumer(queue);
+
+ TextMessage m = session.createTextMessage("floccinaucinihilipilification");
+
+ prod.send(m);
+
+ TextMessage rm = (TextMessage)cons.receive(5000);
+
+ assertEquals("floccinaucinihilipilification", rm.getText());
+
+ SecurityAssociation.SubjectContext context = SecurityAssociation.popSubjectContext();
+
+ Subject s = context.getSubject();
+ assertNotNull(s);
+ Set ps = s.getPrincipals();
+ assertNotNull(ps);
+ assertEquals(1, ps.size());
+ Principal p = (Principal)ps.iterator().next();
+ assertTrue(p instanceof SimplePrincipal);
+ assertEquals("nabopolassar", ((SimplePrincipal)p).getName());
+
+ p = context.getPrincipal();
+ assertNotNull(p);
+ assertTrue(p instanceof SimplePrincipal);
+ assertEquals("nebuchadrezzar", ((SimplePrincipal)p).getName());
+
+ Object o = context.getCredential();
+ assertNotNull(o);
+ assertEquals("xexe", o);
+ }
+ finally
+ {
+ if (conn != null)
+ {
+ conn.close();
+ }
+ }
+ }
+
+ // Package protected ----------------------------------------------------------------------------
+
+ // Protected ------------------------------------------------------------------------------------
+
+ protected void setUp() throws Exception
+ {
+ if(ServerManagement.isRemote())
+ {
+ fail("This test is supposed to be run in a local configuration");
+ }
+
+ super.setUp();
+
+ ServerManagement.start("all");
+
+ ic = new InitialContext(ServerManagement.getJNDIEnvironment());
+
+ ServerManagement.deployQueue("TestQueue");
+
+ ServerManagement.deployQueue("SecureTestQueue");
+
+ final String secureQueueConfig =
+ "<security>" +
+ "<role name=\"publisher\" read=\"true\" write=\"true\" create=\"false\"/>" +
+ "<role name=\"guest\" read=\"true\" write=\"true\" create=\"false\"/>" +
+ "</security>";
+ ServerManagement.configureSecurityForDestination("SecureTestQueue", secureQueueConfig);
+
+ // make MockSecurityManager simulate JaasSecurityManager behavior. This is the whole point
+ // of this test, to catch JBoss AS integreation failure before the integration test suite
+ // does. However, this MUST NOT be a replacement for integration tests, it's just an
+ // additional safety layer.
+
+ MockJBossSecurityManager sm =
+ (MockJBossSecurityManager)ic.lookup(MockJBossSecurityManager.TEST_SECURITY_DOMAIN);
+
+ sm.setSimulateJBossJaasSecurityManager(true);
+
+ log.debug("setup done");
+ }
+
+ protected void tearDown() throws Exception
+ {
+ ServerManagement.undeployQueue("TestQueue");
+ ServerManagement.undeployQueue("SecureTestQueue");
+
+ MockJBossSecurityManager sm =
+ (MockJBossSecurityManager)ic.lookup(MockJBossSecurityManager.TEST_SECURITY_DOMAIN);
+
+ sm.setSimulateJBossJaasSecurityManager(false);
+
+ ic.close();
+
+ super.tearDown();
+ }
+
+ // Private --------------------------------------------------------------------------------------
+
+ // Inner classes --------------------------------------------------------------------------------
+}
Copied: branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting (from rev 2261, branches/Branch_1_0_1_SP/tests/src/org/jboss/test/thirdparty/remoting)
Deleted: branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/ClientInvokerTimeoutTest.java
===================================================================
--- branches/Branch_1_0_1_SP/tests/src/org/jboss/test/thirdparty/remoting/ClientInvokerTimeoutTest.java 2007-02-11 09:04:09 UTC (rev 2261)
+++ branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/ClientInvokerTimeoutTest.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -1,200 +0,0 @@
-/**
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.test.thirdparty.remoting;
-
-import org.jboss.test.messaging.MessagingTestCase;
-import org.jboss.test.messaging.tools.ServerManagement;
-import org.jboss.test.messaging.tools.jmx.ServiceContainer;
-import org.jboss.test.thirdparty.remoting.util.RemotingTestSubsystemService;
-import org.jboss.test.thirdparty.remoting.util.SimpleConnectionListener;
-import org.jboss.logging.Logger;
-import org.jboss.remoting.InvokerLocator;
-import org.jboss.remoting.Client;
-
-/**
- * Tests for http://jira.jboss.org/jira/browse/JBMESSAGING-787,
- * http://jira.jboss.org/jira/browse/JBREM-691. Test written entirely at the Remoting level. If
- * fails with Remoting 2.2.0.Alpha6.
- *
- * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
- *
- * @version <tt>$Revision: 2104 $</tt>
- *
- * $Id: ClientInvokerTimeoutTest.java 2104 2007-01-30 07:35:13Z ovidiu.feodorov at jboss.com $
- */
-public class ClientInvokerTimeoutTest extends MessagingTestCase
-{
- // Constants ------------------------------------------------------------------------------------
-
- private static final Logger log = Logger.getLogger(ClientInvokerTimeoutTest.class);
-
- // Static ---------------------------------------------------------------------------------------
-
- // Attributes -----------------------------------------------------------------------------------
-
- private InvokerLocator serverLocator;
-
- // Constructors ---------------------------------------------------------------------------------
-
- public ClientInvokerTimeoutTest(String name)
- {
- super(name);
- }
-
- // Public ---------------------------------------------------------------------------------------
-
- /**
- * A remoting client created for "business use" will throw an unexpected SocketTimeoutException
- * after 1000 ms during a long invocation, even if it's not supposed to. If fails with Remoting
- * 2.2.0.Alpha6.
- */
- public void testUnexpectedSocketTimeoutException() throws Throwable
- {
- // This test doesn't make sense for HTTP, so shortcut it
-
- Client client = null;
-
- try
- {
- client = new Client(serverLocator, RemotingTestSubsystemService.SUBSYSTEM_LABEL);
-
- client.connect();
-
- SimpleConnectionListener connListener = new SimpleConnectionListener();
- client.addConnectionListener(connListener, 3333);
-
- log.info("connection listener added, pinging will start in 3.3 secs");
-
- Thread.sleep(5000);
-
- log.info("first ping is done, send a long running invocation");
-
- // in 2.2.0.Alpha6 the client will send the invocation over a socket configured to time
- // out after 1000 ms, so this will throw java.net.SocketTimeoutException
-
- client.invoke(new Long(5000));
-
- Thread.sleep(7000);
- }
- finally
- {
- if (client != null)
- {
- client.disconnect();
- }
- }
- }
-
- /**
- * Same as testUnexpectedSocketTimeoutException(), slightly different setup.
- */
- public void testUnexpectedSocketTimeoutException2() throws Throwable
- {
- Client client = null;
-
- try
- {
- // create a "business" client
-
- client = new Client(serverLocator, RemotingTestSubsystemService.SUBSYSTEM_LABEL);
-
- client.connect();
-
- final Client clientCopy = client;
-
- // send a "long running" invocation first on a separate thread, so we can setup the
- // connection validator at the same time
-
- new Thread(new Runnable()
- {
- public void run()
- {
- try
- {
- // this invocation will take 5 secs to complete
- clientCopy.invoke(new Long(5000));
- }
- catch(Throwable t)
- {
- log.error("invocation failed", t);
- }
-
- }
- }, "Lazy Invocation Thread").start();
-
- Thread.sleep(1000);
-
- SimpleConnectionListener connListener = new SimpleConnectionListener();
- client.addConnectionListener(connListener, 3333);
-
- log.info("connection listener added, pinging will start in 3.3 secs");
-
- Thread.sleep(4000);
-
- log.info("first ping is done, the answer to the first invocation should be back already");
-
- // in 2.2.0.Alpha6 the client will send the invocation over a socket configured to time
- // out after 1000 ms, so this will throw java.net.SocketTimeoutException
-
- client.invoke(new Long(5000));
-
- Thread.sleep(7000);
-
- }
- finally
- {
- if (client != null)
- {
- client.disconnect();
- }
- }
- }
-
- // Package protected ----------------------------------------------------------------------------
-
- // Protected ------------------------------------------------------------------------------------
-
- protected void setUp() throws Exception
- {
- super.setUp();
-
- if (!isRemote())
- {
- fail("This test should be run in a remote configuration!");
- }
-
- ServerManagement.start("all");
-
- // obtain the server locator from the service itself, so we won't have any doubts we use
- // the right one
-
- serverLocator = new InvokerLocator((String)ServerManagement.
- getAttribute(ServiceContainer.REMOTING_OBJECT_NAME, "InvokerLocator"));
-
- // deploy a "lazy subsystem", that will delay invocations as long is it told to; used to
- // simulate long running invocations
-
- RemotingTestSubsystemService.
- deployService("org.jboss.test.thirdparty.remoting.LazySubsystem");
-
- log.debug("setup done");
- }
-
- protected void tearDown() throws Exception
- {
- serverLocator = null;
-
- ServerManagement.stop();
-
- super.tearDown();
- }
-
- // Private --------------------------------------------------------------------------------------
-
- // Inner classes --------------------------------------------------------------------------------
-
-}
Copied: branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/ClientInvokerTimeoutTest.java (from rev 2261, branches/Branch_1_0_1_SP/tests/src/org/jboss/test/thirdparty/remoting/ClientInvokerTimeoutTest.java)
===================================================================
--- branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/ClientInvokerTimeoutTest.java (rev 0)
+++ branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/ClientInvokerTimeoutTest.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -0,0 +1,200 @@
+/**
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.test.thirdparty.remoting;
+
+import org.jboss.test.messaging.MessagingTestCase;
+import org.jboss.test.messaging.tools.ServerManagement;
+import org.jboss.test.messaging.tools.jmx.ServiceContainer;
+import org.jboss.test.thirdparty.remoting.util.RemotingTestSubsystemService;
+import org.jboss.test.thirdparty.remoting.util.SimpleConnectionListener;
+import org.jboss.logging.Logger;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.Client;
+
+/**
+ * Tests for http://jira.jboss.org/jira/browse/JBMESSAGING-787,
+ * http://jira.jboss.org/jira/browse/JBREM-691. Test written entirely at the Remoting level. If
+ * fails with Remoting 2.2.0.Alpha6.
+ *
+ * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
+ *
+ * @version <tt>$Revision: 2104 $</tt>
+ *
+ * $Id: ClientInvokerTimeoutTest.java 2104 2007-01-30 07:35:13Z ovidiu.feodorov at jboss.com $
+ */
+public class ClientInvokerTimeoutTest extends MessagingTestCase
+{
+ // Constants ------------------------------------------------------------------------------------
+
+ private static final Logger log = Logger.getLogger(ClientInvokerTimeoutTest.class);
+
+ // Static ---------------------------------------------------------------------------------------
+
+ // Attributes -----------------------------------------------------------------------------------
+
+ private InvokerLocator serverLocator;
+
+ // Constructors ---------------------------------------------------------------------------------
+
+ public ClientInvokerTimeoutTest(String name)
+ {
+ super(name);
+ }
+
+ // Public ---------------------------------------------------------------------------------------
+
+ /**
+ * A remoting client created for "business use" will throw an unexpected SocketTimeoutException
+ * after 1000 ms during a long invocation, even if it's not supposed to. If fails with Remoting
+ * 2.2.0.Alpha6.
+ */
+ public void testUnexpectedSocketTimeoutException() throws Throwable
+ {
+ // This test doesn't make sense for HTTP, so shortcut it
+
+ Client client = null;
+
+ try
+ {
+ client = new Client(serverLocator, RemotingTestSubsystemService.SUBSYSTEM_LABEL);
+
+ client.connect();
+
+ SimpleConnectionListener connListener = new SimpleConnectionListener();
+ client.addConnectionListener(connListener, 3333);
+
+ log.info("connection listener added, pinging will start in 3.3 secs");
+
+ Thread.sleep(5000);
+
+ log.info("first ping is done, send a long running invocation");
+
+ // in 2.2.0.Alpha6 the client will send the invocation over a socket configured to time
+ // out after 1000 ms, so this will throw java.net.SocketTimeoutException
+
+ client.invoke(new Long(5000));
+
+ Thread.sleep(7000);
+ }
+ finally
+ {
+ if (client != null)
+ {
+ client.disconnect();
+ }
+ }
+ }
+
+ /**
+ * Same as testUnexpectedSocketTimeoutException(), slightly different setup.
+ */
+ public void testUnexpectedSocketTimeoutException2() throws Throwable
+ {
+ Client client = null;
+
+ try
+ {
+ // create a "business" client
+
+ client = new Client(serverLocator, RemotingTestSubsystemService.SUBSYSTEM_LABEL);
+
+ client.connect();
+
+ final Client clientCopy = client;
+
+ // send a "long running" invocation first on a separate thread, so we can setup the
+ // connection validator at the same time
+
+ new Thread(new Runnable()
+ {
+ public void run()
+ {
+ try
+ {
+ // this invocation will take 5 secs to complete
+ clientCopy.invoke(new Long(5000));
+ }
+ catch(Throwable t)
+ {
+ log.error("invocation failed", t);
+ }
+
+ }
+ }, "Lazy Invocation Thread").start();
+
+ Thread.sleep(1000);
+
+ SimpleConnectionListener connListener = new SimpleConnectionListener();
+ client.addConnectionListener(connListener, 3333);
+
+ log.info("connection listener added, pinging will start in 3.3 secs");
+
+ Thread.sleep(4000);
+
+ log.info("first ping is done, the answer to the first invocation should be back already");
+
+ // in 2.2.0.Alpha6 the client will send the invocation over a socket configured to time
+ // out after 1000 ms, so this will throw java.net.SocketTimeoutException
+
+ client.invoke(new Long(5000));
+
+ Thread.sleep(7000);
+
+ }
+ finally
+ {
+ if (client != null)
+ {
+ client.disconnect();
+ }
+ }
+ }
+
+ // Package protected ----------------------------------------------------------------------------
+
+ // Protected ------------------------------------------------------------------------------------
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ if (!isRemote())
+ {
+ fail("This test should be run in a remote configuration!");
+ }
+
+ ServerManagement.start("all");
+
+ // obtain the server locator from the service itself, so we won't have any doubts we use
+ // the right one
+
+ serverLocator = new InvokerLocator((String)ServerManagement.
+ getAttribute(ServiceContainer.REMOTING_OBJECT_NAME, "InvokerLocator"));
+
+ // deploy a "lazy subsystem", that will delay invocations as long is it told to; used to
+ // simulate long running invocations
+
+ RemotingTestSubsystemService.
+ deployService("org.jboss.test.thirdparty.remoting.LazySubsystem");
+
+ log.debug("setup done");
+ }
+
+ protected void tearDown() throws Exception
+ {
+ serverLocator = null;
+
+ ServerManagement.stop();
+
+ super.tearDown();
+ }
+
+ // Private --------------------------------------------------------------------------------------
+
+ // Inner classes --------------------------------------------------------------------------------
+
+}
Deleted: branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/LazySubsystem.java
===================================================================
--- branches/Branch_1_0_1_SP/tests/src/org/jboss/test/thirdparty/remoting/LazySubsystem.java 2007-02-11 09:04:09 UTC (rev 2261)
+++ branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/LazySubsystem.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -1,93 +0,0 @@
-/**
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.test.thirdparty.remoting;
-
-import org.jboss.remoting.ServerInvocationHandler;
-import org.jboss.remoting.ServerInvoker;
-import org.jboss.remoting.InvocationRequest;
-import org.jboss.remoting.callback.InvokerCallbackHandler;
-import org.jboss.test.thirdparty.remoting.util.TestableSubsystem;
-import org.jboss.logging.Logger;
-
-import javax.management.MBeanServer;
-
-/**
- * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
- * @version <tt>$Revision: 2107 $</tt>
- *
- * $Id: LazySubsystem.java 2107 2007-01-30 07:46:44Z ovidiu.feodorov at jboss.com $
- */
-public class LazySubsystem implements ServerInvocationHandler, TestableSubsystem
-{
- // Constants ------------------------------------------------------------------------------------
-
- private static final Logger log = Logger.getLogger(LazySubsystem.class);
-
- // Static ---------------------------------------------------------------------------------------
-
- // Attributes -----------------------------------------------------------------------------------
-
- // Constructors ---------------------------------------------------------------------------------
-
- public LazySubsystem()
- {
- }
-
- // ServerInvocationHandler implementation -------------------------------------------------------
-
- public void setMBeanServer(MBeanServer server)
- {
- }
-
- public void setInvoker(ServerInvoker invoker)
- {
- }
-
- public Object invoke(InvocationRequest invocation) throws Throwable
- {
- long sleepTime = ((Long)invocation.getParameter()).longValue();
-
- log.debug("sleeping for " + (sleepTime / 1000) + " seconds ...");
-
- Thread.sleep(sleepTime);
-
- log.debug("woke up");
-
- return null;
- }
-
- public void addListener(InvokerCallbackHandler callbackHandler)
- {
- }
-
- public void removeListener(InvokerCallbackHandler callbackHandler)
- {
- }
-
- // TestableSubsystem implementation ----------------------------------------------------------
-
- public InvocationRequest getNextInvocation(long timeout) throws InterruptedException
- {
- return null;
- }
-
- public boolean isFailed()
- {
- return false;
- }
-
- // Public ---------------------------------------------------------------------------------------
-
- // Package protected ----------------------------------------------------------------------------
-
- // Protected ------------------------------------------------------------------------------------
-
- // Private --------------------------------------------------------------------------------------
-
- // Inner classes --------------------------------------------------------------------------------
-}
-
Copied: branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/LazySubsystem.java (from rev 2261, branches/Branch_1_0_1_SP/tests/src/org/jboss/test/thirdparty/remoting/LazySubsystem.java)
===================================================================
--- branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/LazySubsystem.java (rev 0)
+++ branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/LazySubsystem.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -0,0 +1,93 @@
+/**
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.test.thirdparty.remoting;
+
+import org.jboss.remoting.ServerInvocationHandler;
+import org.jboss.remoting.ServerInvoker;
+import org.jboss.remoting.InvocationRequest;
+import org.jboss.remoting.callback.InvokerCallbackHandler;
+import org.jboss.test.thirdparty.remoting.util.TestableSubsystem;
+import org.jboss.logging.Logger;
+
+import javax.management.MBeanServer;
+
+/**
+ * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
+ * @version <tt>$Revision: 2107 $</tt>
+ *
+ * $Id: LazySubsystem.java 2107 2007-01-30 07:46:44Z ovidiu.feodorov at jboss.com $
+ */
+public class LazySubsystem implements ServerInvocationHandler, TestableSubsystem
+{
+ // Constants ------------------------------------------------------------------------------------
+
+ private static final Logger log = Logger.getLogger(LazySubsystem.class);
+
+ // Static ---------------------------------------------------------------------------------------
+
+ // Attributes -----------------------------------------------------------------------------------
+
+ // Constructors ---------------------------------------------------------------------------------
+
+ public LazySubsystem()
+ {
+ }
+
+ // ServerInvocationHandler implementation -------------------------------------------------------
+
+ public void setMBeanServer(MBeanServer server)
+ {
+ }
+
+ public void setInvoker(ServerInvoker invoker)
+ {
+ }
+
+ public Object invoke(InvocationRequest invocation) throws Throwable
+ {
+ long sleepTime = ((Long)invocation.getParameter()).longValue();
+
+ log.debug("sleeping for " + (sleepTime / 1000) + " seconds ...");
+
+ Thread.sleep(sleepTime);
+
+ log.debug("woke up");
+
+ return null;
+ }
+
+ public void addListener(InvokerCallbackHandler callbackHandler)
+ {
+ }
+
+ public void removeListener(InvokerCallbackHandler callbackHandler)
+ {
+ }
+
+ // TestableSubsystem implementation ----------------------------------------------------------
+
+ public InvocationRequest getNextInvocation(long timeout) throws InterruptedException
+ {
+ return null;
+ }
+
+ public boolean isFailed()
+ {
+ return false;
+ }
+
+ // Public ---------------------------------------------------------------------------------------
+
+ // Package protected ----------------------------------------------------------------------------
+
+ // Protected ------------------------------------------------------------------------------------
+
+ // Private --------------------------------------------------------------------------------------
+
+ // Inner classes --------------------------------------------------------------------------------
+}
+
Deleted: branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/RemotingTest.java
===================================================================
--- branches/Branch_1_0_1_SP/tests/src/org/jboss/test/thirdparty/remoting/RemotingTest.java 2007-02-11 09:04:09 UTC (rev 2261)
+++ branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/RemotingTest.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -1,494 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.thirdparty.remoting;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.Destination;
-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.management.MBeanServer;
-import javax.naming.InitialContext;
-
-import org.jboss.logging.Logger;
-import org.jboss.remoting.Client;
-import org.jboss.remoting.ConnectionListener;
-import org.jboss.remoting.InvocationRequest;
-import org.jboss.remoting.InvokerLocator;
-import org.jboss.remoting.ServerInvocationHandler;
-import org.jboss.remoting.ServerInvoker;
-import org.jboss.remoting.callback.InvokerCallbackHandler;
-import org.jboss.remoting.transport.Connector;
-import org.jboss.test.messaging.MessagingTestCase;
-import org.jboss.test.messaging.tools.ServerManagement;
-import org.jboss.test.messaging.tools.jmx.ServiceContainer;
-
-import EDU.oswego.cs.dl.util.concurrent.Slot;
-
-/**
- * @author <a href="tim.fox at jboss.com">Tim Fox</a>
- * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
- *
- * @version 1.1
- *
- * RemotingTest.java,v 1.1 2006/03/28 14:26:20 timfox Exp
- */
-public class RemotingTest extends MessagingTestCase
-{
- // Constants -----------------------------------------------------
-
- private static final Logger log = Logger.getLogger(RemotingTest.class);
-
- // Static --------------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- InitialContext ic;
- private boolean connListenerCalled;
-
- // Constructors --------------------------------------------------
-
- public RemotingTest(String name)
- {
- super(name);
- }
-
- // Public --------------------------------------------------------
-
- public void testInvokerThreadSafety() throws Exception
- {
- Connector serverConnector = new Connector();
-
- InvokerLocator serverLocator = new InvokerLocator("socket://localhost:9099");
-
- serverConnector.setInvokerLocator(serverLocator.getLocatorURI());
-
- serverConnector.create();
-
- SimpleServerInvocationHandler invocationHandler = new SimpleServerInvocationHandler();
-
- serverConnector.addInvocationHandler("JMS", invocationHandler);
-
- serverConnector.start();
-
- // Create n clients each firing requests in their own thread, using the same locator
-
- try
- {
-
- final int NUM_CLIENTS = 3;
-
- Thread[] threads = new Thread[NUM_CLIENTS];
- Invoker[] invokers = new Invoker[NUM_CLIENTS];
-
- Object obj = new Object();
-
- for (int i = 0; i < NUM_CLIENTS; i++)
- {
- invokers[i] = new Invoker(serverLocator, obj);
- threads[i] = new Thread(invokers[i]);
- threads[i].start();
- }
-
- synchronized (obj)
- {
- obj.wait();
- }
-
- for (int i = 0; i < NUM_CLIENTS; i++)
- {
- if (invokers[i].failed)
- {
- fail();
- for (int j = 0; j < NUM_CLIENTS; j++)
- {
- threads[j].interrupt();
- }
- }
- }
-
- for (int i = 0; i < NUM_CLIENTS; i++)
- {
- threads[i].join();
- }
-
- for (int i = 0; i < NUM_CLIENTS; i++)
- {
- if (invokers[i].failed)
- {
- fail();
- }
- }
- }
- finally
- {
- serverConnector.stop();
- serverConnector.destroy();
- }
- }
-
- /**
- * TODO: Commented out until fixed. See http://jira.jboss.org/jira/browse/JBMESSAGING-287
- */
-// public void testConnectionListener() throws Throwable
-// {
-// // Start a server
-//
-// Connector serverConnector = new Connector();
-//
-// InvokerLocator serverLocator = new InvokerLocator("socket://localhost:9099");
-//
-// serverConnector.setInvokerLocator(serverLocator.getLocatorURI());
-//
-// serverConnector.create();
-//
-// SimpleServerInvocationHandler invocationHandler = new SimpleServerInvocationHandler();
-//
-// serverConnector.addInvocationHandler("JMS", invocationHandler);
-//
-// serverConnector.setLeasePeriod(1000);
-//
-// serverConnector.addConnectionListener(new SimpleConnectionListener());
-//
-// serverConnector.start();
-//
-// try
-// {
-// Client client = new Client(serverLocator);
-//
-// client.connect();
-//
-// Thread.sleep(5000);
-//
-// client.disconnect();
-//
-// // Connection Listener should now be called
-//
-// Thread.sleep(5000);
-//
-// assertTrue(connListenerCalled);
-// }
-// finally
-// {
-// serverConnector.stop();
-// serverConnector.destroy();
-// }
-//
-// }
-
- /**
- * JIRA issue: http://jira.jboss.org/jira/browse/JBMESSAGING-371
- */
- public void testMessageListenerTimeout() throws Exception
- {
- ConnectionFactory cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
- Destination topic = (Destination)ic.lookup("/topic/ATopic");
-
- Connection conn = cf.createConnection();
- Slot slot = new Slot();
-
- Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageConsumer consumer = session.createConsumer(topic);
- consumer.setMessageListener(new SimpleMessageListener(slot));
-
- conn.start();
-
- Connection conn2 = cf.createConnection();
- Session session2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageProducer prod = session2.createProducer(topic);
- Message m = session.createTextMessage("blah");
-
- prod.send(m);
-
- TextMessage rm = (TextMessage)slot.poll(5000);
-
- assertEquals("blah", rm.getText());
-
- // Only for JBoss Remoting > 2.0.0.Beta1
- long sleepTime = ServerInvoker.DEFAULT_TIMEOUT_PERIOD + 60000;
- log.info("sleeping " + (sleepTime / 60000) + " minutes");
-
- Thread.sleep(sleepTime);
-
- log.info("after sleep");
-
- // send the second message. In case of remoting timeout, the callback server won't forward
- // this message to the MessageCallbackHandler, and the test will fail
-
- Message m2 = session.createTextMessage("blah2");
- prod.send(m2);
-
- TextMessage rm2 = (TextMessage)slot.poll(5000);
-
- assertEquals("blah2", rm2.getText());
-
- conn.close();
- conn2.close();
- }
-
- /**
- * See http://jira.jboss.org/jira/browse/JBMESSAGING-748.
- *
- * This test should always pass (we're not testing potential failure conditions), but it produces
- * useful server-side logs.
- */
- public void testServerLockup() throws Throwable
- {
- // this test only makes sense in a remote configuration
- if (!isRemote())
- {
- return;
- }
-
- // get the remote server locator
-
- String s = (String)ServerManagement.
- getAttribute(ServiceContainer.REMOTING_OBJECT_NAME, "InvokerLocator");
-
- final InvokerLocator serverInvokerLocator = new InvokerLocator(s);
-
- // open a socket but don't do anything else. This locks the server with a pre
- // http://jira.jboss.org/jira/browse/JBMESSAGING-748 code base
-
- new Thread(new Runnable()
- {
- public void run()
- {
- try
- {
- log.debug("rogue connection into the server");
-
- TestClientInvoker rogueInvoker = new TestClientInvoker(serverInvokerLocator);
-
- rogueInvoker.connect();
- rogueInvoker.openConnectionButDontSendAnything();
-
-
- log.debug("sleeping for 30 secs");
-
- Thread.sleep(30000);
-
- log.debug("woke up and exiting");
- }
- catch(Throwable t)
- {
- log.error("Failed to establish rogue connection", t);
- }
-
- }
- }, "Rogue thread").start();
-
-
- final Slot rendezVous = new Slot();
-
- // create a second "real" connection and send an invocation from a different thread,
- // simulating a real client trying to connect.
-
- new Thread(new Runnable()
- {
- public void run()
- {
- try
- {
-
- Thread.sleep(5000);
-
- log.debug("trying to connect to the server");
-
- TestClientInvoker honestInvoker = new TestClientInvoker(serverInvokerLocator);
-
- honestInvoker.connect();
- honestInvoker.openConnectionAndSendJunk();
-
- log.debug("sent junk");
-
- rendezVous.put(Boolean.TRUE);
- }
- catch(Throwable t)
- {
- log.error("Failed to connect to server", t);
- }
-
- }
- }, "Honest thread").start();
-
-
- // wait for the honest invoker to finish its invocation
- Boolean b = (Boolean)rendezVous.poll(10000);
- assertNotNull(b);
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- protected void setUp() throws Exception
- {
- super.setUp();
-
- ServerManagement.start("all");
-
- ic = new InitialContext(ServerManagement.getJNDIEnvironment());
-
- ServerManagement.deployTopic("ATopic");
-
- log.debug("setup done");
-
- }
-
- protected void tearDown() throws Exception
- {
- ServerManagement.undeployTopic("ATopic");
-
- ic.close();
-
- super.tearDown();
- }
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
-
- class Invoker implements Runnable
- {
- boolean failed;
- InvokerLocator locator;
- Object o;
- Invoker(InvokerLocator locator, Object o)
- {
- this.locator = locator;
- this.o = o;
- }
- public void run()
- {
- try
- {
- for (int i = 0; i < 5000; i++)
- {
- Client cl = new Client(locator);
- cl.connect();
- cl.invoke("aardvark");
- cl.disconnect();
- }
- synchronized (o)
- {
- o.notify();
- }
- }
- catch (Throwable t)
- {
- failed = true;
- log.error("Caught throwable", t);
- synchronized (o)
- {
- o.notify();
- }
- }
- }
- }
-
- class SimpleConnectionListener implements ConnectionListener
- {
- public void handleConnectionException(Throwable t, Client client)
- {
- connListenerCalled = true;
- }
- }
-
- class SimpleServerInvocationHandler implements ServerInvocationHandler
- {
- InvokerCallbackHandler handler;
-
-
- public void addListener(InvokerCallbackHandler callbackHandler)
- {
- this.handler = callbackHandler;
-
- }
-
- public Object invoke(InvocationRequest invocation) throws Throwable
- {
- //log.info("Received invocation:" + invocation);
-
- return "Sausages";
- }
-
- public void removeListener(InvokerCallbackHandler callbackHandler)
- {
- // FIXME removeListener
-
- }
-
- public void setInvoker(ServerInvoker invoker)
- {
- // FIXME setInvoker
-
- }
-
- public void setMBeanServer(MBeanServer server)
- {
- // FIXME setMBeanServer
-
- }
- }
-
-
- private class SimpleMessageListener implements MessageListener
- {
- private Slot slot;
- private boolean failure;
-
- public SimpleMessageListener(Slot slot)
- {
- this.slot = slot;
- failure = false;
- }
-
- public void onMessage(Message m)
- {
- log.info("received " + m);
- try
- {
- slot.put(m);
- }
- catch(Exception e)
- {
- log.error("failed to put message in slot", e);
- failure = true;
- }
- }
-
- public boolean isFailure()
- {
- return failure;
- }
- }
-
-}
-
-
-
Copied: branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/RemotingTest.java (from rev 2261, branches/Branch_1_0_1_SP/tests/src/org/jboss/test/thirdparty/remoting/RemotingTest.java)
===================================================================
--- branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/RemotingTest.java (rev 0)
+++ branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/RemotingTest.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -0,0 +1,494 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.thirdparty.remoting;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Destination;
+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.management.MBeanServer;
+import javax.naming.InitialContext;
+
+import org.jboss.logging.Logger;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.ConnectionListener;
+import org.jboss.remoting.InvocationRequest;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.ServerInvocationHandler;
+import org.jboss.remoting.ServerInvoker;
+import org.jboss.remoting.callback.InvokerCallbackHandler;
+import org.jboss.remoting.transport.Connector;
+import org.jboss.test.messaging.MessagingTestCase;
+import org.jboss.test.messaging.tools.ServerManagement;
+import org.jboss.test.messaging.tools.jmx.ServiceContainer;
+
+import EDU.oswego.cs.dl.util.concurrent.Slot;
+
+/**
+ * @author <a href="tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
+ *
+ * @version 1.1
+ *
+ * RemotingTest.java,v 1.1 2006/03/28 14:26:20 timfox Exp
+ */
+public class RemotingTest extends MessagingTestCase
+{
+ // Constants -----------------------------------------------------
+
+ private static final Logger log = Logger.getLogger(RemotingTest.class);
+
+ // Static --------------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ InitialContext ic;
+ private boolean connListenerCalled;
+
+ // Constructors --------------------------------------------------
+
+ public RemotingTest(String name)
+ {
+ super(name);
+ }
+
+ // Public --------------------------------------------------------
+
+ public void testInvokerThreadSafety() throws Exception
+ {
+ Connector serverConnector = new Connector();
+
+ InvokerLocator serverLocator = new InvokerLocator("socket://localhost:9099");
+
+ serverConnector.setInvokerLocator(serverLocator.getLocatorURI());
+
+ serverConnector.create();
+
+ SimpleServerInvocationHandler invocationHandler = new SimpleServerInvocationHandler();
+
+ serverConnector.addInvocationHandler("JMS", invocationHandler);
+
+ serverConnector.start();
+
+ // Create n clients each firing requests in their own thread, using the same locator
+
+ try
+ {
+
+ final int NUM_CLIENTS = 3;
+
+ Thread[] threads = new Thread[NUM_CLIENTS];
+ Invoker[] invokers = new Invoker[NUM_CLIENTS];
+
+ Object obj = new Object();
+
+ for (int i = 0; i < NUM_CLIENTS; i++)
+ {
+ invokers[i] = new Invoker(serverLocator, obj);
+ threads[i] = new Thread(invokers[i]);
+ threads[i].start();
+ }
+
+ synchronized (obj)
+ {
+ obj.wait();
+ }
+
+ for (int i = 0; i < NUM_CLIENTS; i++)
+ {
+ if (invokers[i].failed)
+ {
+ fail();
+ for (int j = 0; j < NUM_CLIENTS; j++)
+ {
+ threads[j].interrupt();
+ }
+ }
+ }
+
+ for (int i = 0; i < NUM_CLIENTS; i++)
+ {
+ threads[i].join();
+ }
+
+ for (int i = 0; i < NUM_CLIENTS; i++)
+ {
+ if (invokers[i].failed)
+ {
+ fail();
+ }
+ }
+ }
+ finally
+ {
+ serverConnector.stop();
+ serverConnector.destroy();
+ }
+ }
+
+ /**
+ * TODO: Commented out until fixed. See http://jira.jboss.org/jira/browse/JBMESSAGING-287
+ */
+// public void testConnectionListener() throws Throwable
+// {
+// // Start a server
+//
+// Connector serverConnector = new Connector();
+//
+// InvokerLocator serverLocator = new InvokerLocator("socket://localhost:9099");
+//
+// serverConnector.setInvokerLocator(serverLocator.getLocatorURI());
+//
+// serverConnector.create();
+//
+// SimpleServerInvocationHandler invocationHandler = new SimpleServerInvocationHandler();
+//
+// serverConnector.addInvocationHandler("JMS", invocationHandler);
+//
+// serverConnector.setLeasePeriod(1000);
+//
+// serverConnector.addConnectionListener(new SimpleConnectionListener());
+//
+// serverConnector.start();
+//
+// try
+// {
+// Client client = new Client(serverLocator);
+//
+// client.connect();
+//
+// Thread.sleep(5000);
+//
+// client.disconnect();
+//
+// // Connection Listener should now be called
+//
+// Thread.sleep(5000);
+//
+// assertTrue(connListenerCalled);
+// }
+// finally
+// {
+// serverConnector.stop();
+// serverConnector.destroy();
+// }
+//
+// }
+
+ /**
+ * JIRA issue: http://jira.jboss.org/jira/browse/JBMESSAGING-371
+ */
+ public void testMessageListenerTimeout() throws Exception
+ {
+ ConnectionFactory cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
+ Destination topic = (Destination)ic.lookup("/topic/ATopic");
+
+ Connection conn = cf.createConnection();
+ Slot slot = new Slot();
+
+ Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageConsumer consumer = session.createConsumer(topic);
+ consumer.setMessageListener(new SimpleMessageListener(slot));
+
+ conn.start();
+
+ Connection conn2 = cf.createConnection();
+ Session session2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageProducer prod = session2.createProducer(topic);
+ Message m = session.createTextMessage("blah");
+
+ prod.send(m);
+
+ TextMessage rm = (TextMessage)slot.poll(5000);
+
+ assertEquals("blah", rm.getText());
+
+ // Only for JBoss Remoting > 2.0.0.Beta1
+ long sleepTime = ServerInvoker.DEFAULT_TIMEOUT_PERIOD + 60000;
+ log.info("sleeping " + (sleepTime / 60000) + " minutes");
+
+ Thread.sleep(sleepTime);
+
+ log.info("after sleep");
+
+ // send the second message. In case of remoting timeout, the callback server won't forward
+ // this message to the MessageCallbackHandler, and the test will fail
+
+ Message m2 = session.createTextMessage("blah2");
+ prod.send(m2);
+
+ TextMessage rm2 = (TextMessage)slot.poll(5000);
+
+ assertEquals("blah2", rm2.getText());
+
+ conn.close();
+ conn2.close();
+ }
+
+ /**
+ * See http://jira.jboss.org/jira/browse/JBMESSAGING-748.
+ *
+ * This test should always pass (we're not testing potential failure conditions), but it produces
+ * useful server-side logs.
+ */
+ public void testServerLockup() throws Throwable
+ {
+ // this test only makes sense in a remote configuration
+ if (!isRemote())
+ {
+ return;
+ }
+
+ // get the remote server locator
+
+ String s = (String)ServerManagement.
+ getAttribute(ServiceContainer.REMOTING_OBJECT_NAME, "InvokerLocator");
+
+ final InvokerLocator serverInvokerLocator = new InvokerLocator(s);
+
+ // open a socket but don't do anything else. This locks the server with a pre
+ // http://jira.jboss.org/jira/browse/JBMESSAGING-748 code base
+
+ new Thread(new Runnable()
+ {
+ public void run()
+ {
+ try
+ {
+ log.debug("rogue connection into the server");
+
+ TestClientInvoker rogueInvoker = new TestClientInvoker(serverInvokerLocator);
+
+ rogueInvoker.connect();
+ rogueInvoker.openConnectionButDontSendAnything();
+
+
+ log.debug("sleeping for 30 secs");
+
+ Thread.sleep(30000);
+
+ log.debug("woke up and exiting");
+ }
+ catch(Throwable t)
+ {
+ log.error("Failed to establish rogue connection", t);
+ }
+
+ }
+ }, "Rogue thread").start();
+
+
+ final Slot rendezVous = new Slot();
+
+ // create a second "real" connection and send an invocation from a different thread,
+ // simulating a real client trying to connect.
+
+ new Thread(new Runnable()
+ {
+ public void run()
+ {
+ try
+ {
+
+ Thread.sleep(5000);
+
+ log.debug("trying to connect to the server");
+
+ TestClientInvoker honestInvoker = new TestClientInvoker(serverInvokerLocator);
+
+ honestInvoker.connect();
+ honestInvoker.openConnectionAndSendJunk();
+
+ log.debug("sent junk");
+
+ rendezVous.put(Boolean.TRUE);
+ }
+ catch(Throwable t)
+ {
+ log.error("Failed to connect to server", t);
+ }
+
+ }
+ }, "Honest thread").start();
+
+
+ // wait for the honest invoker to finish its invocation
+ Boolean b = (Boolean)rendezVous.poll(10000);
+ assertNotNull(b);
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ ServerManagement.start("all");
+
+ ic = new InitialContext(ServerManagement.getJNDIEnvironment());
+
+ ServerManagement.deployTopic("ATopic");
+
+ log.debug("setup done");
+
+ }
+
+ protected void tearDown() throws Exception
+ {
+ ServerManagement.undeployTopic("ATopic");
+
+ ic.close();
+
+ super.tearDown();
+ }
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+
+ class Invoker implements Runnable
+ {
+ boolean failed;
+ InvokerLocator locator;
+ Object o;
+ Invoker(InvokerLocator locator, Object o)
+ {
+ this.locator = locator;
+ this.o = o;
+ }
+ public void run()
+ {
+ try
+ {
+ for (int i = 0; i < 5000; i++)
+ {
+ Client cl = new Client(locator);
+ cl.connect();
+ cl.invoke("aardvark");
+ cl.disconnect();
+ }
+ synchronized (o)
+ {
+ o.notify();
+ }
+ }
+ catch (Throwable t)
+ {
+ failed = true;
+ log.error("Caught throwable", t);
+ synchronized (o)
+ {
+ o.notify();
+ }
+ }
+ }
+ }
+
+ class SimpleConnectionListener implements ConnectionListener
+ {
+ public void handleConnectionException(Throwable t, Client client)
+ {
+ connListenerCalled = true;
+ }
+ }
+
+ class SimpleServerInvocationHandler implements ServerInvocationHandler
+ {
+ InvokerCallbackHandler handler;
+
+
+ public void addListener(InvokerCallbackHandler callbackHandler)
+ {
+ this.handler = callbackHandler;
+
+ }
+
+ public Object invoke(InvocationRequest invocation) throws Throwable
+ {
+ //log.info("Received invocation:" + invocation);
+
+ return "Sausages";
+ }
+
+ public void removeListener(InvokerCallbackHandler callbackHandler)
+ {
+ // FIXME removeListener
+
+ }
+
+ public void setInvoker(ServerInvoker invoker)
+ {
+ // FIXME setInvoker
+
+ }
+
+ public void setMBeanServer(MBeanServer server)
+ {
+ // FIXME setMBeanServer
+
+ }
+ }
+
+
+ private class SimpleMessageListener implements MessageListener
+ {
+ private Slot slot;
+ private boolean failure;
+
+ public SimpleMessageListener(Slot slot)
+ {
+ this.slot = slot;
+ failure = false;
+ }
+
+ public void onMessage(Message m)
+ {
+ log.info("received " + m);
+ try
+ {
+ slot.put(m);
+ }
+ catch(Exception e)
+ {
+ log.error("failed to put message in slot", e);
+ failure = true;
+ }
+ }
+
+ public boolean isFailure()
+ {
+ return failure;
+ }
+ }
+
+}
+
+
+
Deleted: branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/TestClientInvoker.java
===================================================================
--- branches/Branch_1_0_1_SP/tests/src/org/jboss/test/thirdparty/remoting/TestClientInvoker.java 2007-02-11 09:04:09 UTC (rev 2261)
+++ branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/TestClientInvoker.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -1,80 +0,0 @@
-/**
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.test.thirdparty.remoting;
-
-import org.jboss.remoting.transport.socket.MicroSocketClientInvoker;
-import org.jboss.remoting.InvokerLocator;
-import org.jboss.logging.Logger;
-
-import java.net.Socket;
-import java.io.OutputStream;
-
-/**
- * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
- * @version <tt>$Revision: 1.1.2.1 $</tt>
- *
- * $Id: TestClientInvoker.java,v 1.1.2.1 2007/01/16 00:29:29 ovidiu Exp $
- */
-class TestClientInvoker extends MicroSocketClientInvoker
-{
- // Constants ------------------------------------------------------------------------------------
-
- private static final Logger log = Logger.getLogger(TestClientInvoker.class);
-
- // Static ---------------------------------------------------------------------------------------
-
- // Attributes -----------------------------------------------------------------------------------
-
- // Constructors ---------------------------------------------------------------------------------
-
- public TestClientInvoker(InvokerLocator locator)
- {
- super(locator);
- }
-
- // Public ---------------------------------------------------------------------------------------
-
- public String toString()
- {
- return "TestClientInvoker[" + Integer.toHexString(hashCode()) + "]";
- }
-
- // Package protected ----------------------------------------------------------------------------
-
- Socket openConnectionButDontSendAnything() throws Exception
- {
- log.debug(this + " creating simple socket");
-
- Socket socket = new Socket(locator.getHost(), locator.getPort());
-
- log.debug(this + " created socket " + socket);
-
- return socket;
- }
-
- void openConnectionAndSendJunk() throws Exception
- {
- Socket socket = openConnectionButDontSendAnything();
-
- OutputStream os = socket.getOutputStream();
-
- os.write((byte)-1);
-
- log.debug(this + " wrote junk on socket");
-
-// os.flush();
-//
-// log.debug(this + " flushed the stream");
- }
-
-
- // Protected ------------------------------------------------------------------------------------
-
- // Private --------------------------------------------------------------------------------------
-
- // Inner classes --------------------------------------------------------------------------------
-}
Copied: branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/TestClientInvoker.java (from rev 2261, branches/Branch_1_0_1_SP/tests/src/org/jboss/test/thirdparty/remoting/TestClientInvoker.java)
===================================================================
--- branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/TestClientInvoker.java (rev 0)
+++ branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/TestClientInvoker.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -0,0 +1,80 @@
+/**
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.test.thirdparty.remoting;
+
+import org.jboss.remoting.transport.socket.MicroSocketClientInvoker;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.logging.Logger;
+
+import java.net.Socket;
+import java.io.OutputStream;
+
+/**
+ * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
+ * @version <tt>$Revision: 1.1.2.1 $</tt>
+ *
+ * $Id: TestClientInvoker.java,v 1.1.2.1 2007/01/16 00:29:29 ovidiu Exp $
+ */
+class TestClientInvoker extends MicroSocketClientInvoker
+{
+ // Constants ------------------------------------------------------------------------------------
+
+ private static final Logger log = Logger.getLogger(TestClientInvoker.class);
+
+ // Static ---------------------------------------------------------------------------------------
+
+ // Attributes -----------------------------------------------------------------------------------
+
+ // Constructors ---------------------------------------------------------------------------------
+
+ public TestClientInvoker(InvokerLocator locator)
+ {
+ super(locator);
+ }
+
+ // Public ---------------------------------------------------------------------------------------
+
+ public String toString()
+ {
+ return "TestClientInvoker[" + Integer.toHexString(hashCode()) + "]";
+ }
+
+ // Package protected ----------------------------------------------------------------------------
+
+ Socket openConnectionButDontSendAnything() throws Exception
+ {
+ log.debug(this + " creating simple socket");
+
+ Socket socket = new Socket(locator.getHost(), locator.getPort());
+
+ log.debug(this + " created socket " + socket);
+
+ return socket;
+ }
+
+ void openConnectionAndSendJunk() throws Exception
+ {
+ Socket socket = openConnectionButDontSendAnything();
+
+ OutputStream os = socket.getOutputStream();
+
+ os.write((byte)-1);
+
+ log.debug(this + " wrote junk on socket");
+
+// os.flush();
+//
+// log.debug(this + " flushed the stream");
+ }
+
+
+ // Protected ------------------------------------------------------------------------------------
+
+ // Private --------------------------------------------------------------------------------------
+
+ // Inner classes --------------------------------------------------------------------------------
+}
Copied: branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/util (from rev 2261, branches/Branch_1_0_1_SP/tests/src/org/jboss/test/thirdparty/remoting/util)
Deleted: branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystem.java
===================================================================
--- branches/Branch_1_0_1_SP/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystem.java 2007-02-11 09:04:09 UTC (rev 2261)
+++ branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystem.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -1,145 +0,0 @@
-/**
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.test.thirdparty.remoting.util;
-
-import org.jboss.remoting.ServerInvocationHandler;
-import org.jboss.remoting.ServerInvoker;
-import org.jboss.remoting.InvocationRequest;
-import org.jboss.remoting.callback.InvokerCallbackHandler;
-import org.jboss.logging.Logger;
-
-import javax.management.MBeanServer;
-import java.io.Serializable;
-import java.util.List;
-import java.util.ArrayList;
-
-import EDU.oswego.cs.dl.util.concurrent.LinkedQueue;
-import EDU.oswego.cs.dl.util.concurrent.Channel;
-
-/**
- * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
- * @version <tt>$Revision: 2098 $</tt>
- *
- * $Id: RemotingTestSubsystem.java 2098 2007-01-30 07:21:00Z ovidiu.feodorov at jboss.com $
- */
-public class RemotingTestSubsystem
- implements TestableSubsystem, ServerInvocationHandler, Serializable
-{
- // Constants ------------------------------------------------------------------------------------
-
- private static final long serialVersionUID = 5457454557215715L;
-
- private static final Logger log = Logger.getLogger(RemotingTestSubsystem.class);
-
- // Static ---------------------------------------------------------------------------------------
-
- /**
- * Very quick and dirty method. Don't try it at home. Needed it because some InvocationRequests
- * (even if the class is declared Serializable) contain request and response payloads which are
- * not, so I am having trouble sending them over wire back to the client.
- */
- private static InvocationRequest dirtyCopy(InvocationRequest source)
- {
- return new InvocationRequest(source.getSessionId(),
- source.getSubsystem(),
- source.getParameter(),
- null,
- null,
- source.getLocator());
- }
-
- // Attributes -----------------------------------------------------------------------------------
-
- private Channel invocationHistory;
- private List callbackListeners;
-
- private boolean failed;
-
- // Constructors ---------------------------------------------------------------------------------
-
- public RemotingTestSubsystem()
- {
- invocationHistory = new LinkedQueue();
- callbackListeners = new ArrayList();
- failed = false;
- }
-
- // ServerInvocationHandler implementation -------------------------------------------------------
-
- public void setMBeanServer(MBeanServer server)
- {
- }
-
- public void setInvoker(ServerInvoker invoker)
- {
- }
-
- public Object invoke(InvocationRequest invocation) throws Throwable
- {
- log.debug(this + " received " + invocation);
-
- final Object parameter = invocation.getParameter();
-
- if ("ignore".equals(parameter))
- {
- // used in stress tests, do not accumulate record the invocation in history, since the
- // client is goint to send a lot of them ....
- log.debug(this + " ignoring invocation");
- return null;
- }
-
- invocationHistory.put(dirtyCopy(invocation));
-
- return null;
- }
-
- public void addListener(InvokerCallbackHandler callbackHandler)
- {
- synchronized(callbackListeners)
- {
- callbackListeners.add(callbackHandler);
- }
- }
-
- public void removeListener(InvokerCallbackHandler callbackHandler)
- {
- synchronized(callbackListeners)
- {
- callbackListeners.remove(callbackHandler);
- }
- }
-
- // TestableSubsystem implementation ----------------------------------------------------------
-
- public InvocationRequest getNextInvocation(long timeout) throws InterruptedException
- {
- return (InvocationRequest)invocationHistory.poll(timeout);
- }
-
- public boolean isFailed()
- {
- synchronized (this)
- {
- return failed;
- }
- }
-
- // Public ---------------------------------------------------------------------------------------
-
- public String toString()
- {
- return "RemotingTestSubsystem[" + Integer.toHexString(hashCode()) + "]";
- }
-
- // Package protected ----------------------------------------------------------------------------
-
- // Protected ------------------------------------------------------------------------------------
-
- // Private --------------------------------------------------------------------------------------
-
- // Inner classes --------------------------------------------------------------------------------
-}
Copied: branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystem.java (from rev 2261, branches/Branch_1_0_1_SP/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystem.java)
===================================================================
--- branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystem.java (rev 0)
+++ branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystem.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -0,0 +1,145 @@
+/**
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.test.thirdparty.remoting.util;
+
+import org.jboss.remoting.ServerInvocationHandler;
+import org.jboss.remoting.ServerInvoker;
+import org.jboss.remoting.InvocationRequest;
+import org.jboss.remoting.callback.InvokerCallbackHandler;
+import org.jboss.logging.Logger;
+
+import javax.management.MBeanServer;
+import java.io.Serializable;
+import java.util.List;
+import java.util.ArrayList;
+
+import EDU.oswego.cs.dl.util.concurrent.LinkedQueue;
+import EDU.oswego.cs.dl.util.concurrent.Channel;
+
+/**
+ * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
+ * @version <tt>$Revision: 2098 $</tt>
+ *
+ * $Id: RemotingTestSubsystem.java 2098 2007-01-30 07:21:00Z ovidiu.feodorov at jboss.com $
+ */
+public class RemotingTestSubsystem
+ implements TestableSubsystem, ServerInvocationHandler, Serializable
+{
+ // Constants ------------------------------------------------------------------------------------
+
+ private static final long serialVersionUID = 5457454557215715L;
+
+ private static final Logger log = Logger.getLogger(RemotingTestSubsystem.class);
+
+ // Static ---------------------------------------------------------------------------------------
+
+ /**
+ * Very quick and dirty method. Don't try it at home. Needed it because some InvocationRequests
+ * (even if the class is declared Serializable) contain request and response payloads which are
+ * not, so I am having trouble sending them over wire back to the client.
+ */
+ private static InvocationRequest dirtyCopy(InvocationRequest source)
+ {
+ return new InvocationRequest(source.getSessionId(),
+ source.getSubsystem(),
+ source.getParameter(),
+ null,
+ null,
+ source.getLocator());
+ }
+
+ // Attributes -----------------------------------------------------------------------------------
+
+ private Channel invocationHistory;
+ private List callbackListeners;
+
+ private boolean failed;
+
+ // Constructors ---------------------------------------------------------------------------------
+
+ public RemotingTestSubsystem()
+ {
+ invocationHistory = new LinkedQueue();
+ callbackListeners = new ArrayList();
+ failed = false;
+ }
+
+ // ServerInvocationHandler implementation -------------------------------------------------------
+
+ public void setMBeanServer(MBeanServer server)
+ {
+ }
+
+ public void setInvoker(ServerInvoker invoker)
+ {
+ }
+
+ public Object invoke(InvocationRequest invocation) throws Throwable
+ {
+ log.debug(this + " received " + invocation);
+
+ final Object parameter = invocation.getParameter();
+
+ if ("ignore".equals(parameter))
+ {
+ // used in stress tests, do not accumulate record the invocation in history, since the
+ // client is goint to send a lot of them ....
+ log.debug(this + " ignoring invocation");
+ return null;
+ }
+
+ invocationHistory.put(dirtyCopy(invocation));
+
+ return null;
+ }
+
+ public void addListener(InvokerCallbackHandler callbackHandler)
+ {
+ synchronized(callbackListeners)
+ {
+ callbackListeners.add(callbackHandler);
+ }
+ }
+
+ public void removeListener(InvokerCallbackHandler callbackHandler)
+ {
+ synchronized(callbackListeners)
+ {
+ callbackListeners.remove(callbackHandler);
+ }
+ }
+
+ // TestableSubsystem implementation ----------------------------------------------------------
+
+ public InvocationRequest getNextInvocation(long timeout) throws InterruptedException
+ {
+ return (InvocationRequest)invocationHistory.poll(timeout);
+ }
+
+ public boolean isFailed()
+ {
+ synchronized (this)
+ {
+ return failed;
+ }
+ }
+
+ // Public ---------------------------------------------------------------------------------------
+
+ public String toString()
+ {
+ return "RemotingTestSubsystem[" + Integer.toHexString(hashCode()) + "]";
+ }
+
+ // Package protected ----------------------------------------------------------------------------
+
+ // Protected ------------------------------------------------------------------------------------
+
+ // Private --------------------------------------------------------------------------------------
+
+ // Inner classes --------------------------------------------------------------------------------
+}
Deleted: branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystemService.java
===================================================================
--- branches/Branch_1_0_1_SP/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystemService.java 2007-02-11 09:04:09 UTC (rev 2261)
+++ branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystemService.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -1,190 +0,0 @@
-/**
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.test.thirdparty.remoting.util;
-
-import org.jboss.logging.Logger;
-import org.jboss.test.messaging.tools.jmx.ServiceContainer;
-import org.jboss.test.messaging.tools.ServerManagement;
-import org.jboss.remoting.InvocationRequest;
-
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import javax.management.MBeanRegistration;
-import java.lang.reflect.Constructor;
-
-/**
- * A standard MBean service to be used when testing remoting.
- *
- * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
- * @version <tt>$Revision: 2098 $</tt>
- *
- * $Id: RemotingTestSubsystemService.java 2098 2007-01-30 07:21:00Z ovidiu.feodorov at jboss.com $
- */
-public class RemotingTestSubsystemService
- implements MBeanRegistration, RemotingTestSubsystemServiceMBean
-{
- // Constants ------------------------------------------------------------------------------------
-
- private static final Logger log = Logger.getLogger(RemotingTestSubsystemService.class);
-
- public static final String SUBSYSTEM_LABEL = "TEST_SUBSYSTEM";
-
- // Static ---------------------------------------------------------------------------------------
-
- public static ObjectName deployService() throws Exception
- {
- return deployService("org.jboss.test.thirdparty.remoting.util.RemotingTestSubsystem");
- }
-
- public static ObjectName deployService(String subsystemClassName) throws Exception
- {
- String testSubsystemConfig =
- "<mbean code=\"org.jboss.test.thirdparty.remoting.util.RemotingTestSubsystemService\"\n" +
- " name=\"test:service=RemotingTestSubsystem\">\n" +
- "<attribute name=\"SubsystemClassName\">" + subsystemClassName + "</attribute>" +
- "</mbean>";
-
- ObjectName on = ServerManagement.deploy(testSubsystemConfig);
- ServerManagement.invoke(on, "start", new Object[0], new String[0]);
-
- return on;
- }
-
- public static void undeployService(ObjectName on) throws Exception
- {
- ServerManagement.invoke(on, "stop", new Object[0], new String[0]);
- ServerManagement.undeploy(on);
- }
-
- public static InvocationRequest getNextInvocationFromServer(ObjectName on, long timeout)
- throws Exception
- {
- return (InvocationRequest)ServerManagement.
- invoke(on, "nextInvocation",
- new Object[] { new Long(timeout) },
- new String[] { "java.lang.Long" });
- }
-
- public static boolean isFailed(ObjectName on)
- throws Exception
- {
- return ((Boolean)ServerManagement.
- invoke(on, "isFailed", null, null)).booleanValue();
- }
-
- // Attributes -----------------------------------------------------------------------------------
-
- private MBeanServer mbeanServer;
- private ObjectName myObjectName;
-
- private String subsystemClassName;
- private TestableSubsystem delegate;
-
- // Constructors ---------------------------------------------------------------------------------
-
- // MBeanRegistration implementation -------------------------------------------------------------
-
- public ObjectName preRegister(MBeanServer mbeanServer, ObjectName objectName) throws Exception
- {
- this.mbeanServer = mbeanServer;
- this.myObjectName = objectName;
- return objectName;
- }
-
- public void postRegister(Boolean b)
- {
- // noop
- }
-
- public void preDeregister() throws Exception
- {
- // noop
- }
-
- public void postDeregister()
- {
- // noop
- }
-
- // RemotingTestSubsystemServiceMBean implementation ---------------------------------------------
-
- public String getSubsystemClassName()
- {
- return subsystemClassName;
- }
-
- public void setSubsystemClassName(String className)
- {
- this.subsystemClassName = className;
- }
-
- public void start() throws Exception
- {
- Class c = Class.forName(subsystemClassName);
- Constructor cons = c.getConstructor(new Class[0]);
-
- delegate = (TestableSubsystem)cons.newInstance(new Object[0]);
-
- // register to the remoting connector
-
- mbeanServer.invoke(ServiceContainer.REMOTING_OBJECT_NAME,
- "addInvocationHandler",
- new Object[] {SUBSYSTEM_LABEL, delegate},
- new String[] {"java.lang.String",
- "org.jboss.remoting.ServerInvocationHandler"});
-
- log.debug(myObjectName + " started");
- }
-
- public void stop()
- {
- try
- {
- // unregister from the remoting connector
-
- mbeanServer.invoke(ServiceContainer.REMOTING_OBJECT_NAME,
- "removeInvocationHandler",
- new Object[] {SUBSYSTEM_LABEL},
- new String[] {"java.lang.String"});
- }
- catch(Exception e)
- {
- log.error("Cannot deinstall remoting subsystem", e);
- }
-
- delegate = null;
-
- log.debug(myObjectName + " stopped");
- }
-
- public InvocationRequest nextInvocation(Long timeout) throws Exception
- {
- if (delegate == null)
- {
- return null;
- }
-
- return delegate.getNextInvocation(timeout.longValue());
-
- }
-
- public boolean isFailed() throws Exception
- {
- return delegate.isFailed();
- }
-
- // Public ---------------------------------------------------------------------------------------
-
- // Package protected ----------------------------------------------------------------------------
-
- // Protected ------------------------------------------------------------------------------------
-
- // Private --------------------------------------------------------------------------------------
-
- // Inner classes --------------------------------------------------------------------------------
-
-}
Copied: branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystemService.java (from rev 2261, branches/Branch_1_0_1_SP/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystemService.java)
===================================================================
--- branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystemService.java (rev 0)
+++ branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystemService.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -0,0 +1,190 @@
+/**
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.test.thirdparty.remoting.util;
+
+import org.jboss.logging.Logger;
+import org.jboss.test.messaging.tools.jmx.ServiceContainer;
+import org.jboss.test.messaging.tools.ServerManagement;
+import org.jboss.remoting.InvocationRequest;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import javax.management.MBeanRegistration;
+import java.lang.reflect.Constructor;
+
+/**
+ * A standard MBean service to be used when testing remoting.
+ *
+ * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
+ * @version <tt>$Revision: 2098 $</tt>
+ *
+ * $Id: RemotingTestSubsystemService.java 2098 2007-01-30 07:21:00Z ovidiu.feodorov at jboss.com $
+ */
+public class RemotingTestSubsystemService
+ implements MBeanRegistration, RemotingTestSubsystemServiceMBean
+{
+ // Constants ------------------------------------------------------------------------------------
+
+ private static final Logger log = Logger.getLogger(RemotingTestSubsystemService.class);
+
+ public static final String SUBSYSTEM_LABEL = "TEST_SUBSYSTEM";
+
+ // Static ---------------------------------------------------------------------------------------
+
+ public static ObjectName deployService() throws Exception
+ {
+ return deployService("org.jboss.test.thirdparty.remoting.util.RemotingTestSubsystem");
+ }
+
+ public static ObjectName deployService(String subsystemClassName) throws Exception
+ {
+ String testSubsystemConfig =
+ "<mbean code=\"org.jboss.test.thirdparty.remoting.util.RemotingTestSubsystemService\"\n" +
+ " name=\"test:service=RemotingTestSubsystem\">\n" +
+ "<attribute name=\"SubsystemClassName\">" + subsystemClassName + "</attribute>" +
+ "</mbean>";
+
+ ObjectName on = ServerManagement.deploy(testSubsystemConfig);
+ ServerManagement.invoke(on, "start", new Object[0], new String[0]);
+
+ return on;
+ }
+
+ public static void undeployService(ObjectName on) throws Exception
+ {
+ ServerManagement.invoke(on, "stop", new Object[0], new String[0]);
+ ServerManagement.undeploy(on);
+ }
+
+ public static InvocationRequest getNextInvocationFromServer(ObjectName on, long timeout)
+ throws Exception
+ {
+ return (InvocationRequest)ServerManagement.
+ invoke(on, "nextInvocation",
+ new Object[] { new Long(timeout) },
+ new String[] { "java.lang.Long" });
+ }
+
+ public static boolean isFailed(ObjectName on)
+ throws Exception
+ {
+ return ((Boolean)ServerManagement.
+ invoke(on, "isFailed", null, null)).booleanValue();
+ }
+
+ // Attributes -----------------------------------------------------------------------------------
+
+ private MBeanServer mbeanServer;
+ private ObjectName myObjectName;
+
+ private String subsystemClassName;
+ private TestableSubsystem delegate;
+
+ // Constructors ---------------------------------------------------------------------------------
+
+ // MBeanRegistration implementation -------------------------------------------------------------
+
+ public ObjectName preRegister(MBeanServer mbeanServer, ObjectName objectName) throws Exception
+ {
+ this.mbeanServer = mbeanServer;
+ this.myObjectName = objectName;
+ return objectName;
+ }
+
+ public void postRegister(Boolean b)
+ {
+ // noop
+ }
+
+ public void preDeregister() throws Exception
+ {
+ // noop
+ }
+
+ public void postDeregister()
+ {
+ // noop
+ }
+
+ // RemotingTestSubsystemServiceMBean implementation ---------------------------------------------
+
+ public String getSubsystemClassName()
+ {
+ return subsystemClassName;
+ }
+
+ public void setSubsystemClassName(String className)
+ {
+ this.subsystemClassName = className;
+ }
+
+ public void start() throws Exception
+ {
+ Class c = Class.forName(subsystemClassName);
+ Constructor cons = c.getConstructor(new Class[0]);
+
+ delegate = (TestableSubsystem)cons.newInstance(new Object[0]);
+
+ // register to the remoting connector
+
+ mbeanServer.invoke(ServiceContainer.REMOTING_OBJECT_NAME,
+ "addInvocationHandler",
+ new Object[] {SUBSYSTEM_LABEL, delegate},
+ new String[] {"java.lang.String",
+ "org.jboss.remoting.ServerInvocationHandler"});
+
+ log.debug(myObjectName + " started");
+ }
+
+ public void stop()
+ {
+ try
+ {
+ // unregister from the remoting connector
+
+ mbeanServer.invoke(ServiceContainer.REMOTING_OBJECT_NAME,
+ "removeInvocationHandler",
+ new Object[] {SUBSYSTEM_LABEL},
+ new String[] {"java.lang.String"});
+ }
+ catch(Exception e)
+ {
+ log.error("Cannot deinstall remoting subsystem", e);
+ }
+
+ delegate = null;
+
+ log.debug(myObjectName + " stopped");
+ }
+
+ public InvocationRequest nextInvocation(Long timeout) throws Exception
+ {
+ if (delegate == null)
+ {
+ return null;
+ }
+
+ return delegate.getNextInvocation(timeout.longValue());
+
+ }
+
+ public boolean isFailed() throws Exception
+ {
+ return delegate.isFailed();
+ }
+
+ // Public ---------------------------------------------------------------------------------------
+
+ // Package protected ----------------------------------------------------------------------------
+
+ // Protected ------------------------------------------------------------------------------------
+
+ // Private --------------------------------------------------------------------------------------
+
+ // Inner classes --------------------------------------------------------------------------------
+
+}
Deleted: branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystemServiceMBean.java
===================================================================
--- branches/Branch_1_0_1_SP/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystemServiceMBean.java 2007-02-11 09:04:09 UTC (rev 2261)
+++ branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystemServiceMBean.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -1,27 +0,0 @@
-/**
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.test.thirdparty.remoting.util;
-
-import org.jboss.remoting.InvocationRequest;
-
-/**
- * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
- * @version <tt>$Revision: 2098 $</tt>
- * $Id: RemotingTestSubsystemServiceMBean.java 2098 2007-01-30 07:21:00Z ovidiu.feodorov at jboss.com $
- */
-public interface RemotingTestSubsystemServiceMBean
-{
- String getSubsystemClassName();
- void setSubsystemClassName(String className);
-
- void start() throws Exception;
- void stop();
-
- InvocationRequest nextInvocation(Long timeout) throws Exception;
-
- boolean isFailed() throws Exception;
-}
Copied: branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystemServiceMBean.java (from rev 2261, branches/Branch_1_0_1_SP/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystemServiceMBean.java)
===================================================================
--- branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystemServiceMBean.java (rev 0)
+++ branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/util/RemotingTestSubsystemServiceMBean.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -0,0 +1,27 @@
+/**
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.test.thirdparty.remoting.util;
+
+import org.jboss.remoting.InvocationRequest;
+
+/**
+ * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
+ * @version <tt>$Revision: 2098 $</tt>
+ * $Id: RemotingTestSubsystemServiceMBean.java 2098 2007-01-30 07:21:00Z ovidiu.feodorov at jboss.com $
+ */
+public interface RemotingTestSubsystemServiceMBean
+{
+ String getSubsystemClassName();
+ void setSubsystemClassName(String className);
+
+ void start() throws Exception;
+ void stop();
+
+ InvocationRequest nextInvocation(Long timeout) throws Exception;
+
+ boolean isFailed() throws Exception;
+}
Deleted: branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/util/SimpleConnectionListener.java
===================================================================
--- branches/Branch_1_0_1_SP/tests/src/org/jboss/test/thirdparty/remoting/util/SimpleConnectionListener.java 2007-02-11 09:04:09 UTC (rev 2261)
+++ branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/util/SimpleConnectionListener.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -1,77 +0,0 @@
-/**
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.test.thirdparty.remoting.util;
-
-import org.jboss.remoting.ConnectionListener;
-import org.jboss.remoting.Client;
-
-import java.io.Serializable;
-
-import EDU.oswego.cs.dl.util.concurrent.Channel;
-import EDU.oswego.cs.dl.util.concurrent.LinkedQueue;
-
-/**
- * It is Serializable so it can be used both on client and on server.
- *
- * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
- * @version <tt>$Revision: 2013 $</tt>
- *
- * $Id: SimpleConnectionListener.java 2013 2007-01-21 10:36:24Z ovidiu.feodorov at jboss.com $
- */
-public class SimpleConnectionListener implements ConnectionListener, Serializable
-{
- // Constants ------------------------------------------------------------------------------------
-
- private static final long serialVersionUID = 5457454557215716L;
-
- // Static ---------------------------------------------------------------------------------------
-
- // Attributes -----------------------------------------------------------------------------------
-
- private transient Channel failures;
-
- // Constructors ---------------------------------------------------------------------------------
-
- // ConnectionListener implementation -----------------------------------------------------------
-
- public void handleConnectionException(Throwable throwable, Client client)
- {
- init();
- try
- {
- failures.put(throwable);
- }
- catch(InterruptedException e)
- {
- throw new RuntimeException("Failed to record failure", e);
- }
- }
-
- // Public ---------------------------------------------------------------------------------------
-
- public Throwable getNextFailure(long timeout) throws InterruptedException
- {
- init();
- return (Throwable)failures.poll(timeout);
- }
-
- // Package protected ----------------------------------------------------------------------------
-
- // Protected ------------------------------------------------------------------------------------
-
- // Private --------------------------------------------------------------------------------------
-
- private synchronized void init()
- {
- if (failures == null)
- {
- failures = new LinkedQueue();
- }
- }
-
- // Inner classes --------------------------------------------------------------------------------
-}
Copied: branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/util/SimpleConnectionListener.java (from rev 2261, branches/Branch_1_0_1_SP/tests/src/org/jboss/test/thirdparty/remoting/util/SimpleConnectionListener.java)
===================================================================
--- branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/util/SimpleConnectionListener.java (rev 0)
+++ branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/util/SimpleConnectionListener.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -0,0 +1,77 @@
+/**
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.test.thirdparty.remoting.util;
+
+import org.jboss.remoting.ConnectionListener;
+import org.jboss.remoting.Client;
+
+import java.io.Serializable;
+
+import EDU.oswego.cs.dl.util.concurrent.Channel;
+import EDU.oswego.cs.dl.util.concurrent.LinkedQueue;
+
+/**
+ * It is Serializable so it can be used both on client and on server.
+ *
+ * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
+ * @version <tt>$Revision: 2013 $</tt>
+ *
+ * $Id: SimpleConnectionListener.java 2013 2007-01-21 10:36:24Z ovidiu.feodorov at jboss.com $
+ */
+public class SimpleConnectionListener implements ConnectionListener, Serializable
+{
+ // Constants ------------------------------------------------------------------------------------
+
+ private static final long serialVersionUID = 5457454557215716L;
+
+ // Static ---------------------------------------------------------------------------------------
+
+ // Attributes -----------------------------------------------------------------------------------
+
+ private transient Channel failures;
+
+ // Constructors ---------------------------------------------------------------------------------
+
+ // ConnectionListener implementation -----------------------------------------------------------
+
+ public void handleConnectionException(Throwable throwable, Client client)
+ {
+ init();
+ try
+ {
+ failures.put(throwable);
+ }
+ catch(InterruptedException e)
+ {
+ throw new RuntimeException("Failed to record failure", e);
+ }
+ }
+
+ // Public ---------------------------------------------------------------------------------------
+
+ public Throwable getNextFailure(long timeout) throws InterruptedException
+ {
+ init();
+ return (Throwable)failures.poll(timeout);
+ }
+
+ // Package protected ----------------------------------------------------------------------------
+
+ // Protected ------------------------------------------------------------------------------------
+
+ // Private --------------------------------------------------------------------------------------
+
+ private synchronized void init()
+ {
+ if (failures == null)
+ {
+ failures = new LinkedQueue();
+ }
+ }
+
+ // Inner classes --------------------------------------------------------------------------------
+}
Deleted: branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/util/TestableSubsystem.java
===================================================================
--- branches/Branch_1_0_1_SP/tests/src/org/jboss/test/thirdparty/remoting/util/TestableSubsystem.java 2007-02-11 09:04:09 UTC (rev 2261)
+++ branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/util/TestableSubsystem.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -1,21 +0,0 @@
-/**
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.test.thirdparty.remoting.util;
-
-import org.jboss.remoting.InvocationRequest;
-
-/**
- * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
- * @version <tt>$Revision: 2098 $</tt>
- * $Id: TestableSubsystem.java 2098 2007-01-30 07:21:00Z ovidiu.feodorov at jboss.com $
- */
-public interface TestableSubsystem
-{
- InvocationRequest getNextInvocation(long timeout) throws InterruptedException;
-
- boolean isFailed();
-}
Copied: branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/util/TestableSubsystem.java (from rev 2261, branches/Branch_1_0_1_SP/tests/src/org/jboss/test/thirdparty/remoting/util/TestableSubsystem.java)
===================================================================
--- branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/util/TestableSubsystem.java (rev 0)
+++ branches/Branch_1_0/tests/src/org/jboss/test/thirdparty/remoting/util/TestableSubsystem.java 2007-02-11 13:16:25 UTC (rev 2264)
@@ -0,0 +1,21 @@
+/**
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.test.thirdparty.remoting.util;
+
+import org.jboss.remoting.InvocationRequest;
+
+/**
+ * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
+ * @version <tt>$Revision: 2098 $</tt>
+ * $Id: TestableSubsystem.java 2098 2007-01-30 07:21:00Z ovidiu.feodorov at jboss.com $
+ */
+public interface TestableSubsystem
+{
+ InvocationRequest getNextInvocation(long timeout) throws InterruptedException;
+
+ boolean isFailed();
+}
Modified: branches/Branch_1_0/util/do-not-distribute.properties
===================================================================
--- branches/Branch_1_0/util/do-not-distribute.properties 2007-02-11 12:25:19 UTC (rev 2263)
+++ branches/Branch_1_0/util/do-not-distribute.properties 2007-02-11 13:16:25 UTC (rev 2264)
@@ -5,8 +5,8 @@
#jboss.home=C:\\work/src/jboss-4.0.1sp1-src/build/output/jboss-4.0.1sp1
#jboss.home=C:\\work/src/cvs/jboss-head/build/output/jboss-5.0.0.Alpha
#jboss.home=C:\\work\\src\\jboss-4.0.3SP1-src\\build\\output\\jboss-4.0.3SP1
-jboss.home=C:\\work\\src\\jboss-4.0.4.GA-src\\build\\output\\jboss-4.0.4.GA
-jboss.home=C:\\work\\src\\jboss-4.0.5.GA-src\\build\\output\\jboss-4.0.5.GA-ejb3
+#jboss.home=C:\\work\\src\\jboss-4.0.4.GA-src\\build\\output\\jboss-4.0.4.GA
+#jboss.home=C:\\work\\src\\jboss-4.0.5.GA-src\\build\\output\\jboss-4.0.5.GA-ejb3
messaging.config.name=messaging
relative.artifact.location=../output/lib
messaging.artifact.name=jboss-messaging-scoped.sar
More information about the jboss-cvs-commits
mailing list