You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by jb...@apache.org on 2015/03/06 23:30:34 UTC
[01/15] activemq-6 git commit: fixing snapshot dependencies after the
release
Repository: activemq-6
Updated Branches:
refs/heads/master b0167ea0c -> f52bc878e
fixing snapshot dependencies after the release
Project: http://git-wip-us.apache.org/repos/asf/activemq-6/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-6/commit/b5a04eb7
Tree: http://git-wip-us.apache.org/repos/asf/activemq-6/tree/b5a04eb7
Diff: http://git-wip-us.apache.org/repos/asf/activemq-6/diff/b5a04eb7
Branch: refs/heads/master
Commit: b5a04eb79f5cebd2bb50af6464822e1a9de266ff
Parents: b0167ea
Author: Clebert Suconic <cl...@apache.org>
Authored: Fri Mar 6 16:53:36 2015 -0500
Committer: Clebert Suconic <cl...@apache.org>
Committed: Fri Mar 6 16:53:36 2015 -0500
----------------------------------------------------------------------
examples/core/embedded-remote/pom.xml | 2 +-
examples/core/embedded/pom.xml | 2 +-
examples/core/perf/pom.xml | 2 +-
examples/core/vertx-connector/pom.xml | 2 +-
examples/jms/activemq-ra-rar/pom.xml | 2 +-
examples/jms/aerogear/pom.xml | 2 +-
examples/jms/applet/pom.xml | 2 +-
examples/jms/application-layer-failover/pom.xml | 2 +-
examples/jms/bridge/pom.xml | 2 +-
examples/jms/browser/pom.xml | 2 +-
examples/jms/client-kickoff/pom.xml | 2 +-
examples/jms/client-side-failoverlistener/pom.xml | 2 +-
examples/jms/client-side-load-balancing/pom.xml | 2 +-
examples/jms/clustered-durable-subscription/pom.xml | 2 +-
examples/jms/clustered-grouping/pom.xml | 2 +-
examples/jms/clustered-jgroups/pom.xml | 2 +-
examples/jms/clustered-queue/pom.xml | 2 +-
examples/jms/clustered-standalone/pom.xml | 2 +-
examples/jms/clustered-static-discovery/pom.xml | 2 +-
examples/jms/clustered-static-oneway/pom.xml | 2 +-
examples/jms/clustered-topic/pom.xml | 2 +-
examples/jms/colocated-failover-scale-down/pom.xml | 2 +-
examples/jms/colocated-failover/pom.xml | 2 +-
examples/jms/consumer-rate-limit/pom.xml | 2 +-
examples/jms/dead-letter/pom.xml | 2 +-
examples/jms/delayed-redelivery/pom.xml | 2 +-
examples/jms/divert/pom.xml | 2 +-
examples/jms/durable-subscription/pom.xml | 2 +-
examples/jms/embedded-simple/pom.xml | 2 +-
examples/jms/embedded/pom.xml | 2 +-
examples/jms/expiry/pom.xml | 2 +-
examples/jms/ha-policy-autobackup/pom.xml | 2 +-
examples/jms/http-transport/pom.xml | 2 +-
examples/jms/instantiate-connection-factory/pom.xml | 2 +-
examples/jms/interceptor/pom.xml | 2 +-
examples/jms/jms-auto-closeable/pom.xml | 2 +-
examples/jms/jms-bridge/pom.xml | 2 +-
examples/jms/jms-completion-listener/pom.xml | 2 +-
examples/jms/jms-context/pom.xml | 2 +-
examples/jms/jms-shared-consumer/pom.xml | 2 +-
examples/jms/jmx/pom.xml | 2 +-
examples/jms/large-message/pom.xml | 2 +-
examples/jms/last-value-queue/pom.xml | 2 +-
examples/jms/management-notifications/pom.xml | 2 +-
examples/jms/management/pom.xml | 2 +-
examples/jms/message-counters/pom.xml | 2 +-
examples/jms/message-group/pom.xml | 2 +-
examples/jms/message-group2/pom.xml | 2 +-
examples/jms/message-priority/pom.xml | 2 +-
examples/jms/multiple-failover-failback/pom.xml | 2 +-
examples/jms/multiple-failover/pom.xml | 2 +-
examples/jms/no-consumer-buffering/pom.xml | 2 +-
examples/jms/non-transaction-failover/pom.xml | 2 +-
examples/jms/openwire/pom.xml | 2 +-
examples/jms/paging/pom.xml | 2 +-
examples/jms/perf/pom.xml | 2 +-
examples/jms/pre-acknowledge/pom.xml | 2 +-
examples/jms/producer-rate-limit/pom.xml | 2 +-
examples/jms/proton-cpp/pom.xml | 2 +-
examples/jms/proton-j/pom.xml | 2 +-
examples/jms/proton-ruby/pom.xml | 2 +-
examples/jms/queue-message-redistribution/pom.xml | 2 +-
examples/jms/queue-requestor/pom.xml | 2 +-
examples/jms/queue-selector/pom.xml | 2 +-
examples/jms/queue/pom.xml | 2 +-
examples/jms/reattach-node/pom.xml | 2 +-
examples/jms/replicated-failback-static/pom.xml | 2 +-
examples/jms/replicated-failback/pom.xml | 2 +-
examples/jms/replicated-multiple-failover/pom.xml | 2 +-
examples/jms/replicated-transaction-failover/pom.xml | 2 +-
examples/jms/request-reply/pom.xml | 2 +-
examples/jms/rest/dup-send/pom.xml | 2 +-
examples/jms/rest/javascript-chat/pom.xml | 2 +-
examples/jms/rest/jms-to-rest/pom.xml | 2 +-
examples/jms/rest/pom.xml | 2 +-
examples/jms/rest/push/pom.xml | 2 +-
examples/jms/scale-down/pom.xml | 2 +-
examples/jms/scheduled-message/pom.xml | 2 +-
examples/jms/security/pom.xml | 2 +-
examples/jms/send-acknowledgements/pom.xml | 2 +-
examples/jms/spring-integration/pom.xml | 2 +-
examples/jms/ssl-enabled/pom.xml | 2 +-
examples/jms/static-selector-jms/pom.xml | 2 +-
examples/jms/static-selector/pom.xml | 2 +-
examples/jms/stomp-websockets/pom.xml | 2 +-
examples/jms/stomp/pom.xml | 2 +-
examples/jms/stomp1.1/pom.xml | 2 +-
examples/jms/stomp1.2/pom.xml | 2 +-
examples/jms/stop-server-failover/pom.xml | 2 +-
examples/jms/symmetric-cluster/pom.xml | 2 +-
examples/jms/temp-queue/pom.xml | 2 +-
examples/jms/topic-hierarchies/pom.xml | 2 +-
examples/jms/topic-selector-example1/pom.xml | 2 +-
examples/jms/topic-selector-example2/pom.xml | 2 +-
examples/jms/topic/pom.xml | 2 +-
examples/jms/transaction-failover/pom.xml | 2 +-
examples/jms/transactional/pom.xml | 2 +-
examples/jms/xa-heuristic/pom.xml | 2 +-
examples/jms/xa-receive/pom.xml | 2 +-
examples/jms/xa-send/pom.xml | 2 +-
examples/soak/normal/pom.xml | 2 +-
examples/soak/pom.xml | 2 +-
tests/byteman-tests/pom.xml | 2 +-
tests/concurrent-tests/pom.xml | 2 +-
tests/integration-tests/pom.xml | 2 +-
tests/jms-tests/pom.xml | 2 +-
tests/joram-tests/pom.xml | 2 +-
tests/performance-tests/pom.xml | 2 +-
tests/pom.xml | 2 +-
tests/soak-tests/pom.xml | 2 +-
tests/stress-tests/pom.xml | 2 +-
tests/timing-tests/pom.xml | 2 +-
tests/unit-tests/pom.xml | 2 +-
113 files changed, 113 insertions(+), 113 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/core/embedded-remote/pom.xml
----------------------------------------------------------------------
diff --git a/examples/core/embedded-remote/pom.xml b/examples/core/embedded-remote/pom.xml
index 93044eb..91ec60e 100644
--- a/examples/core/embedded-remote/pom.xml
+++ b/examples/core/embedded-remote/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.core</groupId>
<artifactId>core-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-core-embedded-remote-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/core/embedded/pom.xml
----------------------------------------------------------------------
diff --git a/examples/core/embedded/pom.xml b/examples/core/embedded/pom.xml
index bcd878f..697101b 100644
--- a/examples/core/embedded/pom.xml
+++ b/examples/core/embedded/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.core</groupId>
<artifactId>core-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-core-embedded-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/core/perf/pom.xml
----------------------------------------------------------------------
diff --git a/examples/core/perf/pom.xml b/examples/core/perf/pom.xml
index f8bc523..1ef4dcc 100644
--- a/examples/core/perf/pom.xml
+++ b/examples/core/perf/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.core</groupId>
<artifactId>core-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-core-perf-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/core/vertx-connector/pom.xml
----------------------------------------------------------------------
diff --git a/examples/core/vertx-connector/pom.xml b/examples/core/vertx-connector/pom.xml
index 0b94b50..8c500f1 100644
--- a/examples/core/vertx-connector/pom.xml
+++ b/examples/core/vertx-connector/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.core</groupId>
<artifactId>core-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-vertx-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/activemq-ra-rar/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/activemq-ra-rar/pom.xml b/examples/jms/activemq-ra-rar/pom.xml
index c3a56cc..d3f2026 100644
--- a/examples/jms/activemq-ra-rar/pom.xml
+++ b/examples/jms/activemq-ra-rar/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-rar</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/aerogear/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/aerogear/pom.xml b/examples/jms/aerogear/pom.xml
index 155a38b..c9cf4c9 100644
--- a/examples/jms/aerogear/pom.xml
+++ b/examples/jms/aerogear/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<properties>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/applet/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/applet/pom.xml b/examples/jms/applet/pom.xml
index 6380dbb..c09ec62 100644
--- a/examples/jms/applet/pom.xml
+++ b/examples/jms/applet/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-applet-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/application-layer-failover/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/application-layer-failover/pom.xml b/examples/jms/application-layer-failover/pom.xml
index 643c002..6092f88 100644
--- a/examples/jms/application-layer-failover/pom.xml
+++ b/examples/jms/application-layer-failover/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-application-layer-failover-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/bridge/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/bridge/pom.xml b/examples/jms/bridge/pom.xml
index 5e543c2..d5cb9ea 100644
--- a/examples/jms/bridge/pom.xml
+++ b/examples/jms/bridge/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-bridge-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/browser/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/browser/pom.xml b/examples/jms/browser/pom.xml
index f399c71..51892e0 100644
--- a/examples/jms/browser/pom.xml
+++ b/examples/jms/browser/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-browser-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/client-kickoff/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/client-kickoff/pom.xml b/examples/jms/client-kickoff/pom.xml
index 0f088b7..442d88a 100644
--- a/examples/jms/client-kickoff/pom.xml
+++ b/examples/jms/client-kickoff/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-client-kickoff-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/client-side-failoverlistener/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/client-side-failoverlistener/pom.xml b/examples/jms/client-side-failoverlistener/pom.xml
index 1498db8..2e116e9 100644
--- a/examples/jms/client-side-failoverlistener/pom.xml
+++ b/examples/jms/client-side-failoverlistener/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-client-side-fileoverlistener-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/client-side-load-balancing/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/client-side-load-balancing/pom.xml b/examples/jms/client-side-load-balancing/pom.xml
index 72dc7d3..b1896a9 100644
--- a/examples/jms/client-side-load-balancing/pom.xml
+++ b/examples/jms/client-side-load-balancing/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-client-side-load-balancing-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/clustered-durable-subscription/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-durable-subscription/pom.xml b/examples/jms/clustered-durable-subscription/pom.xml
index 3044c71..43d8ae7 100644
--- a/examples/jms/clustered-durable-subscription/pom.xml
+++ b/examples/jms/clustered-durable-subscription/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-clustered-durable-subscription-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/clustered-grouping/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-grouping/pom.xml b/examples/jms/clustered-grouping/pom.xml
index d84dc90..ffd3ea5 100644
--- a/examples/jms/clustered-grouping/pom.xml
+++ b/examples/jms/clustered-grouping/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-clustered-grouping-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/clustered-jgroups/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-jgroups/pom.xml b/examples/jms/clustered-jgroups/pom.xml
index 6c5b79b..61dd54e 100644
--- a/examples/jms/clustered-jgroups/pom.xml
+++ b/examples/jms/clustered-jgroups/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>clustered-jgroups</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/clustered-queue/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-queue/pom.xml b/examples/jms/clustered-queue/pom.xml
index e637561..d6d0aa3 100644
--- a/examples/jms/clustered-queue/pom.xml
+++ b/examples/jms/clustered-queue/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>clustered-queue</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/clustered-standalone/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-standalone/pom.xml b/examples/jms/clustered-standalone/pom.xml
index 323f94e..6542869 100644
--- a/examples/jms/clustered-standalone/pom.xml
+++ b/examples/jms/clustered-standalone/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-clustered-standalone-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/clustered-static-discovery/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-static-discovery/pom.xml b/examples/jms/clustered-static-discovery/pom.xml
index c8e17c4..48c0d4d 100644
--- a/examples/jms/clustered-static-discovery/pom.xml
+++ b/examples/jms/clustered-static-discovery/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-clustered-static-discovery-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/clustered-static-oneway/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-static-oneway/pom.xml b/examples/jms/clustered-static-oneway/pom.xml
index 0ff0e61..ec9af39 100644
--- a/examples/jms/clustered-static-oneway/pom.xml
+++ b/examples/jms/clustered-static-oneway/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-clustered-static-oneway-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/clustered-topic/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/clustered-topic/pom.xml b/examples/jms/clustered-topic/pom.xml
index 415b5ca..f28b58a 100644
--- a/examples/jms/clustered-topic/pom.xml
+++ b/examples/jms/clustered-topic/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-clustered-topic-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/colocated-failover-scale-down/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/colocated-failover-scale-down/pom.xml b/examples/jms/colocated-failover-scale-down/pom.xml
index ace154d..64238e6 100644
--- a/examples/jms/colocated-failover-scale-down/pom.xml
+++ b/examples/jms/colocated-failover-scale-down/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>colocated-failover-scale-down</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/colocated-failover/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/colocated-failover/pom.xml b/examples/jms/colocated-failover/pom.xml
index 7a0e915..11c28a9 100644
--- a/examples/jms/colocated-failover/pom.xml
+++ b/examples/jms/colocated-failover/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>colocated-failover</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/consumer-rate-limit/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/consumer-rate-limit/pom.xml b/examples/jms/consumer-rate-limit/pom.xml
index ebd38e1..2269fd7 100644
--- a/examples/jms/consumer-rate-limit/pom.xml
+++ b/examples/jms/consumer-rate-limit/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-consumer-rate-limit-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/dead-letter/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/dead-letter/pom.xml b/examples/jms/dead-letter/pom.xml
index 48e83b2..4fa9bca 100644
--- a/examples/jms/dead-letter/pom.xml
+++ b/examples/jms/dead-letter/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-dead-letter-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/delayed-redelivery/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/delayed-redelivery/pom.xml b/examples/jms/delayed-redelivery/pom.xml
index aaa243d..eb24e1d 100644
--- a/examples/jms/delayed-redelivery/pom.xml
+++ b/examples/jms/delayed-redelivery/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-delayed-redelivery-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/divert/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/divert/pom.xml b/examples/jms/divert/pom.xml
index 51c139f..2651264 100644
--- a/examples/jms/divert/pom.xml
+++ b/examples/jms/divert/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-divert-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/durable-subscription/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/durable-subscription/pom.xml b/examples/jms/durable-subscription/pom.xml
index 1ec4173..ab00230 100644
--- a/examples/jms/durable-subscription/pom.xml
+++ b/examples/jms/durable-subscription/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-durable-subscription-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/embedded-simple/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/embedded-simple/pom.xml b/examples/jms/embedded-simple/pom.xml
index 8ee8f00..f988743 100644
--- a/examples/jms/embedded-simple/pom.xml
+++ b/examples/jms/embedded-simple/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-embedded-simple-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/embedded/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/embedded/pom.xml b/examples/jms/embedded/pom.xml
index ee662b6..0ed98b3 100644
--- a/examples/jms/embedded/pom.xml
+++ b/examples/jms/embedded/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-embedded-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/expiry/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/expiry/pom.xml b/examples/jms/expiry/pom.xml
index fc53819..470ce64 100644
--- a/examples/jms/expiry/pom.xml
+++ b/examples/jms/expiry/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-expiry-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/ha-policy-autobackup/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/ha-policy-autobackup/pom.xml b/examples/jms/ha-policy-autobackup/pom.xml
index 1d95ce9..34e537f 100644
--- a/examples/jms/ha-policy-autobackup/pom.xml
+++ b/examples/jms/ha-policy-autobackup/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>ha-policy-autobackup</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/http-transport/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/http-transport/pom.xml b/examples/jms/http-transport/pom.xml
index a98c42e..e50d33b 100644
--- a/examples/jms/http-transport/pom.xml
+++ b/examples/jms/http-transport/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-http-transport-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/instantiate-connection-factory/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/instantiate-connection-factory/pom.xml b/examples/jms/instantiate-connection-factory/pom.xml
index 0feefe7..5c5b146 100644
--- a/examples/jms/instantiate-connection-factory/pom.xml
+++ b/examples/jms/instantiate-connection-factory/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-instantiate-connection-factory-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/interceptor/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/interceptor/pom.xml b/examples/jms/interceptor/pom.xml
index 7542c97..7eb9bd2 100644
--- a/examples/jms/interceptor/pom.xml
+++ b/examples/jms/interceptor/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-interceptor-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/jms-auto-closeable/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/jms-auto-closeable/pom.xml b/examples/jms/jms-auto-closeable/pom.xml
index 08cb5c5..07ff9c7 100644
--- a/examples/jms/jms-auto-closeable/pom.xml
+++ b/examples/jms/jms-auto-closeable/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-auto-closeable-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/jms-bridge/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/jms-bridge/pom.xml b/examples/jms/jms-bridge/pom.xml
index b1f5657..ba67817 100644
--- a/examples/jms/jms-bridge/pom.xml
+++ b/examples/jms/jms-bridge/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-jms-bridge-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/jms-completion-listener/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/jms-completion-listener/pom.xml b/examples/jms/jms-completion-listener/pom.xml
index 016ed96..bc3d2a5 100644
--- a/examples/jms/jms-completion-listener/pom.xml
+++ b/examples/jms/jms-completion-listener/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-completion-listener-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/jms-context/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/jms-context/pom.xml b/examples/jms/jms-context/pom.xml
index b26dbe6..9005f28 100644
--- a/examples/jms/jms-context/pom.xml
+++ b/examples/jms/jms-context/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-context-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/jms-shared-consumer/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/jms-shared-consumer/pom.xml b/examples/jms/jms-shared-consumer/pom.xml
index 160514f..68c2581 100644
--- a/examples/jms/jms-shared-consumer/pom.xml
+++ b/examples/jms/jms-shared-consumer/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-shared-consumer-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/jmx/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/jmx/pom.xml b/examples/jms/jmx/pom.xml
index 6f94acc..dbf0d95 100644
--- a/examples/jms/jmx/pom.xml
+++ b/examples/jms/jmx/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-jmx-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/large-message/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/large-message/pom.xml b/examples/jms/large-message/pom.xml
index 94a9177..eb7a06a 100644
--- a/examples/jms/large-message/pom.xml
+++ b/examples/jms/large-message/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-large-message-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/last-value-queue/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/last-value-queue/pom.xml b/examples/jms/last-value-queue/pom.xml
index fd1c984..24acc75 100644
--- a/examples/jms/last-value-queue/pom.xml
+++ b/examples/jms/last-value-queue/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-last-value-queue-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/management-notifications/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/management-notifications/pom.xml b/examples/jms/management-notifications/pom.xml
index d9d3ada..c9fd2fa 100644
--- a/examples/jms/management-notifications/pom.xml
+++ b/examples/jms/management-notifications/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-management-notifications-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/management/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/management/pom.xml b/examples/jms/management/pom.xml
index 24c995f..d6e70ca 100644
--- a/examples/jms/management/pom.xml
+++ b/examples/jms/management/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-management-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/message-counters/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/message-counters/pom.xml b/examples/jms/message-counters/pom.xml
index 84a3b30..a429a78 100644
--- a/examples/jms/message-counters/pom.xml
+++ b/examples/jms/message-counters/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-message-counters-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/message-group/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/message-group/pom.xml b/examples/jms/message-group/pom.xml
index bea5966..575f0e6 100644
--- a/examples/jms/message-group/pom.xml
+++ b/examples/jms/message-group/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-message-group-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/message-group2/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/message-group2/pom.xml b/examples/jms/message-group2/pom.xml
index 514d2fc..081a828 100644
--- a/examples/jms/message-group2/pom.xml
+++ b/examples/jms/message-group2/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-message-group2-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/message-priority/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/message-priority/pom.xml b/examples/jms/message-priority/pom.xml
index 0e69b56..acceb38 100644
--- a/examples/jms/message-priority/pom.xml
+++ b/examples/jms/message-priority/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-message-priority-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/multiple-failover-failback/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/multiple-failover-failback/pom.xml b/examples/jms/multiple-failover-failback/pom.xml
index 4340245..98b4cfb 100644
--- a/examples/jms/multiple-failover-failback/pom.xml
+++ b/examples/jms/multiple-failover-failback/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-multiple-failover-failback-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/multiple-failover/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/multiple-failover/pom.xml b/examples/jms/multiple-failover/pom.xml
index e94d855..b908ab3 100644
--- a/examples/jms/multiple-failover/pom.xml
+++ b/examples/jms/multiple-failover/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-multiple-failover-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/no-consumer-buffering/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/no-consumer-buffering/pom.xml b/examples/jms/no-consumer-buffering/pom.xml
index 68eea6b..c52775d 100644
--- a/examples/jms/no-consumer-buffering/pom.xml
+++ b/examples/jms/no-consumer-buffering/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-no-consumer-buffering-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/non-transaction-failover/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/non-transaction-failover/pom.xml b/examples/jms/non-transaction-failover/pom.xml
index ce21ab6..ac56075 100644
--- a/examples/jms/non-transaction-failover/pom.xml
+++ b/examples/jms/non-transaction-failover/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>non-transaction-failover</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/openwire/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/openwire/pom.xml b/examples/jms/openwire/pom.xml
index 7db1b2d..4457a6f 100644
--- a/examples/jms/openwire/pom.xml
+++ b/examples/jms/openwire/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-openwire-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/paging/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/paging/pom.xml b/examples/jms/paging/pom.xml
index 24f1521..9f4ca09 100644
--- a/examples/jms/paging/pom.xml
+++ b/examples/jms/paging/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-paging-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/perf/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/perf/pom.xml b/examples/jms/perf/pom.xml
index fe4fc01..77bff21 100644
--- a/examples/jms/perf/pom.xml
+++ b/examples/jms/perf/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-perf-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/pre-acknowledge/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/pre-acknowledge/pom.xml b/examples/jms/pre-acknowledge/pom.xml
index 9acf235..5ef6f0c 100644
--- a/examples/jms/pre-acknowledge/pom.xml
+++ b/examples/jms/pre-acknowledge/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-pre-acknowledge-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/producer-rate-limit/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/producer-rate-limit/pom.xml b/examples/jms/producer-rate-limit/pom.xml
index ffb7104..32b45ca 100644
--- a/examples/jms/producer-rate-limit/pom.xml
+++ b/examples/jms/producer-rate-limit/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-producer-rate-limit-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/proton-cpp/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/proton-cpp/pom.xml b/examples/jms/proton-cpp/pom.xml
index f060cef..a8141bb 100644
--- a/examples/jms/proton-cpp/pom.xml
+++ b/examples/jms/proton-cpp/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-protoncpp</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/proton-j/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/proton-j/pom.xml b/examples/jms/proton-j/pom.xml
index a461ebf..455c600 100644
--- a/examples/jms/proton-j/pom.xml
+++ b/examples/jms/proton-j/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-proton-j-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/proton-ruby/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/proton-ruby/pom.xml b/examples/jms/proton-ruby/pom.xml
index 46ca091..8f1f648 100644
--- a/examples/jms/proton-ruby/pom.xml
+++ b/examples/jms/proton-ruby/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-proton-ruby-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/queue-message-redistribution/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/queue-message-redistribution/pom.xml b/examples/jms/queue-message-redistribution/pom.xml
index 1aff7e0..7b17a27 100644
--- a/examples/jms/queue-message-redistribution/pom.xml
+++ b/examples/jms/queue-message-redistribution/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-queue-message-redistribution-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/queue-requestor/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/queue-requestor/pom.xml b/examples/jms/queue-requestor/pom.xml
index a5beffc..59d4413 100644
--- a/examples/jms/queue-requestor/pom.xml
+++ b/examples/jms/queue-requestor/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-queue-requestor-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/queue-selector/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/queue-selector/pom.xml b/examples/jms/queue-selector/pom.xml
index 50bb7ec..0f4f2d3 100644
--- a/examples/jms/queue-selector/pom.xml
+++ b/examples/jms/queue-selector/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-queue-selector-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/queue/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/queue/pom.xml b/examples/jms/queue/pom.xml
index cb92211..412c6a6 100644
--- a/examples/jms/queue/pom.xml
+++ b/examples/jms/queue/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-queue-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/reattach-node/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/reattach-node/pom.xml b/examples/jms/reattach-node/pom.xml
index 13c6547..9ca8b32 100644
--- a/examples/jms/reattach-node/pom.xml
+++ b/examples/jms/reattach-node/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-reattach-node-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/replicated-failback-static/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/replicated-failback-static/pom.xml b/examples/jms/replicated-failback-static/pom.xml
index ec6b1bb..8c668df 100644
--- a/examples/jms/replicated-failback-static/pom.xml
+++ b/examples/jms/replicated-failback-static/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-replicated-failback-static-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/replicated-failback/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/replicated-failback/pom.xml b/examples/jms/replicated-failback/pom.xml
index 498bc1a..f8b87fe 100644
--- a/examples/jms/replicated-failback/pom.xml
+++ b/examples/jms/replicated-failback/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-replicated-failback-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/replicated-multiple-failover/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/replicated-multiple-failover/pom.xml b/examples/jms/replicated-multiple-failover/pom.xml
index 8f57a01..c22a131 100644
--- a/examples/jms/replicated-multiple-failover/pom.xml
+++ b/examples/jms/replicated-multiple-failover/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-replicated-multiple-failover-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/replicated-transaction-failover/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/replicated-transaction-failover/pom.xml b/examples/jms/replicated-transaction-failover/pom.xml
index 3aa787e..4e6481b 100644
--- a/examples/jms/replicated-transaction-failover/pom.xml
+++ b/examples/jms/replicated-transaction-failover/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-replicated-transaction-failover-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/request-reply/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/request-reply/pom.xml b/examples/jms/request-reply/pom.xml
index 0ed6707..1efced5 100644
--- a/examples/jms/request-reply/pom.xml
+++ b/examples/jms/request-reply/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-request-reply-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/rest/dup-send/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/rest/dup-send/pom.xml b/examples/jms/rest/dup-send/pom.xml
index 666f410..e4d011f 100644
--- a/examples/jms/rest/dup-send/pom.xml
+++ b/examples/jms/rest/dup-send/pom.xml
@@ -24,7 +24,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.rest.examples</groupId>
<artifactId>activemq-rest-examples-pom</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>dup-send</artifactId>
<packaging>war</packaging>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/rest/javascript-chat/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/rest/javascript-chat/pom.xml b/examples/jms/rest/javascript-chat/pom.xml
index 7221ea4..34b62bd 100644
--- a/examples/jms/rest/javascript-chat/pom.xml
+++ b/examples/jms/rest/javascript-chat/pom.xml
@@ -24,7 +24,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.rest.examples</groupId>
<artifactId>activemq-rest-examples-pom</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>javascript-chat</artifactId>
<packaging>war</packaging>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/rest/jms-to-rest/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/rest/jms-to-rest/pom.xml b/examples/jms/rest/jms-to-rest/pom.xml
index 54131dd..f8af591 100644
--- a/examples/jms/rest/jms-to-rest/pom.xml
+++ b/examples/jms/rest/jms-to-rest/pom.xml
@@ -24,7 +24,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.rest.examples</groupId>
<artifactId>activemq-rest-examples-pom</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>mixed-jms-rest</artifactId>
<packaging>war</packaging>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/rest/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/rest/pom.xml b/examples/jms/rest/pom.xml
index 345387a..d4496ca 100644
--- a/examples/jms/rest/pom.xml
+++ b/examples/jms/rest/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<groupId>org.apache.activemq.rest.examples</groupId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/rest/push/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/rest/push/pom.xml b/examples/jms/rest/push/pom.xml
index 22fe50c..26b6315 100644
--- a/examples/jms/rest/push/pom.xml
+++ b/examples/jms/rest/push/pom.xml
@@ -24,7 +24,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.rest.examples</groupId>
<artifactId>activemq-rest-examples-pom</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>push</artifactId>
<packaging>war</packaging>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/scale-down/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/scale-down/pom.xml b/examples/jms/scale-down/pom.xml
index dbccd49..9656872 100644
--- a/examples/jms/scale-down/pom.xml
+++ b/examples/jms/scale-down/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>scale-down</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/scheduled-message/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/scheduled-message/pom.xml b/examples/jms/scheduled-message/pom.xml
index f3fd1bd..285b6ca 100644
--- a/examples/jms/scheduled-message/pom.xml
+++ b/examples/jms/scheduled-message/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-scheduled-message-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/security/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/security/pom.xml b/examples/jms/security/pom.xml
index db98baa..2b01429 100644
--- a/examples/jms/security/pom.xml
+++ b/examples/jms/security/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-security-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/send-acknowledgements/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/send-acknowledgements/pom.xml b/examples/jms/send-acknowledgements/pom.xml
index 95b6aa6..6e62ebc 100644
--- a/examples/jms/send-acknowledgements/pom.xml
+++ b/examples/jms/send-acknowledgements/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-send-acknowledgements-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/spring-integration/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/spring-integration/pom.xml b/examples/jms/spring-integration/pom.xml
index c24bfa7..424eda7 100644
--- a/examples/jms/spring-integration/pom.xml
+++ b/examples/jms/spring-integration/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-spring-integration-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/ssl-enabled/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/ssl-enabled/pom.xml b/examples/jms/ssl-enabled/pom.xml
index 015b72d..1327824 100644
--- a/examples/jms/ssl-enabled/pom.xml
+++ b/examples/jms/ssl-enabled/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-ssl-enabled-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/static-selector-jms/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/static-selector-jms/pom.xml b/examples/jms/static-selector-jms/pom.xml
index 16824ba..122ad5f 100644
--- a/examples/jms/static-selector-jms/pom.xml
+++ b/examples/jms/static-selector-jms/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-static-selector-jms-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/static-selector/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/static-selector/pom.xml b/examples/jms/static-selector/pom.xml
index 80380a5..680cb78 100644
--- a/examples/jms/static-selector/pom.xml
+++ b/examples/jms/static-selector/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-static-selector-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/stomp-websockets/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/stomp-websockets/pom.xml b/examples/jms/stomp-websockets/pom.xml
index d05748e..a93e665 100644
--- a/examples/jms/stomp-websockets/pom.xml
+++ b/examples/jms/stomp-websockets/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-stomp-websockets-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/stomp/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/stomp/pom.xml b/examples/jms/stomp/pom.xml
index e8c1cdc..19d4048 100644
--- a/examples/jms/stomp/pom.xml
+++ b/examples/jms/stomp/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-stomp-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/stomp1.1/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/stomp1.1/pom.xml b/examples/jms/stomp1.1/pom.xml
index d1cc801..a7ca522 100644
--- a/examples/jms/stomp1.1/pom.xml
+++ b/examples/jms/stomp1.1/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-stomp1.1-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/stomp1.2/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/stomp1.2/pom.xml b/examples/jms/stomp1.2/pom.xml
index 6ef423b..0375a48 100644
--- a/examples/jms/stomp1.2/pom.xml
+++ b/examples/jms/stomp1.2/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-stomp1.2-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/stop-server-failover/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/stop-server-failover/pom.xml b/examples/jms/stop-server-failover/pom.xml
index 2e2deae..c1fce77 100644
--- a/examples/jms/stop-server-failover/pom.xml
+++ b/examples/jms/stop-server-failover/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-stop-server-failover-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/symmetric-cluster/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/symmetric-cluster/pom.xml b/examples/jms/symmetric-cluster/pom.xml
index 913a8e6..200c4be 100644
--- a/examples/jms/symmetric-cluster/pom.xml
+++ b/examples/jms/symmetric-cluster/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-symmetric-cluster-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/temp-queue/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/temp-queue/pom.xml b/examples/jms/temp-queue/pom.xml
index 8d14ba3..6574b3e 100644
--- a/examples/jms/temp-queue/pom.xml
+++ b/examples/jms/temp-queue/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-temp-queue-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/topic-hierarchies/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/topic-hierarchies/pom.xml b/examples/jms/topic-hierarchies/pom.xml
index 52eba52..0787010 100644
--- a/examples/jms/topic-hierarchies/pom.xml
+++ b/examples/jms/topic-hierarchies/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-topic-hierarchies-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/topic-selector-example1/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/topic-selector-example1/pom.xml b/examples/jms/topic-selector-example1/pom.xml
index d57cdeb..65ad547 100644
--- a/examples/jms/topic-selector-example1/pom.xml
+++ b/examples/jms/topic-selector-example1/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-topic-selector-example1-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/topic-selector-example2/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/topic-selector-example2/pom.xml b/examples/jms/topic-selector-example2/pom.xml
index a7f1ecd..f7d8afb 100644
--- a/examples/jms/topic-selector-example2/pom.xml
+++ b/examples/jms/topic-selector-example2/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-topic-selector-example2-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/topic/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/topic/pom.xml b/examples/jms/topic/pom.xml
index 2c8d91f..47afc56 100644
--- a/examples/jms/topic/pom.xml
+++ b/examples/jms/topic/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-topic-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/transaction-failover/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/transaction-failover/pom.xml b/examples/jms/transaction-failover/pom.xml
index 3730318..b7887ab 100644
--- a/examples/jms/transaction-failover/pom.xml
+++ b/examples/jms/transaction-failover/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-transaction-failover-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/transactional/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/transactional/pom.xml b/examples/jms/transactional/pom.xml
index 7dfb9b8..c66afe0 100644
--- a/examples/jms/transactional/pom.xml
+++ b/examples/jms/transactional/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-transactional-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/xa-heuristic/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/xa-heuristic/pom.xml b/examples/jms/xa-heuristic/pom.xml
index 167cc54..df9144d 100644
--- a/examples/jms/xa-heuristic/pom.xml
+++ b/examples/jms/xa-heuristic/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-xa-heuristic-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/xa-receive/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/xa-receive/pom.xml b/examples/jms/xa-receive/pom.xml
index fff7652..fc7c3e5 100644
--- a/examples/jms/xa-receive/pom.xml
+++ b/examples/jms/xa-receive/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-xa-receive-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/jms/xa-send/pom.xml
----------------------------------------------------------------------
diff --git a/examples/jms/xa-send/pom.xml b/examples/jms/xa-send/pom.xml
index 6f97c07..1e3e7d9 100644
--- a/examples/jms/xa-send/pom.xml
+++ b/examples/jms/xa-send/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples.jms</groupId>
<artifactId>jms-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>activemq-jms-xa-send-example</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/soak/normal/pom.xml
----------------------------------------------------------------------
diff --git a/examples/soak/normal/pom.xml b/examples/soak/normal/pom.xml
index 61ee70e..0913e65 100644
--- a/examples/soak/normal/pom.xml
+++ b/examples/soak/normal/pom.xml
@@ -29,7 +29,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.example.soak</groupId>
<artifactId>soak-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<dependencies>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/examples/soak/pom.xml
----------------------------------------------------------------------
diff --git a/examples/soak/pom.xml b/examples/soak/pom.xml
index c23f290..aa6961b 100644
--- a/examples/soak/pom.xml
+++ b/examples/soak/pom.xml
@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.activemq.examples</groupId>
<artifactId>activemq-examples</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<groupId>org.apache.activemq.example.soak</groupId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/tests/byteman-tests/pom.xml
----------------------------------------------------------------------
diff --git a/tests/byteman-tests/pom.xml b/tests/byteman-tests/pom.xml
index 5002c5c..0fbd682 100644
--- a/tests/byteman-tests/pom.xml
+++ b/tests/byteman-tests/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>org.apache.activemq.tests</groupId>
<artifactId>activemq-tests-pom</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>byteman-tests</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/tests/concurrent-tests/pom.xml
----------------------------------------------------------------------
diff --git a/tests/concurrent-tests/pom.xml b/tests/concurrent-tests/pom.xml
index 773c7d0..01c361c 100644
--- a/tests/concurrent-tests/pom.xml
+++ b/tests/concurrent-tests/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>org.apache.activemq.tests</groupId>
<artifactId>activemq-tests-pom</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>concurrent-tests</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/tests/integration-tests/pom.xml
----------------------------------------------------------------------
diff --git a/tests/integration-tests/pom.xml b/tests/integration-tests/pom.xml
index 3b3017c..6eb00bf 100644
--- a/tests/integration-tests/pom.xml
+++ b/tests/integration-tests/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>org.apache.activemq.tests</groupId>
<artifactId>activemq-tests-pom</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>integration-tests</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/tests/jms-tests/pom.xml
----------------------------------------------------------------------
diff --git a/tests/jms-tests/pom.xml b/tests/jms-tests/pom.xml
index c2034fe..4b3595e 100644
--- a/tests/jms-tests/pom.xml
+++ b/tests/jms-tests/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>org.apache.activemq.tests</groupId>
<artifactId>activemq-tests-pom</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>jms-tests</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/tests/joram-tests/pom.xml
----------------------------------------------------------------------
diff --git a/tests/joram-tests/pom.xml b/tests/joram-tests/pom.xml
index fac51b4..81c0fd3 100644
--- a/tests/joram-tests/pom.xml
+++ b/tests/joram-tests/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>org.apache.activemq.tests</groupId>
<artifactId>activemq-tests-pom</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>joram-tests</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/tests/performance-tests/pom.xml
----------------------------------------------------------------------
diff --git a/tests/performance-tests/pom.xml b/tests/performance-tests/pom.xml
index 4457b83..3e6dc27 100644
--- a/tests/performance-tests/pom.xml
+++ b/tests/performance-tests/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>org.apache.activemq.tests</groupId>
<artifactId>activemq-tests-pom</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>performance-tests</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/tests/pom.xml
----------------------------------------------------------------------
diff --git a/tests/pom.xml b/tests/pom.xml
index 65c02c2..0686523 100644
--- a/tests/pom.xml
+++ b/tests/pom.xml
@@ -19,7 +19,7 @@
<parent>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-pom</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<name>ActiveMQ6 Tests POM</name>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/tests/soak-tests/pom.xml
----------------------------------------------------------------------
diff --git a/tests/soak-tests/pom.xml b/tests/soak-tests/pom.xml
index a87cdf9..a789581 100644
--- a/tests/soak-tests/pom.xml
+++ b/tests/soak-tests/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>org.apache.activemq.tests</groupId>
<artifactId>activemq-tests-pom</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>soak-tests</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/tests/stress-tests/pom.xml
----------------------------------------------------------------------
diff --git a/tests/stress-tests/pom.xml b/tests/stress-tests/pom.xml
index 0cb9eed..b51dbbf 100644
--- a/tests/stress-tests/pom.xml
+++ b/tests/stress-tests/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>org.apache.activemq.tests</groupId>
<artifactId>activemq-tests-pom</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>stress-tests</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/tests/timing-tests/pom.xml
----------------------------------------------------------------------
diff --git a/tests/timing-tests/pom.xml b/tests/timing-tests/pom.xml
index db859c3..7a1def1 100644
--- a/tests/timing-tests/pom.xml
+++ b/tests/timing-tests/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>org.apache.activemq.tests</groupId>
<artifactId>activemq-tests-pom</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>timing-tests</artifactId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/b5a04eb7/tests/unit-tests/pom.xml
----------------------------------------------------------------------
diff --git a/tests/unit-tests/pom.xml b/tests/unit-tests/pom.xml
index 776929c..87a4fb2 100644
--- a/tests/unit-tests/pom.xml
+++ b/tests/unit-tests/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>org.apache.activemq.tests</groupId>
<artifactId>activemq-tests-pom</artifactId>
- <version>6.0.0</version>
+ <version>6.0.1-SNAPSHOT</version>
</parent>
<artifactId>unit-tests</artifactId>
[04/15] activemq-6 git commit: Refactored the testsuite a bit
Posted by jb...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/XATest.java
----------------------------------------------------------------------
diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/XATest.java b/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/XATest.java
deleted file mode 100644
index 019b534..0000000
--- a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/XATest.java
+++ /dev/null
@@ -1,2336 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.jms.tests;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.DeliveryMode;
-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.jms.XAConnection;
-import javax.jms.XAConnectionFactory;
-import javax.jms.XASession;
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
-import javax.transaction.xa.XAException;
-import javax.transaction.xa.XAResource;
-import javax.transaction.xa.Xid;
-
-import com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionManagerImple;
-
-import org.apache.activemq.core.client.impl.ClientSessionInternal;
-import org.apache.activemq.jms.tests.util.ProxyAssertSupport;
-import org.jboss.tm.TxUtils;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- *
- * A XATestBase
- *
- * @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
- * @author <a href="mailto:clebert.suconic@jboss.com">Clebert Suconic</a>
- * @version <tt>$Revision: 1.1 $</tt>
- *
- *
- */
-public class XATest extends ActiveMQServerTestCase
-{
- // Constants -----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- protected TransactionManager tm;
-
- protected Transaction suspendedTx;
-
- protected XAConnectionFactory xacf;
-
- protected ConnectionFactory cf;
-
- // Constructors --------------------------------------------------
-
- // TestCase overrides -------------------------------------------
-
- @Override
- @Before
- public void setUp() throws Exception
- {
- super.setUp();
-
- cf = getConnectionFactory();
-
- xacf = getXAConnectionFactory();
-
- tm = getTransactionManager();
-
- ProxyAssertSupport.assertTrue(tm instanceof TransactionManagerImple);
-
- suspendedTx = tm.suspend();
- }
-
- @Override
- @After
- public void tearDown() throws Exception
- {
- if (TxUtils.isUncommitted(tm))
- {
- // roll it back
- try
- {
- tm.rollback();
- }
- catch (Throwable ignore)
- {
- // The connection will probably be closed so this may well throw an exception
- }
- }
- if (tm.getTransaction() != null)
- {
- Transaction tx = tm.suspend();
- if (tx != null)
- {
- log.warn("Transaction still associated with thread " + tx +
- " at status " +
- TxUtils.getStatusAsString(tx.getStatus()));
- }
- }
-
- if (suspendedTx != null)
- {
- tm.resume(suspendedTx);
- }
- }
-
- // Public --------------------------------------------------------
-
- @Test
- public void test2PCSendCommit1PCOptimization() throws Exception
- {
- // Since both resources have same RM, TM will probably use 1PC optimization
-
- XAConnection conn = null;
- Connection conn2 = null;
-
- try
- {
- conn = xacf.createXAConnection();
-
- tm.begin();
-
- XASession sess = conn.createXASession();
- XAResource res = sess.getXAResource();
-
- XAResource res2 = new DummyXAResource();
-
- Transaction tx = tm.getTransaction();
- tx.enlistResource(res);
- tx.enlistResource(res2);
-
- MessageProducer prod = sess.createProducer(queue1);
- prod.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
- Message m = sess.createTextMessage("XATest1");
- prod.send(queue1, m);
- m = sess.createTextMessage("XATest2");
- prod.send(queue1, m);
-
- tx.delistResource(res, XAResource.TMSUCCESS);
- tx.delistResource(res2, XAResource.TMSUCCESS);
-
- tm.commit();
-
- conn2 = cf.createConnection();
- conn2.start();
- Session sessReceiver = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageConsumer cons = sessReceiver.createConsumer(queue1);
- TextMessage m2 = (TextMessage)cons.receive(1000);
- ProxyAssertSupport.assertNotNull(m2);
- ProxyAssertSupport.assertEquals("XATest1", m2.getText());
- m2 = (TextMessage)cons.receive(1000);
- ProxyAssertSupport.assertNotNull(m2);
- ProxyAssertSupport.assertEquals("XATest2", m2.getText());
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- if (conn2 != null)
- {
- conn2.close();
- }
- }
- }
-
- @Test
- public void test2PCSendCommit() throws Exception
- {
- XAConnection conn = null;
- Connection conn2 = null;
-
- try
- {
- conn = xacf.createXAConnection();
-
- tm.begin();
-
- XASession sess = conn.createXASession();
-
- XAResource res = sess.getXAResource();
- XAResource res2 = new DummyXAResource();
-
- // To prevent 1PC optimization being used
- // res.setForceNotSameRM(true);
-
- Transaction tx = tm.getTransaction();
-
- tx.enlistResource(res);
-
- tx.enlistResource(res2);
-
- MessageProducer prod = sess.createProducer(queue1);
- prod.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
- Message m = sess.createTextMessage("XATest1");
- prod.send(queue1, m);
- m = sess.createTextMessage("XATest2");
- prod.send(queue1, m);
-
- tx.delistResource(res, XAResource.TMSUCCESS);
- tx.delistResource(res2, XAResource.TMSUCCESS);
-
- tm.commit();
-
- conn2 = cf.createConnection();
- conn2.start();
- Session sessReceiver = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageConsumer cons = sessReceiver.createConsumer(queue1);
- TextMessage m2 = (TextMessage)cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
- ProxyAssertSupport.assertNotNull(m2);
- ProxyAssertSupport.assertEquals("XATest1", m2.getText());
- m2 = (TextMessage)cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
- ProxyAssertSupport.assertNotNull(m2);
- ProxyAssertSupport.assertEquals("XATest2", m2.getText());
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- if (conn2 != null)
- {
- conn2.close();
- }
- }
- }
-
- @Test
- public void test2PCSendRollback1PCOptimization() throws Exception
- {
- // Since both resources have some RM, TM will probably use 1PC optimization
-
- XAConnection conn = null;
- Connection conn2 = null;
- try
- {
- conn = xacf.createXAConnection();
-
- tm.begin();
-
- XASession sess = conn.createXASession();
- XAResource res = sess.getXAResource();
-
- XAResource res2 = new DummyXAResource();
-
- Transaction tx = tm.getTransaction();
- tx.enlistResource(res);
- tx.enlistResource(res2);
-
- MessageProducer prod = sess.createProducer(queue1);
- prod.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
- Message m = sess.createTextMessage("XATest1");
- prod.send(queue1, m);
- m = sess.createTextMessage("XATest2");
- prod.send(queue1, m);
-
- tx.delistResource(res, XAResource.TMSUCCESS);
- tx.delistResource(res2, XAResource.TMSUCCESS);
-
- tm.rollback();
-
- conn2 = cf.createConnection();
- conn2.start();
- Session sessReceiver = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageConsumer cons = sessReceiver.createConsumer(queue1);
- Message m2 = cons.receive(ActiveMQServerTestCase.MIN_TIMEOUT);
- ProxyAssertSupport.assertNull(m2);
-
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- if (conn2 != null)
- {
- conn2.close();
- }
- }
- }
-
- @Test
- public void test2PCSendFailOnPrepare() throws Exception
- {
- XAConnection conn = null;
- Connection conn2 = null;
- try
- {
- conn = xacf.createXAConnection();
-
- tm.begin();
-
- XASession sess = conn.createXASession();
- XAResource res = sess.getXAResource();
-
- // prevent 1Pc optimisation
- // res.setForceNotSameRM(true);
-
- XAResource res2 = new DummyXAResource(true);
- XAResource res3 = new DummyXAResource();
- XAResource res4 = new DummyXAResource();
-
- Transaction tx = tm.getTransaction();
- tx.enlistResource(res);
- tx.enlistResource(res2);
- tx.enlistResource(res3);
- tx.enlistResource(res4);
-
- MessageProducer prod = sess.createProducer(queue1);
- prod.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
- Message m = sess.createTextMessage("XATest1");
- prod.send(queue1, m);
- m = sess.createTextMessage("XATest2");
- prod.send(queue1, m);
-
- tx.delistResource(res, XAResource.TMSUCCESS);
- tx.delistResource(res2, XAResource.TMSUCCESS);
- tx.delistResource(res3, XAResource.TMSUCCESS);
- tx.delistResource(res4, XAResource.TMSUCCESS);
-
- try
- {
- tm.commit();
-
- ProxyAssertSupport.fail("should not get here");
- }
- catch (Exception e)
- {
- // We should expect this
- }
-
- conn2 = cf.createConnection();
- conn2.start();
- Session sessReceiver = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageConsumer cons = sessReceiver.createConsumer(queue1);
- Message m2 = cons.receive(ActiveMQServerTestCase.MIN_TIMEOUT);
- ProxyAssertSupport.assertNull(m2);
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- if (conn2 != null)
- {
- conn2.close();
- }
- }
- }
-
- @Test
- public void test2PCSendRollback() throws Exception
- {
- XAConnection conn = null;
- Connection conn2 = null;
- try
- {
- conn = xacf.createXAConnection();
-
- tm.begin();
-
- XASession sess = conn.createXASession();
- XAResource res = sess.getXAResource();
-
- // prevent 1Pc optimisation
- // res.setForceNotSameRM(true);
-
- XAResource res2 = new DummyXAResource();
-
- Transaction tx = tm.getTransaction();
- tx.enlistResource(res);
- tx.enlistResource(res2);
-
- MessageProducer prod = sess.createProducer(queue1);
- prod.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
- Message m = sess.createTextMessage("XATest1");
- prod.send(queue1, m);
- m = sess.createTextMessage("XATest2");
- prod.send(queue1, m);
-
- tx.delistResource(res, XAResource.TMSUCCESS);
- tx.delistResource(res2, XAResource.TMSUCCESS);
-
- tm.rollback();
-
- conn2 = cf.createConnection();
- conn2.start();
- Session sessReceiver = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageConsumer cons = sessReceiver.createConsumer(queue1);
- Message m2 = cons.receive(ActiveMQServerTestCase.MIN_TIMEOUT);
- ProxyAssertSupport.assertNull(m2);
-
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- if (conn2 != null)
- {
- conn2.close();
- }
- }
- }
-
- @Test
- public void test2PCReceiveCommit1PCOptimization() throws Exception
- {
- // Since both resources have some RM, TM will probably use 1PC optimization
-
- XAConnection conn = null;
- Connection conn2 = null;
-
- try
- {
- conn2 = cf.createConnection();
- conn2.start();
- Session sessProducer = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageProducer prod = sessProducer.createProducer(queue1);
- Message m = sessProducer.createTextMessage("XATest1");
- prod.send(m);
- m = sessProducer.createTextMessage("XATest2");
- prod.send(m);
-
- conn = xacf.createXAConnection();
- conn.start();
-
- tm.begin();
-
- XASession sess = conn.createXASession();
- XAResource res = sess.getXAResource();
-
- XAResource res2 = new DummyXAResource();
-
- Transaction tx = tm.getTransaction();
- tx.enlistResource(res);
- tx.enlistResource(res2);
-
- MessageConsumer cons = sess.createConsumer(queue1);
-
- TextMessage m2 = (TextMessage)cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
-
- ProxyAssertSupport.assertNotNull(m2);
- ProxyAssertSupport.assertEquals("XATest1", m2.getText());
-
- m2 = (TextMessage)cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
-
- ProxyAssertSupport.assertNotNull(m2);
- ProxyAssertSupport.assertEquals("XATest2", m2.getText());
-
- tx.delistResource(res, XAResource.TMSUCCESS);
- tx.delistResource(res2, XAResource.TMSUCCESS);
-
- tm.commit();
-
- // New tx
- tm.begin();
- tx = tm.getTransaction();
- tx.enlistResource(res);
- tx.enlistResource(res2);
-
- Message m3 = cons.receive(ActiveMQServerTestCase.MIN_TIMEOUT);
-
- ProxyAssertSupport.assertNull(m3);
-
- tx.delistResource(res, XAResource.TMSUCCESS);
- tx.delistResource(res2, XAResource.TMSUCCESS);
-
- tm.commit();
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- if (conn2 != null)
- {
- conn2.close();
- }
- }
-
- }
-
- @Test
- public void test2PCReceiveCommit() throws Exception
- {
- XAConnection conn = null;
- Connection conn2 = null;
-
- try
- {
- conn2 = cf.createConnection();
- conn2.start();
- Session sessProducer = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageProducer prod = sessProducer.createProducer(queue1);
- Message m = sessProducer.createTextMessage("XATest1");
- prod.send(m);
- m = sessProducer.createTextMessage("XATest2");
- prod.send(m);
-
- conn = xacf.createXAConnection();
- conn.start();
-
- tm.begin();
-
- XASession sess = conn.createXASession();
- XAResource res = sess.getXAResource();
- // res.setForceNotSameRM(true);
-
- XAResource res2 = new DummyXAResource();
-
- Transaction tx = tm.getTransaction();
- tx.enlistResource(res);
- tx.enlistResource(res2);
-
- MessageConsumer cons = sess.createConsumer(queue1);
-
- TextMessage m2 = (TextMessage)cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
-
- ProxyAssertSupport.assertNotNull(m2);
- ProxyAssertSupport.assertEquals("XATest1", m2.getText());
-
- m2 = (TextMessage)cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
-
- ProxyAssertSupport.assertNotNull(m2);
- ProxyAssertSupport.assertEquals("XATest2", m2.getText());
-
- tx.delistResource(res, XAResource.TMSUCCESS);
- tx.delistResource(res2, XAResource.TMSUCCESS);
-
- tm.commit();
-
- // New tx
- tm.begin();
- tx = tm.getTransaction();
- tx.enlistResource(res);
- tx.enlistResource(res2);
-
- Message m3 = cons.receive(ActiveMQServerTestCase.MIN_TIMEOUT);
-
- ProxyAssertSupport.assertNull(m3);
-
- tx.delistResource(res, XAResource.TMSUCCESS);
- tx.delistResource(res2, XAResource.TMSUCCESS);
-
- tm.commit();
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- if (conn2 != null)
- {
- conn2.close();
- }
- }
-
- }
-
- @Test
- public void test2PCReceiveRollback1PCOptimization() throws Exception
- {
- // Since both resources have some RM, TM will probably use 1PC optimization
-
- XAConnection conn = null;
- Connection conn2 = null;
-
- try
- {
- conn2 = cf.createConnection();
- Session sessProducer = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageProducer prod = sessProducer.createProducer(queue1);
- Message m = sessProducer.createTextMessage("XATest1");
- prod.send(m);
-
- m = sessProducer.createTextMessage("XATest2");
- prod.send(m);
-
- conn = xacf.createXAConnection();
- conn.start();
-
- tm.begin();
-
- XASession sess = conn.createXASession();
- XAResource res = sess.getXAResource();
-
- XAResource res2 = new DummyXAResource();
-
- Transaction tx = tm.getTransaction();
- tx.enlistResource(res);
- tx.enlistResource(res2);
-
- MessageConsumer cons = sess.createConsumer(queue1);
-
- TextMessage m2 = (TextMessage)cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
- ProxyAssertSupport.assertNotNull(m2);
- ProxyAssertSupport.assertEquals("XATest1", m2.getText());
- m2 = (TextMessage)cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
- ProxyAssertSupport.assertNotNull(m2);
- ProxyAssertSupport.assertEquals("XATest2", m2.getText());
-
- tx.delistResource(res, XAResource.TMSUCCESS);
- tx.delistResource(res2, XAResource.TMSUCCESS);
-
- tm.rollback();
-
- // Message should be redelivered
-
- // New tx
- tm.begin();
- tx = tm.getTransaction();
- tx.enlistResource(res);
- tx.enlistResource(res2);
-
- TextMessage m3 = (TextMessage)cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
- ProxyAssertSupport.assertNotNull(m3);
- ProxyAssertSupport.assertEquals("XATest1", m3.getText());
- m3 = (TextMessage)cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
- ProxyAssertSupport.assertNotNull(m3);
- ProxyAssertSupport.assertEquals("XATest2", m3.getText());
-
- ProxyAssertSupport.assertTrue(m3.getJMSRedelivered());
-
- tx.delistResource(res, XAResource.TMSUCCESS);
- tx.delistResource(res2, XAResource.TMSUCCESS);
-
- tm.commit();
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- if (conn2 != null)
- {
- conn2.close();
- }
- }
- }
-
- @Test
- public void test2PCReceiveRollback() throws Exception
- {
- XAConnection conn = null;
- Connection conn2 = null;
-
- try
- {
- conn2 = cf.createConnection();
- Session sessProducer = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageProducer prod = sessProducer.createProducer(queue1);
- Message m = sessProducer.createTextMessage("XATest1");
- prod.send(m);
-
- m = sessProducer.createTextMessage("XATest2");
- prod.send(m);
-
- conn = xacf.createXAConnection();
- conn.start();
-
- tm.begin();
-
- XASession sess = conn.createXASession();
- XAResource res = sess.getXAResource();
- // res.setForceNotSameRM(true);
-
- XAResource res2 = new DummyXAResource();
-
- Transaction tx = tm.getTransaction();
- tx.enlistResource(res);
- tx.enlistResource(res2);
-
- MessageConsumer cons = sess.createConsumer(queue1);
-
- TextMessage m2 = (TextMessage)cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
- ProxyAssertSupport.assertNotNull(m2);
- ProxyAssertSupport.assertEquals("XATest1", m2.getText());
- m2 = (TextMessage)cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
- ProxyAssertSupport.assertNotNull(m2);
- ProxyAssertSupport.assertEquals("XATest2", m2.getText());
-
- tx.delistResource(res, XAResource.TMSUCCESS);
- tx.delistResource(res2, XAResource.TMSUCCESS);
-
- tm.rollback();
-
- // Message should be redelivered
-
- // New tx
- tm.begin();
- tx = tm.getTransaction();
- tx.enlistResource(res);
- tx.enlistResource(res2);
-
- TextMessage m3 = (TextMessage)cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
- ProxyAssertSupport.assertNotNull(m3);
- ProxyAssertSupport.assertEquals("XATest1", m3.getText());
- m3 = (TextMessage)cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
- ProxyAssertSupport.assertNotNull(m3);
- ProxyAssertSupport.assertEquals("XATest2", m3.getText());
-
- ProxyAssertSupport.assertTrue(m3.getJMSRedelivered());
-
- tx.delistResource(res, XAResource.TMSUCCESS);
- tx.delistResource(res2, XAResource.TMSUCCESS);
-
- tm.commit();
-
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- if (conn2 != null)
- {
- conn2.close();
- }
- }
-
- }
-
- @Test
- public void test1PCSendCommit() throws Exception
- {
- XAConnection conn = null;
- Connection conn2 = null;
-
- try
- {
- conn = xacf.createXAConnection();
-
- tm.begin();
-
- XASession sess = conn.createXASession();
- XAResource res = sess.getXAResource();
-
- Transaction tx = tm.getTransaction();
- tx.enlistResource(res);
-
- MessageProducer prod = sess.createProducer(queue1);
- prod.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
- Message m = sess.createTextMessage("XATest1");
- prod.send(queue1, m);
- m = sess.createTextMessage("XATest2");
- prod.send(queue1, m);
-
- tx.delistResource(res, XAResource.TMSUCCESS);
-
- tm.commit();
-
- conn2 = cf.createConnection();
- conn2.start();
- Session sessReceiver = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageConsumer cons = sessReceiver.createConsumer(queue1);
- TextMessage m2 = (TextMessage)cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
- ProxyAssertSupport.assertNotNull(m2);
- ProxyAssertSupport.assertEquals("XATest1", m2.getText());
- m2 = (TextMessage)cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
- ProxyAssertSupport.assertNotNull(m2);
- ProxyAssertSupport.assertEquals("XATest2", m2.getText());
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- if (conn2 != null)
- {
- conn2.close();
- }
- }
-
- }
-
- @Test
- public void test1PCSendRollback() throws Exception
- {
- XAConnection conn = null;
- Connection conn2 = null;
- try
- {
- conn = xacf.createXAConnection();
-
- tm.begin();
-
- XASession sess = conn.createXASession();
- XAResource res = sess.getXAResource();
-
- Transaction tx = tm.getTransaction();
- tx.enlistResource(res);
-
- MessageProducer prod = sess.createProducer(queue1);
- prod.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
- Message m = sess.createTextMessage("XATest1");
- prod.send(queue1, m);
- m = sess.createTextMessage("XATest2");
- prod.send(queue1, m);
-
- tx.delistResource(res, XAResource.TMSUCCESS);
-
- tm.rollback();
-
- conn2 = cf.createConnection();
- conn2.start();
- Session sessReceiver = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageConsumer cons = sessReceiver.createConsumer(queue1);
- Message m2 = cons.receive(ActiveMQServerTestCase.MIN_TIMEOUT);
- ProxyAssertSupport.assertNull(m2);
-
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- if (conn2 != null)
- {
- conn2.close();
- }
- }
- }
-
- @Test
- public void test1PCReceiveCommit() throws Exception
- {
- XAConnection conn = null;
- Connection conn2 = null;
-
- try
- {
- conn2 = cf.createConnection();
- conn2.start();
- Session sessProducer = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageProducer prod = sessProducer.createProducer(queue1);
- Message m = sessProducer.createTextMessage("XATest1");
- prod.send(m);
- m = sessProducer.createTextMessage("XATest2");
- prod.send(m);
-
- conn = xacf.createXAConnection();
- conn.start();
-
- tm.begin();
-
- XASession sess = conn.createXASession();
- XAResource res = sess.getXAResource();
-
- Transaction tx = tm.getTransaction();
- tx.enlistResource(res);
-
- MessageConsumer cons = sess.createConsumer(queue1);
-
- TextMessage m2 = (TextMessage)cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
-
- ProxyAssertSupport.assertNotNull(m2);
- ProxyAssertSupport.assertEquals("XATest1", m2.getText());
- m2 = (TextMessage)cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
-
- ProxyAssertSupport.assertNotNull(m2);
- ProxyAssertSupport.assertEquals("XATest2", m2.getText());
-
- tx.delistResource(res, XAResource.TMSUCCESS);
-
- tm.commit();
-
- // New tx
- tm.begin();
- tx = tm.getTransaction();
- tx.enlistResource(res);
-
- Message m3 = cons.receive(ActiveMQServerTestCase.MIN_TIMEOUT);
-
- ProxyAssertSupport.assertNull(m3);
-
- tx.delistResource(res, XAResource.TMSUCCESS);
-
- tm.commit();
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- if (conn2 != null)
- {
- conn2.close();
- }
- }
-
- }
-
- @Test
- public void test1PCReceiveRollback() throws Exception
- {
- XAConnection conn = null;
- Connection conn2 = null;
-
- try
- {
- conn2 = cf.createConnection();
- Session sessProducer = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageProducer prod = sessProducer.createProducer(queue1);
- Message m = sessProducer.createTextMessage("XATest1");
- prod.send(m);
- m = sessProducer.createTextMessage("XATest2");
- prod.send(m);
-
- conn = xacf.createXAConnection();
- conn.start();
-
- tm.begin();
-
- XASession sess = conn.createXASession();
- XAResource res = sess.getXAResource();
-
- Transaction tx = tm.getTransaction();
- tx.enlistResource(res);
-
- MessageConsumer cons = sess.createConsumer(queue1);
-
- TextMessage m2 = (TextMessage)cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
-
- ProxyAssertSupport.assertNotNull(m2);
- ProxyAssertSupport.assertEquals("XATest1", m2.getText());
-
- m2 = (TextMessage)cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
-
- ProxyAssertSupport.assertNotNull(m2);
- ProxyAssertSupport.assertEquals("XATest2", m2.getText());
-
- tx.delistResource(res, XAResource.TMSUCCESS);
-
- tm.rollback();
-
- // Message should be redelivered
-
- // New tx
- tm.begin();
- tx = tm.getTransaction();
- tx.enlistResource(res);
-
- TextMessage m3 = (TextMessage)cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
-
- ProxyAssertSupport.assertNotNull(m3);
- ProxyAssertSupport.assertEquals("XATest1", m3.getText());
-
- m3 = (TextMessage)cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
-
- ProxyAssertSupport.assertNotNull(m3);
- ProxyAssertSupport.assertEquals("XATest2", m3.getText());
-
- ProxyAssertSupport.assertTrue(m3.getJMSRedelivered());
-
- tx.delistResource(res, XAResource.TMSUCCESS);
-
- tm.commit();
-
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- if (conn2 != null)
- {
- conn2.close();
- }
- }
-
- }
-
- @Test
- public void testMultipleSessionsOneTxCommitAcknowledge1PCOptimization() throws Exception
- {
- XAConnection conn = null;
- Connection conn2 = null;
-
- // Since both resources have some RM, TM will probably use 1PC optimization
-
- try
- {
- // First send 2 messages
- conn2 = cf.createConnection();
- Session sessProducer = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageProducer prod = sessProducer.createProducer(queue1);
- Message m = sessProducer.createTextMessage("jellyfish1");
- prod.send(m);
- m = sessProducer.createTextMessage("jellyfish2");
- prod.send(m);
-
- conn = xacf.createXAConnection();
- conn.start();
-
- tm.begin();
-
- // Create 2 sessions and enlist them
- XASession sess1 = conn.createXASession();
- XAResource res1 = sess1.getXAResource();
- XASession sess2 = conn.createXASession();
- XAResource res2 = sess2.getXAResource();
-
- Transaction tx = tm.getTransaction();
- tx.enlistResource(res1);
- tx.enlistResource(res2);
-
- // Receive the messages, one on each consumer
- MessageConsumer cons1 = sess1.createConsumer(queue1);
- TextMessage r1 = (TextMessage)cons1.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
-
- ProxyAssertSupport.assertNotNull(r1);
- ProxyAssertSupport.assertEquals("jellyfish1", r1.getText());
-
- cons1.close();
-
- MessageConsumer cons2 = sess2.createConsumer(queue1);
- TextMessage r2 = (TextMessage)cons2.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
-
- ProxyAssertSupport.assertNotNull(r2);
- ProxyAssertSupport.assertEquals("jellyfish2", r2.getText());
-
- tx.delistResource(res1, XAResource.TMSUCCESS);
- tx.delistResource(res2, XAResource.TMSUCCESS);
-
- // commit
- tm.commit();
-
- Session sess = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageConsumer cons = sess.createConsumer(queue1);
- conn2.start();
-
- TextMessage r3 = (TextMessage)cons.receive(ActiveMQServerTestCase.MIN_TIMEOUT);
- ProxyAssertSupport.assertNull(r3);
-
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- if (conn2 != null)
- {
- conn2.close();
- }
- }
-
- }
-
- @Test
- public void testMultipleSessionsOneTxCommitAcknowledge() throws Exception
- {
- XAConnection conn = null;
- Connection conn2 = null;
-
- try
- {
- // First send 2 messages
- conn2 = cf.createConnection();
- Session sessProducer = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageProducer prod = sessProducer.createProducer(queue1);
- Message m = sessProducer.createTextMessage("jellyfish1");
- prod.send(m);
- m = sessProducer.createTextMessage("jellyfish2");
- prod.send(m);
-
- conn = xacf.createXAConnection();
- conn.start();
-
- tm.begin();
-
- // Create 2 sessions and enlist them
- XASession sess1 = conn.createXASession();
- ClientSessionInternal res1 = (ClientSessionInternal)sess1.getXAResource();
- XASession sess2 = conn.createXASession();
- ClientSessionInternal res2 = (ClientSessionInternal)sess2.getXAResource();
- res1.setForceNotSameRM(true);
- res2.setForceNotSameRM(true);
-
- Transaction tx = tm.getTransaction();
- tx.enlistResource(res1);
- tx.enlistResource(res2);
-
- // Receive the messages, one on each consumer
- MessageConsumer cons1 = sess1.createConsumer(queue1);
- TextMessage r1 = (TextMessage)cons1.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
-
- ProxyAssertSupport.assertNotNull(r1);
- ProxyAssertSupport.assertEquals("jellyfish1", r1.getText());
-
- cons1.close();
-
- MessageConsumer cons2 = sess2.createConsumer(queue1);
- TextMessage r2 = (TextMessage)cons2.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
-
- ProxyAssertSupport.assertNotNull(r2);
- ProxyAssertSupport.assertEquals("jellyfish2", r2.getText());
-
- tx.delistResource(res1, XAResource.TMSUCCESS);
- tx.delistResource(res2, XAResource.TMSUCCESS);
-
- // commit
- tm.commit();
-
- Session sess = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageConsumer cons = sess.createConsumer(queue1);
- conn2.start();
-
- TextMessage r3 = (TextMessage)cons.receive(ActiveMQServerTestCase.MIN_TIMEOUT);
- ProxyAssertSupport.assertNull(r3);
-
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- if (conn2 != null)
- {
- conn2.close();
- }
- }
-
- }
-
- @Test
- public void testMultipleSessionsOneTxRollbackAcknowledge1PCOptimization() throws Exception
- {
- XAConnection conn = null;
- Connection conn2 = null;
-
- // Since both resources have some RM, TM will probably use 1PC optimization
-
- try
- {
- // First send 2 messages
- conn2 = cf.createConnection();
- Session sessProducer = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageProducer prod = sessProducer.createProducer(queue1);
- Message m = sessProducer.createTextMessage("jellyfish1");
- prod.send(m);
- m = sessProducer.createTextMessage("jellyfish2");
- prod.send(m);
- m = sessProducer.createTextMessage("jellyfish3");
- prod.send(m);
- m = sessProducer.createTextMessage("jellyfish4");
- prod.send(m);
-
- conn = xacf.createXAConnection();
- conn.start();
-
- tm.begin();
-
- // Create 2 sessions and enlist them
- XASession sess1 = conn.createXASession();
- ClientSessionInternal res1 = (ClientSessionInternal)sess1.getXAResource();
- XASession sess2 = conn.createXASession();
- ClientSessionInternal res2 = (ClientSessionInternal)sess2.getXAResource();
-
- Transaction tx = tm.getTransaction();
- tx.enlistResource(res1);
- tx.enlistResource(res2);
-
- // Receive the messages, two on each consumer
- MessageConsumer cons1 = sess1.createConsumer(queue1);
- TextMessage r1 = (TextMessage)cons1.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
-
- ProxyAssertSupport.assertNotNull(r1);
- ProxyAssertSupport.assertEquals("jellyfish1", r1.getText());
-
- r1 = (TextMessage)cons1.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
-
- ProxyAssertSupport.assertNotNull(r1);
- ProxyAssertSupport.assertEquals("jellyfish2", r1.getText());
-
- cons1.close();
-
- MessageConsumer cons2 = sess2.createConsumer(queue1);
- TextMessage r2 = (TextMessage)cons2.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
-
- ProxyAssertSupport.assertNotNull(r2);
- ProxyAssertSupport.assertEquals("jellyfish3", r2.getText());
-
- r2 = (TextMessage)cons2.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
-
- ProxyAssertSupport.assertNotNull(r2);
- ProxyAssertSupport.assertEquals("jellyfish4", r2.getText());
-
- cons2.close();
-
- // rollback
-
- tx.delistResource(res1, XAResource.TMSUCCESS);
- tx.delistResource(res2, XAResource.TMSUCCESS);
-
- tm.rollback();
-
- // Rollback causes cancel which is asynch
- Thread.sleep(1000);
-
- // We cannot assume anything about the order in which the transaction manager rollsback
- // the sessions - this is implementation dependent
-
- Session sess = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageConsumer cons = sess.createConsumer(queue1);
- conn2.start();
-
- TextMessage r = (TextMessage)cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
- ProxyAssertSupport.assertNotNull(r);
-
- boolean session1First = false;
-
- if (r.getText().equals("jellyfish1"))
- {
- session1First = true;
- }
- else if (r.getText().equals("jellyfish3"))
- {
- session1First = false;
- }
- else
- {
- ProxyAssertSupport.fail("Unexpected message");
- }
-
- if (session1First)
- {
- r = (TextMessage)cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
-
- ProxyAssertSupport.assertNotNull(r);
-
- ProxyAssertSupport.assertEquals("jellyfish2", r.getText());
-
- r = (TextMessage)cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
-
- ProxyAssertSupport.assertNotNull(r);
-
- ProxyAssertSupport.assertEquals("jellyfish3", r.getText());
-
- r = (TextMessage)cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
-
- ProxyAssertSupport.assertNotNull(r);
-
- ProxyAssertSupport.assertEquals("jellyfish4", r.getText());
-
- }
- else
- {
- r = (TextMessage)cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
-
- ProxyAssertSupport.assertNotNull(r);
-
- ProxyAssertSupport.assertEquals("jellyfish4", r.getText());
-
- r = (TextMessage)cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
-
- ProxyAssertSupport.assertNotNull(r);
-
- ProxyAssertSupport.assertEquals("jellyfish1", r.getText());
-
- r = (TextMessage)cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
-
- ProxyAssertSupport.assertNotNull(r);
-
- ProxyAssertSupport.assertEquals("jellyfish2", r.getText());
- }
-
- r = (TextMessage)cons.receive(ActiveMQServerTestCase.MIN_TIMEOUT);
-
- ProxyAssertSupport.assertNull(r);
-
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- if (conn2 != null)
- {
- conn2.close();
- }
- }
-
- }
-
- @Test
- public void testMultipleSessionsOneTxRollbackAcknowledge() throws Exception
- {
- XAConnection conn = null;
- Connection conn2 = null;
-
- try
- {
- // First send 2 messages
- conn2 = cf.createConnection();
- Session sessProducer = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageProducer prod = sessProducer.createProducer(queue1);
- Message m = sessProducer.createTextMessage("jellyfish1");
- prod.send(m);
- m = sessProducer.createTextMessage("jellyfish2");
- prod.send(m);
- m = sessProducer.createTextMessage("jellyfish3");
- prod.send(m);
- m = sessProducer.createTextMessage("jellyfish4");
- prod.send(m);
-
- conn = xacf.createXAConnection();
- conn.start();
-
- tm.begin();
-
- // Create 2 sessions and enlist them
- XASession sess1 = conn.createXASession();
- ClientSessionInternal res1 = (ClientSessionInternal)sess1.getXAResource();
- XASession sess2 = conn.createXASession();
- ClientSessionInternal res2 = (ClientSessionInternal)sess2.getXAResource();
- res1.setForceNotSameRM(true);
- res2.setForceNotSameRM(true);
-
- Transaction tx = tm.getTransaction();
- tx.enlistResource(res1);
- tx.enlistResource(res2);
-
- // Receive the messages, two on each consumer
- MessageConsumer cons1 = sess1.createConsumer(queue1);
- TextMessage r1 = (TextMessage)cons1.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
-
- ProxyAssertSupport.assertNotNull(r1);
- ProxyAssertSupport.assertEquals("jellyfish1", r1.getText());
-
- r1 = (TextMessage)cons1.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
-
- ProxyAssertSupport.assertNotNull(r1);
- ProxyAssertSupport.assertEquals("jellyfish2", r1.getText());
-
- cons1.close();
-
- // Cancel is asynch
- Thread.sleep(500);
-
- MessageConsumer cons2 = sess2.createConsumer(queue1);
- TextMessage r2 = (TextMessage)cons2.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
-
- ProxyAssertSupport.assertNotNull(r2);
- ProxyAssertSupport.assertEquals("jellyfish3", r2.getText());
-
- r2 = (TextMessage)cons2.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
-
- ProxyAssertSupport.assertNotNull(r2);
- ProxyAssertSupport.assertEquals("jellyfish4", r2.getText());
-
- // rollback
-
- cons2.close();
-
- tx.delistResource(res1, XAResource.TMSUCCESS);
- tx.delistResource(res2, XAResource.TMSUCCESS);
-
- tm.rollback();
-
- // Rollback causes cancel which is asynch
- Thread.sleep(1000);
-
- // We cannot assume anything about the order in which the transaction manager rollsback
- // the sessions - this is implementation dependent
-
- Session sess = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageConsumer cons = sess.createConsumer(queue1);
- conn2.start();
-
- TextMessage r = (TextMessage)cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
- ProxyAssertSupport.assertNotNull(r);
-
- boolean session1First = false;
-
- if (r.getText().equals("jellyfish1"))
- {
- session1First = true;
- }
- else if (r.getText().equals("jellyfish3"))
- {
- session1First = false;
- }
- else
- {
- ProxyAssertSupport.fail("Unexpected message");
- }
-
- if (session1First)
- {
- r = (TextMessage)cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
-
- ProxyAssertSupport.assertNotNull(r);
-
- ProxyAssertSupport.assertEquals("jellyfish2", r.getText());
-
- r = (TextMessage)cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
-
- ProxyAssertSupport.assertNotNull(r);
-
- ProxyAssertSupport.assertEquals("jellyfish3", r.getText());
-
- r = (TextMessage)cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
-
- ProxyAssertSupport.assertNotNull(r);
-
- ProxyAssertSupport.assertEquals("jellyfish4", r.getText());
-
- }
- else
- {
- r = (TextMessage)cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
-
- ProxyAssertSupport.assertNotNull(r);
-
- ProxyAssertSupport.assertEquals("jellyfish4", r.getText());
-
- r = (TextMessage)cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
-
- ProxyAssertSupport.assertNotNull(r);
-
- ProxyAssertSupport.assertEquals("jellyfish1", r.getText());
-
- r = (TextMessage)cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
-
- ProxyAssertSupport.assertNotNull(r);
-
- ProxyAssertSupport.assertEquals("jellyfish2", r.getText());
- }
-
- r = (TextMessage)cons.receive(ActiveMQServerTestCase.MIN_TIMEOUT);
-
- ProxyAssertSupport.assertNull(r);
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- if (conn2 != null)
- {
- conn2.close();
- }
- }
- }
-
- @Test
- public void testMultipleSessionsOneTxRollbackAcknowledgeForceFailureInCommit() throws Exception
- {
- XAConnection conn = null;
- Connection conn2 = null;
-
- try
- {
- // First send 4 messages
- conn2 = cf.createConnection();
- Session sessProducer = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageProducer prod = sessProducer.createProducer(queue1);
-
- Message m = sessProducer.createTextMessage("jellyfish1");
- prod.send(m);
- m = sessProducer.createTextMessage("jellyfish2");
- prod.send(m);
- m = sessProducer.createTextMessage("jellyfish3");
- prod.send(m);
- m = sessProducer.createTextMessage("jellyfish4");
- prod.send(m);
-
- conn = xacf.createXAConnection();
- conn.start();
-
- tm.begin();
-
- XASession sess1 = conn.createXASession();
- XAResource res1 = sess1.getXAResource();
- DummyXAResource res2 = new DummyXAResource(true);
-
- Transaction tx = tm.getTransaction();
- tx.enlistResource(res1);
- tx.enlistResource(res2);
-
- MessageConsumer cons1 = sess1.createConsumer(queue1);
- TextMessage r1 = (TextMessage)cons1.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
-
- ProxyAssertSupport.assertNotNull(r1);
- ProxyAssertSupport.assertEquals("jellyfish1", r1.getText());
-
- r1 = (TextMessage)cons1.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
-
- ProxyAssertSupport.assertNotNull(r1);
- ProxyAssertSupport.assertEquals("jellyfish2", r1.getText());
-
- r1 = (TextMessage)cons1.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
-
- ProxyAssertSupport.assertNotNull(r1);
- ProxyAssertSupport.assertEquals("jellyfish3", r1.getText());
-
- r1 = (TextMessage)cons1.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
-
- ProxyAssertSupport.assertNotNull(r1);
- ProxyAssertSupport.assertEquals("jellyfish4", r1.getText());
-
- r1 = (TextMessage)cons1.receive(1000);
-
- ProxyAssertSupport.assertNull(r1);
-
- cons1.close();
-
- // try and commit - and we're going to make the dummyxaresource throw an exception on commit,
- // which should cause rollback to be called on the other resource
-
- tx.delistResource(res1, XAResource.TMSUCCESS);
- tx.delistResource(res2, XAResource.TMSUCCESS);
-
- // rollback will cause an attempt to deliver messages locally to the original consumers.
- // the original consumer has closed, so it will cancelled to the server
- // the server cancel is asynch, so we need to sleep for a bit to make sure it completes
- log.trace("Forcing failure");
- try
- {
- tm.commit();
- ProxyAssertSupport.fail("should not get here");
- }
- catch (Exception e)
- {
- // We should expect this
- }
-
- Thread.sleep(1000);
-
- Session sess = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageConsumer cons = sess.createConsumer(queue1);
- conn2.start();
-
- TextMessage r = (TextMessage)cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
-
- ProxyAssertSupport.assertNotNull(r);
-
- ProxyAssertSupport.assertEquals("jellyfish1", r.getText());
-
- r = (TextMessage)cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
-
- ProxyAssertSupport.assertNotNull(r);
-
- ProxyAssertSupport.assertEquals("jellyfish2", r.getText());
-
- r = (TextMessage)cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
-
- ProxyAssertSupport.assertNotNull(r);
-
- ProxyAssertSupport.assertEquals("jellyfish3", r.getText());
-
- r = (TextMessage)cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
-
- ProxyAssertSupport.assertNotNull(r);
-
- ProxyAssertSupport.assertEquals("jellyfish4", r.getText());
-
- r = (TextMessage)cons.receive(ActiveMQServerTestCase.MIN_TIMEOUT);
-
- ProxyAssertSupport.assertNull(r);
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- if (conn2 != null)
- {
- conn2.close();
- }
- }
-
- }
-
- @Test
- public void testMultipleSessionsOneTxCommitSend1PCOptimization() throws Exception
- {
- // Since both resources have some RM, TM will probably use 1PC optimization
-
- XAConnection conn = null;
-
- Connection conn2 = null;
-
- try
- {
- conn = xacf.createXAConnection();
- conn.start();
-
- tm.begin();
-
- // Create 2 sessions and enlist them
- XASession sess1 = conn.createXASession();
- XAResource res1 = sess1.getXAResource();
- XASession sess2 = conn.createXASession();
- XAResource res2 = sess2.getXAResource();
-
- Transaction tx = tm.getTransaction();
- tx.enlistResource(res1);
- tx.enlistResource(res2);
-
- // Send 2 messages - one from each session
-
- MessageProducer prod1 = sess1.createProducer(queue1);
- MessageProducer prod2 = sess2.createProducer(queue1);
-
- prod1.send(sess1.createTextMessage("echidna1"));
- prod2.send(sess2.createTextMessage("echidna2"));
-
- tx.delistResource(res1, XAResource.TMSUCCESS);
- tx.delistResource(res2, XAResource.TMSUCCESS);
-
- // commit
- tm.commit();
-
- // Messages should be in queue
-
- conn2 = cf.createConnection();
- Session sess = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageConsumer cons = sess.createConsumer(queue1);
- conn2.start();
-
- TextMessage r1 = (TextMessage)cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
- ProxyAssertSupport.assertNotNull(r1);
- ProxyAssertSupport.assertEquals("echidna1", r1.getText());
-
- TextMessage r2 = (TextMessage)cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
- ProxyAssertSupport.assertNotNull(r2);
- ProxyAssertSupport.assertEquals("echidna2", r2.getText());
-
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- if (conn2 != null)
- {
- conn2.close();
- }
- }
- }
-
- @Test
- public void testMultipleSessionsOneTxCommitSend() throws Exception
- {
- // Since both resources have some RM, TM will probably use 1PC optimization
-
- XAConnection conn = null;
-
- Connection conn2 = null;
-
- try
- {
-
- conn = xacf.createXAConnection();
- conn.start();
-
- tm.begin();
-
- // Create 2 sessions and enlist them
- XASession sess1 = conn.createXASession();
- ClientSessionInternal res1 = (ClientSessionInternal)sess1.getXAResource();
- XASession sess2 = conn.createXASession();
- ClientSessionInternal res2 = (ClientSessionInternal)sess2.getXAResource();
- res1.setForceNotSameRM(true);
- res2.setForceNotSameRM(true);
-
- Transaction tx = tm.getTransaction();
- tx.enlistResource(res1);
- tx.enlistResource(res2);
-
- // Send 2 messages - one from each session
-
- MessageProducer prod1 = sess1.createProducer(queue1);
- MessageProducer prod2 = sess2.createProducer(queue1);
-
- prod1.send(sess1.createTextMessage("echidna1"));
- prod2.send(sess2.createTextMessage("echidna2"));
-
- tx.delistResource(res1, XAResource.TMSUCCESS);
- tx.delistResource(res2, XAResource.TMSUCCESS);
-
- // commit
- tm.commit();
-
- // Messages should be in queue
-
- conn2 = cf.createConnection();
- Session sess = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageConsumer cons = sess.createConsumer(queue1);
- conn2.start();
-
- TextMessage r1 = (TextMessage)cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
- ProxyAssertSupport.assertNotNull(r1);
- ProxyAssertSupport.assertEquals("echidna1", r1.getText());
-
- TextMessage r2 = (TextMessage)cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
- ProxyAssertSupport.assertNotNull(r2);
- ProxyAssertSupport.assertEquals("echidna2", r2.getText());
-
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- if (conn2 != null)
- {
- conn2.close();
- }
-
- }
-
- }
-
- @Test
- public void testMultipleSessionsOneTxRollbackSend1PCOptimization() throws Exception
- {
- // Since both resources have some RM, TM will probably use 1PC optimization
-
- XAConnection conn = null;
-
- Connection conn2 = null;
-
- try
- {
- conn = xacf.createXAConnection();
- conn.start();
-
- tm.begin();
-
- // Create 2 sessions and enlist them
- XASession sess1 = conn.createXASession();
- XAResource res1 = sess1.getXAResource();
- XASession sess2 = conn.createXASession();
- XAResource res2 = sess2.getXAResource();
-
- Transaction tx = tm.getTransaction();
- tx.enlistResource(res1);
- tx.enlistResource(res2);
-
- // Send 2 messages - one from each session
-
- MessageProducer prod1 = sess1.createProducer(queue1);
- MessageProducer prod2 = sess2.createProducer(queue1);
-
- prod1.send(sess1.createTextMessage("echidna1"));
- prod2.send(sess2.createTextMessage("echidna2"));
-
- tx.delistResource(res1, XAResource.TMSUCCESS);
- tx.delistResource(res2, XAResource.TMSUCCESS);
-
- // rollback
- tm.rollback();
-
- // Messages should not be in queue
-
- conn2 = cf.createConnection();
- Session sess = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageConsumer cons = sess.createConsumer(queue1);
- conn2.start();
-
- TextMessage r1 = (TextMessage)cons.receive(ActiveMQServerTestCase.MIN_TIMEOUT);
- ProxyAssertSupport.assertNull(r1);
-
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- if (conn2 != null)
- {
- conn2.close();
- }
- }
- }
-
- @Test
- public void testMultipleSessionsOneTxRollbackSend() throws Exception
- {
- XAConnection conn = null;
-
- Connection conn2 = null;
-
- try
- {
-
- conn = xacf.createXAConnection();
- conn.start();
-
- tm.begin();
-
- // Create 2 sessions and enlist them
- XASession sess1 = conn.createXASession();
- ClientSessionInternal res1 = (ClientSessionInternal)sess1.getXAResource();
- XASession sess2 = conn.createXASession();
- ClientSessionInternal res2 = (ClientSessionInternal)sess2.getXAResource();
- res1.setForceNotSameRM(true);
- res2.setForceNotSameRM(true);
-
- Transaction tx = tm.getTransaction();
- tx.enlistResource(res1);
- tx.enlistResource(res2);
-
- // Send 2 messages - one from each session
-
- MessageProducer prod1 = sess1.createProducer(queue1);
- MessageProducer prod2 = sess2.createProducer(queue1);
-
- prod1.send(sess1.createTextMessage("echidna1"));
- prod2.send(sess2.createTextMessage("echidna2"));
-
- tx.delistResource(res1, XAResource.TMSUCCESS);
- tx.delistResource(res2, XAResource.TMSUCCESS);
-
- // rollback
- tm.rollback();
-
- // Messages should not be in queue
-
- conn2 = cf.createConnection();
- Session sess = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageConsumer cons = sess.createConsumer(queue1);
- conn2.start();
-
- TextMessage r1 = (TextMessage)cons.receive(ActiveMQServerTestCase.MIN_TIMEOUT);
- ProxyAssertSupport.assertNull(r1);
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- if (conn2 != null)
- {
- conn2.close();
- }
- }
- }
-
- @Test
- public void testOneSessionTwoTransactionsCommitAcknowledge() throws Exception
- {
- XAConnection conn = null;
-
- Connection conn2 = null;
-
- try
- {
- // First send 2 messages
- conn2 = cf.createConnection();
- Session sessProducer = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageProducer prod = sessProducer.createProducer(queue1);
- Message m = sessProducer.createTextMessage("jellyfish1");
- prod.send(m);
- m = sessProducer.createTextMessage("jellyfish2");
- prod.send(m);
-
- conn = xacf.createXAConnection();
-
- // Create a session
- XASession sess1 = conn.createXASession();
- XAResource res1 = sess1.getXAResource();
-
- conn.start();
- MessageConsumer cons1 = sess1.createConsumer(queue1);
-
- tm.begin();
-
- Transaction tx1 = tm.getTransaction();
- tx1.enlistResource(res1);
-
- // Receive one message in one tx
-
- TextMessage r1 = (TextMessage)cons1.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
- ProxyAssertSupport.assertNotNull(r1);
- ProxyAssertSupport.assertEquals("jellyfish1", r1.getText());
-
- tx1.delistResource(res1, XAResource.TMSUCCESS);
-
- // suspend the tx
- Transaction suspended = tm.suspend();
-
- tm.begin();
-
- Transaction tx2 = tm.getTransaction();
- tx2.enlistResource(res1);
-
- // Receive 2nd message in a different tx
- TextMessage r2 = (TextMessage)cons1.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
- ProxyAssertSupport.assertNotNull(r2);
- ProxyAssertSupport.assertEquals("jellyfish2", r2.getText());
-
- tx2.delistResource(res1, XAResource.TMSUCCESS);
-
- // commit this transaction
- tm.commit();
-
- // verify that no messages are available
- conn2.close();
- conn2 = cf.createConnection();
- Session sess = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
- conn2.start();
- MessageConsumer cons = sess.createConsumer(queue1);
- TextMessage r3 = (TextMessage)cons.receive(ActiveMQServerTestCase.MIN_TIMEOUT);
- ProxyAssertSupport.assertNull(r3);
-
- // now resume the first tx and then commit it
- tm.resume(suspended);
-
- tm.commit();
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- if (conn2 != null)
- {
- conn2.close();
- }
- }
- }
-
- @Test
- public void testOneSessionTwoTransactionsRollbackAcknowledge() throws Exception
- {
- XAConnection conn = null;
-
- Connection conn2 = null;
-
- try
- {
- // First send 2 messages
- conn2 = cf.createConnection();
- Session sessProducer = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageProducer prod = sessProducer.createProducer(queue1);
- Message m = sessProducer.createTextMessage("jellyfish1");
- prod.send(m);
- m = sessProducer.createTextMessage("jellyfish2");
- prod.send(m);
-
- conn = xacf.createXAConnection();
-
- // Create a session
- XASession sess1 = conn.createXASession();
- XAResource res1 = sess1.getXAResource();
-
- conn.start();
- MessageConsumer cons1 = sess1.createConsumer(queue1);
-
- tm.begin();
-
- Transaction tx1 = tm.getTransaction();
- tx1.enlistResource(res1);
-
- // Receive one message in one tx
-
- TextMessage r1 = (TextMessage)cons1.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
- ProxyAssertSupport.assertNotNull(r1);
- ProxyAssertSupport.assertEquals("jellyfish1", r1.getText());
-
- tx1.delistResource(res1, XAResource.TMSUCCESS);
-
- // suspend the tx
- Transaction suspended = tm.suspend();
-
- tm.begin();
-
- Transaction tx2 = tm.getTransaction();
- tx2.enlistResource(res1);
-
- // Receive 2nd message in a different tx
- TextMessage r2 = (TextMessage)cons1.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
- ProxyAssertSupport.assertNotNull(r2);
- ProxyAssertSupport.assertEquals("jellyfish2", r2.getText());
-
- cons1.close();
-
- tx2.delistResource(res1, XAResource.TMSUCCESS);
-
- // rollback this transaction
- tm.rollback();
-
- // verify that second message is available
- conn2.close();
- conn2 = cf.createConnection();
- Session sess = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
- conn2.start();
- MessageConsumer cons = sess.createConsumer(queue1);
-
- TextMessage r3 = (TextMessage)cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
-
- ProxyAssertSupport.assertNotNull(r3);
- ProxyAssertSupport.assertEquals("jellyfish2", r3.getText());
- r3 = (TextMessage)cons.receive(ActiveMQServerTestCase.MIN_TIMEOUT);
- ProxyAssertSupport.assertNull(r3);
-
- // rollback the other tx
- tm.resume(suspended);
- tm.rollback();
-
- // Verify the first message is now available
- r3 = (TextMessage)cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
- ProxyAssertSupport.assertNotNull(r3);
- ProxyAssertSupport.assertEquals("jellyfish1", r3.getText());
- r3 = (TextMessage)cons.receive(ActiveMQServerTestCase.MIN_TIMEOUT);
- ProxyAssertSupport.assertNull(r3);
-
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- if (conn2 != null)
- {
- conn2.close();
- }
-
- }
-
- }
-
- @Test
- public void testOneSessionTwoTransactionsCommitSend() throws Exception
- {
- XAConnection conn = null;
-
- Connection conn2 = null;
-
- try
- {
- conn = xacf.createXAConnection();
-
- // Create a session
- XASession sess1 = conn.createXASession();
- XAResource res1 = sess1.getXAResource();
-
- MessageProducer prod1 = sess1.createProducer(queue1);
-
- tm.begin();
-
- Transaction tx1 = tm.getTransaction();
- tx1.enlistResource(res1);
-
- // Send a message
- prod1.send(sess1.createTextMessage("kangaroo1"));
-
- tx1.delistResource(res1, XAResource.TMSUCCESS);
-
- // suspend the tx
- Transaction suspended = tm.suspend();
-
- tm.begin();
-
- // Send another message in another tx using the same session
- Transaction tx2 = tm.getTransaction();
- tx2.enlistResource(res1);
-
- // Send a message
- prod1.send(sess1.createTextMessage("kangaroo2"));
-
- tx2.delistResource(res1, XAResource.TMSUCCESS);
-
- // commit this transaction
- tm.commit();
-
- // verify only kangaroo2 message is sent
- conn2 = cf.createConnection();
- Session sess = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
- conn2.start();
- MessageConsumer cons = sess.createConsumer(queue1);
- TextMessage r1 = (TextMessage)cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
- ProxyAssertSupport.assertNotNull(r1);
- ProxyAssertSupport.assertEquals("kangaroo2", r1.getText());
- TextMessage r2 = (TextMessage)cons.receive(ActiveMQServerTestCase.MIN_TIMEOUT);
- ProxyAssertSupport.assertNull(r2);
-
- // now resume the first tx and then commit it
- tm.resume(suspended);
-
- tm.commit();
-
- // verify that the first text message is received
- TextMessage r3 = (TextMessage)cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
- ProxyAssertSupport.assertNotNull(r3);
- ProxyAssertSupport.assertEquals("kangaroo1", r3.getText());
-
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- if (conn2 != null)
- {
- conn2.close();
- }
-
- }
-
- }
-
- @Test
- public void testIsSamRM() throws Exception
- {
- XAConnection conn = null;
-
- conn = xacf.createXAConnection();
-
- // Create a session
- XASession sess1 = conn.createXASession();
- XAResource res1 = sess1.getXAResource();
-
- // Create a session
- XASession sess2 = conn.createXASession();
- XAResource res2 = sess2.getXAResource();
-
- ProxyAssertSupport.assertTrue(res1.isSameRM(res2));
- }
-
- @Test
- public void testOneSessionTwoTransactionsRollbackSend() throws Exception
- {
- XAConnection conn = null;
-
- Connection conn2 = null;
-
- try
- {
-
- conn = xacf.createXAConnection();
-
- // Create a session
- XASession sess1 = conn.createXASession();
- XAResource res1 = sess1.getXAResource();
-
- MessageProducer prod1 = sess1.createProducer(queue1);
-
- tm.begin();
-
- Transaction tx1 = tm.getTransaction();
- tx1.enlistResource(res1);
-
- // Send a message
- prod1.send(sess1.createTextMessage("kangaroo1"));
-
- // suspend the tx
- Transaction suspended = tm.suspend();
-
- tm.begin();
-
- // Send another message in another tx using the same session
- Transaction tx2 = tm.getTransaction();
- tx2.enlistResource(res1);
-
- // Send a message
- prod1.send(sess1.createTextMessage("kangaroo2"));
-
- tx2.delistResource(res1, XAResource.TMSUCCESS);
-
- // rollback this transaction
- tm.rollback();
-
- // verify no messages are sent
- conn2 = cf.createConnection();
- Session sess = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
- conn2.start();
- MessageConsumer cons = sess.createConsumer(queue1);
- TextMessage r1 = (TextMessage)cons.receive(ActiveMQServerTestCase.MIN_TIMEOUT);
-
- ProxyAssertSupport.assertNull(r1);
-
- // now resume the first tx and then commit it
- tm.resume(suspended);
-
- tx1.delistResource(res1, XAResource.TMSUCCESS);
-
- tm.commit();
-
- // verify that the first text message is received
- TextMessage r3 = (TextMessage)cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
- ProxyAssertSupport.assertNotNull(r3);
- ProxyAssertSupport.assertEquals("kangaroo1", r3.getText());
-
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- if (conn2 != null)
- {
- conn2.close();
- }
-
- }
-
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
- static class DummyListener implements MessageListener
- {
- protected JmsTestLogger log = JmsTestLogger.LOGGER;
-
- public List<Message> messages = new ArrayList<Message>();
-
- public void onMessage(final Message message)
- {
- messages.add(message);
- }
- }
-
- static class DummyXAResource implements XAResource
- {
- boolean failOnPrepare;
-
- DummyXAResource()
- {
- }
-
- DummyXAResource(final boolean failOnPrepare)
- {
- this.failOnPrepare = failOnPrepare;
- }
-
- public void commit(final Xid arg0, final boolean arg1) throws XAException
- {
- }
-
- public void end(final Xid arg0, final int arg1) throws XAException
- {
- }
-
- public void forget(final Xid arg0) throws XAException
- {
- }
-
- public int getTransactionTimeout() throws XAException
- {
- return 0;
- }
-
- public boolean isSameRM(final XAResource arg0) throws XAException
- {
- return false;
- }
-
- public int prepare(final Xid arg0) throws XAException
- {
- if (failOnPrepare)
- {
- throw new XAException(XAException.XAER_RMFAIL);
- }
- return XAResource.XA_OK;
- }
-
- public Xid[] recover(final int arg0) throws XAException
- {
- return null;
- }
-
- public void rollback(final Xid arg0) throws XAException
- {
- }
-
- public boolean setTransactionTimeout(final int arg0) throws XAException
- {
- return false;
- }
-
- public void start(final Xid arg0, final int arg1) throws XAException
- {
-
- }
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/ConcurrentCloseStressTest.java
----------------------------------------------------------------------
diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/ConcurrentCloseStressTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/ConcurrentCloseStressTest.java
deleted file mode 100644
index 30d001b..0000000
--- a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/ConcurrentCloseStressTest.java
+++ /dev/null
@@ -1,297 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.jms.tests.stress;
-import java.util.ArrayList;
-import java.util.List;
-
-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.apache.activemq.jms.tests.ActiveMQServerTestCase;
-import org.apache.activemq.jms.tests.JmsTestLogger;
-import org.apache.activemq.jms.tests.util.ProxyAssertSupport;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- * This test was added to test regression on http://jira.jboss.com/jira/browse/JBMESSAGING-660
- * @author <a href="mailto:clebert.suconic@jboss.org">Clebert Suconic</a>
- */
-public class ConcurrentCloseStressTest extends ActiveMQServerTestCase
-{
- @BeforeClass
- public static void stressTestsEnabled()
- {
- org.junit.Assume.assumeTrue(JMSStressTestBase.STRESS_TESTS_ENABLED);
- }
-
- InitialContext ic;
-
- ConnectionFactory cf;
-
- Queue queue;
-
- @Override
- @Before
- public void setUp() throws Exception
- {
- super.setUp();
-
- // ServerManagement.start("all");
-
- ic = getInitialContext();
- cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
-
- destroyQueue("TestQueue");
- createQueue("TestQueue");
-
- queue = (Queue)ic.lookup("queue/TestQueue");
-
- log.debug("setup done");
- }
-
- @Override
- @After
- public void tearDown() throws Exception
- {
- destroyQueue("TestQueue");
- super.tearDown();
- }
-
- @Test
- public void testProducersAndConsumers() throws Exception
- {
- Connection connectionProducer = cf.createConnection();
- Connection connectionReader = cf.createConnection();
-
- connectionReader.start();
- connectionProducer.start(); // try with and without this...
-
- ProducerThread[] producerThread = new ProducerThread[20];
- ReaderThread[] readerThread = new ReaderThread[20];
- TestThread[] threads = new TestThread[40];
-
- for (int i = 0; i < 20; i++)
- {
- producerThread[i] = new ProducerThread(i, connectionProducer, queue);
- readerThread[i] = new ReaderThread(i, connectionReader, queue);
- threads[i] = producerThread[i];
- threads[i + 20] = readerThread[i];
- }
-
- for (int i = 0; i < 40; i++)
- {
- threads[i].start();
- }
-
- for (int i = 0; i < 40; i++)
- {
- threads[i].join();
- }
-
- boolean hasFailure = false;
-
- for (int i = 0; i < 40; i++)
- {
- if (!threads[i].exceptions.isEmpty())
- {
- hasFailure = true;
- for (Exception element : threads[i].exceptions)
- {
- Exception ex = element;
- log.error("Exception occurred in one of the threads - " + ex, ex);
- }
- }
- }
-
- int messagesProduced = 0;
- int messagesRead = 0;
- for (ProducerThread element : producerThread)
- {
- messagesProduced += element.messagesProduced;
- }
-
- for (int i = 0; i < producerThread.length; i++)
- {
- messagesRead += readerThread[i].messagesRead;
- }
-
- if (hasFailure)
- {
- ProxyAssertSupport.fail("An exception has occurred in one of the threads");
- }
- }
-
- static class TestThread extends Thread
- {
- List<Exception> exceptions = new ArrayList<Exception>();
-
- protected int index;
-
- public int messageCount = 0;
- }
-
- static class ReaderThread extends TestThread
- {
- private static final JmsTestLogger log = JmsTestLogger.LOGGER;
-
- Connection conn;
-
- Queue queue;
-
- int messagesRead = 0;
-
- public ReaderThread(final int index, final Connection conn, final Queue queue) throws Exception
- {
- this.index = index;
- this.conn = conn;
- this.queue = queue;
- }
-
- @Override
- public void run()
- {
- int commitCounter = 0;
- try
- {
- Session session = conn.createSession(true, Session.SESSION_TRANSACTED);
- MessageConsumer consumer = session.createConsumer(queue);
-
- int lastCount = messageCount;
- while (true)
- {
- TextMessage message = (TextMessage)consumer.receive(5000);
- if (message == null)
- {
- break;
- }
- ReaderThread.log.debug("read message " + message.getText());
-
- // alternating commits and rollbacks
- if (commitCounter++ % 2 == 0)
- {
- messagesRead += messageCount - lastCount;
- lastCount = messageCount;
- ReaderThread.log.debug("commit");
- session.commit();
- }
- else
- {
- lastCount = messageCount;
- ReaderThread.log.debug("rollback");
- session.rollback();
- }
-
- messageCount++;
-
- if (messageCount % 7 == 0)
- {
- session.close();
-
- session = conn.createSession(true, Session.SESSION_TRANSACTED);
- consumer = session.createConsumer(queue);
- }
- }
-
- messagesRead += messageCount - lastCount;
-
- session.commit();
- consumer.close();
- session.close();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- exceptions.add(e);
- }
- }
-
- }
-
- static class ProducerThread extends TestThread
- {
- private static final JmsTestLogger log = JmsTestLogger.LOGGER;
-
- Connection conn;
-
- Queue queue;
-
- int messagesProduced = 0;
-
- public ProducerThread(final int index, final Connection conn, final Queue queue) throws Exception
- {
- this.index = index;
- this.conn = conn;
- this.queue = queue;
- }
-
- @Override
- public void run()
- {
- for (int i = 0; i < 10; i++)
- {
- try
- {
- int lastMessage = messageCount;
- Session sess = conn.createSession(true, Session.SESSION_TRANSACTED);
- MessageProducer producer = sess.createProducer(queue);
-
- for (int j = 0; j < 20; j++)
- {
- producer.send(sess.createTextMessage("Message " + i + ", " + j));
-
- if (j % 2 == 0)
- {
- ProducerThread.log.debug("commit");
- messagesProduced += messageCount - lastMessage;
- lastMessage = messageCount;
-
- sess.commit();
- }
- else
- {
- ProducerThread.log.debug("rollback");
- lastMessage = messageCount;
- sess.rollback();
- }
- messageCount++;
-
- }
-
- messagesProduced += messageCount - lastMessage;
- sess.commit();
- sess.close();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- exceptions.add(e);
- }
- }
- }
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/CorruptMessageStressTest.java
----------------------------------------------------------------------
diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/CorruptMessageStressTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/CorruptMessageStressTest.java
deleted file mode 100644
index e5fde58..0000000
--- a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/CorruptMessageStressTest.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.jms.tests.stress;
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.DeliveryMode;
-import javax.jms.Message;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.naming.InitialContext;
-
-import org.apache.activemq.jms.tests.ActiveMQServerTestCase;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- * A stress test written to investigate http://jira.jboss.org/jira/browse/JBMESSAGING-362
- *
- * @author <a href="mailto:ovidiu@feodorov.com">Ovidiu Feodorov</a>
- */
-public class CorruptMessageStressTest extends ActiveMQServerTestCase
-{
- @BeforeClass
- public static void stressTestsEnabled()
- {
- org.junit.Assume.assumeTrue(JMSStressTestBase.STRESS_TESTS_ENABLED);
- }
-
- public static int PRODUCER_COUNT = 30;
-
- public static int MESSAGE_COUNT = 10000;
-
- // Static --------------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- private InitialContext ic;
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- @Test
- public void testMultipleSenders() throws Exception
- {
- ConnectionFactory cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
- Queue queue = (Queue)ic.lookup("/queue/StressTestQueue");
- drainDestination(cf, queue);
-
- Connection conn = cf.createConnection();
-
- Session[] sessions = new Session[CorruptMessageStressTest.PRODUCER_COUNT];
- MessageProducer[] producers = new MessageProducer[CorruptMessageStressTest.PRODUCER_COUNT];
-
- for (int i = 0; i < CorruptMessageStressTest.PRODUCER_COUNT; i++)
- {
- sessions[i] = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
- producers[i] = sessions[i].createProducer(queue);
- producers[i].setDeliveryMode(DeliveryMode.NON_PERSISTENT);
- }
-
- Thread[] threads = new Thread[CorruptMessageStressTest.PRODUCER_COUNT];
-
- for (int i = 0; i < CorruptMessageStressTest.PRODUCER_COUNT; i++)
- {
- threads[i] = new Thread(new Sender(sessions[i], producers[i]), "Sender Thread #" + i);
- threads[i].start();
- }
-
- // wait for the threads to finish
-
- for (int i = 0; i < CorruptMessageStressTest.PRODUCER_COUNT; i++)
- {
- threads[i].join();
- }
-
- conn.close();
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- @Override
- @Before
- public void setUp() throws Exception
- {
- super.setUp();
-
- // ServerManagement.start("all");
- ic = getInitialContext();
- createQueue("StressTestQueue");
- }
-
- @Override
- @After
- public void tearDown() throws Exception
- {
- super.tearDown();
- destroyQueue("StressTestQueue");
- ic.close();
- }
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
- private class Sender implements Runnable
- {
- private final Session session;
-
- private final MessageProducer producer;
-
- private int count = 0;
-
- public Sender(final Session session, final MessageProducer producer)
- {
- this.session = session;
- this.producer = producer;
- }
-
- public void run()
- {
- while (true)
- {
- if (count == CorruptMessageStressTest.MESSAGE_COUNT)
- {
- break;
- }
-
- try
- {
- Message m = session.createMessage();
- m.setStringProperty("XXX", "XXX-VALUE");
- m.setStringProperty("YYY", "YYY-VALUE");
- producer.send(m);
- count++;
- }
- catch (Exception e)
- {
- log.error("Sender thread failed", e);
- break;
- }
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/JMSStressTestBase.java
----------------------------------------------------------------------
diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/JMSStressTestBase.java b/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/JMSStressTestBase.java
deleted file mode 100644
index 93b368c..0000000
--- a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/JMSStressTestBase.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.jms.tests.stress;
-import javax.jms.ConnectionFactory;
-import javax.jms.Destination;
-import javax.jms.Topic;
-import javax.jms.XASession;
-
-import org.apache.activemq.jms.tests.ActiveMQServerTestCase;
-import org.apache.activemq.jms.tests.util.ProxyAssertSupport;
-import org.junit.After;
-import org.junit.BeforeClass;
-
-/**
- *
- * Base class for stress tests
- *
- * @author <a href="tim.fox@jboss.com">Tim Fox</a>
- *
-*/
-public abstract class JMSStressTestBase extends ActiveMQServerTestCase
-{
- public static final boolean STRESS_TESTS_ENABLED = false;
-
- @BeforeClass
- public static void stressTestsEnabled()
- {
- org.junit.Assume.assumeTrue(JMSStressTestBase.STRESS_TESTS_ENABLED);
- }
-
- protected static final int NUM_PERSISTENT_MESSAGES = 4000;
-
- protected static final int NUM_NON_PERSISTENT_MESSAGES = 6000;
-
- protected static final int NUM_PERSISTENT_PRESEND = 5000;
-
- protected static final int NUM_NON_PERSISTENT_PRESEND = 3000;
-
- protected ConnectionFactory cf;
-
- protected Destination topic;
-
- protected Destination destinationQueue1;
- protected Destination destinationQueue2;
- protected Destination destinationQueue3;
- protected Destination destinationQueue4;
-
- protected Topic topic1;
- protected Topic topic2;
- protected Topic topic3;
- protected Topic topic4;
-
- @Override
- @After
- public void tearDown() throws Exception
- {
- super.tearDown();
- if (checkNoMessageData())
- {
- ProxyAssertSupport.fail("Message data still exists");
- }
- }
-
- protected void runRunners(final Runner[] runners) throws Exception
- {
- Thread[] threads = new Thread[runners.length];
- for (int i = 0; i < runners.length; i++)
- {
- threads[i] = new Thread(runners[i]);
- threads[i].start();
- }
-
- for (int i = 0; i < runners.length; i++)
- {
- threads[i].join();
- }
-
- for (int i = 0; i < runners.length; i++)
- {
- if (runners[i].isFailed())
- {
- ProxyAssertSupport.fail("Runner " + i + " failed");
- log.error("runner failed");
- }
- }
- }
-
- protected void tweakXASession(final XASession sess)
- {
-
- }
-}
[09/15] activemq-6 git commit: Refactored the testsuite a bit
Posted by jb...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/jms/bridge/JMSBridgeTest.java
----------------------------------------------------------------------
diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/jms/bridge/JMSBridgeTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/jms/bridge/JMSBridgeTest.java
new file mode 100644
index 0000000..de916f3
--- /dev/null
+++ b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/jms/bridge/JMSBridgeTest.java
@@ -0,0 +1,2449 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.tests.extras.jms.bridge;
+
+import javax.jms.Connection;
+import javax.jms.DeliveryMode;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+import java.lang.management.ManagementFactory;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.activemq.api.jms.ActiveMQJMSConstants;
+import org.apache.activemq.jms.bridge.ConnectionFactoryFactory;
+import org.apache.activemq.jms.bridge.QualityOfServiceMode;
+import org.apache.activemq.jms.bridge.impl.JMSBridgeImpl;
+import org.apache.activemq.jms.client.ActiveMQMessage;
+import org.apache.activemq.service.extensions.ServiceUtils;
+import org.apache.activemq.tests.integration.IntegrationTestLogger;
+import org.apache.activemq.tests.integration.ra.DummyTransactionManager;
+import org.apache.activemq.utils.DefaultSensitiveStringCodec;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * A JMSBridgeTest
+ *
+ * @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
+ */
+public class JMSBridgeTest extends BridgeTestBase
+{
+ private static final IntegrationTestLogger log = IntegrationTestLogger.LOGGER;
+
+ // MaxBatchSize but no MaxBatchTime
+
+ @Test
+ public void testNoMaxBatchTime_AtMostOnce_P() throws Exception
+ {
+ testNoMaxBatchTime(QualityOfServiceMode.AT_MOST_ONCE, true);
+ }
+
+ @Test
+ public void testNoMaxBatchTime_DuplicatesOk_P() throws Exception
+ {
+ testNoMaxBatchTime(QualityOfServiceMode.DUPLICATES_OK, true);
+ }
+
+ @Test
+ public void testNoMaxBatchTime_OnceAndOnlyOnce_P() throws Exception
+ {
+ testNoMaxBatchTime(QualityOfServiceMode.ONCE_AND_ONLY_ONCE, true);
+ }
+
+ @Test
+ public void testNoMaxBatchTime_AtMostOnce_NP() throws Exception
+ {
+ testNoMaxBatchTime(QualityOfServiceMode.AT_MOST_ONCE, false);
+ }
+
+ @Test
+ public void testNoMaxBatchTime_DuplicatesOk_NP() throws Exception
+ {
+ testNoMaxBatchTime(QualityOfServiceMode.DUPLICATES_OK, false);
+ }
+
+ @Test
+ public void testNoMaxBatchTime_OnceAndOnlyOnce_NP() throws Exception
+ {
+ testNoMaxBatchTime(QualityOfServiceMode.ONCE_AND_ONLY_ONCE, false);
+ }
+
+ // Same server
+
+ // MaxBatchSize but no MaxBatchTime
+
+ @Test
+ public void testNoMaxBatchTimeSameServer_AtMostOnce_P() throws Exception
+ {
+ testNoMaxBatchTimeSameServer(QualityOfServiceMode.AT_MOST_ONCE, true);
+ }
+
+ @Test
+ public void testNoMaxBatchTimeSameServer_DuplicatesOk_P() throws Exception
+ {
+ testNoMaxBatchTimeSameServer(QualityOfServiceMode.DUPLICATES_OK, true);
+ }
+
+ @Test
+ public void testNoMaxBatchTimeSameServer_OnceAndOnlyOnce_P() throws Exception
+ {
+ testNoMaxBatchTimeSameServer(QualityOfServiceMode.ONCE_AND_ONLY_ONCE, true);
+ }
+
+ @Test
+ public void testNoMaxBatchTimeSameServer_AtMostOnce_NP() throws Exception
+ {
+ testNoMaxBatchTimeSameServer(QualityOfServiceMode.AT_MOST_ONCE, false);
+ }
+
+ @Test
+ public void testNoMaxBatchTimeSameServer_DuplicatesOk_NP() throws Exception
+ {
+ testNoMaxBatchTimeSameServer(QualityOfServiceMode.DUPLICATES_OK, false);
+ }
+
+ @Test
+ public void testNoMaxBatchTimeSameServer_OnceAndOnlyOnce_NP() throws Exception
+ {
+ testNoMaxBatchTimeSameServer(QualityOfServiceMode.ONCE_AND_ONLY_ONCE, false);
+ }
+
+ // MaxBatchTime but no MaxBatchSize
+
+ @Test
+ public void testMaxBatchTime_AtMostOnce_P() throws Exception
+ {
+ testMaxBatchTime(QualityOfServiceMode.AT_MOST_ONCE, true);
+ }
+
+ @Test
+ public void testMaxBatchTime_DuplicatesOk_P() throws Exception
+ {
+ testMaxBatchTime(QualityOfServiceMode.DUPLICATES_OK, true);
+ }
+
+ @Test
+ public void testMaxBatchTime_OnceAndOnlyOnce_P() throws Exception
+ {
+ testMaxBatchTime(QualityOfServiceMode.ONCE_AND_ONLY_ONCE, true);
+ }
+
+ @Test
+ public void testMaxBatchTime_AtMostOnce_NP() throws Exception
+ {
+ testMaxBatchTime(QualityOfServiceMode.AT_MOST_ONCE, false);
+ }
+
+ @Test
+ public void testMaxBatchTime_DuplicatesOk_NP() throws Exception
+ {
+ testMaxBatchTime(QualityOfServiceMode.DUPLICATES_OK, false);
+ }
+
+ @Test
+ public void testMaxBatchTime_OnceAndOnlyOnce_NP() throws Exception
+ {
+ testMaxBatchTime(QualityOfServiceMode.ONCE_AND_ONLY_ONCE, false);
+ }
+
+ // Same server
+
+ // MaxBatchTime but no MaxBatchSize
+
+ @Test
+ public void testMaxBatchTimeSameServer_AtMostOnce_P() throws Exception
+ {
+ testMaxBatchTimeSameServer(QualityOfServiceMode.AT_MOST_ONCE, true);
+ }
+
+ @Test
+ public void testMaxBatchTimeSameServer_DuplicatesOk_P() throws Exception
+ {
+ testMaxBatchTimeSameServer(QualityOfServiceMode.DUPLICATES_OK, true);
+ }
+
+ @Test
+ public void testMaxBatchTimeSameServer_OnceAndOnlyOnce_P() throws Exception
+ {
+ testMaxBatchTimeSameServer(QualityOfServiceMode.ONCE_AND_ONLY_ONCE, true);
+ }
+
+ @Test
+ public void testMaxBatchTimeSameServer_AtMostOnce_NP() throws Exception
+ {
+ testMaxBatchTimeSameServer(QualityOfServiceMode.AT_MOST_ONCE, false);
+ }
+
+ @Test
+ public void testMaxBatchTimeSameServer_DuplicatesOk_NP() throws Exception
+ {
+ testMaxBatchTimeSameServer(QualityOfServiceMode.DUPLICATES_OK, false);
+ }
+
+ @Test
+ public void testMaxBatchTimeSameServer_OnceAndOnlyOnce_NP() throws Exception
+ {
+ testMaxBatchTimeSameServer(QualityOfServiceMode.ONCE_AND_ONLY_ONCE, false);
+ }
+
+ // Stress with batch size of 50
+
+ @Test
+ public void testStress_AtMostOnce_P_50() throws Exception
+ {
+ testStress(QualityOfServiceMode.AT_MOST_ONCE, true, 50);
+ }
+
+ @Test
+ public void testStress_DuplicatesOk_P_50() throws Exception
+ {
+ testStress(QualityOfServiceMode.DUPLICATES_OK, true, 50);
+ }
+
+ @Test
+ public void testStress_OnceAndOnlyOnce_P_50() throws Exception
+ {
+ testStress(QualityOfServiceMode.ONCE_AND_ONLY_ONCE, true, 50);
+ }
+
+ @Test
+ public void testStress_AtMostOnce_NP_50() throws Exception
+ {
+ testStress(QualityOfServiceMode.AT_MOST_ONCE, false, 50);
+ }
+
+ @Test
+ public void testStress_DuplicatesOk_NP_50() throws Exception
+ {
+ testStress(QualityOfServiceMode.DUPLICATES_OK, false, 50);
+ }
+
+ @Test
+ public void testStress_OnceAndOnlyOnce_NP_50() throws Exception
+ {
+ testStress(QualityOfServiceMode.ONCE_AND_ONLY_ONCE, false, 50);
+ }
+
+ // Stress with batch size of 1
+
+ @Test
+ public void testStress_AtMostOnce_P_1() throws Exception
+ {
+ testStress(QualityOfServiceMode.AT_MOST_ONCE, true, 1);
+ }
+
+ @Test
+ public void testStress_DuplicatesOk_P_1() throws Exception
+ {
+ testStress(QualityOfServiceMode.DUPLICATES_OK, true, 1);
+ }
+
+ @Test
+ public void testStress_OnceAndOnlyOnce_P_1() throws Exception
+ {
+ testStress(QualityOfServiceMode.ONCE_AND_ONLY_ONCE, true, 1);
+ }
+
+ @Test
+ public void testStress_AtMostOnce_NP_1() throws Exception
+ {
+ testStress(QualityOfServiceMode.AT_MOST_ONCE, false, 1);
+ }
+
+ @Test
+ public void testStress_DuplicatesOk_NP_1() throws Exception
+ {
+ testStress(QualityOfServiceMode.DUPLICATES_OK, false, 1);
+ }
+
+ @Test
+ public void testStress_OnceAndOnlyOnce_NP_1() throws Exception
+ {
+ testStress(QualityOfServiceMode.ONCE_AND_ONLY_ONCE, false, 1);
+ }
+
+ // Max batch time
+
+ @Test
+ public void testStressMaxBatchTime_OnceAndOnlyOnce_NP() throws Exception
+ {
+ testStressBatchTime(QualityOfServiceMode.ONCE_AND_ONLY_ONCE, false, 200);
+ }
+
+ @Test
+ public void testStressMaxBatchTime_OnceAndOnlyOnce_P() throws Exception
+ {
+ testStressBatchTime(QualityOfServiceMode.ONCE_AND_ONLY_ONCE, true, 200);
+ }
+
+ // Stress on same server
+
+ // Stress with batch size of 50
+
+ @Test
+ public void testStressSameServer_AtMostOnce_P_50() throws Exception
+ {
+ testStressSameServer(QualityOfServiceMode.AT_MOST_ONCE, true, 50);
+ }
+
+ @Test
+ public void testStressSameServer_DuplicatesOk_P_50() throws Exception
+ {
+ testStressSameServer(QualityOfServiceMode.DUPLICATES_OK, true, 50);
+ }
+
+ @Test
+ public void testStressSameServer_OnceAndOnlyOnce_P_50() throws Exception
+ {
+ testStress(QualityOfServiceMode.ONCE_AND_ONLY_ONCE, true, 50);
+ }
+
+ @Test
+ public void testStressSameServer_AtMostOnce_NP_50() throws Exception
+ {
+ testStressSameServer(QualityOfServiceMode.AT_MOST_ONCE, false, 50);
+ }
+
+ @Test
+ public void testStressSameServer_DuplicatesOk_NP_50() throws Exception
+ {
+ testStressSameServer(QualityOfServiceMode.DUPLICATES_OK, false, 50);
+ }
+
+ @Test
+ public void testStressSameServer_OnceAndOnlyOnce_NP_50() throws Exception
+ {
+ testStressSameServer(QualityOfServiceMode.ONCE_AND_ONLY_ONCE, false, 50);
+ }
+
+ // Stress with batch size of 1
+
+ @Test
+ public void testStressSameServer_AtMostOnce_P_1() throws Exception
+ {
+ testStressSameServer(QualityOfServiceMode.AT_MOST_ONCE, true, 1);
+ }
+
+ @Test
+ public void testStressSameServer_DuplicatesOk_P_1() throws Exception
+ {
+ testStressSameServer(QualityOfServiceMode.DUPLICATES_OK, true, 1);
+ }
+
+ @Test
+ public void testStressSameServer_OnceAndOnlyOnce_P_1() throws Exception
+ {
+ testStressSameServer(QualityOfServiceMode.ONCE_AND_ONLY_ONCE, true, 1);
+ }
+
+ @Test
+ public void testStressSameServer_AtMostOnce_NP_1() throws Exception
+ {
+ testStressSameServer(QualityOfServiceMode.AT_MOST_ONCE, false, 1);
+ }
+
+ @Test
+ public void testStressSameServer_DuplicatesOk_NP_1() throws Exception
+ {
+ testStressSameServer(QualityOfServiceMode.DUPLICATES_OK, false, 1);
+ }
+
+ @Test
+ public void testStressSameServer_OnceAndOnlyOnce_NP_1() throws Exception
+ {
+ testStressSameServer(QualityOfServiceMode.ONCE_AND_ONLY_ONCE, false, 1);
+ }
+
+ @Test
+ public void testStartBridgeFirst() throws Exception
+ {
+ //stop the source server, we want to start the bridge first
+ jmsServer0.stop();
+ JMSBridgeImpl bridge = null;
+
+ ConnectionFactoryFactory factInUse0 = cff0;
+ ConnectionFactoryFactory factInUse1 = cff1;
+ try
+ {
+ final int NUM_MESSAGES = 10;
+
+ bridge = new JMSBridgeImpl(factInUse0,
+ factInUse1,
+ sourceQueueFactory,
+ targetQueueFactory,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 5000,
+ 10,
+ QualityOfServiceMode.AT_MOST_ONCE,
+ NUM_MESSAGES,
+ -1,
+ null,
+ null,
+ false);
+
+ bridge.start();
+
+ //now start the server
+ jmsServer0.start();
+ createQueue("sourceQueue", 0);
+ createQueue("localTargetQueue", 0);
+ jmsServer0.createTopic(false, "sourceTopic", "/topic/sourceTopic");
+ // Send half the messages
+
+ sendMessages(cf0, sourceQueue, 0, NUM_MESSAGES / 2, false, false);
+
+ // Verify none are received
+
+ checkEmpty(targetQueue, 1);
+
+ // Send the other half
+
+ sendMessages(cf0, sourceQueue, NUM_MESSAGES / 2, NUM_MESSAGES / 2, false, false);
+
+ // This should now be receivable
+
+ checkAllMessageReceivedInOrder(cf1, targetQueue, 0, NUM_MESSAGES, false);
+
+ // Send another batch with one more than batch size
+
+ sendMessages(cf0, sourceQueue, 0, NUM_MESSAGES + 1, false, false);
+
+ // Make sure only batch size are received
+
+ checkAllMessageReceivedInOrder(cf1, targetQueue, 0, NUM_MESSAGES, false);
+
+ // Final batch
+
+ sendMessages(cf0, sourceQueue, 0, NUM_MESSAGES - 1, false, false);
+
+ checkAllMessageReceivedInOrder(cf1, targetQueue, NUM_MESSAGES, 1, false);
+
+ checkAllMessageReceivedInOrder(cf1, targetQueue, 0, NUM_MESSAGES - 1, false);
+
+ }
+ finally
+ {
+ if (bridge != null)
+ {
+ JMSBridgeTest.log.info("Stopping bridge");
+ bridge.stop();
+ }
+ }
+ }
+
+ @Test
+ public void testParams() throws Exception
+ {
+ JMSBridgeImpl bridge = null;
+
+ QualityOfServiceMode qosMode = QualityOfServiceMode.AT_MOST_ONCE;
+
+ int batchSize = 10;
+
+ int maxBatchTime = -1;
+
+ String sourceUsername = null;
+
+ String sourcePassword = null;
+
+ String destUsername = null;
+
+ String destPassword = null;
+
+ String selector = null;
+
+ long failureRetryInterval = 5000;
+
+ int maxRetries = 10;
+
+ String subName = null;
+
+ String clientID = null;
+
+ try
+ {
+ bridge =
+ new JMSBridgeImpl(null,
+ cff1,
+ sourceQueueFactory,
+ targetQueueFactory,
+ sourceUsername,
+ sourcePassword,
+ destUsername,
+ destPassword,
+ selector,
+ failureRetryInterval,
+ maxRetries,
+ qosMode,
+ batchSize,
+ maxBatchTime,
+ subName,
+ clientID,
+ false);
+ fail("expected exception");
+ }
+ catch (IllegalArgumentException e)
+ {
+ // Ok
+ }
+ finally
+ {
+ stopComponent(bridge);
+ }
+
+ try
+ {
+ bridge = new JMSBridgeImpl(cff0,
+ null,
+ sourceQueueFactory,
+ targetQueueFactory,
+ sourceUsername,
+ sourcePassword,
+ destUsername,
+ destPassword,
+ selector,
+ failureRetryInterval,
+ maxRetries,
+ qosMode,
+ batchSize,
+ maxBatchTime,
+ subName,
+ clientID,
+ false);
+ fail("expected exception");
+ }
+ catch (IllegalArgumentException e)
+ {
+ // Ok
+ }
+ finally
+ {
+ stopComponent(bridge);
+ }
+
+ try
+ {
+ bridge = new JMSBridgeImpl(cff0,
+ cff1,
+ null,
+ targetQueueFactory,
+ sourceUsername,
+ sourcePassword,
+ destUsername,
+ destPassword,
+ selector,
+ failureRetryInterval,
+ maxRetries,
+ qosMode,
+ batchSize,
+ maxBatchTime,
+ subName,
+ clientID,
+ false);
+ fail("expected exception");
+ }
+ catch (IllegalArgumentException e)
+ {
+ // Ok
+ }
+ finally
+ {
+ stopComponent(bridge);
+ }
+
+ try
+ {
+ bridge = new JMSBridgeImpl(cff0,
+ cff1,
+ sourceQueueFactory,
+ null,
+ sourceUsername,
+ sourcePassword,
+ destUsername,
+ destPassword,
+ selector,
+ failureRetryInterval,
+ maxRetries,
+ qosMode,
+ batchSize,
+ maxBatchTime,
+ subName,
+ clientID,
+ false);
+ fail("expected exception");
+ }
+ catch (IllegalArgumentException e)
+ {
+ // Ok
+ }
+ finally
+ {
+ stopComponent(bridge);
+ }
+
+ try
+ {
+ bridge = new JMSBridgeImpl(cff0,
+ cff1,
+ sourceQueueFactory,
+ targetQueueFactory,
+ sourceUsername,
+ sourcePassword,
+ destUsername,
+ destPassword,
+ selector,
+ -2,
+ maxRetries,
+ qosMode,
+ batchSize,
+ maxBatchTime,
+ subName,
+ clientID,
+ false);
+ fail("expected exception");
+ }
+ catch (IllegalArgumentException e)
+ {
+ // Ok
+ }
+ finally
+ {
+ stopComponent(bridge);
+ }
+
+ try
+ {
+ bridge = new JMSBridgeImpl(cff0,
+ cff1,
+ sourceQueueFactory,
+ targetQueueFactory,
+ sourceUsername,
+ sourcePassword,
+ destUsername,
+ destPassword,
+ selector,
+ -1,
+ 10,
+ qosMode,
+ batchSize,
+ maxBatchTime,
+ subName,
+ clientID,
+ false);
+ fail("expected exception");
+ }
+ catch (IllegalArgumentException e)
+ {
+ // Ok
+ }
+ finally
+ {
+ stopComponent(bridge);
+ }
+
+ try
+ {
+ bridge = new JMSBridgeImpl(cff0,
+ cff1,
+ sourceQueueFactory,
+ null,
+ sourceUsername,
+ sourcePassword,
+ destUsername,
+ destPassword,
+ selector,
+ failureRetryInterval,
+ maxRetries,
+ qosMode,
+ 0,
+ maxBatchTime,
+ subName,
+ clientID,
+ false);
+ fail("expected exception");
+ }
+ catch (IllegalArgumentException e)
+ {
+ // Ok
+ }
+ finally
+ {
+ stopComponent(bridge);
+ }
+
+ try
+ {
+ bridge = new JMSBridgeImpl(cff0,
+ cff1,
+ sourceQueueFactory,
+ null,
+ sourceUsername,
+ sourcePassword,
+ destUsername,
+ destPassword,
+ selector,
+ failureRetryInterval,
+ maxRetries,
+ qosMode,
+ batchSize,
+ -2,
+ subName,
+ clientID,
+ false);
+ fail("expected exception");
+ }
+ catch (IllegalArgumentException e)
+ {
+ // Ok
+ }
+ finally
+ {
+ stopComponent(bridge);
+ }
+ }
+
+ @Test
+ public void testStartStopStart() throws Exception
+ {
+ JMSBridgeImpl bridge = null;
+
+ Connection connSource = null;
+
+ Connection connTarget = null;
+
+ try
+ {
+ final int NUM_MESSAGES = 10;
+
+ bridge = new JMSBridgeImpl(cff0,
+ cff1,
+ sourceQueueFactory,
+ targetQueueFactory,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 5000,
+ 10,
+ QualityOfServiceMode.AT_MOST_ONCE,
+ 1,
+ -1,
+ null,
+ null,
+ false);
+
+ bridge.start();
+
+ bridge.stop();
+
+ bridge.start();
+
+ connSource = cf0.createConnection();
+
+ Session sessSend = connSource.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageProducer prod = sessSend.createProducer(sourceQueue);
+
+ for (int i = 0; i < NUM_MESSAGES; i++)
+ {
+ TextMessage tm = sessSend.createTextMessage("message" + i);
+ prod.send(tm);
+ }
+
+ connTarget = cf1.createConnection();
+ Session sessRec = connTarget.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageConsumer cons = sessRec.createConsumer(targetQueue);
+
+ connTarget.start();
+
+ for (int i = 0; i < NUM_MESSAGES; i++)
+ {
+ TextMessage tm = (TextMessage) cons.receive(10000);
+ Assert.assertNotNull(tm);
+ Assert.assertEquals("message" + i, tm.getText());
+ }
+
+ Message m = cons.receiveNoWait();
+ Assert.assertNull(m);
+ }
+ finally
+ {
+ if (connSource != null)
+ {
+ connSource.close();
+ }
+
+ if (connTarget != null)
+ {
+ connTarget.close();
+ }
+
+ if (bridge != null)
+ {
+ bridge.stop();
+ }
+
+ removeAllMessages(sourceQueue.getQueueName(), 0);
+ }
+ }
+
+ @Test
+ public void testSelector() throws Exception
+ {
+ JMSBridgeImpl bridge = null;
+
+ Connection connSource = null;
+
+ Connection connTarget = null;
+
+ try
+ {
+ final int NUM_MESSAGES = 10;
+
+ String selector = "vegetable='radish'";
+
+ bridge = new JMSBridgeImpl(cff0,
+ cff1,
+ sourceQueueFactory,
+ targetQueueFactory,
+ null,
+ null,
+ null,
+ null,
+ selector,
+ 5000,
+ 10,
+ QualityOfServiceMode.AT_MOST_ONCE,
+ 1,
+ -1,
+ null,
+ null,
+ false);
+
+ bridge.start();
+
+ connSource = cf0.createConnection();
+
+ Session sessSend = connSource.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageProducer prod = sessSend.createProducer(sourceQueue);
+
+ for (int i = 0; i < NUM_MESSAGES; i++)
+ {
+ TextMessage tm = sessSend.createTextMessage("message" + i);
+
+ if (i >= NUM_MESSAGES / 2)
+ {
+ tm.setStringProperty("vegetable", "radish");
+ }
+ else
+ {
+ tm.setStringProperty("vegetable", "cauliflower");
+ }
+
+ prod.send(tm);
+ }
+
+ connTarget = cf1.createConnection();
+
+ Session sessRec = connTarget.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageConsumer cons = sessRec.createConsumer(targetQueue);
+
+ connTarget.start();
+
+ for (int i = NUM_MESSAGES / 2; i < NUM_MESSAGES; i++)
+ {
+ TextMessage tm = (TextMessage) cons.receive(10000);
+
+ Assert.assertNotNull(tm);
+
+ Assert.assertEquals("message" + i, tm.getText());
+ }
+
+ Message m = cons.receiveNoWait();
+
+ Assert.assertNull(m);
+
+ }
+ finally
+ {
+ if (connSource != null)
+ {
+ connSource.close();
+ }
+
+ if (connTarget != null)
+ {
+ connTarget.close();
+ }
+
+ if (bridge != null)
+ {
+ bridge.stop();
+ }
+
+ removeAllMessages(sourceQueue.getQueueName(), 0);
+ }
+ }
+
+ @Test
+ public void testMaskPassword() throws Exception
+ {
+ JMSBridgeImpl bridge = null;
+
+ Connection connSource = null;
+
+ Connection connTarget = null;
+
+ DefaultSensitiveStringCodec codec = new DefaultSensitiveStringCodec();
+ String mask = (String) codec.encode("guest");
+
+ try
+ {
+ final int NUM_MESSAGES = 10;
+
+ bridge = new JMSBridgeImpl(cff0, cff1, sourceQueueFactory,
+ targetQueueFactory, "guest", mask, "guest", mask, null, 5000,
+ 10, QualityOfServiceMode.AT_MOST_ONCE, 1, -1, null, null, false);
+
+ bridge.setUseMaskedPassword(true);
+
+ bridge.start();
+
+ connSource = cf0.createConnection();
+
+ Session sessSend = connSource.createSession(false,
+ Session.AUTO_ACKNOWLEDGE);
+
+ MessageProducer prod = sessSend.createProducer(sourceQueue);
+
+ for (int i = 0; i < NUM_MESSAGES; i++)
+ {
+ TextMessage tm = sessSend.createTextMessage("message" + i);
+
+ prod.send(tm);
+ }
+
+ connTarget = cf1.createConnection();
+
+ Session sessRec = connTarget.createSession(false,
+ Session.AUTO_ACKNOWLEDGE);
+
+ MessageConsumer cons = sessRec.createConsumer(targetQueue);
+
+ connTarget.start();
+
+ for (int i = 0; i < NUM_MESSAGES; i++)
+ {
+ TextMessage tm = (TextMessage) cons.receive(10000);
+
+ Assert.assertNotNull(tm);
+
+ Assert.assertEquals("message" + i, tm.getText());
+ }
+
+ Message m = cons.receiveNoWait();
+
+ Assert.assertNull(m);
+
+ }
+ finally
+ {
+ if (connSource != null)
+ {
+ connSource.close();
+ }
+
+ if (connTarget != null)
+ {
+ connTarget.close();
+ }
+
+ if (bridge != null)
+ {
+ bridge.stop();
+ }
+
+ removeAllMessages(sourceQueue.getQueueName(), 0);
+ }
+ }
+
+ @Test
+ public void testPasswordCodec() throws Exception
+ {
+ JMSBridgeImpl bridge = null;
+
+ Connection connSource = null;
+
+ Connection connTarget = null;
+
+ DefaultSensitiveStringCodec codec = new DefaultSensitiveStringCodec();
+ Map<String, String> prop = new HashMap<String, String>();
+ prop.put("key", "bridgekey");
+ codec.init(prop);
+
+ String mask = (String) codec.encode("guest");
+
+ try
+ {
+ final int NUM_MESSAGES = 10;
+
+ bridge = new JMSBridgeImpl(cff0, cff1, sourceQueueFactory,
+ targetQueueFactory, "guest", mask, "guest", mask, null, 5000,
+ 10, QualityOfServiceMode.AT_MOST_ONCE, 1, -1, null, null, false);
+
+ bridge.setUseMaskedPassword(true);
+ bridge.setPasswordCodec(codec.getClass().getName() + ";key=bridgekey");
+
+ bridge.start();
+
+ connSource = cf0.createConnection();
+
+ Session sessSend = connSource.createSession(false,
+ Session.AUTO_ACKNOWLEDGE);
+
+ MessageProducer prod = sessSend.createProducer(sourceQueue);
+
+ for (int i = 0; i < NUM_MESSAGES; i++)
+ {
+ TextMessage tm = sessSend.createTextMessage("message" + i);
+
+ prod.send(tm);
+ }
+
+ connTarget = cf1.createConnection();
+
+ Session sessRec = connTarget.createSession(false,
+ Session.AUTO_ACKNOWLEDGE);
+
+ MessageConsumer cons = sessRec.createConsumer(targetQueue);
+
+ connTarget.start();
+
+ for (int i = 0; i < NUM_MESSAGES; i++)
+ {
+ TextMessage tm = (TextMessage) cons.receive(10000);
+
+ Assert.assertNotNull(tm);
+
+ Assert.assertEquals("message" + i, tm.getText());
+ }
+
+ Message m = cons.receiveNoWait();
+
+ Assert.assertNull(m);
+
+ }
+ finally
+ {
+ if (connSource != null)
+ {
+ connSource.close();
+ }
+
+ if (connTarget != null)
+ {
+ connTarget.close();
+ }
+
+ if (bridge != null)
+ {
+ bridge.stop();
+ }
+
+ removeAllMessages(sourceQueue.getQueueName(), 0);
+ }
+ }
+
+ @Test
+ public void testStartBridgeWithJTATransactionAlreadyRunningLargeMessage() throws Exception
+ {
+ internalTestStartBridgeWithJTATransactionAlreadyRunning(true);
+ }
+
+ @Test
+ public void testStartBridgeWithJTATransactionAlreadyRunningRegularMessage() throws Exception
+ {
+ internalTestStartBridgeWithJTATransactionAlreadyRunning(false);
+ }
+
+ public void internalTestStartBridgeWithJTATransactionAlreadyRunning(final boolean largeMessage) throws Exception
+ {
+ JMSBridgeImpl bridge = null;
+
+ Transaction toResume = null;
+
+ Transaction started = null;
+
+ TransactionManager mgr = newTransactionManager();
+
+ try
+ {
+
+ toResume = mgr.suspend();
+
+ mgr.begin();
+
+ started = mgr.getTransaction();
+
+ final int NUM_MESSAGES = 10;
+
+ bridge = new JMSBridgeImpl(cff0,
+ cff1,
+ sourceTopicFactory,
+ targetQueueFactory,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 5000,
+ 10,
+ QualityOfServiceMode.AT_MOST_ONCE,
+ 1,
+ -1,
+ null,
+ null,
+ false);
+ bridge.start();
+
+ sendMessages(cf0, sourceTopic, 0, NUM_MESSAGES, false, largeMessage);
+
+ checkAllMessageReceivedInOrder(cf1, targetQueue, 0, NUM_MESSAGES, largeMessage);
+ }
+ finally
+ {
+ if (started != null)
+ {
+ try
+ {
+ started.rollback();
+ }
+ catch (Exception e)
+ {
+ JMSBridgeTest.log.error("Failed to rollback", e);
+ }
+ }
+
+ if (toResume != null)
+ {
+ try
+ {
+ mgr.resume(toResume);
+ }
+ catch (Exception e)
+ {
+ JMSBridgeTest.log.error("Failed to resume", e);
+ }
+ }
+ if (bridge != null)
+ {
+ bridge.stop();
+ }
+ }
+ }
+
+ @Test
+ public void testNonDurableSubscriberLargeMessage() throws Exception
+ {
+ internalTestNonDurableSubscriber(true, 1);
+ }
+
+ @Test
+ public void testNonDurableSubscriberRegularMessage() throws Exception
+ {
+ internalTestNonDurableSubscriber(false, 1);
+ }
+
+ public void internalTestNonDurableSubscriber(final boolean largeMessage, final int batchSize) throws Exception
+ {
+ JMSBridgeImpl bridge = null;
+
+ try
+ {
+ final int NUM_MESSAGES = 10;
+
+ bridge = new JMSBridgeImpl(cff0,
+ cff1,
+ sourceTopicFactory,
+ targetQueueFactory,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 5000,
+ 10,
+ QualityOfServiceMode.AT_MOST_ONCE,
+ batchSize,
+ -1,
+ null,
+ null,
+ false);
+
+ bridge.start();
+
+ sendMessages(cf0, sourceTopic, 0, NUM_MESSAGES, false, largeMessage);
+
+ checkAllMessageReceivedInOrder(cf1, targetQueue, 0, NUM_MESSAGES, largeMessage);
+ }
+ finally
+ {
+ if (bridge != null)
+ {
+ bridge.stop();
+ }
+ }
+ }
+
+ @Test
+ public void testDurableSubscriberLargeMessage() throws Exception
+ {
+ internalTestDurableSubscriber(true, 1);
+ }
+
+ @Test
+ public void testDurableSubscriberRegularMessage() throws Exception
+ {
+ internalTestDurableSubscriber(false, 1);
+ }
+
+ public void internalTestDurableSubscriber(final boolean largeMessage, final int batchSize) throws Exception
+ {
+ JMSBridgeImpl bridge = null;
+
+ try
+ {
+ final int NUM_MESSAGES = 10;
+
+ bridge = new JMSBridgeImpl(cff0,
+ cff1,
+ sourceTopicFactory,
+ targetQueueFactory,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 5000,
+ 10,
+ QualityOfServiceMode.AT_MOST_ONCE,
+ batchSize,
+ -1,
+ "subTest",
+ "clientid123",
+ false);
+
+ bridge.start();
+
+ sendMessages(cf0, sourceTopic, 0, NUM_MESSAGES, true, largeMessage);
+
+ checkAllMessageReceivedInOrder(cf1, targetQueue, 0, NUM_MESSAGES, largeMessage);
+ }
+ finally
+ {
+ if (bridge != null)
+ {
+ bridge.stop();
+ }
+
+ // Now unsubscribe
+ Connection conn = cf0.createConnection();
+ conn.setClientID("clientid123");
+ Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ sess.unsubscribe("subTest");
+ conn.close();
+ }
+ }
+
+ @Test
+ public void testMessageIDInHeaderOn() throws Exception
+ {
+ messageIDInHeader(true);
+ }
+
+ @Test
+ public void testMessageIDInHeaderOff() throws Exception
+ {
+ messageIDInHeader(false);
+ }
+
+ private void messageIDInHeader(final boolean on) throws Exception
+ {
+ JMSBridgeImpl bridge = null;
+
+ Connection connSource = null;
+
+ Connection connTarget = null;
+
+ try
+ {
+ final int NUM_MESSAGES = 10;
+
+ bridge = new JMSBridgeImpl(cff0,
+ cff1,
+ sourceQueueFactory,
+ targetQueueFactory,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 5000,
+ 10,
+ QualityOfServiceMode.AT_MOST_ONCE,
+ 1,
+ -1,
+ null,
+ null,
+ on);
+
+ bridge.start();
+
+ connSource = cf0.createConnection();
+
+ connTarget = cf1.createConnection();
+
+ JMSBridgeTest.log.trace("Sending " + NUM_MESSAGES + " messages");
+
+ List<String> ids1 = new ArrayList<String>();
+
+ Session sessSource = connSource.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageProducer prod = sessSource.createProducer(sourceQueue);
+
+ for (int i = 0; i < NUM_MESSAGES; i++)
+ {
+ TextMessage tm = sessSource.createTextMessage("message" + i);
+
+ // We add some properties to make sure they get passed through ok
+ tm.setStringProperty("wib", "uhuh");
+ tm.setBooleanProperty("cheese", true);
+ tm.setIntProperty("Sausages", 23);
+ tm.setByteProperty("bacon", (byte) 12);
+ tm.setDoubleProperty("toast", 17261762.12121d);
+ tm.setFloatProperty("orange", 1212.1212f);
+ tm.setLongProperty("blurg", 817217827L);
+ tm.setShortProperty("stst", (short) 26363);
+
+ //Set some JMS headers too
+
+ //And also set a core props
+ ((ActiveMQMessage) tm).getCoreMessage().putBytesProperty("bytes", new byte[]{1, 2, 3});
+
+ // We add some JMSX ones too
+
+ tm.setStringProperty("JMSXGroupID", "mygroup543");
+
+ prod.send(tm);
+
+ ids1.add(tm.getJMSMessageID());
+ }
+
+ JMSBridgeTest.log.trace("Sent the first messages");
+
+ Session sessTarget = connTarget.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageConsumer cons = sessTarget.createConsumer(targetQueue);
+
+ connTarget.start();
+
+ List<TextMessage> msgs = new ArrayList<TextMessage>();
+
+ for (int i = 0; i < NUM_MESSAGES; i++)
+ {
+ TextMessage tm = (TextMessage) cons.receive(5000);
+
+ Assert.assertNotNull(tm);
+
+ Assert.assertEquals("message" + i, tm.getText());
+
+ Assert.assertEquals("uhuh", tm.getStringProperty("wib"));
+ Assert.assertTrue(tm.getBooleanProperty("cheese"));
+ Assert.assertEquals(23, tm.getIntProperty("Sausages"));
+ assertEquals((byte) 12, tm.getByteProperty("bacon"));
+ assertEquals(17261762.12121d, tm.getDoubleProperty("toast"), 0.000000001);
+ assertEquals(1212.1212f, tm.getFloatProperty("orange"), 0.000001);
+ assertEquals(817217827L, tm.getLongProperty("blurg"));
+ assertEquals((short) 26363, tm.getShortProperty("stst"));
+
+ assertEqualsByteArrays(new byte[]{1, 2, 3}, ((ActiveMQMessage) tm).getCoreMessage().getBytesProperty("bytes"));
+
+ Assert.assertEquals("mygroup543", tm.getStringProperty("JMSXGroupID"));
+
+ if (on)
+ {
+ String header = tm.getStringProperty(ActiveMQJMSConstants.JBOSS_MESSAGING_BRIDGE_MESSAGE_ID_LIST);
+
+ Assert.assertNotNull(header);
+
+ Assert.assertEquals(ids1.get(i), header);
+
+ msgs.add(tm);
+ }
+ }
+
+ if (on)
+ {
+ // Now we send them again back to the source
+
+ Iterator<TextMessage> iter = msgs.iterator();
+
+ List<String> ids2 = new ArrayList<String>();
+
+ while (iter.hasNext())
+ {
+ Message msg = iter.next();
+
+ prod.send(msg);
+
+ ids2.add(msg.getJMSMessageID());
+ }
+
+ // And consume them again
+
+ for (int i = 0; i < NUM_MESSAGES; i++)
+ {
+ TextMessage tm = (TextMessage) cons.receive(5000);
+
+ Assert.assertNotNull(tm);
+
+ Assert.assertEquals("message" + i, tm.getText());
+
+ Assert.assertEquals("uhuh", tm.getStringProperty("wib"));
+ Assert.assertTrue(tm.getBooleanProperty("cheese"));
+ Assert.assertEquals(23, tm.getIntProperty("Sausages"));
+ assertEquals((byte) 12, tm.getByteProperty("bacon"));
+ assertEquals(17261762.12121d, tm.getDoubleProperty("toast"), 0.000001);
+ assertEquals(1212.1212f, tm.getFloatProperty("orange"), 0.0000001);
+ assertEquals(817217827L, tm.getLongProperty("blurg"));
+ assertEquals((short) 26363, tm.getShortProperty("stst"));
+
+ assertEqualsByteArrays(new byte[]{1, 2, 3}, ((ActiveMQMessage) tm).getCoreMessage().getBytesProperty("bytes"));
+
+ Assert.assertEquals("mygroup543", tm.getStringProperty("JMSXGroupID"));
+
+ String header = tm.getStringProperty(ActiveMQJMSConstants.JBOSS_MESSAGING_BRIDGE_MESSAGE_ID_LIST);
+
+ Assert.assertNotNull(header);
+
+ Assert.assertEquals(ids1.get(i) + "," + ids2.get(i), header);
+ }
+ }
+
+ }
+ finally
+ {
+ if (bridge != null)
+ {
+ bridge.stop();
+ }
+
+ if (connSource != null)
+ {
+ connSource.close();
+ }
+
+ if (connTarget != null)
+ {
+ connTarget.close();
+ }
+ }
+ }
+
+ @Test
+ public void testPropertiesPreservedPOn() throws Exception
+ {
+ propertiesPreserved(true, true);
+ }
+
+ @Test
+ public void testPropertiesPreservedNPoff() throws Exception
+ {
+ propertiesPreserved(false, true);
+ }
+
+ @Test
+ public void testPropertiesPreservedNPOn() throws Exception
+ {
+ propertiesPreserved(false, true);
+ }
+
+ @Test
+ public void testPropertiesPreservedPoff() throws Exception
+ {
+ propertiesPreserved(true, true);
+ }
+
+ private void propertiesPreserved(final boolean persistent, final boolean messageIDInHeader) throws Exception
+ {
+ JMSBridgeImpl bridge = null;
+
+ Connection connSource = null;
+
+ Connection connTarget = null;
+
+ try
+ {
+ final int NUM_MESSAGES = 10;
+
+ bridge = new JMSBridgeImpl(cff0,
+ cff1,
+ sourceQueueFactory,
+ targetQueueFactory,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 5000,
+ 10,
+ QualityOfServiceMode.AT_MOST_ONCE,
+ 1,
+ -1,
+ null,
+ null,
+ messageIDInHeader);
+
+ bridge.start();
+
+ connSource = cf0.createConnection();
+
+ connTarget = cf1.createConnection();
+
+ JMSBridgeTest.log.trace("Sending " + NUM_MESSAGES + " messages");
+
+ Session sessSource = connSource.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ Session sessTarget = connTarget.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageConsumer cons = sessTarget.createConsumer(targetQueue);
+
+ connTarget.start();
+
+ MessageProducer prod = sessSource.createProducer(sourceQueue);
+
+ prod.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
+
+ TextMessage tm = sessSource.createTextMessage("blahmessage");
+
+ prod.setPriority(7);
+
+ prod.setTimeToLive(1 * 60 * 60 * 1000);
+
+ prod.send(tm);
+
+ long expiration = tm.getJMSExpiration();
+
+ Assert.assertEquals(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT,
+ tm.getJMSDeliveryMode());
+
+ tm = (TextMessage) cons.receive(1000);
+
+ Assert.assertNotNull(tm);
+
+ Assert.assertEquals("blahmessage", tm.getText());
+
+ Assert.assertEquals(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT,
+ tm.getJMSDeliveryMode());
+
+ Assert.assertEquals(7, tm.getJMSPriority());
+
+ Assert.assertTrue(Math.abs(expiration - tm.getJMSExpiration()) < 100);
+
+ Message m = cons.receive(5000);
+
+ Assert.assertNull(m);
+
+ // Now do one with expiration = 0
+
+ tm = sessSource.createTextMessage("blahmessage2");
+
+ prod.setPriority(7);
+
+ prod.setTimeToLive(0);
+
+ prod.send(tm);
+
+ Assert.assertEquals(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT,
+ tm.getJMSDeliveryMode());
+
+ tm = (TextMessage) cons.receive(1000);
+
+ Assert.assertNotNull(tm);
+
+ Assert.assertEquals("blahmessage2", tm.getText());
+
+ Assert.assertEquals(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT,
+ tm.getJMSDeliveryMode());
+
+ Assert.assertEquals(7, tm.getJMSPriority());
+
+ Assert.assertEquals(0, tm.getJMSExpiration());
+
+ m = cons.receive(5000);
+
+ Assert.assertNull(m);
+
+ tm = sessSource.createTextMessage("blahmessage3");
+
+ final boolean myBool = false;
+ final byte myByte = (byte) 23;
+ final double myDouble = 17625765d;
+ final float myFloat = 87127.23f;
+ final int myInt = 123;
+ final long myLong = 81728712;
+ final short myShort = (short) 88;
+ final String myString = "ojweodewj";
+ final String myJMSX = "aardvark";
+
+ tm.setBooleanProperty("mybool", myBool);
+ tm.setByteProperty("mybyte", myByte);
+ tm.setDoubleProperty("mydouble", myDouble);
+ tm.setFloatProperty("myfloat", myFloat);
+ tm.setIntProperty("myint", myInt);
+ tm.setLongProperty("mylong", myLong);
+ tm.setShortProperty("myshort", myShort);
+ tm.setStringProperty("mystring", myString);
+
+ tm.setStringProperty("JMSXMyNaughtyJMSXProperty", myJMSX);
+
+ prod.send(tm);
+
+ tm = (TextMessage) cons.receive(5000);
+
+ Assert.assertNotNull(tm);
+
+ Assert.assertEquals("blahmessage3", tm.getText());
+
+ Assert.assertEquals(myBool, tm.getBooleanProperty("mybool"));
+ Assert.assertEquals(myByte, tm.getByteProperty("mybyte"));
+ Assert.assertEquals(myDouble, tm.getDoubleProperty("mydouble"), 0.000001);
+ Assert.assertEquals(myFloat, tm.getFloatProperty("myfloat"), 0.000001);
+ Assert.assertEquals(myInt, tm.getIntProperty("myint"));
+ Assert.assertEquals(myLong, tm.getLongProperty("mylong"));
+ Assert.assertEquals(myShort, tm.getShortProperty("myshort"));
+ Assert.assertEquals(myString, tm.getStringProperty("mystring"));
+ Assert.assertEquals(myJMSX, tm.getStringProperty("JMSXMyNaughtyJMSXProperty"));
+
+ m = cons.receive(5000);
+
+ }
+ finally
+ {
+ if (bridge != null)
+ {
+ bridge.stop();
+ }
+
+ if (connSource != null)
+ {
+ connSource.close();
+ }
+
+ if (connTarget != null)
+ {
+ connTarget.close();
+ }
+ }
+ }
+
+ @Test
+ public void testNoMessageIDInHeader() throws Exception
+ {
+ JMSBridgeImpl bridge = null;
+
+ Connection connSource = null;
+
+ Connection connTarget = null;
+
+ try
+ {
+ final int NUM_MESSAGES = 10;
+
+ bridge = new JMSBridgeImpl(cff0,
+ cff1,
+ sourceQueueFactory,
+ targetQueueFactory,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 5000,
+ 10,
+ QualityOfServiceMode.AT_MOST_ONCE,
+ 1,
+ -1,
+ null,
+ null,
+ false);
+
+ bridge.start();
+
+ connSource = cf0.createConnection();
+
+ connTarget = cf1.createConnection();
+
+ JMSBridgeTest.log.trace("Sending " + NUM_MESSAGES + " messages");
+
+ Session sessSource = connSource.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageProducer prod = sessSource.createProducer(sourceQueue);
+
+ for (int i = 0; i < NUM_MESSAGES; i++)
+ {
+ TextMessage tm = sessSource.createTextMessage("message" + i);
+
+ // We add some headers to make sure they get passed through ok
+ tm.setStringProperty("wib", "uhuh");
+ tm.setBooleanProperty("cheese", true);
+ tm.setIntProperty("Sausages", 23);
+
+ prod.send(tm);
+ }
+
+ JMSBridgeTest.log.trace("Sent the first messages");
+
+ Session sessTarget = connTarget.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageConsumer cons = sessTarget.createConsumer(targetQueue);
+
+ connTarget.start();
+
+ for (int i = 0; i < NUM_MESSAGES; i++)
+ {
+ TextMessage tm = (TextMessage) cons.receive(5000);
+
+ Assert.assertNotNull(tm);
+
+ Assert.assertEquals("message" + i, tm.getText());
+
+ Assert.assertEquals("uhuh", tm.getStringProperty("wib"));
+ Assert.assertTrue(tm.getBooleanProperty("cheese"));
+ Assert.assertEquals(23, tm.getIntProperty("Sausages"));
+
+ String header = tm.getStringProperty(ActiveMQJMSConstants.JBOSS_MESSAGING_BRIDGE_MESSAGE_ID_LIST);
+
+ Assert.assertNull(header);
+ }
+ }
+ finally
+ {
+ if (bridge != null)
+ {
+ bridge.stop();
+ }
+
+ if (connSource != null)
+ {
+ connSource.close();
+ }
+
+ if (connTarget != null)
+ {
+ connTarget.close();
+ }
+ }
+ }
+
+ // Private -------------------------------------------------------------------------------
+
+ private void testStress(final QualityOfServiceMode qosMode, final boolean persistent, final int batchSize) throws Exception
+ {
+ Connection connSource = null;
+
+ JMSBridgeImpl bridge = null;
+
+ Thread t = null;
+
+ ConnectionFactoryFactory factInUse0 = cff0;
+ ConnectionFactoryFactory factInUse1 = cff1;
+ if (qosMode.equals(QualityOfServiceMode.ONCE_AND_ONLY_ONCE))
+ {
+ factInUse0 = cff0xa;
+ factInUse1 = cff1xa;
+ ServiceUtils.setTransactionManager(newTransactionManager());
+ }
+
+ try
+ {
+ bridge = new JMSBridgeImpl(factInUse0,
+ factInUse1,
+ sourceQueueFactory,
+ targetQueueFactory,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 5000,
+ 10,
+ qosMode,
+ batchSize,
+ -1,
+ null,
+ null,
+ false);
+
+ bridge.start();
+
+ connSource = cf0.createConnection();
+
+ Session sessSend = connSource.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageProducer prod = sessSend.createProducer(sourceQueue);
+
+ final int NUM_MESSAGES = 250;
+
+ StressSender sender = new StressSender();
+ sender.sess = sessSend;
+ sender.prod = prod;
+ sender.numMessages = NUM_MESSAGES;
+ prod.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
+
+ t = new Thread(sender);
+
+ t.start();
+
+ checkAllMessageReceivedInOrder(cf1, targetQueue, 0, NUM_MESSAGES, false);
+
+ t.join();
+
+ if (sender.ex != null)
+ {
+ // An error occurred during the send
+ throw sender.ex;
+ }
+
+ }
+ finally
+ {
+ if (t != null)
+ {
+ t.join(10000);
+ }
+
+ if (connSource != null)
+ {
+ try
+ {
+ connSource.close();
+ }
+ catch (Exception e)
+ {
+ JMSBridgeTest.log.error("Failed to close connection", e);
+ }
+ }
+
+ if (bridge != null)
+ {
+ bridge.stop();
+ }
+ }
+ }
+
+ private void testStressBatchTime(final QualityOfServiceMode qosMode, final boolean persistent, final int maxBatchTime) throws Exception
+ {
+ Connection connSource = null;
+
+ JMSBridgeImpl bridge = null;
+
+ Thread t = null;
+
+ ConnectionFactoryFactory factInUse0 = cff0;
+ ConnectionFactoryFactory factInUse1 = cff1;
+ if (qosMode.equals(QualityOfServiceMode.ONCE_AND_ONLY_ONCE))
+ {
+ factInUse0 = cff0xa;
+ factInUse1 = cff1xa;
+ ServiceUtils.setTransactionManager(newTransactionManager());
+ }
+
+ try
+ {
+ bridge = new JMSBridgeImpl(factInUse0,
+ factInUse1,
+ sourceQueueFactory,
+ targetQueueFactory,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 5000,
+ 10,
+ qosMode,
+ 2,
+ maxBatchTime,
+ null,
+ null,
+ false);
+
+ bridge.start();
+
+ connSource = cf0.createConnection();
+
+ Session sessSend = connSource.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageProducer prod = sessSend.createProducer(sourceQueue);
+
+ final int NUM_MESSAGES = 500;
+
+ StressSender sender = new StressSender();
+ sender.sess = sessSend;
+ sender.prod = prod;
+ sender.numMessages = NUM_MESSAGES;
+ prod.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
+
+ t = new Thread(sender);
+
+ t.start();
+
+ checkAllMessageReceivedInOrder(cf1, targetQueue, 0, NUM_MESSAGES, false);
+
+ t.join();
+
+ if (sender.ex != null)
+ {
+ // An error occurred during the send
+ throw sender.ex;
+ }
+
+ }
+ finally
+ {
+ if (t != null)
+ {
+ t.join(10000);
+ }
+
+ if (connSource != null)
+ {
+ try
+ {
+ connSource.close();
+ }
+ catch (Exception e)
+ {
+ JMSBridgeTest.log.error("Failed to close connection", e);
+ }
+ }
+
+ if (bridge != null)
+ {
+ bridge.stop();
+ }
+ }
+ }
+
+ // Both source and destination on same rm
+ private void testStressSameServer(final QualityOfServiceMode qosMode, final boolean persistent, final int batchSize) throws Exception
+ {
+ Connection connSource = null;
+
+ JMSBridgeImpl bridge = null;
+
+ Thread t = null;
+
+ ConnectionFactoryFactory factInUse0 = cff0;
+ if (qosMode.equals(QualityOfServiceMode.ONCE_AND_ONLY_ONCE))
+ {
+ factInUse0 = cff0xa;
+ }
+
+ try
+ {
+ bridge = new JMSBridgeImpl(factInUse0,
+ factInUse0,
+ sourceQueueFactory,
+ localTargetQueueFactory,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 5000,
+ 10,
+ qosMode,
+ batchSize,
+ -1,
+ null,
+ null,
+ false);
+
+ bridge.start();
+
+ connSource = cf0.createConnection();
+
+ Session sessSend = connSource.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageProducer prod = sessSend.createProducer(sourceQueue);
+
+ final int NUM_MESSAGES = 200;
+
+ StressSender sender = new StressSender();
+ sender.sess = sessSend;
+ sender.prod = prod;
+ sender.numMessages = NUM_MESSAGES;
+ prod.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
+
+ t = new Thread(sender);
+
+ t.start();
+
+ checkAllMessageReceivedInOrder(cf0, localTargetQueue, 0, NUM_MESSAGES, false);
+
+ t.join();
+
+ if (sender.ex != null)
+ {
+ // An error occurred during the send
+ throw sender.ex;
+ }
+
+ }
+ finally
+ {
+ if (t != null)
+ {
+ t.join(10000);
+ }
+
+ if (connSource != null)
+ {
+ try
+ {
+ connSource.close();
+ }
+ catch (Exception e)
+ {
+ JMSBridgeTest.log.error("Failed to close connection", e);
+ }
+ }
+
+ if (bridge != null)
+ {
+ bridge.stop();
+ }
+ }
+ }
+
+ private void testNoMaxBatchTime(final QualityOfServiceMode qosMode, final boolean persistent) throws Exception
+ {
+ JMSBridgeImpl bridge = null;
+
+ ConnectionFactoryFactory factInUse0 = cff0;
+ ConnectionFactoryFactory factInUse1 = cff1;
+ if (qosMode.equals(QualityOfServiceMode.ONCE_AND_ONLY_ONCE))
+ {
+ factInUse0 = cff0xa;
+ factInUse1 = cff1xa;
+ ServiceUtils.setTransactionManager(newTransactionManager());
+ }
+ try
+ {
+ final int NUM_MESSAGES = 10;
+
+ bridge = new JMSBridgeImpl(factInUse0,
+ factInUse1,
+ sourceQueueFactory,
+ targetQueueFactory,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 5000,
+ 10,
+ qosMode,
+ NUM_MESSAGES,
+ -1,
+ null,
+ null,
+ false);
+
+ bridge.start();
+
+ // Send half the messages
+
+ sendMessages(cf0, sourceQueue, 0, NUM_MESSAGES / 2, persistent, false);
+
+ // Verify none are received
+
+ checkEmpty(targetQueue, 1);
+
+ // Send the other half
+
+ sendMessages(cf0, sourceQueue, NUM_MESSAGES / 2, NUM_MESSAGES / 2, persistent, false);
+
+ // This should now be receivable
+
+ checkAllMessageReceivedInOrder(cf1, targetQueue, 0, NUM_MESSAGES, false);
+
+ // Send another batch with one more than batch size
+
+ sendMessages(cf0, sourceQueue, 0, NUM_MESSAGES + 1, persistent, false);
+
+ // Make sure only batch size are received
+
+ checkAllMessageReceivedInOrder(cf1, targetQueue, 0, NUM_MESSAGES, false);
+
+ // Final batch
+
+ sendMessages(cf0, sourceQueue, 0, NUM_MESSAGES - 1, persistent, false);
+
+ checkAllMessageReceivedInOrder(cf1, targetQueue, NUM_MESSAGES, 1, false);
+
+ checkAllMessageReceivedInOrder(cf1, targetQueue, 0, NUM_MESSAGES - 1, false);
+ }
+ finally
+ {
+ if (bridge != null)
+ {
+ JMSBridgeTest.log.info("Stopping bridge");
+ bridge.stop();
+ }
+ }
+ }
+
+ private void testNoMaxBatchTimeSameServer(final QualityOfServiceMode qosMode, final boolean persistent) throws Exception
+ {
+ JMSBridgeImpl bridge = null;
+
+ ConnectionFactoryFactory factInUse0 = cff0;
+ if (qosMode.equals(QualityOfServiceMode.ONCE_AND_ONLY_ONCE))
+ {
+ factInUse0 = cff0xa;
+ ServiceUtils.setTransactionManager(newTransactionManager());
+ }
+
+ try
+ {
+ final int NUM_MESSAGES = 10;
+
+ bridge = new JMSBridgeImpl(factInUse0,
+ factInUse0,
+ sourceQueueFactory,
+ localTargetQueueFactory,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 5000,
+ 10,
+ qosMode,
+ NUM_MESSAGES,
+ -1,
+ null,
+ null,
+ false);
+
+ bridge.start();
+
+ sendMessages(cf0, sourceQueue, 0, NUM_MESSAGES / 2, persistent, false);
+
+ checkEmpty(targetQueue, 1);
+
+ // Send the other half
+
+ sendMessages(cf0, sourceQueue, NUM_MESSAGES / 2, NUM_MESSAGES / 2, persistent, false);
+
+ // This should now be receivable
+
+ checkAllMessageReceivedInOrder(cf0, localTargetQueue, 0, NUM_MESSAGES, false);
+
+ checkEmpty(localTargetQueue, 0);
+
+ checkEmpty(sourceQueue, 0);
+
+ // Send another batch with one more than batch size
+
+ sendMessages(cf0, sourceQueue, 0, NUM_MESSAGES + 1, persistent, false);
+
+ // Make sure only batch size are received
+
+ checkAllMessageReceivedInOrder(cf0, localTargetQueue, 0, NUM_MESSAGES, false);
+
+ // Final batch
+
+ sendMessages(cf0, sourceQueue, 0, NUM_MESSAGES - 1, persistent, false);
+
+ checkAllMessageReceivedInOrder(cf0, localTargetQueue, NUM_MESSAGES, 1, false);
+
+ checkAllMessageReceivedInOrder(cf0, localTargetQueue, 0, NUM_MESSAGES - 1, false);
+ }
+ finally
+ {
+ if (bridge != null)
+ {
+ bridge.stop();
+ }
+ }
+ }
+
+ private void testMaxBatchTime(final QualityOfServiceMode qosMode, final boolean persistent) throws Exception
+ {
+ JMSBridgeImpl bridge = null;
+
+ ConnectionFactoryFactory factInUse0 = cff0;
+ ConnectionFactoryFactory factInUse1 = cff1;
+ if (qosMode.equals(QualityOfServiceMode.ONCE_AND_ONLY_ONCE))
+ {
+ factInUse0 = cff0xa;
+ factInUse1 = cff1xa;
+ ServiceUtils.setTransactionManager(newTransactionManager());
+ }
+
+ try
+ {
+ final long MAX_BATCH_TIME = 3000;
+
+ final int MAX_BATCH_SIZE = 100000; // something big so it won't reach it
+
+ bridge = new JMSBridgeImpl(factInUse0,
+ factInUse1,
+ sourceQueueFactory,
+ targetQueueFactory,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 3000,
+ 10,
+ qosMode,
+ MAX_BATCH_SIZE,
+ MAX_BATCH_TIME,
+ null,
+ null,
+ false);
+
+ bridge.start();
+
+ final int NUM_MESSAGES = 10;
+
+ // Send some message
+
+ sendMessages(cf0, sourceQueue, 0, NUM_MESSAGES, persistent, false);
+
+ // Verify none are received
+
+ checkEmpty(targetQueue, 1);
+
+ // Messages should now be receivable
+
+ checkAllMessageReceivedInOrder(cf1, targetQueue, 0, NUM_MESSAGES, false);
+ }
+ finally
+ {
+ if (bridge != null)
+ {
+ bridge.stop();
+ }
+ }
+ }
+
+ private void testMaxBatchTimeSameServer(final QualityOfServiceMode qosMode, final boolean persistent) throws Exception
+ {
+ JMSBridgeImpl bridge = null;
+
+ ConnectionFactoryFactory factInUse0 = cff0;
+ if (qosMode.equals(QualityOfServiceMode.ONCE_AND_ONLY_ONCE))
+ {
+ factInUse0 = cff0xa;
+ ServiceUtils.setTransactionManager(newTransactionManager());
+ }
+
+ try
+ {
+ final long MAX_BATCH_TIME = 3000;
+
+ final int MAX_BATCH_SIZE = 100000; // something big so it won't reach it
+
+ bridge = new JMSBridgeImpl(factInUse0,
+ factInUse0,
+ sourceQueueFactory,
+ localTargetQueueFactory,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 3000,
+ 10,
+ qosMode,
+ MAX_BATCH_SIZE,
+ MAX_BATCH_TIME,
+ null,
+ null,
+ false);
+
+ bridge.start();
+
+ final int NUM_MESSAGES = 10;
+
+ // Send some message
+
+ // Send some message
+
+ sendMessages(cf0, sourceQueue, 0, NUM_MESSAGES, persistent, false);
+
+ // Verify none are received
+
+ checkEmpty(localTargetQueue, 0);
+
+ // Messages should now be receivable
+
+ checkAllMessageReceivedInOrder(cf0, localTargetQueue, 0, NUM_MESSAGES, false);
+ }
+ finally
+ {
+ if (bridge != null)
+ {
+ bridge.stop();
+ }
+ }
+ }
+
+ @Test
+ public void testSetTMClass() throws Exception
+ {
+ TransactionManagerLocatorImpl.tm = new DummyTransactionManager();
+
+ JMSBridgeImpl bridge = null;
+ try
+ {
+ bridge = new JMSBridgeImpl(cff0,
+ cff0,
+ sourceQueueFactory,
+ localTargetQueueFactory,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 3000,
+ 10,
+ QualityOfServiceMode.ONCE_AND_ONLY_ONCE,
+ 10000,
+ 3000,
+ null,
+ null,
+ false);
+ bridge.start();
+ }
+ finally
+ {
+ if (bridge != null)
+ {
+ bridge.stop();
+ }
+ }
+ }
+
+ @Test
+ public void testMBeanServer() throws Exception
+ {
+
+ MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
+ ObjectName objectName = new ObjectName("example.jmsbridge:service=JMSBridge");
+
+ JMSBridgeImpl bridge = new JMSBridgeImpl(cff0,
+ cff0,
+ sourceQueueFactory,
+ localTargetQueueFactory,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 5000,
+ 10,
+ QualityOfServiceMode.AT_MOST_ONCE,
+ 1,
+ -1,
+ null,
+ null,
+ false,
+ mbeanServer,
+ objectName.getCanonicalName());
+
+ Assert.assertTrue(mbeanServer.isRegistered(objectName));
+
+ bridge.destroy();
+
+ Assert.assertFalse(mbeanServer.isRegistered(objectName));
+ }
+
+ public TransactionManager getNewTm()
+ {
+ return newTransactionManager();
+ }
+
+ // Inner classes -------------------------------------------------------------------
+
+ private static class StressSender implements Runnable
+ {
+ int numMessages;
+
+ Session sess;
+
+ MessageProducer prod;
+
+ Exception ex;
+
+ public void run()
+ {
+ try
+ {
+ for (int i = 0; i < numMessages; i++)
+ {
+ TextMessage tm = sess.createTextMessage("message" + i);
+
+ prod.send(tm);
+
+ JMSBridgeTest.log.trace("Sent message " + i);
+ }
+ }
+ catch (Exception e)
+ {
+ JMSBridgeTest.log.error("Failed to send", e);
+ ex = e;
+ }
+ }
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/jms/bridge/TransactionManagerLocatorImpl.java
----------------------------------------------------------------------
diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/jms/bridge/TransactionManagerLocatorImpl.java b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/jms/bridge/TransactionManagerLocatorImpl.java
new file mode 100644
index 0000000..255741f
--- /dev/null
+++ b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/jms/bridge/TransactionManagerLocatorImpl.java
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.tests.extras.jms.bridge;
+
+import javax.transaction.TransactionManager;
+
+import org.apache.activemq.service.extensions.transactions.TransactionManagerLocator;
+
+/**
+ * @author mtaylor
+ */
+
+public class TransactionManagerLocatorImpl implements TransactionManagerLocator
+{
+ public static TransactionManager tm = null;
+
+ @Override
+ public TransactionManager getTransactionManager()
+ {
+ return tm;
+ }
+
+ public void setTransactionManager(TransactionManager transactionManager)
+ {
+ tm = transactionManager;
+ }
+}
[07/15] activemq-6 git commit: Refactored the testsuite a bit
Posted by jb...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/jms/bridge/ClusteredBridgeTestBase.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/jms/bridge/ClusteredBridgeTestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/jms/bridge/ClusteredBridgeTestBase.java
deleted file mode 100644
index 31a094a..0000000
--- a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/jms/bridge/ClusteredBridgeTestBase.java
+++ /dev/null
@@ -1,312 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.tests.integration.jms.bridge;
-
-import javax.jms.ConnectionFactory;
-import javax.jms.Destination;
-import javax.naming.Context;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import com.arjuna.ats.arjuna.coordinator.TransactionReaper;
-import com.arjuna.ats.arjuna.coordinator.TxControl;
-import org.apache.activemq.api.core.ActiveMQException;
-import org.apache.activemq.api.core.TransportConfiguration;
-import org.apache.activemq.api.core.client.ClientConsumer;
-import org.apache.activemq.api.core.client.ClientMessage;
-import org.apache.activemq.api.core.client.ClientProducer;
-import org.apache.activemq.api.core.client.ClientSession;
-import org.apache.activemq.api.core.client.ClientSessionFactory;
-import org.apache.activemq.api.core.client.FailoverEventListener;
-import org.apache.activemq.api.core.client.FailoverEventType;
-import org.apache.activemq.api.core.client.ActiveMQClient;
-import org.apache.activemq.api.core.client.ServerLocator;
-import org.apache.activemq.api.jms.ActiveMQJMSClient;
-import org.apache.activemq.api.jms.JMSFactoryType;
-import org.apache.activemq.core.config.Configuration;
-import org.apache.activemq.core.config.ha.ReplicaPolicyConfiguration;
-import org.apache.activemq.core.config.ha.ReplicatedPolicyConfiguration;
-import org.apache.activemq.core.registry.JndiBindingRegistry;
-import org.apache.activemq.core.remoting.impl.invm.TransportConstants;
-import org.apache.activemq.core.server.ActiveMQServer;
-import org.apache.activemq.core.server.ActiveMQServers;
-import org.apache.activemq.jms.bridge.ConnectionFactoryFactory;
-import org.apache.activemq.jms.bridge.DestinationFactory;
-import org.apache.activemq.jms.client.ActiveMQConnectionFactory;
-import org.apache.activemq.jms.server.JMSServerManager;
-import org.apache.activemq.jms.server.impl.JMSServerManagerImpl;
-import org.apache.activemq.tests.unit.util.InVMContext;
-import org.apache.activemq.tests.util.ServiceTestBase;
-import org.junit.After;
-import org.junit.Before;
-
-/**
- * A ClusteredBridgeTestBase
- * This class serves as a base class for jms bridge tests in
- * clustered scenarios.
- *
- * @author <a href="mailto:hgao@redhat.com">Howard Gao</a>
- */
-public abstract class ClusteredBridgeTestBase extends ServiceTestBase
-{
- private static int index = 0;
-
- protected Map<String, ServerGroup> groups = new HashMap<String, ServerGroup>();
-
- @Override
- @Before
- public void setUp() throws Exception
- {
- super.setUp();
- Iterator<ServerGroup> iter = groups.values().iterator();
- while (iter.hasNext())
- {
- iter.next().start();
- }
- TxControl.enable();
- }
-
- @Override
- @After
- public void tearDown() throws Exception
- {
- Iterator<ServerGroup> iter = groups.values().iterator();
- while (iter.hasNext())
- {
- iter.next().stop();
- }
-
- TxControl.disable(true);
-
- TransactionReaper.terminate(false);
-
- super.tearDown();
- }
-
- //create a live/backup pair.
- protected ServerGroup createServerGroup(String name) throws Exception
- {
- ServerGroup server = groups.get(name);
- if (server == null)
- {
- server = new ServerGroup(name, groups.size());
- server.create();
- groups.put(name, server);
- }
- return server;
- }
-
- //each ServerGroup represents a live/backup pair
- protected class ServerGroup
- {
- private static final int ID_OFFSET = 100;
- private String name;
- private int id;
-
- private JMSServerManager liveNode;
- private JMSServerManager backupNode;
-
- private TransportConfiguration liveConnector;
- private TransportConfiguration backupConnector;
-
- private Context liveContext;
-
- private ServerLocator locator;
- private ClientSessionFactory sessionFactory;
-
- /**
- * @param name - name of the group
- * @param id - id of the live (should be < 100)
- */
- public ServerGroup(String name, int id)
- {
- this.name = name;
- this.id = id;
- }
-
- public String getName()
- {
- return name;
- }
-
- public void create() throws Exception
- {
- Map<String, Object> params0 = new HashMap<String, Object>();
- params0.put(TransportConstants.SERVER_ID_PROP_NAME, id);
- liveConnector = new TransportConfiguration(INVM_CONNECTOR_FACTORY, params0, "in-vm-live");
-
- Map<String, Object> params = new HashMap<String, Object>();
- params.put(TransportConstants.SERVER_ID_PROP_NAME, id + ID_OFFSET);
- backupConnector = new TransportConfiguration(INVM_CONNECTOR_FACTORY, params, "in-vm-backup");
-
- //live
- Configuration conf0 = createBasicConfig()
- .setJournalDirectory(getJournalDir(id, false))
- .setBindingsDirectory(getBindingsDir(id, false))
- .addAcceptorConfiguration(new TransportConfiguration(INVM_ACCEPTOR_FACTORY, params0))
- .addConnectorConfiguration(liveConnector.getName(), liveConnector)
- .setHAPolicyConfiguration(new ReplicatedPolicyConfiguration())
- .addClusterConfiguration(basicClusterConnectionConfig(liveConnector.getName()));
-
- ActiveMQServer server0 = addServer(ActiveMQServers.newActiveMQServer(conf0, true));
-
- liveContext = new InVMContext();
- liveNode = new JMSServerManagerImpl(server0);
- liveNode.setRegistry(new JndiBindingRegistry(liveContext));
-
- //backup
- Configuration conf = createBasicConfig()
- .setJournalDirectory(getJournalDir(id, true))
- .setBindingsDirectory(getBindingsDir(id, true))
- .addAcceptorConfiguration(new TransportConfiguration(INVM_ACCEPTOR_FACTORY, params))
- .addConnectorConfiguration(backupConnector.getName(), backupConnector)
- .addConnectorConfiguration(liveConnector.getName(), liveConnector)
- .setHAPolicyConfiguration(new ReplicaPolicyConfiguration())
- .addClusterConfiguration(basicClusterConnectionConfig(backupConnector.getName(), liveConnector.getName()));
-
- ActiveMQServer backup = addServer(ActiveMQServers.newActiveMQServer(conf, true));
-
- Context context = new InVMContext();
-
- backupNode = new JMSServerManagerImpl(backup);
- backupNode.setRegistry(new JndiBindingRegistry(context));
- }
-
- public void start() throws Exception
- {
- liveNode.start();
- waitForServer(liveNode.getActiveMQServer());
- backupNode.start();
- waitForRemoteBackupSynchronization(backupNode.getActiveMQServer());
-
- locator = ActiveMQClient.createServerLocatorWithHA(liveConnector);
- locator.setReconnectAttempts(-1);
- sessionFactory = locator.createSessionFactory();
- }
-
- public void stop() throws Exception
- {
- sessionFactory.close();
- locator.close();
- liveNode.stop();
- backupNode.stop();
- }
-
- public void createQueue(String queueName) throws Exception
- {
- liveNode.createQueue(true, queueName, null, true, "/queue/" + queueName);
- }
-
- public ConnectionFactoryFactory getConnectionFactoryFactory()
- {
- ConnectionFactoryFactory cff = new ConnectionFactoryFactory()
- {
- public ConnectionFactory createConnectionFactory() throws Exception
- {
- ActiveMQConnectionFactory cf = ActiveMQJMSClient.createConnectionFactoryWithHA(JMSFactoryType.XA_CF,
- liveConnector);
- cf.getServerLocator().setReconnectAttempts(-1);
- return cf;
- }
- };
-
- return cff;
- }
-
- public DestinationFactory getDestinationFactory(final String queueName)
- {
-
- DestinationFactory destFactory = new DestinationFactory()
- {
- public Destination createDestination() throws Exception
- {
- return (Destination) liveContext.lookup("/queue/" + queueName);
- }
- };
- return destFactory;
- }
-
- public void sendMessages(String queueName, int num) throws ActiveMQException
- {
- ClientSession session = sessionFactory.createSession();
- ClientProducer producer = session.createProducer("jms.queue." + queueName);
- for (int i = 0; i < num; i++)
- {
- ClientMessage m = session.createMessage(true);
- m.putStringProperty("bridge-message", "hello " + index);
- index++;
- producer.send(m);
- }
- session.close();
- }
-
- public void receiveMessages(String queueName, int num, boolean checkDup) throws ActiveMQException
- {
- ClientSession session = sessionFactory.createSession();
- session.start();
- ClientConsumer consumer = session.createConsumer("jms.queue." + queueName);
- for (int i = 0; i < num; i++)
- {
- ClientMessage m = consumer.receive(30000);
- assertNotNull("i=" + i, m);
- assertNotNull(m.getStringProperty("bridge-message"));
- m.acknowledge();
- }
-
- ClientMessage m = consumer.receive(500);
- if (checkDup)
- {
- assertNull(m);
- }
- else
- {
- //drain messages
- while (m != null)
- {
- m = consumer.receive(200);
- }
- }
-
- session.close();
- }
-
- public void crashLive() throws Exception
- {
- final CountDownLatch latch = new CountDownLatch(1);
- sessionFactory.addFailoverListener(new FailoverEventListener()
- {
-
- @Override
- public void failoverEvent(FailoverEventType eventType)
- {
- if (eventType == FailoverEventType.FAILOVER_COMPLETED)
- {
- latch.countDown();
- }
- }
- });
-
- liveNode.getActiveMQServer().stop();
-
- boolean ok = latch.await(10000, TimeUnit.MILLISECONDS);
- assertTrue(ok);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/jms/bridge/JMSBridgeClusteredTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/jms/bridge/JMSBridgeClusteredTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/jms/bridge/JMSBridgeClusteredTest.java
deleted file mode 100644
index d3baf43..0000000
--- a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/jms/bridge/JMSBridgeClusteredTest.java
+++ /dev/null
@@ -1,276 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.tests.integration.jms.bridge;
-
-import javax.transaction.TransactionManager;
-
-import com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionManagerImple;
-import org.apache.activemq.api.core.ActiveMQException;
-import org.apache.activemq.jms.bridge.ConnectionFactoryFactory;
-import org.apache.activemq.jms.bridge.DestinationFactory;
-import org.apache.activemq.jms.bridge.QualityOfServiceMode;
-import org.apache.activemq.jms.bridge.impl.JMSBridgeImpl;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * A JMSBridgeClusteredTest
- * <p/>
- * Tests of jms bridge using HA connection factories.
- *
- * @author <a href="mailto:hgao@redhat.com">Howard Gao</a>
- */
-public class JMSBridgeClusteredTest extends ClusteredBridgeTestBase
-{
- private ServerGroup sourceServer;
- private ServerGroup targetServer;
-
- private String sourceQueueName = "SourceQueue";
- private String targetQueueName = "TargetQueue";
-
- @Override
- @Before
- public void setUp() throws Exception
- {
- super.setUp();
-
- sourceServer = createServerGroup("source-server");
- targetServer = createServerGroup("target-server");
-
- sourceServer.start();
- targetServer.start();
-
- sourceServer.createQueue(sourceQueueName);
- targetServer.createQueue(targetQueueName);
- }
-
- @Test
- public void testBridgeOnFailoverXA() throws Exception
- {
- performSourceAndTargetCrashAndFailover(QualityOfServiceMode.ONCE_AND_ONLY_ONCE);
- }
-
- @Test
- public void testBridgeOnFailoverDupsOk() throws Exception
- {
- performSourceAndTargetCrashAndFailover(QualityOfServiceMode.DUPLICATES_OK);
- }
-
- @Test
- public void testBridgeOnFailoverAtMostOnce() throws Exception
- {
- performSourceAndTargetCrashAndFailover(QualityOfServiceMode.AT_MOST_ONCE);
- }
-
- @Test
- public void testCrashAndFailoverWithMessagesXA() throws Exception
- {
- performSourceAndTargetCrashAndFailoverWithMessages(QualityOfServiceMode.ONCE_AND_ONLY_ONCE);
- }
-
- //test messages are correctly bridged when failover happens during a batch send.
- //first send some messages, make sure bridge doesn't send it (below batch size)
- //then crash the live
- //then send more messages
- //then receive those messages, no more, no less.
- //this test are valid for ONCE_AND_ONLY_ONCE and AT_MOST_ONCE.
- //with DUPS_OK the test failed because some messages are delivered again
- //after failover, which is fine as in this mode duplication is allowed.
- public void performSourceAndTargetCrashAndFailoverWithMessages(QualityOfServiceMode mode) throws Exception
- {
- JMSBridgeImpl bridge = null;
- TransactionManager txMgr = null;
-
- try
- {
- ConnectionFactoryFactory sourceCFF = sourceServer.getConnectionFactoryFactory();
- ConnectionFactoryFactory targetCFF = targetServer.getConnectionFactoryFactory();
- DestinationFactory sourceQueueFactory = sourceServer.getDestinationFactory(sourceQueueName);
- DestinationFactory targetQueueFactory = targetServer.getDestinationFactory(targetQueueName);
-
- //even number
- final int batchSize = 4;
- bridge = new JMSBridgeImpl(sourceCFF,
- targetCFF,
- sourceQueueFactory,
- targetQueueFactory,
- null,
- null,
- null,
- null,
- null,
- 1000,
- -1,
- mode,
- batchSize,
- -1,
- null,
- null,
- false);
-
- txMgr = newTransactionManager();
- bridge.setTransactionManager(txMgr);
-
- //start the bridge
- bridge.start();
-
- System.out.println("started bridge");
-
- final int NUM_MESSAGES = batchSize / 2;
-
- //send some messages to source
- sendMessages(sourceServer, sourceQueueName, NUM_MESSAGES);
- //receive from target, no message should be received.
- receiveMessages(targetServer, targetQueueName, 0);
-
- //now crash target server
- targetServer.crashLive();
-
- //send more
- sendMessages(sourceServer, sourceQueueName, NUM_MESSAGES);
-
- receiveMessages(targetServer, targetQueueName, batchSize);
-
- //send some again
- sendMessages(sourceServer, sourceQueueName, NUM_MESSAGES);
- //check no messages arrived.
- receiveMessages(targetServer, targetQueueName, 0);
- //now crash source server
- sourceServer.crashLive();
-
- //verify bridge still work
- sendMessages(sourceServer, sourceQueueName, NUM_MESSAGES);
- receiveMessages(targetServer, targetQueueName, batchSize);
- }
- finally
- {
- if (bridge != null)
- {
- bridge.stop();
- }
- }
- }
-
- /*
- * Deploy a bridge, source and target queues are in
- * separate live/backup pairs. Source and Target CF are ha.
- * Test the bridge work when the live servers crash.
- */
- private void performSourceAndTargetCrashAndFailover(QualityOfServiceMode mode) throws Exception
- {
-
- JMSBridgeImpl bridge = null;
- TransactionManager txMgr = null;
-
- try
- {
- ConnectionFactoryFactory sourceCFF = sourceServer.getConnectionFactoryFactory();
- ConnectionFactoryFactory targetCFF = targetServer.getConnectionFactoryFactory();
- DestinationFactory sourceQueueFactory = sourceServer.getDestinationFactory(sourceQueueName);
- DestinationFactory targetQueueFactory = targetServer.getDestinationFactory(targetQueueName);
-
- bridge = new JMSBridgeImpl(sourceCFF,
- targetCFF,
- sourceQueueFactory,
- targetQueueFactory,
- null,
- null,
- null,
- null,
- null,
- 1000,
- -1,
- mode,
- 10,
- 1000,
- null,
- null,
- false);
-
- txMgr = newTransactionManager();
- bridge.setTransactionManager(txMgr);
-
- //start the bridge
- bridge.start();
-
- final int NUM_MESSAGES = 10;
-
- //send some messages to source
- sendMessages(sourceServer, sourceQueueName, NUM_MESSAGES);
- //receive from target
- receiveMessages(targetServer, targetQueueName, NUM_MESSAGES);
-
- //now crash target server
- targetServer.crashLive();
-
- //verify bridge still works
- sendMessages(sourceServer, sourceQueueName, NUM_MESSAGES);
- receiveMessages(targetServer, targetQueueName, NUM_MESSAGES);
-
- //now crash source server
- sourceServer.crashLive();
-
- //verify bridge still work
- sendMessages(sourceServer, sourceQueueName, NUM_MESSAGES);
- receiveMessages(targetServer, targetQueueName, NUM_MESSAGES, mode == QualityOfServiceMode.ONCE_AND_ONLY_ONCE);
- }
- finally
- {
- if (bridge != null)
- {
- bridge.stop();
- }
- }
- }
-
- private void sendMessages(ServerGroup server, String queueName, int num) throws ActiveMQException
- {
- server.sendMessages(queueName, num);
- }
-
- private void receiveMessages(ServerGroup server, String queueName, int num, boolean checkDup) throws ActiveMQException
- {
- try
- {
- server.receiveMessages(queueName, num, checkDup);
- }
- catch (ActiveMQException e)
- {
- e.printStackTrace();
- throw e;
- }
- }
-
- private void receiveMessages(ServerGroup server, String queueName, int num) throws ActiveMQException
- {
- try
- {
- server.receiveMessages(queueName, num, false);
- }
- catch (ActiveMQException e)
- {
- e.printStackTrace();
- throw e;
- }
- }
-
- protected TransactionManager newTransactionManager()
- {
- return new TransactionManagerImple();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/jms/bridge/JMSBridgeReconnectionTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/jms/bridge/JMSBridgeReconnectionTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/jms/bridge/JMSBridgeReconnectionTest.java
deleted file mode 100644
index 752c8c5..0000000
--- a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/jms/bridge/JMSBridgeReconnectionTest.java
+++ /dev/null
@@ -1,559 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.tests.integration.jms.bridge;
-
-import org.apache.activemq.api.core.TransportConfiguration;
-import org.apache.activemq.api.core.client.ClientSession;
-import org.apache.activemq.api.jms.ActiveMQJMSClient;
-import org.apache.activemq.api.jms.JMSFactoryType;
-import org.apache.activemq.jms.bridge.ConnectionFactoryFactory;
-import org.apache.activemq.jms.bridge.QualityOfServiceMode;
-import org.apache.activemq.jms.bridge.impl.JMSBridgeImpl;
-import org.apache.activemq.jms.client.ActiveMQXAConnectionFactory;
-import org.apache.activemq.tests.integration.IntegrationTestLogger;
-import org.apache.activemq.tests.integration.ra.DummyTransactionManager;
-import org.junit.Assert;
-import org.junit.Test;
-
-import javax.transaction.HeuristicMixedException;
-import javax.transaction.HeuristicRollbackException;
-import javax.transaction.RollbackException;
-import javax.transaction.Synchronization;
-import javax.transaction.SystemException;
-import javax.transaction.Transaction;
-import javax.transaction.xa.XAResource;
-
-/**
- * @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
- */
-public class JMSBridgeReconnectionTest extends BridgeTestBase
-{
- /**
- *
- */
- private static final int TIME_WAIT = 5000;
-
- private static final IntegrationTestLogger log = IntegrationTestLogger.LOGGER;
-
- // Crash and reconnect
-
- // Once and only once
-
- @Test
- public void testCrashAndReconnectDestBasic_OnceAndOnlyOnce_P() throws Exception
- {
- performCrashAndReconnectDestBasic(QualityOfServiceMode.ONCE_AND_ONLY_ONCE, true, false);
- }
-
- @Test
- public void testCrashAndReconnectDestBasic_OnceAndOnlyOnce_P_LargeMessage() throws Exception
- {
- performCrashAndReconnectDestBasic(QualityOfServiceMode.ONCE_AND_ONLY_ONCE, true, true);
- }
-
- @Test
- public void testCrashAndReconnectDestBasic_OnceAndOnlyOnce_NP() throws Exception
- {
- performCrashAndReconnectDestBasic(QualityOfServiceMode.ONCE_AND_ONLY_ONCE, false, false);
- }
-
- // dups ok
-
- @Test
- public void testCrashAndReconnectDestBasic_DuplicatesOk_P() throws Exception
- {
- performCrashAndReconnectDestBasic(QualityOfServiceMode.DUPLICATES_OK, true, false);
- }
-
- @Test
- public void testCrashAndReconnectDestBasic_DuplicatesOk_NP() throws Exception
- {
- performCrashAndReconnectDestBasic(QualityOfServiceMode.DUPLICATES_OK, false, false);
- }
-
- // At most once
-
- @Test
- public void testCrashAndReconnectDestBasic_AtMostOnce_P() throws Exception
- {
- performCrashAndReconnectDestBasic(QualityOfServiceMode.AT_MOST_ONCE, true, false);
- }
-
- @Test
- public void testCrashAndReconnectDestBasic_AtMostOnce_NP() throws Exception
- {
- performCrashAndReconnectDestBasic(QualityOfServiceMode.AT_MOST_ONCE, false, false);
- }
-
- // Crash tests specific to XA transactions
-
- @Test
- public void testCrashAndReconnectDestCrashBeforePrepare_P() throws Exception
- {
- performCrashAndReconnectDestCrashBeforePrepare(true);
- }
-
- @Test
- public void testCrashAndReconnectDestCrashBeforePrepare_NP() throws Exception
- {
- performCrashAndReconnectDestCrashBeforePrepare(false);
- }
-
- // Crash before bridge is started
-
- @Test
- public void testRetryConnectionOnStartup() throws Exception
- {
- jmsServer1.stop();
-
- JMSBridgeImpl bridge = new JMSBridgeImpl(cff0,
- cff1,
- sourceQueueFactory,
- targetQueueFactory,
- null,
- null,
- null,
- null,
- null,
- 1000,
- -1,
- QualityOfServiceMode.DUPLICATES_OK,
- 10,
- -1,
- null,
- null,
- false);
- bridge.setTransactionManager(newTransactionManager());
- addActiveMQComponent(bridge);
- bridge.start();
- Assert.assertFalse(bridge.isStarted());
- Assert.assertTrue(bridge.isFailed());
-
- // Restart the server
- jmsServer1.start();
-
- createQueue("targetQueue", 1);
- setUpAdministeredObjects();
-
- Thread.sleep(3000);
-
- Assert.assertTrue(bridge.isStarted());
- Assert.assertFalse(bridge.isFailed());
- }
-
- /**
- * https://jira.jboss.org/jira/browse/HORNETQ-287
- */
- @Test
- public void testStopBridgeWithFailureWhenStarted() throws Exception
- {
- jmsServer1.stop();
-
- JMSBridgeImpl bridge = new JMSBridgeImpl(cff0,
- cff1,
- sourceQueueFactory,
- targetQueueFactory,
- null,
- null,
- null,
- null,
- null,
- 500,
- -1,
- QualityOfServiceMode.DUPLICATES_OK,
- 10,
- -1,
- null,
- null,
- false);
- bridge.setTransactionManager(newTransactionManager());
-
- bridge.start();
- Assert.assertFalse(bridge.isStarted());
- Assert.assertTrue(bridge.isFailed());
-
- bridge.stop();
- Assert.assertFalse(bridge.isStarted());
-
- // we restart and setup the server for the test's tearDown checks
- jmsServer1.start();
- createQueue("targetQueue", 1);
- setUpAdministeredObjects();
- }
-
- /*
- * Send some messages
- * Crash the destination server
- * Bring the destination server back up
- * Send some more messages
- * Verify all messages are received
- */
- private void performCrashAndReconnectDestBasic(final QualityOfServiceMode qosMode,
- final boolean persistent,
- final boolean largeMessage) throws Exception
- {
- JMSBridgeImpl bridge = null;
-
- ConnectionFactoryFactory factInUse0 = cff0;
- ConnectionFactoryFactory factInUse1 = cff1;
- if (qosMode.equals(QualityOfServiceMode.ONCE_AND_ONLY_ONCE))
- {
- factInUse0 = cff0xa;
- factInUse1 = cff1xa;
- }
-
- bridge =
- new JMSBridgeImpl(factInUse0,
- factInUse1,
- sourceQueueFactory,
- targetQueueFactory,
- null,
- null,
- null,
- null,
- null,
- 1000,
- -1,
- qosMode,
- 10,
- -1,
- null,
- null,
- false);
- addActiveMQComponent(bridge);
- bridge.setTransactionManager(newTransactionManager());
- bridge.start();
-
- final int NUM_MESSAGES = 10;
-
- // Send some messages
-
- sendMessages(cf0, sourceQueue, 0, NUM_MESSAGES / 2, persistent, largeMessage);
-
- // Verify none are received
-
- checkEmpty(targetQueue, 1);
-
- // Now crash the dest server
-
- JMSBridgeReconnectionTest.log.info("About to crash server");
-
- jmsServer1.stop();
-
- // Wait a while before starting up to simulate the dest being down for a while
- JMSBridgeReconnectionTest.log.info("Waiting 5 secs before bringing server back up");
- Thread.sleep(TIME_WAIT);
- JMSBridgeReconnectionTest.log.info("Done wait");
-
- // Restart the server
- JMSBridgeReconnectionTest.log.info("Restarting server");
- jmsServer1.start();
-
- // jmsServer1.createQueue(false, "targetQueue", null, true, "queue/targetQueue");
-
- createQueue("targetQueue", 1);
-
- setUpAdministeredObjects();
-
- // Send some more messages
-
- JMSBridgeReconnectionTest.log.info("Sending more messages");
-
- sendMessages(cf0, sourceQueue, NUM_MESSAGES / 2, NUM_MESSAGES / 2, persistent, largeMessage);
-
- JMSBridgeReconnectionTest.log.info("Sent messages");
-
- jmsServer1.stop();
-
- bridge.stop();
-
- System.out.println("JMSBridgeReconnectionTest.performCrashAndReconnectDestBasic");
- }
-
- @Test
- public void performCrashDestinationStopBridge() throws Exception
- {
- ConnectionFactoryFactory factInUse0 = cff0;
- ConnectionFactoryFactory factInUse1 = cff1;
- final JMSBridgeImpl bridge =
- new JMSBridgeImpl(factInUse0,
- factInUse1,
- sourceQueueFactory,
- targetQueueFactory,
- null,
- null,
- null,
- null,
- null,
- 1000,
- -1,
- QualityOfServiceMode.DUPLICATES_OK,
- 10,
- -1,
- null,
- null,
- false);
-
-
- addActiveMQComponent(bridge);
- bridge.setTransactionManager(newTransactionManager());
- bridge.start();
-
- Thread clientThread = new Thread(new Runnable()
- {
- @Override
- public void run()
- {
- while (bridge.isStarted())
- {
- try
- {
- sendMessages(cf0, sourceQueue, 0, 1, false, false);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- }
- });
-
- clientThread.start();
-
- checkAllMessageReceivedInOrder(cf1, targetQueue, 0, 1, false);
-
- JMSBridgeReconnectionTest.log.info("About to crash server");
-
- jmsServer1.stop();
-
- // Wait a while before starting up to simulate the dest being down for a while
- JMSBridgeReconnectionTest.log.info("Waiting 5 secs before bringing server back up");
- Thread.sleep(TIME_WAIT);
- JMSBridgeReconnectionTest.log.info("Done wait");
-
- bridge.stop();
-
- clientThread.join(5000);
-
- assertTrue(!clientThread.isAlive());
- }
-
- @Test
- public void performCrashAndReconnect() throws Exception
- {
- performCrashAndReconnect(true);
- }
-
- @Test
- public void performCrashAndNoReconnect() throws Exception
- {
- performCrashAndReconnect(false);
- }
-
-
- private void performCrashAndReconnect(boolean restart) throws Exception
- {
- cff1xa = new ConnectionFactoryFactory()
- {
- public Object createConnectionFactory() throws Exception
- {
- ActiveMQXAConnectionFactory cf = (ActiveMQXAConnectionFactory) ActiveMQJMSClient.createConnectionFactoryWithHA(JMSFactoryType.XA_CF,
- new TransportConfiguration(
- INVM_CONNECTOR_FACTORY,
- params1));
-
- // Note! We disable automatic reconnection on the session factory. The bridge needs to do the reconnection
- cf.setReconnectAttempts(-1);
- cf.setBlockOnNonDurableSend(true);
- cf.setBlockOnDurableSend(true);
- cf.setCacheLargeMessagesClient(true);
-
- return cf;
- }
-
- };
-
- DummyTransactionManager tm = new DummyTransactionManager();
- DummyTransaction tx = new DummyTransaction();
- tm.tx = tx;
-
- JMSBridgeImpl bridge =
- new JMSBridgeImpl(cff0xa,
- cff1xa,
- sourceQueueFactory,
- targetQueueFactory,
- null,
- null,
- null,
- null,
- null,
- 1000,
- -1,
- QualityOfServiceMode.ONCE_AND_ONLY_ONCE,
- 10,
- 5000,
- null,
- null,
- false);
- addActiveMQComponent(bridge);
- bridge.setTransactionManager(tm);
-
- bridge.start();
-
- // Now crash the dest server
-
- JMSBridgeReconnectionTest.log.info("About to crash server");
-
- jmsServer1.stop();
-
- if (restart)
- {
- jmsServer1.start();
- }
- // Wait a while before starting up to simulate the dest being down for a while
- JMSBridgeReconnectionTest.log.info("Waiting 5 secs before bringing server back up");
- Thread.sleep(TIME_WAIT);
- JMSBridgeReconnectionTest.log.info("Done wait");
-
- bridge.stop();
-
- if (restart)
- {
- assertTrue(tx.rolledback);
- assertTrue(tx.targetConnected);
- }
- else
- {
- assertTrue(tx.rolledback);
- assertFalse(tx.targetConnected);
- }
- }
-
- private class DummyTransaction implements Transaction
- {
- boolean rolledback = false;
- ClientSession targetSession;
- boolean targetConnected = false;
- @Override
- public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, SystemException
- {
-
- }
-
- @Override
- public void rollback() throws IllegalStateException, SystemException
- {
- rolledback = true;
- targetConnected = !targetSession.isClosed();
- }
-
- @Override
- public void setRollbackOnly() throws IllegalStateException, SystemException
- {
-
- }
-
- @Override
- public int getStatus() throws SystemException
- {
- return 0;
- }
-
- @Override
- public boolean enlistResource(XAResource xaResource) throws RollbackException, IllegalStateException, SystemException
- {
- targetSession = (ClientSession) xaResource;
- return false;
- }
-
- @Override
- public boolean delistResource(XAResource xaResource, int i) throws IllegalStateException, SystemException
- {
- return false;
- }
-
- @Override
- public void registerSynchronization(Synchronization synchronization) throws RollbackException, IllegalStateException, SystemException
- {
-
- }
- }
- /*
- * Send some messages
- * Crash the destination server
- * Set the max batch time such that it will attempt to send the batch while the dest server is down
- * Bring up the destination server
- * Send some more messages
- * Verify all messages are received
- */
- private void performCrashAndReconnectDestCrashBeforePrepare(final boolean persistent) throws Exception
- {
- JMSBridgeImpl bridge =
- new JMSBridgeImpl(cff0xa,
- cff1xa,
- sourceQueueFactory,
- targetQueueFactory,
- null,
- null,
- null,
- null,
- null,
- 1000,
- -1,
- QualityOfServiceMode.ONCE_AND_ONLY_ONCE,
- 10,
- 5000,
- null,
- null,
- false);
- addActiveMQComponent(bridge);
- bridge.setTransactionManager(newTransactionManager());
-
- bridge.start();
-
- final int NUM_MESSAGES = 10;
- // Send some messages
-
- sendMessages(cf0, sourceQueue, 0, NUM_MESSAGES / 2, persistent, false);
-
- // verify none are received
-
- checkEmpty(targetQueue, 1);
-
- // Now crash the dest server
-
- JMSBridgeReconnectionTest.log.info("About to crash server");
-
- jmsServer1.stop();
-
- // Wait a while before starting up to simulate the dest being down for a while
- JMSBridgeReconnectionTest.log.info("Waiting 5 secs before bringing server back up");
- Thread.sleep(TIME_WAIT);
- JMSBridgeReconnectionTest.log.info("Done wait");
-
- // Restart the server
- jmsServer1.start();
-
- createQueue("targetQueue", 1);
-
- setUpAdministeredObjects();
-
- sendMessages(cf0, sourceQueue, NUM_MESSAGES / 2, NUM_MESSAGES / 2, persistent, false);
-
- checkMessagesReceived(cf1, targetQueue, QualityOfServiceMode.ONCE_AND_ONLY_ONCE, NUM_MESSAGES, false, false);
- }
-}
[02/15] activemq-6 git commit: Refactored the testsuite a bit
Posted by jb...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/TopicStressTest.java
----------------------------------------------------------------------
diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/TopicStressTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/TopicStressTest.java
deleted file mode 100644
index f81099e..0000000
--- a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/TopicStressTest.java
+++ /dev/null
@@ -1,297 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.jms.tests.stress;
-
-import javax.jms.Connection;
-import javax.jms.DeliveryMode;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.XAConnection;
-import javax.jms.XASession;
-
-import org.junit.Test;
-
-/**
- * A TopicStressTest.
- *
- * @author <a href="tim.fox@jboss.com">Tim Fox</a>
- * @version <tt>$Revision: 2349 $</tt>
- */
-public class TopicStressTest extends JMSStressTestBase
-{
- /*
- * Stress a topic with with many non transactional, transactional and 2pc receivers.
- * Non transactional receivers use ack modes of auto, dups and client ack.
- * Client ack receivers go through a cycle of receiving a batch, acking and recovering
- * Transactional receivers go through a cycle of receiving committing and rolling back.
- * Half the consumers are durable and half non durable.
- *
- */
- @Test
- public void testTopicMultipleReceivers() throws Exception
- {
- Connection conn1 = cf.createConnection();
-
- Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Session sess2 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageProducer prod1 = sess1.createProducer(topic1);
- prod1.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-
- MessageProducer prod2 = sess2.createProducer(topic1);
- prod2.setDeliveryMode(DeliveryMode.PERSISTENT);
-
- Connection conn2 = cf.createConnection();
- conn2.setClientID("clientid1");
- conn2.start();
-
- // 4 auto ack
- Session rsess1 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Session rsess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Session rsess3 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Session rsess4 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- // 4 dups
- Session rsess5 = conn2.createSession(false, Session.DUPS_OK_ACKNOWLEDGE);
- Session rsess6 = conn2.createSession(false, Session.DUPS_OK_ACKNOWLEDGE);
- Session rsess7 = conn2.createSession(false, Session.DUPS_OK_ACKNOWLEDGE);
- Session rsess8 = conn2.createSession(false, Session.DUPS_OK_ACKNOWLEDGE);
-
- // 4 client
- Session rsess9 = conn2.createSession(false, Session.CLIENT_ACKNOWLEDGE);
- Session rsess10 = conn2.createSession(false, Session.CLIENT_ACKNOWLEDGE);
- Session rsess11 = conn2.createSession(false, Session.CLIENT_ACKNOWLEDGE);
- Session rsess12 = conn2.createSession(false, Session.CLIENT_ACKNOWLEDGE);
-
- // 4 transactional
- Session rsess13 = conn2.createSession(true, Session.SESSION_TRANSACTED);
- Session rsess14 = conn2.createSession(true, Session.SESSION_TRANSACTED);
- Session rsess15 = conn2.createSession(true, Session.SESSION_TRANSACTED);
- Session rsess16 = conn2.createSession(true, Session.SESSION_TRANSACTED);
-
- // 4 2pc transactional
- XASession rxaSess1 = ((XAConnection) conn2).createXASession();
- tweakXASession(rxaSess1);
- XASession rxaSess2 = ((XAConnection) conn2).createXASession();
- tweakXASession(rxaSess2);
- XASession rxaSess3 = ((XAConnection) conn2).createXASession();
- tweakXASession(rxaSess3);
- XASession rxaSess4 = ((XAConnection) conn2).createXASession();
- tweakXASession(rxaSess4);
-
- Session rsess17 = rxaSess1.getSession();
- Session rsess18 = rxaSess2.getSession();
- Session rsess19 = rxaSess3.getSession();
- Session rsess20 = rxaSess4.getSession();
-
- MessageConsumer cons1 = rsess1.createConsumer(topic1);
- MessageConsumer cons2 = rsess2.createDurableSubscriber(topic1, "sub1");
- MessageConsumer cons3 = rsess3.createConsumer(topic1);
- MessageConsumer cons4 = rsess4.createDurableSubscriber(topic1, "sub2");
- MessageConsumer cons5 = rsess5.createConsumer(topic1);
- MessageConsumer cons6 = rsess6.createDurableSubscriber(topic1, "sub3");
- MessageConsumer cons7 = rsess7.createConsumer(topic1);
- MessageConsumer cons8 = rsess8.createDurableSubscriber(topic1, "sub4");
- MessageConsumer cons9 = rsess9.createConsumer(topic1);
- MessageConsumer cons10 = rsess10.createDurableSubscriber(topic1, "sub5");
- MessageConsumer cons11 = rsess11.createConsumer(topic1);
- MessageConsumer cons12 = rsess12.createDurableSubscriber(topic1, "sub6");
- MessageConsumer cons13 = rsess13.createConsumer(topic1);
- MessageConsumer cons14 = rsess14.createDurableSubscriber(topic1, "sub7");
- MessageConsumer cons15 = rsess15.createConsumer(topic1);
- MessageConsumer cons16 = rsess16.createDurableSubscriber(topic1, "sub8");
- MessageConsumer cons17 = rsess17.createConsumer(topic1);
- MessageConsumer cons18 = rsess18.createDurableSubscriber(topic1, "sub9");
- MessageConsumer cons19 = rsess19.createConsumer(topic1);
- MessageConsumer cons20 = rsess20.createDurableSubscriber(topic1, "sub10");
-
- // To make sure paging occurs first send some messages before receiving
-
- Runner[] runners = new Runner[]{
- new Sender("prod1", sess1, prod1, JMSStressTestBase.NUM_NON_PERSISTENT_PRESEND),
- new Sender("prod2", sess2, prod2, JMSStressTestBase.NUM_PERSISTENT_PRESEND)};
-
- runRunners(runners);
-
- runners = new Runner[]{
- // 4 auto ack
- new Receiver(rsess1,
- cons1,
- JMSStressTestBase.NUM_NON_PERSISTENT_MESSAGES + JMSStressTestBase.NUM_PERSISTENT_MESSAGES +
- JMSStressTestBase.NUM_NON_PERSISTENT_PRESEND +
- JMSStressTestBase.NUM_PERSISTENT_PRESEND,
- false),
- new Receiver(rsess2,
- cons2,
- JMSStressTestBase.NUM_NON_PERSISTENT_MESSAGES + JMSStressTestBase.NUM_PERSISTENT_MESSAGES +
- JMSStressTestBase.NUM_NON_PERSISTENT_PRESEND +
- JMSStressTestBase.NUM_PERSISTENT_PRESEND,
- true),
- new Receiver(rsess3,
- cons3,
- JMSStressTestBase.NUM_NON_PERSISTENT_MESSAGES + JMSStressTestBase.NUM_PERSISTENT_MESSAGES +
- JMSStressTestBase.NUM_NON_PERSISTENT_PRESEND +
- JMSStressTestBase.NUM_PERSISTENT_PRESEND,
- false),
- new Receiver(rsess4,
- cons4,
- JMSStressTestBase.NUM_NON_PERSISTENT_MESSAGES + JMSStressTestBase.NUM_PERSISTENT_MESSAGES +
- JMSStressTestBase.NUM_NON_PERSISTENT_PRESEND +
- JMSStressTestBase.NUM_PERSISTENT_PRESEND,
- true),
-
- // 4 dups ok
- new Receiver(rsess5,
- cons5,
- JMSStressTestBase.NUM_NON_PERSISTENT_MESSAGES + JMSStressTestBase.NUM_PERSISTENT_MESSAGES +
- JMSStressTestBase.NUM_NON_PERSISTENT_PRESEND +
- JMSStressTestBase.NUM_PERSISTENT_PRESEND,
- false),
- new Receiver(rsess6,
- cons6,
- JMSStressTestBase.NUM_NON_PERSISTENT_MESSAGES + JMSStressTestBase.NUM_PERSISTENT_MESSAGES +
- JMSStressTestBase.NUM_NON_PERSISTENT_PRESEND +
- JMSStressTestBase.NUM_PERSISTENT_PRESEND,
- true),
- new Receiver(rsess7,
- cons7,
- JMSStressTestBase.NUM_NON_PERSISTENT_MESSAGES + JMSStressTestBase.NUM_PERSISTENT_MESSAGES +
- JMSStressTestBase.NUM_NON_PERSISTENT_PRESEND +
- JMSStressTestBase.NUM_PERSISTENT_PRESEND,
- false),
- new Receiver(rsess8,
- cons8,
- JMSStressTestBase.NUM_NON_PERSISTENT_MESSAGES + JMSStressTestBase.NUM_PERSISTENT_MESSAGES +
- JMSStressTestBase.NUM_NON_PERSISTENT_PRESEND +
- JMSStressTestBase.NUM_PERSISTENT_PRESEND,
- true),
-
- // 4 client ack
- new RecoveringReceiver(rsess9,
- cons9,
- JMSStressTestBase.NUM_NON_PERSISTENT_MESSAGES + JMSStressTestBase.NUM_PERSISTENT_MESSAGES +
- JMSStressTestBase.NUM_NON_PERSISTENT_PRESEND +
- JMSStressTestBase.NUM_PERSISTENT_PRESEND,
- 1,
- 1,
- false),
- new RecoveringReceiver(rsess10,
- cons10,
- JMSStressTestBase.NUM_NON_PERSISTENT_MESSAGES + JMSStressTestBase.NUM_PERSISTENT_MESSAGES +
- JMSStressTestBase.NUM_NON_PERSISTENT_PRESEND +
- JMSStressTestBase.NUM_PERSISTENT_PRESEND,
- 10,
- 7,
- true),
- new RecoveringReceiver(rsess11,
- cons11,
- JMSStressTestBase.NUM_NON_PERSISTENT_MESSAGES + JMSStressTestBase.NUM_PERSISTENT_MESSAGES +
- JMSStressTestBase.NUM_NON_PERSISTENT_PRESEND +
- JMSStressTestBase.NUM_PERSISTENT_PRESEND,
- 50,
- 21,
- false),
- new RecoveringReceiver(rsess12,
- cons12,
- JMSStressTestBase.NUM_NON_PERSISTENT_MESSAGES + JMSStressTestBase.NUM_PERSISTENT_MESSAGES +
- JMSStressTestBase.NUM_NON_PERSISTENT_PRESEND +
- JMSStressTestBase.NUM_PERSISTENT_PRESEND,
- 100,
- 67,
- true),
-
- // 4 transactional
-
- new TransactionalReceiver(rsess13,
- cons13,
- JMSStressTestBase.NUM_NON_PERSISTENT_MESSAGES + JMSStressTestBase.NUM_PERSISTENT_MESSAGES +
- JMSStressTestBase.NUM_NON_PERSISTENT_PRESEND +
- JMSStressTestBase.NUM_PERSISTENT_PRESEND,
- 1,
- 1,
- false),
- new TransactionalReceiver(rsess14,
- cons14,
- JMSStressTestBase.NUM_NON_PERSISTENT_MESSAGES + JMSStressTestBase.NUM_PERSISTENT_MESSAGES +
- JMSStressTestBase.NUM_NON_PERSISTENT_PRESEND +
- JMSStressTestBase.NUM_PERSISTENT_PRESEND,
- 10,
- 7,
- true),
- new TransactionalReceiver(rsess15,
- cons15,
- JMSStressTestBase.NUM_NON_PERSISTENT_MESSAGES + JMSStressTestBase.NUM_PERSISTENT_MESSAGES +
- JMSStressTestBase.NUM_NON_PERSISTENT_PRESEND +
- JMSStressTestBase.NUM_PERSISTENT_PRESEND,
- 50,
- 21,
- false),
- new TransactionalReceiver(rsess16,
- cons16,
- JMSStressTestBase.NUM_NON_PERSISTENT_MESSAGES + JMSStressTestBase.NUM_PERSISTENT_MESSAGES +
- JMSStressTestBase.NUM_NON_PERSISTENT_PRESEND +
- JMSStressTestBase.NUM_PERSISTENT_PRESEND,
- 100,
- 67,
- true),
-
- // 4 2pc transactional
- new Transactional2PCReceiver(rxaSess1,
- cons17,
- JMSStressTestBase.NUM_NON_PERSISTENT_MESSAGES + JMSStressTestBase.NUM_PERSISTENT_MESSAGES +
- JMSStressTestBase.NUM_NON_PERSISTENT_PRESEND +
- JMSStressTestBase.NUM_PERSISTENT_PRESEND,
- 1,
- 1,
- false),
- new Transactional2PCReceiver(rxaSess2,
- cons18,
- JMSStressTestBase.NUM_NON_PERSISTENT_MESSAGES + JMSStressTestBase.NUM_PERSISTENT_MESSAGES +
- JMSStressTestBase.NUM_NON_PERSISTENT_PRESEND +
- JMSStressTestBase.NUM_PERSISTENT_PRESEND,
- 10,
- 7,
- true),
- new Transactional2PCReceiver(rxaSess3,
- cons19,
- JMSStressTestBase.NUM_NON_PERSISTENT_MESSAGES + JMSStressTestBase.NUM_PERSISTENT_MESSAGES +
- JMSStressTestBase.NUM_NON_PERSISTENT_PRESEND +
- JMSStressTestBase.NUM_PERSISTENT_PRESEND,
- 50,
- 21,
- false),
- new Transactional2PCReceiver(rxaSess4,
- cons20,
- JMSStressTestBase.NUM_NON_PERSISTENT_MESSAGES + JMSStressTestBase.NUM_PERSISTENT_MESSAGES +
- JMSStressTestBase.NUM_NON_PERSISTENT_PRESEND +
- JMSStressTestBase.NUM_PERSISTENT_PRESEND,
- 100,
- 67,
- true),
-
- new Sender("prod3", sess1, prod1, JMSStressTestBase.NUM_NON_PERSISTENT_MESSAGES),
- new Sender("prod4", sess2, prod2, JMSStressTestBase.NUM_PERSISTENT_MESSAGES)};
-
- runRunners(runners);
-
- conn1.close();
-
- conn2.close();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/Transactional2PCReceiver.java
----------------------------------------------------------------------
diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/Transactional2PCReceiver.java b/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/Transactional2PCReceiver.java
deleted file mode 100644
index 31e611c..0000000
--- a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/Transactional2PCReceiver.java
+++ /dev/null
@@ -1,231 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.jms.tests.stress;
-
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.XASession;
-import javax.transaction.xa.XAResource;
-
-import org.apache.activemq.core.transaction.impl.XidImpl;
-import org.apache.activemq.jms.tests.JmsTestLogger;
-import org.apache.activemq.utils.UUIDGenerator;
-
-/**
- *
- * A receiver that receives messages in a XA transaction
- *
- * Receives <commitSize> messages then prepares, commits, then
- * Receives <rollbackSize> messages then prepares, rollsback until
- * a total of <numMessages> messages have been received (committed)
- * <numMessages> must be a multiple of <commitSize>
- *
- * @author <a href="tim.fox@jboss.com">Tim Fox</a>
- *
- */
-public class Transactional2PCReceiver extends Receiver
-{
- private static final JmsTestLogger log = JmsTestLogger.LOGGER;
-
- protected int commitSize;
-
- protected int rollbackSize;
-
- protected XAResource xaResource;
-
- class Count
- {
- int lastCommitted;
-
- int lastReceived;
- }
-
- public Transactional2PCReceiver(final XASession sess,
- final MessageConsumer cons,
- final int numMessages,
- final int commitSize,
- final int rollbackSize,
- final boolean isListener) throws Exception
- {
- super(sess, cons, numMessages, isListener);
- this.commitSize = commitSize;
- this.rollbackSize = rollbackSize;
- xaResource = sess.getXAResource();
- }
-
- @Override
- public void run()
- {
- // Small pause so as not to miss any messages in a topic
- try
- {
- Thread.sleep(1000);
- }
- catch (InterruptedException e)
- {
- }
-
- try
- {
- int iterations = numMessages / commitSize;
-
- XidImpl xid = null;
-
- xid = new XidImpl("bq1".getBytes(), 1, UUIDGenerator.getInstance().generateStringUUID().getBytes());
- xaResource.start(xid, XAResource.TMNOFLAGS);
-
- for (int outerCount = 0; outerCount < iterations; outerCount++)
- {
-
- for (int innerCount = 0; innerCount < commitSize; innerCount++)
- {
- Message m = getMessage();
-
- if (m == null)
- {
- Transactional2PCReceiver.log.error("Message is null");
- setFailed(true);
- return;
- }
- String prodName = m.getStringProperty("PROD_NAME");
- Integer msgCount = new Integer(m.getIntProperty("MSG_NUMBER"));
-
- Count count = (Count)counts.get(prodName);
- if (count == null)
- {
- // First time
- if (msgCount.intValue() != 0)
- {
- Transactional2PCReceiver.log.error("First message from " + prodName +
- " is not 0, it is " +
- msgCount);
- setFailed(true);
- return;
- }
- else
- {
- count = new Count();
- counts.put(prodName, count);
- }
- }
- else
- {
- if (count.lastCommitted != msgCount.intValue() - 1)
- {
- Transactional2PCReceiver.log.error("Message out of sequence for " + prodName +
- ", expected " +
- (count.lastCommitted + 1) +
- ", actual " +
- msgCount);
- setFailed(true);
- return;
- }
- }
- count.lastCommitted = msgCount.intValue();
-
- count.lastReceived = msgCount.intValue();
-
- if (innerCount == commitSize - 1)
- {
- xaResource.end(xid, XAResource.TMSUCCESS);
- xaResource.prepare(xid);
- xaResource.commit(xid, false);
-
- // Starting new tx
- xid = new XidImpl("bq1".getBytes(), 1, UUIDGenerator.getInstance().generateStringUUID().getBytes());
- xaResource.start(xid, XAResource.TMNOFLAGS);
-
- }
-
- processingDone();
- }
-
- if (outerCount == iterations - 1)
- {
- break;
- }
-
- for (int innerCount = 0; innerCount < rollbackSize; innerCount++)
- {
- Message m = getMessage();
-
- if (m == null)
- {
- Transactional2PCReceiver.log.error("Message is null (rollback)");
- setFailed(true);
- return;
- }
- String prodName = m.getStringProperty("PROD_NAME");
- Integer msgCount = new Integer(m.getIntProperty("MSG_NUMBER"));
-
- Count count = (Count)counts.get(prodName);
- if (count == null)
- {
- // First time
- if (msgCount.intValue() != 0)
- {
- Transactional2PCReceiver.log.error("First message from " + prodName +
- " is not 0, it is " +
- msgCount);
- setFailed(true);
- return;
- }
- else
- {
- count = new Count();
- count.lastCommitted = -1;
- counts.put(prodName, count);
- }
- }
- else
- {
- if (count.lastReceived != msgCount.intValue() - 1)
- {
- Transactional2PCReceiver.log.error("Message out of sequence");
- setFailed(true);
- return;
- }
- }
- count.lastReceived = msgCount.intValue();
-
- if (innerCount == rollbackSize - 1)
- {
- xaResource.end(xid, XAResource.TMSUCCESS);
- xaResource.prepare(xid);
- xaResource.rollback(xid);
-
- xid = new XidImpl("bq1".getBytes(), 1, UUIDGenerator.getInstance().generateStringUUID().getBytes());
- xaResource.start(xid, XAResource.TMNOFLAGS);
- }
- processingDone();
- }
- }
-
- xaResource.end(xid, XAResource.TMSUCCESS);
- xaResource.prepare(xid);
- xaResource.commit(xid, false);
-
- finished();
-
- }
- catch (Exception e)
- {
- Transactional2PCReceiver.log.error("Failed to receive message", e);
- setFailed(true);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/Transactional2PCSender.java
----------------------------------------------------------------------
diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/Transactional2PCSender.java b/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/Transactional2PCSender.java
deleted file mode 100644
index e1e1880..0000000
--- a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/Transactional2PCSender.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.jms.tests.stress;
-
-import javax.jms.Message;
-import javax.jms.MessageProducer;
-import javax.jms.XASession;
-import javax.transaction.xa.XAResource;
-
-import org.apache.activemq.core.transaction.impl.XidImpl;
-import org.apache.activemq.jms.tests.JmsTestLogger;
-import org.apache.activemq.utils.UUIDGenerator;
-
-/**
- *
- * A Sender that sends messages to a destination in an XA transaction
- *
- * Sends messages to a destination in a jms transaction.
- * Sends <commitSize> messages then prepares, commits, then
- * sends <rollbackSize> messages then prepares, rollsback until
- * a total of <numMessages> messages have been sent (commitSize)
- * <nuMessages> must be a multiple of <commitSize>
- *
- * @author <a href="tim.fox@jboss.com">Tim Fox</a>
- *
- */
-public class Transactional2PCSender extends Sender
-{
- private static final JmsTestLogger log = JmsTestLogger.LOGGER;
-
- protected int commitSize;
-
- protected int rollbackSize;
-
- protected XAResource xaResource;
-
- public Transactional2PCSender(final String prodName,
- final XASession sess,
- final MessageProducer prod,
- final int numMessages,
- final int commitSize,
- final int rollbackSize)
- {
- super(prodName, sess, prod, numMessages);
-
- this.commitSize = commitSize;
- this.rollbackSize = rollbackSize;
- xaResource = sess.getXAResource();
- }
-
- @Override
- public void run()
- {
-
- int iterations = numMessages / commitSize;
-
- try
- {
- for (int outerCount = 0; outerCount < iterations; outerCount++)
- {
- XidImpl xid = null;
- if (commitSize > 0)
- {
- xid = new XidImpl("bq1".getBytes(), 1, UUIDGenerator.getInstance().generateStringUUID().getBytes());
- xaResource.start(xid, XAResource.TMNOFLAGS);
- }
- for (int innerCount = 0; innerCount < commitSize; innerCount++)
- {
- Message m = sess.createMessage();
- m.setStringProperty("PROD_NAME", prodName);
- m.setIntProperty("MSG_NUMBER", outerCount * commitSize + innerCount);
- prod.send(m);
- }
- if (commitSize > 0)
- {
- xaResource.end(xid, XAResource.TMSUCCESS);
- xaResource.prepare(xid);
- xaResource.commit(xid, false);
- }
- if (rollbackSize > 0)
- {
- xid = new XidImpl("bq1".getBytes(), 1, UUIDGenerator.getInstance().generateStringUUID().getBytes());
- xaResource.start(xid, XAResource.TMNOFLAGS);
- }
- for (int innerCount = 0; innerCount < rollbackSize; innerCount++)
- {
- Message m = sess.createMessage();
- m.setStringProperty("PROD_NAME", prodName);
- m.setIntProperty("MSG_NUMBER", (outerCount + 1) * commitSize + innerCount);
- prod.send(m);
- }
- if (rollbackSize > 0)
- {
- xaResource.end(xid, XAResource.TMSUCCESS);
- xaResource.prepare(xid);
- xaResource.rollback(xid);
- }
- }
- }
- catch (Exception e)
- {
- Transactional2PCSender.log.error("Failed to send message", e);
- setFailed(true);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/TransactionalReceiver.java
----------------------------------------------------------------------
diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/TransactionalReceiver.java b/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/TransactionalReceiver.java
deleted file mode 100644
index 90617c5..0000000
--- a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/TransactionalReceiver.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.jms.tests.stress;
-
-import org.apache.activemq.jms.tests.JmsTestLogger;
-
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.Session;
-
-/**
- *
- * A Receiver that receives messages from a destination in a JMS transaction
- *
- * Receives <commitSize> messages then commits, then
- * Receives <rollbackSize> messages then rollsback until
- * a total of <numMessages> messages have been received (committed)
- * <nuMessages> must be a multiple of <commitSize>
- *
- * @author <a href="tim.fox@jboss.com">Tim Fox</a>
- *
- */
-public class TransactionalReceiver extends Receiver
-{
- private static final JmsTestLogger log = JmsTestLogger.LOGGER;
-
- protected int commitSize;
-
- protected int rollbackSize;
-
- class Count
- {
- int lastCommitted;
-
- int lastReceived;
- }
-
- public TransactionalReceiver(final Session sess,
- final MessageConsumer cons,
- final int numMessages,
- final int commitSize,
- final int rollbackSize,
- final boolean isListener) throws Exception
- {
- super(sess, cons, numMessages, isListener);
- this.commitSize = commitSize;
- this.rollbackSize = rollbackSize;
- }
-
- @Override
- public void run()
- {
- // Small pause so as not to miss any messages in a topic
- try
- {
- Thread.sleep(1000);
- }
- catch (InterruptedException e)
- {
- }
-
- try
- {
- int iterations = numMessages / commitSize;
-
- for (int outerCount = 0; outerCount < iterations; outerCount++)
- {
- for (int innerCount = 0; innerCount < commitSize; innerCount++)
- {
- Message m = getMessage();
-
- if (m == null)
- {
- TransactionalReceiver.log.error("Message is null");
- setFailed(true);
- return;
- }
- String prodName = m.getStringProperty("PROD_NAME");
- Integer msgCount = new Integer(m.getIntProperty("MSG_NUMBER"));
-
- Count count = (Count)counts.get(prodName);
- if (count == null)
- {
- // First time
- if (msgCount.intValue() != 0)
- {
- TransactionalReceiver.log.error("First message from " + prodName + " is not 0, it is " + msgCount);
- setFailed(true);
- return;
- }
- else
- {
- count = new Count();
- counts.put(prodName, count);
- }
- }
- else
- {
- if (count.lastCommitted != msgCount.intValue() - 1)
- {
- TransactionalReceiver.log.error("Message out of sequence for " + m.getJMSMessageID() +
- " " +
- prodName +
- ", expected " +
- (count.lastCommitted + 1) +
- ", actual " +
- msgCount);
- setFailed(true);
- return;
- }
- }
- count.lastCommitted = msgCount.intValue();
-
- count.lastReceived = msgCount.intValue();
-
- if (innerCount == commitSize - 1)
- {
- sess.commit();
- }
-
- processingDone();
- }
-
- if (outerCount == iterations - 1)
- {
- break;
- }
-
- for (int innerCount = 0; innerCount < rollbackSize; innerCount++)
- {
- Message m = getMessage();
-
- if (m == null)
- {
- TransactionalReceiver.log.error("Message is null");
- setFailed(true);
- return;
- }
- String prodName = m.getStringProperty("PROD_NAME");
- Integer msgCount = new Integer(m.getIntProperty("MSG_NUMBER"));
-
- Count count = (Count)counts.get(prodName);
- if (count == null)
- {
- // First time
- if (msgCount.intValue() != 0)
- {
- TransactionalReceiver.log.error("First message from " + prodName + " is not 0, it is " + msgCount);
- setFailed(true);
- return;
- }
- else
- {
- count = new Count();
- count.lastCommitted = -1;
- counts.put(prodName, count);
- }
- }
- else
- {
- if (count.lastReceived != msgCount.intValue() - 1)
- {
- TransactionalReceiver.log.error("Message out of sequence");
- setFailed(true);
- return;
- }
- }
- count.lastReceived = msgCount.intValue();
-
- if (innerCount == rollbackSize - 1 && outerCount != iterations - 1)
- {
- // Don't roll back on the very last one
- sess.rollback();
- }
- processingDone();
- }
- }
- finished();
- }
- catch (Exception e)
- {
- TransactionalReceiver.log.error("Failed to receive message", e);
- setFailed(true);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/TransactionalSender.java
----------------------------------------------------------------------
diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/TransactionalSender.java b/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/TransactionalSender.java
deleted file mode 100644
index 4c19344..0000000
--- a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/TransactionalSender.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.jms.tests.stress;
-
-import org.apache.activemq.jms.tests.JmsTestLogger;
-
-import javax.jms.Message;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-/**
- *
- * A Sender that sends messages to a destination in a JMS transaction.
- *
- * Sends messages to a destination in a jms transaction.
- * Sends <commitSize> messages then commits, then
- * sends <rollbackSize> messages then rollsback until
- * a total of <numMessages> messages have been sent (commitSize)
- * <numMessages> must be a multiple of <commitSize>
- *
- * @author <a href="tim.fox@jboss.com">Tim Fox</a>
- *
- */
-public class TransactionalSender extends Sender
-{
- private static final JmsTestLogger log = JmsTestLogger.LOGGER;
-
- protected int commitSize;
-
- protected int rollbackSize;
-
- public TransactionalSender(final String prodName,
- final Session sess,
- final MessageProducer prod,
- final int numMessages,
- final int commitSize,
- final int rollbackSize)
- {
- super(prodName, sess, prod, numMessages);
-
- this.commitSize = commitSize;
- this.rollbackSize = rollbackSize;
-
- }
-
- @Override
- public void run()
- {
- int iterations = numMessages / commitSize;
-
- try
- {
- for (int outerCount = 0; outerCount < iterations; outerCount++)
- {
- for (int innerCount = 0; innerCount < commitSize; innerCount++)
- {
- Message m = sess.createMessage();
- m.setStringProperty("PROD_NAME", prodName);
- m.setIntProperty("MSG_NUMBER", outerCount * commitSize + innerCount);
- prod.send(m);
- }
- sess.commit();
- for (int innerCount = 0; innerCount < rollbackSize; innerCount++)
- {
- Message m = sess.createMessage();
- m.setStringProperty("PROD_NAME", prodName);
- m.setIntProperty("MSG_NUMBER", (outerCount + 1) * commitSize + innerCount);
- prod.send(m);
- }
- sess.rollback();
- }
- }
- catch (Exception e)
- {
- TransactionalSender.log.error("Failed to send message", e);
- setFailed(true);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/pom.xml
----------------------------------------------------------------------
diff --git a/tests/pom.xml b/tests/pom.xml
index 0686523..f2db04d 100644
--- a/tests/pom.xml
+++ b/tests/pom.xml
@@ -77,15 +77,9 @@
<profiles>
<profile>
- <id>banned-tests</id>
+ <id>extra-tests</id>
<modules>
- <module>jms-tests</module>
- <module>integration-tests</module>
- <module>byteman-tests</module>
- <module>soak-tests</module>
- <module>stress-tests</module>
- <module>concurrent-tests</module>
- <module>performance-tests</module>
+ <module>extra-tests</module>
</modules>
</profile>
</profiles>
@@ -94,5 +88,10 @@
<module>unit-tests</module>
<module>joram-tests</module>
<module>timing-tests</module>
+ <module>jms-tests</module>
+ <module>integration-tests</module>
+ <module>soak-tests</module>
+ <module>stress-tests</module>
+ <module>performance-tests</module>
</modules>
</project>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/timing-tests/src/test/java/org/apache/activemq/tests/timing/core/server/impl/QueueConcurrentTest.java
----------------------------------------------------------------------
diff --git a/tests/timing-tests/src/test/java/org/apache/activemq/tests/timing/core/server/impl/QueueConcurrentTest.java b/tests/timing-tests/src/test/java/org/apache/activemq/tests/timing/core/server/impl/QueueConcurrentTest.java
new file mode 100644
index 0000000..740d9b8
--- /dev/null
+++ b/tests/timing-tests/src/test/java/org/apache/activemq/tests/timing/core/server/impl/QueueConcurrentTest.java
@@ -0,0 +1,231 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.tests.timing.core.server.impl;
+import org.junit.Before;
+import org.junit.After;
+
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.activemq.api.core.SimpleString;
+import org.apache.activemq.core.server.HandleStatus;
+import org.apache.activemq.core.server.MessageReference;
+import org.apache.activemq.core.server.Queue;
+import org.apache.activemq.core.server.ServerMessage;
+import org.apache.activemq.core.server.impl.QueueImpl;
+import org.apache.activemq.tests.unit.UnitTestLogger;
+import org.apache.activemq.tests.unit.core.server.impl.fakes.FakeConsumer;
+import org.apache.activemq.tests.unit.core.server.impl.fakes.FakeQueueFactory;
+import org.apache.activemq.tests.util.UnitTestCase;
+
+/**
+ *
+ * A concurrent QueueTest
+ *
+ * All the concurrent queue tests go in here
+ *
+ * @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
+ *
+ */
+public class QueueConcurrentTest extends UnitTestCase
+{
+ private static final UnitTestLogger log = UnitTestLogger.LOGGER;
+
+ private FakeQueueFactory queueFactory = new FakeQueueFactory();
+
+ @Override
+ @Before
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ queueFactory = new FakeQueueFactory();
+ }
+
+ @Override
+ @After
+ public void tearDown() throws Exception
+ {
+ queueFactory.stop();
+ super.tearDown();
+ }
+
+ /*
+ * Concurrent set consumer not busy, busy then, call deliver while messages are being added and consumed
+ */
+ @Test
+ public void testConcurrentAddsDeliver() throws Exception
+ {
+ QueueImpl queue = (QueueImpl)queueFactory.createQueue(1,
+ new SimpleString("address1"),
+ new SimpleString("queue1"),
+ null,
+ null,
+ false,
+ false,
+ false);
+
+ FakeConsumer consumer = new FakeConsumer();
+
+ queue.addConsumer(consumer);
+
+ final long testTime = 5000;
+
+ Sender sender = new Sender(queue, testTime);
+
+ Toggler toggler = new Toggler(queue, consumer, testTime);
+
+ sender.start();
+
+ toggler.start();
+
+ sender.join();
+
+ toggler.join();
+
+ consumer.setStatusImmediate(HandleStatus.HANDLED);
+
+ queue.deliverNow();
+
+ if (sender.getException() != null)
+ {
+ throw sender.getException();
+ }
+
+ if (toggler.getException() != null)
+ {
+ throw toggler.getException();
+ }
+
+ assertRefListsIdenticalRefs(sender.getReferences(), consumer.getReferences());
+
+ QueueConcurrentTest.log.info("num refs: " + sender.getReferences().size());
+
+ QueueConcurrentTest.log.info("num toggles: " + toggler.getNumToggles());
+
+ }
+
+ // Inner classes ---------------------------------------------------------------
+
+ class Sender extends Thread
+ {
+ private volatile Exception e;
+
+ private final Queue queue;
+
+ private final long testTime;
+
+ private volatile int i;
+
+ public Exception getException()
+ {
+ return e;
+ }
+
+ private final List<MessageReference> refs = new ArrayList<MessageReference>();
+
+ public List<MessageReference> getReferences()
+ {
+ return refs;
+ }
+
+ Sender(final Queue queue, final long testTime)
+ {
+ this.testTime = testTime;
+
+ this.queue = queue;
+ }
+
+ @Override
+ public void run()
+ {
+ long start = System.currentTimeMillis();
+
+ while (System.currentTimeMillis() - start < testTime)
+ {
+ ServerMessage message = generateMessage(i);
+
+ MessageReference ref = message.createReference(queue);
+
+ queue.addTail(ref, false);
+
+ refs.add(ref);
+
+ i++;
+ }
+ }
+ }
+
+ class Toggler extends Thread
+ {
+ private volatile Exception e;
+
+ private final QueueImpl queue;
+
+ private final FakeConsumer consumer;
+
+ private final long testTime;
+
+ private boolean toggle;
+
+ private volatile int numToggles;
+
+ public int getNumToggles()
+ {
+ return numToggles;
+ }
+
+ public Exception getException()
+ {
+ return e;
+ }
+
+ Toggler(final QueueImpl queue, final FakeConsumer consumer, final long testTime)
+ {
+ this.testTime = testTime;
+
+ this.queue = queue;
+
+ this.consumer = consumer;
+ }
+
+ @Override
+ public void run()
+ {
+ long start = System.currentTimeMillis();
+
+ while (System.currentTimeMillis() - start < testTime)
+ {
+ if (toggle)
+ {
+ consumer.setStatusImmediate(HandleStatus.BUSY);
+ }
+ else
+ {
+ consumer.setStatusImmediate(HandleStatus.HANDLED);
+
+ queue.deliverNow();
+ }
+ toggle = !toggle;
+
+ numToggles++;
+ }
+ }
+ }
+
+}
[03/15] activemq-6 git commit: Refactored the testsuite a bit
Posted by jb...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/ManyConnectionsStressTest.java
----------------------------------------------------------------------
diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/ManyConnectionsStressTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/ManyConnectionsStressTest.java
deleted file mode 100644
index a53f174..0000000
--- a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/ManyConnectionsStressTest.java
+++ /dev/null
@@ -1,218 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.jms.tests.stress;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.jms.Topic;
-import javax.naming.InitialContext;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.apache.activemq.jms.tests.ActiveMQServerTestCase;
-import org.apache.activemq.jms.tests.util.ProxyAssertSupport;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- * Create 500 connections each with a consumer, consuming from a topic
- *
- * @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
- */
-public class ManyConnectionsStressTest extends ActiveMQServerTestCase
-{
- @BeforeClass
- public static void stressTestsEnabled()
- {
- org.junit.Assume.assumeTrue(JMSStressTestBase.STRESS_TESTS_ENABLED);
- }
-
- private static final int NUM_CONNECTIONS = 500;
-
- private static final int NUM_MESSAGES = 100;
-
- // Static --------------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- private InitialContext ic;
-
- private volatile boolean failed;
-
- private final Set<MyListener> listeners = new HashSet<MyListener>();
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- @Override
- @Before
- public void setUp() throws Exception
- {
- super.setUp();
-
- // ServerManagement.start("all");
-
- ic = getInitialContext();
-
- createTopic("StressTestTopic");
- }
-
- @Override
- @After
- public void tearDown() throws Exception
- {
- destroyTopic("StressTestTopic");
- ic.close();
- super.tearDown();
- }
-
- @Test
- public void testManyConnections() throws Exception
- {
- ConnectionFactory cf = (ConnectionFactory) ic.lookup("/ConnectionFactory");
-
- Topic topic = (Topic) ic.lookup("/topic/StressTestTopic");
-
- Connection[] conns = new Connection[ManyConnectionsStressTest.NUM_CONNECTIONS];
-
- for (int i = 0; i < ManyConnectionsStressTest.NUM_CONNECTIONS; i++)
- {
- conns[i] = addConnection(cf.createConnection());
-
- Session sess = conns[i].createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageConsumer cons = sess.createConsumer(topic);
-
- MyListener listener = new MyListener();
-
- synchronized (listeners)
- {
- listeners.add(listener);
- }
-
- cons.setMessageListener(listener);
-
- conns[i].start();
-
- log.info("Created " + i);
- }
-
- // Thread.sleep(100 * 60 * 1000);
-
- Connection connSend = addConnection(cf.createConnection());
-
- Session sessSend = connSend.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageProducer prod = sessSend.createProducer(topic);
-
- for (int i = 0; i < ManyConnectionsStressTest.NUM_MESSAGES; i++)
- {
- TextMessage tm = sessSend.createTextMessage("message" + i);
-
- tm.setIntProperty("count", i);
-
- prod.send(tm);
- }
-
- long wait = 30000;
-
- synchronized (listeners)
- {
- while (!listeners.isEmpty() && wait > 0)
- {
- long start = System.currentTimeMillis();
- try
- {
- listeners.wait(wait);
- }
- catch (InterruptedException e)
- {
- // Ignore
- }
- wait -= System.currentTimeMillis() - start;
- }
- }
-
- if (wait <= 0)
- {
- ProxyAssertSupport.fail("Timed out");
- }
-
- ProxyAssertSupport.assertFalse(failed);
- }
-
- private void finished(final MyListener listener)
- {
- synchronized (listeners)
- {
- log.info("consumer " + listener + " has finished");
-
- listeners.remove(listener);
-
- listeners.notify();
- }
- }
-
- private void failed(final MyListener listener)
- {
- synchronized (listeners)
- {
- log.error("consumer " + listener + " has failed");
-
- listeners.remove(listener);
-
- failed = true;
-
- listeners.notify();
- }
- }
-
- private final class MyListener implements MessageListener
- {
- public void onMessage(final Message msg)
- {
- try
- {
- int count = msg.getIntProperty("count");
-
- // log.info(this + " got message " + msg);
-
- if (count == ManyConnectionsStressTest.NUM_MESSAGES - 1)
- {
- finished(this);
- }
- }
- catch (JMSException e)
- {
- log.error("Failed to get int property", e);
-
- failed(this);
- }
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/OpenCloseStressTest.java
----------------------------------------------------------------------
diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/OpenCloseStressTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/OpenCloseStressTest.java
deleted file mode 100644
index 29d5f8f..0000000
--- a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/OpenCloseStressTest.java
+++ /dev/null
@@ -1,445 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.jms.tests.stress;
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.DeliveryMode;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.jms.Topic;
-import javax.naming.InitialContext;
-
-import org.apache.activemq.jms.tests.ActiveMQServerTestCase;
-import org.apache.activemq.jms.tests.util.ProxyAssertSupport;
-import org.apache.activemq.utils.UUIDGenerator;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- * A OpenCloseStressTest.
- * <p>
- * This stress test starts several publisher connections and several subscriber connections, then
- * sends and consumes messages while concurrently closing the sessions.
- * <p>
- * This test will help catch race conditions that occurred with rapid open/closing of sessions when
- * messages are being sent/received
- * <p>
- * E.g. http://jira.jboss.com/jira/browse/JBMESSAGING-982
- * @author <a href="tim.fox@jboss.com">Tim Fox</a>
- */
-public class OpenCloseStressTest extends ActiveMQServerTestCase
-{
- @BeforeClass
- public static void stressTestsEnabled()
- {
- org.junit.Assume.assumeTrue(JMSStressTestBase.STRESS_TESTS_ENABLED);
- }
-
- InitialContext ic;
-
- ConnectionFactory cf;
-
- Topic topic;
-
- @Override
- @Before
- public void setUp() throws Exception
- {
- super.setUp();
-
- // ServerManagement.start("all");
-
- ic = getInitialContext();
- cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
-
- destroyTopic("TestTopic");
- createTopic("TestTopic");
-
- topic = (Topic)ic.lookup("topic/TestTopic");
-
- log.debug("setup done");
- }
-
- @Override
- @After
- public void tearDown() throws Exception
- {
- destroyQueue("TestQueue");
- log.debug("tear down done");
- }
-
- @Test
- public void testOpenClose() throws Exception
- {
- Connection conn1 = null;
- Connection conn2 = null;
- Connection conn3 = null;
-
- Connection conn4 = null;
- Connection conn5 = null;
- Connection conn6 = null;
- Connection conn7 = null;
- Connection conn8 = null;
-
- try
- {
- Publisher[] publishers = new Publisher[3];
-
- final int MSGS_PER_PUBLISHER = 10000;
-
- conn1 = cf.createConnection();
- Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageProducer prod1 = sess1.createProducer(topic);
- prod1.setDeliveryMode(DeliveryMode.PERSISTENT);
- publishers[0] = new Publisher(sess1, prod1, MSGS_PER_PUBLISHER, 2);
-
- conn2 = cf.createConnection();
- Session sess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageProducer prod2 = sess2.createProducer(topic);
- prod2.setDeliveryMode(DeliveryMode.PERSISTENT);
- publishers[1] = new Publisher(sess2, prod2, MSGS_PER_PUBLISHER, 5);
-
- conn3 = cf.createConnection();
- Session sess3 = conn3.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageProducer prod3 = sess3.createProducer(topic);
- prod3.setDeliveryMode(DeliveryMode.PERSISTENT);
- publishers[2] = new Publisher(sess3, prod3, MSGS_PER_PUBLISHER, 1);
-
- Subscriber[] subscribers = new Subscriber[5];
-
- conn4 = cf.createConnection();
- subscribers[0] = new Subscriber(conn4, 3 * MSGS_PER_PUBLISHER, 500, 1000 * 60 * 15, topic, false);
-
- conn5 = cf.createConnection();
- subscribers[1] = new Subscriber(conn5, 3 * MSGS_PER_PUBLISHER, 2000, 1000 * 60 * 15, topic, false);
-
- conn6 = cf.createConnection();
- subscribers[2] = new Subscriber(conn6, 3 * MSGS_PER_PUBLISHER, 700, 1000 * 60 * 15, topic, false);
-
- conn7 = cf.createConnection();
- subscribers[3] = new Subscriber(conn7, 3 * MSGS_PER_PUBLISHER, 1500, 1000 * 60 * 15, topic, true);
-
- conn8 = cf.createConnection();
- subscribers[4] = new Subscriber(conn8, 3 * MSGS_PER_PUBLISHER, 1200, 1000 * 60 * 15, topic, true);
-
- Thread[] threads = new Thread[8];
-
- // subscribers
- threads[0] = new Thread(subscribers[0]);
-
- threads[1] = new Thread(subscribers[1]);
-
- threads[2] = new Thread(subscribers[2]);
-
- threads[3] = new Thread(subscribers[3]);
-
- threads[4] = new Thread(subscribers[4]);
-
- // publishers
-
- threads[5] = new Thread(publishers[0]);
-
- threads[6] = new Thread(publishers[1]);
-
- threads[7] = new Thread(publishers[2]);
-
- for (int i = 0; i < subscribers.length; i++)
- {
- threads[i].start();
- }
-
- // Pause before creating producers otherwise subscribers to make sure they're all created
-
- Thread.sleep(5000);
-
- for (int i = subscribers.length; i < threads.length; i++)
- {
- threads[i].start();
- }
-
- for (Thread thread : threads)
- {
- thread.join();
- }
-
- for (Subscriber subscriber : subscribers)
- {
- if (subscriber.isDurable())
- {
- ProxyAssertSupport.assertEquals(3 * MSGS_PER_PUBLISHER, subscriber.getMessagesReceived());
- }
- else
- {
- // Note that for a non durable subscriber the number of messages received in total
- // will be somewhat less than the total number received since when recycling the session
- // there is a period of time after closing the previous session and starting the next one
- // when messages are being sent and won't be received (since there is no consumer)
- }
-
- ProxyAssertSupport.assertFalse(subscriber.isFailed());
- }
-
- for (Publisher publisher : publishers)
- {
- ProxyAssertSupport.assertFalse(publisher.isFailed());
- }
- }
- finally
- {
- if (conn1 != null)
- {
- conn1.close();
- }
- if (conn2 != null)
- {
- conn2.close();
- }
- if (conn3 != null)
- {
- conn3.close();
- }
- if (conn4 != null)
- {
- conn4.close();
- }
- if (conn5 != null)
- {
- conn5.close();
- }
- if (conn6 != null)
- {
- conn6.close();
- }
- if (conn7 != null)
- {
- conn7.close();
- }
- if (conn8 != null)
- {
- conn8.close();
- }
- }
-
- }
-
- class Publisher implements Runnable
- {
- private final Session sess;
-
- private final int numMessages;
-
- private final int delay;
-
- private final MessageProducer prod;
-
- private boolean failed;
-
- boolean isFailed()
- {
- return failed;
- }
-
- Publisher(final Session sess, final MessageProducer prod, final int numMessages, final int delay)
- {
- this.sess = sess;
-
- this.prod = prod;
-
- this.numMessages = numMessages;
-
- this.delay = delay;
- }
-
- public void run()
- {
- try
- {
- for (int i = 0; i < numMessages; i++)
- {
- TextMessage tm = sess.createTextMessage("message" + i);
-
- prod.send(tm);
-
- try
- {
- Thread.sleep(delay);
- }
- catch (Exception ignore)
- {
- }
- }
- }
- catch (JMSException e)
- {
- log.error("Failed to send message", e);
- failed = true;
- }
- }
-
- }
-
- class Subscriber implements Runnable
- {
- private Session sess;
-
- private MessageConsumer cons;
-
- private int msgsReceived;
-
- private final int numMessages;
-
- private final int delay;
-
- private final Connection conn;
-
- private boolean failed;
-
- private final long timeout;
-
- private final Destination dest;
-
- private final boolean durable;
-
- private String subname;
-
- boolean isFailed()
- {
- return failed;
- }
-
- boolean isDurable()
- {
- return durable;
- }
-
- synchronized void msgReceived()
- {
- msgsReceived++;
- }
-
- synchronized int getMessagesReceived()
- {
- return msgsReceived;
- }
-
- class Listener implements MessageListener
- {
-
- public void onMessage(final Message msg)
- {
- msgReceived();
- }
-
- }
-
- Subscriber(final Connection conn,
- final int numMessages,
- final int delay,
- final long timeout,
- final Destination dest,
- final boolean durable) throws Exception
- {
- this.conn = conn;
-
- this.numMessages = numMessages;
-
- this.delay = delay;
-
- this.timeout = timeout;
-
- this.dest = dest;
-
- this.durable = durable;
-
- if (durable)
- {
- conn.setClientID(UUIDGenerator.getInstance().generateStringUUID());
-
- subname = UUIDGenerator.getInstance().generateStringUUID();
- }
- }
-
- public void run()
- {
- try
- {
- long start = System.currentTimeMillis();
-
- while (System.currentTimeMillis() - start < timeout && msgsReceived < numMessages)
- {
- // recycle the session
-
- recycleSession();
-
- Thread.sleep(delay);
- }
-
- // Delete the durable sub
-
- if (durable)
- {
- recycleSession();
-
- cons.close();
-
- sess.unsubscribe(subname);
- }
- }
- catch (Exception e)
- {
- log.error("Failed in subscriber", e);
- failed = true;
- }
-
- }
-
- void recycleSession() throws Exception
- {
- conn.stop();
-
- if (sess != null)
- {
- sess.close();
- }
-
- sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- if (durable)
- {
- cons = sess.createDurableSubscriber((Topic)dest, subname);
- }
- else
- {
- cons = sess.createConsumer(dest);
- }
-
- cons.setMessageListener(new Listener());
-
- conn.start();
- }
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/QueueStressTest.java
----------------------------------------------------------------------
diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/QueueStressTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/QueueStressTest.java
deleted file mode 100644
index 7878859..0000000
--- a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/QueueStressTest.java
+++ /dev/null
@@ -1,271 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.jms.tests.stress;
-
-import javax.jms.Connection;
-import javax.jms.DeliveryMode;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.XAConnection;
-import javax.jms.XASession;
-
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- * A QueueStressTest.
- *
- * @author <a href="tim.fox@jboss.com">Tim Fox</a>
- * @version <tt>$Revision: 2349 $</tt>
- */
-
-public class QueueStressTest extends JMSStressTestBase
-{
- @BeforeClass
- public static void stressTestsEnabled()
- {
- org.junit.Assume.assumeTrue(JMSStressTestBase.STRESS_TESTS_ENABLED);
- }
-
- /*
- * Stress a queue with transational, non transactional and 2pc senders sending both persistent
- * and non persistent messages
- * Transactional senders go through a cycle of sending and rolling back
- *
- */
- @Test
- public void testQueueMultipleSenders() throws Exception
- {
- Connection conn1 = cf.createConnection();
-
- Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Session sess2 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Session sess3 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Session sess4 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Session sess5 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Session sess6 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Session sess7 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Session sess8 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- Session sess9 = conn1.createSession(true, Session.SESSION_TRANSACTED);
- Session sess10 = conn1.createSession(true, Session.SESSION_TRANSACTED);
- Session sess11 = conn1.createSession(true, Session.SESSION_TRANSACTED);
- Session sess12 = conn1.createSession(true, Session.SESSION_TRANSACTED);
- Session sess13 = conn1.createSession(true, Session.SESSION_TRANSACTED);
- Session sess14 = conn1.createSession(true, Session.SESSION_TRANSACTED);
- Session sess15 = conn1.createSession(true, Session.SESSION_TRANSACTED);
- Session sess16 = conn1.createSession(true, Session.SESSION_TRANSACTED);
-
- XASession xaSess1 = ((XAConnection) conn1).createXASession();
- tweakXASession(xaSess1);
- XASession xaSess2 = ((XAConnection) conn1).createXASession();
- tweakXASession(xaSess2);
- XASession xaSess3 = ((XAConnection) conn1).createXASession();
- tweakXASession(xaSess3);
- XASession xaSess4 = ((XAConnection) conn1).createXASession();
- tweakXASession(xaSess4);
- XASession xaSess5 = ((XAConnection) conn1).createXASession();
- tweakXASession(xaSess5);
- XASession xaSess6 = ((XAConnection) conn1).createXASession();
- tweakXASession(xaSess6);
- XASession xaSess7 = ((XAConnection) conn1).createXASession();
- tweakXASession(xaSess7);
- XASession xaSess8 = ((XAConnection) conn1).createXASession();
- tweakXASession(xaSess8);
-
- Session sess17 = xaSess1.getSession();
- Session sess18 = xaSess2.getSession();
- Session sess19 = xaSess3.getSession();
- Session sess20 = xaSess4.getSession();
- Session sess21 = xaSess5.getSession();
- Session sess22 = xaSess6.getSession();
- Session sess23 = xaSess7.getSession();
- Session sess24 = xaSess8.getSession();
-
- MessageProducer prod1 = sess1.createProducer(destinationQueue1);
- prod1.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
- MessageProducer prod2 = sess2.createProducer(destinationQueue1);
- prod2.setDeliveryMode(DeliveryMode.PERSISTENT);
- MessageProducer prod3 = sess3.createProducer(destinationQueue1);
- prod3.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
- MessageProducer prod4 = sess4.createProducer(destinationQueue1);
- prod4.setDeliveryMode(DeliveryMode.PERSISTENT);
- MessageProducer prod5 = sess5.createProducer(destinationQueue1);
- prod5.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
- MessageProducer prod6 = sess6.createProducer(destinationQueue1);
- prod6.setDeliveryMode(DeliveryMode.PERSISTENT);
- MessageProducer prod7 = sess7.createProducer(destinationQueue1);
- prod7.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
- MessageProducer prod8 = sess8.createProducer(destinationQueue1);
- prod8.setDeliveryMode(DeliveryMode.PERSISTENT);
- MessageProducer prod9 = sess9.createProducer(destinationQueue1);
- prod9.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
- MessageProducer prod10 = sess10.createProducer(destinationQueue1);
- prod10.setDeliveryMode(DeliveryMode.PERSISTENT);
- MessageProducer prod11 = sess11.createProducer(destinationQueue1);
- prod11.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
- MessageProducer prod12 = sess12.createProducer(destinationQueue1);
- prod12.setDeliveryMode(DeliveryMode.PERSISTENT);
- MessageProducer prod13 = sess13.createProducer(destinationQueue1);
- prod13.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
- MessageProducer prod14 = sess14.createProducer(destinationQueue1);
- prod14.setDeliveryMode(DeliveryMode.PERSISTENT);
- MessageProducer prod15 = sess15.createProducer(destinationQueue1);
- prod15.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
- MessageProducer prod16 = sess16.createProducer(destinationQueue1);
- prod16.setDeliveryMode(DeliveryMode.PERSISTENT);
- MessageProducer prod17 = sess17.createProducer(destinationQueue1);
- prod17.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
- MessageProducer prod18 = sess18.createProducer(destinationQueue1);
- prod18.setDeliveryMode(DeliveryMode.PERSISTENT);
- MessageProducer prod19 = sess19.createProducer(destinationQueue1);
- prod19.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
- MessageProducer prod20 = sess20.createProducer(destinationQueue1);
- prod20.setDeliveryMode(DeliveryMode.PERSISTENT);
- MessageProducer prod21 = sess21.createProducer(destinationQueue1);
- prod21.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
- MessageProducer prod22 = sess22.createProducer(destinationQueue1);
- prod22.setDeliveryMode(DeliveryMode.PERSISTENT);
- MessageProducer prod23 = sess23.createProducer(destinationQueue1);
- prod23.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
- MessageProducer prod24 = sess24.createProducer(destinationQueue1);
- prod24.setDeliveryMode(DeliveryMode.PERSISTENT);
-
- Connection conn2 = cf.createConnection();
- conn2.start();
- Session sessReceive = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageConsumer cons = sessReceive.createConsumer(destinationQueue1);
-
- Runner[] runners = new Runner[]{
- new Sender("prod1", sess1, prod1, JMSStressTestBase.NUM_NON_PERSISTENT_MESSAGES),
- new Sender("prod2", sess2, prod2, JMSStressTestBase.NUM_PERSISTENT_MESSAGES),
- new Sender("prod3", sess3, prod3, JMSStressTestBase.NUM_NON_PERSISTENT_MESSAGES),
- new Sender("prod4", sess4, prod4, JMSStressTestBase.NUM_PERSISTENT_MESSAGES),
- new Sender("prod5", sess5, prod5, JMSStressTestBase.NUM_NON_PERSISTENT_MESSAGES),
- new Sender("prod6", sess6, prod6, JMSStressTestBase.NUM_PERSISTENT_MESSAGES),
- new Sender("prod7", sess7, prod7, JMSStressTestBase.NUM_NON_PERSISTENT_MESSAGES),
- new Sender("prod8", sess8, prod8, JMSStressTestBase.NUM_PERSISTENT_MESSAGES),
- new TransactionalSender("prod9",
- sess9,
- prod9,
- JMSStressTestBase.NUM_NON_PERSISTENT_MESSAGES,
- 1,
- 1),
- new TransactionalSender("prod10",
- sess10,
- prod10,
- JMSStressTestBase.NUM_PERSISTENT_MESSAGES,
- 1,
- 1),
- new TransactionalSender("prod11",
- sess11,
- prod11,
- JMSStressTestBase.NUM_NON_PERSISTENT_MESSAGES,
- 10,
- 7),
- new TransactionalSender("prod12",
- sess12,
- prod12,
- JMSStressTestBase.NUM_PERSISTENT_MESSAGES,
- 10,
- 7),
- new TransactionalSender("prod13",
- sess13,
- prod13,
- JMSStressTestBase.NUM_NON_PERSISTENT_MESSAGES,
- 50,
- 21),
- new TransactionalSender("prod14",
- sess14,
- prod14,
- JMSStressTestBase.NUM_PERSISTENT_MESSAGES,
- 50,
- 21),
- new TransactionalSender("prod15",
- sess15,
- prod15,
- JMSStressTestBase.NUM_NON_PERSISTENT_MESSAGES,
- 100,
- 67),
- new TransactionalSender("prod16",
- sess16,
- prod16,
- JMSStressTestBase.NUM_PERSISTENT_MESSAGES,
- 100,
- 67),
- new Transactional2PCSender("prod17",
- xaSess1,
- prod17,
- JMSStressTestBase.NUM_NON_PERSISTENT_MESSAGES,
- 1,
- 1),
- new Transactional2PCSender("prod18",
- xaSess2,
- prod18,
- JMSStressTestBase.NUM_PERSISTENT_MESSAGES,
- 1,
- 1),
- new Transactional2PCSender("prod19",
- xaSess3,
- prod19,
- JMSStressTestBase.NUM_NON_PERSISTENT_MESSAGES,
- 10,
- 7),
- new Transactional2PCSender("prod20",
- xaSess4,
- prod20,
- JMSStressTestBase.NUM_PERSISTENT_MESSAGES,
- 10,
- 7),
- new Transactional2PCSender("prod21",
- xaSess5,
- prod21,
- JMSStressTestBase.NUM_NON_PERSISTENT_MESSAGES,
- 50,
- 21),
- new Transactional2PCSender("prod22",
- xaSess6,
- prod22,
- JMSStressTestBase.NUM_PERSISTENT_MESSAGES,
- 50,
- 21),
- new Transactional2PCSender("prod23",
- xaSess7,
- prod23,
- JMSStressTestBase.NUM_NON_PERSISTENT_MESSAGES,
- 100,
- 67),
- new Transactional2PCSender("prod24",
- xaSess8,
- prod24,
- JMSStressTestBase.NUM_PERSISTENT_MESSAGES,
- 100,
- 67),
- new Receiver(sessReceive,
- cons,
- 12 * JMSStressTestBase.NUM_NON_PERSISTENT_MESSAGES + 12 * JMSStressTestBase.NUM_PERSISTENT_MESSAGES,
- false)};
-
- runRunners(runners);
-
- conn1.close();
-
- conn2.close();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/Receiver.java
----------------------------------------------------------------------
diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/Receiver.java b/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/Receiver.java
deleted file mode 100644
index 1a4c6b4..0000000
--- a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/Receiver.java
+++ /dev/null
@@ -1,297 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.jms.tests.stress;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionConsumer;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.ServerSession;
-import javax.jms.ServerSessionPool;
-import javax.jms.Session;
-
-import org.apache.activemq.jms.tests.JmsTestLogger;
-
-/**
- * Receives messages from a destination for stress testing
- * @author <a href="tim.fox@jboss.com">Tim Fox</a>
- */
-public class Receiver extends Runner implements MessageListener
-{
- private static final JmsTestLogger log = JmsTestLogger.LOGGER;
-
- private static final long RECEIVE_TIMEOUT = 120000;
-
- protected MessageConsumer cons;
-
- protected int count;
-
- protected boolean isListener;
-
- protected Map<String, Object> counts = new HashMap<String, Object>();
-
- protected boolean isCC;
-
- protected Connection conn;
-
- protected ConnectionConsumer cc;
-
- private final Object lock1 = new Object();
-
- private final Object lock2 = new Object();
-
- private Message theMessage;
-
- private boolean finished;
-
- public Receiver(final Connection conn, final Session sess, final int numMessages, final Destination dest) throws Exception
- {
- super(sess, numMessages);
-
- isListener = true;
-
- isCC = true;
-
- sess.setMessageListener(this);
-
- cc = conn.createConnectionConsumer(dest, null, new MockServerSessionPool(sess), 10);
-
- }
-
- public Receiver(final Session sess, final MessageConsumer cons, final int numMessages, final boolean isListener) throws Exception
- {
- super(sess, numMessages);
- this.cons = cons;
- this.isListener = isListener;
- if (this.isListener)
- {
- cons.setMessageListener(this);
- }
- }
-
- private boolean done;
-
- public void onMessage(final Message m)
- {
- try
- {
- synchronized (lock1)
- {
- theMessage = m;
-
- lock1.notify();
- }
-
- // Wait for message to be processed
- synchronized (lock2)
- {
- while (!done && !finished)
- {
- lock2.wait();
- }
- done = false;
- }
-
- }
- catch (Exception e)
- {
- Receiver.log.error("Failed to put in channel", e);
- setFailed(true);
- }
- }
-
- protected void finished()
- {
- synchronized (lock2)
- {
- finished = true;
- lock2.notify();
- }
- }
-
- protected Message getMessage() throws Exception
- {
- Message m;
-
- if (isListener)
- {
- synchronized (lock1)
- {
- long start = System.currentTimeMillis();
- long waitTime = Receiver.RECEIVE_TIMEOUT;
- while (theMessage == null && waitTime >= 0)
- {
- lock1.wait(waitTime);
-
- waitTime = Receiver.RECEIVE_TIMEOUT - (System.currentTimeMillis() - start);
- }
- m = theMessage;
- theMessage = null;
- }
- }
- else
- {
- m = cons.receive(Receiver.RECEIVE_TIMEOUT);
- }
-
- return m;
- }
-
- protected void processingDone()
- {
- if (isListener)
- {
- synchronized (lock2)
- {
- done = true;
- lock2.notify();
- }
- }
- }
-
- @Override
- public void run()
- {
-
- // Small pause so as not to miss any messages in a topic
- try
- {
- Thread.sleep(1000);
- }
- catch (InterruptedException e)
- {
- }
-
- try
- {
- String prodName = null;
- Integer msgCount = null;
-
- while (count < numMessages)
- {
- Message m = getMessage();
-
- if (m == null)
- {
- Receiver.log.error("Message is null");
- setFailed(true);
- processingDone();
- return;
- }
-
- prodName = m.getStringProperty("PROD_NAME");
- msgCount = new Integer(m.getIntProperty("MSG_NUMBER"));
-
- // log.info(this + " Got message " + prodName + ":" + msgCount + "M: " + m.getJMSMessageID());
-
- Integer prevCount = (Integer)counts.get(prodName);
- if (prevCount == null)
- {
- if (msgCount.intValue() != 0)
- {
- Receiver.log.error("First message received not zero");
- setFailed(true);
- processingDone();
- return;
- }
- }
- else
- {
- if (prevCount.intValue() != msgCount.intValue() - 1)
- {
- Receiver.log.error("Message out of sequence for " + prodName +
- ", expected:" +
- (prevCount.intValue() + 1) +
- " got " +
- msgCount);
- setFailed(true);
- processingDone();
- return;
- }
- }
- counts.put(prodName, msgCount);
-
- count++;
-
- processingDone();
- }
-
- }
- catch (Exception e)
- {
- Receiver.log.error("Failed to receive message", e);
- setFailed(true);
- }
- finally
- {
- if (cc != null)
- {
- try
- {
- cc.close();
- }
- catch (JMSException e)
- {
- Receiver.log.error("Failed to close connection consumer", e);
- }
- }
- }
- }
-
- static final class MockServerSessionPool implements ServerSessionPool
- {
- private final ServerSession serverSession;
-
- MockServerSessionPool(final Session sess)
- {
- serverSession = new MockServerSession(sess);
- }
-
- public ServerSession getServerSession() throws JMSException
- {
- return serverSession;
- }
- }
-
- static final class MockServerSession implements ServerSession
- {
- Session session;
-
- MockServerSession(final Session sess)
- {
- session = sess;
- }
-
- public Session getSession() throws JMSException
- {
- return session;
- }
-
- public void start() throws JMSException
- {
- session.run();
- }
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/RecoveringReceiver.java
----------------------------------------------------------------------
diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/RecoveringReceiver.java b/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/RecoveringReceiver.java
deleted file mode 100644
index eb2e4ea..0000000
--- a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/RecoveringReceiver.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.jms.tests.stress;
-
-import org.apache.activemq.jms.tests.JmsTestLogger;
-
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.Session;
-
-/**
- *
- * A RecoveringReceiver.
- *
- * A Receiver that receives messages from a destination and alternately
- * acknowledges and recovers the session.
- * Must be used with ack mode CLIENT_ACKNOWLEDGE
- *
- *
- * @author <a href="tim.fox@jboss.com">Tim Fox</a>
- *
- */
-public class RecoveringReceiver extends Receiver
-{
- private static final JmsTestLogger log = JmsTestLogger.LOGGER;
-
- protected int ackSize;
-
- protected int recoverSize;
-
- class Count
- {
- int lastAcked;
-
- int lastReceived;
- }
-
- public RecoveringReceiver(final Session sess,
- final MessageConsumer cons,
- final int numMessages,
- final int ackSize,
- final int recoverSize,
- final boolean isListener) throws Exception
- {
- super(sess, cons, numMessages, isListener);
- this.ackSize = ackSize;
- this.recoverSize = recoverSize;
- }
-
- @Override
- public void run()
- {
- // Small pause so as not to miss any messages in a topic
- try
- {
- Thread.sleep(1000);
- }
- catch (InterruptedException e)
- {
- }
-
- try
- {
- int iterations = numMessages / ackSize;
-
- for (int outerCount = 0; outerCount < iterations; outerCount++)
- {
- Message m = null;
- for (int innerCount = 0; innerCount < ackSize; innerCount++)
- {
- m = getMessage();
-
- if (m == null)
- {
- RecoveringReceiver.log.error("Message is null");
- setFailed(true);
- return;
- }
- String prodName = m.getStringProperty("PROD_NAME");
- Integer msgCount = new Integer(m.getIntProperty("MSG_NUMBER"));
-
- Count count = (Count)counts.get(prodName);
- if (count == null)
- {
- // First time
- if (msgCount.intValue() != 0)
- {
- RecoveringReceiver.log.error("First message from " + prodName + " is not 0, it is " + msgCount);
- setFailed(true);
- return;
- }
- else
- {
- count = new Count();
- counts.put(prodName, count);
- }
- }
- else
- {
- if (count.lastAcked != msgCount.intValue() - 1)
- {
- RecoveringReceiver.log.error("Message out of sequence for " + prodName +
- ", expected " +
- (count.lastAcked + 1));
- setFailed(true);
- return;
- }
- }
- count.lastAcked = msgCount.intValue();
-
- count.lastReceived = msgCount.intValue();
-
- if (innerCount == ackSize - 1)
- {
- m.acknowledge();
- }
- processingDone();
-
- }
-
- if (outerCount == iterations - 1)
- {
- break;
- }
-
- for (int innerCount = 0; innerCount < recoverSize; innerCount++)
- {
- m = getMessage();
-
- if (m == null)
- {
- RecoveringReceiver.log.error("Message is null");
- return;
- }
- String prodName = m.getStringProperty("PROD_NAME");
- Integer msgCount = new Integer(m.getIntProperty("MSG_NUMBER"));
-
- Count count = (Count)counts.get(prodName);
- if (count == null)
- {
- // First time
- if (msgCount.intValue() != 0)
- {
- RecoveringReceiver.log.error("First message from " + prodName + " is not 0, it is " + msgCount);
- setFailed(true);
- return;
- }
- else
- {
- count = new Count();
- count.lastAcked = -1;
- counts.put(prodName, count);
- }
- }
- else
- {
- if (count.lastReceived != msgCount.intValue() - 1)
- {
- RecoveringReceiver.log.error("Message out of sequence");
- setFailed(true);
- return;
- }
- }
- count.lastReceived = msgCount.intValue();
-
- if (innerCount == recoverSize - 1)
- {
- sess.recover();
- }
- processingDone();
- }
- }
- }
- catch (Exception e)
- {
- RecoveringReceiver.log.error("Failed to receive message", e);
- setFailed(true);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/RelayStressTest.java
----------------------------------------------------------------------
diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/RelayStressTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/RelayStressTest.java
deleted file mode 100644
index 04cd830..0000000
--- a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/RelayStressTest.java
+++ /dev/null
@@ -1,256 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.jms.tests.stress;
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.DeliveryMode;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.Topic;
-import javax.naming.InitialContext;
-
-import org.apache.activemq.jms.tests.ActiveMQServerTestCase;
-import org.apache.activemq.jms.tests.JmsTestLogger;
-import org.apache.activemq.jms.tests.util.ProxyAssertSupport;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- * Send messages to a topic with selector1, consumer them with multiple consumers and relay them
- * back to the topic with a different selector, then consume that with more consumers.
- *
- * @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
- *
- *
- */
-public class RelayStressTest extends ActiveMQServerTestCase
-{
- @BeforeClass
- public static void stressTestsEnabled()
- {
- org.junit.Assume.assumeTrue(JMSStressTestBase.STRESS_TESTS_ENABLED);
- }
-
- // Constants -----------------------------------------------------
-
- private static JmsTestLogger log = JmsTestLogger.LOGGER;
-
- // Static --------------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- private InitialContext ic;
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- @Override
- @Before
- public void setUp() throws Exception
- {
- super.setUp();
-
- // ServerManagement.start("all");
- ic = getInitialContext();
- createTopic("StressTestTopic");
-
- RelayStressTest.log.debug("setup done");
- }
-
- @Override
- @After
- public void tearDown() throws Exception
- {
- destroyTopic("StressTestTopic");
- ic.close();
- }
-
- @Test
- public void testRelay() throws Exception
- {
- ConnectionFactory cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
-
- Topic topic = (Topic)ic.lookup("/topic/StressTestTopic");
-
- final int numMessages = 20000;
-
- final int numRelayers = 5;
-
- final int numConsumers = 20;
-
- Connection conn = cf.createConnection();
-
- class Relayer implements MessageListener
- {
- boolean done;
-
- boolean failed;
-
- int count;
-
- MessageProducer prod;
-
- Relayer(final MessageProducer prod)
- {
- this.prod = prod;
- }
-
- public void onMessage(final Message m)
- {
- try
- {
- m.clearProperties();
- m.setStringProperty("name", "Tim");
-
- prod.send(m);
-
- count++;
-
- if (count == numMessages)
- {
- synchronized (this)
- {
- done = true;
- notify();
- }
- }
- }
- catch (JMSException e)
- {
- e.printStackTrace();
- synchronized (this)
- {
- done = true;
- failed = true;
- notify();
- }
- }
- }
- }
-
- class Consumer implements MessageListener
- {
- boolean failed;
-
- boolean done;
-
- int count;
-
- public void onMessage(final Message m)
- {
- count++;
-
- if (count == numMessages * numRelayers)
- {
- synchronized (this)
- {
- done = true;
- notify();
- }
- }
- }
- }
-
- Relayer[] relayers = new Relayer[numRelayers];
-
- Consumer[] consumers = new Consumer[numConsumers];
-
- for (int i = 0; i < numRelayers; i++)
- {
- Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageConsumer cons = sess.createConsumer(topic, "name = 'Watt'");
- // MessageConsumer cons = sess.createConsumer(topic);
-
- MessageProducer prod = sess.createProducer(topic);
-
- relayers[i] = new Relayer(prod);
-
- cons.setMessageListener(relayers[i]);
- }
-
- for (int i = 0; i < numConsumers; i++)
- {
- Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageConsumer cons = sess.createConsumer(topic, "name = 'Tim'");
-
- consumers[i] = new Consumer();
-
- cons.setMessageListener(consumers[i]);
- }
-
- conn.start();
-
- Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageProducer prod = sess.createProducer(topic);
-
- prod.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-
- for (int i = 0; i < numMessages; i++)
- {
- Message m = sess.createMessage();
-
- m.setStringProperty("name", "Watt");
-
- prod.send(m);
- }
-
- for (int i = 0; i < numRelayers; i++)
- {
- synchronized (relayers[i])
- {
- if (!relayers[i].done)
- {
- relayers[i].wait();
- }
- }
- }
-
- for (int i = 0; i < numConsumers; i++)
- {
- synchronized (consumers[i])
- {
- if (!consumers[i].done)
- {
- consumers[i].wait();
- }
- }
- }
-
- conn.close();
-
- for (int i = 0; i < numRelayers; i++)
- {
- ProxyAssertSupport.assertFalse(relayers[i].failed);
- }
-
- for (int i = 0; i < numConsumers; i++)
- {
- ProxyAssertSupport.assertFalse(consumers[i].failed);
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/Runner.java
----------------------------------------------------------------------
diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/Runner.java b/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/Runner.java
deleted file mode 100644
index d5aab5e..0000000
--- a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/Runner.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.jms.tests.stress;
-
-import org.apache.activemq.jms.tests.JmsTestLogger;
-
-import javax.jms.Session;
-
-/**
- *
- * A Runner.
- *
- * Base class for running components of a stress test
- *
- * @author <a href="tim.fox@jboss.com">Tim Fox</a>
- *
- */
-public abstract class Runner implements Runnable
-{
- protected JmsTestLogger log = JmsTestLogger.LOGGER;
-
- protected Session sess;
-
- protected int numMessages;
-
- private boolean failed;
-
- public Runner(final Session sess, final int numMessages)
- {
- this.sess = sess;
- this.numMessages = numMessages;
- }
-
- public abstract void run();
-
- public boolean isFailed()
- {
- return failed;
- }
-
- public void setFailed(final boolean failed)
- {
- this.failed = failed;
- if (failed)
- {
- log.info("Marking Runner " + this + " as failed", new Exception("trace"));
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/Sender.java
----------------------------------------------------------------------
diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/Sender.java b/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/Sender.java
deleted file mode 100644
index f57a375..0000000
--- a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/Sender.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.jms.tests.stress;
-
-import org.apache.activemq.jms.tests.JmsTestLogger;
-
-import javax.jms.Message;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-/**
- *
- * A Sender.
- *
- * Sends messages to a destination, used in stress testing
- *
- * @author <a href="tim.fox@jboss.com">Tim Fox</a>
- *
- */
-public class Sender extends Runner
-{
- private static final JmsTestLogger log = JmsTestLogger.LOGGER;
-
- protected MessageProducer prod;
-
- protected String prodName;
-
- protected int count;
-
- public Sender(final String prodName, final Session sess, final MessageProducer prod, final int numMessages)
- {
- super(sess, numMessages);
- this.prod = prod;
- this.prodName = prodName;
- }
-
- @Override
- public void run()
- {
- try
- {
- while (count < numMessages)
- {
- Message m = sess.createMessage();
- m.setStringProperty("PROD_NAME", prodName);
- m.setIntProperty("MSG_NUMBER", count);
- prod.send(m);
- count++;
- }
- }
- catch (Exception e)
- {
- Sender.log.error("Failed to send message", e);
- setFailed(true);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/SeveralClientsStressTest.java
----------------------------------------------------------------------
diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/SeveralClientsStressTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/SeveralClientsStressTest.java
deleted file mode 100644
index 72b33b3..0000000
--- a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/stress/SeveralClientsStressTest.java
+++ /dev/null
@@ -1,547 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.jms.tests.stress;
-import java.util.HashSet;
-import java.util.Random;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.DeliveryMode;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.naming.Context;
-
-import org.apache.activemq.jms.tests.ActiveMQServerTestCase;
-import org.apache.activemq.jms.tests.JmsTestLogger;
-import org.apache.activemq.jms.tests.util.ProxyAssertSupport;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- * In order for this test to run, you will need to edit /etc/security/limits.conf and change your max sockets to something bigger than 1024
- *
- * It's required to re-login after this change.
- *
- * For Windows you need also to increase this limit (max opened files) somehow.
- *
- *
-Example of /etc/security/limits.confg:
-#<domain> <type> <item> <value>
-clebert hard nofile 10240
-
-
- * @author <a href="mailto:clebert.suconic@jboss.org">Clebert Suconic</a>
- */
-public class SeveralClientsStressTest extends ActiveMQServerTestCase
-{
- @BeforeClass
- public static void stressTestsEnabled()
- {
- org.junit.Assume.assumeTrue(JMSStressTestBase.STRESS_TESTS_ENABLED);
- }
-
- protected boolean info = false;
-
- protected boolean startServer = true;
-
- // Static ---------------------------------------------------------------------------------------
-
- protected static long PRODUCER_ALIVE_FOR = 60000; // one minute
-
- protected static long CONSUMER_ALIVE_FOR = 60000; // one minutes
-
- protected static long TEST_ALIVE_FOR = 5 * 60 * 1000; // 5 minutes
-
- protected static int NUMBER_OF_PRODUCERS = 100; // this should be set to 300 later
-
- protected static int NUMBER_OF_CONSUMERS = 100; // this should be set to 300 later
-
- // a producer should have a long wait between each message sent?
- protected static boolean LONG_WAIT_ON_PRODUCERS = false;
-
- protected static AtomicInteger producedMessages = new AtomicInteger(0);
-
- protected static AtomicInteger readMessages = new AtomicInteger(0);
-
- protected Context createContext() throws Exception
- {
- return getInitialContext();
- }
-
- // Constructors ---------------------------------------------------------------------------------
-
- // Public ---------------------------------------------------------------------------------------
-
- @Test
- public void testQueue() throws Exception
- {
- Context ctx = createContext();
-
- HashSet<SeveralClientsStressTest.Worker> threads = new HashSet<SeveralClientsStressTest.Worker>();
-
- // A chhanel of communication between workers and the test method
- LinkedBlockingQueue<InternalMessage> testChannel = new LinkedBlockingQueue<InternalMessage>();
-
- for (int i = 0; i < SeveralClientsStressTest.NUMBER_OF_PRODUCERS; i++)
- {
- threads.add(new SeveralClientsStressTest.Producer(i, testChannel));
- }
-
- for (int i = 0; i < SeveralClientsStressTest.NUMBER_OF_CONSUMERS; i++)
- {
- threads.add(new SeveralClientsStressTest.Consumer(i, testChannel));
- }
-
- for (Worker worker : threads)
- {
- worker.start();
- }
-
- long timeToFinish = System.currentTimeMillis() + SeveralClientsStressTest.TEST_ALIVE_FOR;
-
- int numberOfProducers = SeveralClientsStressTest.NUMBER_OF_PRODUCERS;
- int numberOfConsumers = SeveralClientsStressTest.NUMBER_OF_CONSUMERS;
-
- while (threads.size() > 0)
- {
- SeveralClientsStressTest.InternalMessage msg = testChannel.poll(2000,
- TimeUnit.MILLISECONDS);
-
- log.info("Produced:" + SeveralClientsStressTest.producedMessages.get() +
- " and Consumed:" +
- SeveralClientsStressTest.readMessages.get() +
- " messages");
-
- if (msg != null)
- {
- if (info)
- {
- log.info("Received message " + msg);
- }
- if (msg instanceof SeveralClientsStressTest.WorkerFailed)
- {
- ProxyAssertSupport.fail("Worker " + msg.getWorker() + " has failed");
- }
- else if (msg instanceof SeveralClientsStressTest.WorkedFinishedMessages)
- {
- SeveralClientsStressTest.WorkedFinishedMessages finished = (SeveralClientsStressTest.WorkedFinishedMessages)msg;
- if (threads.remove(finished.getWorker()))
- {
- if (System.currentTimeMillis() < timeToFinish)
- {
- if (finished.getWorker() instanceof SeveralClientsStressTest.Producer)
- {
- if (info)
- {
- log.info("Scheduling new Producer " + numberOfProducers);
- }
- SeveralClientsStressTest.Producer producer = new SeveralClientsStressTest.Producer(numberOfProducers++,
- testChannel);
- threads.add(producer);
- producer.start();
- }
- else if (finished.getWorker() instanceof SeveralClientsStressTest.Consumer)
- {
- if (info)
- {
- log.info("Scheduling new ClientConsumer " + numberOfConsumers);
- }
- SeveralClientsStressTest.Consumer consumer = new SeveralClientsStressTest.Consumer(numberOfConsumers++,
- testChannel);
- threads.add(consumer);
- consumer.start();
- }
- }
- }
- else
- {
- log.warn(finished.getWorker() + " was not available on threads HashSet");
- }
- }
- }
- }
-
- log.info("Produced:" + SeveralClientsStressTest.producedMessages.get() +
- " and Consumed:" +
- SeveralClientsStressTest.readMessages.get() +
- " messages");
-
- clearMessages();
-
- log.info("Produced:" + SeveralClientsStressTest.producedMessages.get() +
- " and Consumed:" +
- SeveralClientsStressTest.readMessages.get() +
- " messages");
-
- ProxyAssertSupport.assertEquals(SeveralClientsStressTest.producedMessages.get(),
- SeveralClientsStressTest.readMessages.get());
- }
-
- // Package protected ----------------------------------------------------------------------------
-
- // Protected ------------------------------------------------------------------------------------
-
- protected void clearMessages() throws Exception
- {
- Context ctx = createContext();
- ConnectionFactory cf = (ConnectionFactory)ctx.lookup("/ClusteredConnectionFactory");
- Connection conn = cf.createConnection();
- Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Queue queue = (Queue)ctx.lookup("queue/testQueue");
- MessageConsumer consumer = sess.createConsumer(queue);
-
- conn.start();
-
- while (consumer.receive(1000) != null)
- {
- SeveralClientsStressTest.readMessages.incrementAndGet();
- log.info("Received JMS message on clearMessages");
- }
-
- conn.close();
- }
-
- @Override
- @Before
- public void setUp() throws Exception
- {
- super.setUp();
-
- if (startServer)
- {
- // ServerManagement.start("all", true);
- createQueue("testQueue");
- }
-
- clearMessages();
- SeveralClientsStressTest.producedMessages = new AtomicInteger(0);
- SeveralClientsStressTest.readMessages = new AtomicInteger(0);
- }
-
- // Private --------------------------------------------------------------------------------------
-
- // Inner classes --------------------------------------------------------------------------------
-
- private class Worker extends Thread
- {
-
- protected JmsTestLogger log = JmsTestLogger.LOGGER;
-
- private boolean failed = false;
-
- private final int workerId;
-
- private Exception ex;
-
- LinkedBlockingQueue<InternalMessage> messageQueue;
-
- public int getWorkerId()
- {
- return workerId;
- }
-
- public Exception getException()
- {
- return ex;
- }
-
- public boolean isFailed()
- {
- return failed;
- }
-
- protected synchronized void setFailed(final boolean failed, final Exception ex)
- {
- this.failed = failed;
- this.ex = ex;
-
- log.info("Sending Exception", ex);
-
- sendInternalMessage(new SeveralClientsStressTest.WorkerFailed(this));
-
- }
-
- protected void sendInternalMessage(final SeveralClientsStressTest.InternalMessage msg)
- {
- if (info)
- {
- log.info("Sending message " + msg);
- }
- try
- {
- messageQueue.put(msg);
- }
- catch (Exception e)
- {
- log.error(e, e);
- setFailed(true, e);
- }
- }
-
- public Worker(final String name, final int workerId,
- final LinkedBlockingQueue<SeveralClientsStressTest.InternalMessage> messageQueue)
- {
- super(name);
- this.workerId = workerId;
- this.messageQueue = messageQueue;
- setDaemon(true);
- }
-
- @Override
- public String toString()
- {
- return this.getClass().getName() + ":" + getWorkerId();
- }
- }
-
- final class Producer extends SeveralClientsStressTest.Worker
- {
- public Producer(final int producerId,
- final LinkedBlockingQueue<SeveralClientsStressTest.InternalMessage> messageQueue)
- {
- super("Producer:" + producerId, producerId, messageQueue);
- }
-
- Random random = new Random();
-
- @Override
- public void run()
- {
- try
- {
- Context ctx = createContext();
-
- ConnectionFactory cf = (ConnectionFactory)ctx.lookup("/ClusteredConnectionFactory");
-
- Queue queue = (Queue)ctx.lookup("queue/testQueue");
-
- if (info)
- {
- log.info("Creating connection and producer");
- }
- Connection conn = cf.createConnection();
- Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageProducer prod = sess.createProducer(queue);
-
- if (getWorkerId() % 2 == 0)
- {
- if (info)
- {
- log.info("Non Persistent Producer was created");
- }
- prod.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
- }
- else
- {
- if (info)
- {
- log.info("Persistent Producer was created");
- }
- prod.setDeliveryMode(DeliveryMode.PERSISTENT);
- }
-
- long timeToFinish = System.currentTimeMillis() + SeveralClientsStressTest.PRODUCER_ALIVE_FOR;
-
- try
- {
- int messageSent = 0;
- while (System.currentTimeMillis() < timeToFinish)
- {
- prod.send(sess.createTextMessage("Message sent at " + System.currentTimeMillis()));
- SeveralClientsStressTest.producedMessages.incrementAndGet();
- messageSent++;
- if (messageSent % 50 == 0)
- {
- if (info)
- {
- log.info("Sent " + messageSent + " Messages");
- }
- }
-
- if (SeveralClientsStressTest.LONG_WAIT_ON_PRODUCERS)
- {
- int waitTime = random.nextInt() % 2 + 1;
- if (waitTime < 0)
- {
- waitTime *= -1;
- }
- Thread.sleep(waitTime * 1000); // wait 1 or 2 seconds
- }
- else
- {
- Thread.sleep(100);
- }
- }
- sendInternalMessage(new SeveralClientsStressTest.WorkedFinishedMessages(this));
- }
- finally
- {
- conn.close();
- }
-
- }
- catch (Exception e)
- {
- log.error(e, e);
- setFailed(true, e);
- }
- }
- }
-
- final class Consumer extends SeveralClientsStressTest.Worker
- {
- public Consumer(final int consumerId,
- final LinkedBlockingQueue<SeveralClientsStressTest.InternalMessage> messageQueue)
- {
- super("ClientConsumer:" + consumerId, consumerId, messageQueue);
- }
-
- @Override
- public void run()
- {
- try
- {
- Context ctx = createContext();
-
- ConnectionFactory cf = (ConnectionFactory)ctx.lookup("/ClusteredConnectionFactory");
-
- Queue queue = (Queue)ctx.lookup("queue/testQueue");
-
- if (info)
- {
- log.info("Creating connection and consumer");
- }
- Connection conn = cf.createConnection();
- Session sess = conn.createSession(true, Session.SESSION_TRANSACTED);
- MessageConsumer consumer = sess.createConsumer(queue);
- if (info)
- {
- log.info("ClientConsumer was created");
- }
-
- conn.start();
-
- int msgs = 0;
-
- int transactions = 0;
-
- long timeToFinish = System.currentTimeMillis() + SeveralClientsStressTest.CONSUMER_ALIVE_FOR;
-
- try
- {
- while (System.currentTimeMillis() < timeToFinish)
- {
- Message msg = consumer.receive(1000);
- if (msg != null)
- {
- msgs++;
- if (msgs >= 50)
- {
- transactions++;
- if (transactions % 2 == 0)
- {
- if (info)
- {
- log.info("Commit transaction");
- }
- sess.commit();
- SeveralClientsStressTest.readMessages.addAndGet(msgs);
- }
- else
- {
- if (info)
- {
- log.info("Rollback transaction");
- }
- sess.rollback();
- }
- msgs = 0;
- }
- }
- else
- {
- break;
- }
- }
-
- SeveralClientsStressTest.readMessages.addAndGet(msgs);
- sess.commit();
-
- sendInternalMessage(new SeveralClientsStressTest.WorkedFinishedMessages(this));
- }
- finally
- {
- conn.close();
- }
-
- }
- catch (Exception e)
- {
- log.error(e);
- setFailed(true, e);
- }
- }
- }
-
- // Objects used on the communication between Workers and the test
- static class InternalMessage
- {
- SeveralClientsStressTest.Worker worker;
-
- public InternalMessage(final SeveralClientsStressTest.Worker worker)
- {
- this.worker = worker;
- }
-
- public SeveralClientsStressTest.Worker getWorker()
- {
- return worker;
- }
-
- @Override
- public String toString()
- {
- return this.getClass().getName() + " worker-> " + worker.toString();
- }
- }
-
- static class WorkedFinishedMessages extends SeveralClientsStressTest.InternalMessage
- {
-
- public WorkedFinishedMessages(final SeveralClientsStressTest.Worker worker)
- {
- super(worker);
- }
-
- }
-
- static class WorkerFailed extends SeveralClientsStressTest.InternalMessage
- {
- public WorkerFailed(final SeveralClientsStressTest.Worker worker)
- {
- super(worker);
- }
- }
-
-}
[11/15] activemq-6 git commit: Refactored the testsuite a bit
Posted by jb...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/HierarchicalObjectRepositoryTest.java
----------------------------------------------------------------------
diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/HierarchicalObjectRepositoryTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/HierarchicalObjectRepositoryTest.java
new file mode 100644
index 0000000..e1b5b72
--- /dev/null
+++ b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/HierarchicalObjectRepositoryTest.java
@@ -0,0 +1,154 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.tests.extras.byteman;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.activemq.core.settings.impl.HierarchicalObjectRepository;
+import org.jboss.byteman.contrib.bmunit.BMRule;
+import org.jboss.byteman.contrib.bmunit.BMRules;
+import org.jboss.byteman.contrib.bmunit.BMUnitRunner;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(BMUnitRunner.class)
+@BMRules(rules = { @BMRule(name = "modify map during iteration",
+ targetClass = "org.apache.activemq.core.settings.impl.HierarchicalObjectRepository",
+ targetMethod = "getPossibleMatches(String)", targetLocation = "AT INVOKE java.util.HashMap.put",
+ action = "org.apache.activemq.tests.extras.byteman.HierarchicalObjectRepositoryTest.bum()"), })
+public class HierarchicalObjectRepositoryTest
+{
+ private static final String A = "a.";
+ private static final int TOTAL = 100;
+ private static CountDownLatch latch;
+ private static CountDownLatch latch2;
+ private ExecutorService executor;
+ private HierarchicalObjectRepository<String> repo;
+
+ @Before
+ public void setUp()
+ {
+ latch = new CountDownLatch(1);
+ latch2 = new CountDownLatch(1);
+ executor = Executors.newSingleThreadExecutor();
+ repo = new HierarchicalObjectRepository<String>();
+ addToRepo(repo, A);
+ }
+
+ static void addToRepo(HierarchicalObjectRepository<String> repo0, String pattern)
+ {
+ for (int i = 0; i < TOTAL; i++)
+ {
+ repo0.addMatch(pattern + i + ".*", String.valueOf(i));
+ }
+ }
+
+ @After
+ public void tearDown() throws InterruptedException
+ {
+ latch.countDown();
+ latch2.countDown();
+ executor.shutdown();
+ executor.awaitTermination(1, TimeUnit.SECONDS);
+ }
+
+ private class Clearer implements Runnable
+ {
+ private final int code;
+
+ public Clearer(int code)
+ {
+ this.code = code;
+ }
+
+ @Override
+ public void run()
+ {
+ try
+ {
+ latch.await();
+ }
+ catch (InterruptedException e)
+ {
+ throw new RuntimeException(e);
+ }
+
+ switch (code)
+ {
+ case 0:
+ repo.clear();
+ break;
+ case 1:
+ addToRepo(repo, "bb.");
+ break;
+ case 2:
+ for (int i = TOTAL / 2; i < TOTAL; i++)
+ {
+ repo.removeMatch(A + i + ".*");
+ }
+ break;
+ default:
+ throw new RuntimeException();
+ }
+
+ latch2.countDown();
+ }
+ }
+
+ @Test
+ public void testConcurrentModificationsClear()
+ {
+ executor.execute(new Clearer(0));
+ repo.getMatch(A + (TOTAL - 10) + ".foobar");
+ Assert.assertEquals("Byteman rule failed?", 0, latch.getCount());
+ }
+
+ @Test
+ public void testConcurrentModificationsAdd()
+ {
+ executor.execute(new Clearer(1));
+ repo.getMatch(A + (TOTAL - 10) + ".foobar");
+ Assert.assertEquals("Byteman rule failed?", 0, latch.getCount());
+ }
+
+ @Test
+ public void testConcurrentModificationsRemove()
+ {
+ executor.execute(new Clearer(2));
+ repo.getMatch(A + (TOTAL - 10) + ".foobar");
+ Assert.assertEquals("Byteman rule failed?", 0, latch.getCount());
+ }
+
+ public static void bum()
+ {
+ latch.countDown();
+ try
+ {
+ latch2.await(3, TimeUnit.SECONDS);
+ }
+ catch (InterruptedException e)
+ {
+ // no op
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/JMSBridgeReconnectionTest.java
----------------------------------------------------------------------
diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/JMSBridgeReconnectionTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/JMSBridgeReconnectionTest.java
new file mode 100644
index 0000000..3be3f73
--- /dev/null
+++ b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/JMSBridgeReconnectionTest.java
@@ -0,0 +1,163 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.tests.extras.byteman;
+
+import org.apache.activemq.core.client.impl.ClientProducerCredits;
+import org.apache.activemq.core.message.impl.MessageInternal;
+import org.apache.activemq.core.protocol.core.Packet;
+import org.apache.activemq.core.protocol.core.impl.PacketImpl;
+import org.apache.activemq.core.protocol.core.impl.wireformat.SessionSendMessage;
+import org.apache.activemq.jms.bridge.ConnectionFactoryFactory;
+import org.apache.activemq.jms.bridge.QualityOfServiceMode;
+import org.apache.activemq.jms.bridge.impl.JMSBridgeImpl;
+import org.apache.activemq.jms.server.JMSServerManager;
+import org.apache.activemq.tests.extras.jms.bridge.BridgeTestBase;
+import org.jboss.byteman.contrib.bmunit.BMRule;
+import org.jboss.byteman.contrib.bmunit.BMRules;
+import org.jboss.byteman.contrib.bmunit.BMUnitRunner;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+@RunWith(BMUnitRunner.class)
+public class JMSBridgeReconnectionTest extends BridgeTestBase
+{
+
+ @Test
+ @BMRules
+ (
+ rules =
+ {
+ @BMRule
+ (
+ name = "trace clientsessionimpl send",
+ targetClass = "org.apache.activemq.core.protocol.core.impl.ChannelImpl",
+ targetMethod = "send",
+ targetLocation = "ENTRY",
+ action = "org.apache.activemq.tests.extras.byteman.JMSBridgeReconnectionTest.pause($1);"
+ ),
+ @BMRule
+ (
+ name = "trace sendRegularMessage",
+ targetClass = "org.apache.activemq.core.client.impl.ClientProducerImpl",
+ targetMethod = "sendRegularMessage",
+ targetLocation = "ENTRY",
+ action = "org.apache.activemq.tests.extras.byteman.JMSBridgeReconnectionTest.pause2($1,$2,$3);"
+ )
+ }
+ )
+ public void performCrashDestinationStopBridge() throws Exception
+ {
+ activeMQServer = jmsServer1;
+ ConnectionFactoryFactory factInUse0 = cff0;
+ ConnectionFactoryFactory factInUse1 = cff1;
+ final JMSBridgeImpl bridge =
+ new JMSBridgeImpl(factInUse0,
+ factInUse1,
+ sourceQueueFactory,
+ targetQueueFactory,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 1000,
+ -1,
+ QualityOfServiceMode.DUPLICATES_OK,
+ 10,
+ -1,
+ null,
+ null,
+ false);
+
+ addActiveMQComponent(bridge);
+ bridge.setTransactionManager(newTransactionManager());
+ bridge.start();
+ final CountDownLatch latch = new CountDownLatch(20);
+ Thread clientThread = new Thread(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ while (bridge.isStarted())
+ {
+ try
+ {
+ sendMessages(cf0, sourceQueue, 0, 1, false, false);
+ latch.countDown();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+ });
+
+ clientThread.start();
+
+ stopLatch.await(10000, TimeUnit.MILLISECONDS);
+
+ bridge.stop();
+
+ clientThread.join(5000);
+
+ assertTrue(!clientThread.isAlive());
+ }
+
+ public static void pause(Packet packet)
+ {
+ if (packet.getType() == PacketImpl.SESS_SEND)
+ {
+ SessionSendMessage sendMessage = (SessionSendMessage) packet;
+ if (sendMessage.getMessage().containsProperty("__HQ_CID") && count < 0 && !stopped)
+ {
+ try
+ {
+ activeMQServer.stop();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ stopped = true;
+ try
+ {
+ Thread.sleep(5000);
+ }
+ catch (InterruptedException e)
+ {
+ e.printStackTrace();
+ }
+ stopLatch.countDown();
+ }
+ }
+ }
+
+ static JMSServerManager activeMQServer;
+ static boolean stopped = false;
+ static int count = 20;
+ static CountDownLatch stopLatch = new CountDownLatch(1);
+ public static void pause2(MessageInternal msgI, boolean sendBlocking, final ClientProducerCredits theCredits)
+ {
+ if (msgI.containsProperty("__HQ_CID"))
+ {
+ count--;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/LatencyTest.java
----------------------------------------------------------------------
diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/LatencyTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/LatencyTest.java
new file mode 100644
index 0000000..68914fe
--- /dev/null
+++ b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/LatencyTest.java
@@ -0,0 +1,69 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.tests.extras.byteman;
+
+import org.apache.activemq.api.core.client.ClientSession;
+import org.apache.activemq.api.core.client.ClientSessionFactory;
+import org.apache.activemq.api.core.client.ServerLocator;
+import org.apache.activemq.core.server.ActiveMQServer;
+import org.apache.activemq.tests.util.ServiceTestBase;
+import org.jboss.byteman.contrib.bmunit.BMRule;
+import org.jboss.byteman.contrib.bmunit.BMRules;
+import org.jboss.byteman.contrib.bmunit.BMUnitRunner;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(BMUnitRunner.class)
+public class LatencyTest extends ServiceTestBase
+{
+ /*
+ * simple test to make sure connect still works with some network latency built into netty
+ * */
+ @Test
+ @BMRules
+ (
+ rules =
+ {
+ @BMRule
+ (
+ name = "trace ClientBootstrap.connect",
+ targetClass = "org.jboss.netty.bootstrap.ClientBootstrap",
+ targetMethod = "connect",
+ targetLocation = "ENTRY",
+ action = "System.out.println(\"netty connecting\")"
+ ),
+ @BMRule
+ (
+ name = "sleep OioWorker.run",
+ targetClass = "org.jboss.netty.channel.socket.oio.OioWorker",
+ targetMethod = "run",
+ targetLocation = "ENTRY",
+ action = "Thread.sleep(500)"
+ )
+ }
+ )
+ public void testLatency() throws Exception
+ {
+ ActiveMQServer server = createServer(createDefaultConfig(true));
+ server.start();
+ ServerLocator locator = createNettyNonHALocator();
+ ClientSessionFactory factory = createSessionFactory(locator);
+ ClientSession session = factory.createSession();
+ session.close();
+ server.stop();
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/MessageCopyTest.java
----------------------------------------------------------------------
diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/MessageCopyTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/MessageCopyTest.java
new file mode 100644
index 0000000..18b00d5
--- /dev/null
+++ b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/MessageCopyTest.java
@@ -0,0 +1,206 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.tests.extras.byteman;
+
+import java.util.ArrayList;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.activemq.api.core.ActiveMQBuffer;
+import org.apache.activemq.api.core.SimpleString;
+import org.apache.activemq.core.protocol.core.impl.wireformat.SessionSendMessage;
+import org.apache.activemq.core.server.impl.ServerMessageImpl;
+import org.apache.activemq.tests.util.RandomUtil;
+import org.jboss.byteman.contrib.bmunit.BMRule;
+import org.jboss.byteman.contrib.bmunit.BMRules;
+import org.jboss.byteman.contrib.bmunit.BMUnitRunner;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * @author Clebert Suconic
+ */
+@RunWith(BMUnitRunner.class)
+public class MessageCopyTest
+{
+ @Test
+ @BMRules
+ (
+
+ rules =
+ {
+ @BMRule
+ (
+ name = "message-copy0",
+ targetClass = "org.apache.activemq.core.server.impl.ServerMessageImpl",
+ targetMethod = "copy()",
+ targetLocation = "ENTRY",
+ action = "System.out.println(\"copy\"), waitFor(\"encode-done\")"
+ ),
+ @BMRule
+ (
+ name = "message-copy-done",
+ targetClass = "org.apache.activemq.core.protocol.core.impl.wireformat.SessionSendMessage",
+ targetMethod = "encode(org.apache.activemq.spi.core.protocol.RemotingConnection)",
+ targetLocation = "EXIT",
+ action = "System.out.println(\"encodeDone\"), signalWake(\"encode-done\", true)"
+ ),
+ @BMRule
+ (
+ name = "message-copy1",
+ targetClass = "org.apache.activemq.core.buffers.impl.ChannelBufferWrapper",
+ targetMethod = "copy(int, int)",
+ condition = "Thread.currentThread().getName().equals(\"T1\")",
+ targetLocation = "EXIT",
+ action = "System.out.println(\"setIndex at \" + Thread.currentThread().getName()), waitFor(\"finish-read\")"
+ ),
+ @BMRule(
+ name = "JMSServer.stop wait-init",
+ targetClass = "org.apache.activemq.tests.extras.byteman.MessageCopyTest",
+ targetMethod = "simulateRead",
+ targetLocation = "EXIT",
+ action = "signalWake(\"finish-read\", true)"
+ )
+ }
+ )
+ public void testMessageCopyIssue() throws Exception
+ {
+ final long RUNS = 1;
+ final ServerMessageImpl msg = new ServerMessageImpl(123, 18);
+
+ msg.setMessageID(RandomUtil.randomLong());
+ msg.encodeMessageIDToBuffer();
+ msg.setAddress(new SimpleString("Batatantkashf aksjfh aksfjh askfdjh askjfh "));
+
+ final AtomicInteger errors = new AtomicInteger(0);
+
+ int T1_number = 1;
+ int T2_number = 1;
+
+ final CountDownLatch latchAlign = new CountDownLatch(T1_number + T2_number);
+ final CountDownLatch latchReady = new CountDownLatch(1);
+ class T1 extends Thread
+ {
+ T1()
+ {
+ super("T1");
+ }
+
+ @Override
+ public void run()
+ {
+ latchAlign.countDown();
+ try
+ {
+ latchReady.await();
+ }
+ catch (Exception ignored)
+ {
+ }
+
+ for (int i = 0; i < RUNS; i++)
+ {
+ try
+ {
+ ServerMessageImpl newMsg = (ServerMessageImpl) msg.copy();
+ }
+ catch (Throwable e)
+ {
+ e.printStackTrace();
+ errors.incrementAndGet();
+ }
+ }
+ }
+ }
+
+ class T2 extends Thread
+ {
+ T2()
+ {
+ super("T2");
+ }
+
+ @Override
+ public void run()
+ {
+ latchAlign.countDown();
+ try
+ {
+ latchReady.await();
+ }
+ catch (Exception ignored)
+ {
+ }
+
+ for (int i = 0; i < RUNS; i++)
+ {
+ try
+ {
+ SessionSendMessage ssm = new SessionSendMessage(msg);
+ ActiveMQBuffer buf = ssm.encode(null);
+ System.out.println("reading at buf = " + buf);
+ simulateRead(buf);
+ }
+ catch (Throwable e)
+ {
+ e.printStackTrace();
+ errors.incrementAndGet();
+ }
+ }
+ }
+ }
+
+
+ ArrayList<Thread> threads = new ArrayList<Thread>();
+
+ for (int i = 0; i < T1_number; i++)
+ {
+ T1 t = new T1();
+ threads.add(t);
+ t.start();
+ }
+
+ for (int i = 0; i < T2_number; i++)
+ {
+ T2 t2 = new T2();
+ threads.add(t2);
+ t2.start();
+ }
+
+ latchAlign.await();
+
+ latchReady.countDown();
+
+ for (Thread t : threads)
+ {
+ t.join();
+ }
+
+ Assert.assertEquals(0, errors.get());
+ }
+
+ private void simulateRead(ActiveMQBuffer buf)
+ {
+ buf.setIndex(buf.capacity() / 2, buf.capacity() / 2);
+
+ // ok this is not actually happening during the read process, but changing this shouldn't affect the buffer on copy
+ buf.writeBytes(new byte[1024]);
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/OrphanedConsumerTest.java
----------------------------------------------------------------------
diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/OrphanedConsumerTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/OrphanedConsumerTest.java
new file mode 100644
index 0000000..6826704
--- /dev/null
+++ b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/OrphanedConsumerTest.java
@@ -0,0 +1,301 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.tests.extras.byteman;
+
+
+import org.apache.activemq.api.core.SimpleString;
+import org.apache.activemq.api.core.client.ClientConsumer;
+import org.apache.activemq.api.core.client.ClientMessage;
+import org.apache.activemq.api.core.client.ClientProducer;
+import org.apache.activemq.api.core.client.ClientSession;
+import org.apache.activemq.api.core.client.ServerLocator;
+import org.apache.activemq.core.client.impl.ClientSessionFactoryImpl;
+import org.apache.activemq.core.server.ActiveMQServer;
+import org.apache.activemq.core.server.Queue;
+import org.apache.activemq.tests.util.ServiceTestBase;
+import org.jboss.byteman.contrib.bmunit.BMRule;
+import org.jboss.byteman.contrib.bmunit.BMRules;
+import org.jboss.byteman.contrib.bmunit.BMUnitRunner;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * @author Clebert Suconic
+ */
+@RunWith(BMUnitRunner.class)
+public class OrphanedConsumerTest extends ServiceTestBase
+{
+
+ private static boolean conditionActive = true;
+
+ public static final boolean isConditionActive()
+ {
+ return conditionActive;
+ }
+
+
+ public static final void setConditionActive(boolean _conditionActive)
+ {
+ conditionActive = _conditionActive;
+ }
+
+
+ public static void throwException() throws Exception
+ {
+ throw new InterruptedException("nice.. I interrupted this!");
+ }
+
+ private ActiveMQServer server;
+
+ private ServerLocator locator;
+
+ static ActiveMQServer staticServer;
+
+ /**
+ * {@link #leavingCloseOnTestCountersWhileClosing()} will set this in case of any issues.
+ * the test must then validate for this being null
+ */
+ static AssertionError verification;
+
+ /**
+ * This static method is an entry point for the byteman rules on {@link #testOrphanedConsumers()}
+ * */
+ public static void leavingCloseOnTestCountersWhileClosing()
+ {
+ if (staticServer.getConnectionCount() == 0)
+ {
+ verification = new AssertionError("The connection was closed before the consumers and sessions, this may cause issues on management leaving Orphaned Consumers!");
+ }
+
+ if (staticServer.getSessions().size() == 0)
+ {
+ verification = new AssertionError("The session was closed before the consumers, this may cause issues on management leaving Orphaned Consumers!");
+ }
+ }
+
+
+ @Override
+ @Before
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ setConditionActive(true);
+ /** I'm using the internal method here because closing
+ * this locator on tear down would hang.
+ * as we are tweaking with the internal state and making it fail */
+ locator = internalCreateNonHALocator(true);
+ }
+
+
+ @Override
+ @After
+ public void tearDown() throws Exception
+ {
+ super.tearDown();
+ setConditionActive(false);
+
+ staticServer = null;
+ }
+
+
+ /**
+ * This is like being two tests in one:
+ * I - validating that any exception during the close wouldn't stop connection from being closed
+ * II - validating that the connection is only removed at the end of the process and you wouldn't see
+ * inconsistencies on management
+ * @throws Exception
+ */
+ @Test
+ @BMRules
+ (
+ rules =
+ {
+ @BMRule
+ (
+ name = "closeExit",
+ targetClass = "org.apache.activemq.core.server.impl.ServerConsumerImpl",
+ targetMethod = "close",
+ targetLocation = "AT EXIT",
+ condition = "org.apache.activemq.tests.extras.byteman.OrphanedConsumerTest.isConditionActive()",
+ action = "System.out.println(\"throwing stuff\");throw new InterruptedException()"
+ ),
+ @BMRule
+ (
+ name = "closeEnter",
+ targetClass = "org.apache.activemq.core.server.impl.ServerConsumerImpl",
+ targetMethod = "close",
+ targetLocation = "ENTRY",
+ condition = "org.apache.activemq.tests.extras.byteman.OrphanedConsumerTest.isConditionActive()",
+ action = "org.apache.activemq.tests.extras.byteman.OrphanedConsumerTest.leavingCloseOnTestCountersWhileClosing()"
+ )
+
+ }
+ )
+ public void testOrphanedConsumers() throws Exception
+ {
+ internalTestOrphanedConsumers(false);
+ }
+
+
+ /**
+ * This is like being two tests in one:
+ * I - validating that any exception during the close wouldn't stop connection from being closed
+ * II - validating that the connection is only removed at the end of the process and you wouldn't see
+ * inconsistencies on management
+ * @throws Exception
+ */
+ @Test
+ @BMRules
+ (
+ rules =
+ {
+ @BMRule
+ (
+ name = "closeExit",
+ targetClass = "org.apache.activemq.core.server.impl.ServerConsumerImpl",
+ targetMethod = "close",
+ targetLocation = "AT EXIT",
+ condition = "org.apache.activemq.tests.extras.byteman.OrphanedConsumerTest.isConditionActive()",
+ action = "System.out.println(\"throwing stuff\");throw new InterruptedException()"
+ ),
+ @BMRule
+ (
+ name = "closeEnter",
+ targetClass = "org.apache.activemq.core.server.impl.ServerConsumerImpl",
+ targetMethod = "close",
+ targetLocation = "ENTRY",
+ condition = "org.apache.activemq.tests.extras.byteman.OrphanedConsumerTest.isConditionActive()",
+ action = "org.apache.activemq.tests.extras.byteman.OrphanedConsumerTest.leavingCloseOnTestCountersWhileClosing()"
+ )
+
+ }
+ )
+ public void testOrphanedConsumersByManagement() throws Exception
+ {
+ internalTestOrphanedConsumers(true);
+ }
+
+ /**
+ *
+ * @param useManagement true = it will use a management operation to make the connection failure, false through ping
+ * @throws Exception
+ */
+ private void internalTestOrphanedConsumers(boolean useManagement) throws Exception
+ {
+ final int NUMBER_OF_MESSAGES = 2;
+ server = createServer(true, true);
+ server.start();
+ staticServer = server;
+
+ locator.setBlockOnNonDurableSend(false);
+ locator.setBlockOnDurableSend(false);
+ locator.setBlockOnAcknowledge(true);
+ locator.setConnectionTTL(1000);
+ locator.setClientFailureCheckPeriod(100);
+ locator.setReconnectAttempts(0);
+ // We are not interested on consumer-window-size on this test
+ // We want that every message is delivered
+ // as we asserting for number of consumers available and round-robin on delivery
+ locator.setConsumerWindowSize(-1);
+
+ ClientSessionFactoryImpl sf = (ClientSessionFactoryImpl)createSessionFactory(locator);
+
+ ClientSession session = sf.createSession(true, true, 0);
+
+ session.createQueue("queue", "queue1", true);
+ session.createQueue("queue", "queue2", true);
+
+ ClientProducer prod = session.createProducer("queue");
+
+ ClientConsumer consumer = session.createConsumer("queue1");
+ ClientConsumer consumer2 = session.createConsumer("queue2");
+
+
+ Queue queue1 = server.locateQueue(new SimpleString("queue1"));
+
+ Queue queue2 = server.locateQueue(new SimpleString("queue2"));
+
+ session.start();
+
+
+ if (!useManagement)
+ {
+ sf.stopPingingAfterOne();
+
+ for (long timeout = System.currentTimeMillis() + 6000; timeout > System.currentTimeMillis() && server.getConnectionCount() != 0; )
+ {
+ Thread.sleep(100);
+ }
+
+ // an extra second to avoid races of something closing the session while we are asserting it
+ Thread.sleep(1000);
+ }
+ else
+ {
+ server.getActiveMQServerControl().closeConnectionsForAddress("127.0.0.1");
+ }
+
+ if (verification != null)
+ {
+ throw verification;
+ }
+
+ assertEquals(0, queue1.getConsumerCount());
+ assertEquals(0, queue2.getConsumerCount());
+
+ setConditionActive(false);
+
+ locator = internalCreateNonHALocator(true);
+
+ locator.setBlockOnNonDurableSend(false);
+ locator.setBlockOnDurableSend(false);
+ locator.setBlockOnAcknowledge(true);
+ locator.setReconnectAttempts(0);
+ locator.setConsumerWindowSize(-1);
+
+ sf = (ClientSessionFactoryImpl)locator.createSessionFactory();
+ session = sf.createSession(true, true, 0);
+
+
+ session.start();
+
+
+ prod = session.createProducer("queue");
+
+ for (int i = 0; i < NUMBER_OF_MESSAGES; i++)
+ {
+ ClientMessage message = session.createMessage(true);
+ message.putIntProperty("i", i);
+ prod.send(message);
+ }
+
+ consumer = session.createConsumer("queue1");
+ consumer2 = session.createConsumer("queue2");
+
+ for (int i = 0; i < NUMBER_OF_MESSAGES; i++)
+ {
+ assertNotNull(consumer.receive(5000));
+ assertNotNull(consumer2.receive(5000));
+ }
+
+ session.close();
+ }
+
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/PagingLeakTest.java
----------------------------------------------------------------------
diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/PagingLeakTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/PagingLeakTest.java
new file mode 100644
index 0000000..2da8445
--- /dev/null
+++ b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/PagingLeakTest.java
@@ -0,0 +1,273 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.tests.extras.byteman;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.activemq.api.core.SimpleString;
+import org.apache.activemq.api.core.TransportConfiguration;
+import org.apache.activemq.api.core.client.ClientConsumer;
+import org.apache.activemq.api.core.client.ClientMessage;
+import org.apache.activemq.api.core.client.ClientProducer;
+import org.apache.activemq.api.core.client.ClientSession;
+import org.apache.activemq.api.core.client.ClientSessionFactory;
+import org.apache.activemq.api.core.client.ServerLocator;
+import org.apache.activemq.core.config.Configuration;
+import org.apache.activemq.core.paging.cursor.impl.PagePositionImpl;
+import org.apache.activemq.core.server.ActiveMQServer;
+import org.apache.activemq.core.server.ActiveMQServers;
+import org.apache.activemq.core.settings.impl.AddressFullMessagePolicy;
+import org.apache.activemq.core.settings.impl.AddressSettings;
+import org.apache.activemq.tests.util.ServiceTestBase;
+import org.jboss.byteman.contrib.bmunit.BMRule;
+import org.jboss.byteman.contrib.bmunit.BMRules;
+import org.jboss.byteman.contrib.bmunit.BMUnitRunner;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(BMUnitRunner.class)
+public class PagingLeakTest extends ServiceTestBase
+{
+
+ private static final AtomicInteger pagePosInstances = new AtomicInteger(0);
+
+ public static void newPosition()
+ {
+ pagePosInstances.incrementAndGet();
+ }
+
+ public static void deletePosition()
+ {
+ pagePosInstances.decrementAndGet();
+ }
+
+ @Before
+ public void setup()
+ {
+ pagePosInstances.set(0);
+ }
+
+ @Test
+ @BMRules
+ (
+ rules =
+ {
+ @BMRule
+ (
+ name = "newPosition",
+ targetClass = "org.apache.activemq.core.paging.cursor.impl.PagePositionImpl",
+ targetMethod = "<init>()",
+ targetLocation = "ENTRY",
+ action = "org.apache.activemq.tests.extras.byteman.PagingLeakTest.newPosition()"
+ ),
+ @BMRule
+ (
+ name = "finalPosition",
+ targetClass = "org.apache.activemq.core.paging.cursor.impl.PagePositionImpl",
+ targetMethod = "finalize",
+ targetLocation = "ENTRY",
+ action = "org.apache.activemq.tests.extras.byteman.PagingLeakTest.deletePosition()"
+ )
+ }
+ )
+ public void testValidateLeak() throws Throwable
+ {
+
+ List<PagePositionImpl> positions = new ArrayList<PagePositionImpl>();
+
+ for (int i = 0; i < 300; i++)
+ {
+ positions.add(new PagePositionImpl(3, 3));
+ }
+
+ long timeout = System.currentTimeMillis() + 5000;
+ while (pagePosInstances.get() != 300 && timeout > System.currentTimeMillis())
+ {
+ forceGC();
+ }
+
+ // This is just to validate the rules are correctly applied on byteman
+ assertEquals("You have changed something on PagePositionImpl in such way that these byteman rules are no longer working", 300, pagePosInstances.get());
+
+ positions.clear();
+
+ timeout = System.currentTimeMillis() + 5000;
+ while (pagePosInstances.get() != 0 && timeout > System.currentTimeMillis())
+ {
+ forceGC();
+ }
+
+ // This is just to validate the rules are correctly applied on byteman
+ assertEquals("You have changed something on PagePositionImpl in such way that these byteman rules are no longer working", 0, pagePosInstances.get());
+
+ final ArrayList<Exception> errors = new ArrayList<Exception>();
+ // A backup that will be waiting to be activated
+ Configuration conf = createDefaultConfig(true)
+ .setSecurityEnabled(false)
+ .addConnectorConfiguration("invm", new TransportConfiguration(INVM_CONNECTOR_FACTORY));
+
+ final ActiveMQServer server = ActiveMQServers.newActiveMQServer(conf, true);
+ addServer(server);
+
+
+ server.start();
+
+
+ AddressSettings settings = new AddressSettings();
+ settings.setPageSizeBytes(20 * 1024);
+ settings.setMaxSizeBytes(200 * 1024);
+ settings.setAddressFullMessagePolicy(AddressFullMessagePolicy.PAGE);
+
+
+ server.getAddressSettingsRepository().addMatch("#", settings);
+
+
+ final SimpleString address = new SimpleString("pgdAddress");
+
+ class Consumer extends Thread
+ {
+ final ServerLocator locator;
+ final ClientSessionFactory sf;
+ final ClientSession session;
+ final ClientConsumer consumer;
+
+ final int sleepTime;
+ final int maxConsumed;
+
+ Consumer(int sleepTime, String suffix, int maxConsumed) throws Exception
+ {
+
+ server.createQueue(address, address.concat(suffix), null, true, false);
+
+ this.sleepTime = sleepTime;
+ locator = createInVMLocator(0);
+ sf = locator.createSessionFactory();
+ session = sf.createSession(true, true);
+ consumer = session.createConsumer(address.concat(suffix));
+
+ this.maxConsumed = maxConsumed;
+ }
+
+ public void run()
+ {
+ try
+ {
+ session.start();
+
+ long lastTime = System.currentTimeMillis();
+
+ for (long i = 0; i < maxConsumed; i++)
+ {
+ ClientMessage msg = consumer.receive(5000);
+
+ if (msg == null)
+ {
+ errors.add(new Exception("didn't receive a message"));
+ return;
+ }
+
+ msg.acknowledge();
+
+
+ if (sleepTime > 0)
+ {
+
+ Thread.sleep(sleepTime);
+ }
+
+ if (i % 1000 == 0)
+ {
+ System.out.println("Consumed " + i + " events in " + (System.currentTimeMillis() - lastTime));
+ lastTime = System.currentTimeMillis();
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+
+
+ int numberOfMessages = 10000;
+
+ Consumer consumer1 = new Consumer(100, "-1", 150);
+ Consumer consumer2 = new Consumer(0, "-2", numberOfMessages);
+
+ final ServerLocator locator = createInVMLocator(0);
+ final ClientSessionFactory sf = locator.createSessionFactory();
+ final ClientSession session = sf.createSession(true, true);
+ final ClientProducer producer = session.createProducer(address);
+
+
+ byte[] b = new byte[1024];
+
+
+ for (long i = 0; i < numberOfMessages; i++)
+ {
+ ClientMessage msg = session.createMessage(true);
+ msg.getBodyBuffer().writeBytes(b);
+ producer.send(msg);
+
+ if (i == 1000)
+ {
+ System.out.println("Starting consumers!!!");
+ consumer1.start();
+ consumer2.start();
+ }
+
+ if (i % 1000 == 0)
+ {
+ validateInstances();
+ }
+
+ }
+
+
+ consumer1.join();
+ consumer2.join();
+
+ validateInstances();
+ Throwable elast = null;
+
+ for (Throwable e : errors)
+ {
+ e.printStackTrace();
+ elast = e;
+ }
+
+ if (elast != null)
+ {
+ throw elast;
+ }
+
+ }
+
+ private void validateInstances()
+ {
+ forceGC();
+ int count2 = pagePosInstances.get();
+ Assert.assertTrue("There is a leak, you shouldn't have this many instances (" + count2 + ")", count2 < 5000);
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/ReplicationBackupTest.java
----------------------------------------------------------------------
diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/ReplicationBackupTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/ReplicationBackupTest.java
new file mode 100644
index 0000000..15c987c
--- /dev/null
+++ b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/ReplicationBackupTest.java
@@ -0,0 +1,121 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.tests.extras.byteman;
+
+import java.util.concurrent.CountDownLatch;
+
+import org.apache.activemq.api.config.ActiveMQDefaultConfiguration;
+import org.apache.activemq.api.core.TransportConfiguration;
+import org.apache.activemq.core.config.Configuration;
+import org.apache.activemq.core.server.ActiveMQServer;
+import org.apache.activemq.tests.util.ReplicatedBackupUtils;
+import org.apache.activemq.tests.util.ServiceTestBase;
+import org.apache.activemq.tests.util.TransportConfigurationUtils;
+import org.jboss.byteman.contrib.bmunit.BMRule;
+import org.jboss.byteman.contrib.bmunit.BMRules;
+import org.jboss.byteman.contrib.bmunit.BMUnitRunner;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(BMUnitRunner.class)
+public class ReplicationBackupTest extends ServiceTestBase
+{
+ private static final CountDownLatch ruleFired = new CountDownLatch(1);
+ private ActiveMQServer backupServer;
+ private ActiveMQServer liveServer;
+
+ /*
+ * simple test to induce a potential race condition where the server's acceptors are active, but the server's
+ * state != STARTED
+ */
+ @Test
+ @BMRules
+ (
+ rules =
+ {
+ @BMRule
+ (
+ name = "prevent backup annoucement",
+ targetClass = "org.apache.activemq.core.server.impl.SharedNothingLiveActivation",
+ targetMethod = "run",
+ targetLocation = "AT EXIT",
+ action = "org.apache.activemq.tests.extras.byteman.ReplicationBackupTest.breakIt();"
+ )
+ }
+ )
+ public void testReplicatedBackupAnnouncement() throws Exception
+ {
+ TransportConfiguration liveConnector = TransportConfigurationUtils.getNettyConnector(true, 0);
+ TransportConfiguration liveAcceptor = TransportConfigurationUtils.getNettyAcceptor(true, 0);
+ TransportConfiguration backupConnector = TransportConfigurationUtils.getNettyConnector(false, 0);
+ TransportConfiguration backupAcceptor = TransportConfigurationUtils.getNettyAcceptor(false, 0);
+
+ final String suffix = "_backup";
+
+ Configuration backupConfig = createDefaultConfig()
+ .setBindingsDirectory(ActiveMQDefaultConfiguration.getDefaultBindingsDirectory() + suffix)
+ .setJournalDirectory(ActiveMQDefaultConfiguration.getDefaultJournalDir() + suffix)
+ .setPagingDirectory(ActiveMQDefaultConfiguration.getDefaultPagingDir() + suffix)
+ .setLargeMessagesDirectory(ActiveMQDefaultConfiguration.getDefaultLargeMessagesDir() + suffix);
+
+ Configuration liveConfig = createDefaultConfig();
+
+ ReplicatedBackupUtils.configureReplicationPair(backupConfig, backupConnector, backupAcceptor, liveConfig, liveConnector, liveAcceptor);
+
+ liveServer = createServer(liveConfig);
+
+ // start the live server in a new thread so we can start the backup simultaneously to induce a potential race
+ Thread startThread = new Thread(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ try
+ {
+ liveServer.start();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ });
+ startThread.start();
+
+ ruleFired.await();
+
+ backupServer = createServer(backupConfig);
+ backupServer.start();
+ ServiceTestBase.waitForRemoteBackup(null, 3, true, backupServer);
+ }
+
+ public static void breakIt()
+ {
+ ruleFired.countDown();
+ try
+ {
+ /* before the fix this sleep would put the "live" server into a state where the acceptors were started
+ * but the server's state != STARTED which would cause the backup to fail to announce
+ */
+ Thread.sleep(2000);
+ }
+ catch (InterruptedException e)
+ {
+ e.printStackTrace();
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/ScaleDownFailoverTest.java
----------------------------------------------------------------------
diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/ScaleDownFailoverTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/ScaleDownFailoverTest.java
new file mode 100644
index 0000000..d06b093
--- /dev/null
+++ b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/ScaleDownFailoverTest.java
@@ -0,0 +1,200 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.tests.extras.byteman;
+
+import org.apache.activemq.api.core.TransportConfiguration;
+import org.apache.activemq.api.core.client.ClientMessage;
+import org.apache.activemq.core.config.ScaleDownConfiguration;
+import org.apache.activemq.core.config.ha.LiveOnlyPolicyConfiguration;
+import org.apache.activemq.core.remoting.impl.netty.TransportConstants;
+import org.apache.activemq.core.server.ActiveMQServer;
+import org.apache.activemq.tests.integration.cluster.distribution.ClusterTestBase;
+import org.jboss.byteman.contrib.bmunit.BMRule;
+import org.jboss.byteman.contrib.bmunit.BMUnitRunner;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(BMUnitRunner.class)
+public class ScaleDownFailoverTest extends ClusterTestBase
+{
+ protected static int stopCount = 0;
+ private static ActiveMQServer[] staticServers;
+
+ @Override
+ @Before
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ stopCount = 0;
+ setupLiveServer(0, isFileStorage(), false, isNetty(), true);
+ setupLiveServer(1, isFileStorage(), false, isNetty(), true);
+ setupLiveServer(2, isFileStorage(), false, isNetty(), true);
+ ScaleDownConfiguration scaleDownConfiguration = new ScaleDownConfiguration();
+ ScaleDownConfiguration scaleDownConfiguration2 = new ScaleDownConfiguration();
+ scaleDownConfiguration2.setEnabled(false);
+ ScaleDownConfiguration scaleDownConfiguration3 = new ScaleDownConfiguration();
+ scaleDownConfiguration3.setEnabled(false);
+ ((LiveOnlyPolicyConfiguration) servers[0].getConfiguration().getHAPolicyConfiguration()).setScaleDownConfiguration(scaleDownConfiguration);
+ ((LiveOnlyPolicyConfiguration) servers[1].getConfiguration().getHAPolicyConfiguration()).setScaleDownConfiguration(scaleDownConfiguration2);
+ ((LiveOnlyPolicyConfiguration) servers[2].getConfiguration().getHAPolicyConfiguration()).setScaleDownConfiguration(scaleDownConfiguration3);
+ if (isGrouped())
+ {
+ scaleDownConfiguration.setGroupName("bill");
+ scaleDownConfiguration2.setGroupName("bill");
+ scaleDownConfiguration3.setGroupName("bill");
+ }
+ staticServers = servers;
+ setupClusterConnection("cluster0", "queues", false, 1, isNetty(), 0, 1, 2);
+ setupClusterConnection("cluster1", "queues", false, 1, isNetty(), 1, 0, 2);
+ setupClusterConnection("cluster2", "queues", false, 1, isNetty(), 2, 0, 1);
+ scaleDownConfiguration.getConnectors().addAll(servers[0].getConfiguration().getClusterConfigurations().iterator().next().getStaticConnectors());
+ scaleDownConfiguration2.getConnectors().addAll(servers[1].getConfiguration().getClusterConfigurations().iterator().next().getStaticConnectors());
+ scaleDownConfiguration3.getConnectors().addAll(servers[2].getConfiguration().getClusterConfigurations().iterator().next().getStaticConnectors());
+
+ startServers(0, 1, 2);
+ setupSessionFactory(0, isNetty());
+ setupSessionFactory(1, isNetty());
+ setupSessionFactory(2, isNetty());
+ }
+
+ protected boolean isNetty()
+ {
+ return true;
+ }
+
+ protected boolean isGrouped()
+ {
+ return false;
+ }
+
+ @Override
+ @After
+ public void tearDown() throws Exception
+ {
+ closeAllConsumers();
+ closeAllSessionFactories();
+ closeAllServerLocatorsFactories();
+ stopServers(0, 1, 2);
+ super.tearDown();
+ }
+
+
+ @Test
+ @BMRule
+ (
+ name = "blow-up",
+ targetClass = "org.apache.activemq.api.core.client.ServerLocator",
+ targetMethod = "createSessionFactory(org.apache.activemq.api.core.TransportConfiguration, int, boolean)",
+ isInterface = true,
+ targetLocation = "ENTRY",
+ action = "org.apache.activemq.tests.extras.byteman.ScaleDownFailoverTest.fail($1);"
+ )
+ public void testScaleDownWhenFirstServerFails() throws Exception
+ {
+ final int TEST_SIZE = 2;
+ final String addressName = "testAddress";
+ final String queueName1 = "testQueue1";
+ final String queueName2 = "testQueue2";
+
+ // create 2 queues on each node mapped to the same address
+ createQueue(0, addressName, queueName1, null, false);
+ createQueue(0, addressName, queueName2, null, false);
+ createQueue(1, addressName, queueName1, null, false);
+ createQueue(1, addressName, queueName2, null, false);
+ createQueue(2, addressName, queueName1, null, false);
+ createQueue(2, addressName, queueName2, null, false);
+
+ // send messages to node 0
+ send(0, addressName, TEST_SIZE, false, null);
+
+ // consume a message from node 0
+ addConsumer(0, 0, queueName2, null);
+ ClientMessage clientMessage = consumers[0].getConsumer().receive(250);
+ Assert.assertNotNull(clientMessage);
+ clientMessage.acknowledge();
+ removeConsumer(0);
+
+ servers[0].stop();
+
+ // verify that at least one server stopped
+ Assert.assertTrue(!servers[1].isStarted() || !servers[2].isStarted());
+
+ int remainingServer;
+ if (servers[1].isStarted())
+ remainingServer = 1;
+ else
+ remainingServer = 2;
+
+ // get the 2 messages from queue 1
+ addConsumer(0, remainingServer, queueName1, null);
+ clientMessage = consumers[0].getConsumer().receive(250);
+ Assert.assertNotNull(clientMessage);
+ clientMessage.acknowledge();
+ clientMessage = consumers[0].getConsumer().receive(250);
+ Assert.assertNotNull(clientMessage);
+ clientMessage.acknowledge();
+
+ // ensure there are no more messages on queue 1
+ clientMessage = consumers[0].getConsumer().receive(250);
+ Assert.assertNull(clientMessage);
+ removeConsumer(0);
+
+ // get the 1 message from queue 2
+ addConsumer(0, remainingServer, queueName2, null);
+ clientMessage = consumers[0].getConsumer().receive(250);
+ Assert.assertNotNull(clientMessage);
+ clientMessage.acknowledge();
+
+ // ensure there are no more messages on queue 1
+ clientMessage = consumers[0].getConsumer().receive(250);
+ Assert.assertNull(clientMessage);
+ removeConsumer(0);
+ }
+
+ public static void fail(TransportConfiguration tc)
+ {
+ // only kill one server
+ if (stopCount == 0)
+ {
+ try
+ {
+ for (ActiveMQServer activeMQServer : staticServers)
+ {
+ if (activeMQServer != null)
+ {
+ for (TransportConfiguration transportConfiguration : activeMQServer.getConfiguration().getAcceptorConfigurations())
+ {
+ if (transportConfiguration.getParams().get(TransportConstants.PORT_PROP_NAME).equals(tc.getParams().get(TransportConstants.PORT_PROP_NAME)))
+ {
+ activeMQServer.stop();
+ stopCount++;
+ System.out.println("Stopping server listening at: " + tc.getParams().get(TransportConstants.PORT_PROP_NAME));
+ }
+ }
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/ScaleDownFailureTest.java
----------------------------------------------------------------------
diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/ScaleDownFailureTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/ScaleDownFailureTest.java
new file mode 100644
index 0000000..fbf46f1
--- /dev/null
+++ b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/ScaleDownFailureTest.java
@@ -0,0 +1,117 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.tests.extras.byteman;
+
+import org.apache.activemq.api.core.client.ClientMessage;
+import org.apache.activemq.core.config.ScaleDownConfiguration;
+import org.apache.activemq.core.config.ha.LiveOnlyPolicyConfiguration;
+import org.apache.activemq.tests.integration.cluster.distribution.ClusterTestBase;
+import org.jboss.byteman.contrib.bmunit.BMRule;
+import org.jboss.byteman.contrib.bmunit.BMUnitRunner;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(BMUnitRunner.class)
+public class ScaleDownFailureTest extends ClusterTestBase
+{
+ @Override
+ @Before
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ setupLiveServer(0, isFileStorage(), false, isNetty(), true);
+ setupLiveServer(1, isFileStorage(), false, isNetty(), true);
+ if (isGrouped())
+ {
+ ScaleDownConfiguration scaleDownConfiguration = new ScaleDownConfiguration();
+ scaleDownConfiguration.setGroupName("bill");
+ ((LiveOnlyPolicyConfiguration) servers[0].getConfiguration().getHAPolicyConfiguration()).setScaleDownConfiguration(scaleDownConfiguration);
+ ((LiveOnlyPolicyConfiguration) servers[1].getConfiguration().getHAPolicyConfiguration()).setScaleDownConfiguration(scaleDownConfiguration);
+ }
+ setupClusterConnection("cluster0", "queues", false, 1, isNetty(), 0, 1);
+ setupClusterConnection("cluster1", "queues", false, 1, isNetty(), 1, 0);
+ startServers(0, 1);
+ setupSessionFactory(0, isNetty());
+ setupSessionFactory(1, isNetty());
+ }
+
+ protected boolean isNetty()
+ {
+ return true;
+ }
+
+ protected boolean isGrouped()
+ {
+ return false;
+ }
+
+ @Override
+ @After
+ public void tearDown() throws Exception
+ {
+ closeAllConsumers();
+ closeAllSessionFactories();
+ closeAllServerLocatorsFactories();
+ ((LiveOnlyPolicyConfiguration) servers[0].getConfiguration().getHAPolicyConfiguration()).setScaleDownConfiguration(null);
+ stopServers(0, 1);
+ super.tearDown();
+ }
+
+ @Test
+ @BMRule
+ (
+ name = "blow-up",
+ targetClass = "org.apache.activemq.api.core.client.ServerLocator",
+ targetMethod = "createSessionFactory(org.apache.activemq.api.core.TransportConfiguration, int, boolean)",
+ isInterface = true,
+ targetLocation = "ENTRY",
+ action = "throw new Exception()"
+ )
+ public void testScaleDownWhenRemoteServerIsUnavailable() throws Exception
+ {
+ final int TEST_SIZE = 1;
+ final String addressName = "testAddress";
+ final String queueName1 = "testQueue1";
+ final String queueName2 = "testQueue2";
+
+ // create 2 queues on each node mapped to the same address
+ createQueue(0, addressName, queueName1, null, false);
+ createQueue(0, addressName, queueName2, null, false);
+ createQueue(1, addressName, queueName1, null, false);
+ createQueue(1, addressName, queueName2, null, false);
+
+ // send messages to node 0
+ send(0, addressName, TEST_SIZE, false, null);
+
+ // consume a message from node 0
+ addConsumer(0, 0, queueName2, null, false);
+ ClientMessage clientMessage = consumers[0].getConsumer().receive();
+ Assert.assertNotNull(clientMessage);
+ clientMessage.acknowledge();
+ consumers[0].getSession().commit();
+ removeConsumer(0);
+
+ servers[0].stop();
+
+ addConsumer(0, 1, queueName1, null);
+ clientMessage = consumers[0].getConsumer().receive(250);
+ Assert.assertNull(clientMessage);
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/ScaleDownGroupedFailoverTest.java
----------------------------------------------------------------------
diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/ScaleDownGroupedFailoverTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/ScaleDownGroupedFailoverTest.java
new file mode 100644
index 0000000..e86d4d6
--- /dev/null
+++ b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/ScaleDownGroupedFailoverTest.java
@@ -0,0 +1,25 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.tests.extras.byteman;
+
+public class ScaleDownGroupedFailoverTest extends ScaleDownFailoverTest
+{
+ protected boolean isGrouped()
+ {
+ return true;
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/ScaleDownGroupedFailureTest.java
----------------------------------------------------------------------
diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/ScaleDownGroupedFailureTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/ScaleDownGroupedFailureTest.java
new file mode 100644
index 0000000..87dd577
--- /dev/null
+++ b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/ScaleDownGroupedFailureTest.java
@@ -0,0 +1,25 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.tests.extras.byteman;
+
+public class ScaleDownGroupedFailureTest extends ScaleDownFailureTest
+{
+ protected boolean isGrouped()
+ {
+ return true;
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/StartStopDeadlockTest.java
----------------------------------------------------------------------
diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/StartStopDeadlockTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/StartStopDeadlockTest.java
new file mode 100644
index 0000000..fa8dfdc
--- /dev/null
+++ b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/StartStopDeadlockTest.java
@@ -0,0 +1,170 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.tests.extras.byteman;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.activemq.api.core.TransportConfiguration;
+import org.apache.activemq.core.config.Configuration;
+import org.apache.activemq.core.config.ha.SharedStoreMasterPolicyConfiguration;
+import org.apache.activemq.core.config.ha.SharedStoreSlavePolicyConfiguration;
+import org.apache.activemq.core.registry.JndiBindingRegistry;
+import org.apache.activemq.core.server.ActiveMQServer;
+import org.apache.activemq.core.server.ActiveMQServers;
+import org.apache.activemq.jms.server.impl.JMSServerManagerImpl;
+import org.apache.activemq.tests.unit.util.InVMNamingContext;
+import org.apache.activemq.tests.util.ServiceTestBase;
+import org.jboss.byteman.contrib.bmunit.BMRule;
+import org.jboss.byteman.contrib.bmunit.BMRules;
+import org.jboss.byteman.contrib.bmunit.BMUnitRunner;
+import org.junit.After;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * This test validates a deadlock identified by https://bugzilla.redhat.com/show_bug.cgi?id=959616
+ *
+ * @author Clebert
+ */
+@RunWith(BMUnitRunner.class)
+public class StartStopDeadlockTest extends ServiceTestBase
+{
+ /*
+ * simple test to make sure connect still works with some network latency built into netty
+ * */
+ @Test
+ @BMRules
+ (
+
+ rules =
+ {
+ @BMRule
+ (
+ name = "Server.start wait-init",
+ targetClass = "org.apache.activemq.core.server.impl.ActiveMQServerImpl",
+ targetMethod = "initialisePart2",
+ targetLocation = "ENTRY",
+ condition = "incrementCounter(\"server-Init\") == 2",
+ action = "System.out.println(\"server backup init\"), waitFor(\"start-init\")"
+ ),
+ @BMRule(
+ name = "JMSServer.stop wait-init",
+ targetClass = "org.apache.activemq.jms.server.impl.JMSServerManagerImpl",
+ targetMethod = "stop",
+ targetLocation = "ENTRY",
+ action = "signalWake(\"start-init\", true)"
+ ),
+ @BMRule(
+ name = "StartStopDeadlockTest tearDown",
+ targetClass = "org.apache.activemq.tests.extras.byteman.StartStopDeadlockTest",
+ targetMethod = "tearDown",
+ targetLocation = "ENTRY",
+ action = "deleteCounter(\"server-Init\")"
+ )
+ }
+ )
+ public void testDeadlock() throws Exception
+ {
+
+ // A live server that will always be crashed
+ Configuration confLive = createDefaultConfig(true)
+ .setSecurityEnabled(false)
+ .setHAPolicyConfiguration(new SharedStoreMasterPolicyConfiguration())
+ .addConnectorConfiguration("invm", new TransportConfiguration(INVM_CONNECTOR_FACTORY));
+ final ActiveMQServer serverLive = ActiveMQServers.newActiveMQServer(confLive);
+ serverLive.start();
+ addServer(serverLive);
+
+
+ // A backup that will be waiting to be activated
+ Configuration conf = createDefaultConfig(true)
+ .setSecurityEnabled(false)
+ .setHAPolicyConfiguration(new SharedStoreSlavePolicyConfiguration())
+ .addConnectorConfiguration("invm", new TransportConfiguration(INVM_CONNECTOR_FACTORY));
+
+ final ActiveMQServer server = ActiveMQServers.newActiveMQServer(conf, true);
+ addServer(server);
+
+ final JMSServerManagerImpl jmsServer = new JMSServerManagerImpl(server);
+ final InVMNamingContext context = new InVMNamingContext();
+ jmsServer.setRegistry(new JndiBindingRegistry(context));
+
+ jmsServer.start();
+
+ final AtomicInteger errors = new AtomicInteger(0);
+ final CountDownLatch align = new CountDownLatch(2);
+ final CountDownLatch startLatch = new CountDownLatch(1);
+
+
+ Thread tCrasher = new Thread("tStart")
+ {
+ @Override
+ public void run()
+ {
+ try
+ {
+ align.countDown();
+ startLatch.await();
+ System.out.println("Crashing....");
+ serverLive.stop(true);
+ }
+ catch (Exception e)
+ {
+ errors.incrementAndGet();
+ e.printStackTrace();
+ }
+ }
+ };
+
+ Thread tStop = new Thread("tStop")
+ {
+ @Override
+ public void run()
+ {
+ try
+ {
+ align.countDown();
+ startLatch.await();
+ jmsServer.stop();
+ }
+ catch (Exception e)
+ {
+ errors.incrementAndGet();
+ e.printStackTrace();
+ }
+ }
+ };
+
+ tCrasher.start();
+ tStop.start();
+ align.await();
+ startLatch.countDown();
+
+ tCrasher.join();
+ tStop.join();
+
+ assertEquals(0, errors.get());
+ }
+
+ @Override
+ @After
+ public void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/StompInternalStateTest.java
----------------------------------------------------------------------
diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/StompInternalStateTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/StompInternalStateTest.java
new file mode 100644
index 0000000..12037f4
--- /dev/null
+++ b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/StompInternalStateTest.java
@@ -0,0 +1,146 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.tests.extras.byteman;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.activemq.api.core.TransportConfiguration;
+import org.apache.activemq.api.core.client.ClientSession;
+import org.apache.activemq.api.core.client.ClientSessionFactory;
+import org.apache.activemq.api.core.client.ServerLocator;
+import org.apache.activemq.api.core.management.CoreNotificationType;
+import org.apache.activemq.core.config.Configuration;
+import org.apache.activemq.core.protocol.stomp.StompProtocolManagerFactory;
+import org.apache.activemq.core.remoting.impl.invm.InVMAcceptorFactory;
+import org.apache.activemq.core.remoting.impl.netty.NettyAcceptorFactory;
+import org.apache.activemq.core.remoting.impl.netty.TransportConstants;
+import org.apache.activemq.core.server.ActiveMQServer;
+import org.apache.activemq.core.server.management.Notification;
+import org.apache.activemq.tests.util.ServiceTestBase;
+import org.jboss.byteman.contrib.bmunit.BMRule;
+import org.jboss.byteman.contrib.bmunit.BMRules;
+import org.jboss.byteman.contrib.bmunit.BMUnitRunner;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(BMUnitRunner.class)
+public class StompInternalStateTest extends ServiceTestBase
+{
+ private static final String STOMP_QUEUE_NAME = "jms.queue.StompTestQueue";
+
+ private static volatile String resultTestStompProtocolManagerLeak = null;
+
+ protected ActiveMQServer server = null;
+
+ @Test
+ @BMRules
+ (
+ rules =
+ {
+ @BMRule
+ (
+ name = "StompProtocolManager Leak Server Rule",
+ targetClass = "org.apache.activemq.core.protocol.stomp.StompProtocolManager",
+ targetMethod = "onNotification(org.apache.activemq.core.server.management.Notification)",
+ targetLocation = "EXIT",
+ helper = "org.apache.activemq.tests.extras.byteman.StompInternalStateTest",
+ action = "verifyBindingAddRemove($1, $0.destinations)"
+ )
+ }
+ )
+ public void testStompProtocolManagerLeak() throws Exception
+ {
+ ClientSession session = null;
+ try
+ {
+ assertNull(resultTestStompProtocolManagerLeak);
+ ServerLocator locator = createNettyNonHALocator();
+ ClientSessionFactory factory = createSessionFactory(locator);
+ session = factory.createSession();
+ session.createTemporaryQueue(STOMP_QUEUE_NAME, STOMP_QUEUE_NAME);
+ session.deleteQueue(STOMP_QUEUE_NAME);
+
+ assertNull(resultTestStompProtocolManagerLeak);
+ }
+ finally
+ {
+ if (session != null)
+ {
+ session.close();
+ }
+ }
+ }
+
+ @Override
+ protected Configuration createDefaultConfig(final boolean netty) throws Exception
+ {
+ Configuration config = super.createDefaultConfig(netty)
+ .setSecurityEnabled(false)
+ .setPersistenceEnabled(false);
+
+ Map<String, Object> params = new HashMap<String, Object>();
+ params.put(TransportConstants.PROTOCOLS_PROP_NAME, StompProtocolManagerFactory.STOMP_PROTOCOL_NAME);
+ params.put(TransportConstants.PORT_PROP_NAME, TransportConstants.DEFAULT_STOMP_PORT);
+ params.put(TransportConstants.STOMP_CONSUMERS_CREDIT, "-1");
+ TransportConfiguration stompTransport = new TransportConfiguration(NettyAcceptorFactory.class.getName(), params);
+ config.getAcceptorConfigurations().add(stompTransport);
+ config.getAcceptorConfigurations().add(new TransportConfiguration(InVMAcceptorFactory.class.getName()));
+
+ return config;
+ }
+
+ @SuppressWarnings("unchecked")
+ public void verifyBindingAddRemove(Notification noti, Object obj)
+ {
+ Set<String> destinations = (Set<String>)obj;
+ if (noti.getType() == CoreNotificationType.BINDING_ADDED)
+ {
+ if (!destinations.contains(STOMP_QUEUE_NAME))
+ {
+ resultTestStompProtocolManagerLeak += "didn't save the queue when binding added " + destinations;
+ }
+ }
+ else if (noti.getType() == CoreNotificationType.BINDING_REMOVED)
+ {
+ if (destinations.contains(STOMP_QUEUE_NAME))
+ {
+ resultTestStompProtocolManagerLeak = "didn't remove the queue when binding removed " + destinations;
+ }
+ }
+ }
+
+ @Override
+ @Before
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ server = createServer(createDefaultConfig(true));
+ server.start();
+ }
+
+ @Override
+ @After
+ public void tearDown() throws Exception
+ {
+ server.stop();
+ super.tearDown();
+ }
+}
[06/15] activemq-6 git commit: Refactored the testsuite a bit
Posted by jb...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/jms/bridge/JMSBridgeTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/jms/bridge/JMSBridgeTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/jms/bridge/JMSBridgeTest.java
deleted file mode 100644
index 474c126..0000000
--- a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/jms/bridge/JMSBridgeTest.java
+++ /dev/null
@@ -1,2449 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.tests.integration.jms.bridge;
-
-import javax.jms.Connection;
-import javax.jms.DeliveryMode;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
-import java.lang.management.ManagementFactory;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.activemq.api.jms.ActiveMQJMSConstants;
-import org.apache.activemq.jms.bridge.ConnectionFactoryFactory;
-import org.apache.activemq.jms.bridge.QualityOfServiceMode;
-import org.apache.activemq.jms.bridge.impl.JMSBridgeImpl;
-import org.apache.activemq.jms.client.ActiveMQMessage;
-import org.apache.activemq.service.extensions.ServiceUtils;
-import org.apache.activemq.tests.integration.IntegrationTestLogger;
-import org.apache.activemq.tests.integration.ra.DummyTransactionManager;
-import org.apache.activemq.utils.DefaultSensitiveStringCodec;
-import org.junit.Assert;
-import org.junit.Test;
-
-/**
- * A JMSBridgeTest
- *
- * @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
- */
-public class JMSBridgeTest extends BridgeTestBase
-{
- private static final IntegrationTestLogger log = IntegrationTestLogger.LOGGER;
-
- // MaxBatchSize but no MaxBatchTime
-
- @Test
- public void testNoMaxBatchTime_AtMostOnce_P() throws Exception
- {
- testNoMaxBatchTime(QualityOfServiceMode.AT_MOST_ONCE, true);
- }
-
- @Test
- public void testNoMaxBatchTime_DuplicatesOk_P() throws Exception
- {
- testNoMaxBatchTime(QualityOfServiceMode.DUPLICATES_OK, true);
- }
-
- @Test
- public void testNoMaxBatchTime_OnceAndOnlyOnce_P() throws Exception
- {
- testNoMaxBatchTime(QualityOfServiceMode.ONCE_AND_ONLY_ONCE, true);
- }
-
- @Test
- public void testNoMaxBatchTime_AtMostOnce_NP() throws Exception
- {
- testNoMaxBatchTime(QualityOfServiceMode.AT_MOST_ONCE, false);
- }
-
- @Test
- public void testNoMaxBatchTime_DuplicatesOk_NP() throws Exception
- {
- testNoMaxBatchTime(QualityOfServiceMode.DUPLICATES_OK, false);
- }
-
- @Test
- public void testNoMaxBatchTime_OnceAndOnlyOnce_NP() throws Exception
- {
- testNoMaxBatchTime(QualityOfServiceMode.ONCE_AND_ONLY_ONCE, false);
- }
-
- // Same server
-
- // MaxBatchSize but no MaxBatchTime
-
- @Test
- public void testNoMaxBatchTimeSameServer_AtMostOnce_P() throws Exception
- {
- testNoMaxBatchTimeSameServer(QualityOfServiceMode.AT_MOST_ONCE, true);
- }
-
- @Test
- public void testNoMaxBatchTimeSameServer_DuplicatesOk_P() throws Exception
- {
- testNoMaxBatchTimeSameServer(QualityOfServiceMode.DUPLICATES_OK, true);
- }
-
- @Test
- public void testNoMaxBatchTimeSameServer_OnceAndOnlyOnce_P() throws Exception
- {
- testNoMaxBatchTimeSameServer(QualityOfServiceMode.ONCE_AND_ONLY_ONCE, true);
- }
-
- @Test
- public void testNoMaxBatchTimeSameServer_AtMostOnce_NP() throws Exception
- {
- testNoMaxBatchTimeSameServer(QualityOfServiceMode.AT_MOST_ONCE, false);
- }
-
- @Test
- public void testNoMaxBatchTimeSameServer_DuplicatesOk_NP() throws Exception
- {
- testNoMaxBatchTimeSameServer(QualityOfServiceMode.DUPLICATES_OK, false);
- }
-
- @Test
- public void testNoMaxBatchTimeSameServer_OnceAndOnlyOnce_NP() throws Exception
- {
- testNoMaxBatchTimeSameServer(QualityOfServiceMode.ONCE_AND_ONLY_ONCE, false);
- }
-
- // MaxBatchTime but no MaxBatchSize
-
- @Test
- public void testMaxBatchTime_AtMostOnce_P() throws Exception
- {
- testMaxBatchTime(QualityOfServiceMode.AT_MOST_ONCE, true);
- }
-
- @Test
- public void testMaxBatchTime_DuplicatesOk_P() throws Exception
- {
- testMaxBatchTime(QualityOfServiceMode.DUPLICATES_OK, true);
- }
-
- @Test
- public void testMaxBatchTime_OnceAndOnlyOnce_P() throws Exception
- {
- testMaxBatchTime(QualityOfServiceMode.ONCE_AND_ONLY_ONCE, true);
- }
-
- @Test
- public void testMaxBatchTime_AtMostOnce_NP() throws Exception
- {
- testMaxBatchTime(QualityOfServiceMode.AT_MOST_ONCE, false);
- }
-
- @Test
- public void testMaxBatchTime_DuplicatesOk_NP() throws Exception
- {
- testMaxBatchTime(QualityOfServiceMode.DUPLICATES_OK, false);
- }
-
- @Test
- public void testMaxBatchTime_OnceAndOnlyOnce_NP() throws Exception
- {
- testMaxBatchTime(QualityOfServiceMode.ONCE_AND_ONLY_ONCE, false);
- }
-
- // Same server
-
- // MaxBatchTime but no MaxBatchSize
-
- @Test
- public void testMaxBatchTimeSameServer_AtMostOnce_P() throws Exception
- {
- testMaxBatchTimeSameServer(QualityOfServiceMode.AT_MOST_ONCE, true);
- }
-
- @Test
- public void testMaxBatchTimeSameServer_DuplicatesOk_P() throws Exception
- {
- testMaxBatchTimeSameServer(QualityOfServiceMode.DUPLICATES_OK, true);
- }
-
- @Test
- public void testMaxBatchTimeSameServer_OnceAndOnlyOnce_P() throws Exception
- {
- testMaxBatchTimeSameServer(QualityOfServiceMode.ONCE_AND_ONLY_ONCE, true);
- }
-
- @Test
- public void testMaxBatchTimeSameServer_AtMostOnce_NP() throws Exception
- {
- testMaxBatchTimeSameServer(QualityOfServiceMode.AT_MOST_ONCE, false);
- }
-
- @Test
- public void testMaxBatchTimeSameServer_DuplicatesOk_NP() throws Exception
- {
- testMaxBatchTimeSameServer(QualityOfServiceMode.DUPLICATES_OK, false);
- }
-
- @Test
- public void testMaxBatchTimeSameServer_OnceAndOnlyOnce_NP() throws Exception
- {
- testMaxBatchTimeSameServer(QualityOfServiceMode.ONCE_AND_ONLY_ONCE, false);
- }
-
- // Stress with batch size of 50
-
- @Test
- public void testStress_AtMostOnce_P_50() throws Exception
- {
- testStress(QualityOfServiceMode.AT_MOST_ONCE, true, 50);
- }
-
- @Test
- public void testStress_DuplicatesOk_P_50() throws Exception
- {
- testStress(QualityOfServiceMode.DUPLICATES_OK, true, 50);
- }
-
- @Test
- public void testStress_OnceAndOnlyOnce_P_50() throws Exception
- {
- testStress(QualityOfServiceMode.ONCE_AND_ONLY_ONCE, true, 50);
- }
-
- @Test
- public void testStress_AtMostOnce_NP_50() throws Exception
- {
- testStress(QualityOfServiceMode.AT_MOST_ONCE, false, 50);
- }
-
- @Test
- public void testStress_DuplicatesOk_NP_50() throws Exception
- {
- testStress(QualityOfServiceMode.DUPLICATES_OK, false, 50);
- }
-
- @Test
- public void testStress_OnceAndOnlyOnce_NP_50() throws Exception
- {
- testStress(QualityOfServiceMode.ONCE_AND_ONLY_ONCE, false, 50);
- }
-
- // Stress with batch size of 1
-
- @Test
- public void testStress_AtMostOnce_P_1() throws Exception
- {
- testStress(QualityOfServiceMode.AT_MOST_ONCE, true, 1);
- }
-
- @Test
- public void testStress_DuplicatesOk_P_1() throws Exception
- {
- testStress(QualityOfServiceMode.DUPLICATES_OK, true, 1);
- }
-
- @Test
- public void testStress_OnceAndOnlyOnce_P_1() throws Exception
- {
- testStress(QualityOfServiceMode.ONCE_AND_ONLY_ONCE, true, 1);
- }
-
- @Test
- public void testStress_AtMostOnce_NP_1() throws Exception
- {
- testStress(QualityOfServiceMode.AT_MOST_ONCE, false, 1);
- }
-
- @Test
- public void testStress_DuplicatesOk_NP_1() throws Exception
- {
- testStress(QualityOfServiceMode.DUPLICATES_OK, false, 1);
- }
-
- @Test
- public void testStress_OnceAndOnlyOnce_NP_1() throws Exception
- {
- testStress(QualityOfServiceMode.ONCE_AND_ONLY_ONCE, false, 1);
- }
-
- // Max batch time
-
- @Test
- public void testStressMaxBatchTime_OnceAndOnlyOnce_NP() throws Exception
- {
- testStressBatchTime(QualityOfServiceMode.ONCE_AND_ONLY_ONCE, false, 200);
- }
-
- @Test
- public void testStressMaxBatchTime_OnceAndOnlyOnce_P() throws Exception
- {
- testStressBatchTime(QualityOfServiceMode.ONCE_AND_ONLY_ONCE, true, 200);
- }
-
- // Stress on same server
-
- // Stress with batch size of 50
-
- @Test
- public void testStressSameServer_AtMostOnce_P_50() throws Exception
- {
- testStressSameServer(QualityOfServiceMode.AT_MOST_ONCE, true, 50);
- }
-
- @Test
- public void testStressSameServer_DuplicatesOk_P_50() throws Exception
- {
- testStressSameServer(QualityOfServiceMode.DUPLICATES_OK, true, 50);
- }
-
- @Test
- public void testStressSameServer_OnceAndOnlyOnce_P_50() throws Exception
- {
- testStress(QualityOfServiceMode.ONCE_AND_ONLY_ONCE, true, 50);
- }
-
- @Test
- public void testStressSameServer_AtMostOnce_NP_50() throws Exception
- {
- testStressSameServer(QualityOfServiceMode.AT_MOST_ONCE, false, 50);
- }
-
- @Test
- public void testStressSameServer_DuplicatesOk_NP_50() throws Exception
- {
- testStressSameServer(QualityOfServiceMode.DUPLICATES_OK, false, 50);
- }
-
- @Test
- public void testStressSameServer_OnceAndOnlyOnce_NP_50() throws Exception
- {
- testStressSameServer(QualityOfServiceMode.ONCE_AND_ONLY_ONCE, false, 50);
- }
-
- // Stress with batch size of 1
-
- @Test
- public void testStressSameServer_AtMostOnce_P_1() throws Exception
- {
- testStressSameServer(QualityOfServiceMode.AT_MOST_ONCE, true, 1);
- }
-
- @Test
- public void testStressSameServer_DuplicatesOk_P_1() throws Exception
- {
- testStressSameServer(QualityOfServiceMode.DUPLICATES_OK, true, 1);
- }
-
- @Test
- public void testStressSameServer_OnceAndOnlyOnce_P_1() throws Exception
- {
- testStressSameServer(QualityOfServiceMode.ONCE_AND_ONLY_ONCE, true, 1);
- }
-
- @Test
- public void testStressSameServer_AtMostOnce_NP_1() throws Exception
- {
- testStressSameServer(QualityOfServiceMode.AT_MOST_ONCE, false, 1);
- }
-
- @Test
- public void testStressSameServer_DuplicatesOk_NP_1() throws Exception
- {
- testStressSameServer(QualityOfServiceMode.DUPLICATES_OK, false, 1);
- }
-
- @Test
- public void testStressSameServer_OnceAndOnlyOnce_NP_1() throws Exception
- {
- testStressSameServer(QualityOfServiceMode.ONCE_AND_ONLY_ONCE, false, 1);
- }
-
- @Test
- public void testStartBridgeFirst() throws Exception
- {
- //stop the source server, we want to start the bridge first
- jmsServer0.stop();
- JMSBridgeImpl bridge = null;
-
- ConnectionFactoryFactory factInUse0 = cff0;
- ConnectionFactoryFactory factInUse1 = cff1;
- try
- {
- final int NUM_MESSAGES = 10;
-
- bridge = new JMSBridgeImpl(factInUse0,
- factInUse1,
- sourceQueueFactory,
- targetQueueFactory,
- null,
- null,
- null,
- null,
- null,
- 5000,
- 10,
- QualityOfServiceMode.AT_MOST_ONCE,
- NUM_MESSAGES,
- -1,
- null,
- null,
- false);
-
- bridge.start();
-
- //now start the server
- jmsServer0.start();
- createQueue("sourceQueue", 0);
- createQueue("localTargetQueue", 0);
- jmsServer0.createTopic(false, "sourceTopic", "/topic/sourceTopic");
- // Send half the messages
-
- sendMessages(cf0, sourceQueue, 0, NUM_MESSAGES / 2, false, false);
-
- // Verify none are received
-
- checkEmpty(targetQueue, 1);
-
- // Send the other half
-
- sendMessages(cf0, sourceQueue, NUM_MESSAGES / 2, NUM_MESSAGES / 2, false, false);
-
- // This should now be receivable
-
- checkAllMessageReceivedInOrder(cf1, targetQueue, 0, NUM_MESSAGES, false);
-
- // Send another batch with one more than batch size
-
- sendMessages(cf0, sourceQueue, 0, NUM_MESSAGES + 1, false, false);
-
- // Make sure only batch size are received
-
- checkAllMessageReceivedInOrder(cf1, targetQueue, 0, NUM_MESSAGES, false);
-
- // Final batch
-
- sendMessages(cf0, sourceQueue, 0, NUM_MESSAGES - 1, false, false);
-
- checkAllMessageReceivedInOrder(cf1, targetQueue, NUM_MESSAGES, 1, false);
-
- checkAllMessageReceivedInOrder(cf1, targetQueue, 0, NUM_MESSAGES - 1, false);
-
- }
- finally
- {
- if (bridge != null)
- {
- JMSBridgeTest.log.info("Stopping bridge");
- bridge.stop();
- }
- }
- }
-
- @Test
- public void testParams() throws Exception
- {
- JMSBridgeImpl bridge = null;
-
- QualityOfServiceMode qosMode = QualityOfServiceMode.AT_MOST_ONCE;
-
- int batchSize = 10;
-
- int maxBatchTime = -1;
-
- String sourceUsername = null;
-
- String sourcePassword = null;
-
- String destUsername = null;
-
- String destPassword = null;
-
- String selector = null;
-
- long failureRetryInterval = 5000;
-
- int maxRetries = 10;
-
- String subName = null;
-
- String clientID = null;
-
- try
- {
- bridge =
- new JMSBridgeImpl(null,
- cff1,
- sourceQueueFactory,
- targetQueueFactory,
- sourceUsername,
- sourcePassword,
- destUsername,
- destPassword,
- selector,
- failureRetryInterval,
- maxRetries,
- qosMode,
- batchSize,
- maxBatchTime,
- subName,
- clientID,
- false);
- fail("expected exception");
- }
- catch (IllegalArgumentException e)
- {
- // Ok
- }
- finally
- {
- stopComponent(bridge);
- }
-
- try
- {
- bridge = new JMSBridgeImpl(cff0,
- null,
- sourceQueueFactory,
- targetQueueFactory,
- sourceUsername,
- sourcePassword,
- destUsername,
- destPassword,
- selector,
- failureRetryInterval,
- maxRetries,
- qosMode,
- batchSize,
- maxBatchTime,
- subName,
- clientID,
- false);
- fail("expected exception");
- }
- catch (IllegalArgumentException e)
- {
- // Ok
- }
- finally
- {
- stopComponent(bridge);
- }
-
- try
- {
- bridge = new JMSBridgeImpl(cff0,
- cff1,
- null,
- targetQueueFactory,
- sourceUsername,
- sourcePassword,
- destUsername,
- destPassword,
- selector,
- failureRetryInterval,
- maxRetries,
- qosMode,
- batchSize,
- maxBatchTime,
- subName,
- clientID,
- false);
- fail("expected exception");
- }
- catch (IllegalArgumentException e)
- {
- // Ok
- }
- finally
- {
- stopComponent(bridge);
- }
-
- try
- {
- bridge = new JMSBridgeImpl(cff0,
- cff1,
- sourceQueueFactory,
- null,
- sourceUsername,
- sourcePassword,
- destUsername,
- destPassword,
- selector,
- failureRetryInterval,
- maxRetries,
- qosMode,
- batchSize,
- maxBatchTime,
- subName,
- clientID,
- false);
- fail("expected exception");
- }
- catch (IllegalArgumentException e)
- {
- // Ok
- }
- finally
- {
- stopComponent(bridge);
- }
-
- try
- {
- bridge = new JMSBridgeImpl(cff0,
- cff1,
- sourceQueueFactory,
- targetQueueFactory,
- sourceUsername,
- sourcePassword,
- destUsername,
- destPassword,
- selector,
- -2,
- maxRetries,
- qosMode,
- batchSize,
- maxBatchTime,
- subName,
- clientID,
- false);
- fail("expected exception");
- }
- catch (IllegalArgumentException e)
- {
- // Ok
- }
- finally
- {
- stopComponent(bridge);
- }
-
- try
- {
- bridge = new JMSBridgeImpl(cff0,
- cff1,
- sourceQueueFactory,
- targetQueueFactory,
- sourceUsername,
- sourcePassword,
- destUsername,
- destPassword,
- selector,
- -1,
- 10,
- qosMode,
- batchSize,
- maxBatchTime,
- subName,
- clientID,
- false);
- fail("expected exception");
- }
- catch (IllegalArgumentException e)
- {
- // Ok
- }
- finally
- {
- stopComponent(bridge);
- }
-
- try
- {
- bridge = new JMSBridgeImpl(cff0,
- cff1,
- sourceQueueFactory,
- null,
- sourceUsername,
- sourcePassword,
- destUsername,
- destPassword,
- selector,
- failureRetryInterval,
- maxRetries,
- qosMode,
- 0,
- maxBatchTime,
- subName,
- clientID,
- false);
- fail("expected exception");
- }
- catch (IllegalArgumentException e)
- {
- // Ok
- }
- finally
- {
- stopComponent(bridge);
- }
-
- try
- {
- bridge = new JMSBridgeImpl(cff0,
- cff1,
- sourceQueueFactory,
- null,
- sourceUsername,
- sourcePassword,
- destUsername,
- destPassword,
- selector,
- failureRetryInterval,
- maxRetries,
- qosMode,
- batchSize,
- -2,
- subName,
- clientID,
- false);
- fail("expected exception");
- }
- catch (IllegalArgumentException e)
- {
- // Ok
- }
- finally
- {
- stopComponent(bridge);
- }
- }
-
- @Test
- public void testStartStopStart() throws Exception
- {
- JMSBridgeImpl bridge = null;
-
- Connection connSource = null;
-
- Connection connTarget = null;
-
- try
- {
- final int NUM_MESSAGES = 10;
-
- bridge = new JMSBridgeImpl(cff0,
- cff1,
- sourceQueueFactory,
- targetQueueFactory,
- null,
- null,
- null,
- null,
- null,
- 5000,
- 10,
- QualityOfServiceMode.AT_MOST_ONCE,
- 1,
- -1,
- null,
- null,
- false);
-
- bridge.start();
-
- bridge.stop();
-
- bridge.start();
-
- connSource = cf0.createConnection();
-
- Session sessSend = connSource.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageProducer prod = sessSend.createProducer(sourceQueue);
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = sessSend.createTextMessage("message" + i);
- prod.send(tm);
- }
-
- connTarget = cf1.createConnection();
- Session sessRec = connTarget.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageConsumer cons = sessRec.createConsumer(targetQueue);
-
- connTarget.start();
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = (TextMessage) cons.receive(10000);
- Assert.assertNotNull(tm);
- Assert.assertEquals("message" + i, tm.getText());
- }
-
- Message m = cons.receiveNoWait();
- Assert.assertNull(m);
- }
- finally
- {
- if (connSource != null)
- {
- connSource.close();
- }
-
- if (connTarget != null)
- {
- connTarget.close();
- }
-
- if (bridge != null)
- {
- bridge.stop();
- }
-
- removeAllMessages(sourceQueue.getQueueName(), 0);
- }
- }
-
- @Test
- public void testSelector() throws Exception
- {
- JMSBridgeImpl bridge = null;
-
- Connection connSource = null;
-
- Connection connTarget = null;
-
- try
- {
- final int NUM_MESSAGES = 10;
-
- String selector = "vegetable='radish'";
-
- bridge = new JMSBridgeImpl(cff0,
- cff1,
- sourceQueueFactory,
- targetQueueFactory,
- null,
- null,
- null,
- null,
- selector,
- 5000,
- 10,
- QualityOfServiceMode.AT_MOST_ONCE,
- 1,
- -1,
- null,
- null,
- false);
-
- bridge.start();
-
- connSource = cf0.createConnection();
-
- Session sessSend = connSource.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageProducer prod = sessSend.createProducer(sourceQueue);
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = sessSend.createTextMessage("message" + i);
-
- if (i >= NUM_MESSAGES / 2)
- {
- tm.setStringProperty("vegetable", "radish");
- }
- else
- {
- tm.setStringProperty("vegetable", "cauliflower");
- }
-
- prod.send(tm);
- }
-
- connTarget = cf1.createConnection();
-
- Session sessRec = connTarget.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageConsumer cons = sessRec.createConsumer(targetQueue);
-
- connTarget.start();
-
- for (int i = NUM_MESSAGES / 2; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = (TextMessage) cons.receive(10000);
-
- Assert.assertNotNull(tm);
-
- Assert.assertEquals("message" + i, tm.getText());
- }
-
- Message m = cons.receiveNoWait();
-
- Assert.assertNull(m);
-
- }
- finally
- {
- if (connSource != null)
- {
- connSource.close();
- }
-
- if (connTarget != null)
- {
- connTarget.close();
- }
-
- if (bridge != null)
- {
- bridge.stop();
- }
-
- removeAllMessages(sourceQueue.getQueueName(), 0);
- }
- }
-
- @Test
- public void testMaskPassword() throws Exception
- {
- JMSBridgeImpl bridge = null;
-
- Connection connSource = null;
-
- Connection connTarget = null;
-
- DefaultSensitiveStringCodec codec = new DefaultSensitiveStringCodec();
- String mask = (String) codec.encode("guest");
-
- try
- {
- final int NUM_MESSAGES = 10;
-
- bridge = new JMSBridgeImpl(cff0, cff1, sourceQueueFactory,
- targetQueueFactory, "guest", mask, "guest", mask, null, 5000,
- 10, QualityOfServiceMode.AT_MOST_ONCE, 1, -1, null, null, false);
-
- bridge.setUseMaskedPassword(true);
-
- bridge.start();
-
- connSource = cf0.createConnection();
-
- Session sessSend = connSource.createSession(false,
- Session.AUTO_ACKNOWLEDGE);
-
- MessageProducer prod = sessSend.createProducer(sourceQueue);
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = sessSend.createTextMessage("message" + i);
-
- prod.send(tm);
- }
-
- connTarget = cf1.createConnection();
-
- Session sessRec = connTarget.createSession(false,
- Session.AUTO_ACKNOWLEDGE);
-
- MessageConsumer cons = sessRec.createConsumer(targetQueue);
-
- connTarget.start();
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = (TextMessage) cons.receive(10000);
-
- Assert.assertNotNull(tm);
-
- Assert.assertEquals("message" + i, tm.getText());
- }
-
- Message m = cons.receiveNoWait();
-
- Assert.assertNull(m);
-
- }
- finally
- {
- if (connSource != null)
- {
- connSource.close();
- }
-
- if (connTarget != null)
- {
- connTarget.close();
- }
-
- if (bridge != null)
- {
- bridge.stop();
- }
-
- removeAllMessages(sourceQueue.getQueueName(), 0);
- }
- }
-
- @Test
- public void testPasswordCodec() throws Exception
- {
- JMSBridgeImpl bridge = null;
-
- Connection connSource = null;
-
- Connection connTarget = null;
-
- DefaultSensitiveStringCodec codec = new DefaultSensitiveStringCodec();
- Map<String, String> prop = new HashMap<String, String>();
- prop.put("key", "bridgekey");
- codec.init(prop);
-
- String mask = (String) codec.encode("guest");
-
- try
- {
- final int NUM_MESSAGES = 10;
-
- bridge = new JMSBridgeImpl(cff0, cff1, sourceQueueFactory,
- targetQueueFactory, "guest", mask, "guest", mask, null, 5000,
- 10, QualityOfServiceMode.AT_MOST_ONCE, 1, -1, null, null, false);
-
- bridge.setUseMaskedPassword(true);
- bridge.setPasswordCodec(codec.getClass().getName() + ";key=bridgekey");
-
- bridge.start();
-
- connSource = cf0.createConnection();
-
- Session sessSend = connSource.createSession(false,
- Session.AUTO_ACKNOWLEDGE);
-
- MessageProducer prod = sessSend.createProducer(sourceQueue);
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = sessSend.createTextMessage("message" + i);
-
- prod.send(tm);
- }
-
- connTarget = cf1.createConnection();
-
- Session sessRec = connTarget.createSession(false,
- Session.AUTO_ACKNOWLEDGE);
-
- MessageConsumer cons = sessRec.createConsumer(targetQueue);
-
- connTarget.start();
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = (TextMessage) cons.receive(10000);
-
- Assert.assertNotNull(tm);
-
- Assert.assertEquals("message" + i, tm.getText());
- }
-
- Message m = cons.receiveNoWait();
-
- Assert.assertNull(m);
-
- }
- finally
- {
- if (connSource != null)
- {
- connSource.close();
- }
-
- if (connTarget != null)
- {
- connTarget.close();
- }
-
- if (bridge != null)
- {
- bridge.stop();
- }
-
- removeAllMessages(sourceQueue.getQueueName(), 0);
- }
- }
-
- @Test
- public void testStartBridgeWithJTATransactionAlreadyRunningLargeMessage() throws Exception
- {
- internalTestStartBridgeWithJTATransactionAlreadyRunning(true);
- }
-
- @Test
- public void testStartBridgeWithJTATransactionAlreadyRunningRegularMessage() throws Exception
- {
- internalTestStartBridgeWithJTATransactionAlreadyRunning(false);
- }
-
- public void internalTestStartBridgeWithJTATransactionAlreadyRunning(final boolean largeMessage) throws Exception
- {
- JMSBridgeImpl bridge = null;
-
- Transaction toResume = null;
-
- Transaction started = null;
-
- TransactionManager mgr = newTransactionManager();
-
- try
- {
-
- toResume = mgr.suspend();
-
- mgr.begin();
-
- started = mgr.getTransaction();
-
- final int NUM_MESSAGES = 10;
-
- bridge = new JMSBridgeImpl(cff0,
- cff1,
- sourceTopicFactory,
- targetQueueFactory,
- null,
- null,
- null,
- null,
- null,
- 5000,
- 10,
- QualityOfServiceMode.AT_MOST_ONCE,
- 1,
- -1,
- null,
- null,
- false);
- bridge.start();
-
- sendMessages(cf0, sourceTopic, 0, NUM_MESSAGES, false, largeMessage);
-
- checkAllMessageReceivedInOrder(cf1, targetQueue, 0, NUM_MESSAGES, largeMessage);
- }
- finally
- {
- if (started != null)
- {
- try
- {
- started.rollback();
- }
- catch (Exception e)
- {
- JMSBridgeTest.log.error("Failed to rollback", e);
- }
- }
-
- if (toResume != null)
- {
- try
- {
- mgr.resume(toResume);
- }
- catch (Exception e)
- {
- JMSBridgeTest.log.error("Failed to resume", e);
- }
- }
- if (bridge != null)
- {
- bridge.stop();
- }
- }
- }
-
- @Test
- public void testNonDurableSubscriberLargeMessage() throws Exception
- {
- internalTestNonDurableSubscriber(true, 1);
- }
-
- @Test
- public void testNonDurableSubscriberRegularMessage() throws Exception
- {
- internalTestNonDurableSubscriber(false, 1);
- }
-
- public void internalTestNonDurableSubscriber(final boolean largeMessage, final int batchSize) throws Exception
- {
- JMSBridgeImpl bridge = null;
-
- try
- {
- final int NUM_MESSAGES = 10;
-
- bridge = new JMSBridgeImpl(cff0,
- cff1,
- sourceTopicFactory,
- targetQueueFactory,
- null,
- null,
- null,
- null,
- null,
- 5000,
- 10,
- QualityOfServiceMode.AT_MOST_ONCE,
- batchSize,
- -1,
- null,
- null,
- false);
-
- bridge.start();
-
- sendMessages(cf0, sourceTopic, 0, NUM_MESSAGES, false, largeMessage);
-
- checkAllMessageReceivedInOrder(cf1, targetQueue, 0, NUM_MESSAGES, largeMessage);
- }
- finally
- {
- if (bridge != null)
- {
- bridge.stop();
- }
- }
- }
-
- @Test
- public void testDurableSubscriberLargeMessage() throws Exception
- {
- internalTestDurableSubscriber(true, 1);
- }
-
- @Test
- public void testDurableSubscriberRegularMessage() throws Exception
- {
- internalTestDurableSubscriber(false, 1);
- }
-
- public void internalTestDurableSubscriber(final boolean largeMessage, final int batchSize) throws Exception
- {
- JMSBridgeImpl bridge = null;
-
- try
- {
- final int NUM_MESSAGES = 10;
-
- bridge = new JMSBridgeImpl(cff0,
- cff1,
- sourceTopicFactory,
- targetQueueFactory,
- null,
- null,
- null,
- null,
- null,
- 5000,
- 10,
- QualityOfServiceMode.AT_MOST_ONCE,
- batchSize,
- -1,
- "subTest",
- "clientid123",
- false);
-
- bridge.start();
-
- sendMessages(cf0, sourceTopic, 0, NUM_MESSAGES, true, largeMessage);
-
- checkAllMessageReceivedInOrder(cf1, targetQueue, 0, NUM_MESSAGES, largeMessage);
- }
- finally
- {
- if (bridge != null)
- {
- bridge.stop();
- }
-
- // Now unsubscribe
- Connection conn = cf0.createConnection();
- conn.setClientID("clientid123");
- Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
- sess.unsubscribe("subTest");
- conn.close();
- }
- }
-
- @Test
- public void testMessageIDInHeaderOn() throws Exception
- {
- messageIDInHeader(true);
- }
-
- @Test
- public void testMessageIDInHeaderOff() throws Exception
- {
- messageIDInHeader(false);
- }
-
- private void messageIDInHeader(final boolean on) throws Exception
- {
- JMSBridgeImpl bridge = null;
-
- Connection connSource = null;
-
- Connection connTarget = null;
-
- try
- {
- final int NUM_MESSAGES = 10;
-
- bridge = new JMSBridgeImpl(cff0,
- cff1,
- sourceQueueFactory,
- targetQueueFactory,
- null,
- null,
- null,
- null,
- null,
- 5000,
- 10,
- QualityOfServiceMode.AT_MOST_ONCE,
- 1,
- -1,
- null,
- null,
- on);
-
- bridge.start();
-
- connSource = cf0.createConnection();
-
- connTarget = cf1.createConnection();
-
- JMSBridgeTest.log.trace("Sending " + NUM_MESSAGES + " messages");
-
- List<String> ids1 = new ArrayList<String>();
-
- Session sessSource = connSource.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageProducer prod = sessSource.createProducer(sourceQueue);
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = sessSource.createTextMessage("message" + i);
-
- // We add some properties to make sure they get passed through ok
- tm.setStringProperty("wib", "uhuh");
- tm.setBooleanProperty("cheese", true);
- tm.setIntProperty("Sausages", 23);
- tm.setByteProperty("bacon", (byte) 12);
- tm.setDoubleProperty("toast", 17261762.12121d);
- tm.setFloatProperty("orange", 1212.1212f);
- tm.setLongProperty("blurg", 817217827L);
- tm.setShortProperty("stst", (short) 26363);
-
- //Set some JMS headers too
-
- //And also set a core props
- ((ActiveMQMessage) tm).getCoreMessage().putBytesProperty("bytes", new byte[]{1, 2, 3});
-
- // We add some JMSX ones too
-
- tm.setStringProperty("JMSXGroupID", "mygroup543");
-
- prod.send(tm);
-
- ids1.add(tm.getJMSMessageID());
- }
-
- JMSBridgeTest.log.trace("Sent the first messages");
-
- Session sessTarget = connTarget.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageConsumer cons = sessTarget.createConsumer(targetQueue);
-
- connTarget.start();
-
- List<TextMessage> msgs = new ArrayList<TextMessage>();
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = (TextMessage) cons.receive(5000);
-
- Assert.assertNotNull(tm);
-
- Assert.assertEquals("message" + i, tm.getText());
-
- Assert.assertEquals("uhuh", tm.getStringProperty("wib"));
- Assert.assertTrue(tm.getBooleanProperty("cheese"));
- Assert.assertEquals(23, tm.getIntProperty("Sausages"));
- assertEquals((byte) 12, tm.getByteProperty("bacon"));
- assertEquals(17261762.12121d, tm.getDoubleProperty("toast"), 0.000000001);
- assertEquals(1212.1212f, tm.getFloatProperty("orange"), 0.000001);
- assertEquals(817217827L, tm.getLongProperty("blurg"));
- assertEquals((short) 26363, tm.getShortProperty("stst"));
-
- assertEqualsByteArrays(new byte[]{1, 2, 3}, ((ActiveMQMessage) tm).getCoreMessage().getBytesProperty("bytes"));
-
- Assert.assertEquals("mygroup543", tm.getStringProperty("JMSXGroupID"));
-
- if (on)
- {
- String header = tm.getStringProperty(ActiveMQJMSConstants.JBOSS_MESSAGING_BRIDGE_MESSAGE_ID_LIST);
-
- Assert.assertNotNull(header);
-
- Assert.assertEquals(ids1.get(i), header);
-
- msgs.add(tm);
- }
- }
-
- if (on)
- {
- // Now we send them again back to the source
-
- Iterator<TextMessage> iter = msgs.iterator();
-
- List<String> ids2 = new ArrayList<String>();
-
- while (iter.hasNext())
- {
- Message msg = iter.next();
-
- prod.send(msg);
-
- ids2.add(msg.getJMSMessageID());
- }
-
- // And consume them again
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = (TextMessage) cons.receive(5000);
-
- Assert.assertNotNull(tm);
-
- Assert.assertEquals("message" + i, tm.getText());
-
- Assert.assertEquals("uhuh", tm.getStringProperty("wib"));
- Assert.assertTrue(tm.getBooleanProperty("cheese"));
- Assert.assertEquals(23, tm.getIntProperty("Sausages"));
- assertEquals((byte) 12, tm.getByteProperty("bacon"));
- assertEquals(17261762.12121d, tm.getDoubleProperty("toast"), 0.000001);
- assertEquals(1212.1212f, tm.getFloatProperty("orange"), 0.0000001);
- assertEquals(817217827L, tm.getLongProperty("blurg"));
- assertEquals((short) 26363, tm.getShortProperty("stst"));
-
- assertEqualsByteArrays(new byte[]{1, 2, 3}, ((ActiveMQMessage) tm).getCoreMessage().getBytesProperty("bytes"));
-
- Assert.assertEquals("mygroup543", tm.getStringProperty("JMSXGroupID"));
-
- String header = tm.getStringProperty(ActiveMQJMSConstants.JBOSS_MESSAGING_BRIDGE_MESSAGE_ID_LIST);
-
- Assert.assertNotNull(header);
-
- Assert.assertEquals(ids1.get(i) + "," + ids2.get(i), header);
- }
- }
-
- }
- finally
- {
- if (bridge != null)
- {
- bridge.stop();
- }
-
- if (connSource != null)
- {
- connSource.close();
- }
-
- if (connTarget != null)
- {
- connTarget.close();
- }
- }
- }
-
- @Test
- public void testPropertiesPreservedPOn() throws Exception
- {
- propertiesPreserved(true, true);
- }
-
- @Test
- public void testPropertiesPreservedNPoff() throws Exception
- {
- propertiesPreserved(false, true);
- }
-
- @Test
- public void testPropertiesPreservedNPOn() throws Exception
- {
- propertiesPreserved(false, true);
- }
-
- @Test
- public void testPropertiesPreservedPoff() throws Exception
- {
- propertiesPreserved(true, true);
- }
-
- private void propertiesPreserved(final boolean persistent, final boolean messageIDInHeader) throws Exception
- {
- JMSBridgeImpl bridge = null;
-
- Connection connSource = null;
-
- Connection connTarget = null;
-
- try
- {
- final int NUM_MESSAGES = 10;
-
- bridge = new JMSBridgeImpl(cff0,
- cff1,
- sourceQueueFactory,
- targetQueueFactory,
- null,
- null,
- null,
- null,
- null,
- 5000,
- 10,
- QualityOfServiceMode.AT_MOST_ONCE,
- 1,
- -1,
- null,
- null,
- messageIDInHeader);
-
- bridge.start();
-
- connSource = cf0.createConnection();
-
- connTarget = cf1.createConnection();
-
- JMSBridgeTest.log.trace("Sending " + NUM_MESSAGES + " messages");
-
- Session sessSource = connSource.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- Session sessTarget = connTarget.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageConsumer cons = sessTarget.createConsumer(targetQueue);
-
- connTarget.start();
-
- MessageProducer prod = sessSource.createProducer(sourceQueue);
-
- prod.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
-
- TextMessage tm = sessSource.createTextMessage("blahmessage");
-
- prod.setPriority(7);
-
- prod.setTimeToLive(1 * 60 * 60 * 1000);
-
- prod.send(tm);
-
- long expiration = tm.getJMSExpiration();
-
- Assert.assertEquals(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT,
- tm.getJMSDeliveryMode());
-
- tm = (TextMessage) cons.receive(1000);
-
- Assert.assertNotNull(tm);
-
- Assert.assertEquals("blahmessage", tm.getText());
-
- Assert.assertEquals(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT,
- tm.getJMSDeliveryMode());
-
- Assert.assertEquals(7, tm.getJMSPriority());
-
- Assert.assertTrue(Math.abs(expiration - tm.getJMSExpiration()) < 100);
-
- Message m = cons.receive(5000);
-
- Assert.assertNull(m);
-
- // Now do one with expiration = 0
-
- tm = sessSource.createTextMessage("blahmessage2");
-
- prod.setPriority(7);
-
- prod.setTimeToLive(0);
-
- prod.send(tm);
-
- Assert.assertEquals(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT,
- tm.getJMSDeliveryMode());
-
- tm = (TextMessage) cons.receive(1000);
-
- Assert.assertNotNull(tm);
-
- Assert.assertEquals("blahmessage2", tm.getText());
-
- Assert.assertEquals(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT,
- tm.getJMSDeliveryMode());
-
- Assert.assertEquals(7, tm.getJMSPriority());
-
- Assert.assertEquals(0, tm.getJMSExpiration());
-
- m = cons.receive(5000);
-
- Assert.assertNull(m);
-
- tm = sessSource.createTextMessage("blahmessage3");
-
- final boolean myBool = false;
- final byte myByte = (byte) 23;
- final double myDouble = 17625765d;
- final float myFloat = 87127.23f;
- final int myInt = 123;
- final long myLong = 81728712;
- final short myShort = (short) 88;
- final String myString = "ojweodewj";
- final String myJMSX = "aardvark";
-
- tm.setBooleanProperty("mybool", myBool);
- tm.setByteProperty("mybyte", myByte);
- tm.setDoubleProperty("mydouble", myDouble);
- tm.setFloatProperty("myfloat", myFloat);
- tm.setIntProperty("myint", myInt);
- tm.setLongProperty("mylong", myLong);
- tm.setShortProperty("myshort", myShort);
- tm.setStringProperty("mystring", myString);
-
- tm.setStringProperty("JMSXMyNaughtyJMSXProperty", myJMSX);
-
- prod.send(tm);
-
- tm = (TextMessage) cons.receive(5000);
-
- Assert.assertNotNull(tm);
-
- Assert.assertEquals("blahmessage3", tm.getText());
-
- Assert.assertEquals(myBool, tm.getBooleanProperty("mybool"));
- Assert.assertEquals(myByte, tm.getByteProperty("mybyte"));
- Assert.assertEquals(myDouble, tm.getDoubleProperty("mydouble"), 0.000001);
- Assert.assertEquals(myFloat, tm.getFloatProperty("myfloat"), 0.000001);
- Assert.assertEquals(myInt, tm.getIntProperty("myint"));
- Assert.assertEquals(myLong, tm.getLongProperty("mylong"));
- Assert.assertEquals(myShort, tm.getShortProperty("myshort"));
- Assert.assertEquals(myString, tm.getStringProperty("mystring"));
- Assert.assertEquals(myJMSX, tm.getStringProperty("JMSXMyNaughtyJMSXProperty"));
-
- m = cons.receive(5000);
-
- }
- finally
- {
- if (bridge != null)
- {
- bridge.stop();
- }
-
- if (connSource != null)
- {
- connSource.close();
- }
-
- if (connTarget != null)
- {
- connTarget.close();
- }
- }
- }
-
- @Test
- public void testNoMessageIDInHeader() throws Exception
- {
- JMSBridgeImpl bridge = null;
-
- Connection connSource = null;
-
- Connection connTarget = null;
-
- try
- {
- final int NUM_MESSAGES = 10;
-
- bridge = new JMSBridgeImpl(cff0,
- cff1,
- sourceQueueFactory,
- targetQueueFactory,
- null,
- null,
- null,
- null,
- null,
- 5000,
- 10,
- QualityOfServiceMode.AT_MOST_ONCE,
- 1,
- -1,
- null,
- null,
- false);
-
- bridge.start();
-
- connSource = cf0.createConnection();
-
- connTarget = cf1.createConnection();
-
- JMSBridgeTest.log.trace("Sending " + NUM_MESSAGES + " messages");
-
- Session sessSource = connSource.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageProducer prod = sessSource.createProducer(sourceQueue);
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = sessSource.createTextMessage("message" + i);
-
- // We add some headers to make sure they get passed through ok
- tm.setStringProperty("wib", "uhuh");
- tm.setBooleanProperty("cheese", true);
- tm.setIntProperty("Sausages", 23);
-
- prod.send(tm);
- }
-
- JMSBridgeTest.log.trace("Sent the first messages");
-
- Session sessTarget = connTarget.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageConsumer cons = sessTarget.createConsumer(targetQueue);
-
- connTarget.start();
-
- for (int i = 0; i < NUM_MESSAGES; i++)
- {
- TextMessage tm = (TextMessage) cons.receive(5000);
-
- Assert.assertNotNull(tm);
-
- Assert.assertEquals("message" + i, tm.getText());
-
- Assert.assertEquals("uhuh", tm.getStringProperty("wib"));
- Assert.assertTrue(tm.getBooleanProperty("cheese"));
- Assert.assertEquals(23, tm.getIntProperty("Sausages"));
-
- String header = tm.getStringProperty(ActiveMQJMSConstants.JBOSS_MESSAGING_BRIDGE_MESSAGE_ID_LIST);
-
- Assert.assertNull(header);
- }
- }
- finally
- {
- if (bridge != null)
- {
- bridge.stop();
- }
-
- if (connSource != null)
- {
- connSource.close();
- }
-
- if (connTarget != null)
- {
- connTarget.close();
- }
- }
- }
-
- // Private -------------------------------------------------------------------------------
-
- private void testStress(final QualityOfServiceMode qosMode, final boolean persistent, final int batchSize) throws Exception
- {
- Connection connSource = null;
-
- JMSBridgeImpl bridge = null;
-
- Thread t = null;
-
- ConnectionFactoryFactory factInUse0 = cff0;
- ConnectionFactoryFactory factInUse1 = cff1;
- if (qosMode.equals(QualityOfServiceMode.ONCE_AND_ONLY_ONCE))
- {
- factInUse0 = cff0xa;
- factInUse1 = cff1xa;
- ServiceUtils.setTransactionManager(newTransactionManager());
- }
-
- try
- {
- bridge = new JMSBridgeImpl(factInUse0,
- factInUse1,
- sourceQueueFactory,
- targetQueueFactory,
- null,
- null,
- null,
- null,
- null,
- 5000,
- 10,
- qosMode,
- batchSize,
- -1,
- null,
- null,
- false);
-
- bridge.start();
-
- connSource = cf0.createConnection();
-
- Session sessSend = connSource.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageProducer prod = sessSend.createProducer(sourceQueue);
-
- final int NUM_MESSAGES = 250;
-
- StressSender sender = new StressSender();
- sender.sess = sessSend;
- sender.prod = prod;
- sender.numMessages = NUM_MESSAGES;
- prod.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
-
- t = new Thread(sender);
-
- t.start();
-
- checkAllMessageReceivedInOrder(cf1, targetQueue, 0, NUM_MESSAGES, false);
-
- t.join();
-
- if (sender.ex != null)
- {
- // An error occurred during the send
- throw sender.ex;
- }
-
- }
- finally
- {
- if (t != null)
- {
- t.join(10000);
- }
-
- if (connSource != null)
- {
- try
- {
- connSource.close();
- }
- catch (Exception e)
- {
- JMSBridgeTest.log.error("Failed to close connection", e);
- }
- }
-
- if (bridge != null)
- {
- bridge.stop();
- }
- }
- }
-
- private void testStressBatchTime(final QualityOfServiceMode qosMode, final boolean persistent, final int maxBatchTime) throws Exception
- {
- Connection connSource = null;
-
- JMSBridgeImpl bridge = null;
-
- Thread t = null;
-
- ConnectionFactoryFactory factInUse0 = cff0;
- ConnectionFactoryFactory factInUse1 = cff1;
- if (qosMode.equals(QualityOfServiceMode.ONCE_AND_ONLY_ONCE))
- {
- factInUse0 = cff0xa;
- factInUse1 = cff1xa;
- ServiceUtils.setTransactionManager(newTransactionManager());
- }
-
- try
- {
- bridge = new JMSBridgeImpl(factInUse0,
- factInUse1,
- sourceQueueFactory,
- targetQueueFactory,
- null,
- null,
- null,
- null,
- null,
- 5000,
- 10,
- qosMode,
- 2,
- maxBatchTime,
- null,
- null,
- false);
-
- bridge.start();
-
- connSource = cf0.createConnection();
-
- Session sessSend = connSource.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageProducer prod = sessSend.createProducer(sourceQueue);
-
- final int NUM_MESSAGES = 500;
-
- StressSender sender = new StressSender();
- sender.sess = sessSend;
- sender.prod = prod;
- sender.numMessages = NUM_MESSAGES;
- prod.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
-
- t = new Thread(sender);
-
- t.start();
-
- checkAllMessageReceivedInOrder(cf1, targetQueue, 0, NUM_MESSAGES, false);
-
- t.join();
-
- if (sender.ex != null)
- {
- // An error occurred during the send
- throw sender.ex;
- }
-
- }
- finally
- {
- if (t != null)
- {
- t.join(10000);
- }
-
- if (connSource != null)
- {
- try
- {
- connSource.close();
- }
- catch (Exception e)
- {
- JMSBridgeTest.log.error("Failed to close connection", e);
- }
- }
-
- if (bridge != null)
- {
- bridge.stop();
- }
- }
- }
-
- // Both source and destination on same rm
- private void testStressSameServer(final QualityOfServiceMode qosMode, final boolean persistent, final int batchSize) throws Exception
- {
- Connection connSource = null;
-
- JMSBridgeImpl bridge = null;
-
- Thread t = null;
-
- ConnectionFactoryFactory factInUse0 = cff0;
- if (qosMode.equals(QualityOfServiceMode.ONCE_AND_ONLY_ONCE))
- {
- factInUse0 = cff0xa;
- }
-
- try
- {
- bridge = new JMSBridgeImpl(factInUse0,
- factInUse0,
- sourceQueueFactory,
- localTargetQueueFactory,
- null,
- null,
- null,
- null,
- null,
- 5000,
- 10,
- qosMode,
- batchSize,
- -1,
- null,
- null,
- false);
-
- bridge.start();
-
- connSource = cf0.createConnection();
-
- Session sessSend = connSource.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageProducer prod = sessSend.createProducer(sourceQueue);
-
- final int NUM_MESSAGES = 200;
-
- StressSender sender = new StressSender();
- sender.sess = sessSend;
- sender.prod = prod;
- sender.numMessages = NUM_MESSAGES;
- prod.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
-
- t = new Thread(sender);
-
- t.start();
-
- checkAllMessageReceivedInOrder(cf0, localTargetQueue, 0, NUM_MESSAGES, false);
-
- t.join();
-
- if (sender.ex != null)
- {
- // An error occurred during the send
- throw sender.ex;
- }
-
- }
- finally
- {
- if (t != null)
- {
- t.join(10000);
- }
-
- if (connSource != null)
- {
- try
- {
- connSource.close();
- }
- catch (Exception e)
- {
- JMSBridgeTest.log.error("Failed to close connection", e);
- }
- }
-
- if (bridge != null)
- {
- bridge.stop();
- }
- }
- }
-
- private void testNoMaxBatchTime(final QualityOfServiceMode qosMode, final boolean persistent) throws Exception
- {
- JMSBridgeImpl bridge = null;
-
- ConnectionFactoryFactory factInUse0 = cff0;
- ConnectionFactoryFactory factInUse1 = cff1;
- if (qosMode.equals(QualityOfServiceMode.ONCE_AND_ONLY_ONCE))
- {
- factInUse0 = cff0xa;
- factInUse1 = cff1xa;
- ServiceUtils.setTransactionManager(newTransactionManager());
- }
- try
- {
- final int NUM_MESSAGES = 10;
-
- bridge = new JMSBridgeImpl(factInUse0,
- factInUse1,
- sourceQueueFactory,
- targetQueueFactory,
- null,
- null,
- null,
- null,
- null,
- 5000,
- 10,
- qosMode,
- NUM_MESSAGES,
- -1,
- null,
- null,
- false);
-
- bridge.start();
-
- // Send half the messages
-
- sendMessages(cf0, sourceQueue, 0, NUM_MESSAGES / 2, persistent, false);
-
- // Verify none are received
-
- checkEmpty(targetQueue, 1);
-
- // Send the other half
-
- sendMessages(cf0, sourceQueue, NUM_MESSAGES / 2, NUM_MESSAGES / 2, persistent, false);
-
- // This should now be receivable
-
- checkAllMessageReceivedInOrder(cf1, targetQueue, 0, NUM_MESSAGES, false);
-
- // Send another batch with one more than batch size
-
- sendMessages(cf0, sourceQueue, 0, NUM_MESSAGES + 1, persistent, false);
-
- // Make sure only batch size are received
-
- checkAllMessageReceivedInOrder(cf1, targetQueue, 0, NUM_MESSAGES, false);
-
- // Final batch
-
- sendMessages(cf0, sourceQueue, 0, NUM_MESSAGES - 1, persistent, false);
-
- checkAllMessageReceivedInOrder(cf1, targetQueue, NUM_MESSAGES, 1, false);
-
- checkAllMessageReceivedInOrder(cf1, targetQueue, 0, NUM_MESSAGES - 1, false);
- }
- finally
- {
- if (bridge != null)
- {
- JMSBridgeTest.log.info("Stopping bridge");
- bridge.stop();
- }
- }
- }
-
- private void testNoMaxBatchTimeSameServer(final QualityOfServiceMode qosMode, final boolean persistent) throws Exception
- {
- JMSBridgeImpl bridge = null;
-
- ConnectionFactoryFactory factInUse0 = cff0;
- if (qosMode.equals(QualityOfServiceMode.ONCE_AND_ONLY_ONCE))
- {
- factInUse0 = cff0xa;
- ServiceUtils.setTransactionManager(newTransactionManager());
- }
-
- try
- {
- final int NUM_MESSAGES = 10;
-
- bridge = new JMSBridgeImpl(factInUse0,
- factInUse0,
- sourceQueueFactory,
- localTargetQueueFactory,
- null,
- null,
- null,
- null,
- null,
- 5000,
- 10,
- qosMode,
- NUM_MESSAGES,
- -1,
- null,
- null,
- false);
-
- bridge.start();
-
- sendMessages(cf0, sourceQueue, 0, NUM_MESSAGES / 2, persistent, false);
-
- checkEmpty(targetQueue, 1);
-
- // Send the other half
-
- sendMessages(cf0, sourceQueue, NUM_MESSAGES / 2, NUM_MESSAGES / 2, persistent, false);
-
- // This should now be receivable
-
- checkAllMessageReceivedInOrder(cf0, localTargetQueue, 0, NUM_MESSAGES, false);
-
- checkEmpty(localTargetQueue, 0);
-
- checkEmpty(sourceQueue, 0);
-
- // Send another batch with one more than batch size
-
- sendMessages(cf0, sourceQueue, 0, NUM_MESSAGES + 1, persistent, false);
-
- // Make sure only batch size are received
-
- checkAllMessageReceivedInOrder(cf0, localTargetQueue, 0, NUM_MESSAGES, false);
-
- // Final batch
-
- sendMessages(cf0, sourceQueue, 0, NUM_MESSAGES - 1, persistent, false);
-
- checkAllMessageReceivedInOrder(cf0, localTargetQueue, NUM_MESSAGES, 1, false);
-
- checkAllMessageReceivedInOrder(cf0, localTargetQueue, 0, NUM_MESSAGES - 1, false);
- }
- finally
- {
- if (bridge != null)
- {
- bridge.stop();
- }
- }
- }
-
- private void testMaxBatchTime(final QualityOfServiceMode qosMode, final boolean persistent) throws Exception
- {
- JMSBridgeImpl bridge = null;
-
- ConnectionFactoryFactory factInUse0 = cff0;
- ConnectionFactoryFactory factInUse1 = cff1;
- if (qosMode.equals(QualityOfServiceMode.ONCE_AND_ONLY_ONCE))
- {
- factInUse0 = cff0xa;
- factInUse1 = cff1xa;
- ServiceUtils.setTransactionManager(newTransactionManager());
- }
-
- try
- {
- final long MAX_BATCH_TIME = 3000;
-
- final int MAX_BATCH_SIZE = 100000; // something big so it won't reach it
-
- bridge = new JMSBridgeImpl(factInUse0,
- factInUse1,
- sourceQueueFactory,
- targetQueueFactory,
- null,
- null,
- null,
- null,
- null,
- 3000,
- 10,
- qosMode,
- MAX_BATCH_SIZE,
- MAX_BATCH_TIME,
- null,
- null,
- false);
-
- bridge.start();
-
- final int NUM_MESSAGES = 10;
-
- // Send some message
-
- sendMessages(cf0, sourceQueue, 0, NUM_MESSAGES, persistent, false);
-
- // Verify none are received
-
- checkEmpty(targetQueue, 1);
-
- // Messages should now be receivable
-
- checkAllMessageReceivedInOrder(cf1, targetQueue, 0, NUM_MESSAGES, false);
- }
- finally
- {
- if (bridge != null)
- {
- bridge.stop();
- }
- }
- }
-
- private void testMaxBatchTimeSameServer(final QualityOfServiceMode qosMode, final boolean persistent) throws Exception
- {
- JMSBridgeImpl bridge = null;
-
- ConnectionFactoryFactory factInUse0 = cff0;
- if (qosMode.equals(QualityOfServiceMode.ONCE_AND_ONLY_ONCE))
- {
- factInUse0 = cff0xa;
- ServiceUtils.setTransactionManager(newTransactionManager());
- }
-
- try
- {
- final long MAX_BATCH_TIME = 3000;
-
- final int MAX_BATCH_SIZE = 100000; // something big so it won't reach it
-
- bridge = new JMSBridgeImpl(factInUse0,
- factInUse0,
- sourceQueueFactory,
- localTargetQueueFactory,
- null,
- null,
- null,
- null,
- null,
- 3000,
- 10,
- qosMode,
- MAX_BATCH_SIZE,
- MAX_BATCH_TIME,
- null,
- null,
- false);
-
- bridge.start();
-
- final int NUM_MESSAGES = 10;
-
- // Send some message
-
- // Send some message
-
- sendMessages(cf0, sourceQueue, 0, NUM_MESSAGES, persistent, false);
-
- // Verify none are received
-
- checkEmpty(localTargetQueue, 0);
-
- // Messages should now be receivable
-
- checkAllMessageReceivedInOrder(cf0, localTargetQueue, 0, NUM_MESSAGES, false);
- }
- finally
- {
- if (bridge != null)
- {
- bridge.stop();
- }
- }
- }
-
- @Test
- public void testSetTMClass() throws Exception
- {
- TransactionManagerLocatorImpl.tm = new DummyTransactionManager();
-
- JMSBridgeImpl bridge = null;
- try
- {
- bridge = new JMSBridgeImpl(cff0,
- cff0,
- sourceQueueFactory,
- localTargetQueueFactory,
- null,
- null,
- null,
- null,
- null,
- 3000,
- 10,
- QualityOfServiceMode.ONCE_AND_ONLY_ONCE,
- 10000,
- 3000,
- null,
- null,
- false);
- bridge.start();
- }
- finally
- {
- if (bridge != null)
- {
- bridge.stop();
- }
- }
- }
-
- @Test
- public void testMBeanServer() throws Exception
- {
-
- MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
- ObjectName objectName = new ObjectName("example.jmsbridge:service=JMSBridge");
-
- JMSBridgeImpl bridge = new JMSBridgeImpl(cff0,
- cff0,
- sourceQueueFactory,
- localTargetQueueFactory,
- null,
- null,
- null,
- null,
- null,
- 5000,
- 10,
- QualityOfServiceMode.AT_MOST_ONCE,
- 1,
- -1,
- null,
- null,
- false,
- mbeanServer,
- objectName.getCanonicalName());
-
- Assert.assertTrue(mbeanServer.isRegistered(objectName));
-
- bridge.destroy();
-
- Assert.assertFalse(mbeanServer.isRegistered(objectName));
- }
-
- public TransactionManager getNewTm()
- {
- return newTransactionManager();
- }
-
- // Inner classes -------------------------------------------------------------------
-
- private static class StressSender implements Runnable
- {
- int numMessages;
-
- Session sess;
-
- MessageProducer prod;
-
- Exception ex;
-
- public void run()
- {
- try
- {
- for (int i = 0; i < numMessages; i++)
- {
- TextMessage tm = sess.createTextMessage("message" + i);
-
- prod.send(tm);
-
- JMSBridgeTest.log.trace("Sent message " + i);
- }
- }
- catch (Exception e)
- {
- JMSBridgeTest.log.error("Failed to send", e);
- ex = e;
- }
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/jms/bridge/TransactionManagerLocatorImpl.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/jms/bridge/TransactionManagerLocatorImpl.java b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/jms/bridge/TransactionManagerLocatorImpl.java
deleted file mode 100644
index f502d23..0000000
--- a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/jms/bridge/TransactionManagerLocatorImpl.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.activemq.tests.integration.jms.bridge;
-
-import javax.transaction.TransactionManager;
-
-import org.apache.activemq.service.extensions.transactions.TransactionManagerLocator;
-
-/**
- * @author mtaylor
- */
-
-public class TransactionManagerLocatorImpl implements TransactionManagerLocator
-{
- public static TransactionManager tm = null;
-
- @Override
- public TransactionManager getTransactionManager()
- {
- return tm;
- }
-
- public void setTransactionManager(TransactionManager transactionManager)
- {
- tm = transactionManager;
- }
-}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/ra/JMSContextTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/ra/JMSContextTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/ra/JMSContextTest.java
index e4ef1bd..3210655 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/ra/JMSContextTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/ra/JMSContextTest.java
@@ -31,7 +31,6 @@ import org.apache.activemq.ra.ActiveMQRAManagedConnectionFactory;
import org.apache.activemq.ra.ActiveMQResourceAdapter;
import org.apache.activemq.spi.core.security.ActiveMQSecurityManagerImpl;
import org.apache.activemq.service.extensions.ServiceUtils;
-import org.apache.activemq.tests.integration.jms.bridge.TransactionManagerLocatorImpl;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -68,7 +67,6 @@ public class JMSContextTest extends ActiveMQRATestBase
resourceAdapter.setConnectorClassName(InVMConnectorFactory.class.getName());
MyBootstrapContext ctx = new MyBootstrapContext();
- TransactionManagerLocatorImpl.tm = DummyTransactionManager.tm;
resourceAdapter.start(ctx);
ActiveMQRAManagedConnectionFactory mcf = new ActiveMQRAManagedConnectionFactory();
mcf.setResourceAdapter(resourceAdapter);
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/stomp/ConcurrentStompTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/stomp/ConcurrentStompTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/stomp/ConcurrentStompTest.java
new file mode 100644
index 0000000..eb1678a
--- /dev/null
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/stomp/ConcurrentStompTest.java
@@ -0,0 +1,159 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.tests.integration.stomp;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.Socket;
+import java.nio.charset.StandardCharsets;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.activemq.core.protocol.stomp.Stomp;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class ConcurrentStompTest extends StompTestBase
+{
+ private Socket stompSocket_2;
+
+ private ByteArrayOutputStream inputBuffer_2;
+
+ /**
+ * Send messages on 1 socket and receives them concurrently on another socket.
+ */
+ @Test
+ public void testSendManyMessages() throws Exception
+ {
+ try
+ {
+ String connect = "CONNECT\n" + "login: brianm\n" + "passcode: wombats\n\n" + Stomp.NULL;
+
+ sendFrame(connect);
+ String connected = receiveFrame(10000);
+ Assert.assertTrue(connected.startsWith("CONNECTED"));
+
+ stompSocket_2 = createSocket();
+ inputBuffer_2 = new ByteArrayOutputStream();
+
+ sendFrame(stompSocket_2, connect);
+ connected = receiveFrame(stompSocket_2, inputBuffer_2, 10000);
+ Assert.assertTrue(connected.startsWith("CONNECTED"));
+
+ final int count = 1000;
+ final CountDownLatch latch = new CountDownLatch(count);
+
+ String subscribe =
+ "SUBSCRIBE\n" +
+ "destination:" + getQueuePrefix() + getQueueName() + "\n" +
+ "ack:auto\n\n" +
+ Stomp.NULL;
+ sendFrame(stompSocket_2, subscribe);
+ Thread.sleep(2000);
+
+ new Thread()
+ {
+ @Override
+ public void run()
+ {
+ int i = 0;
+ while (true)
+ {
+ try
+ {
+ String frame = receiveFrame(stompSocket_2, inputBuffer_2, 10000);
+ Assert.assertTrue(frame.startsWith("MESSAGE"));
+ Assert.assertTrue(frame.indexOf("destination:") > 0);
+ System.out.println("<<< " + i++);
+ latch.countDown();
+ }
+ catch (Exception e)
+ {
+ break;
+ }
+ }
+ }
+ }.start();
+
+ String send = "SEND\n" + "destination:" + getQueuePrefix() + getQueueName() + "\n";
+ for (int i = 1; i <= count; i++)
+ {
+ // Thread.sleep(1);
+ System.out.println(">>> " + i);
+ sendFrame(send + "count:" + i + "\n\n" + Stomp.NULL);
+ }
+
+ assertTrue(latch.await(60, TimeUnit.SECONDS));
+
+ }
+ finally
+ {
+ stompSocket_2.close();
+ inputBuffer_2.close();
+ }
+
+
+ }
+
+ // Implementation methods
+ // -------------------------------------------------------------------------
+ public void sendFrame(Socket socket, String data) throws Exception
+ {
+ byte[] bytes = data.getBytes(StandardCharsets.UTF_8);
+ OutputStream outputStream = socket.getOutputStream();
+ for (byte b : bytes)
+ {
+ outputStream.write(b);
+ }
+ outputStream.flush();
+ }
+
+ public String receiveFrame(Socket socket, ByteArrayOutputStream input, long timeOut) throws Exception
+ {
+ socket.setSoTimeout((int) timeOut);
+ InputStream is = socket.getInputStream();
+ int c = 0;
+ for (;;)
+ {
+ c = is.read();
+ if (c < 0)
+ {
+ throw new IOException("socket closed.");
+ }
+ else if (c == 0)
+ {
+ c = is.read();
+ if (c != '\n')
+ {
+ byte[] ba = input.toByteArray();
+ System.out.println(new String(ba, StandardCharsets.UTF_8));
+ }
+ Assert.assertEquals("Expecting stomp frame to terminate with \0\n", c, '\n');
+ byte[] ba = input.toByteArray();
+ input.reset();
+ return new String(ba, StandardCharsets.UTF_8);
+ }
+ else
+ {
+ input.write(c);
+ }
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/integration-tests/src/test/java/org/apache/activemq/tests/util/JMSTestBase.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/tests/util/JMSTestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/tests/util/JMSTestBase.java
index ca9b00b..2dae1e5 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/tests/util/JMSTestBase.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/tests/util/JMSTestBase.java
@@ -34,7 +34,6 @@ import java.util.List;
import java.util.Random;
import java.util.Set;
-import com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionManagerImple;
import org.apache.activemq.api.core.TransportConfiguration;
import org.apache.activemq.api.core.management.QueueControl;
import org.apache.activemq.api.jms.management.JMSQueueControl;
@@ -46,7 +45,6 @@ import org.apache.activemq.jms.server.config.ConnectionFactoryConfiguration;
import org.apache.activemq.jms.server.config.impl.ConnectionFactoryConfigurationImpl;
import org.apache.activemq.jms.server.impl.JMSServerManagerImpl;
import org.apache.activemq.service.extensions.ServiceUtils;
-import org.apache.activemq.tests.integration.jms.bridge.TransactionManagerLocatorImpl;
import org.apache.activemq.tests.integration.ra.DummyTransactionManager;
import org.apache.activemq.tests.unit.util.InVMNamingContext;
import org.junit.After;
@@ -234,7 +232,6 @@ public class JMSTestBase extends ServiceTestBase
mbeanServer = null;
- TransactionManagerLocatorImpl.tm = null;
ServiceUtils.setTransactionManager(null);
super.tearDown();
@@ -301,11 +298,6 @@ public class JMSTestBase extends ServiceTestBase
}
}
- protected void useRealTransactionManager()
- {
- ServiceUtils.setTransactionManager((javax.transaction.TransactionManager) new TransactionManagerImple());
- }
-
protected void useDummyTransactionManager()
{
ServiceUtils.setTransactionManager(new DummyTransactionManager());
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/integration-tests/src/test/resources/META-INF/services/org.apache.activemq.service.extensions.transactions.TransactionManagerLocator
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/resources/META-INF/services/org.apache.activemq.service.extensions.transactions.TransactionManagerLocator b/tests/integration-tests/src/test/resources/META-INF/services/org.apache.activemq.service.extensions.transactions.TransactionManagerLocator
index fe26423..e9ef6bf 100644
--- a/tests/integration-tests/src/test/resources/META-INF/services/org.apache.activemq.service.extensions.transactions.TransactionManagerLocator
+++ b/tests/integration-tests/src/test/resources/META-INF/services/org.apache.activemq.service.extensions.transactions.TransactionManagerLocator
@@ -1 +1 @@
-org.apache.activemq.tests.integration.jms.bridge.TransactionManagerLocatorImpl
+org.apache.activemq.tests.extras.jms.bridge.TransactionManagerLocatorImpl
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/jms-tests/pom.xml
----------------------------------------------------------------------
diff --git a/tests/jms-tests/pom.xml b/tests/jms-tests/pom.xml
index 4b3595e..8466285 100644
--- a/tests/jms-tests/pom.xml
+++ b/tests/jms-tests/pom.xml
@@ -95,19 +95,6 @@
<artifactId>geronimo-ejb_3.0_spec</artifactId>
</dependency>
- <!--this specifically for the XA Tests -->
- <dependency>
- <groupId>org.jboss</groupId>
- <artifactId>jboss-transaction-spi</artifactId>
- <version>7.0.0.Final</version>
- <exclusions>
- <exclusion>
- <groupId>org.jboss.logging</groupId>
- <artifactId>jboss-logging-spi</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
<dependency>
<groupId>org.apache.geronimo.components</groupId>
<artifactId>geronimo-jaspi</artifactId>
@@ -154,14 +141,6 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>${skipJmsTests}</skipTests>
- <excludes>
- <!-- TODO: Can we remove XATests? Can we remove them all? -->
- <exclude>org/apache/activemq/jms/tests/XARecoveryTest.java</exclude>
- <exclude>org/apache/activemq/jms/tests/XAResourceRecoveryTest.java</exclude>
- <exclude>org/apache/activemq/jms/tests/XATest.java</exclude>
- <exclude>org/apache/activemq/jms/tests/stress/*.java</exclude>
- <exclude>org/apache/activemq/jms/tests/manual/**</exclude>
- </excludes>
<argLine>${activemq-surefire-argline}</argLine>
</configuration>
</plugin>
[10/15] activemq-6 git commit: Refactored the testsuite a bit
Posted by jb...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/jms/bridge/BridgeTestBase.java
----------------------------------------------------------------------
diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/jms/bridge/BridgeTestBase.java b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/jms/bridge/BridgeTestBase.java
new file mode 100644
index 0000000..ee53af0
--- /dev/null
+++ b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/jms/bridge/BridgeTestBase.java
@@ -0,0 +1,613 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.tests.extras.jms.bridge;
+
+import javax.jms.BytesMessage;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.DeliveryMode;
+import javax.jms.Destination;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.jms.Topic;
+import javax.jms.XAConnectionFactory;
+import javax.transaction.TransactionManager;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Set;
+
+import com.arjuna.ats.arjuna.coordinator.TransactionReaper;
+import com.arjuna.ats.arjuna.coordinator.TxControl;
+import com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionManagerImple;
+import org.apache.activemq.api.core.TransportConfiguration;
+import org.apache.activemq.api.core.management.ResourceNames;
+import org.apache.activemq.api.jms.ActiveMQJMSClient;
+import org.apache.activemq.api.jms.JMSFactoryType;
+import org.apache.activemq.api.jms.management.JMSQueueControl;
+import org.apache.activemq.api.jms.management.TopicControl;
+import org.apache.activemq.core.config.Configuration;
+import org.apache.activemq.core.registry.JndiBindingRegistry;
+import org.apache.activemq.core.remoting.impl.invm.TransportConstants;
+import org.apache.activemq.core.server.ActiveMQServer;
+import org.apache.activemq.core.server.ActiveMQServers;
+import org.apache.activemq.core.server.management.ManagementService;
+import org.apache.activemq.jms.bridge.ConnectionFactoryFactory;
+import org.apache.activemq.jms.bridge.DestinationFactory;
+import org.apache.activemq.jms.bridge.QualityOfServiceMode;
+import org.apache.activemq.jms.client.ActiveMQConnectionFactory;
+import org.apache.activemq.jms.client.ActiveMQJMSConnectionFactory;
+import org.apache.activemq.jms.client.ActiveMQMessage;
+import org.apache.activemq.jms.client.ActiveMQXAConnectionFactory;
+import org.apache.activemq.jms.server.JMSServerManager;
+import org.apache.activemq.jms.server.impl.JMSServerManagerImpl;
+import org.apache.activemq.tests.integration.IntegrationTestLogger;
+import org.apache.activemq.tests.unit.util.InVMNamingContext;
+import org.apache.activemq.tests.util.UnitTestCase;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+
+/**
+ * A BridgeTestBase
+ *
+ * @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
+ */
+public abstract class BridgeTestBase extends UnitTestCase
+{
+ private static final IntegrationTestLogger log = IntegrationTestLogger.LOGGER;
+
+ protected ConnectionFactoryFactory cff0, cff1;
+
+ protected ConnectionFactoryFactory cff0xa, cff1xa;
+
+ protected ConnectionFactory cf0, cf1;
+
+ protected XAConnectionFactory cf0xa, cf1xa;
+
+ protected DestinationFactory sourceQueueFactory;
+ protected DestinationFactory targetQueueFactory;
+ protected DestinationFactory localTargetQueueFactory;
+ protected DestinationFactory sourceTopicFactory;
+
+ protected Queue sourceQueue, targetQueue, localTargetQueue;
+
+ protected Topic sourceTopic;
+
+ protected ActiveMQServer server0;
+
+ protected JMSServerManager jmsServer0;
+
+ protected ActiveMQServer server1;
+
+ protected JMSServerManager jmsServer1;
+
+ private InVMNamingContext context0;
+
+ protected InVMNamingContext context1;
+
+ protected HashMap<String, Object> params1;
+
+ protected ConnectionFactoryFactory cff0LowProducerWindow;
+
+ @Override
+ @Before
+ public void setUp() throws Exception
+ {
+ super.setUp();
+
+ // Start the servers
+ Configuration conf0 = createBasicConfig()
+ .setJournalDirectory(getJournalDir(0, false))
+ .setBindingsDirectory(getBindingsDir(0, false))
+ .addAcceptorConfiguration(new TransportConfiguration(INVM_ACCEPTOR_FACTORY));
+
+ server0 = addServer(ActiveMQServers.newActiveMQServer(conf0, false));
+
+ context0 = new InVMNamingContext();
+ jmsServer0 = new JMSServerManagerImpl(server0);
+ jmsServer0.setRegistry(new JndiBindingRegistry(context0));
+ jmsServer0.start();
+
+ params1 = new HashMap<String, Object>();
+ params1.put(TransportConstants.SERVER_ID_PROP_NAME, 1);
+
+ Configuration conf1 = createBasicConfig()
+ .setJournalDirectory(getJournalDir(1, false))
+ .setBindingsDirectory(getBindingsDir(1, false))
+ .addAcceptorConfiguration(new TransportConfiguration(INVM_ACCEPTOR_FACTORY, params1));
+
+ server1 = addServer(ActiveMQServers.newActiveMQServer(conf1, false));
+
+ context1 = new InVMNamingContext();
+
+ jmsServer1 = new JMSServerManagerImpl(server1);
+ jmsServer1.setRegistry(new JndiBindingRegistry(context1));
+ jmsServer1.start();
+
+ createQueue("sourceQueue", 0);
+
+ jmsServer0.createTopic(false, "sourceTopic", "/topic/sourceTopic");
+
+ createQueue("localTargetQueue", 0);
+
+ createQueue("targetQueue", 1);
+
+ setUpAdministeredObjects();
+ TxControl.enable();
+ // We need a local transaction and recovery manager
+ // We must start this after the remote servers have been created or it won't
+ // have deleted the database and the recovery manager may attempt to recover transactions
+
+ }
+
+ protected void createQueue(final String queueName, final int index) throws Exception
+ {
+ JMSServerManager server = jmsServer0;
+ if (index == 1)
+ {
+ server = jmsServer1;
+ }
+ assertTrue("queue '/queue/" + queueName + "' created",
+ server.createQueue(false, queueName, null, true, "/queue/" + queueName));
+ }
+
+ @Override
+ @After
+ public void tearDown() throws Exception
+ {
+ checkEmpty(sourceQueue, 0);
+ checkEmpty(localTargetQueue, 0);
+ checkEmpty(targetQueue, 1);
+
+ // Check no subscriptions left lying around
+
+ checkNoSubscriptions(sourceTopic, 0);
+ if (cff0 instanceof ActiveMQConnectionFactory)
+ {
+ ((ActiveMQConnectionFactory) cff0).close();
+ }
+ if (cff1 instanceof ActiveMQConnectionFactory)
+ {
+ ((ActiveMQConnectionFactory) cff1).close();
+ }
+ stopComponent(jmsServer0);
+ stopComponent(jmsServer1);
+ cff0 = cff1 = null;
+ cff0xa = cff1xa = null;
+
+ cf0 = cf1 = null;
+
+ cf0xa = cf1xa = null;
+
+ sourceQueueFactory = targetQueueFactory = localTargetQueueFactory = sourceTopicFactory = null;
+
+ sourceQueue = targetQueue = localTargetQueue = null;
+
+ sourceTopic = null;
+
+ server0 = null;
+
+ jmsServer0 = null;
+
+ server1 = null;
+
+ jmsServer1 = null;
+ if (context0 != null)
+ context0.close();
+ context0 = null;
+ if (context1 != null)
+ context1.close();
+ context1 = null;
+
+ // Shutting down Arjuna threads
+ TxControl.disable(true);
+
+ TransactionReaper.terminate(false);
+ super.tearDown();
+ }
+
+
+ protected void setUpAdministeredObjects() throws Exception
+ {
+ cff0LowProducerWindow = new ConnectionFactoryFactory()
+ {
+ public ConnectionFactory createConnectionFactory() throws Exception
+ {
+ ActiveMQConnectionFactory cf = ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF,
+ new TransportConfiguration(
+ INVM_CONNECTOR_FACTORY));
+
+ // Note! We disable automatic reconnection on the session factory. The bridge needs to do the reconnection
+ cf.setReconnectAttempts(0);
+ cf.setBlockOnNonDurableSend(true);
+ cf.setBlockOnDurableSend(true);
+ cf.setCacheLargeMessagesClient(true);
+ cf.setProducerWindowSize(100);
+
+ return cf;
+ }
+
+ };
+
+
+ cff0 = new ConnectionFactoryFactory()
+ {
+ public ConnectionFactory createConnectionFactory() throws Exception
+ {
+ ActiveMQConnectionFactory cf = ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF,
+ new TransportConfiguration(
+ INVM_CONNECTOR_FACTORY));
+
+ // Note! We disable automatic reconnection on the session factory. The bridge needs to do the reconnection
+ cf.setReconnectAttempts(0);
+ cf.setBlockOnNonDurableSend(true);
+ cf.setBlockOnDurableSend(true);
+ cf.setCacheLargeMessagesClient(true);
+
+ return cf;
+ }
+
+ };
+
+ cff0xa = new ConnectionFactoryFactory()
+ {
+ public Object createConnectionFactory() throws Exception
+ {
+ ActiveMQXAConnectionFactory cf = (ActiveMQXAConnectionFactory) ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.XA_CF,
+ new TransportConfiguration(
+ INVM_CONNECTOR_FACTORY));
+
+ // Note! We disable automatic reconnection on the session factory. The bridge needs to do the reconnection
+ cf.setReconnectAttempts(0);
+ cf.setBlockOnNonDurableSend(true);
+ cf.setBlockOnDurableSend(true);
+ cf.setCacheLargeMessagesClient(true);
+
+ return cf;
+ }
+
+ };
+
+ cf0 = (ConnectionFactory) cff0.createConnectionFactory();
+ cf0xa = (XAConnectionFactory) cff0xa.createConnectionFactory();
+
+ cff1 = new ConnectionFactoryFactory()
+ {
+
+ public ConnectionFactory createConnectionFactory() throws Exception
+ {
+ ActiveMQJMSConnectionFactory cf = (ActiveMQJMSConnectionFactory) ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF,
+ new TransportConfiguration(
+ INVM_CONNECTOR_FACTORY,
+ params1));
+
+ // Note! We disable automatic reconnection on the session factory. The bridge needs to do the reconnection
+ cf.setReconnectAttempts(0);
+ cf.setBlockOnNonDurableSend(true);
+ cf.setBlockOnDurableSend(true);
+ cf.setCacheLargeMessagesClient(true);
+
+ return cf;
+ }
+ };
+
+ cff1xa = new ConnectionFactoryFactory()
+ {
+
+ public XAConnectionFactory createConnectionFactory() throws Exception
+ {
+ ActiveMQXAConnectionFactory cf = (ActiveMQXAConnectionFactory) ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.XA_CF,
+ new TransportConfiguration(
+ INVM_CONNECTOR_FACTORY,
+ params1));
+
+ // Note! We disable automatic reconnection on the session factory. The bridge needs to do the reconnection
+ cf.setReconnectAttempts(0);
+ cf.setBlockOnNonDurableSend(true);
+ cf.setBlockOnDurableSend(true);
+ cf.setCacheLargeMessagesClient(true);
+
+ return cf;
+ }
+ };
+
+ cf1 = (ConnectionFactory) cff1.createConnectionFactory();
+ cf1xa = (XAConnectionFactory) cff1xa.createConnectionFactory();
+
+ sourceQueueFactory = new DestinationFactory()
+ {
+ public Destination createDestination() throws Exception
+ {
+ return (Destination) context0.lookup("/queue/sourceQueue");
+ }
+ };
+
+ sourceQueue = (Queue) sourceQueueFactory.createDestination();
+
+ targetQueueFactory = new DestinationFactory()
+ {
+ public Destination createDestination() throws Exception
+ {
+ return (Destination) context1.lookup("/queue/targetQueue");
+ }
+ };
+
+ targetQueue = (Queue) targetQueueFactory.createDestination();
+
+ sourceTopicFactory = new DestinationFactory()
+ {
+ public Destination createDestination() throws Exception
+ {
+ return (Destination) context0.lookup("/topic/sourceTopic");
+ }
+ };
+
+ sourceTopic = (Topic) sourceTopicFactory.createDestination();
+
+ localTargetQueueFactory = new DestinationFactory()
+ {
+ public Destination createDestination() throws Exception
+ {
+ return (Destination) context0.lookup("/queue/localTargetQueue");
+ }
+ };
+
+ localTargetQueue = (Queue) localTargetQueueFactory.createDestination();
+ }
+
+ protected void sendMessages(final ConnectionFactory cf,
+ final Destination dest,
+ final int start,
+ final int numMessages,
+ final boolean persistent,
+ final boolean largeMessage) throws Exception
+ {
+ Connection conn = null;
+
+ try
+ {
+ conn = cf.createConnection();
+
+ Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageProducer prod = sess.createProducer(dest);
+
+ prod.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
+
+ for (int i = start; i < start + numMessages; i++)
+ {
+ if (largeMessage)
+ {
+ BytesMessage msg = sess.createBytesMessage();
+ ((ActiveMQMessage) msg).setInputStream(UnitTestCase.createFakeLargeStream(1024L * 1024L));
+ msg.setStringProperty("msg", "message" + i);
+ prod.send(msg);
+ }
+ else
+ {
+ TextMessage tm = sess.createTextMessage("message" + i);
+ prod.send(tm);
+ }
+
+ }
+ }
+ finally
+ {
+ if (conn != null)
+ {
+ conn.close();
+ }
+ }
+ }
+
+ protected void checkMessagesReceived(final ConnectionFactory cf,
+ final Destination dest,
+ final QualityOfServiceMode qosMode,
+ final int numMessages,
+ final boolean longWaitForFirst,
+ final boolean largeMessage) throws Exception
+ {
+ Connection conn = null;
+
+ try
+ {
+ conn = cf.createConnection();
+
+ conn.start();
+
+ Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageConsumer cons = sess.createConsumer(dest);
+
+ // Consume the messages
+
+ Set<String> msgs = new HashSet<String>();
+
+ int count = 0;
+
+ // We always wait longer for the first one - it may take some time to arrive especially if we are
+ // waiting for recovery to kick in
+ while (true)
+ {
+ Message tm = cons.receive(count == 0 ? (longWaitForFirst ? 60000 : 10000) : 5000);
+
+ if (tm == null)
+ {
+ break;
+ }
+
+ // log.info("Got message " + tm.getText());
+
+ if (largeMessage)
+ {
+ BytesMessage bmsg = (BytesMessage) tm;
+ msgs.add(tm.getStringProperty("msg"));
+ byte[] buffRead = new byte[1024];
+ for (int i = 0; i < 1024; i++)
+ {
+ Assert.assertEquals(1024, bmsg.readBytes(buffRead));
+ }
+ }
+ else
+ {
+ msgs.add(((TextMessage) tm).getText());
+ }
+
+ count++;
+
+ }
+
+ if (qosMode == QualityOfServiceMode.ONCE_AND_ONLY_ONCE || qosMode == QualityOfServiceMode.DUPLICATES_OK)
+ {
+ // All the messages should be received
+
+ for (int i = 0; i < numMessages; i++)
+ {
+ Assert.assertTrue("quality=" + qosMode + ", #=" + i + ", message=" + msgs, msgs.contains("message" + i));
+ }
+
+ // Should be no more
+ if (qosMode == QualityOfServiceMode.ONCE_AND_ONLY_ONCE)
+ {
+ Assert.assertEquals(numMessages, msgs.size());
+ }
+ }
+ else if (qosMode == QualityOfServiceMode.AT_MOST_ONCE)
+ {
+ // No *guarantee* that any messages will be received
+ // but you still might get some depending on how/where the crash occurred
+ }
+
+ BridgeTestBase.log.trace("Check complete");
+
+ }
+ finally
+ {
+ if (conn != null)
+ {
+ conn.close();
+ }
+ }
+ }
+
+ protected void checkAllMessageReceivedInOrder(final ConnectionFactory cf,
+ final Destination dest,
+ final int start,
+ final int numMessages,
+ final boolean largeMessage) throws Exception
+ {
+ Connection conn = null;
+ try
+ {
+ conn = cf.createConnection();
+
+ conn.start();
+
+ Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageConsumer cons = sess.createConsumer(dest);
+
+ // Consume the messages
+
+ for (int i = 0; i < numMessages; i++)
+ {
+ Message tm = cons.receive(30000);
+
+ Assert.assertNotNull(tm);
+
+ if (largeMessage)
+ {
+ BytesMessage bmsg = (BytesMessage) tm;
+ Assert.assertEquals("message" + (i + start), tm.getStringProperty("msg"));
+ byte[] buffRead = new byte[1024];
+ for (int j = 0; j < 1024; j++)
+ {
+ Assert.assertEquals(1024, bmsg.readBytes(buffRead));
+ }
+ }
+ else
+ {
+ Assert.assertEquals("message" + (i + start), ((TextMessage) tm).getText());
+ }
+ }
+ }
+ finally
+ {
+ if (conn != null)
+ {
+ conn.close();
+ }
+ }
+ }
+
+ public boolean checkEmpty(final Queue queue, final int index) throws Exception
+ {
+ ManagementService managementService = server0.getManagementService();
+ if (index == 1)
+ {
+ managementService = server1.getManagementService();
+ }
+ JMSQueueControl queueControl = (JMSQueueControl) managementService.getResource(ResourceNames.JMS_QUEUE + queue.getQueueName());
+
+ //server may be closed
+ if (queueControl != null)
+ {
+ queueControl.flushExecutor();
+ Long messageCount = queueControl.getMessageCount();
+
+ if (messageCount > 0)
+ {
+ queueControl.removeMessages(null);
+ }
+ }
+ return true;
+ }
+
+ protected void checkNoSubscriptions(final Topic topic, final int index) throws Exception
+ {
+ ManagementService managementService = server0.getManagementService();
+ if (index == 1)
+ {
+ managementService = server1.getManagementService();
+ }
+ TopicControl topicControl = (TopicControl) managementService.getResource(ResourceNames.JMS_TOPIC + topic.getTopicName());
+ Assert.assertEquals(0, topicControl.getSubscriptionCount());
+
+ }
+
+ protected void removeAllMessages(final String queueName, final int index) throws Exception
+ {
+ ManagementService managementService = server0.getManagementService();
+ if (index == 1)
+ {
+ managementService = server1.getManagementService();
+ }
+ JMSQueueControl queueControl = (JMSQueueControl) managementService.getResource(ResourceNames.JMS_QUEUE + queueName);
+ queueControl.removeMessages(null);
+ }
+
+ protected TransactionManager newTransactionManager()
+ {
+ return new TransactionManagerImple();
+ }
+
+ // Inner classes -------------------------------------------------------------------
+}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/jms/bridge/ClusteredBridgeTestBase.java
----------------------------------------------------------------------
diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/jms/bridge/ClusteredBridgeTestBase.java b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/jms/bridge/ClusteredBridgeTestBase.java
new file mode 100644
index 0000000..dffe667
--- /dev/null
+++ b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/jms/bridge/ClusteredBridgeTestBase.java
@@ -0,0 +1,312 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.tests.extras.jms.bridge;
+
+import javax.jms.ConnectionFactory;
+import javax.jms.Destination;
+import javax.naming.Context;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import com.arjuna.ats.arjuna.coordinator.TransactionReaper;
+import com.arjuna.ats.arjuna.coordinator.TxControl;
+import org.apache.activemq.api.core.ActiveMQException;
+import org.apache.activemq.api.core.TransportConfiguration;
+import org.apache.activemq.api.core.client.ClientConsumer;
+import org.apache.activemq.api.core.client.ClientMessage;
+import org.apache.activemq.api.core.client.ClientProducer;
+import org.apache.activemq.api.core.client.ClientSession;
+import org.apache.activemq.api.core.client.ClientSessionFactory;
+import org.apache.activemq.api.core.client.FailoverEventListener;
+import org.apache.activemq.api.core.client.FailoverEventType;
+import org.apache.activemq.api.core.client.ActiveMQClient;
+import org.apache.activemq.api.core.client.ServerLocator;
+import org.apache.activemq.api.jms.ActiveMQJMSClient;
+import org.apache.activemq.api.jms.JMSFactoryType;
+import org.apache.activemq.core.config.Configuration;
+import org.apache.activemq.core.config.ha.ReplicaPolicyConfiguration;
+import org.apache.activemq.core.config.ha.ReplicatedPolicyConfiguration;
+import org.apache.activemq.core.registry.JndiBindingRegistry;
+import org.apache.activemq.core.remoting.impl.invm.TransportConstants;
+import org.apache.activemq.core.server.ActiveMQServer;
+import org.apache.activemq.core.server.ActiveMQServers;
+import org.apache.activemq.jms.bridge.ConnectionFactoryFactory;
+import org.apache.activemq.jms.bridge.DestinationFactory;
+import org.apache.activemq.jms.client.ActiveMQConnectionFactory;
+import org.apache.activemq.jms.server.JMSServerManager;
+import org.apache.activemq.jms.server.impl.JMSServerManagerImpl;
+import org.apache.activemq.tests.unit.util.InVMContext;
+import org.apache.activemq.tests.util.ServiceTestBase;
+import org.junit.After;
+import org.junit.Before;
+
+/**
+ * A ClusteredBridgeTestBase
+ * This class serves as a base class for jms bridge tests in
+ * clustered scenarios.
+ *
+ * @author <a href="mailto:hgao@redhat.com">Howard Gao</a>
+ */
+public abstract class ClusteredBridgeTestBase extends ServiceTestBase
+{
+ private static int index = 0;
+
+ protected Map<String, ServerGroup> groups = new HashMap<String, ServerGroup>();
+
+ @Override
+ @Before
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ Iterator<ServerGroup> iter = groups.values().iterator();
+ while (iter.hasNext())
+ {
+ iter.next().start();
+ }
+ TxControl.enable();
+ }
+
+ @Override
+ @After
+ public void tearDown() throws Exception
+ {
+ Iterator<ServerGroup> iter = groups.values().iterator();
+ while (iter.hasNext())
+ {
+ iter.next().stop();
+ }
+
+ TxControl.disable(true);
+
+ TransactionReaper.terminate(false);
+
+ super.tearDown();
+ }
+
+ //create a live/backup pair.
+ protected ServerGroup createServerGroup(String name) throws Exception
+ {
+ ServerGroup server = groups.get(name);
+ if (server == null)
+ {
+ server = new ServerGroup(name, groups.size());
+ server.create();
+ groups.put(name, server);
+ }
+ return server;
+ }
+
+ //each ServerGroup represents a live/backup pair
+ protected class ServerGroup
+ {
+ private static final int ID_OFFSET = 100;
+ private String name;
+ private int id;
+
+ private JMSServerManager liveNode;
+ private JMSServerManager backupNode;
+
+ private TransportConfiguration liveConnector;
+ private TransportConfiguration backupConnector;
+
+ private Context liveContext;
+
+ private ServerLocator locator;
+ private ClientSessionFactory sessionFactory;
+
+ /**
+ * @param name - name of the group
+ * @param id - id of the live (should be < 100)
+ */
+ public ServerGroup(String name, int id)
+ {
+ this.name = name;
+ this.id = id;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void create() throws Exception
+ {
+ Map<String, Object> params0 = new HashMap<String, Object>();
+ params0.put(TransportConstants.SERVER_ID_PROP_NAME, id);
+ liveConnector = new TransportConfiguration(INVM_CONNECTOR_FACTORY, params0, "in-vm-live");
+
+ Map<String, Object> params = new HashMap<String, Object>();
+ params.put(TransportConstants.SERVER_ID_PROP_NAME, id + ID_OFFSET);
+ backupConnector = new TransportConfiguration(INVM_CONNECTOR_FACTORY, params, "in-vm-backup");
+
+ //live
+ Configuration conf0 = createBasicConfig()
+ .setJournalDirectory(getJournalDir(id, false))
+ .setBindingsDirectory(getBindingsDir(id, false))
+ .addAcceptorConfiguration(new TransportConfiguration(INVM_ACCEPTOR_FACTORY, params0))
+ .addConnectorConfiguration(liveConnector.getName(), liveConnector)
+ .setHAPolicyConfiguration(new ReplicatedPolicyConfiguration())
+ .addClusterConfiguration(basicClusterConnectionConfig(liveConnector.getName()));
+
+ ActiveMQServer server0 = addServer(ActiveMQServers.newActiveMQServer(conf0, true));
+
+ liveContext = new InVMContext();
+ liveNode = new JMSServerManagerImpl(server0);
+ liveNode.setRegistry(new JndiBindingRegistry(liveContext));
+
+ //backup
+ Configuration conf = createBasicConfig()
+ .setJournalDirectory(getJournalDir(id, true))
+ .setBindingsDirectory(getBindingsDir(id, true))
+ .addAcceptorConfiguration(new TransportConfiguration(INVM_ACCEPTOR_FACTORY, params))
+ .addConnectorConfiguration(backupConnector.getName(), backupConnector)
+ .addConnectorConfiguration(liveConnector.getName(), liveConnector)
+ .setHAPolicyConfiguration(new ReplicaPolicyConfiguration())
+ .addClusterConfiguration(basicClusterConnectionConfig(backupConnector.getName(), liveConnector.getName()));
+
+ ActiveMQServer backup = addServer(ActiveMQServers.newActiveMQServer(conf, true));
+
+ Context context = new InVMContext();
+
+ backupNode = new JMSServerManagerImpl(backup);
+ backupNode.setRegistry(new JndiBindingRegistry(context));
+ }
+
+ public void start() throws Exception
+ {
+ liveNode.start();
+ waitForServer(liveNode.getActiveMQServer());
+ backupNode.start();
+ waitForRemoteBackupSynchronization(backupNode.getActiveMQServer());
+
+ locator = ActiveMQClient.createServerLocatorWithHA(liveConnector);
+ locator.setReconnectAttempts(-1);
+ sessionFactory = locator.createSessionFactory();
+ }
+
+ public void stop() throws Exception
+ {
+ sessionFactory.close();
+ locator.close();
+ liveNode.stop();
+ backupNode.stop();
+ }
+
+ public void createQueue(String queueName) throws Exception
+ {
+ liveNode.createQueue(true, queueName, null, true, "/queue/" + queueName);
+ }
+
+ public ConnectionFactoryFactory getConnectionFactoryFactory()
+ {
+ ConnectionFactoryFactory cff = new ConnectionFactoryFactory()
+ {
+ public ConnectionFactory createConnectionFactory() throws Exception
+ {
+ ActiveMQConnectionFactory cf = ActiveMQJMSClient.createConnectionFactoryWithHA(JMSFactoryType.XA_CF,
+ liveConnector);
+ cf.getServerLocator().setReconnectAttempts(-1);
+ return cf;
+ }
+ };
+
+ return cff;
+ }
+
+ public DestinationFactory getDestinationFactory(final String queueName)
+ {
+
+ DestinationFactory destFactory = new DestinationFactory()
+ {
+ public Destination createDestination() throws Exception
+ {
+ return (Destination) liveContext.lookup("/queue/" + queueName);
+ }
+ };
+ return destFactory;
+ }
+
+ public void sendMessages(String queueName, int num) throws ActiveMQException
+ {
+ ClientSession session = sessionFactory.createSession();
+ ClientProducer producer = session.createProducer("jms.queue." + queueName);
+ for (int i = 0; i < num; i++)
+ {
+ ClientMessage m = session.createMessage(true);
+ m.putStringProperty("bridge-message", "hello " + index);
+ index++;
+ producer.send(m);
+ }
+ session.close();
+ }
+
+ public void receiveMessages(String queueName, int num, boolean checkDup) throws ActiveMQException
+ {
+ ClientSession session = sessionFactory.createSession();
+ session.start();
+ ClientConsumer consumer = session.createConsumer("jms.queue." + queueName);
+ for (int i = 0; i < num; i++)
+ {
+ ClientMessage m = consumer.receive(30000);
+ assertNotNull("i=" + i, m);
+ assertNotNull(m.getStringProperty("bridge-message"));
+ m.acknowledge();
+ }
+
+ ClientMessage m = consumer.receive(500);
+ if (checkDup)
+ {
+ assertNull(m);
+ }
+ else
+ {
+ //drain messages
+ while (m != null)
+ {
+ m = consumer.receive(200);
+ }
+ }
+
+ session.close();
+ }
+
+ public void crashLive() throws Exception
+ {
+ final CountDownLatch latch = new CountDownLatch(1);
+ sessionFactory.addFailoverListener(new FailoverEventListener()
+ {
+
+ @Override
+ public void failoverEvent(FailoverEventType eventType)
+ {
+ if (eventType == FailoverEventType.FAILOVER_COMPLETED)
+ {
+ latch.countDown();
+ }
+ }
+ });
+
+ liveNode.getActiveMQServer().stop();
+
+ boolean ok = latch.await(10000, TimeUnit.MILLISECONDS);
+ assertTrue(ok);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/jms/bridge/JMSBridgeClusteredTest.java
----------------------------------------------------------------------
diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/jms/bridge/JMSBridgeClusteredTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/jms/bridge/JMSBridgeClusteredTest.java
new file mode 100644
index 0000000..f356540
--- /dev/null
+++ b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/jms/bridge/JMSBridgeClusteredTest.java
@@ -0,0 +1,276 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.tests.extras.jms.bridge;
+
+import javax.transaction.TransactionManager;
+
+import com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionManagerImple;
+import org.apache.activemq.api.core.ActiveMQException;
+import org.apache.activemq.jms.bridge.ConnectionFactoryFactory;
+import org.apache.activemq.jms.bridge.DestinationFactory;
+import org.apache.activemq.jms.bridge.QualityOfServiceMode;
+import org.apache.activemq.jms.bridge.impl.JMSBridgeImpl;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * A JMSBridgeClusteredTest
+ * <p/>
+ * Tests of jms bridge using HA connection factories.
+ *
+ * @author <a href="mailto:hgao@redhat.com">Howard Gao</a>
+ */
+public class JMSBridgeClusteredTest extends ClusteredBridgeTestBase
+{
+ private ServerGroup sourceServer;
+ private ServerGroup targetServer;
+
+ private String sourceQueueName = "SourceQueue";
+ private String targetQueueName = "TargetQueue";
+
+ @Override
+ @Before
+ public void setUp() throws Exception
+ {
+ super.setUp();
+
+ sourceServer = createServerGroup("source-server");
+ targetServer = createServerGroup("target-server");
+
+ sourceServer.start();
+ targetServer.start();
+
+ sourceServer.createQueue(sourceQueueName);
+ targetServer.createQueue(targetQueueName);
+ }
+
+ @Test
+ public void testBridgeOnFailoverXA() throws Exception
+ {
+ performSourceAndTargetCrashAndFailover(QualityOfServiceMode.ONCE_AND_ONLY_ONCE);
+ }
+
+ @Test
+ public void testBridgeOnFailoverDupsOk() throws Exception
+ {
+ performSourceAndTargetCrashAndFailover(QualityOfServiceMode.DUPLICATES_OK);
+ }
+
+ @Test
+ public void testBridgeOnFailoverAtMostOnce() throws Exception
+ {
+ performSourceAndTargetCrashAndFailover(QualityOfServiceMode.AT_MOST_ONCE);
+ }
+
+ @Test
+ public void testCrashAndFailoverWithMessagesXA() throws Exception
+ {
+ performSourceAndTargetCrashAndFailoverWithMessages(QualityOfServiceMode.ONCE_AND_ONLY_ONCE);
+ }
+
+ //test messages are correctly bridged when failover happens during a batch send.
+ //first send some messages, make sure bridge doesn't send it (below batch size)
+ //then crash the live
+ //then send more messages
+ //then receive those messages, no more, no less.
+ //this test are valid for ONCE_AND_ONLY_ONCE and AT_MOST_ONCE.
+ //with DUPS_OK the test failed because some messages are delivered again
+ //after failover, which is fine as in this mode duplication is allowed.
+ public void performSourceAndTargetCrashAndFailoverWithMessages(QualityOfServiceMode mode) throws Exception
+ {
+ JMSBridgeImpl bridge = null;
+ TransactionManager txMgr = null;
+
+ try
+ {
+ ConnectionFactoryFactory sourceCFF = sourceServer.getConnectionFactoryFactory();
+ ConnectionFactoryFactory targetCFF = targetServer.getConnectionFactoryFactory();
+ DestinationFactory sourceQueueFactory = sourceServer.getDestinationFactory(sourceQueueName);
+ DestinationFactory targetQueueFactory = targetServer.getDestinationFactory(targetQueueName);
+
+ //even number
+ final int batchSize = 4;
+ bridge = new JMSBridgeImpl(sourceCFF,
+ targetCFF,
+ sourceQueueFactory,
+ targetQueueFactory,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 1000,
+ -1,
+ mode,
+ batchSize,
+ -1,
+ null,
+ null,
+ false);
+
+ txMgr = newTransactionManager();
+ bridge.setTransactionManager(txMgr);
+
+ //start the bridge
+ bridge.start();
+
+ System.out.println("started bridge");
+
+ final int NUM_MESSAGES = batchSize / 2;
+
+ //send some messages to source
+ sendMessages(sourceServer, sourceQueueName, NUM_MESSAGES);
+ //receive from target, no message should be received.
+ receiveMessages(targetServer, targetQueueName, 0);
+
+ //now crash target server
+ targetServer.crashLive();
+
+ //send more
+ sendMessages(sourceServer, sourceQueueName, NUM_MESSAGES);
+
+ receiveMessages(targetServer, targetQueueName, batchSize);
+
+ //send some again
+ sendMessages(sourceServer, sourceQueueName, NUM_MESSAGES);
+ //check no messages arrived.
+ receiveMessages(targetServer, targetQueueName, 0);
+ //now crash source server
+ sourceServer.crashLive();
+
+ //verify bridge still work
+ sendMessages(sourceServer, sourceQueueName, NUM_MESSAGES);
+ receiveMessages(targetServer, targetQueueName, batchSize);
+ }
+ finally
+ {
+ if (bridge != null)
+ {
+ bridge.stop();
+ }
+ }
+ }
+
+ /*
+ * Deploy a bridge, source and target queues are in
+ * separate live/backup pairs. Source and Target CF are ha.
+ * Test the bridge work when the live servers crash.
+ */
+ private void performSourceAndTargetCrashAndFailover(QualityOfServiceMode mode) throws Exception
+ {
+
+ JMSBridgeImpl bridge = null;
+ TransactionManager txMgr = null;
+
+ try
+ {
+ ConnectionFactoryFactory sourceCFF = sourceServer.getConnectionFactoryFactory();
+ ConnectionFactoryFactory targetCFF = targetServer.getConnectionFactoryFactory();
+ DestinationFactory sourceQueueFactory = sourceServer.getDestinationFactory(sourceQueueName);
+ DestinationFactory targetQueueFactory = targetServer.getDestinationFactory(targetQueueName);
+
+ bridge = new JMSBridgeImpl(sourceCFF,
+ targetCFF,
+ sourceQueueFactory,
+ targetQueueFactory,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 1000,
+ -1,
+ mode,
+ 10,
+ 1000,
+ null,
+ null,
+ false);
+
+ txMgr = newTransactionManager();
+ bridge.setTransactionManager(txMgr);
+
+ //start the bridge
+ bridge.start();
+
+ final int NUM_MESSAGES = 10;
+
+ //send some messages to source
+ sendMessages(sourceServer, sourceQueueName, NUM_MESSAGES);
+ //receive from target
+ receiveMessages(targetServer, targetQueueName, NUM_MESSAGES);
+
+ //now crash target server
+ targetServer.crashLive();
+
+ //verify bridge still works
+ sendMessages(sourceServer, sourceQueueName, NUM_MESSAGES);
+ receiveMessages(targetServer, targetQueueName, NUM_MESSAGES);
+
+ //now crash source server
+ sourceServer.crashLive();
+
+ //verify bridge still work
+ sendMessages(sourceServer, sourceQueueName, NUM_MESSAGES);
+ receiveMessages(targetServer, targetQueueName, NUM_MESSAGES, mode == QualityOfServiceMode.ONCE_AND_ONLY_ONCE);
+ }
+ finally
+ {
+ if (bridge != null)
+ {
+ bridge.stop();
+ }
+ }
+ }
+
+ private void sendMessages(ServerGroup server, String queueName, int num) throws ActiveMQException
+ {
+ server.sendMessages(queueName, num);
+ }
+
+ private void receiveMessages(ServerGroup server, String queueName, int num, boolean checkDup) throws ActiveMQException
+ {
+ try
+ {
+ server.receiveMessages(queueName, num, checkDup);
+ }
+ catch (ActiveMQException e)
+ {
+ e.printStackTrace();
+ throw e;
+ }
+ }
+
+ private void receiveMessages(ServerGroup server, String queueName, int num) throws ActiveMQException
+ {
+ try
+ {
+ server.receiveMessages(queueName, num, false);
+ }
+ catch (ActiveMQException e)
+ {
+ e.printStackTrace();
+ throw e;
+ }
+ }
+
+ protected TransactionManager newTransactionManager()
+ {
+ return new TransactionManagerImple();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/jms/bridge/JMSBridgeReconnectionTest.java
----------------------------------------------------------------------
diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/jms/bridge/JMSBridgeReconnectionTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/jms/bridge/JMSBridgeReconnectionTest.java
new file mode 100644
index 0000000..972fe4b
--- /dev/null
+++ b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/jms/bridge/JMSBridgeReconnectionTest.java
@@ -0,0 +1,559 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.tests.extras.jms.bridge;
+
+import org.apache.activemq.api.core.TransportConfiguration;
+import org.apache.activemq.api.core.client.ClientSession;
+import org.apache.activemq.api.jms.ActiveMQJMSClient;
+import org.apache.activemq.api.jms.JMSFactoryType;
+import org.apache.activemq.jms.bridge.ConnectionFactoryFactory;
+import org.apache.activemq.jms.bridge.QualityOfServiceMode;
+import org.apache.activemq.jms.bridge.impl.JMSBridgeImpl;
+import org.apache.activemq.jms.client.ActiveMQXAConnectionFactory;
+import org.apache.activemq.tests.integration.IntegrationTestLogger;
+import org.apache.activemq.tests.integration.ra.DummyTransactionManager;
+import org.junit.Assert;
+import org.junit.Test;
+
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.RollbackException;
+import javax.transaction.Synchronization;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.xa.XAResource;
+
+/**
+ * @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
+ */
+public class JMSBridgeReconnectionTest extends BridgeTestBase
+{
+ /**
+ *
+ */
+ private static final int TIME_WAIT = 5000;
+
+ private static final IntegrationTestLogger log = IntegrationTestLogger.LOGGER;
+
+ // Crash and reconnect
+
+ // Once and only once
+
+ @Test
+ public void testCrashAndReconnectDestBasic_OnceAndOnlyOnce_P() throws Exception
+ {
+ performCrashAndReconnectDestBasic(QualityOfServiceMode.ONCE_AND_ONLY_ONCE, true, false);
+ }
+
+ @Test
+ public void testCrashAndReconnectDestBasic_OnceAndOnlyOnce_P_LargeMessage() throws Exception
+ {
+ performCrashAndReconnectDestBasic(QualityOfServiceMode.ONCE_AND_ONLY_ONCE, true, true);
+ }
+
+ @Test
+ public void testCrashAndReconnectDestBasic_OnceAndOnlyOnce_NP() throws Exception
+ {
+ performCrashAndReconnectDestBasic(QualityOfServiceMode.ONCE_AND_ONLY_ONCE, false, false);
+ }
+
+ // dups ok
+
+ @Test
+ public void testCrashAndReconnectDestBasic_DuplicatesOk_P() throws Exception
+ {
+ performCrashAndReconnectDestBasic(QualityOfServiceMode.DUPLICATES_OK, true, false);
+ }
+
+ @Test
+ public void testCrashAndReconnectDestBasic_DuplicatesOk_NP() throws Exception
+ {
+ performCrashAndReconnectDestBasic(QualityOfServiceMode.DUPLICATES_OK, false, false);
+ }
+
+ // At most once
+
+ @Test
+ public void testCrashAndReconnectDestBasic_AtMostOnce_P() throws Exception
+ {
+ performCrashAndReconnectDestBasic(QualityOfServiceMode.AT_MOST_ONCE, true, false);
+ }
+
+ @Test
+ public void testCrashAndReconnectDestBasic_AtMostOnce_NP() throws Exception
+ {
+ performCrashAndReconnectDestBasic(QualityOfServiceMode.AT_MOST_ONCE, false, false);
+ }
+
+ // Crash tests specific to XA transactions
+
+ @Test
+ public void testCrashAndReconnectDestCrashBeforePrepare_P() throws Exception
+ {
+ performCrashAndReconnectDestCrashBeforePrepare(true);
+ }
+
+ @Test
+ public void testCrashAndReconnectDestCrashBeforePrepare_NP() throws Exception
+ {
+ performCrashAndReconnectDestCrashBeforePrepare(false);
+ }
+
+ // Crash before bridge is started
+
+ @Test
+ public void testRetryConnectionOnStartup() throws Exception
+ {
+ jmsServer1.stop();
+
+ JMSBridgeImpl bridge = new JMSBridgeImpl(cff0,
+ cff1,
+ sourceQueueFactory,
+ targetQueueFactory,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 1000,
+ -1,
+ QualityOfServiceMode.DUPLICATES_OK,
+ 10,
+ -1,
+ null,
+ null,
+ false);
+ bridge.setTransactionManager(newTransactionManager());
+ addActiveMQComponent(bridge);
+ bridge.start();
+ Assert.assertFalse(bridge.isStarted());
+ Assert.assertTrue(bridge.isFailed());
+
+ // Restart the server
+ jmsServer1.start();
+
+ createQueue("targetQueue", 1);
+ setUpAdministeredObjects();
+
+ Thread.sleep(3000);
+
+ Assert.assertTrue(bridge.isStarted());
+ Assert.assertFalse(bridge.isFailed());
+ }
+
+ /**
+ * https://jira.jboss.org/jira/browse/HORNETQ-287
+ */
+ @Test
+ public void testStopBridgeWithFailureWhenStarted() throws Exception
+ {
+ jmsServer1.stop();
+
+ JMSBridgeImpl bridge = new JMSBridgeImpl(cff0,
+ cff1,
+ sourceQueueFactory,
+ targetQueueFactory,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 500,
+ -1,
+ QualityOfServiceMode.DUPLICATES_OK,
+ 10,
+ -1,
+ null,
+ null,
+ false);
+ bridge.setTransactionManager(newTransactionManager());
+
+ bridge.start();
+ Assert.assertFalse(bridge.isStarted());
+ Assert.assertTrue(bridge.isFailed());
+
+ bridge.stop();
+ Assert.assertFalse(bridge.isStarted());
+
+ // we restart and setup the server for the test's tearDown checks
+ jmsServer1.start();
+ createQueue("targetQueue", 1);
+ setUpAdministeredObjects();
+ }
+
+ /*
+ * Send some messages
+ * Crash the destination server
+ * Bring the destination server back up
+ * Send some more messages
+ * Verify all messages are received
+ */
+ private void performCrashAndReconnectDestBasic(final QualityOfServiceMode qosMode,
+ final boolean persistent,
+ final boolean largeMessage) throws Exception
+ {
+ JMSBridgeImpl bridge = null;
+
+ ConnectionFactoryFactory factInUse0 = cff0;
+ ConnectionFactoryFactory factInUse1 = cff1;
+ if (qosMode.equals(QualityOfServiceMode.ONCE_AND_ONLY_ONCE))
+ {
+ factInUse0 = cff0xa;
+ factInUse1 = cff1xa;
+ }
+
+ bridge =
+ new JMSBridgeImpl(factInUse0,
+ factInUse1,
+ sourceQueueFactory,
+ targetQueueFactory,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 1000,
+ -1,
+ qosMode,
+ 10,
+ -1,
+ null,
+ null,
+ false);
+ addActiveMQComponent(bridge);
+ bridge.setTransactionManager(newTransactionManager());
+ bridge.start();
+
+ final int NUM_MESSAGES = 10;
+
+ // Send some messages
+
+ sendMessages(cf0, sourceQueue, 0, NUM_MESSAGES / 2, persistent, largeMessage);
+
+ // Verify none are received
+
+ checkEmpty(targetQueue, 1);
+
+ // Now crash the dest server
+
+ JMSBridgeReconnectionTest.log.info("About to crash server");
+
+ jmsServer1.stop();
+
+ // Wait a while before starting up to simulate the dest being down for a while
+ JMSBridgeReconnectionTest.log.info("Waiting 5 secs before bringing server back up");
+ Thread.sleep(TIME_WAIT);
+ JMSBridgeReconnectionTest.log.info("Done wait");
+
+ // Restart the server
+ JMSBridgeReconnectionTest.log.info("Restarting server");
+ jmsServer1.start();
+
+ // jmsServer1.createQueue(false, "targetQueue", null, true, "queue/targetQueue");
+
+ createQueue("targetQueue", 1);
+
+ setUpAdministeredObjects();
+
+ // Send some more messages
+
+ JMSBridgeReconnectionTest.log.info("Sending more messages");
+
+ sendMessages(cf0, sourceQueue, NUM_MESSAGES / 2, NUM_MESSAGES / 2, persistent, largeMessage);
+
+ JMSBridgeReconnectionTest.log.info("Sent messages");
+
+ jmsServer1.stop();
+
+ bridge.stop();
+
+ System.out.println("JMSBridgeReconnectionTest.performCrashAndReconnectDestBasic");
+ }
+
+ @Test
+ public void performCrashDestinationStopBridge() throws Exception
+ {
+ ConnectionFactoryFactory factInUse0 = cff0;
+ ConnectionFactoryFactory factInUse1 = cff1;
+ final JMSBridgeImpl bridge =
+ new JMSBridgeImpl(factInUse0,
+ factInUse1,
+ sourceQueueFactory,
+ targetQueueFactory,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 1000,
+ -1,
+ QualityOfServiceMode.DUPLICATES_OK,
+ 10,
+ -1,
+ null,
+ null,
+ false);
+
+
+ addActiveMQComponent(bridge);
+ bridge.setTransactionManager(newTransactionManager());
+ bridge.start();
+
+ Thread clientThread = new Thread(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ while (bridge.isStarted())
+ {
+ try
+ {
+ sendMessages(cf0, sourceQueue, 0, 1, false, false);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+ });
+
+ clientThread.start();
+
+ checkAllMessageReceivedInOrder(cf1, targetQueue, 0, 1, false);
+
+ JMSBridgeReconnectionTest.log.info("About to crash server");
+
+ jmsServer1.stop();
+
+ // Wait a while before starting up to simulate the dest being down for a while
+ JMSBridgeReconnectionTest.log.info("Waiting 5 secs before bringing server back up");
+ Thread.sleep(TIME_WAIT);
+ JMSBridgeReconnectionTest.log.info("Done wait");
+
+ bridge.stop();
+
+ clientThread.join(5000);
+
+ assertTrue(!clientThread.isAlive());
+ }
+
+ @Test
+ public void performCrashAndReconnect() throws Exception
+ {
+ performCrashAndReconnect(true);
+ }
+
+ @Test
+ public void performCrashAndNoReconnect() throws Exception
+ {
+ performCrashAndReconnect(false);
+ }
+
+
+ private void performCrashAndReconnect(boolean restart) throws Exception
+ {
+ cff1xa = new ConnectionFactoryFactory()
+ {
+ public Object createConnectionFactory() throws Exception
+ {
+ ActiveMQXAConnectionFactory cf = (ActiveMQXAConnectionFactory) ActiveMQJMSClient.createConnectionFactoryWithHA(JMSFactoryType.XA_CF,
+ new TransportConfiguration(
+ INVM_CONNECTOR_FACTORY,
+ params1));
+
+ // Note! We disable automatic reconnection on the session factory. The bridge needs to do the reconnection
+ cf.setReconnectAttempts(-1);
+ cf.setBlockOnNonDurableSend(true);
+ cf.setBlockOnDurableSend(true);
+ cf.setCacheLargeMessagesClient(true);
+
+ return cf;
+ }
+
+ };
+
+ DummyTransactionManager tm = new DummyTransactionManager();
+ DummyTransaction tx = new DummyTransaction();
+ tm.tx = tx;
+
+ JMSBridgeImpl bridge =
+ new JMSBridgeImpl(cff0xa,
+ cff1xa,
+ sourceQueueFactory,
+ targetQueueFactory,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 1000,
+ -1,
+ QualityOfServiceMode.ONCE_AND_ONLY_ONCE,
+ 10,
+ 5000,
+ null,
+ null,
+ false);
+ addActiveMQComponent(bridge);
+ bridge.setTransactionManager(tm);
+
+ bridge.start();
+
+ // Now crash the dest server
+
+ JMSBridgeReconnectionTest.log.info("About to crash server");
+
+ jmsServer1.stop();
+
+ if (restart)
+ {
+ jmsServer1.start();
+ }
+ // Wait a while before starting up to simulate the dest being down for a while
+ JMSBridgeReconnectionTest.log.info("Waiting 5 secs before bringing server back up");
+ Thread.sleep(TIME_WAIT);
+ JMSBridgeReconnectionTest.log.info("Done wait");
+
+ bridge.stop();
+
+ if (restart)
+ {
+ assertTrue(tx.rolledback);
+ assertTrue(tx.targetConnected);
+ }
+ else
+ {
+ assertTrue(tx.rolledback);
+ assertFalse(tx.targetConnected);
+ }
+ }
+
+ private class DummyTransaction implements Transaction
+ {
+ boolean rolledback = false;
+ ClientSession targetSession;
+ boolean targetConnected = false;
+ @Override
+ public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, SystemException
+ {
+
+ }
+
+ @Override
+ public void rollback() throws IllegalStateException, SystemException
+ {
+ rolledback = true;
+ targetConnected = !targetSession.isClosed();
+ }
+
+ @Override
+ public void setRollbackOnly() throws IllegalStateException, SystemException
+ {
+
+ }
+
+ @Override
+ public int getStatus() throws SystemException
+ {
+ return 0;
+ }
+
+ @Override
+ public boolean enlistResource(XAResource xaResource) throws RollbackException, IllegalStateException, SystemException
+ {
+ targetSession = (ClientSession) xaResource;
+ return false;
+ }
+
+ @Override
+ public boolean delistResource(XAResource xaResource, int i) throws IllegalStateException, SystemException
+ {
+ return false;
+ }
+
+ @Override
+ public void registerSynchronization(Synchronization synchronization) throws RollbackException, IllegalStateException, SystemException
+ {
+
+ }
+ }
+ /*
+ * Send some messages
+ * Crash the destination server
+ * Set the max batch time such that it will attempt to send the batch while the dest server is down
+ * Bring up the destination server
+ * Send some more messages
+ * Verify all messages are received
+ */
+ private void performCrashAndReconnectDestCrashBeforePrepare(final boolean persistent) throws Exception
+ {
+ JMSBridgeImpl bridge =
+ new JMSBridgeImpl(cff0xa,
+ cff1xa,
+ sourceQueueFactory,
+ targetQueueFactory,
+ null,
+ null,
+ null,
+ null,
+ null,
+ 1000,
+ -1,
+ QualityOfServiceMode.ONCE_AND_ONLY_ONCE,
+ 10,
+ 5000,
+ null,
+ null,
+ false);
+ addActiveMQComponent(bridge);
+ bridge.setTransactionManager(newTransactionManager());
+
+ bridge.start();
+
+ final int NUM_MESSAGES = 10;
+ // Send some messages
+
+ sendMessages(cf0, sourceQueue, 0, NUM_MESSAGES / 2, persistent, false);
+
+ // verify none are received
+
+ checkEmpty(targetQueue, 1);
+
+ // Now crash the dest server
+
+ JMSBridgeReconnectionTest.log.info("About to crash server");
+
+ jmsServer1.stop();
+
+ // Wait a while before starting up to simulate the dest being down for a while
+ JMSBridgeReconnectionTest.log.info("Waiting 5 secs before bringing server back up");
+ Thread.sleep(TIME_WAIT);
+ JMSBridgeReconnectionTest.log.info("Done wait");
+
+ // Restart the server
+ jmsServer1.start();
+
+ createQueue("targetQueue", 1);
+
+ setUpAdministeredObjects();
+
+ sendMessages(cf0, sourceQueue, NUM_MESSAGES / 2, NUM_MESSAGES / 2, persistent, false);
+
+ checkMessagesReceived(cf1, targetQueue, QualityOfServiceMode.ONCE_AND_ONLY_ONCE, NUM_MESSAGES, false, false);
+ }
+}
[12/15] activemq-6 git commit: Refactored the testsuite a bit
Posted by jb...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/concurrent-tests/src/test/java/org/apache/activemq/tests/concurrent/stomp/ConcurrentStompTest.java
----------------------------------------------------------------------
diff --git a/tests/concurrent-tests/src/test/java/org/apache/activemq/tests/concurrent/stomp/ConcurrentStompTest.java b/tests/concurrent-tests/src/test/java/org/apache/activemq/tests/concurrent/stomp/ConcurrentStompTest.java
deleted file mode 100644
index c101c9c..0000000
--- a/tests/concurrent-tests/src/test/java/org/apache/activemq/tests/concurrent/stomp/ConcurrentStompTest.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.tests.concurrent.stomp;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.Socket;
-import java.nio.charset.StandardCharsets;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.activemq.core.protocol.stomp.Stomp;
-import org.apache.activemq.tests.integration.stomp.StompTestBase;
-import org.junit.Assert;
-import org.junit.Test;
-
-public class ConcurrentStompTest extends StompTestBase
-{
- private Socket stompSocket_2;
-
- private ByteArrayOutputStream inputBuffer_2;
-
- /**
- * Send messages on 1 socket and receives them concurrently on another socket.
- */
- @Test
- public void testSendManyMessages() throws Exception
- {
- try
- {
- String connect = "CONNECT\n" + "login: brianm\n" + "passcode: wombats\n\n" + Stomp.NULL;
-
- sendFrame(connect);
- String connected = receiveFrame(10000);
- Assert.assertTrue(connected.startsWith("CONNECTED"));
-
- stompSocket_2 = createSocket();
- inputBuffer_2 = new ByteArrayOutputStream();
-
- sendFrame(stompSocket_2, connect);
- connected = receiveFrame(stompSocket_2, inputBuffer_2, 10000);
- Assert.assertTrue(connected.startsWith("CONNECTED"));
-
- final int count = 1000;
- final CountDownLatch latch = new CountDownLatch(count);
-
- String subscribe =
- "SUBSCRIBE\n" +
- "destination:" + getQueuePrefix() + getQueueName() + "\n" +
- "ack:auto\n\n" +
- Stomp.NULL;
- sendFrame(stompSocket_2, subscribe);
- Thread.sleep(2000);
-
- new Thread()
- {
- @Override
- public void run()
- {
- int i = 0;
- while (true)
- {
- try
- {
- String frame = receiveFrame(stompSocket_2, inputBuffer_2, 10000);
- Assert.assertTrue(frame.startsWith("MESSAGE"));
- Assert.assertTrue(frame.indexOf("destination:") > 0);
- System.out.println("<<< " + i++);
- latch.countDown();
- }
- catch (Exception e)
- {
- break;
- }
- }
- }
- }.start();
-
- String send = "SEND\n" + "destination:" + getQueuePrefix() + getQueueName() + "\n";
- for (int i = 1; i <= count; i++)
- {
- // Thread.sleep(1);
- System.out.println(">>> " + i);
- sendFrame(send + "count:" + i + "\n\n" + Stomp.NULL);
- }
-
- assertTrue(latch.await(60, TimeUnit.SECONDS));
-
- }
- finally
- {
- stompSocket_2.close();
- inputBuffer_2.close();
- }
-
-
- }
-
- // Implementation methods
- // -------------------------------------------------------------------------
- public void sendFrame(Socket socket, String data) throws Exception
- {
- byte[] bytes = data.getBytes(StandardCharsets.UTF_8);
- OutputStream outputStream = socket.getOutputStream();
- for (byte b : bytes)
- {
- outputStream.write(b);
- }
- outputStream.flush();
- }
-
- public String receiveFrame(Socket socket, ByteArrayOutputStream input, long timeOut) throws Exception
- {
- socket.setSoTimeout((int) timeOut);
- InputStream is = socket.getInputStream();
- int c = 0;
- for (;;)
- {
- c = is.read();
- if (c < 0)
- {
- throw new IOException("socket closed.");
- }
- else if (c == 0)
- {
- c = is.read();
- if (c != '\n')
- {
- byte[] ba = input.toByteArray();
- System.out.println(new String(ba, StandardCharsets.UTF_8));
- }
- Assert.assertEquals("Expecting stomp frame to terminate with \0\n", c, '\n');
- byte[] ba = input.toByteArray();
- input.reset();
- return new String(ba, StandardCharsets.UTF_8);
- }
- else
- {
- input.write(c);
- }
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/extra-tests/pom.xml
----------------------------------------------------------------------
diff --git a/tests/extra-tests/pom.xml b/tests/extra-tests/pom.xml
new file mode 100644
index 0000000..3329bf3
--- /dev/null
+++ b/tests/extra-tests/pom.xml
@@ -0,0 +1,246 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- This test folder contains tests that are not part of the regular testsuite
+ because they use optional libraries such as LGPL or private ones.
+ They are optional and will validate extra functionality available through Service Integration
+ Example: Transaction Manager -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.activemq.tests</groupId>
+ <artifactId>activemq-tests-pom</artifactId>
+ <version>6.0.1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>extra-tests</artifactId>
+ <packaging>jar</packaging>
+ <name>ActiveMQ6 Extra Tests</name>
+
+ <properties>
+ <tools.jar>${java.home}/../lib/tools.jar</tools.jar>
+ <byteman.version>2.2.0</byteman.version>
+ <activemq.basedir>${project.basedir}/../..</activemq.basedir>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-all</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.byteman</groupId>
+ <artifactId>byteman</artifactId>
+ <version>${byteman.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.byteman</groupId>
+ <artifactId>byteman-submit</artifactId>
+ <scope>test</scope>
+ <version>${byteman.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.byteman</groupId>
+ <artifactId>byteman-install</artifactId>
+ <scope>test</scope>
+ <version>${byteman.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.byteman</groupId>
+ <artifactId>byteman-bmunit</artifactId>
+ <scope>test</scope>
+ <version>${byteman.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>com.sun</groupId>
+ <artifactId>tools</artifactId>
+ <version>1.7</version>
+ <scope>system</scope>
+ <systemPath>${tools.jar}</systemPath>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-core-client</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ <type>test-jar</type>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-server</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ <type>test-jar</type>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.activemq.tests</groupId>
+ <artifactId>integration-tests</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ <type>test-jar</type>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.activemq.tests</groupId>
+ <artifactId>unit-tests</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ <type>test-jar</type>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-jms-client</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-jms-server</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-ra</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-bootstrap</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-j2ee-connector_1.5_spec</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-ejb_3.0_spec</artifactId>
+ </dependency>
+ <!--this specifically for the JMS Bridge -->
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jta_1.1_spec</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.components</groupId>
+ <artifactId>geronimo-jaspi</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_2.0_spec</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-processor</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.logmanager</groupId>
+ <artifactId>jboss-logmanager</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+
+
+
+ <!-- Needed for JMS Bridge Tests -->
+ <dependency>
+ <groupId>org.jboss.jbossts.jts</groupId>
+ <artifactId>jbossjts-jacorb</artifactId>
+ <version>4.17.13.Final</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-transaction-spi</artifactId>
+ <version>7.1.0.Final</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>test</phase>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skipTests>${skipExtraTests}</skipTests>
+ <!-- ensure we don't inherit a byteman jar form any env settings -->
+ <environmentVariables>
+ <BYTEMAN_HOME></BYTEMAN_HOME>
+ </environmentVariables>
+ <systemProperties>
+ <!--
+ <property>
+ <name>org.jboss.byteman.home</name>
+ <value></value>
+ </property>
+ <property>
+ <name>org.jboss.byteman.verbose</name>
+ <value>true</value>
+ </property>
+ <property>
+ <name>org.jboss.byteman.contrib.bmunit.verbose</name>
+ <value>true</value>
+ </property>
+ <property>
+ <name>org.jboss.byteman.dump.generated.classes</name>
+ <value></value>
+ </property>
+ -->
+ </systemProperties>
+ <!-- make sure maven puts the byteman jar in the classpath rather than in a manifest jar -->
+ <useManifestOnlyJar>false</useManifestOnlyJar>
+ <forkMode>once</forkMode>
+ <!--
+ <debugForkedProcess>true</debugForkedProcess>
+ -->
+ <parallel>false</parallel>
+ <!--<argLine>${activemq-surefire-argline} -Dorg.jboss.byteman.verbose -Dorg.jboss.byteman.contrib.bmunit.verbose</argLine>-->
+ <!-- '-noverify' is needed here to fix VerifyErrors on ScaleDownFailoverTest and ScaleDownFailureTest (and their subclasses). I got the tip from https://issues.jboss.org/browse/BYTEMAN-248. -->
+ <argLine>${activemq-surefire-argline} -noverify</argLine>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/ExtrasTestLogger.java
----------------------------------------------------------------------
diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/ExtrasTestLogger.java b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/ExtrasTestLogger.java
new file mode 100644
index 0000000..c97d01a
--- /dev/null
+++ b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/ExtrasTestLogger.java
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.tests.extras;
+
+import org.jboss.logging.BasicLogger;
+import org.jboss.logging.Logger;
+import org.jboss.logging.annotations.MessageLogger;
+
+/**
+ * @author <a href="mailto:andy.taylor@jboss.org">Andy Taylor</a>
+ * 4/18/12
+ */
+@MessageLogger(projectCode = "HQTEST")
+public interface ExtrasTestLogger extends BasicLogger
+{
+ /**
+ * The integration test logger.
+ */
+ ExtrasTestLogger LOGGER = Logger.getMessageLogger(ExtrasTestLogger.class, ExtrasTestLogger.class.getPackage().getName());
+}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/ActiveMQMessageHandlerTest.java
----------------------------------------------------------------------
diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/ActiveMQMessageHandlerTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/ActiveMQMessageHandlerTest.java
new file mode 100644
index 0000000..0914295
--- /dev/null
+++ b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/ActiveMQMessageHandlerTest.java
@@ -0,0 +1,428 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.tests.extras.byteman;
+
+import com.arjuna.ats.arjuna.coordinator.TransactionReaper;
+import com.arjuna.ats.arjuna.coordinator.TxControl;
+import com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionManagerImple;
+import org.apache.activemq.api.core.SimpleString;
+import org.apache.activemq.api.core.client.ClientConsumer;
+import org.apache.activemq.api.core.client.ClientMessage;
+import org.apache.activemq.api.core.client.ClientProducer;
+import org.apache.activemq.api.core.client.ClientSession;
+import org.apache.activemq.api.core.client.ClientSessionFactory;
+import org.apache.activemq.core.postoffice.Binding;
+import org.apache.activemq.core.server.Queue;
+import org.apache.activemq.ra.ActiveMQResourceAdapter;
+import org.apache.activemq.ra.inflow.ActiveMQActivationSpec;
+import org.apache.activemq.tests.integration.ra.ActiveMQRATestBase;
+import org.jboss.byteman.contrib.bmunit.BMRule;
+import org.jboss.byteman.contrib.bmunit.BMRules;
+import org.jboss.byteman.contrib.bmunit.BMUnitRunner;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.jms.Message;
+import javax.resource.ResourceException;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+import java.lang.reflect.Method;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @author <a href="mailto:andy.taylor@jboss.org">Andy Taylor</a>
+ * Created May 20, 2010
+ */
+@RunWith(BMUnitRunner.class)
+public class ActiveMQMessageHandlerTest extends ActiveMQRATestBase
+{
+
+ protected boolean usePersistence()
+ {
+ return true;
+ }
+
+
+ @Override
+ public boolean useSecurity()
+ {
+ return false;
+ }
+
+ @Test
+ @BMRules
+ (
+ rules =
+ {
+ @BMRule
+ (
+ name = "interrupt",
+ targetClass = "org.apache.activemq.core.protocol.core.impl.ActiveMQSessionContext",
+ targetMethod = "xaEnd",
+ targetLocation = "ENTRY",
+ action = "org.apache.activemq.tests.extras.byteman.ActiveMQMessageHandlerTest.interrupt();"
+ )
+ }
+ )
+ public void testSimpleMessageReceivedOnQueue() throws Exception
+ {
+ ActiveMQResourceAdapter qResourceAdapter = newResourceAdapter();
+ resourceAdapter = qResourceAdapter;
+
+ MyBootstrapContext ctx = new MyBootstrapContext();
+
+ qResourceAdapter.setConnectorClassName(NETTY_CONNECTOR_FACTORY);
+ qResourceAdapter.start(ctx);
+
+ ActiveMQActivationSpec spec = new ActiveMQActivationSpec();
+ spec.setMaxSession(1);
+ spec.setCallTimeout(1000L);
+ spec.setResourceAdapter(qResourceAdapter);
+ spec.setUseJNDI(false);
+ spec.setDestinationType("javax.jms.Queue");
+ spec.setDestination(MDBQUEUE);
+
+ CountDownLatch latch = new CountDownLatch(1);
+
+ XADummyEndpoint endpoint = new XADummyEndpoint(latch, false);
+
+ DummyMessageEndpointFactory endpointFactory = new DummyMessageEndpointFactory(endpoint, true);
+
+ qResourceAdapter.endpointActivation(endpointFactory, spec);
+
+ ClientSession session = locator.createSessionFactory().createSession();
+
+ ClientProducer clientProducer = session.createProducer(MDBQUEUEPREFIXED);
+
+ ClientMessage message = session.createMessage(true);
+
+ message.getBodyBuffer().writeString("teststring");
+
+ clientProducer.send(message);
+
+ session.close();
+
+ latch.await(5, TimeUnit.SECONDS);
+
+ assertNotNull(endpoint.lastMessage);
+ assertEquals(endpoint.lastMessage.getCoreMessage().getBodyBuffer().readString(), "teststring");
+
+ qResourceAdapter.endpointDeactivation(endpointFactory, spec);
+
+ qResourceAdapter.stop();
+
+ Binding binding = server.getPostOffice().getBinding(SimpleString.toSimpleString(MDBQUEUEPREFIXED));
+ assertEquals(1, getMessageCount(((Queue) binding.getBindable())));
+
+ server.stop();
+ server.start();
+
+ ClientSessionFactory factory = locator.createSessionFactory();
+ session = factory.createSession(true, true);
+
+ session.start();
+ ClientConsumer consumer = session.createConsumer(MDBQUEUEPREFIXED);
+ assertNotNull(consumer.receive(5000));
+ session.close();
+ }
+
+ @Test
+ @BMRules
+ (
+ rules =
+ {
+ @BMRule
+ (
+ name = "interrupt",
+ targetClass = "org.apache.activemq.core.protocol.core.impl.ActiveMQSessionContext",
+ targetMethod = "xaEnd",
+ targetLocation = "ENTRY",
+ action = "org.apache.activemq.tests.extras.byteman.ActiveMQMessageHandlerTest.interrupt();"
+ )
+ }
+ )
+ public void testSimpleMessageReceivedOnQueueTwoPhase() throws Exception
+ {
+ ActiveMQResourceAdapter qResourceAdapter = newResourceAdapter();
+ resourceAdapter = qResourceAdapter;
+
+ MyBootstrapContext ctx = new MyBootstrapContext();
+
+ qResourceAdapter.setConnectorClassName(NETTY_CONNECTOR_FACTORY);
+ qResourceAdapter.start(ctx);
+
+ ActiveMQActivationSpec spec = new ActiveMQActivationSpec();
+ spec.setMaxSession(1);
+ spec.setCallTimeout(1000L);
+ spec.setResourceAdapter(qResourceAdapter);
+ spec.setUseJNDI(false);
+ spec.setDestinationType("javax.jms.Queue");
+ spec.setDestination(MDBQUEUE);
+
+ CountDownLatch latch = new CountDownLatch(1);
+
+ XADummyEndpoint endpoint = new XADummyEndpoint(latch, true);
+
+ DummyMessageEndpointFactory endpointFactory = new DummyMessageEndpointFactory(endpoint, true);
+
+ qResourceAdapter.endpointActivation(endpointFactory, spec);
+
+ ClientSession session = locator.createSessionFactory().createSession();
+
+ ClientProducer clientProducer = session.createProducer(MDBQUEUEPREFIXED);
+
+ ClientMessage message = session.createMessage(true);
+
+ message.getBodyBuffer().writeString("teststring");
+
+ clientProducer.send(message);
+
+ session.close();
+
+ latch.await(5, TimeUnit.SECONDS);
+
+ assertNotNull(endpoint.lastMessage);
+ assertEquals(endpoint.lastMessage.getCoreMessage().getBodyBuffer().readString(), "teststring");
+
+ qResourceAdapter.endpointDeactivation(endpointFactory, spec);
+
+ qResourceAdapter.stop();
+
+ Binding binding = server.getPostOffice().getBinding(SimpleString.toSimpleString(MDBQUEUEPREFIXED));
+ assertEquals(1, getMessageCount(((Queue) binding.getBindable())));
+
+
+ server.stop();
+ server.start();
+
+ ClientSessionFactory factory = locator.createSessionFactory();
+ session = factory.createSession(true, true);
+
+ session.start();
+ ClientConsumer consumer = session.createConsumer(MDBQUEUEPREFIXED);
+ assertNotNull(consumer.receive(5000));
+ session.close();
+ }
+
+ static volatile ActiveMQResourceAdapter resourceAdapter;
+ static boolean resourceAdapterStopped = false;
+ public static void interrupt() throws InterruptedException
+ {
+ //Thread.currentThread().interrupt();
+ if (!resourceAdapterStopped)
+ {
+ resourceAdapter.stop();
+ resourceAdapterStopped = true;
+ throw new InterruptedException("foo");
+ }
+ //Thread.currentThread().interrupt();
+ }
+
+ Transaction currentTX;
+
+ public class XADummyEndpoint extends DummyMessageEndpoint
+ {
+ final boolean twoPhase;
+ ClientSession session;
+ int afterDeliveryCounts = 0;
+
+ public XADummyEndpoint(CountDownLatch latch, boolean twoPhase) throws SystemException
+ {
+ super(latch);
+ this.twoPhase = twoPhase;
+ try
+ {
+ session = locator.createSessionFactory().createSession(true, false, false);
+ }
+ catch (Throwable e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ public void beforeDelivery(Method method) throws NoSuchMethodException, ResourceException
+ {
+ super.beforeDelivery(method);
+ try
+ {
+ DummyTMLocator.tm.begin();
+ currentTX = DummyTMLocator.tm.getTransaction();
+ currentTX.enlistResource(xaResource);
+ if (twoPhase)
+ {
+ currentTX.enlistResource(new DummyXAResource());
+ }
+ }
+ catch (Throwable e)
+ {
+ throw new RuntimeException(e.getMessage(), e);
+ }
+ }
+
+ public void onMessage(Message message)
+ {
+ super.onMessage(message);
+// try
+// {
+// lastMessage = (ActiveMQMessage) message;
+// currentTX.enlistResource(session);
+// ClientProducer prod = session.createProducer()
+// }
+// catch (Exception e)
+// {
+// e.printStackTrace();
+// }
+
+
+ }
+
+
+
+ @Override
+ public void afterDelivery() throws ResourceException
+ {
+ afterDeliveryCounts++;
+ try
+ {
+ currentTX.commit();
+ }
+ catch (Throwable e)
+ {
+ //its unsure as to whether the EJB/JCA layer will handle this or throw it to us,
+ // either way we don't do anything else so its fine just to throw.
+ // NB this will only happen with 2 phase commit
+ throw new RuntimeException(e);
+ }
+ super.afterDelivery();
+ }
+ }
+
+ @Before
+ public void setUp() throws Exception
+ {
+ resourceAdapter = null;
+ resourceAdapterStopped = false;
+ super.setUp();
+ DummyTMLocator.startTM();
+ }
+
+
+ @After
+ public void tearDown() throws Exception
+ {
+ DummyTMLocator.stopTM();
+ super.tearDown();
+ }
+
+ public static class DummyTMLocator
+ {
+ public static TransactionManagerImple tm;
+ public static void stopTM()
+ {
+ try
+ {
+ TransactionReaper.terminate(true);
+ TxControl.disable(true);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ tm = null;
+ }
+ public static void startTM()
+ {
+ tm = new TransactionManagerImple();
+ TxControl.enable();
+ }
+ public TransactionManager getTM()
+ {
+ return tm;
+ }
+ }
+
+ static class DummyXAResource implements XAResource
+ {
+ @Override
+ public void commit(Xid xid, boolean b) throws XAException
+ {
+
+ }
+
+ @Override
+ public void end(Xid xid, int i) throws XAException
+ {
+
+ }
+
+ @Override
+ public void forget(Xid xid) throws XAException
+ {
+
+ }
+
+ @Override
+ public int getTransactionTimeout() throws XAException
+ {
+ return 0;
+ }
+
+ @Override
+ public boolean isSameRM(XAResource xaResource) throws XAException
+ {
+ return false;
+ }
+
+ @Override
+ public int prepare(Xid xid) throws XAException
+ {
+ return 0;
+ }
+
+ @Override
+ public Xid[] recover(int i) throws XAException
+ {
+ return new Xid[0];
+ }
+
+ @Override
+ public void rollback(Xid xid) throws XAException
+ {
+
+ }
+
+ @Override
+ public boolean setTransactionTimeout(int i) throws XAException
+ {
+ return false;
+ }
+
+ @Override
+ public void start(Xid xid, int i) throws XAException
+ {
+
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/BMFailoverTest.java
----------------------------------------------------------------------
diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/BMFailoverTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/BMFailoverTest.java
new file mode 100644
index 0000000..fb91994
--- /dev/null
+++ b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/BMFailoverTest.java
@@ -0,0 +1,451 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.tests.extras.byteman;
+
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+
+import org.apache.activemq.api.core.ActiveMQTransactionOutcomeUnknownException;
+import org.apache.activemq.api.core.ActiveMQTransactionRolledBackException;
+import org.apache.activemq.api.core.ActiveMQUnBlockedException;
+import org.apache.activemq.api.core.SimpleString;
+import org.apache.activemq.api.core.TransportConfiguration;
+import org.apache.activemq.api.core.client.ClientConsumer;
+import org.apache.activemq.api.core.client.ClientMessage;
+import org.apache.activemq.api.core.client.ClientProducer;
+import org.apache.activemq.api.core.client.ClientSession;
+import org.apache.activemq.api.core.client.ClientSessionFactory;
+import org.apache.activemq.api.core.client.ServerLocator;
+import org.apache.activemq.core.client.ActiveMQClientMessageBundle;
+import org.apache.activemq.core.client.impl.ClientMessageImpl;
+import org.apache.activemq.core.client.impl.ClientSessionFactoryInternal;
+import org.apache.activemq.core.client.impl.ClientSessionInternal;
+import org.apache.activemq.core.postoffice.Binding;
+import org.apache.activemq.core.server.Queue;
+import org.apache.activemq.core.transaction.impl.XidImpl;
+import org.apache.activemq.tests.integration.cluster.failover.FailoverTestBase;
+import org.apache.activemq.tests.integration.cluster.util.TestableServer;
+import org.apache.activemq.tests.util.RandomUtil;
+import org.apache.activemq.utils.UUIDGenerator;
+import org.jboss.byteman.contrib.bmunit.BMRule;
+import org.jboss.byteman.contrib.bmunit.BMRules;
+import org.jboss.byteman.contrib.bmunit.BMUnitRunner;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * @author <a href="mailto:andy.taylor@jboss.org">Andy Taylor</a>
+ * 4/18/13
+ */
+@RunWith(BMUnitRunner.class)
+public class BMFailoverTest extends FailoverTestBase
+{
+ private ServerLocator locator;
+ private ClientSessionFactoryInternal sf;
+ private ClientSessionFactoryInternal sf2;
+ public static TestableServer serverToStop;
+
+ @Before
+ @Override
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ stopped = false;
+ locator = getServerLocator();
+ }
+
+ @After
+ @Override
+ public void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
+ private static boolean stopped = false;
+ public static void stopAndThrow() throws ActiveMQUnBlockedException
+ {
+ if (!stopped)
+ {
+ try
+ {
+ serverToStop.getServer().stop(true);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ try
+ {
+ Thread.sleep(2000);
+ }
+ catch (InterruptedException e)
+ {
+ e.printStackTrace();
+ }
+ stopped = true;
+ throw ActiveMQClientMessageBundle.BUNDLE.unblockingACall(null);
+ }
+ }
+ @Test
+ @BMRules
+ (
+ rules =
+ {
+ @BMRule
+ (
+ name = "trace ActiveMQSessionContext xaEnd",
+ targetClass = "org.apache.activemq.core.protocol.core.impl.ActiveMQSessionContext",
+ targetMethod = "xaEnd",
+ targetLocation = "AT EXIT",
+ action = "org.apache.activemq.tests.extras.byteman.BMFailoverTest.stopAndThrow()"
+ )
+ }
+ )
+ //https://bugzilla.redhat.com/show_bug.cgi?id=1152410
+ public void testFailOnEndAndRetry() throws Exception
+ {
+ serverToStop = liveServer;
+
+ createSessionFactory();
+
+ ClientSession session = createSession(sf, true, false, false);
+
+ session.createQueue(FailoverTestBase.ADDRESS, FailoverTestBase.ADDRESS, null, true);
+
+ ClientProducer producer = session.createProducer(FailoverTestBase.ADDRESS);
+
+ for (int i = 0; i < 100; i++)
+ {
+ producer.send(createMessage(session, i, true));
+ }
+
+ ClientConsumer consumer = session.createConsumer(FailoverTestBase.ADDRESS);
+
+ Xid xid = RandomUtil.randomXid();
+
+ session.start(xid, XAResource.TMNOFLAGS);
+ session.start();
+ // Receive MSGs but don't ack!
+ for (int i = 0; i < 100; i++)
+ {
+ ClientMessage message = consumer.receive(1000);
+
+ Assert.assertNotNull(message);
+
+ assertMessageBody(i, message);
+
+ Assert.assertEquals(i, message.getIntProperty("counter").intValue());
+ }
+ try
+ {
+ //top level prepare
+ session.end(xid, XAResource.TMSUCCESS);
+ }
+ catch (XAException e)
+ {
+ try
+ {
+ //top level abort
+ session.end(xid, XAResource.TMFAIL);
+ }
+ catch (XAException e1)
+ {
+ try
+ {
+ //rollback
+ session.rollback(xid);
+ }
+ catch (XAException e2)
+ {
+ }
+ }
+ }
+ xid = RandomUtil.randomXid();
+ session.start(xid, XAResource.TMNOFLAGS);
+
+ for (int i = 0; i < 50; i++)
+ {
+ ClientMessage message = consumer.receive(1000);
+
+ Assert.assertNotNull(message);
+
+ assertMessageBody(i, message);
+
+ Assert.assertEquals(i, message.getIntProperty("counter").intValue());
+ }
+ session.end(xid, XAResource.TMSUCCESS);
+ session.commit(xid, true);
+ }
+
+ @Test
+ @BMRules
+ (
+ rules =
+ {
+ @BMRule
+ (
+ name = "trace clientsessionimpl commit",
+ targetClass = "org.apache.activemq.core.client.impl.ClientSessionImpl",
+ targetMethod = "start(javax.transaction.xa.Xid, int)",
+ targetLocation = "AT EXIT",
+ action = "org.apache.activemq.tests.extras.byteman.BMFailoverTest.serverToStop.getServer().stop(true)"
+ )
+ }
+ )
+ public void testFailoverOnCommit2() throws Exception
+ {
+ serverToStop = liveServer;
+ locator = getServerLocator();
+ locator.setFailoverOnInitialConnection(true);
+ SimpleString inQueue = new SimpleString("inQueue");
+ SimpleString outQueue = new SimpleString("outQueue");
+ createSessionFactory();
+ createSessionFactory2();
+
+ // closeable will take care of closing it
+ try (ClientSession session = sf.createSession(false, true, true);
+ ClientProducer sendInitialProducer = session.createProducer();)
+ {
+ session.createQueue(inQueue, inQueue, null, true);
+ session.createQueue(outQueue, outQueue, null, true);
+ sendInitialProducer.send(inQueue, createMessage(session, 0, true));
+ }
+
+ ClientSession xaSessionRec = addClientSession(sf.createSession(true, false, false));
+
+ ClientConsumer consumer = addClientConsumer(xaSessionRec.createConsumer(inQueue));
+
+ byte[] globalTransactionId = UUIDGenerator.getInstance().generateStringUUID().getBytes();
+ Xid xidRec = new XidImpl("xa2".getBytes(), 1, globalTransactionId);
+
+ xaSessionRec.start();
+
+ xaSessionRec.getXAResource().start(xidRec, XAResource.TMNOFLAGS);
+
+ //failover is now occurring, receive, ack and end will be called whilst this is happening.
+
+ ClientMessageImpl m = (ClientMessageImpl) consumer.receive(5000);
+
+ assertNotNull(m);
+
+ System.out.println("********************" + m.getIntProperty("counter"));
+ //the mdb would ack the message before calling onMessage()
+ m.acknowledge();
+
+ try
+ {
+ //this may fail but thats ok, it depends on the race and when failover actually happens
+ xaSessionRec.end(xidRec, XAResource.TMSUCCESS);
+ }
+ catch (XAException ignore)
+ {
+ }
+
+ //we always reset the client on the RA
+ ((ClientSessionInternal) xaSessionRec).resetIfNeeded();
+
+ // closeable will take care of closing it
+ try (ClientSession session = sf.createSession(false, true, true);
+ ClientProducer sendInitialProducer = session.createProducer();)
+ {
+ sendInitialProducer.send(inQueue, createMessage(session, 0, true));
+ }
+
+ //now receive and send a message successfully
+
+ globalTransactionId = UUIDGenerator.getInstance().generateStringUUID().getBytes();
+ xidRec = new XidImpl("xa4".getBytes(), 1, globalTransactionId);
+ xaSessionRec.getXAResource().start(xidRec, XAResource.TMNOFLAGS);
+
+ Binding binding = backupServer.getServer().getPostOffice().getBinding(inQueue);
+ Queue inQ = (Queue) binding.getBindable();
+
+ m = (ClientMessageImpl) consumer.receive(5000);
+
+ assertNotNull(m);
+ //the mdb would ack the message before calling onMessage()
+ m.acknowledge();
+
+ System.out.println("********************" + m.getIntProperty("counter"));
+
+ xaSessionRec.getXAResource().end(xidRec, XAResource.TMSUCCESS);
+ xaSessionRec.getXAResource().prepare(xidRec);
+ xaSessionRec.getXAResource().commit(xidRec, false);
+
+
+ //let's close the consumer so anything pending is handled
+ consumer.close();
+
+ assertEquals(1, getMessageCount(inQ));
+ }
+
+
+ @Test
+ @BMRules
+ (
+ rules =
+ {
+ @BMRule
+ (
+ name = "trace clientsessionimpl commit",
+ targetClass = "org.apache.activemq.core.client.impl.ClientSessionImpl",
+ targetMethod = "commit",
+ targetLocation = "ENTRY",
+ action = "org.apache.activemq.tests.extras.byteman.BMFailoverTest.serverToStop.getServer().stop(true)"
+ )
+ }
+ )
+ public void testFailoverOnCommit() throws Exception
+ {
+ serverToStop = liveServer;
+ locator = getServerLocator();
+ locator.setFailoverOnInitialConnection(true);
+ createSessionFactory();
+ ClientSession session = createSessionAndQueue();
+
+ ClientProducer producer = addClientProducer(session.createProducer(FailoverTestBase.ADDRESS));
+
+ sendMessages(session, producer, 10);
+ try
+ {
+ session.commit();
+ fail("should have thrown an exception");
+ }
+ catch (ActiveMQTransactionOutcomeUnknownException e)
+ {
+ //pass
+ }
+ sendMessages(session, producer, 10);
+ session.commit();
+ Queue bindable = (Queue) backupServer.getServer().getPostOffice().getBinding(FailoverTestBase.ADDRESS).getBindable();
+ assertEquals(10, getMessageCount(bindable));
+ }
+
+ @Test
+ @BMRules
+ (
+ rules =
+ {
+ @BMRule
+ (
+ name = "trace clientsessionimpl commit",
+ targetClass = "org.apache.activemq.core.client.impl.ClientSessionImpl",
+ targetMethod = "commit",
+ targetLocation = "ENTRY",
+ action = "org.apache.activemq.tests.extras.byteman.BMFailoverTest.serverToStop.getServer().stop(true)"
+ )
+ }
+ )
+ public void testFailoverOnReceiveCommit() throws Exception
+ {
+ serverToStop = liveServer;
+ locator = getServerLocator();
+ locator.setFailoverOnInitialConnection(true);
+ createSessionFactory();
+ ClientSession session = createSessionAndQueue();
+
+ ClientSession sendSession = createSession(sf, true, true);
+
+ ClientProducer producer = addClientProducer(sendSession.createProducer(FailoverTestBase.ADDRESS));
+
+ sendMessages(sendSession, producer, 10);
+
+ ClientConsumer consumer = session.createConsumer(FailoverTestBase.ADDRESS);
+ session.start();
+ for (int i = 0; i < 10; i++)
+ {
+ ClientMessage m = consumer.receive(500);
+ assertNotNull(m);
+ m.acknowledge();
+ }
+ try
+ {
+ session.commit();
+ fail("should have thrown an exception");
+ }
+ catch (ActiveMQTransactionOutcomeUnknownException e)
+ {
+ //pass
+ }
+ catch (ActiveMQTransactionRolledBackException e1)
+ {
+ //pass
+ }
+ Queue bindable = (Queue) backupServer.getServer().getPostOffice().getBinding(FailoverTestBase.ADDRESS).getBindable();
+ assertEquals(10, getMessageCount(bindable));
+
+ }
+
+ @Override
+ protected TransportConfiguration getAcceptorTransportConfiguration(final boolean live)
+ {
+ return getNettyAcceptorTransportConfiguration(live);
+ }
+
+ @Override
+ protected TransportConfiguration getConnectorTransportConfiguration(final boolean live)
+ {
+ return getNettyConnectorTransportConfiguration(live);
+ }
+
+ private ClientSession createSessionAndQueue() throws Exception
+ {
+ ClientSession session = createSession(sf, false, false);
+
+ session.createQueue(FailoverTestBase.ADDRESS, FailoverTestBase.ADDRESS, null, true);
+ return session;
+ }
+
+ private ClientSession createXASessionAndQueue() throws Exception
+ {
+ ClientSession session = addClientSession(sf.createSession(true, true, true));
+
+ session.createQueue(FailoverTestBase.ADDRESS, FailoverTestBase.ADDRESS, null, true);
+ return session;
+ }
+
+ protected ClientSession
+ createSession(ClientSessionFactory sf1, boolean autoCommitSends, boolean autoCommitAcks) throws Exception
+ {
+ return addClientSession(sf1.createSession(autoCommitSends, autoCommitAcks));
+ }
+
+ protected ClientSession
+ createSession(ClientSessionFactory sf1, boolean xa, boolean autoCommitSends, boolean autoCommitAcks) throws Exception
+ {
+ return addClientSession(sf1.createSession(xa, autoCommitSends, autoCommitAcks));
+ }
+
+
+ private void createSessionFactory() throws Exception
+ {
+ locator.setBlockOnNonDurableSend(true);
+ locator.setBlockOnDurableSend(true);
+ locator.setReconnectAttempts(-1);
+
+ sf = createSessionFactoryAndWaitForTopology(locator, 2);
+ }
+
+ private void createSessionFactory2() throws Exception
+ {
+ sf2 = createSessionFactoryAndWaitForTopology(locator, 2);
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/BridgeServerLocatorConfigurationTest.java
----------------------------------------------------------------------
diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/BridgeServerLocatorConfigurationTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/BridgeServerLocatorConfigurationTest.java
new file mode 100644
index 0000000..bf97f5a
--- /dev/null
+++ b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/BridgeServerLocatorConfigurationTest.java
@@ -0,0 +1,181 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.tests.extras.byteman;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.activemq.api.core.TransportConfiguration;
+import org.apache.activemq.api.core.client.ServerLocator;
+import org.apache.activemq.core.config.BridgeConfiguration;
+import org.apache.activemq.core.config.CoreQueueConfiguration;
+import org.apache.activemq.core.remoting.impl.invm.TransportConstants;
+import org.apache.activemq.core.server.ActiveMQServer;
+import org.apache.activemq.core.server.cluster.impl.BridgeImpl;
+import org.apache.activemq.tests.util.ServiceTestBase;
+import org.jboss.byteman.contrib.bmunit.BMRule;
+import org.jboss.byteman.contrib.bmunit.BMUnitRunner;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(BMUnitRunner.class)
+public class BridgeServerLocatorConfigurationTest extends ServiceTestBase
+{
+
+ private static final long BRIDGE_TTL = 1234L;
+ private static final String BRIDGE_NAME = "bridge1";
+
+ protected boolean isNetty()
+ {
+ return false;
+ }
+
+ private String getConnector()
+ {
+ if (isNetty())
+ {
+ return NETTY_CONNECTOR_FACTORY;
+ }
+ return INVM_CONNECTOR_FACTORY;
+ }
+
+ @Test
+ @BMRule(name = "check connection ttl",
+ targetClass = "org.apache.activemq.tests.extras.byteman.BridgeServerLocatorConfigurationTest",
+ targetMethod = "getBridgeTTL(ActiveMQServer, String)", targetLocation = "EXIT",
+ action = "$! = $0.getConfiguredBridge($1).serverLocator.getConnectionTTL();")
+ /**
+ * Checks the connection ttl by using byteman to override the methods on this class to return the value of private variables in the Bridge.
+ * @throws Exception
+ *
+ * The byteman rule on this test overwrites the {@link #getBridgeTTL} method to retrieve the bridge called {@link @BRIDGE_NAME}.
+ * It the overrides the return value to be the value of the connection ttl. Note that the unused String parameter is required to
+ * ensure that byteman populates the $1 variable, otherwise it will not bind correctly.
+ */
+ public void testConnectionTTLOnBridge() throws Exception
+ {
+ Map<String, Object> server0Params = new HashMap<String, Object>();
+ ActiveMQServer serverWithBridge = createClusteredServerWithParams(isNetty(), 0, true, server0Params);
+
+ Map<String, Object> server1Params = new HashMap<String, Object>();
+ if (isNetty())
+ {
+ server1Params.put("port", org.apache.activemq.core.remoting.impl.netty.TransportConstants.DEFAULT_PORT + 1);
+ }
+ else
+ {
+ server1Params.put(TransportConstants.SERVER_ID_PROP_NAME, 1);
+ }
+ ActiveMQServer server1 = createClusteredServerWithParams(isNetty(), 1, true, server1Params);
+ ServerLocator locator = null;
+ try
+ {
+ final String testAddress = "testAddress";
+ final String queueName0 = "queue0";
+ final String forwardAddress = "forwardAddress";
+ final String queueName1 = "queue1";
+
+ Map<String, TransportConfiguration> connectors = new HashMap<String, TransportConfiguration>();
+ TransportConfiguration server1tc = new TransportConfiguration(getConnector(), server1Params);
+ connectors.put(server1tc.getName(), server1tc);
+
+ serverWithBridge.getConfiguration().setConnectorConfigurations(connectors);
+
+ ArrayList<String> staticConnectors = new ArrayList<String>();
+ staticConnectors.add(server1tc.getName());
+
+ BridgeConfiguration bridgeConfiguration = new BridgeConfiguration()
+ .setName(BRIDGE_NAME)
+ .setQueueName(queueName0)
+ .setForwardingAddress(forwardAddress)
+ .setConnectionTTL(BRIDGE_TTL)
+ .setRetryInterval(1000)
+ .setReconnectAttempts(0)
+ .setReconnectAttemptsOnSameNode(0)
+ .setConfirmationWindowSize(1024)
+ .setStaticConnectors(staticConnectors);
+
+ List<BridgeConfiguration> bridgeConfigs = new ArrayList<BridgeConfiguration>();
+ bridgeConfigs.add(bridgeConfiguration);
+ serverWithBridge.getConfiguration().setBridgeConfigurations(bridgeConfigs);
+
+ CoreQueueConfiguration queueConfig0 = new CoreQueueConfiguration()
+ .setAddress(testAddress)
+ .setName(queueName0);
+ List<CoreQueueConfiguration> queueConfigs0 = new ArrayList<CoreQueueConfiguration>();
+ queueConfigs0.add(queueConfig0);
+ serverWithBridge.getConfiguration().setQueueConfigurations(queueConfigs0);
+
+ CoreQueueConfiguration queueConfig1 = new CoreQueueConfiguration()
+ .setAddress(forwardAddress)
+ .setName(queueName1);
+ List<CoreQueueConfiguration> queueConfigs1 = new ArrayList<CoreQueueConfiguration>();
+ queueConfigs1.add(queueConfig1);
+ server1.getConfiguration().setQueueConfigurations(queueConfigs1);
+
+ server1.start();
+ waitForServer(server1);
+
+ serverWithBridge.start();
+ waitForServer(serverWithBridge);
+
+ long bridgeTTL = getBridgeTTL(serverWithBridge, BRIDGE_NAME);
+
+ assertEquals(BRIDGE_TTL, bridgeTTL);
+ }
+ finally
+ {
+ if (locator != null)
+ {
+ locator.close();
+ }
+
+ serverWithBridge.stop();
+
+ server1.stop();
+ }
+ }
+
+ /**
+ * Method for byteman to wrap around and do its magic with to return the ttl from private members
+ * rather than -1
+ * @param bridgeServer
+ * @param bridgeName
+ * @return
+ */
+ private long getBridgeTTL(ActiveMQServer bridgeServer, String bridgeName)
+ {
+ return -1L;
+ }
+
+ /**
+ * Byteman seems to need this method so that it gets back the concrete type not the interface
+ * @param bridgeServer
+ * @return
+ */
+ private BridgeImpl getConfiguredBridge(ActiveMQServer bridgeServer)
+ {
+ return getConfiguredBridge(bridgeServer, BRIDGE_NAME);
+ }
+
+ private BridgeImpl getConfiguredBridge(ActiveMQServer bridgeServer, String bridgeName)
+ {
+ return (BridgeImpl)bridgeServer.getClusterManager().getBridges().get(bridgeName);
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/ClosingConnectionTest.java
----------------------------------------------------------------------
diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/ClosingConnectionTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/ClosingConnectionTest.java
new file mode 100644
index 0000000..cd3ee24
--- /dev/null
+++ b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/ClosingConnectionTest.java
@@ -0,0 +1,192 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.tests.extras.byteman;
+
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+
+import org.apache.activemq.api.core.SimpleString;
+import org.apache.activemq.api.core.client.ClientMessage;
+import org.apache.activemq.api.core.client.ClientProducer;
+import org.apache.activemq.api.core.client.ClientSession;
+import org.apache.activemq.api.core.client.ClientSessionFactory;
+import org.apache.activemq.api.core.client.ServerLocator;
+import org.apache.activemq.api.core.management.ActiveMQServerControl;
+import org.apache.activemq.core.server.ActiveMQServer;
+import org.apache.activemq.core.server.JournalType;
+import org.apache.activemq.core.settings.impl.AddressSettings;
+import org.apache.activemq.tests.integration.IntegrationTestLogger;
+import org.apache.activemq.tests.integration.management.ManagementControlHelper;
+import org.apache.activemq.tests.util.ServiceTestBase;
+import org.jboss.byteman.contrib.bmunit.BMRule;
+import org.jboss.byteman.contrib.bmunit.BMRules;
+import org.jboss.byteman.contrib.bmunit.BMUnitRunner;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(BMUnitRunner.class)
+public class ClosingConnectionTest extends ServiceTestBase
+{
+ public static final SimpleString ADDRESS = new SimpleString("SimpleAddress");
+
+ private ServerLocator locator;
+
+ private ActiveMQServer server;
+
+ private static MBeanServer mBeanServer;
+
+ private static boolean readyToKill = false;
+
+ protected boolean isNetty()
+ {
+ return true;
+ }
+
+
+ @Override
+ @Before
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ mBeanServer = MBeanServerFactory.createMBeanServer();
+ server = newActiveMQServer();
+ server.getConfiguration().setJournalType(JournalType.NIO);
+ server.getConfiguration().setJMXManagementEnabled(true);
+ server.start();
+ waitForServer(server);
+ locator = createFactory(isNetty());
+ readyToKill = false;
+ }
+
+ public static void killConnection() throws InterruptedException
+ {
+ if (readyToKill)
+ {
+ // We have to kill the connection in a new thread otherwise Netty won't interrupt the current thread
+ Thread closeConnectionThread = new Thread(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ try
+ {
+ ActiveMQServerControl serverControl = ManagementControlHelper.createActiveMQServerControl(mBeanServer);
+ serverControl.closeConnectionsForUser("guest");
+ readyToKill = false;
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ });
+
+ closeConnectionThread.start();
+
+ try
+ {
+ /* We want to simulate a long-running remoting thread here. If closing the connection in the closeConnectionThread
+ * interrupts this thread then it will cause sleep() to throw and InterruptedException. Therefore we catch
+ * the InterruptedException and re-interrupt the current thread so the interrupt will be passed properly
+ * back to the caller. It's a bit of a hack, but I couldn't find any other way to simulate it.
+ */
+ Thread.sleep(1500);
+ }
+ catch (InterruptedException e)
+ {
+ Thread.currentThread().interrupt();
+ }
+ }
+ }
+
+ /*
+ * Test for https://bugzilla.redhat.com/show_bug.cgi?id=1193085
+ * */
+ @Test
+ @BMRules
+ (
+ rules =
+ {
+ @BMRule
+ (
+ name = "rule to kill connection",
+ targetClass = "org.apache.activemq.core.journal.impl.NIOSequentialFile",
+ targetMethod = "open(int, boolean)",
+ targetLocation = "AT INVOKE java.nio.channels.FileChannel.size()",
+ action = "org.apache.activemq.tests.extras.byteman.ClosingConnectionTest.killConnection();"
+
+ )
+ }
+ )
+ public void testKillConnection() throws Exception
+ {
+ locator.setBlockOnNonDurableSend(true);
+ locator.setBlockOnDurableSend(true);
+ locator.setBlockOnAcknowledge(true);
+
+ ClientSessionFactory sf = createSessionFactory(locator);
+ ClientSession session = sf.createSession("guest", null, false, true, true, false, 0);
+
+ session.createQueue(ADDRESS, ADDRESS, null, true);
+
+ ClientProducer producer = session.createProducer(ADDRESS);
+
+ ClientMessage message = session.createMessage(true);
+ message.getBodyBuffer().writeBytes(new byte[1024]);
+
+ for (int i = 0; i < 200; i++)
+ {
+ producer.send(message);
+ }
+
+ assertTrue(server.locateQueue(ADDRESS).getPageSubscription().getPagingStore().isPaging());
+
+ readyToKill = true;
+ try
+ {
+ for (int i = 0; i < 8; i++)
+ {
+ producer.send(message);
+ }
+ fail("Sending message here should result in failure.");
+ }
+ catch (Exception e)
+ {
+ IntegrationTestLogger.LOGGER.info("Caught exception: " + e.getMessage());
+ }
+
+ Thread.sleep(1000);
+
+ assertTrue(server.isStarted());
+
+ session.close();
+ }
+
+ private ActiveMQServer newActiveMQServer() throws Exception
+ {
+ ActiveMQServer server = createServer(true, createDefaultConfig(isNetty()), mBeanServer);
+
+ AddressSettings defaultSetting = new AddressSettings();
+ defaultSetting.setPageSizeBytes(10 * 1024);
+ defaultSetting.setMaxSizeBytes(20 * 1024);
+
+ server.getAddressSettingsRepository().addMatch("#", defaultSetting);
+
+ return server;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/ClusteredGroupingTest.java
----------------------------------------------------------------------
diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/ClusteredGroupingTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/ClusteredGroupingTest.java
new file mode 100644
index 0000000..bc9f853
--- /dev/null
+++ b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/ClusteredGroupingTest.java
@@ -0,0 +1,473 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.tests.extras.byteman;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.activemq.api.core.ActiveMQNonExistentQueueException;
+import org.apache.activemq.api.core.Message;
+import org.apache.activemq.api.core.SimpleString;
+import org.apache.activemq.api.core.management.ManagementHelper;
+import org.apache.activemq.api.core.management.CoreNotificationType;
+import org.apache.activemq.core.server.ActiveMQServer;
+import org.apache.activemq.core.server.group.impl.GroupingHandlerConfiguration;
+import org.apache.activemq.core.server.group.impl.Response;
+import org.apache.activemq.core.server.management.Notification;
+import org.apache.activemq.tests.integration.cluster.distribution.ClusterTestBase;
+import org.jboss.byteman.contrib.bmunit.BMRule;
+import org.jboss.byteman.contrib.bmunit.BMRules;
+import org.jboss.byteman.contrib.bmunit.BMUnitRunner;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * @author <a href="mailto:andy.taylor@jboss.org">Andy Taylor</a>
+ */
+@RunWith(BMUnitRunner.class)
+public class ClusteredGroupingTest extends ClusterTestBase
+{
+ @Test
+ @BMRules
+ (
+ rules =
+ {
+ @BMRule
+ (
+ name = "blow-up",
+ targetClass = "org.apache.activemq.core.server.group.impl.LocalGroupingHandler",
+ targetMethod = "removeGrouping",
+ targetLocation = "ENTRY",
+ action = "org.apache.activemq.tests.extras.byteman.ClusteredGroupingTest.pause($1);"
+ ),
+ @BMRule
+ (
+ name = "blow-up2",
+ targetClass = "org.apache.activemq.core.server.group.impl.GroupHandlingAbstract",
+ targetMethod = "forceRemove",
+ targetLocation = "ENTRY",
+ action = "org.apache.activemq.tests.extras.byteman.ClusteredGroupingTest.restart2();"
+ )
+ }
+ )
+ public void test2serversLocalGoesDown() throws Exception
+ {
+ setupServer(0, isFileStorage(), isNetty());
+ setupServer(1, isFileStorage(), isNetty());
+
+ setupClusterConnection("cluster0", "queues", false, 1, 0, 500, isNetty(), 0, 1);
+
+ setupClusterConnection("cluster1", "queues", false, 1, 0, 500, isNetty(), 1, 0);
+
+ setUpGroupHandler(GroupingHandlerConfiguration.TYPE.LOCAL, 0);
+ setUpGroupHandler(GroupingHandlerConfiguration.TYPE.REMOTE, 1);
+
+ startServers(0, 1);
+
+ setupSessionFactory(0, isNetty());
+ setupSessionFactory(1, isNetty());
+
+ createQueue(0, "queues.testaddress", "queue0", null, true);
+ createQueue(1, "queues.testaddress", "queue0", null, true);
+
+ addConsumer(0, 1, "queue0", null);
+
+ waitForBindings(0, "queues.testaddress", 1, 0, true);
+ waitForBindings(1, "queues.testaddress", 1, 1, true);
+
+ waitForBindings(0, "queues.testaddress", 1, 1, false);
+ waitForBindings(1, "queues.testaddress", 1, 0, false);
+
+ sendWithProperty(0, "queues.testaddress", 1, true, Message.HDR_GROUP_ID, new SimpleString("id1"));
+
+ latch = new CountDownLatch(1);
+ latch2 = new CountDownLatch(1);
+
+ crashAndWaitForFailure(getServer(1));
+
+ assertTrue(latch2.await(20000, TimeUnit.MILLISECONDS));
+
+ try
+ {
+ try
+ {
+ sendWithProperty(0, "queues.testaddress", 1, true, Message.HDR_GROUP_ID, new SimpleString("id1"));
+ }
+ catch (ActiveMQNonExistentQueueException e)
+ {
+ fail("did not handle removal of queue");
+ }
+ }
+ finally
+ {
+ latch.countDown();
+ }
+ }
+
+ @Test
+ @BMRules
+ (
+ rules =
+ {
+ @BMRule
+ (
+ name = "blow-up",
+ targetClass = "org.apache.activemq.core.server.group.impl.RemoteGroupingHandler",
+ targetMethod = "onNotification",
+ targetLocation = "ENTRY",
+ action = "org.apache.activemq.tests.extras.byteman.ClusteredGroupingTest.pause2($1);"
+ ),
+ @BMRule(name = "blow-up2",
+ targetClass = "org.apache.activemq.core.server.group.impl.RemoteGroupingHandler",
+ targetMethod = "remove",
+ targetLocation = "ENTRY",
+ action = "org.apache.activemq.tests.extras.byteman.ClusteredGroupingTest.restart2();")
+ }
+ )
+ public void test3serversLocalGoesDown() throws Exception
+ {
+ setupServer(0, isFileStorage(), isNetty());
+ setupServer(1, isFileStorage(), isNetty());
+ setupServer(2, isFileStorage(), isNetty());
+
+ setupClusterConnection("cluster0", "queues", false, 1, 0, 500, isNetty(), 0, 1, 2);
+
+ setupClusterConnection("cluster1", "queues", false, 1, 0, 500, isNetty(), 1, 0, 2);
+
+ setupClusterConnection("cluster2", "queues", false, 1, 0, 500, isNetty(), 2, 0, 1);
+
+ setUpGroupHandler(GroupingHandlerConfiguration.TYPE.LOCAL, 0);
+ setUpGroupHandler(GroupingHandlerConfiguration.TYPE.REMOTE, 1);
+ setUpGroupHandler(GroupingHandlerConfiguration.TYPE.REMOTE, 2);
+
+ startServers(0, 1, 2);
+
+ setupSessionFactory(0, isNetty());
+ setupSessionFactory(1, isNetty());
+ setupSessionFactory(2, isNetty());
+
+ createQueue(0, "queues.testaddress", "queue0", null, true);
+ createQueue(1, "queues.testaddress", "queue0", null, true);
+ createQueue(2, "queues.testaddress", "queue0", null, true);
+
+ addConsumer(0, 2, "queue0", null);
+
+ waitForBindings(0, "queues.testaddress", 1, 0, true);
+ waitForBindings(1, "queues.testaddress", 1, 0, true);
+ waitForBindings(2, "queues.testaddress", 1, 1, true);
+
+ waitForBindings(0, "queues.testaddress", 2, 1, false);
+ waitForBindings(1, "queues.testaddress", 2, 1, false);
+ waitForBindings(2, "queues.testaddress", 2, 0, false);
+
+ sendWithProperty(1, "queues.testaddress", 1, true, Message.HDR_GROUP_ID, new SimpleString("id1"));
+
+ latch = new CountDownLatch(1);
+ latch2 = new CountDownLatch(1);
+
+ main = Thread.currentThread();
+ crashAndWaitForFailure(getServer(2));
+
+ assertTrue(latch2.await(20000, TimeUnit.MILLISECONDS));
+
+ try
+ {
+ try
+ {
+ sendWithProperty(1, "queues.testaddress", 1, true, Message.HDR_GROUP_ID, new SimpleString("id1"));
+ }
+ catch (ActiveMQNonExistentQueueException e)
+ {
+ fail("did not handle removal of queue");
+ }
+ }
+ finally
+ {
+ latch.countDown();
+ }
+
+ assertHandlersAreSame(getServer(0), getServer(1));
+ }
+
+ @Test
+ @BMRules
+ (
+ rules =
+ {
+ @BMRule
+ (
+ name = "blow-up",
+ targetClass = "org.apache.activemq.core.server.group.impl.LocalGroupingHandler",
+ targetMethod = "onNotification",
+ targetLocation = "ENTRY",
+ action = "org.apache.activemq.tests.extras.byteman.ClusteredGroupingTest.pause2($1);"
+ ),
+ @BMRule(name = "blow-up2",
+ targetClass = "org.apache.activemq.core.server.group.impl.LocalGroupingHandler",
+ targetMethod = "remove",
+ targetLocation = "ENTRY",
+ action = "org.apache.activemq.tests.extras.byteman.ClusteredGroupingTest.restart2();")
+ }
+ )
+ public void testLocal3serversLocalGoesDown() throws Exception
+ {
+ setupServer(0, isFileStorage(), isNetty());
+ setupServer(1, isFileStorage(), isNetty());
+ setupServer(2, isFileStorage(), isNetty());
+
+ setupClusterConnection("cluster0", "queues", false, 1, 0, 500, isNetty(), 0, 1, 2);
+
+ setupClusterConnection("cluster1", "queues", false, 1, 0, 500, isNetty(), 1, 0, 2);
+
+ setupClusterConnection("cluster2", "queues", false, 1, 0, 500, isNetty(), 2, 0, 1);
+
+ setUpGroupHandler(GroupingHandlerConfiguration.TYPE.LOCAL, 0);
+ setUpGroupHandler(GroupingHandlerConfiguration.TYPE.REMOTE, 1);
+ setUpGroupHandler(GroupingHandlerConfiguration.TYPE.REMOTE, 2);
+
+ startServers(0, 1, 2);
+
+ setupSessionFactory(0, isNetty());
+ setupSessionFactory(1, isNetty());
+ setupSessionFactory(2, isNetty());
+
+ createQueue(0, "queues.testaddress", "queue0", null, true);
+ createQueue(1, "queues.testaddress", "queue0", null, true);
+ createQueue(2, "queues.testaddress", "queue0", null, true);
+
+ addConsumer(0, 2, "queue0", null);
+
+ waitForBindings(0, "queues.testaddress", 1, 0, true);
+ waitForBindings(1, "queues.testaddress", 1, 0, true);
+ waitForBindings(2, "queues.testaddress", 1, 1, true);
+
+ waitForBindings(0, "queues.testaddress", 2, 1, false);
+ waitForBindings(1, "queues.testaddress", 2, 1, false);
+ waitForBindings(2, "queues.testaddress", 2, 0, false);
+
+ sendWithProperty(0, "queues.testaddress", 1, true, Message.HDR_GROUP_ID, new SimpleString("id1"));
+
+ latch = new CountDownLatch(1);
+ latch2 = new CountDownLatch(1);
+
+ main = Thread.currentThread();
+ crashAndWaitForFailure(getServer(2));
+
+ assertTrue(latch2.await(20000, TimeUnit.MILLISECONDS));
+
+ try
+ {
+ try
+ {
+ sendWithProperty(0, "queues.testaddress", 1, true, Message.HDR_GROUP_ID, new SimpleString("id1"));
+ }
+ catch (ActiveMQNonExistentQueueException e)
+ {
+ fail("did not handle removal of queue");
+ }
+ }
+ finally
+ {
+ latch.countDown();
+ }
+
+ assertHandlersAreSame(getServer(0), getServer(1));
+ }
+
+ @Test
+ @BMRules
+ (
+ rules =
+ {
+ @BMRule
+ (
+ name = "blow-up",
+ targetClass = "org.apache.activemq.core.server.group.impl.LocalGroupingHandler",
+ targetMethod = "onNotification",
+ targetLocation = "ENTRY",
+ action = "org.apache.activemq.tests.extras.byteman.ClusteredGroupingTest.pause2($1);"
+ ),
+ @BMRule(name = "blow-up2",
+ targetClass = "org.apache.activemq.core.server.group.impl.LocalGroupingHandler",
+ targetMethod = "remove",
+ targetLocation = "ENTRY",
+ action = "org.apache.activemq.tests.extras.byteman.ClusteredGroupingTest.restart2();")
+ }
+ )
+ public void testLocal4serversLocalGoesDown() throws Exception
+ {
+ setupServer(0, isFileStorage(), isNetty());
+ setupServer(1, isFileStorage(), isNetty());
+ setupServer(2, isFileStorage(), isNetty());
+ setupServer(3, isFileStorage(), isNetty());
+
+ setupClusterConnection("cluster0", "queues", false, 1, 0, 500, isNetty(), 0, 1, 2, 3);
+
+ setupClusterConnection("cluster1", "queues", false, 1, 0, 500, isNetty(), 1, 0, 2, 3);
+
+ setupClusterConnection("cluster2", "queues", false, 1, 0, 500, isNetty(), 2, 0, 1, 3);
+
+ setupClusterConnection("cluster3", "queues", false, 1, 0, 500, isNetty(), 3, 1, 2, 3);
+
+ setUpGroupHandler(GroupingHandlerConfiguration.TYPE.LOCAL, 0);
+ setUpGroupHandler(GroupingHandlerConfiguration.TYPE.REMOTE, 1);
+ setUpGroupHandler(GroupingHandlerConfiguration.TYPE.REMOTE, 2);
+ setUpGroupHandler(GroupingHandlerConfiguration.TYPE.REMOTE, 3);
+
+ startServers(0, 1, 2, 3);
+
+ setupSessionFactory(0, isNetty());
+ setupSessionFactory(1, isNetty());
+ setupSessionFactory(2, isNetty());
+ setupSessionFactory(3, isNetty());
+
+ createQueue(0, "queues.testaddress", "queue0", null, true);
+ createQueue(1, "queues.testaddress", "queue0", null, true);
+ createQueue(2, "queues.testaddress", "queue0", null, true);
+ createQueue(3, "queues.testaddress", "queue0", null, true);
+
+ addConsumer(0, 2, "queue0", null);
+
+ waitForBindings(0, "queues.testaddress", 1, 0, true);
+ waitForBindings(1, "queues.testaddress", 1, 0, true);
+ waitForBindings(2, "queues.testaddress", 1, 1, true);
+ waitForBindings(3, "queues.testaddress", 1, 0, true);
+
+ waitForBindings(0, "queues.testaddress", 3, 1, false);
+ waitForBindings(1, "queues.testaddress", 3, 1, false);
+ waitForBindings(2, "queues.testaddress", 3, 0, false);
+ waitForBindings(3, "queues.testaddress", 3, 1, false);
+
+ sendWithProperty(0, "queues.testaddress", 1, true, Message.HDR_GROUP_ID, new SimpleString("id1"));
+
+ latch = new CountDownLatch(1);
+ latch2 = new CountDownLatch(1);
+
+ main = Thread.currentThread();
+ crashAndWaitForFailure(getServer(2));
+
+ assertTrue(latch2.await(20000, TimeUnit.MILLISECONDS));
+
+ try
+ {
+ try
+ {
+ sendWithProperty(0, "queues.testaddress", 1, true, Message.HDR_GROUP_ID, new SimpleString("id1"));
+ }
+ catch (ActiveMQNonExistentQueueException e)
+ {
+ fail("did not handle removal of queue");
+ }
+ }
+ finally
+ {
+ latch.countDown();
+ }
+ //now restart server
+ getServer(2).start();
+ waitForBindings(2, "queues.testaddress", 1, 0, true);
+ waitForBindings(2, "queues.testaddress", 3, 0, false);
+ sendWithProperty(3, "queues.testaddress", 1, true, Message.HDR_GROUP_ID, new SimpleString("id1"));
+ Thread.sleep(2000);
+ assertHandlersAreSame(getServer(0), getServer(1), getServer(2), getServer(3));
+ }
+
+ private void assertHandlersAreSame(ActiveMQServer server, ActiveMQServer... qServers)
+ {
+ SimpleString id = server.getGroupingHandler().getProposal(new SimpleString("id1.queue0"), false).getClusterName();
+ for (ActiveMQServer qServer : qServers)
+ {
+ Response proposal = qServer.getGroupingHandler().getProposal(new SimpleString("id1.queue0"), false);
+ if (proposal != null)
+ {
+ assertEquals(qServer.getIdentity() + " is incorrect", id, proposal.getChosenClusterName());
+ }
+ }
+ }
+
+ static CountDownLatch latch;
+ static CountDownLatch latch2;
+ static Thread main;
+
+ public static void pause(SimpleString clusterName)
+ {
+ if (clusterName.toString().startsWith("queue0"))
+ {
+ try
+ {
+ latch2.countDown();
+ latch.await();
+ }
+ catch (InterruptedException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public static void pause2(Notification notification)
+ {
+ if (notification.getType() == CoreNotificationType.BINDING_REMOVED)
+ {
+ SimpleString clusterName = notification.getProperties()
+ .getSimpleStringProperty(ManagementHelper.HDR_CLUSTER_NAME);
+ boolean inMain = main == Thread.currentThread();
+ if (clusterName.toString().startsWith("queue0") && !inMain)
+ {
+ try
+ {
+ latch2.countDown();
+ latch.await();
+ }
+ catch (InterruptedException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ public static void restart2()
+ {
+ latch.countDown();
+ }
+
+
+ @Override
+ @Before
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ }
+
+ @Override
+ @After
+ public void tearDown() throws Exception
+ {
+ closeAllConsumers();
+ closeAllSessionFactories();
+ closeAllServerLocatorsFactories();
+ super.tearDown();
+ }
+
+ public boolean isNetty()
+ {
+ return true;
+ }
+}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/GroupingTest.java
----------------------------------------------------------------------
diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/GroupingTest.java b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/GroupingTest.java
new file mode 100644
index 0000000..34f58f7
--- /dev/null
+++ b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/byteman/GroupingTest.java
@@ -0,0 +1,202 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.tests.extras.byteman;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.JMSException;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+import org.apache.activemq.api.core.ActiveMQNotConnectedException;
+import org.apache.activemq.jms.client.ActiveMQConnectionFactory;
+import org.apache.activemq.spi.core.protocol.RemotingConnection;
+import org.apache.activemq.tests.util.JMSTestBase;
+import org.jboss.byteman.contrib.bmunit.BMRule;
+import org.jboss.byteman.contrib.bmunit.BMRules;
+import org.jboss.byteman.contrib.bmunit.BMUnitRunner;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * GroupingTest
+ *
+ * @author Andy Taylor
+ */
+@RunWith(BMUnitRunner.class)
+public class GroupingTest extends JMSTestBase
+{
+ private Queue queue;
+ static boolean pause = false;
+
+ @Before
+ @Override
+ public void setUp() throws Exception
+ {
+ super.setUp();
+
+ queue = createQueue("TestQueue");
+ }
+
+ @After
+ @Override
+ public void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
+ protected ConnectionFactory getCF() throws Exception
+ {
+ return cf;
+ }
+
+
+ @Test
+ @BMRules
+ (
+ rules =
+ {
+ @BMRule
+ (
+ name = "trace clientsessionimpl commit",
+ targetClass = "org.apache.activemq.core.server.impl.ServerSessionImpl",
+ targetMethod = "rollback",
+ targetLocation = "EXIT",
+ action = "org.apache.activemq.tests.extras.byteman.GroupingTest.pause();"
+ )
+ }
+ )
+ public void testGroupingRollbackOnClose() throws Exception
+ {
+ Connection sendConnection = null;
+ Connection connection = null;
+ Connection connection2 = null;
+ try
+ {
+ ActiveMQConnectionFactory fact = (ActiveMQConnectionFactory) getCF();
+ fact.setReconnectAttempts(0);
+ //fact.setConsumerWindowSize(1000);
+ //fact.setTransactionBatchSize(0);
+ connection = fact.createConnection();
+ RemotingConnection rc = server.getRemotingService().getConnections().iterator().next();
+ connection2 = fact.createConnection();
+ sendConnection = fact.createConnection();
+
+ final Session sendSession = sendConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
+ Session session2 = connection2.createSession(true, Session.SESSION_TRANSACTED);
+
+ final MessageProducer producer = sendSession.createProducer(queue);
+
+ MessageConsumer consumer1 = session.createConsumer(queue);
+ MessageConsumer consumer2 = session2.createConsumer(queue);
+
+ connection.start();
+ connection2.start();
+
+ final String jmsxgroupID = null;
+
+ Thread t = new Thread(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+
+ try
+ {
+ for (int j = 0; j < 10000; j++)
+ {
+ TextMessage message = sendSession.createTextMessage();
+
+ message.setText("Message" + j);
+
+ message.setStringProperty("JMSXGroupID", "foo");
+
+ producer.send(message);
+ }
+ }
+ catch (JMSException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ });
+ t.start();
+
+ //consume 5 msgs from 1st first consumer
+ for (int j = 0; j < 5; j++)
+ {
+ TextMessage tm = (TextMessage) consumer1.receive(10000);
+
+ assertNotNull(tm);
+
+ assertEquals("Message" + j, tm.getText());
+
+ assertEquals(tm.getStringProperty("JMSXGroupID"), "foo");
+ }
+
+ pause = true;
+ rc.fail(new ActiveMQNotConnectedException());
+ pause = false;
+
+ for (int j = 0; j < 10000; j++)
+ {
+ TextMessage tm = (TextMessage) consumer2.receive(5000);
+
+ assertNotNull(tm);
+
+ assertEquals("Message" + j, tm.getText());
+
+ assertEquals(tm.getStringProperty("JMSXGroupID"), "foo");
+ }
+ }
+ finally
+ {
+ if (sendConnection != null)
+ {
+ sendConnection.close();
+ }
+ if (connection2 != null)
+ {
+ connection2.close();
+ }
+ }
+ }
+
+
+ public static void pause()
+ {
+ if (pause)
+ {
+ try
+ {
+ System.out.println("pausing after rollback");
+ Thread.sleep(500);
+ }
+ catch (InterruptedException e)
+ {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
+ System.out.println("finished pausing after rollback");
+ }
+ }
+}
[08/15] activemq-6 git commit: Refactored the testsuite a bit
Posted by jb...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/jms/xa/XATest.java
----------------------------------------------------------------------
diff --git a/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/jms/xa/XATest.java b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/jms/xa/XATest.java
new file mode 100644
index 0000000..4847e34
--- /dev/null
+++ b/tests/extra-tests/src/test/java/org/apache/activemq/tests/extras/jms/xa/XATest.java
@@ -0,0 +1,2142 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.tests.extras.jms.xa;
+
+import javax.jms.Connection;
+import javax.jms.DeliveryMode;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.jms.XAConnection;
+import javax.jms.XAConnectionFactory;
+import javax.jms.XASession;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+
+import com.arjuna.ats.arjuna.coordinator.TransactionReaper;
+import com.arjuna.ats.arjuna.coordinator.TxControl;
+import com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionManagerImple;
+
+import org.apache.activemq.api.jms.ActiveMQJMSClient;
+import org.apache.activemq.core.client.impl.ClientSessionInternal;
+import org.apache.activemq.tests.extras.ExtrasTestLogger;
+import org.apache.activemq.tests.util.JMSTestBase;
+import org.jboss.tm.TxUtils;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ *
+ * A XATestBase
+ *
+ * @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
+ * @author <a href="mailto:clebert.suconic@jboss.com">Clebert Suconic</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ *
+ */
+public class XATest extends JMSTestBase
+{
+ // Constants -----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ protected TransactionManager tm;
+
+ protected Transaction suspendedTx;
+
+ protected XAConnectionFactory xacf;
+
+ protected Queue queue1;
+
+ // Constructors --------------------------------------------------
+
+ // TestCase overrides -------------------------------------------
+
+ @Override
+ @Before
+ public void setUp() throws Exception
+ {
+ super.setUp();
+
+ xacf = ActiveMQJMSClient.createConnectionFactory("tcp://localhost:61616", "test");
+
+ queue1 = createQueue("queue1");
+ TxControl.enable();
+
+ tm = new TransactionManagerImple();
+
+ Assert.assertTrue(tm instanceof TransactionManagerImple);
+
+ suspendedTx = tm.suspend();
+ }
+
+ @Override
+ @After
+ public void tearDown() throws Exception
+ {
+ if (TxUtils.isUncommitted(tm))
+ {
+ // roll it back
+ try
+ {
+ tm.rollback();
+ }
+ catch (Throwable ignore)
+ {
+ // The connection will probably be closed so this may well throw an exception
+ }
+ }
+ if (tm.getTransaction() != null)
+ {
+ Transaction tx = tm.suspend();
+ if (tx != null)
+ {
+ ExtrasTestLogger.LOGGER.warn("Transaction still associated with thread " + tx +
+ " at status " +
+ TxUtils.getStatusAsString(tx.getStatus()));
+ }
+ }
+
+ if (suspendedTx != null)
+ {
+ tm.resume(suspendedTx);
+ }
+
+ TxControl.disable(true);
+
+ TransactionReaper.terminate(false);
+
+ super.tearDown();
+
+ }
+
+ // Public --------------------------------------------------------
+
+ @Test
+ public void test2PCSendCommit1PCOptimization() throws Exception
+ {
+ // Since both resources have same RM, TM will probably use 1PC optimization
+
+ XAConnection conn = null;
+ Connection conn2 = null;
+
+ try
+ {
+ conn = xacf.createXAConnection();
+
+ tm.begin();
+
+ XASession sess = conn.createXASession();
+ XAResource res = sess.getXAResource();
+
+ XAResource res2 = new DummyXAResource();
+
+ Transaction tx = tm.getTransaction();
+ tx.enlistResource(res);
+ tx.enlistResource(res2);
+
+ MessageProducer prod = sess.createProducer(queue1);
+ prod.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+ Message m = sess.createTextMessage("XATest1");
+ prod.send(m);
+ m = sess.createTextMessage("XATest2");
+ prod.send(m);
+
+ tx.delistResource(res, XAResource.TMSUCCESS);
+ tx.delistResource(res2, XAResource.TMSUCCESS);
+
+ tm.commit();
+
+ conn2 = cf.createConnection();
+ conn2.start();
+ Session sessReceiver = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageConsumer cons = sessReceiver.createConsumer(queue1);
+ TextMessage m2 = (TextMessage)cons.receive(1000);
+ Assert.assertNotNull(m2);
+ Assert.assertEquals("XATest1", m2.getText());
+ m2 = (TextMessage)cons.receive(1000);
+ Assert.assertNotNull(m2);
+ Assert.assertEquals("XATest2", m2.getText());
+ }
+ finally
+ {
+ if (conn != null)
+ {
+ conn.close();
+ }
+ if (conn2 != null)
+ {
+ conn2.close();
+ }
+ }
+ }
+
+ @Test
+ public void test2PCSendCommit() throws Exception
+ {
+ XAConnection conn = null;
+ Connection conn2 = null;
+
+ try
+ {
+ conn = xacf.createXAConnection();
+
+ tm.begin();
+
+ XASession sess = conn.createXASession();
+
+ XAResource res = sess.getXAResource();
+ XAResource res2 = new DummyXAResource();
+
+ // To prevent 1PC optimization being used
+ // res.setForceNotSameRM(true);
+
+ Transaction tx = tm.getTransaction();
+
+ tx.enlistResource(res);
+
+ tx.enlistResource(res2);
+
+ MessageProducer prod = sess.createProducer(queue1);
+ prod.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+ Message m = sess.createTextMessage("XATest1");
+ prod.send(m);
+ m = sess.createTextMessage("XATest2");
+ prod.send(m);
+
+ tx.delistResource(res, XAResource.TMSUCCESS);
+ tx.delistResource(res2, XAResource.TMSUCCESS);
+
+ tm.commit();
+
+ conn2 = cf.createConnection();
+ conn2.start();
+ Session sessReceiver = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageConsumer cons = sessReceiver.createConsumer(queue1);
+ TextMessage m2 = (TextMessage)cons.receive(5000);
+ Assert.assertNotNull(m2);
+ Assert.assertEquals("XATest1", m2.getText());
+ m2 = (TextMessage)cons.receive(5000);
+ Assert.assertNotNull(m2);
+ Assert.assertEquals("XATest2", m2.getText());
+ }
+ finally
+ {
+ if (conn != null)
+ {
+ conn.close();
+ }
+ if (conn2 != null)
+ {
+ conn2.close();
+ }
+ }
+ }
+
+ @Test
+ public void test2PCSendFailOnPrepare() throws Exception
+ {
+ XAConnection conn = null;
+ Connection conn2 = null;
+ try
+ {
+ conn = xacf.createXAConnection();
+
+ tm.begin();
+
+ XASession sess = conn.createXASession();
+ XAResource res = sess.getXAResource();
+
+ // prevent 1Pc optimisation
+ // res.setForceNotSameRM(true);
+
+ XAResource res2 = new DummyXAResource(true);
+ XAResource res3 = new DummyXAResource();
+ XAResource res4 = new DummyXAResource();
+
+ Transaction tx = tm.getTransaction();
+ tx.enlistResource(res);
+ tx.enlistResource(res2);
+ tx.enlistResource(res3);
+ tx.enlistResource(res4);
+
+ MessageProducer prod = sess.createProducer(null);
+ prod.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+ Message m = sess.createTextMessage("XATest1");
+ prod.send(queue1, m);
+ m = sess.createTextMessage("XATest2");
+ prod.send(queue1, m);
+
+ tx.delistResource(res, XAResource.TMSUCCESS);
+ tx.delistResource(res2, XAResource.TMSUCCESS);
+ tx.delistResource(res3, XAResource.TMSUCCESS);
+ tx.delistResource(res4, XAResource.TMSUCCESS);
+
+ try
+ {
+ tm.commit();
+
+ Assert.fail("should not get here");
+ }
+ catch (Exception e)
+ {
+ // We should expect this
+ }
+
+ conn2 = cf.createConnection();
+ conn2.start();
+ Session sessReceiver = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageConsumer cons = sessReceiver.createConsumer(queue1);
+ Message m2 = cons.receive(100);
+ Assert.assertNull(m2);
+ }
+ finally
+ {
+ if (conn != null)
+ {
+ conn.close();
+ }
+ if (conn2 != null)
+ {
+ conn2.close();
+ }
+ }
+ }
+
+ @Test
+ public void test2PCSendRollback() throws Exception
+ {
+ XAConnection conn = null;
+ Connection conn2 = null;
+ try
+ {
+ conn = xacf.createXAConnection();
+
+ tm.begin();
+
+ XASession sess = conn.createXASession();
+ XAResource res = sess.getXAResource();
+
+ // prevent 1Pc optimisation
+ // res.setForceNotSameRM(true);
+
+ XAResource res2 = new DummyXAResource();
+
+ Transaction tx = tm.getTransaction();
+ tx.enlistResource(res);
+ tx.enlistResource(res2);
+
+ MessageProducer prod = sess.createProducer(null);
+ prod.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+ Message m = sess.createTextMessage("XATest1");
+ prod.send(queue1, m);
+ m = sess.createTextMessage("XATest2");
+ prod.send(queue1, m);
+
+ tx.delistResource(res, XAResource.TMSUCCESS);
+ tx.delistResource(res2, XAResource.TMSUCCESS);
+
+ tm.rollback();
+
+ conn2 = cf.createConnection();
+ conn2.start();
+ Session sessReceiver = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageConsumer cons = sessReceiver.createConsumer(queue1);
+ Message m2 = cons.receive(100);
+ Assert.assertNull(m2);
+
+ }
+ finally
+ {
+ if (conn != null)
+ {
+ conn.close();
+ }
+ if (conn2 != null)
+ {
+ conn2.close();
+ }
+ }
+ }
+
+ @Test
+ public void test2PCReceiveCommit1PCOptimization() throws Exception
+ {
+ // Since both resources have some RM, TM will probably use 1PC optimization
+
+ XAConnection conn = null;
+ Connection conn2 = null;
+
+ try
+ {
+ conn2 = cf.createConnection();
+ conn2.start();
+ Session sessProducer = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageProducer prod = sessProducer.createProducer(queue1);
+ Message m = sessProducer.createTextMessage("XATest1");
+ prod.send(m);
+ m = sessProducer.createTextMessage("XATest2");
+ prod.send(m);
+
+ conn = xacf.createXAConnection();
+ conn.start();
+
+ tm.begin();
+
+ XASession sess = conn.createXASession();
+ XAResource res = sess.getXAResource();
+
+ XAResource res2 = new DummyXAResource();
+
+ Transaction tx = tm.getTransaction();
+ tx.enlistResource(res);
+ tx.enlistResource(res2);
+
+ MessageConsumer cons = sess.createConsumer(queue1);
+
+ TextMessage m2 = (TextMessage)cons.receive(5000);
+
+ Assert.assertNotNull(m2);
+ Assert.assertEquals("XATest1", m2.getText());
+
+ m2 = (TextMessage)cons.receive(5000);
+
+ Assert.assertNotNull(m2);
+ Assert.assertEquals("XATest2", m2.getText());
+
+ tx.delistResource(res, XAResource.TMSUCCESS);
+ tx.delistResource(res2, XAResource.TMSUCCESS);
+
+ tm.commit();
+
+ // New tx
+ tm.begin();
+ tx = tm.getTransaction();
+ tx.enlistResource(res);
+ tx.enlistResource(res2);
+
+ Message m3 = cons.receive(100);
+
+ Assert.assertNull(m3);
+
+ tx.delistResource(res, XAResource.TMSUCCESS);
+ tx.delistResource(res2, XAResource.TMSUCCESS);
+
+ tm.commit();
+ }
+ finally
+ {
+ if (conn != null)
+ {
+ conn.close();
+ }
+ if (conn2 != null)
+ {
+ conn2.close();
+ }
+ }
+
+ }
+
+ @Test
+ public void test2PCReceiveCommit() throws Exception
+ {
+ XAConnection conn = null;
+ Connection conn2 = null;
+
+ try
+ {
+ conn2 = cf.createConnection();
+ conn2.start();
+ Session sessProducer = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageProducer prod = sessProducer.createProducer(queue1);
+ Message m = sessProducer.createTextMessage("XATest1");
+ prod.send(m);
+ m = sessProducer.createTextMessage("XATest2");
+ prod.send(m);
+
+ conn = xacf.createXAConnection();
+ conn.start();
+
+ tm.begin();
+
+ XASession sess = conn.createXASession();
+ XAResource res = sess.getXAResource();
+ // res.setForceNotSameRM(true);
+
+ XAResource res2 = new DummyXAResource();
+
+ Transaction tx = tm.getTransaction();
+ tx.enlistResource(res);
+ tx.enlistResource(res2);
+
+ MessageConsumer cons = sess.createConsumer(queue1);
+
+ TextMessage m2 = (TextMessage)cons.receive(5000);
+
+ Assert.assertNotNull(m2);
+ Assert.assertEquals("XATest1", m2.getText());
+
+ m2 = (TextMessage)cons.receive(5000);
+
+ Assert.assertNotNull(m2);
+ Assert.assertEquals("XATest2", m2.getText());
+
+ tx.delistResource(res, XAResource.TMSUCCESS);
+ tx.delistResource(res2, XAResource.TMSUCCESS);
+
+ tm.commit();
+
+ // New tx
+ tm.begin();
+ tx = tm.getTransaction();
+ tx.enlistResource(res);
+ tx.enlistResource(res2);
+
+ Message m3 = cons.receive(100);
+
+ Assert.assertNull(m3);
+
+ tx.delistResource(res, XAResource.TMSUCCESS);
+ tx.delistResource(res2, XAResource.TMSUCCESS);
+
+ tm.commit();
+ }
+ finally
+ {
+ if (conn != null)
+ {
+ conn.close();
+ }
+ if (conn2 != null)
+ {
+ conn2.close();
+ }
+ }
+
+ }
+
+ @Test
+ public void test2PCReceiveRollback1PCOptimization() throws Exception
+ {
+ // Since both resources have some RM, TM will probably use 1PC optimization
+
+ XAConnection conn = null;
+ Connection conn2 = null;
+
+ try
+ {
+ conn2 = cf.createConnection();
+ Session sessProducer = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageProducer prod = sessProducer.createProducer(queue1);
+ Message m = sessProducer.createTextMessage("XATest1");
+ prod.send(m);
+
+ m = sessProducer.createTextMessage("XATest2");
+ prod.send(m);
+
+ conn = xacf.createXAConnection();
+ conn.start();
+
+ tm.begin();
+
+ XASession sess = conn.createXASession();
+ XAResource res = sess.getXAResource();
+
+ XAResource res2 = new DummyXAResource();
+
+ Transaction tx = tm.getTransaction();
+ tx.enlistResource(res);
+ tx.enlistResource(res2);
+
+ MessageConsumer cons = sess.createConsumer(queue1);
+
+ TextMessage m2 = (TextMessage)cons.receive(5000);
+ Assert.assertNotNull(m2);
+ Assert.assertEquals("XATest1", m2.getText());
+ m2 = (TextMessage)cons.receive(5000);
+ Assert.assertNotNull(m2);
+ Assert.assertEquals("XATest2", m2.getText());
+
+ tx.delistResource(res, XAResource.TMSUCCESS);
+ tx.delistResource(res2, XAResource.TMSUCCESS);
+
+ tm.rollback();
+
+ // Message should be redelivered
+
+ // New tx
+ tm.begin();
+ tx = tm.getTransaction();
+ tx.enlistResource(res);
+ tx.enlistResource(res2);
+
+ TextMessage m3 = (TextMessage)cons.receive(5000);
+ Assert.assertNotNull(m3);
+ Assert.assertEquals("XATest1", m3.getText());
+ m3 = (TextMessage)cons.receive(5000);
+ Assert.assertNotNull(m3);
+ Assert.assertEquals("XATest2", m3.getText());
+
+ Assert.assertTrue(m3.getJMSRedelivered());
+
+ tx.delistResource(res, XAResource.TMSUCCESS);
+ tx.delistResource(res2, XAResource.TMSUCCESS);
+
+ tm.commit();
+ }
+ finally
+ {
+ if (conn != null)
+ {
+ conn.close();
+ }
+ if (conn2 != null)
+ {
+ conn2.close();
+ }
+ }
+ }
+
+ @Test
+ public void test2PCReceiveRollback() throws Exception
+ {
+ XAConnection conn = null;
+ Connection conn2 = null;
+
+ try
+ {
+ conn2 = cf.createConnection();
+ Session sessProducer = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageProducer prod = sessProducer.createProducer(queue1);
+ Message m = sessProducer.createTextMessage("XATest1");
+ prod.send(m);
+
+ m = sessProducer.createTextMessage("XATest2");
+ prod.send(m);
+
+ conn = xacf.createXAConnection();
+ conn.start();
+
+ tm.begin();
+
+ XASession sess = conn.createXASession();
+ XAResource res = sess.getXAResource();
+ // res.setForceNotSameRM(true);
+
+ XAResource res2 = new DummyXAResource();
+
+ Transaction tx = tm.getTransaction();
+ tx.enlistResource(res);
+ tx.enlistResource(res2);
+
+ MessageConsumer cons = sess.createConsumer(queue1);
+
+ TextMessage m2 = (TextMessage)cons.receive(5000);
+ Assert.assertNotNull(m2);
+ Assert.assertEquals("XATest1", m2.getText());
+ m2 = (TextMessage)cons.receive(5000);
+ Assert.assertNotNull(m2);
+ Assert.assertEquals("XATest2", m2.getText());
+
+ tx.delistResource(res, XAResource.TMSUCCESS);
+ tx.delistResource(res2, XAResource.TMSUCCESS);
+
+ tm.rollback();
+
+ // Message should be redelivered
+
+ // New tx
+ tm.begin();
+ tx = tm.getTransaction();
+ tx.enlistResource(res);
+ tx.enlistResource(res2);
+
+ TextMessage m3 = (TextMessage)cons.receive(5000);
+ Assert.assertNotNull(m3);
+ Assert.assertEquals("XATest1", m3.getText());
+ m3 = (TextMessage)cons.receive(5000);
+ Assert.assertNotNull(m3);
+ Assert.assertEquals("XATest2", m3.getText());
+
+ Assert.assertTrue(m3.getJMSRedelivered());
+
+ tx.delistResource(res, XAResource.TMSUCCESS);
+ tx.delistResource(res2, XAResource.TMSUCCESS);
+
+ tm.commit();
+
+ }
+ finally
+ {
+ if (conn != null)
+ {
+ conn.close();
+ }
+ if (conn2 != null)
+ {
+ conn2.close();
+ }
+ }
+
+ }
+
+ @Test
+ public void test1PCSendCommit() throws Exception
+ {
+ XAConnection conn = null;
+ Connection conn2 = null;
+
+ try
+ {
+ conn = xacf.createXAConnection();
+
+ tm.begin();
+
+ XASession sess = conn.createXASession();
+ XAResource res = sess.getXAResource();
+
+ Transaction tx = tm.getTransaction();
+ tx.enlistResource(res);
+
+ MessageProducer prod = sess.createProducer(null);
+ prod.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+ Message m = sess.createTextMessage("XATest1");
+ prod.send(queue1, m);
+ m = sess.createTextMessage("XATest2");
+ prod.send(queue1, m);
+
+ tx.delistResource(res, XAResource.TMSUCCESS);
+
+ tm.commit();
+
+ conn2 = cf.createConnection();
+ conn2.start();
+ Session sessReceiver = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageConsumer cons = sessReceiver.createConsumer(queue1);
+ TextMessage m2 = (TextMessage)cons.receive(5000);
+ Assert.assertNotNull(m2);
+ Assert.assertEquals("XATest1", m2.getText());
+ m2 = (TextMessage)cons.receive(5000);
+ Assert.assertNotNull(m2);
+ Assert.assertEquals("XATest2", m2.getText());
+ }
+ finally
+ {
+ if (conn != null)
+ {
+ conn.close();
+ }
+ if (conn2 != null)
+ {
+ conn2.close();
+ }
+ }
+
+ }
+
+ @Test
+ public void test1PCReceiveCommit() throws Exception
+ {
+ XAConnection conn = null;
+ Connection conn2 = null;
+
+ try
+ {
+ conn2 = cf.createConnection();
+ conn2.start();
+ Session sessProducer = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageProducer prod = sessProducer.createProducer(queue1);
+ Message m = sessProducer.createTextMessage("XATest1");
+ prod.send(m);
+ m = sessProducer.createTextMessage("XATest2");
+ prod.send(m);
+
+ conn = xacf.createXAConnection();
+ conn.start();
+
+ tm.begin();
+
+ XASession sess = conn.createXASession();
+ XAResource res = sess.getXAResource();
+
+ Transaction tx = tm.getTransaction();
+ tx.enlistResource(res);
+
+ MessageConsumer cons = sess.createConsumer(queue1);
+
+ TextMessage m2 = (TextMessage)cons.receive(5000);
+
+ Assert.assertNotNull(m2);
+ Assert.assertEquals("XATest1", m2.getText());
+ m2 = (TextMessage)cons.receive(5000);
+
+ Assert.assertNotNull(m2);
+ Assert.assertEquals("XATest2", m2.getText());
+
+ tx.delistResource(res, XAResource.TMSUCCESS);
+
+ tm.commit();
+
+ // New tx
+ tm.begin();
+ tx = tm.getTransaction();
+ tx.enlistResource(res);
+
+ Message m3 = cons.receive(100);
+
+ Assert.assertNull(m3);
+
+ tx.delistResource(res, XAResource.TMSUCCESS);
+
+ tm.commit();
+ }
+ finally
+ {
+ if (conn != null)
+ {
+ conn.close();
+ }
+ if (conn2 != null)
+ {
+ conn2.close();
+ }
+ }
+
+ }
+
+ @Test
+ public void test1PCReceiveRollback() throws Exception
+ {
+ XAConnection conn = null;
+ Connection conn2 = null;
+
+ try
+ {
+ conn2 = cf.createConnection();
+ Session sessProducer = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageProducer prod = sessProducer.createProducer(queue1);
+ Message m = sessProducer.createTextMessage("XATest1");
+ prod.send(m);
+ m = sessProducer.createTextMessage("XATest2");
+ prod.send(m);
+
+ conn = xacf.createXAConnection();
+ conn.start();
+
+ tm.begin();
+
+ XASession sess = conn.createXASession();
+ XAResource res = sess.getXAResource();
+
+ Transaction tx = tm.getTransaction();
+ tx.enlistResource(res);
+
+ MessageConsumer cons = sess.createConsumer(queue1);
+
+ TextMessage m2 = (TextMessage)cons.receive(5000);
+
+ Assert.assertNotNull(m2);
+ Assert.assertEquals("XATest1", m2.getText());
+
+ m2 = (TextMessage)cons.receive(5000);
+
+ Assert.assertNotNull(m2);
+ Assert.assertEquals("XATest2", m2.getText());
+
+ tx.delistResource(res, XAResource.TMSUCCESS);
+
+ tm.rollback();
+
+ // Message should be redelivered
+
+ // New tx
+ tm.begin();
+ tx = tm.getTransaction();
+ tx.enlistResource(res);
+
+ TextMessage m3 = (TextMessage)cons.receive(5000);
+
+ Assert.assertNotNull(m3);
+ Assert.assertEquals("XATest1", m3.getText());
+
+ m3 = (TextMessage)cons.receive(5000);
+
+ Assert.assertNotNull(m3);
+ Assert.assertEquals("XATest2", m3.getText());
+
+ Assert.assertTrue(m3.getJMSRedelivered());
+
+ tx.delistResource(res, XAResource.TMSUCCESS);
+
+ tm.commit();
+
+ }
+ finally
+ {
+ if (conn != null)
+ {
+ conn.close();
+ }
+ if (conn2 != null)
+ {
+ conn2.close();
+ }
+ }
+
+ }
+
+ @Test
+ public void testMultipleSessionsOneTxCommitAcknowledge1PCOptimization() throws Exception
+ {
+ XAConnection conn = null;
+ Connection conn2 = null;
+
+ // Since both resources have some RM, TM will probably use 1PC optimization
+
+ try
+ {
+ // First send 2 messages
+ conn2 = cf.createConnection();
+ Session sessProducer = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageProducer prod = sessProducer.createProducer(queue1);
+ Message m = sessProducer.createTextMessage("jellyfish1");
+ prod.send(m);
+ m = sessProducer.createTextMessage("jellyfish2");
+ prod.send(m);
+
+ conn = xacf.createXAConnection();
+ conn.start();
+
+ tm.begin();
+
+ // Create 2 sessions and enlist them
+ XASession sess1 = conn.createXASession();
+ XAResource res1 = sess1.getXAResource();
+ XASession sess2 = conn.createXASession();
+ XAResource res2 = sess2.getXAResource();
+
+ Transaction tx = tm.getTransaction();
+ tx.enlistResource(res1);
+ tx.enlistResource(res2);
+
+ // Receive the messages, one on each consumer
+ MessageConsumer cons1 = sess1.createConsumer(queue1);
+ TextMessage r1 = (TextMessage)cons1.receive(5000);
+
+ Assert.assertNotNull(r1);
+ Assert.assertEquals("jellyfish1", r1.getText());
+
+ cons1.close();
+
+ MessageConsumer cons2 = sess2.createConsumer(queue1);
+ TextMessage r2 = (TextMessage)cons2.receive(5000);
+
+ Assert.assertNotNull(r2);
+ Assert.assertEquals("jellyfish2", r2.getText());
+
+ tx.delistResource(res1, XAResource.TMSUCCESS);
+ tx.delistResource(res2, XAResource.TMSUCCESS);
+
+ // commit
+ tm.commit();
+
+ Session sess = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageConsumer cons = sess.createConsumer(queue1);
+ conn2.start();
+
+ TextMessage r3 = (TextMessage)cons.receive(100);
+ Assert.assertNull(r3);
+
+ }
+ finally
+ {
+ if (conn != null)
+ {
+ conn.close();
+ }
+ if (conn2 != null)
+ {
+ conn2.close();
+ }
+ }
+
+ }
+
+ @Test
+ public void testMultipleSessionsOneTxCommitAcknowledge() throws Exception
+ {
+ XAConnection conn = null;
+ Connection conn2 = null;
+
+ try
+ {
+ // First send 2 messages
+ conn2 = cf.createConnection();
+ Session sessProducer = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageProducer prod = sessProducer.createProducer(queue1);
+ Message m = sessProducer.createTextMessage("jellyfish1");
+ prod.send(m);
+ m = sessProducer.createTextMessage("jellyfish2");
+ prod.send(m);
+
+ conn = xacf.createXAConnection();
+ conn.start();
+
+ tm.begin();
+
+ // Create 2 sessions and enlist them
+ XASession sess1 = conn.createXASession();
+ ClientSessionInternal res1 = (ClientSessionInternal)sess1.getXAResource();
+ XASession sess2 = conn.createXASession();
+ ClientSessionInternal res2 = (ClientSessionInternal)sess2.getXAResource();
+ res1.setForceNotSameRM(true);
+ res2.setForceNotSameRM(true);
+
+ Transaction tx = tm.getTransaction();
+ tx.enlistResource(res1);
+ tx.enlistResource(res2);
+
+ // Receive the messages, one on each consumer
+ MessageConsumer cons1 = sess1.createConsumer(queue1);
+ TextMessage r1 = (TextMessage)cons1.receive(5000);
+
+ Assert.assertNotNull(r1);
+ Assert.assertEquals("jellyfish1", r1.getText());
+
+ cons1.close();
+
+ MessageConsumer cons2 = sess2.createConsumer(queue1);
+ TextMessage r2 = (TextMessage)cons2.receive(5000);
+
+ Assert.assertNotNull(r2);
+ Assert.assertEquals("jellyfish2", r2.getText());
+
+ tx.delistResource(res1, XAResource.TMSUCCESS);
+ tx.delistResource(res2, XAResource.TMSUCCESS);
+
+ // commit
+ tm.commit();
+
+ Session sess = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageConsumer cons = sess.createConsumer(queue1);
+ conn2.start();
+
+ TextMessage r3 = (TextMessage)cons.receive(100);
+ Assert.assertNull(r3);
+
+ }
+ finally
+ {
+ if (conn != null)
+ {
+ conn.close();
+ }
+ if (conn2 != null)
+ {
+ conn2.close();
+ }
+ }
+
+ }
+
+ @Test
+ public void testMultipleSessionsOneTxRollbackAcknowledge1PCOptimization() throws Exception
+ {
+ XAConnection conn = null;
+ Connection conn2 = null;
+
+ // Since both resources have some RM, TM will probably use 1PC optimization
+
+ try
+ {
+ // First send 2 messages
+ conn2 = cf.createConnection();
+ Session sessProducer = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageProducer prod = sessProducer.createProducer(queue1);
+ Message m = sessProducer.createTextMessage("jellyfish1");
+ prod.send(m);
+ m = sessProducer.createTextMessage("jellyfish2");
+ prod.send(m);
+ m = sessProducer.createTextMessage("jellyfish3");
+ prod.send(m);
+ m = sessProducer.createTextMessage("jellyfish4");
+ prod.send(m);
+
+ conn = xacf.createXAConnection();
+ conn.start();
+
+ tm.begin();
+
+ // Create 2 sessions and enlist them
+ XASession sess1 = conn.createXASession();
+ ClientSessionInternal res1 = (ClientSessionInternal)sess1.getXAResource();
+ XASession sess2 = conn.createXASession();
+ ClientSessionInternal res2 = (ClientSessionInternal)sess2.getXAResource();
+
+ Transaction tx = tm.getTransaction();
+ tx.enlistResource(res1);
+ tx.enlistResource(res2);
+
+ // Receive the messages, two on each consumer
+ MessageConsumer cons1 = sess1.createConsumer(queue1);
+ TextMessage r1 = (TextMessage)cons1.receive(5000);
+
+ Assert.assertNotNull(r1);
+ Assert.assertEquals("jellyfish1", r1.getText());
+
+ r1 = (TextMessage)cons1.receive(5000);
+
+ Assert.assertNotNull(r1);
+ Assert.assertEquals("jellyfish2", r1.getText());
+
+ cons1.close();
+
+ MessageConsumer cons2 = sess2.createConsumer(queue1);
+ TextMessage r2 = (TextMessage)cons2.receive(5000);
+
+ Assert.assertNotNull(r2);
+ Assert.assertEquals("jellyfish3", r2.getText());
+
+ r2 = (TextMessage)cons2.receive(5000);
+
+ Assert.assertNotNull(r2);
+ Assert.assertEquals("jellyfish4", r2.getText());
+
+ cons2.close();
+
+ // rollback
+
+ tx.delistResource(res1, XAResource.TMSUCCESS);
+ tx.delistResource(res2, XAResource.TMSUCCESS);
+
+ tm.rollback();
+
+ // Rollback causes cancel which is asynch
+ Thread.sleep(1000);
+
+ // We cannot assume anything about the order in which the transaction manager rollsback
+ // the sessions - this is implementation dependent
+
+ Session sess = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageConsumer cons = sess.createConsumer(queue1);
+ conn2.start();
+
+ TextMessage r = (TextMessage)cons.receive(5000);
+ Assert.assertNotNull(r);
+
+ boolean session1First = false;
+
+ if (r.getText().equals("jellyfish1"))
+ {
+ session1First = true;
+ }
+ else if (r.getText().equals("jellyfish3"))
+ {
+ session1First = false;
+ }
+ else
+ {
+ Assert.fail("Unexpected message");
+ }
+
+ if (session1First)
+ {
+ r = (TextMessage)cons.receive(5000);
+
+ Assert.assertNotNull(r);
+
+ Assert.assertEquals("jellyfish2", r.getText());
+
+ r = (TextMessage)cons.receive(5000);
+
+ Assert.assertNotNull(r);
+
+ Assert.assertEquals("jellyfish3", r.getText());
+
+ r = (TextMessage)cons.receive(5000);
+
+ Assert.assertNotNull(r);
+
+ Assert.assertEquals("jellyfish4", r.getText());
+
+ }
+ else
+ {
+ r = (TextMessage)cons.receive(5000);
+
+ Assert.assertNotNull(r);
+
+ Assert.assertEquals("jellyfish4", r.getText());
+
+ r = (TextMessage)cons.receive(5000);
+
+ Assert.assertNotNull(r);
+
+ Assert.assertEquals("jellyfish1", r.getText());
+
+ r = (TextMessage)cons.receive(5000);
+
+ Assert.assertNotNull(r);
+
+ Assert.assertEquals("jellyfish2", r.getText());
+ }
+
+ r = (TextMessage)cons.receive(100);
+
+ Assert.assertNull(r);
+
+ }
+ finally
+ {
+ if (conn != null)
+ {
+ conn.close();
+ }
+ if (conn2 != null)
+ {
+ conn2.close();
+ }
+ }
+
+ }
+
+ @Test
+ public void testMultipleSessionsOneTxRollbackAcknowledge() throws Exception
+ {
+ XAConnection conn = null;
+ Connection conn2 = null;
+
+ try
+ {
+ // First send 2 messages
+ conn2 = cf.createConnection();
+ Session sessProducer = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageProducer prod = sessProducer.createProducer(queue1);
+ Message m = sessProducer.createTextMessage("jellyfish1");
+ prod.send(m);
+ m = sessProducer.createTextMessage("jellyfish2");
+ prod.send(m);
+ m = sessProducer.createTextMessage("jellyfish3");
+ prod.send(m);
+ m = sessProducer.createTextMessage("jellyfish4");
+ prod.send(m);
+
+ conn = xacf.createXAConnection();
+ conn.start();
+
+ tm.begin();
+
+ // Create 2 sessions and enlist them
+ XASession sess1 = conn.createXASession();
+ ClientSessionInternal res1 = (ClientSessionInternal)sess1.getXAResource();
+ XASession sess2 = conn.createXASession();
+ ClientSessionInternal res2 = (ClientSessionInternal)sess2.getXAResource();
+ res1.setForceNotSameRM(true);
+ res2.setForceNotSameRM(true);
+
+ Transaction tx = tm.getTransaction();
+ tx.enlistResource(res1);
+ tx.enlistResource(res2);
+
+ // Receive the messages, two on each consumer
+ MessageConsumer cons1 = sess1.createConsumer(queue1);
+ TextMessage r1 = (TextMessage)cons1.receive(5000);
+
+ Assert.assertNotNull(r1);
+ Assert.assertEquals("jellyfish1", r1.getText());
+
+ r1 = (TextMessage)cons1.receive(5000);
+
+ Assert.assertNotNull(r1);
+ Assert.assertEquals("jellyfish2", r1.getText());
+
+ cons1.close();
+
+ // Cancel is asynch
+ Thread.sleep(500);
+
+ MessageConsumer cons2 = sess2.createConsumer(queue1);
+ TextMessage r2 = (TextMessage)cons2.receive(5000);
+
+ Assert.assertNotNull(r2);
+ Assert.assertEquals("jellyfish3", r2.getText());
+
+ r2 = (TextMessage)cons2.receive(5000);
+
+ Assert.assertNotNull(r2);
+ Assert.assertEquals("jellyfish4", r2.getText());
+
+ // rollback
+
+ cons2.close();
+
+ tx.delistResource(res1, XAResource.TMSUCCESS);
+ tx.delistResource(res2, XAResource.TMSUCCESS);
+
+ tm.rollback();
+
+ // Rollback causes cancel which is asynch
+ Thread.sleep(1000);
+
+ // We cannot assume anything about the order in which the transaction manager rollsback
+ // the sessions - this is implementation dependent
+
+ Session sess = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageConsumer cons = sess.createConsumer(queue1);
+ conn2.start();
+
+ TextMessage r = (TextMessage)cons.receive(5000);
+ Assert.assertNotNull(r);
+
+ boolean session1First = false;
+
+ if (r.getText().equals("jellyfish1"))
+ {
+ session1First = true;
+ }
+ else if (r.getText().equals("jellyfish3"))
+ {
+ session1First = false;
+ }
+ else
+ {
+ Assert.fail("Unexpected message");
+ }
+
+ if (session1First)
+ {
+ r = (TextMessage)cons.receive(5000);
+
+ Assert.assertNotNull(r);
+
+ Assert.assertEquals("jellyfish2", r.getText());
+
+ r = (TextMessage)cons.receive(5000);
+
+ Assert.assertNotNull(r);
+
+ Assert.assertEquals("jellyfish3", r.getText());
+
+ r = (TextMessage)cons.receive(5000);
+
+ Assert.assertNotNull(r);
+
+ Assert.assertEquals("jellyfish4", r.getText());
+
+ }
+ else
+ {
+ r = (TextMessage)cons.receive(5000);
+
+ Assert.assertNotNull(r);
+
+ Assert.assertEquals("jellyfish4", r.getText());
+
+ r = (TextMessage)cons.receive(5000);
+
+ Assert.assertNotNull(r);
+
+ Assert.assertEquals("jellyfish1", r.getText());
+
+ r = (TextMessage)cons.receive(5000);
+
+ Assert.assertNotNull(r);
+
+ Assert.assertEquals("jellyfish2", r.getText());
+ }
+
+ r = (TextMessage)cons.receive(100);
+
+ Assert.assertNull(r);
+ }
+ finally
+ {
+ if (conn != null)
+ {
+ conn.close();
+ }
+ if (conn2 != null)
+ {
+ conn2.close();
+ }
+ }
+ }
+
+ @Test
+ public void testMultipleSessionsOneTxRollbackAcknowledgeForceFailureInCommit() throws Exception
+ {
+ XAConnection conn = null;
+ Connection conn2 = null;
+
+ try
+ {
+ // First send 4 messages
+ conn2 = cf.createConnection();
+ Session sessProducer = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageProducer prod = sessProducer.createProducer(queue1);
+
+ Message m = sessProducer.createTextMessage("jellyfish1");
+ prod.send(m);
+ m = sessProducer.createTextMessage("jellyfish2");
+ prod.send(m);
+ m = sessProducer.createTextMessage("jellyfish3");
+ prod.send(m);
+ m = sessProducer.createTextMessage("jellyfish4");
+ prod.send(m);
+
+ conn = xacf.createXAConnection();
+ conn.start();
+
+ tm.begin();
+
+ XASession sess1 = conn.createXASession();
+ XAResource res1 = sess1.getXAResource();
+ DummyXAResource res2 = new DummyXAResource(true);
+
+ Transaction tx = tm.getTransaction();
+ tx.enlistResource(res1);
+ tx.enlistResource(res2);
+
+ MessageConsumer cons1 = sess1.createConsumer(queue1);
+ TextMessage r1 = (TextMessage)cons1.receive(5000);
+
+ Assert.assertNotNull(r1);
+ Assert.assertEquals("jellyfish1", r1.getText());
+
+ r1 = (TextMessage)cons1.receive(5000);
+
+ Assert.assertNotNull(r1);
+ Assert.assertEquals("jellyfish2", r1.getText());
+
+ r1 = (TextMessage)cons1.receive(5000);
+
+ Assert.assertNotNull(r1);
+ Assert.assertEquals("jellyfish3", r1.getText());
+
+ r1 = (TextMessage)cons1.receive(5000);
+
+ Assert.assertNotNull(r1);
+ Assert.assertEquals("jellyfish4", r1.getText());
+
+ r1 = (TextMessage)cons1.receive(100);
+
+ Assert.assertNull(r1);
+
+ cons1.close();
+
+ // try and commit - and we're going to make the dummyxaresource throw an exception on commit,
+ // which should cause rollback to be called on the other resource
+
+ tx.delistResource(res1, XAResource.TMSUCCESS);
+ tx.delistResource(res2, XAResource.TMSUCCESS);
+
+ // rollback will cause an attempt to deliver messages locally to the original consumers.
+ // the original consumer has closed, so it will cancelled to the server
+ // the server cancel is asynch, so we need to sleep for a bit to make sure it completes
+ ExtrasTestLogger.LOGGER.trace("Forcing failure");
+ try
+ {
+ tm.commit();
+ Assert.fail("should not get here");
+ }
+ catch (Exception e)
+ {
+ // We should expect this
+ }
+
+ Thread.sleep(1000);
+
+ Session sess = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageConsumer cons = sess.createConsumer(queue1);
+ conn2.start();
+
+ TextMessage r = (TextMessage)cons.receive(5000);
+
+ Assert.assertNotNull(r);
+
+ Assert.assertEquals("jellyfish1", r.getText());
+
+ r = (TextMessage)cons.receive(5000);
+
+ Assert.assertNotNull(r);
+
+ Assert.assertEquals("jellyfish2", r.getText());
+
+ r = (TextMessage)cons.receive(5000);
+
+ Assert.assertNotNull(r);
+
+ Assert.assertEquals("jellyfish3", r.getText());
+
+ r = (TextMessage)cons.receive(5000);
+
+ Assert.assertNotNull(r);
+
+ Assert.assertEquals("jellyfish4", r.getText());
+
+ r = (TextMessage)cons.receive(100);
+
+ Assert.assertNull(r);
+ }
+ finally
+ {
+ if (conn != null)
+ {
+ conn.close();
+ }
+ if (conn2 != null)
+ {
+ conn2.close();
+ }
+ }
+
+ }
+
+ @Test
+ public void testMultipleSessionsOneTxCommitSend1PCOptimization() throws Exception
+ {
+ // Since both resources have some RM, TM will probably use 1PC optimization
+
+ XAConnection conn = null;
+
+ Connection conn2 = null;
+
+ try
+ {
+ conn = xacf.createXAConnection();
+ conn.start();
+
+ tm.begin();
+
+ // Create 2 sessions and enlist them
+ XASession sess1 = conn.createXASession();
+ XAResource res1 = sess1.getXAResource();
+ XASession sess2 = conn.createXASession();
+ XAResource res2 = sess2.getXAResource();
+
+ Transaction tx = tm.getTransaction();
+ tx.enlistResource(res1);
+ tx.enlistResource(res2);
+
+ // Send 2 messages - one from each session
+
+ MessageProducer prod1 = sess1.createProducer(queue1);
+ MessageProducer prod2 = sess2.createProducer(queue1);
+
+ prod1.send(sess1.createTextMessage("echidna1"));
+ prod2.send(sess2.createTextMessage("echidna2"));
+
+ tx.delistResource(res1, XAResource.TMSUCCESS);
+ tx.delistResource(res2, XAResource.TMSUCCESS);
+
+ // commit
+ tm.commit();
+
+ // Messages should be in queue
+
+ conn2 = cf.createConnection();
+ Session sess = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageConsumer cons = sess.createConsumer(queue1);
+ conn2.start();
+
+ TextMessage r1 = (TextMessage)cons.receive(5000);
+ Assert.assertNotNull(r1);
+ Assert.assertEquals("echidna1", r1.getText());
+
+ TextMessage r2 = (TextMessage)cons.receive(5000);
+ Assert.assertNotNull(r2);
+ Assert.assertEquals("echidna2", r2.getText());
+
+ }
+ finally
+ {
+ if (conn != null)
+ {
+ conn.close();
+ }
+ if (conn2 != null)
+ {
+ conn2.close();
+ }
+ }
+ }
+
+ @Test
+ public void testMultipleSessionsOneTxCommitSend() throws Exception
+ {
+ // Since both resources have some RM, TM will probably use 1PC optimization
+
+ XAConnection conn = null;
+
+ Connection conn2 = null;
+
+ try
+ {
+
+ conn = xacf.createXAConnection();
+ conn.start();
+
+ tm.begin();
+
+ // Create 2 sessions and enlist them
+ XASession sess1 = conn.createXASession();
+ ClientSessionInternal res1 = (ClientSessionInternal)sess1.getXAResource();
+ XASession sess2 = conn.createXASession();
+ ClientSessionInternal res2 = (ClientSessionInternal)sess2.getXAResource();
+ res1.setForceNotSameRM(true);
+ res2.setForceNotSameRM(true);
+
+ Transaction tx = tm.getTransaction();
+ tx.enlistResource(res1);
+ tx.enlistResource(res2);
+
+ // Send 2 messages - one from each session
+
+ MessageProducer prod1 = sess1.createProducer(queue1);
+ MessageProducer prod2 = sess2.createProducer(queue1);
+
+ prod1.send(sess1.createTextMessage("echidna1"));
+ prod2.send(sess2.createTextMessage("echidna2"));
+
+ tx.delistResource(res1, XAResource.TMSUCCESS);
+ tx.delistResource(res2, XAResource.TMSUCCESS);
+
+ // commit
+ tm.commit();
+
+ // Messages should be in queue
+
+ conn2 = cf.createConnection();
+ Session sess = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageConsumer cons = sess.createConsumer(queue1);
+ conn2.start();
+
+ TextMessage r1 = (TextMessage)cons.receive(5000);
+ Assert.assertNotNull(r1);
+ Assert.assertEquals("echidna1", r1.getText());
+
+ TextMessage r2 = (TextMessage)cons.receive(5000);
+ Assert.assertNotNull(r2);
+ Assert.assertEquals("echidna2", r2.getText());
+
+ }
+ finally
+ {
+ if (conn != null)
+ {
+ conn.close();
+ }
+ if (conn2 != null)
+ {
+ conn2.close();
+ }
+
+ }
+
+ }
+
+ @Test
+ public void testMultipleSessionsOneTxRollbackSend1PCOptimization() throws Exception
+ {
+ // Since both resources have some RM, TM will probably use 1PC optimization
+
+ XAConnection conn = null;
+
+ Connection conn2 = null;
+
+ try
+ {
+ conn = xacf.createXAConnection();
+ conn.start();
+
+ tm.begin();
+
+ // Create 2 sessions and enlist them
+ XASession sess1 = conn.createXASession();
+ XAResource res1 = sess1.getXAResource();
+ XASession sess2 = conn.createXASession();
+ XAResource res2 = sess2.getXAResource();
+
+ Transaction tx = tm.getTransaction();
+ tx.enlistResource(res1);
+ tx.enlistResource(res2);
+
+ // Send 2 messages - one from each session
+
+ MessageProducer prod1 = sess1.createProducer(queue1);
+ MessageProducer prod2 = sess2.createProducer(queue1);
+
+ prod1.send(sess1.createTextMessage("echidna1"));
+ prod2.send(sess2.createTextMessage("echidna2"));
+
+ tx.delistResource(res1, XAResource.TMSUCCESS);
+ tx.delistResource(res2, XAResource.TMSUCCESS);
+
+ // rollback
+ tm.rollback();
+
+ // Messages should not be in queue
+
+ conn2 = cf.createConnection();
+ Session sess = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageConsumer cons = sess.createConsumer(queue1);
+ conn2.start();
+
+ TextMessage r1 = (TextMessage)cons.receive(100);
+ Assert.assertNull(r1);
+
+ }
+ finally
+ {
+ if (conn != null)
+ {
+ conn.close();
+ }
+ if (conn2 != null)
+ {
+ conn2.close();
+ }
+ }
+ }
+
+ @Test
+ public void testMultipleSessionsOneTxRollbackSend() throws Exception
+ {
+ XAConnection conn = null;
+
+ Connection conn2 = null;
+
+ try
+ {
+
+ conn = xacf.createXAConnection();
+ conn.start();
+
+ tm.begin();
+
+ // Create 2 sessions and enlist them
+ XASession sess1 = conn.createXASession();
+ ClientSessionInternal res1 = (ClientSessionInternal)sess1.getXAResource();
+ XASession sess2 = conn.createXASession();
+ ClientSessionInternal res2 = (ClientSessionInternal)sess2.getXAResource();
+ res1.setForceNotSameRM(true);
+ res2.setForceNotSameRM(true);
+
+ Transaction tx = tm.getTransaction();
+ tx.enlistResource(res1);
+ tx.enlistResource(res2);
+
+ // Send 2 messages - one from each session
+
+ MessageProducer prod1 = sess1.createProducer(queue1);
+ MessageProducer prod2 = sess2.createProducer(queue1);
+
+ prod1.send(sess1.createTextMessage("echidna1"));
+ prod2.send(sess2.createTextMessage("echidna2"));
+
+ tx.delistResource(res1, XAResource.TMSUCCESS);
+ tx.delistResource(res2, XAResource.TMSUCCESS);
+
+ // rollback
+ tm.rollback();
+
+ // Messages should not be in queue
+
+ conn2 = cf.createConnection();
+ Session sess = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageConsumer cons = sess.createConsumer(queue1);
+ conn2.start();
+
+ TextMessage r1 = (TextMessage)cons.receive(100);
+ Assert.assertNull(r1);
+ }
+ finally
+ {
+ if (conn != null)
+ {
+ conn.close();
+ }
+ if (conn2 != null)
+ {
+ conn2.close();
+ }
+ }
+ }
+
+ @Test
+ public void testOneSessionTwoTransactionsCommitAcknowledge() throws Exception
+ {
+ XAConnection conn = null;
+
+ Connection conn2 = null;
+
+ try
+ {
+ // First send 2 messages
+ conn2 = cf.createConnection();
+ Session sessProducer = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageProducer prod = sessProducer.createProducer(queue1);
+ Message m = sessProducer.createTextMessage("jellyfish1");
+ prod.send(m);
+ m = sessProducer.createTextMessage("jellyfish2");
+ prod.send(m);
+
+ conn = xacf.createXAConnection();
+
+ // Create a session
+ XASession sess1 = conn.createXASession();
+ XAResource res1 = sess1.getXAResource();
+
+ conn.start();
+ MessageConsumer cons1 = sess1.createConsumer(queue1);
+
+ tm.begin();
+
+ Transaction tx1 = tm.getTransaction();
+ tx1.enlistResource(res1);
+
+ // Receive one message in one tx
+
+ TextMessage r1 = (TextMessage)cons1.receive(5000);
+ Assert.assertNotNull(r1);
+ Assert.assertEquals("jellyfish1", r1.getText());
+
+ tx1.delistResource(res1, XAResource.TMSUCCESS);
+
+ // suspend the tx
+ Transaction suspended = tm.suspend();
+
+ tm.begin();
+
+ Transaction tx2 = tm.getTransaction();
+ tx2.enlistResource(res1);
+
+ // Receive 2nd message in a different tx
+ TextMessage r2 = (TextMessage)cons1.receive(5000);
+ Assert.assertNotNull(r2);
+ Assert.assertEquals("jellyfish2", r2.getText());
+
+ tx2.delistResource(res1, XAResource.TMSUCCESS);
+
+ // commit this transaction
+ tm.commit();
+
+ // verify that no messages are available
+ conn2.close();
+ conn2 = cf.createConnection();
+ Session sess = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ conn2.start();
+ MessageConsumer cons = sess.createConsumer(queue1);
+ TextMessage r3 = (TextMessage)cons.receive(100);
+ Assert.assertNull(r3);
+
+ // now resume the first tx and then commit it
+ tm.resume(suspended);
+
+ tm.commit();
+ }
+ finally
+ {
+ if (conn != null)
+ {
+ conn.close();
+ }
+ if (conn2 != null)
+ {
+ conn2.close();
+ }
+ }
+ }
+
+ @Test
+ public void testOneSessionTwoTransactionsRollbackAcknowledge() throws Exception
+ {
+ XAConnection conn = null;
+
+ Connection conn2 = null;
+
+ try
+ {
+ // First send 2 messages
+ conn2 = cf.createConnection();
+ Session sessProducer = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageProducer prod = sessProducer.createProducer(queue1);
+ Message m = sessProducer.createTextMessage("jellyfish1");
+ prod.send(m);
+ m = sessProducer.createTextMessage("jellyfish2");
+ prod.send(m);
+
+ conn = xacf.createXAConnection();
+
+ // Create a session
+ XASession sess1 = conn.createXASession();
+ XAResource res1 = sess1.getXAResource();
+
+ conn.start();
+ MessageConsumer cons1 = sess1.createConsumer(queue1);
+
+ tm.begin();
+
+ Transaction tx1 = tm.getTransaction();
+ tx1.enlistResource(res1);
+
+ // Receive one message in one tx
+
+ TextMessage r1 = (TextMessage)cons1.receive(5000);
+ Assert.assertNotNull(r1);
+ Assert.assertEquals("jellyfish1", r1.getText());
+
+ tx1.delistResource(res1, XAResource.TMSUCCESS);
+
+ // suspend the tx
+ Transaction suspended = tm.suspend();
+
+ tm.begin();
+
+ Transaction tx2 = tm.getTransaction();
+ tx2.enlistResource(res1);
+
+ // Receive 2nd message in a different tx
+ TextMessage r2 = (TextMessage)cons1.receive(5000);
+ Assert.assertNotNull(r2);
+ Assert.assertEquals("jellyfish2", r2.getText());
+
+ cons1.close();
+
+ tx2.delistResource(res1, XAResource.TMSUCCESS);
+
+ // rollback this transaction
+ tm.rollback();
+
+ // verify that second message is available
+ conn2.close();
+ conn2 = cf.createConnection();
+ Session sess = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ conn2.start();
+ MessageConsumer cons = sess.createConsumer(queue1);
+
+ TextMessage r3 = (TextMessage)cons.receive(5000);
+
+ Assert.assertNotNull(r3);
+ Assert.assertEquals("jellyfish2", r3.getText());
+ r3 = (TextMessage)cons.receive(100);
+ Assert.assertNull(r3);
+
+ // rollback the other tx
+ tm.resume(suspended);
+ tm.rollback();
+
+ // Verify the first message is now available
+ r3 = (TextMessage)cons.receive(5000);
+ Assert.assertNotNull(r3);
+ Assert.assertEquals("jellyfish1", r3.getText());
+ r3 = (TextMessage)cons.receive(100);
+ Assert.assertNull(r3);
+
+ }
+ finally
+ {
+ if (conn != null)
+ {
+ conn.close();
+ }
+ if (conn2 != null)
+ {
+ conn2.close();
+ }
+
+ }
+
+ }
+
+ @Test
+ public void testOneSessionTwoTransactionsCommitSend() throws Exception
+ {
+ XAConnection conn = null;
+
+ Connection conn2 = null;
+
+ try
+ {
+ conn = xacf.createXAConnection();
+
+ // Create a session
+ XASession sess1 = conn.createXASession();
+ XAResource res1 = sess1.getXAResource();
+
+ MessageProducer prod1 = sess1.createProducer(queue1);
+
+ tm.begin();
+
+ Transaction tx1 = tm.getTransaction();
+ tx1.enlistResource(res1);
+
+ // Send a message
+ prod1.send(sess1.createTextMessage("kangaroo1"));
+
+ tx1.delistResource(res1, XAResource.TMSUCCESS);
+
+ // suspend the tx
+ Transaction suspended = tm.suspend();
+
+ tm.begin();
+
+ // Send another message in another tx using the same session
+ Transaction tx2 = tm.getTransaction();
+ tx2.enlistResource(res1);
+
+ // Send a message
+ prod1.send(sess1.createTextMessage("kangaroo2"));
+
+ tx2.delistResource(res1, XAResource.TMSUCCESS);
+
+ // commit this transaction
+ tm.commit();
+
+ // verify only kangaroo2 message is sent
+ conn2 = cf.createConnection();
+ Session sess = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ conn2.start();
+ MessageConsumer cons = sess.createConsumer(queue1);
+ TextMessage r1 = (TextMessage)cons.receive(5000);
+ Assert.assertNotNull(r1);
+ Assert.assertEquals("kangaroo2", r1.getText());
+ TextMessage r2 = (TextMessage)cons.receive(100);
+ Assert.assertNull(r2);
+
+ // now resume the first tx and then commit it
+ tm.resume(suspended);
+
+ tm.commit();
+
+ // verify that the first text message is received
+ TextMessage r3 = (TextMessage)cons.receive(5000);
+ Assert.assertNotNull(r3);
+ Assert.assertEquals("kangaroo1", r3.getText());
+
+ }
+ finally
+ {
+ if (conn != null)
+ {
+ conn.close();
+ }
+ if (conn2 != null)
+ {
+ conn2.close();
+ }
+
+ }
+
+ }
+
+ @Test
+ public void testIsSamRM() throws Exception
+ {
+ XAConnection conn = null;
+
+ conn = xacf.createXAConnection();
+
+ // Create a session
+ XASession sess1 = conn.createXASession();
+ XAResource res1 = sess1.getXAResource();
+
+ // Create a session
+ XASession sess2 = conn.createXASession();
+ XAResource res2 = sess2.getXAResource();
+
+ Assert.assertTrue(res1.isSameRM(res2));
+ }
+
+ static class DummyXAResource implements XAResource
+ {
+ boolean failOnPrepare;
+
+ DummyXAResource()
+ {
+ }
+
+ DummyXAResource(final boolean failOnPrepare)
+ {
+ this.failOnPrepare = failOnPrepare;
+ }
+
+ public void commit(final Xid arg0, final boolean arg1) throws XAException
+ {
+ }
+
+ public void end(final Xid arg0, final int arg1) throws XAException
+ {
+ }
+
+ public void forget(final Xid arg0) throws XAException
+ {
+ }
+
+ public int getTransactionTimeout() throws XAException
+ {
+ return 0;
+ }
+
+ public boolean isSameRM(final XAResource arg0) throws XAException
+ {
+ return false;
+ }
+
+ public int prepare(final Xid arg0) throws XAException
+ {
+ if (failOnPrepare)
+ {
+ throw new XAException(XAException.XAER_RMFAIL);
+ }
+ return XAResource.XA_OK;
+ }
+
+ public Xid[] recover(final int arg0) throws XAException
+ {
+ return null;
+ }
+
+ public void rollback(final Xid arg0) throws XAException
+ {
+ }
+
+ public boolean setTransactionTimeout(final int arg0) throws XAException
+ {
+ return false;
+ }
+
+ public void start(final Xid arg0, final int arg1) throws XAException
+ {
+
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/integration-tests/pom.xml
----------------------------------------------------------------------
diff --git a/tests/integration-tests/pom.xml b/tests/integration-tests/pom.xml
index 6eb00bf..3c32bfe 100644
--- a/tests/integration-tests/pom.xml
+++ b/tests/integration-tests/pom.xml
@@ -181,18 +181,6 @@
<version>5.0.0.GA</version>
</dependency>
- <!-- Needed for JMS Bridge Tests -->
- <dependency>
- <groupId>org.jboss.jbossts.jts</groupId>
- <artifactId>jbossjts-jacorb</artifactId>
- <version>4.17.13.Final</version>
- </dependency>
- <dependency>
- <groupId>org.jboss</groupId>
- <artifactId>jboss-transaction-spi</artifactId>
- <version>7.1.0.Final</version>
- </dependency>
-
<!--Vertx provided dependencies-->
<dependency>
<groupId>io.vertx</groupId>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/jms/bridge/BridgeTestBase.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/jms/bridge/BridgeTestBase.java b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/jms/bridge/BridgeTestBase.java
deleted file mode 100644
index d5dfa9c..0000000
--- a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/jms/bridge/BridgeTestBase.java
+++ /dev/null
@@ -1,613 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.tests.integration.jms.bridge;
-
-import javax.jms.BytesMessage;
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.DeliveryMode;
-import javax.jms.Destination;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.jms.Topic;
-import javax.jms.XAConnectionFactory;
-import javax.transaction.TransactionManager;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Set;
-
-import com.arjuna.ats.arjuna.coordinator.TransactionReaper;
-import com.arjuna.ats.arjuna.coordinator.TxControl;
-import com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionManagerImple;
-import org.apache.activemq.api.core.TransportConfiguration;
-import org.apache.activemq.api.core.management.ResourceNames;
-import org.apache.activemq.api.jms.ActiveMQJMSClient;
-import org.apache.activemq.api.jms.JMSFactoryType;
-import org.apache.activemq.api.jms.management.JMSQueueControl;
-import org.apache.activemq.api.jms.management.TopicControl;
-import org.apache.activemq.core.config.Configuration;
-import org.apache.activemq.core.registry.JndiBindingRegistry;
-import org.apache.activemq.core.remoting.impl.invm.TransportConstants;
-import org.apache.activemq.core.server.ActiveMQServer;
-import org.apache.activemq.core.server.ActiveMQServers;
-import org.apache.activemq.core.server.management.ManagementService;
-import org.apache.activemq.jms.bridge.ConnectionFactoryFactory;
-import org.apache.activemq.jms.bridge.DestinationFactory;
-import org.apache.activemq.jms.bridge.QualityOfServiceMode;
-import org.apache.activemq.jms.client.ActiveMQConnectionFactory;
-import org.apache.activemq.jms.client.ActiveMQJMSConnectionFactory;
-import org.apache.activemq.jms.client.ActiveMQMessage;
-import org.apache.activemq.jms.client.ActiveMQXAConnectionFactory;
-import org.apache.activemq.jms.server.JMSServerManager;
-import org.apache.activemq.jms.server.impl.JMSServerManagerImpl;
-import org.apache.activemq.tests.integration.IntegrationTestLogger;
-import org.apache.activemq.tests.unit.util.InVMNamingContext;
-import org.apache.activemq.tests.util.UnitTestCase;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-
-/**
- * A BridgeTestBase
- *
- * @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
- */
-public abstract class BridgeTestBase extends UnitTestCase
-{
- private static final IntegrationTestLogger log = IntegrationTestLogger.LOGGER;
-
- protected ConnectionFactoryFactory cff0, cff1;
-
- protected ConnectionFactoryFactory cff0xa, cff1xa;
-
- protected ConnectionFactory cf0, cf1;
-
- protected XAConnectionFactory cf0xa, cf1xa;
-
- protected DestinationFactory sourceQueueFactory;
- protected DestinationFactory targetQueueFactory;
- protected DestinationFactory localTargetQueueFactory;
- protected DestinationFactory sourceTopicFactory;
-
- protected Queue sourceQueue, targetQueue, localTargetQueue;
-
- protected Topic sourceTopic;
-
- protected ActiveMQServer server0;
-
- protected JMSServerManager jmsServer0;
-
- protected ActiveMQServer server1;
-
- protected JMSServerManager jmsServer1;
-
- private InVMNamingContext context0;
-
- protected InVMNamingContext context1;
-
- protected HashMap<String, Object> params1;
-
- protected ConnectionFactoryFactory cff0LowProducerWindow;
-
- @Override
- @Before
- public void setUp() throws Exception
- {
- super.setUp();
-
- // Start the servers
- Configuration conf0 = createBasicConfig()
- .setJournalDirectory(getJournalDir(0, false))
- .setBindingsDirectory(getBindingsDir(0, false))
- .addAcceptorConfiguration(new TransportConfiguration(INVM_ACCEPTOR_FACTORY));
-
- server0 = addServer(ActiveMQServers.newActiveMQServer(conf0, false));
-
- context0 = new InVMNamingContext();
- jmsServer0 = new JMSServerManagerImpl(server0);
- jmsServer0.setRegistry(new JndiBindingRegistry(context0));
- jmsServer0.start();
-
- params1 = new HashMap<String, Object>();
- params1.put(TransportConstants.SERVER_ID_PROP_NAME, 1);
-
- Configuration conf1 = createBasicConfig()
- .setJournalDirectory(getJournalDir(1, false))
- .setBindingsDirectory(getBindingsDir(1, false))
- .addAcceptorConfiguration(new TransportConfiguration(INVM_ACCEPTOR_FACTORY, params1));
-
- server1 = addServer(ActiveMQServers.newActiveMQServer(conf1, false));
-
- context1 = new InVMNamingContext();
-
- jmsServer1 = new JMSServerManagerImpl(server1);
- jmsServer1.setRegistry(new JndiBindingRegistry(context1));
- jmsServer1.start();
-
- createQueue("sourceQueue", 0);
-
- jmsServer0.createTopic(false, "sourceTopic", "/topic/sourceTopic");
-
- createQueue("localTargetQueue", 0);
-
- createQueue("targetQueue", 1);
-
- setUpAdministeredObjects();
- TxControl.enable();
- // We need a local transaction and recovery manager
- // We must start this after the remote servers have been created or it won't
- // have deleted the database and the recovery manager may attempt to recover transactions
-
- }
-
- protected void createQueue(final String queueName, final int index) throws Exception
- {
- JMSServerManager server = jmsServer0;
- if (index == 1)
- {
- server = jmsServer1;
- }
- assertTrue("queue '/queue/" + queueName + "' created",
- server.createQueue(false, queueName, null, true, "/queue/" + queueName));
- }
-
- @Override
- @After
- public void tearDown() throws Exception
- {
- checkEmpty(sourceQueue, 0);
- checkEmpty(localTargetQueue, 0);
- checkEmpty(targetQueue, 1);
-
- // Check no subscriptions left lying around
-
- checkNoSubscriptions(sourceTopic, 0);
- if (cff0 instanceof ActiveMQConnectionFactory)
- {
- ((ActiveMQConnectionFactory) cff0).close();
- }
- if (cff1 instanceof ActiveMQConnectionFactory)
- {
- ((ActiveMQConnectionFactory) cff1).close();
- }
- stopComponent(jmsServer0);
- stopComponent(jmsServer1);
- cff0 = cff1 = null;
- cff0xa = cff1xa = null;
-
- cf0 = cf1 = null;
-
- cf0xa = cf1xa = null;
-
- sourceQueueFactory = targetQueueFactory = localTargetQueueFactory = sourceTopicFactory = null;
-
- sourceQueue = targetQueue = localTargetQueue = null;
-
- sourceTopic = null;
-
- server0 = null;
-
- jmsServer0 = null;
-
- server1 = null;
-
- jmsServer1 = null;
- if (context0 != null)
- context0.close();
- context0 = null;
- if (context1 != null)
- context1.close();
- context1 = null;
-
- // Shutting down Arjuna threads
- TxControl.disable(true);
-
- TransactionReaper.terminate(false);
- super.tearDown();
- }
-
-
- protected void setUpAdministeredObjects() throws Exception
- {
- cff0LowProducerWindow = new ConnectionFactoryFactory()
- {
- public ConnectionFactory createConnectionFactory() throws Exception
- {
- ActiveMQConnectionFactory cf = ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF,
- new TransportConfiguration(
- INVM_CONNECTOR_FACTORY));
-
- // Note! We disable automatic reconnection on the session factory. The bridge needs to do the reconnection
- cf.setReconnectAttempts(0);
- cf.setBlockOnNonDurableSend(true);
- cf.setBlockOnDurableSend(true);
- cf.setCacheLargeMessagesClient(true);
- cf.setProducerWindowSize(100);
-
- return cf;
- }
-
- };
-
-
- cff0 = new ConnectionFactoryFactory()
- {
- public ConnectionFactory createConnectionFactory() throws Exception
- {
- ActiveMQConnectionFactory cf = ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF,
- new TransportConfiguration(
- INVM_CONNECTOR_FACTORY));
-
- // Note! We disable automatic reconnection on the session factory. The bridge needs to do the reconnection
- cf.setReconnectAttempts(0);
- cf.setBlockOnNonDurableSend(true);
- cf.setBlockOnDurableSend(true);
- cf.setCacheLargeMessagesClient(true);
-
- return cf;
- }
-
- };
-
- cff0xa = new ConnectionFactoryFactory()
- {
- public Object createConnectionFactory() throws Exception
- {
- ActiveMQXAConnectionFactory cf = (ActiveMQXAConnectionFactory) ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.XA_CF,
- new TransportConfiguration(
- INVM_CONNECTOR_FACTORY));
-
- // Note! We disable automatic reconnection on the session factory. The bridge needs to do the reconnection
- cf.setReconnectAttempts(0);
- cf.setBlockOnNonDurableSend(true);
- cf.setBlockOnDurableSend(true);
- cf.setCacheLargeMessagesClient(true);
-
- return cf;
- }
-
- };
-
- cf0 = (ConnectionFactory) cff0.createConnectionFactory();
- cf0xa = (XAConnectionFactory) cff0xa.createConnectionFactory();
-
- cff1 = new ConnectionFactoryFactory()
- {
-
- public ConnectionFactory createConnectionFactory() throws Exception
- {
- ActiveMQJMSConnectionFactory cf = (ActiveMQJMSConnectionFactory) ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF,
- new TransportConfiguration(
- INVM_CONNECTOR_FACTORY,
- params1));
-
- // Note! We disable automatic reconnection on the session factory. The bridge needs to do the reconnection
- cf.setReconnectAttempts(0);
- cf.setBlockOnNonDurableSend(true);
- cf.setBlockOnDurableSend(true);
- cf.setCacheLargeMessagesClient(true);
-
- return cf;
- }
- };
-
- cff1xa = new ConnectionFactoryFactory()
- {
-
- public XAConnectionFactory createConnectionFactory() throws Exception
- {
- ActiveMQXAConnectionFactory cf = (ActiveMQXAConnectionFactory) ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.XA_CF,
- new TransportConfiguration(
- INVM_CONNECTOR_FACTORY,
- params1));
-
- // Note! We disable automatic reconnection on the session factory. The bridge needs to do the reconnection
- cf.setReconnectAttempts(0);
- cf.setBlockOnNonDurableSend(true);
- cf.setBlockOnDurableSend(true);
- cf.setCacheLargeMessagesClient(true);
-
- return cf;
- }
- };
-
- cf1 = (ConnectionFactory) cff1.createConnectionFactory();
- cf1xa = (XAConnectionFactory) cff1xa.createConnectionFactory();
-
- sourceQueueFactory = new DestinationFactory()
- {
- public Destination createDestination() throws Exception
- {
- return (Destination) context0.lookup("/queue/sourceQueue");
- }
- };
-
- sourceQueue = (Queue) sourceQueueFactory.createDestination();
-
- targetQueueFactory = new DestinationFactory()
- {
- public Destination createDestination() throws Exception
- {
- return (Destination) context1.lookup("/queue/targetQueue");
- }
- };
-
- targetQueue = (Queue) targetQueueFactory.createDestination();
-
- sourceTopicFactory = new DestinationFactory()
- {
- public Destination createDestination() throws Exception
- {
- return (Destination) context0.lookup("/topic/sourceTopic");
- }
- };
-
- sourceTopic = (Topic) sourceTopicFactory.createDestination();
-
- localTargetQueueFactory = new DestinationFactory()
- {
- public Destination createDestination() throws Exception
- {
- return (Destination) context0.lookup("/queue/localTargetQueue");
- }
- };
-
- localTargetQueue = (Queue) localTargetQueueFactory.createDestination();
- }
-
- protected void sendMessages(final ConnectionFactory cf,
- final Destination dest,
- final int start,
- final int numMessages,
- final boolean persistent,
- final boolean largeMessage) throws Exception
- {
- Connection conn = null;
-
- try
- {
- conn = cf.createConnection();
-
- Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageProducer prod = sess.createProducer(dest);
-
- prod.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
-
- for (int i = start; i < start + numMessages; i++)
- {
- if (largeMessage)
- {
- BytesMessage msg = sess.createBytesMessage();
- ((ActiveMQMessage) msg).setInputStream(UnitTestCase.createFakeLargeStream(1024L * 1024L));
- msg.setStringProperty("msg", "message" + i);
- prod.send(msg);
- }
- else
- {
- TextMessage tm = sess.createTextMessage("message" + i);
- prod.send(tm);
- }
-
- }
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- }
- }
-
- protected void checkMessagesReceived(final ConnectionFactory cf,
- final Destination dest,
- final QualityOfServiceMode qosMode,
- final int numMessages,
- final boolean longWaitForFirst,
- final boolean largeMessage) throws Exception
- {
- Connection conn = null;
-
- try
- {
- conn = cf.createConnection();
-
- conn.start();
-
- Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageConsumer cons = sess.createConsumer(dest);
-
- // Consume the messages
-
- Set<String> msgs = new HashSet<String>();
-
- int count = 0;
-
- // We always wait longer for the first one - it may take some time to arrive especially if we are
- // waiting for recovery to kick in
- while (true)
- {
- Message tm = cons.receive(count == 0 ? (longWaitForFirst ? 60000 : 10000) : 5000);
-
- if (tm == null)
- {
- break;
- }
-
- // log.info("Got message " + tm.getText());
-
- if (largeMessage)
- {
- BytesMessage bmsg = (BytesMessage) tm;
- msgs.add(tm.getStringProperty("msg"));
- byte[] buffRead = new byte[1024];
- for (int i = 0; i < 1024; i++)
- {
- Assert.assertEquals(1024, bmsg.readBytes(buffRead));
- }
- }
- else
- {
- msgs.add(((TextMessage) tm).getText());
- }
-
- count++;
-
- }
-
- if (qosMode == QualityOfServiceMode.ONCE_AND_ONLY_ONCE || qosMode == QualityOfServiceMode.DUPLICATES_OK)
- {
- // All the messages should be received
-
- for (int i = 0; i < numMessages; i++)
- {
- Assert.assertTrue("quality=" + qosMode + ", #=" + i + ", message=" + msgs, msgs.contains("message" + i));
- }
-
- // Should be no more
- if (qosMode == QualityOfServiceMode.ONCE_AND_ONLY_ONCE)
- {
- Assert.assertEquals(numMessages, msgs.size());
- }
- }
- else if (qosMode == QualityOfServiceMode.AT_MOST_ONCE)
- {
- // No *guarantee* that any messages will be received
- // but you still might get some depending on how/where the crash occurred
- }
-
- BridgeTestBase.log.trace("Check complete");
-
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- }
- }
-
- protected void checkAllMessageReceivedInOrder(final ConnectionFactory cf,
- final Destination dest,
- final int start,
- final int numMessages,
- final boolean largeMessage) throws Exception
- {
- Connection conn = null;
- try
- {
- conn = cf.createConnection();
-
- conn.start();
-
- Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageConsumer cons = sess.createConsumer(dest);
-
- // Consume the messages
-
- for (int i = 0; i < numMessages; i++)
- {
- Message tm = cons.receive(30000);
-
- Assert.assertNotNull(tm);
-
- if (largeMessage)
- {
- BytesMessage bmsg = (BytesMessage) tm;
- Assert.assertEquals("message" + (i + start), tm.getStringProperty("msg"));
- byte[] buffRead = new byte[1024];
- for (int j = 0; j < 1024; j++)
- {
- Assert.assertEquals(1024, bmsg.readBytes(buffRead));
- }
- }
- else
- {
- Assert.assertEquals("message" + (i + start), ((TextMessage) tm).getText());
- }
- }
- }
- finally
- {
- if (conn != null)
- {
- conn.close();
- }
- }
- }
-
- public boolean checkEmpty(final Queue queue, final int index) throws Exception
- {
- ManagementService managementService = server0.getManagementService();
- if (index == 1)
- {
- managementService = server1.getManagementService();
- }
- JMSQueueControl queueControl = (JMSQueueControl) managementService.getResource(ResourceNames.JMS_QUEUE + queue.getQueueName());
-
- //server may be closed
- if (queueControl != null)
- {
- queueControl.flushExecutor();
- Long messageCount = queueControl.getMessageCount();
-
- if (messageCount > 0)
- {
- queueControl.removeMessages(null);
- }
- }
- return true;
- }
-
- protected void checkNoSubscriptions(final Topic topic, final int index) throws Exception
- {
- ManagementService managementService = server0.getManagementService();
- if (index == 1)
- {
- managementService = server1.getManagementService();
- }
- TopicControl topicControl = (TopicControl) managementService.getResource(ResourceNames.JMS_TOPIC + topic.getTopicName());
- Assert.assertEquals(0, topicControl.getSubscriptionCount());
-
- }
-
- protected void removeAllMessages(final String queueName, final int index) throws Exception
- {
- ManagementService managementService = server0.getManagementService();
- if (index == 1)
- {
- managementService = server1.getManagementService();
- }
- JMSQueueControl queueControl = (JMSQueueControl) managementService.getResource(ResourceNames.JMS_QUEUE + queueName);
- queueControl.removeMessages(null);
- }
-
- protected TransactionManager newTransactionManager()
- {
- return new TransactionManagerImple();
- }
-
- // Inner classes -------------------------------------------------------------------
-}
[15/15] activemq-6 git commit: This closes #157 - pom/testsuite fixes
Posted by jb...@apache.org.
This closes #157 - pom/testsuite fixes
Project: http://git-wip-us.apache.org/repos/asf/activemq-6/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-6/commit/f52bc878
Tree: http://git-wip-us.apache.org/repos/asf/activemq-6/tree/f52bc878
Diff: http://git-wip-us.apache.org/repos/asf/activemq-6/diff/f52bc878
Branch: refs/heads/master
Commit: f52bc878ee403b3672bc09322f029a8097998916
Parents: b0167ea 3661829
Author: jbertram <jb...@redhat.com>
Authored: Fri Mar 6 16:24:25 2015 -0600
Committer: jbertram <jb...@redhat.com>
Committed: Fri Mar 6 16:24:25 2015 -0600
----------------------------------------------------------------------
.../jms/server/impl/JMSServerManagerImpl.java | 2 +-
examples/core/embedded-remote/pom.xml | 2 +-
examples/core/embedded/pom.xml | 2 +-
examples/core/perf/pom.xml | 2 +-
examples/core/vertx-connector/pom.xml | 2 +-
examples/jms/activemq-ra-rar/pom.xml | 2 +-
examples/jms/aerogear/pom.xml | 2 +-
examples/jms/applet/pom.xml | 2 +-
examples/jms/application-layer-failover/pom.xml | 2 +-
examples/jms/bridge/pom.xml | 2 +-
examples/jms/browser/pom.xml | 2 +-
examples/jms/client-kickoff/pom.xml | 2 +-
.../jms/client-side-failoverlistener/pom.xml | 2 +-
examples/jms/client-side-load-balancing/pom.xml | 2 +-
.../jms/clustered-durable-subscription/pom.xml | 2 +-
examples/jms/clustered-grouping/pom.xml | 2 +-
examples/jms/clustered-jgroups/pom.xml | 2 +-
examples/jms/clustered-queue/pom.xml | 2 +-
examples/jms/clustered-standalone/pom.xml | 2 +-
examples/jms/clustered-static-discovery/pom.xml | 2 +-
examples/jms/clustered-static-oneway/pom.xml | 2 +-
examples/jms/clustered-topic/pom.xml | 2 +-
.../jms/colocated-failover-scale-down/pom.xml | 2 +-
examples/jms/colocated-failover/pom.xml | 2 +-
examples/jms/consumer-rate-limit/pom.xml | 2 +-
examples/jms/dead-letter/pom.xml | 2 +-
examples/jms/delayed-redelivery/pom.xml | 2 +-
examples/jms/divert/pom.xml | 2 +-
examples/jms/durable-subscription/pom.xml | 2 +-
examples/jms/embedded-simple/pom.xml | 2 +-
examples/jms/embedded/pom.xml | 2 +-
examples/jms/expiry/pom.xml | 2 +-
examples/jms/ha-policy-autobackup/pom.xml | 2 +-
examples/jms/http-transport/pom.xml | 2 +-
.../jms/instantiate-connection-factory/pom.xml | 2 +-
examples/jms/interceptor/pom.xml | 2 +-
examples/jms/jms-auto-closeable/pom.xml | 2 +-
examples/jms/jms-bridge/pom.xml | 2 +-
examples/jms/jms-completion-listener/pom.xml | 2 +-
examples/jms/jms-context/pom.xml | 2 +-
examples/jms/jms-shared-consumer/pom.xml | 2 +-
examples/jms/jmx/pom.xml | 2 +-
examples/jms/large-message/pom.xml | 2 +-
examples/jms/last-value-queue/pom.xml | 2 +-
examples/jms/management-notifications/pom.xml | 2 +-
examples/jms/management/pom.xml | 2 +-
examples/jms/message-counters/pom.xml | 2 +-
examples/jms/message-group/pom.xml | 2 +-
examples/jms/message-group2/pom.xml | 2 +-
examples/jms/message-priority/pom.xml | 2 +-
examples/jms/multiple-failover-failback/pom.xml | 2 +-
examples/jms/multiple-failover/pom.xml | 2 +-
examples/jms/no-consumer-buffering/pom.xml | 2 +-
examples/jms/non-transaction-failover/pom.xml | 2 +-
examples/jms/openwire/pom.xml | 2 +-
examples/jms/paging/pom.xml | 2 +-
examples/jms/perf/pom.xml | 2 +-
examples/jms/pre-acknowledge/pom.xml | 2 +-
examples/jms/producer-rate-limit/pom.xml | 2 +-
examples/jms/proton-cpp/pom.xml | 2 +-
examples/jms/proton-j/pom.xml | 2 +-
examples/jms/proton-ruby/pom.xml | 2 +-
.../jms/queue-message-redistribution/pom.xml | 2 +-
examples/jms/queue-requestor/pom.xml | 2 +-
examples/jms/queue-selector/pom.xml | 2 +-
examples/jms/queue/pom.xml | 2 +-
examples/jms/reattach-node/pom.xml | 2 +-
examples/jms/replicated-failback-static/pom.xml | 2 +-
examples/jms/replicated-failback/pom.xml | 2 +-
.../jms/replicated-multiple-failover/pom.xml | 2 +-
.../jms/replicated-transaction-failover/pom.xml | 2 +-
examples/jms/request-reply/pom.xml | 2 +-
examples/jms/rest/dup-send/pom.xml | 2 +-
examples/jms/rest/javascript-chat/pom.xml | 2 +-
examples/jms/rest/jms-to-rest/pom.xml | 2 +-
examples/jms/rest/pom.xml | 2 +-
examples/jms/rest/push/pom.xml | 2 +-
examples/jms/scale-down/pom.xml | 2 +-
examples/jms/scheduled-message/pom.xml | 2 +-
examples/jms/security/pom.xml | 2 +-
examples/jms/send-acknowledgements/pom.xml | 2 +-
examples/jms/spring-integration/pom.xml | 2 +-
examples/jms/ssl-enabled/pom.xml | 2 +-
examples/jms/static-selector-jms/pom.xml | 2 +-
examples/jms/static-selector/pom.xml | 2 +-
examples/jms/stomp-websockets/pom.xml | 2 +-
examples/jms/stomp/pom.xml | 2 +-
examples/jms/stomp1.1/pom.xml | 2 +-
examples/jms/stomp1.2/pom.xml | 2 +-
examples/jms/stop-server-failover/pom.xml | 2 +-
examples/jms/symmetric-cluster/pom.xml | 2 +-
examples/jms/temp-queue/pom.xml | 2 +-
examples/jms/topic-hierarchies/pom.xml | 2 +-
examples/jms/topic-selector-example1/pom.xml | 2 +-
examples/jms/topic-selector-example2/pom.xml | 2 +-
examples/jms/topic/pom.xml | 2 +-
examples/jms/transaction-failover/pom.xml | 2 +-
examples/jms/transactional/pom.xml | 2 +-
examples/jms/xa-heuristic/pom.xml | 2 +-
examples/jms/xa-receive/pom.xml | 2 +-
examples/jms/xa-send/pom.xml | 2 +-
examples/soak/normal/pom.xml | 2 +-
examples/soak/pom.xml | 2 +-
pom.xml | 6 +-
tests/byteman-tests/pom.xml | 229 --
.../tests/ActiveMQMessageHandlerTest.java | 428 ---
.../activemq/byteman/tests/BMFailoverTest.java | 451 ---
.../BridgeServerLocatorConfigurationTest.java | 181 --
.../byteman/tests/ClosingConnectionTest.java | 192 --
.../byteman/tests/ClusteredGroupingTest.java | 473 ---
.../activemq/byteman/tests/GroupingTest.java | 202 --
.../tests/JMSBridgeReconnectionTest.java | 163 -
.../activemq/byteman/tests/LatencyTest.java | 69 -
.../activemq/byteman/tests/MessageCopyTest.java | 206 --
.../byteman/tests/OrphanedConsumerTest.java | 301 --
.../activemq/byteman/tests/PagingLeakTest.java | 273 --
.../byteman/tests/ReplicationBackupTest.java | 121 -
.../byteman/tests/ScaleDownFailoverTest.java | 200 --
.../byteman/tests/ScaleDownFailureTest.java | 117 -
.../tests/ScaleDownGroupedFailoverTest.java | 25 -
.../tests/ScaleDownGroupedFailureTest.java | 25 -
.../byteman/tests/StartStopDeadlockTest.java | 170 -
.../byteman/tests/StompInternalStateTest.java | 146 -
.../impl/HierarchicalObjectRepositoryTest.java | 153 -
tests/concurrent-tests/pom.xml | 101 -
.../tests/concurrent/server/impl/QueueTest.java | 231 --
.../concurrent/stomp/ConcurrentStompTest.java | 160 -
tests/extra-tests/pom.xml | 246 ++
.../activemq/tests/extras/ExtrasTestLogger.java | 34 +
.../byteman/ActiveMQMessageHandlerTest.java | 428 +++
.../tests/extras/byteman/BMFailoverTest.java | 451 +++
.../BridgeServerLocatorConfigurationTest.java | 181 ++
.../extras/byteman/ClosingConnectionTest.java | 192 ++
.../extras/byteman/ClusteredGroupingTest.java | 473 +++
.../tests/extras/byteman/GroupingTest.java | 202 ++
.../HierarchicalObjectRepositoryTest.java | 154 +
.../byteman/JMSBridgeReconnectionTest.java | 163 +
.../tests/extras/byteman/LatencyTest.java | 69 +
.../tests/extras/byteman/MessageCopyTest.java | 206 ++
.../extras/byteman/OrphanedConsumerTest.java | 301 ++
.../tests/extras/byteman/PagingLeakTest.java | 273 ++
.../extras/byteman/ReplicationBackupTest.java | 121 +
.../extras/byteman/ScaleDownFailoverTest.java | 200 ++
.../extras/byteman/ScaleDownFailureTest.java | 117 +
.../byteman/ScaleDownGroupedFailoverTest.java | 25 +
.../byteman/ScaleDownGroupedFailureTest.java | 25 +
.../extras/byteman/StartStopDeadlockTest.java | 170 +
.../extras/byteman/StompInternalStateTest.java | 146 +
.../tests/extras/jms/bridge/BridgeTestBase.java | 613 ++++
.../jms/bridge/ClusteredBridgeTestBase.java | 312 ++
.../jms/bridge/JMSBridgeClusteredTest.java | 276 ++
.../jms/bridge/JMSBridgeReconnectionTest.java | 559 ++++
.../tests/extras/jms/bridge/JMSBridgeTest.java | 2449 ++++++++++++++
.../bridge/TransactionManagerLocatorImpl.java | 42 +
.../activemq/tests/extras/jms/xa/XATest.java | 2142 ++++++++++++
tests/integration-tests/pom.xml | 14 +-
.../integration/jms/bridge/BridgeTestBase.java | 613 ----
.../jms/bridge/ClusteredBridgeTestBase.java | 312 --
.../jms/bridge/JMSBridgeClusteredTest.java | 276 --
.../jms/bridge/JMSBridgeReconnectionTest.java | 559 ----
.../integration/jms/bridge/JMSBridgeTest.java | 2449 --------------
.../bridge/TransactionManagerLocatorImpl.java | 42 -
.../tests/integration/ra/JMSContextTest.java | 2 -
.../integration/stomp/ConcurrentStompTest.java | 159 +
.../apache/activemq/tests/util/JMSTestBase.java | 8 -
...sions.transactions.TransactionManagerLocator | 2 +-
tests/jms-tests/pom.xml | 23 +-
.../activemq/jms/tests/XARecoveryTest.java | 3052 ------------------
.../org/apache/activemq/jms/tests/XATest.java | 2336 --------------
.../tests/stress/ConcurrentCloseStressTest.java | 297 --
.../tests/stress/CorruptMessageStressTest.java | 164 -
.../jms/tests/stress/JMSStressTestBase.java | 106 -
.../tests/stress/ManyConnectionsStressTest.java | 218 --
.../jms/tests/stress/OpenCloseStressTest.java | 445 ---
.../jms/tests/stress/QueueStressTest.java | 271 --
.../activemq/jms/tests/stress/Receiver.java | 297 --
.../jms/tests/stress/RecoveringReceiver.java | 195 --
.../jms/tests/stress/RelayStressTest.java | 256 --
.../activemq/jms/tests/stress/Runner.java | 64 -
.../activemq/jms/tests/stress/Sender.java | 72 -
.../tests/stress/SeveralClientsStressTest.java | 547 ----
.../jms/tests/stress/TopicStressTest.java | 297 --
.../tests/stress/Transactional2PCReceiver.java | 231 --
.../tests/stress/Transactional2PCSender.java | 120 -
.../jms/tests/stress/TransactionalReceiver.java | 200 --
.../jms/tests/stress/TransactionalSender.java | 93 -
tests/joram-tests/pom.xml | 2 +-
tests/performance-tests/pom.xml | 2 +-
tests/pom.xml | 17 +-
tests/soak-tests/pom.xml | 2 +-
tests/stress-tests/pom.xml | 2 +-
tests/timing-tests/pom.xml | 2 +-
.../core/server/impl/QueueConcurrentTest.java | 231 ++
tests/unit-tests/pom.xml | 2 +-
194 files changed, 11083 insertions(+), 18296 deletions(-)
----------------------------------------------------------------------
[14/15] activemq-6 git commit: Refactored the testsuite a bit
Posted by jb...@apache.org.
Refactored the testsuite a bit
With these changes the testsuite is not using any LGPL code by default. Anything woud go through extra-tests
These following changes were made on this commit (in summary):
- renamed byteman-tests as extra-tests
- added extra-tests on a new profile called extra-tests
- added all the other tests back to the tests profile
- removed concurrent-tests and moved them all to timing-tests
- removed old tests that were ignored for a long time and were stale
Project: http://git-wip-us.apache.org/repos/asf/activemq-6/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-6/commit/3661829e
Tree: http://git-wip-us.apache.org/repos/asf/activemq-6/tree/3661829e
Diff: http://git-wip-us.apache.org/repos/asf/activemq-6/diff/3661829e
Branch: refs/heads/master
Commit: 3661829e6d02c9751422bb50c2f0816236bdea53
Parents: b5a04eb
Author: Clebert Suconic <cl...@apache.org>
Authored: Fri Mar 6 11:56:17 2015 -0500
Committer: Clebert Suconic <cl...@apache.org>
Committed: Fri Mar 6 17:16:26 2015 -0500
----------------------------------------------------------------------
.../jms/server/impl/JMSServerManagerImpl.java | 2 +-
pom.xml | 6 +-
tests/byteman-tests/pom.xml | 229 --
.../tests/ActiveMQMessageHandlerTest.java | 428 ---
.../activemq/byteman/tests/BMFailoverTest.java | 451 ---
.../BridgeServerLocatorConfigurationTest.java | 181 --
.../byteman/tests/ClosingConnectionTest.java | 192 --
.../byteman/tests/ClusteredGroupingTest.java | 473 ---
.../activemq/byteman/tests/GroupingTest.java | 202 --
.../tests/JMSBridgeReconnectionTest.java | 163 -
.../activemq/byteman/tests/LatencyTest.java | 69 -
.../activemq/byteman/tests/MessageCopyTest.java | 206 --
.../byteman/tests/OrphanedConsumerTest.java | 301 --
.../activemq/byteman/tests/PagingLeakTest.java | 273 --
.../byteman/tests/ReplicationBackupTest.java | 121 -
.../byteman/tests/ScaleDownFailoverTest.java | 200 --
.../byteman/tests/ScaleDownFailureTest.java | 117 -
.../tests/ScaleDownGroupedFailoverTest.java | 25 -
.../tests/ScaleDownGroupedFailureTest.java | 25 -
.../byteman/tests/StartStopDeadlockTest.java | 170 -
.../byteman/tests/StompInternalStateTest.java | 146 -
.../impl/HierarchicalObjectRepositoryTest.java | 153 -
tests/concurrent-tests/pom.xml | 101 -
.../tests/concurrent/server/impl/QueueTest.java | 231 --
.../concurrent/stomp/ConcurrentStompTest.java | 160 -
tests/extra-tests/pom.xml | 246 ++
.../activemq/tests/extras/ExtrasTestLogger.java | 34 +
.../byteman/ActiveMQMessageHandlerTest.java | 428 +++
.../tests/extras/byteman/BMFailoverTest.java | 451 +++
.../BridgeServerLocatorConfigurationTest.java | 181 ++
.../extras/byteman/ClosingConnectionTest.java | 192 ++
.../extras/byteman/ClusteredGroupingTest.java | 473 +++
.../tests/extras/byteman/GroupingTest.java | 202 ++
.../HierarchicalObjectRepositoryTest.java | 154 +
.../byteman/JMSBridgeReconnectionTest.java | 163 +
.../tests/extras/byteman/LatencyTest.java | 69 +
.../tests/extras/byteman/MessageCopyTest.java | 206 ++
.../extras/byteman/OrphanedConsumerTest.java | 301 ++
.../tests/extras/byteman/PagingLeakTest.java | 273 ++
.../extras/byteman/ReplicationBackupTest.java | 121 +
.../extras/byteman/ScaleDownFailoverTest.java | 200 ++
.../extras/byteman/ScaleDownFailureTest.java | 117 +
.../byteman/ScaleDownGroupedFailoverTest.java | 25 +
.../byteman/ScaleDownGroupedFailureTest.java | 25 +
.../extras/byteman/StartStopDeadlockTest.java | 170 +
.../extras/byteman/StompInternalStateTest.java | 146 +
.../tests/extras/jms/bridge/BridgeTestBase.java | 613 ++++
.../jms/bridge/ClusteredBridgeTestBase.java | 312 ++
.../jms/bridge/JMSBridgeClusteredTest.java | 276 ++
.../jms/bridge/JMSBridgeReconnectionTest.java | 559 ++++
.../tests/extras/jms/bridge/JMSBridgeTest.java | 2449 ++++++++++++++
.../bridge/TransactionManagerLocatorImpl.java | 42 +
.../activemq/tests/extras/jms/xa/XATest.java | 2142 ++++++++++++
tests/integration-tests/pom.xml | 12 -
.../integration/jms/bridge/BridgeTestBase.java | 613 ----
.../jms/bridge/ClusteredBridgeTestBase.java | 312 --
.../jms/bridge/JMSBridgeClusteredTest.java | 276 --
.../jms/bridge/JMSBridgeReconnectionTest.java | 559 ----
.../integration/jms/bridge/JMSBridgeTest.java | 2449 --------------
.../bridge/TransactionManagerLocatorImpl.java | 42 -
.../tests/integration/ra/JMSContextTest.java | 2 -
.../integration/stomp/ConcurrentStompTest.java | 159 +
.../apache/activemq/tests/util/JMSTestBase.java | 8 -
...sions.transactions.TransactionManagerLocator | 2 +-
tests/jms-tests/pom.xml | 21 -
.../activemq/jms/tests/XARecoveryTest.java | 3052 ------------------
.../org/apache/activemq/jms/tests/XATest.java | 2336 --------------
.../tests/stress/ConcurrentCloseStressTest.java | 297 --
.../tests/stress/CorruptMessageStressTest.java | 164 -
.../jms/tests/stress/JMSStressTestBase.java | 106 -
.../tests/stress/ManyConnectionsStressTest.java | 218 --
.../jms/tests/stress/OpenCloseStressTest.java | 445 ---
.../jms/tests/stress/QueueStressTest.java | 271 --
.../activemq/jms/tests/stress/Receiver.java | 297 --
.../jms/tests/stress/RecoveringReceiver.java | 195 --
.../jms/tests/stress/RelayStressTest.java | 256 --
.../activemq/jms/tests/stress/Runner.java | 64 -
.../activemq/jms/tests/stress/Sender.java | 72 -
.../tests/stress/SeveralClientsStressTest.java | 547 ----
.../jms/tests/stress/TopicStressTest.java | 297 --
.../tests/stress/Transactional2PCReceiver.java | 231 --
.../tests/stress/Transactional2PCSender.java | 120 -
.../jms/tests/stress/TransactionalReceiver.java | 200 --
.../jms/tests/stress/TransactionalSender.java | 93 -
tests/pom.xml | 15 +-
.../core/server/impl/QueueConcurrentTest.java | 231 ++
86 files changed, 10972 insertions(+), 18185 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/impl/JMSServerManagerImpl.java
----------------------------------------------------------------------
diff --git a/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/impl/JMSServerManagerImpl.java b/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/impl/JMSServerManagerImpl.java
index 8edcde4..23a4444 100644
--- a/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/impl/JMSServerManagerImpl.java
+++ b/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/impl/JMSServerManagerImpl.java
@@ -436,7 +436,7 @@ public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback
}
// We have to perform the server.stop outside of the lock because of backup activation issues.
// See https://bugzilla.redhat.com/show_bug.cgi?id=959616
- // And org.apache.activemq.byteman.tests.StartStopDeadlockTest which is validating for this case here
+ // And org.apache.activemq.extras.tests.StartStopDeadlockTest which is validating for this case here
server.stop();
}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 6122b1d..77ae86f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -63,7 +63,7 @@
<resteasy.version>3.0.9.Final</resteasy.version>
<skipUnitTests>true</skipUnitTests>
<skipJmsTests>true</skipJmsTests>
- <skipBytemanTests>true</skipBytemanTests>
+ <skipExtraTests>true</skipExtraTests>
<skipIntegrationTests>true</skipIntegrationTests>
<skipJoramTests>true</skipJoramTests>
<skipTimingTests>true</skipTimingTests>
@@ -517,7 +517,7 @@
<skipStressTests>true</skipStressTests>
<skipSoakTests>true</skipSoakTests>
<skipPerformanceTests>true</skipPerformanceTests>
- <skipBytemanTests>false</skipBytemanTests>
+ <skipExtraTests>false</skipExtraTests>
</properties>
</profile>
<profile>
@@ -552,7 +552,7 @@
<skipJoramTests>false</skipJoramTests>
<skipConcurrentTests>false</skipConcurrentTests>
<skipRestTests>false</skipRestTests>
- <skipBytemanTests>false</skipBytemanTests>
+ <skipExtraTests>false</skipExtraTests>
<skipStyleCheck>false</skipStyleCheck>
</properties>
</profile>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/byteman-tests/pom.xml
----------------------------------------------------------------------
diff --git a/tests/byteman-tests/pom.xml b/tests/byteman-tests/pom.xml
deleted file mode 100644
index 0fbd682..0000000
--- a/tests/byteman-tests/pom.xml
+++ /dev/null
@@ -1,229 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.activemq.tests</groupId>
- <artifactId>activemq-tests-pom</artifactId>
- <version>6.0.1-SNAPSHOT</version>
- </parent>
-
- <artifactId>byteman-tests</artifactId>
- <packaging>jar</packaging>
- <name>ActiveMQ6 ByteMan Tests</name>
-
- <properties>
- <tools.jar>${java.home}/../lib/tools.jar</tools.jar>
- <byteman.version>2.2.0</byteman.version>
- <activemq.basedir>${project.basedir}/../..</activemq.basedir>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>io.netty</groupId>
- <artifactId>netty-all</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.byteman</groupId>
- <artifactId>byteman</artifactId>
- <version>${byteman.version}</version>
- </dependency>
- <dependency>
- <groupId>org.jboss.byteman</groupId>
- <artifactId>byteman-submit</artifactId>
- <scope>test</scope>
- <version>${byteman.version}</version>
- </dependency>
- <dependency>
- <groupId>org.jboss.byteman</groupId>
- <artifactId>byteman-install</artifactId>
- <scope>test</scope>
- <version>${byteman.version}</version>
- </dependency>
- <dependency>
- <groupId>org.jboss.byteman</groupId>
- <artifactId>byteman-bmunit</artifactId>
- <scope>test</scope>
- <version>${byteman.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.testng</groupId>
- <artifactId>testng</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>com.sun</groupId>
- <artifactId>tools</artifactId>
- <version>1.7</version>
- <scope>system</scope>
- <systemPath>${tools.jar}</systemPath>
- </dependency>
- <dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>activemq-core-client</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- <type>test-jar</type>
- </dependency>
- <dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>activemq-server</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- <type>test-jar</type>
- </dependency>
- <dependency>
- <groupId>org.apache.activemq.tests</groupId>
- <artifactId>integration-tests</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- <type>test-jar</type>
- </dependency>
- <dependency>
- <groupId>org.apache.activemq.tests</groupId>
- <artifactId>unit-tests</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- <type>test-jar</type>
- </dependency>
- <dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>activemq-jms-client</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>activemq-jms-server</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>activemq-ra</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>activemq-bootstrap</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-j2ee-connector_1.5_spec</artifactId>
- </dependency>
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-ejb_3.0_spec</artifactId>
- </dependency>
- <!--this specifically for the JMS Bridge -->
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-jta_1.1_spec</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.geronimo.components</groupId>
- <artifactId>geronimo-jaspi</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-jms_2.0_spec</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.logging</groupId>
- <artifactId>jboss-logging-processor</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.logging</groupId>
- <artifactId>jboss-logging</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.logmanager</groupId>
- <artifactId>jboss-logmanager</artifactId>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <executions>
- <execution>
- <phase>test</phase>
- <goals>
- <goal>test-jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <skipTests>${skipBytemanTests}</skipTests>
- <includes>
- <include>org.apache.activemq/byteman/tests/*.java</include>
- </includes>
- <!-- ensure we don't inherit a byteman jar form any env settings -->
- <environmentVariables>
- <BYTEMAN_HOME></BYTEMAN_HOME>
- </environmentVariables>
- <systemProperties>
- <!--
- <property>
- <name>org.jboss.byteman.home</name>
- <value></value>
- </property>
- <property>
- <name>org.jboss.byteman.verbose</name>
- <value>true</value>
- </property>
- <property>
- <name>org.jboss.byteman.contrib.bmunit.verbose</name>
- <value>true</value>
- </property>
- <property>
- <name>org.jboss.byteman.dump.generated.classes</name>
- <value></value>
- </property>
- -->
- </systemProperties>
- <!-- make sure maven puts the byteman jar in the classpath rather than in a manifest jar -->
- <useManifestOnlyJar>false</useManifestOnlyJar>
- <forkMode>once</forkMode>
- <!--
- <debugForkedProcess>true</debugForkedProcess>
- -->
- <parallel>false</parallel>
- <!--<argLine>${activemq-surefire-argline} -Dorg.jboss.byteman.verbose -Dorg.jboss.byteman.contrib.bmunit.verbose</argLine>-->
- <!-- '-noverify' is needed here to fix VerifyErrors on ScaleDownFailoverTest and ScaleDownFailureTest (and their subclasses). I got the tip from https://issues.jboss.org/browse/BYTEMAN-248. -->
- <argLine>${activemq-surefire-argline} -noverify</argLine>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/ActiveMQMessageHandlerTest.java
----------------------------------------------------------------------
diff --git a/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/ActiveMQMessageHandlerTest.java b/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/ActiveMQMessageHandlerTest.java
deleted file mode 100644
index fe07bd0..0000000
--- a/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/ActiveMQMessageHandlerTest.java
+++ /dev/null
@@ -1,428 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.byteman.tests;
-
-import com.arjuna.ats.arjuna.coordinator.TransactionReaper;
-import com.arjuna.ats.arjuna.coordinator.TxControl;
-import com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionManagerImple;
-import org.apache.activemq.api.core.SimpleString;
-import org.apache.activemq.api.core.client.ClientConsumer;
-import org.apache.activemq.api.core.client.ClientMessage;
-import org.apache.activemq.api.core.client.ClientProducer;
-import org.apache.activemq.api.core.client.ClientSession;
-import org.apache.activemq.api.core.client.ClientSessionFactory;
-import org.apache.activemq.core.postoffice.Binding;
-import org.apache.activemq.core.server.Queue;
-import org.apache.activemq.ra.ActiveMQResourceAdapter;
-import org.apache.activemq.ra.inflow.ActiveMQActivationSpec;
-import org.apache.activemq.tests.integration.ra.ActiveMQRATestBase;
-import org.jboss.byteman.contrib.bmunit.BMRule;
-import org.jboss.byteman.contrib.bmunit.BMRules;
-import org.jboss.byteman.contrib.bmunit.BMUnitRunner;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import javax.jms.Message;
-import javax.resource.ResourceException;
-import javax.transaction.SystemException;
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
-import javax.transaction.xa.XAException;
-import javax.transaction.xa.XAResource;
-import javax.transaction.xa.Xid;
-import java.lang.reflect.Method;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-/**
- * @author <a href="mailto:andy.taylor@jboss.org">Andy Taylor</a>
- * Created May 20, 2010
- */
-@RunWith(BMUnitRunner.class)
-public class ActiveMQMessageHandlerTest extends ActiveMQRATestBase
-{
-
- protected boolean usePersistence()
- {
- return true;
- }
-
-
- @Override
- public boolean useSecurity()
- {
- return false;
- }
-
- @Test
- @BMRules
- (
- rules =
- {
- @BMRule
- (
- name = "interrupt",
- targetClass = "org.apache.activemq.core.protocol.core.impl.ActiveMQSessionContext",
- targetMethod = "xaEnd",
- targetLocation = "ENTRY",
- action = "org.apache.activemq.byteman.tests.ActiveMQMessageHandlerTest.interrupt();"
- )
- }
- )
- public void testSimpleMessageReceivedOnQueue() throws Exception
- {
- ActiveMQResourceAdapter qResourceAdapter = newResourceAdapter();
- resourceAdapter = qResourceAdapter;
-
- MyBootstrapContext ctx = new MyBootstrapContext();
-
- qResourceAdapter.setConnectorClassName(NETTY_CONNECTOR_FACTORY);
- qResourceAdapter.start(ctx);
-
- ActiveMQActivationSpec spec = new ActiveMQActivationSpec();
- spec.setMaxSession(1);
- spec.setCallTimeout(1000L);
- spec.setResourceAdapter(qResourceAdapter);
- spec.setUseJNDI(false);
- spec.setDestinationType("javax.jms.Queue");
- spec.setDestination(MDBQUEUE);
-
- CountDownLatch latch = new CountDownLatch(1);
-
- XADummyEndpoint endpoint = new XADummyEndpoint(latch, false);
-
- DummyMessageEndpointFactory endpointFactory = new DummyMessageEndpointFactory(endpoint, true);
-
- qResourceAdapter.endpointActivation(endpointFactory, spec);
-
- ClientSession session = locator.createSessionFactory().createSession();
-
- ClientProducer clientProducer = session.createProducer(MDBQUEUEPREFIXED);
-
- ClientMessage message = session.createMessage(true);
-
- message.getBodyBuffer().writeString("teststring");
-
- clientProducer.send(message);
-
- session.close();
-
- latch.await(5, TimeUnit.SECONDS);
-
- assertNotNull(endpoint.lastMessage);
- assertEquals(endpoint.lastMessage.getCoreMessage().getBodyBuffer().readString(), "teststring");
-
- qResourceAdapter.endpointDeactivation(endpointFactory, spec);
-
- qResourceAdapter.stop();
-
- Binding binding = server.getPostOffice().getBinding(SimpleString.toSimpleString(MDBQUEUEPREFIXED));
- assertEquals(1, getMessageCount(((Queue) binding.getBindable())));
-
- server.stop();
- server.start();
-
- ClientSessionFactory factory = locator.createSessionFactory();
- session = factory.createSession(true, true);
-
- session.start();
- ClientConsumer consumer = session.createConsumer(MDBQUEUEPREFIXED);
- assertNotNull(consumer.receive(5000));
- session.close();
- }
-
- @Test
- @BMRules
- (
- rules =
- {
- @BMRule
- (
- name = "interrupt",
- targetClass = "org.apache.activemq.core.protocol.core.impl.ActiveMQSessionContext",
- targetMethod = "xaEnd",
- targetLocation = "ENTRY",
- action = "org.apache.activemq.byteman.tests.ActiveMQMessageHandlerTest.interrupt();"
- )
- }
- )
- public void testSimpleMessageReceivedOnQueueTwoPhase() throws Exception
- {
- ActiveMQResourceAdapter qResourceAdapter = newResourceAdapter();
- resourceAdapter = qResourceAdapter;
-
- MyBootstrapContext ctx = new MyBootstrapContext();
-
- qResourceAdapter.setConnectorClassName(NETTY_CONNECTOR_FACTORY);
- qResourceAdapter.start(ctx);
-
- ActiveMQActivationSpec spec = new ActiveMQActivationSpec();
- spec.setMaxSession(1);
- spec.setCallTimeout(1000L);
- spec.setResourceAdapter(qResourceAdapter);
- spec.setUseJNDI(false);
- spec.setDestinationType("javax.jms.Queue");
- spec.setDestination(MDBQUEUE);
-
- CountDownLatch latch = new CountDownLatch(1);
-
- XADummyEndpoint endpoint = new XADummyEndpoint(latch, true);
-
- DummyMessageEndpointFactory endpointFactory = new DummyMessageEndpointFactory(endpoint, true);
-
- qResourceAdapter.endpointActivation(endpointFactory, spec);
-
- ClientSession session = locator.createSessionFactory().createSession();
-
- ClientProducer clientProducer = session.createProducer(MDBQUEUEPREFIXED);
-
- ClientMessage message = session.createMessage(true);
-
- message.getBodyBuffer().writeString("teststring");
-
- clientProducer.send(message);
-
- session.close();
-
- latch.await(5, TimeUnit.SECONDS);
-
- assertNotNull(endpoint.lastMessage);
- assertEquals(endpoint.lastMessage.getCoreMessage().getBodyBuffer().readString(), "teststring");
-
- qResourceAdapter.endpointDeactivation(endpointFactory, spec);
-
- qResourceAdapter.stop();
-
- Binding binding = server.getPostOffice().getBinding(SimpleString.toSimpleString(MDBQUEUEPREFIXED));
- assertEquals(1, getMessageCount(((Queue) binding.getBindable())));
-
-
- server.stop();
- server.start();
-
- ClientSessionFactory factory = locator.createSessionFactory();
- session = factory.createSession(true, true);
-
- session.start();
- ClientConsumer consumer = session.createConsumer(MDBQUEUEPREFIXED);
- assertNotNull(consumer.receive(5000));
- session.close();
- }
-
- static volatile ActiveMQResourceAdapter resourceAdapter;
- static boolean resourceAdapterStopped = false;
- public static void interrupt() throws InterruptedException
- {
- //Thread.currentThread().interrupt();
- if (!resourceAdapterStopped)
- {
- resourceAdapter.stop();
- resourceAdapterStopped = true;
- throw new InterruptedException("foo");
- }
- //Thread.currentThread().interrupt();
- }
-
- Transaction currentTX;
-
- public class XADummyEndpoint extends DummyMessageEndpoint
- {
- final boolean twoPhase;
- ClientSession session;
- int afterDeliveryCounts = 0;
-
- public XADummyEndpoint(CountDownLatch latch, boolean twoPhase) throws SystemException
- {
- super(latch);
- this.twoPhase = twoPhase;
- try
- {
- session = locator.createSessionFactory().createSession(true, false, false);
- }
- catch (Throwable e)
- {
- throw new RuntimeException(e);
- }
- }
-
- @Override
- public void beforeDelivery(Method method) throws NoSuchMethodException, ResourceException
- {
- super.beforeDelivery(method);
- try
- {
- DummyTMLocator.tm.begin();
- currentTX = DummyTMLocator.tm.getTransaction();
- currentTX.enlistResource(xaResource);
- if (twoPhase)
- {
- currentTX.enlistResource(new DummyXAResource());
- }
- }
- catch (Throwable e)
- {
- throw new RuntimeException(e.getMessage(), e);
- }
- }
-
- public void onMessage(Message message)
- {
- super.onMessage(message);
-// try
-// {
-// lastMessage = (ActiveMQMessage) message;
-// currentTX.enlistResource(session);
-// ClientProducer prod = session.createProducer()
-// }
-// catch (Exception e)
-// {
-// e.printStackTrace();
-// }
-
-
- }
-
-
-
- @Override
- public void afterDelivery() throws ResourceException
- {
- afterDeliveryCounts++;
- try
- {
- currentTX.commit();
- }
- catch (Throwable e)
- {
- //its unsure as to whether the EJB/JCA layer will handle this or throw it to us,
- // either way we don't do anything else so its fine just to throw.
- // NB this will only happen with 2 phase commit
- throw new RuntimeException(e);
- }
- super.afterDelivery();
- }
- }
-
- @Before
- public void setUp() throws Exception
- {
- resourceAdapter = null;
- resourceAdapterStopped = false;
- super.setUp();
- DummyTMLocator.startTM();
- }
-
-
- @After
- public void tearDown() throws Exception
- {
- DummyTMLocator.stopTM();
- super.tearDown();
- }
-
- public static class DummyTMLocator
- {
- public static TransactionManagerImple tm;
- public static void stopTM()
- {
- try
- {
- TransactionReaper.terminate(true);
- TxControl.disable(true);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- tm = null;
- }
- public static void startTM()
- {
- tm = new TransactionManagerImple();
- TxControl.enable();
- }
- public TransactionManager getTM()
- {
- return tm;
- }
- }
-
- static class DummyXAResource implements XAResource
- {
- @Override
- public void commit(Xid xid, boolean b) throws XAException
- {
-
- }
-
- @Override
- public void end(Xid xid, int i) throws XAException
- {
-
- }
-
- @Override
- public void forget(Xid xid) throws XAException
- {
-
- }
-
- @Override
- public int getTransactionTimeout() throws XAException
- {
- return 0;
- }
-
- @Override
- public boolean isSameRM(XAResource xaResource) throws XAException
- {
- return false;
- }
-
- @Override
- public int prepare(Xid xid) throws XAException
- {
- return 0;
- }
-
- @Override
- public Xid[] recover(int i) throws XAException
- {
- return new Xid[0];
- }
-
- @Override
- public void rollback(Xid xid) throws XAException
- {
-
- }
-
- @Override
- public boolean setTransactionTimeout(int i) throws XAException
- {
- return false;
- }
-
- @Override
- public void start(Xid xid, int i) throws XAException
- {
-
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/BMFailoverTest.java
----------------------------------------------------------------------
diff --git a/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/BMFailoverTest.java b/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/BMFailoverTest.java
deleted file mode 100644
index 49f101f..0000000
--- a/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/BMFailoverTest.java
+++ /dev/null
@@ -1,451 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.byteman.tests;
-
-import javax.transaction.xa.XAException;
-import javax.transaction.xa.XAResource;
-import javax.transaction.xa.Xid;
-
-import org.apache.activemq.api.core.ActiveMQTransactionOutcomeUnknownException;
-import org.apache.activemq.api.core.ActiveMQTransactionRolledBackException;
-import org.apache.activemq.api.core.ActiveMQUnBlockedException;
-import org.apache.activemq.api.core.SimpleString;
-import org.apache.activemq.api.core.TransportConfiguration;
-import org.apache.activemq.api.core.client.ClientConsumer;
-import org.apache.activemq.api.core.client.ClientMessage;
-import org.apache.activemq.api.core.client.ClientProducer;
-import org.apache.activemq.api.core.client.ClientSession;
-import org.apache.activemq.api.core.client.ClientSessionFactory;
-import org.apache.activemq.api.core.client.ServerLocator;
-import org.apache.activemq.core.client.ActiveMQClientMessageBundle;
-import org.apache.activemq.core.client.impl.ClientMessageImpl;
-import org.apache.activemq.core.client.impl.ClientSessionFactoryInternal;
-import org.apache.activemq.core.client.impl.ClientSessionInternal;
-import org.apache.activemq.core.postoffice.Binding;
-import org.apache.activemq.core.server.Queue;
-import org.apache.activemq.core.transaction.impl.XidImpl;
-import org.apache.activemq.tests.integration.cluster.failover.FailoverTestBase;
-import org.apache.activemq.tests.integration.cluster.util.TestableServer;
-import org.apache.activemq.tests.util.RandomUtil;
-import org.apache.activemq.utils.UUIDGenerator;
-import org.jboss.byteman.contrib.bmunit.BMRule;
-import org.jboss.byteman.contrib.bmunit.BMRules;
-import org.jboss.byteman.contrib.bmunit.BMUnitRunner;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * @author <a href="mailto:andy.taylor@jboss.org">Andy Taylor</a>
- * 4/18/13
- */
-@RunWith(BMUnitRunner.class)
-public class BMFailoverTest extends FailoverTestBase
-{
- private ServerLocator locator;
- private ClientSessionFactoryInternal sf;
- private ClientSessionFactoryInternal sf2;
- public static TestableServer serverToStop;
-
- @Before
- @Override
- public void setUp() throws Exception
- {
- super.setUp();
- stopped = false;
- locator = getServerLocator();
- }
-
- @After
- @Override
- public void tearDown() throws Exception
- {
- super.tearDown();
- }
-
- private static boolean stopped = false;
- public static void stopAndThrow() throws ActiveMQUnBlockedException
- {
- if (!stopped)
- {
- try
- {
- serverToStop.getServer().stop(true);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- try
- {
- Thread.sleep(2000);
- }
- catch (InterruptedException e)
- {
- e.printStackTrace();
- }
- stopped = true;
- throw ActiveMQClientMessageBundle.BUNDLE.unblockingACall(null);
- }
- }
- @Test
- @BMRules
- (
- rules =
- {
- @BMRule
- (
- name = "trace ActiveMQSessionContext xaEnd",
- targetClass = "org.apache.activemq.core.protocol.core.impl.ActiveMQSessionContext",
- targetMethod = "xaEnd",
- targetLocation = "AT EXIT",
- action = "org.apache.activemq.byteman.tests.BMFailoverTest.stopAndThrow()"
- )
- }
- )
- //https://bugzilla.redhat.com/show_bug.cgi?id=1152410
- public void testFailOnEndAndRetry() throws Exception
- {
- serverToStop = liveServer;
-
- createSessionFactory();
-
- ClientSession session = createSession(sf, true, false, false);
-
- session.createQueue(FailoverTestBase.ADDRESS, FailoverTestBase.ADDRESS, null, true);
-
- ClientProducer producer = session.createProducer(FailoverTestBase.ADDRESS);
-
- for (int i = 0; i < 100; i++)
- {
- producer.send(createMessage(session, i, true));
- }
-
- ClientConsumer consumer = session.createConsumer(FailoverTestBase.ADDRESS);
-
- Xid xid = RandomUtil.randomXid();
-
- session.start(xid, XAResource.TMNOFLAGS);
- session.start();
- // Receive MSGs but don't ack!
- for (int i = 0; i < 100; i++)
- {
- ClientMessage message = consumer.receive(1000);
-
- Assert.assertNotNull(message);
-
- assertMessageBody(i, message);
-
- Assert.assertEquals(i, message.getIntProperty("counter").intValue());
- }
- try
- {
- //top level prepare
- session.end(xid, XAResource.TMSUCCESS);
- }
- catch (XAException e)
- {
- try
- {
- //top level abort
- session.end(xid, XAResource.TMFAIL);
- }
- catch (XAException e1)
- {
- try
- {
- //rollback
- session.rollback(xid);
- }
- catch (XAException e2)
- {
- }
- }
- }
- xid = RandomUtil.randomXid();
- session.start(xid, XAResource.TMNOFLAGS);
-
- for (int i = 0; i < 50; i++)
- {
- ClientMessage message = consumer.receive(1000);
-
- Assert.assertNotNull(message);
-
- assertMessageBody(i, message);
-
- Assert.assertEquals(i, message.getIntProperty("counter").intValue());
- }
- session.end(xid, XAResource.TMSUCCESS);
- session.commit(xid, true);
- }
-
- @Test
- @BMRules
- (
- rules =
- {
- @BMRule
- (
- name = "trace clientsessionimpl commit",
- targetClass = "org.apache.activemq.core.client.impl.ClientSessionImpl",
- targetMethod = "start(javax.transaction.xa.Xid, int)",
- targetLocation = "AT EXIT",
- action = "org.apache.activemq.byteman.tests.BMFailoverTest.serverToStop.getServer().stop(true)"
- )
- }
- )
- public void testFailoverOnCommit2() throws Exception
- {
- serverToStop = liveServer;
- locator = getServerLocator();
- locator.setFailoverOnInitialConnection(true);
- SimpleString inQueue = new SimpleString("inQueue");
- SimpleString outQueue = new SimpleString("outQueue");
- createSessionFactory();
- createSessionFactory2();
-
- // closeable will take care of closing it
- try (ClientSession session = sf.createSession(false, true, true);
- ClientProducer sendInitialProducer = session.createProducer();)
- {
- session.createQueue(inQueue, inQueue, null, true);
- session.createQueue(outQueue, outQueue, null, true);
- sendInitialProducer.send(inQueue, createMessage(session, 0, true));
- }
-
- ClientSession xaSessionRec = addClientSession(sf.createSession(true, false, false));
-
- ClientConsumer consumer = addClientConsumer(xaSessionRec.createConsumer(inQueue));
-
- byte[] globalTransactionId = UUIDGenerator.getInstance().generateStringUUID().getBytes();
- Xid xidRec = new XidImpl("xa2".getBytes(), 1, globalTransactionId);
-
- xaSessionRec.start();
-
- xaSessionRec.getXAResource().start(xidRec, XAResource.TMNOFLAGS);
-
- //failover is now occurring, receive, ack and end will be called whilst this is happening.
-
- ClientMessageImpl m = (ClientMessageImpl) consumer.receive(5000);
-
- assertNotNull(m);
-
- System.out.println("********************" + m.getIntProperty("counter"));
- //the mdb would ack the message before calling onMessage()
- m.acknowledge();
-
- try
- {
- //this may fail but thats ok, it depends on the race and when failover actually happens
- xaSessionRec.end(xidRec, XAResource.TMSUCCESS);
- }
- catch (XAException ignore)
- {
- }
-
- //we always reset the client on the RA
- ((ClientSessionInternal) xaSessionRec).resetIfNeeded();
-
- // closeable will take care of closing it
- try (ClientSession session = sf.createSession(false, true, true);
- ClientProducer sendInitialProducer = session.createProducer();)
- {
- sendInitialProducer.send(inQueue, createMessage(session, 0, true));
- }
-
- //now receive and send a message successfully
-
- globalTransactionId = UUIDGenerator.getInstance().generateStringUUID().getBytes();
- xidRec = new XidImpl("xa4".getBytes(), 1, globalTransactionId);
- xaSessionRec.getXAResource().start(xidRec, XAResource.TMNOFLAGS);
-
- Binding binding = backupServer.getServer().getPostOffice().getBinding(inQueue);
- Queue inQ = (Queue) binding.getBindable();
-
- m = (ClientMessageImpl) consumer.receive(5000);
-
- assertNotNull(m);
- //the mdb would ack the message before calling onMessage()
- m.acknowledge();
-
- System.out.println("********************" + m.getIntProperty("counter"));
-
- xaSessionRec.getXAResource().end(xidRec, XAResource.TMSUCCESS);
- xaSessionRec.getXAResource().prepare(xidRec);
- xaSessionRec.getXAResource().commit(xidRec, false);
-
-
- //let's close the consumer so anything pending is handled
- consumer.close();
-
- assertEquals(1, getMessageCount(inQ));
- }
-
-
- @Test
- @BMRules
- (
- rules =
- {
- @BMRule
- (
- name = "trace clientsessionimpl commit",
- targetClass = "org.apache.activemq.core.client.impl.ClientSessionImpl",
- targetMethod = "commit",
- targetLocation = "ENTRY",
- action = "org.apache.activemq.byteman.tests.BMFailoverTest.serverToStop.getServer().stop(true)"
- )
- }
- )
- public void testFailoverOnCommit() throws Exception
- {
- serverToStop = liveServer;
- locator = getServerLocator();
- locator.setFailoverOnInitialConnection(true);
- createSessionFactory();
- ClientSession session = createSessionAndQueue();
-
- ClientProducer producer = addClientProducer(session.createProducer(FailoverTestBase.ADDRESS));
-
- sendMessages(session, producer, 10);
- try
- {
- session.commit();
- fail("should have thrown an exception");
- }
- catch (ActiveMQTransactionOutcomeUnknownException e)
- {
- //pass
- }
- sendMessages(session, producer, 10);
- session.commit();
- Queue bindable = (Queue) backupServer.getServer().getPostOffice().getBinding(FailoverTestBase.ADDRESS).getBindable();
- assertEquals(10, getMessageCount(bindable));
- }
-
- @Test
- @BMRules
- (
- rules =
- {
- @BMRule
- (
- name = "trace clientsessionimpl commit",
- targetClass = "org.apache.activemq.core.client.impl.ClientSessionImpl",
- targetMethod = "commit",
- targetLocation = "ENTRY",
- action = "org.apache.activemq.byteman.tests.BMFailoverTest.serverToStop.getServer().stop(true)"
- )
- }
- )
- public void testFailoverOnReceiveCommit() throws Exception
- {
- serverToStop = liveServer;
- locator = getServerLocator();
- locator.setFailoverOnInitialConnection(true);
- createSessionFactory();
- ClientSession session = createSessionAndQueue();
-
- ClientSession sendSession = createSession(sf, true, true);
-
- ClientProducer producer = addClientProducer(sendSession.createProducer(FailoverTestBase.ADDRESS));
-
- sendMessages(sendSession, producer, 10);
-
- ClientConsumer consumer = session.createConsumer(FailoverTestBase.ADDRESS);
- session.start();
- for (int i = 0; i < 10; i++)
- {
- ClientMessage m = consumer.receive(500);
- assertNotNull(m);
- m.acknowledge();
- }
- try
- {
- session.commit();
- fail("should have thrown an exception");
- }
- catch (ActiveMQTransactionOutcomeUnknownException e)
- {
- //pass
- }
- catch (ActiveMQTransactionRolledBackException e1)
- {
- //pass
- }
- Queue bindable = (Queue) backupServer.getServer().getPostOffice().getBinding(FailoverTestBase.ADDRESS).getBindable();
- assertEquals(10, getMessageCount(bindable));
-
- }
-
- @Override
- protected TransportConfiguration getAcceptorTransportConfiguration(final boolean live)
- {
- return getNettyAcceptorTransportConfiguration(live);
- }
-
- @Override
- protected TransportConfiguration getConnectorTransportConfiguration(final boolean live)
- {
- return getNettyConnectorTransportConfiguration(live);
- }
-
- private ClientSession createSessionAndQueue() throws Exception
- {
- ClientSession session = createSession(sf, false, false);
-
- session.createQueue(FailoverTestBase.ADDRESS, FailoverTestBase.ADDRESS, null, true);
- return session;
- }
-
- private ClientSession createXASessionAndQueue() throws Exception
- {
- ClientSession session = addClientSession(sf.createSession(true, true, true));
-
- session.createQueue(FailoverTestBase.ADDRESS, FailoverTestBase.ADDRESS, null, true);
- return session;
- }
-
- protected ClientSession
- createSession(ClientSessionFactory sf1, boolean autoCommitSends, boolean autoCommitAcks) throws Exception
- {
- return addClientSession(sf1.createSession(autoCommitSends, autoCommitAcks));
- }
-
- protected ClientSession
- createSession(ClientSessionFactory sf1, boolean xa, boolean autoCommitSends, boolean autoCommitAcks) throws Exception
- {
- return addClientSession(sf1.createSession(xa, autoCommitSends, autoCommitAcks));
- }
-
-
- private void createSessionFactory() throws Exception
- {
- locator.setBlockOnNonDurableSend(true);
- locator.setBlockOnDurableSend(true);
- locator.setReconnectAttempts(-1);
-
- sf = createSessionFactoryAndWaitForTopology(locator, 2);
- }
-
- private void createSessionFactory2() throws Exception
- {
- sf2 = createSessionFactoryAndWaitForTopology(locator, 2);
- }
-}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/BridgeServerLocatorConfigurationTest.java
----------------------------------------------------------------------
diff --git a/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/BridgeServerLocatorConfigurationTest.java b/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/BridgeServerLocatorConfigurationTest.java
deleted file mode 100644
index 9e166f9..0000000
--- a/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/BridgeServerLocatorConfigurationTest.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.byteman.tests;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.activemq.api.core.TransportConfiguration;
-import org.apache.activemq.api.core.client.ServerLocator;
-import org.apache.activemq.core.config.BridgeConfiguration;
-import org.apache.activemq.core.config.CoreQueueConfiguration;
-import org.apache.activemq.core.remoting.impl.invm.TransportConstants;
-import org.apache.activemq.core.server.ActiveMQServer;
-import org.apache.activemq.core.server.cluster.impl.BridgeImpl;
-import org.apache.activemq.tests.util.ServiceTestBase;
-import org.jboss.byteman.contrib.bmunit.BMRule;
-import org.jboss.byteman.contrib.bmunit.BMUnitRunner;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-@RunWith(BMUnitRunner.class)
-public class BridgeServerLocatorConfigurationTest extends ServiceTestBase
-{
-
- private static final long BRIDGE_TTL = 1234L;
- private static final String BRIDGE_NAME = "bridge1";
-
- protected boolean isNetty()
- {
- return false;
- }
-
- private String getConnector()
- {
- if (isNetty())
- {
- return NETTY_CONNECTOR_FACTORY;
- }
- return INVM_CONNECTOR_FACTORY;
- }
-
- @Test
- @BMRule(name = "check connection ttl",
- targetClass = "org.apache.activemq.byteman.tests.BridgeServerLocatorConfigurationTest",
- targetMethod = "getBridgeTTL(ActiveMQServer, String)", targetLocation = "EXIT",
- action = "$! = $0.getConfiguredBridge($1).serverLocator.getConnectionTTL();")
- /**
- * Checks the connection ttl by using byteman to override the methods on this class to return the value of private variables in the Bridge.
- * @throws Exception
- *
- * The byteman rule on this test overwrites the {@link #getBridgeTTL} method to retrieve the bridge called {@link @BRIDGE_NAME}.
- * It the overrides the return value to be the value of the connection ttl. Note that the unused String parameter is required to
- * ensure that byteman populates the $1 variable, otherwise it will not bind correctly.
- */
- public void testConnectionTTLOnBridge() throws Exception
- {
- Map<String, Object> server0Params = new HashMap<String, Object>();
- ActiveMQServer serverWithBridge = createClusteredServerWithParams(isNetty(), 0, true, server0Params);
-
- Map<String, Object> server1Params = new HashMap<String, Object>();
- if (isNetty())
- {
- server1Params.put("port", org.apache.activemq.core.remoting.impl.netty.TransportConstants.DEFAULT_PORT + 1);
- }
- else
- {
- server1Params.put(TransportConstants.SERVER_ID_PROP_NAME, 1);
- }
- ActiveMQServer server1 = createClusteredServerWithParams(isNetty(), 1, true, server1Params);
- ServerLocator locator = null;
- try
- {
- final String testAddress = "testAddress";
- final String queueName0 = "queue0";
- final String forwardAddress = "forwardAddress";
- final String queueName1 = "queue1";
-
- Map<String, TransportConfiguration> connectors = new HashMap<String, TransportConfiguration>();
- TransportConfiguration server1tc = new TransportConfiguration(getConnector(), server1Params);
- connectors.put(server1tc.getName(), server1tc);
-
- serverWithBridge.getConfiguration().setConnectorConfigurations(connectors);
-
- ArrayList<String> staticConnectors = new ArrayList<String>();
- staticConnectors.add(server1tc.getName());
-
- BridgeConfiguration bridgeConfiguration = new BridgeConfiguration()
- .setName(BRIDGE_NAME)
- .setQueueName(queueName0)
- .setForwardingAddress(forwardAddress)
- .setConnectionTTL(BRIDGE_TTL)
- .setRetryInterval(1000)
- .setReconnectAttempts(0)
- .setReconnectAttemptsOnSameNode(0)
- .setConfirmationWindowSize(1024)
- .setStaticConnectors(staticConnectors);
-
- List<BridgeConfiguration> bridgeConfigs = new ArrayList<BridgeConfiguration>();
- bridgeConfigs.add(bridgeConfiguration);
- serverWithBridge.getConfiguration().setBridgeConfigurations(bridgeConfigs);
-
- CoreQueueConfiguration queueConfig0 = new CoreQueueConfiguration()
- .setAddress(testAddress)
- .setName(queueName0);
- List<CoreQueueConfiguration> queueConfigs0 = new ArrayList<CoreQueueConfiguration>();
- queueConfigs0.add(queueConfig0);
- serverWithBridge.getConfiguration().setQueueConfigurations(queueConfigs0);
-
- CoreQueueConfiguration queueConfig1 = new CoreQueueConfiguration()
- .setAddress(forwardAddress)
- .setName(queueName1);
- List<CoreQueueConfiguration> queueConfigs1 = new ArrayList<CoreQueueConfiguration>();
- queueConfigs1.add(queueConfig1);
- server1.getConfiguration().setQueueConfigurations(queueConfigs1);
-
- server1.start();
- waitForServer(server1);
-
- serverWithBridge.start();
- waitForServer(serverWithBridge);
-
- long bridgeTTL = getBridgeTTL(serverWithBridge, BRIDGE_NAME);
-
- assertEquals(BRIDGE_TTL, bridgeTTL);
- }
- finally
- {
- if (locator != null)
- {
- locator.close();
- }
-
- serverWithBridge.stop();
-
- server1.stop();
- }
- }
-
- /**
- * Method for byteman to wrap around and do its magic with to return the ttl from private members
- * rather than -1
- * @param bridgeServer
- * @param bridgeName
- * @return
- */
- private long getBridgeTTL(ActiveMQServer bridgeServer, String bridgeName)
- {
- return -1L;
- }
-
- /**
- * Byteman seems to need this method so that it gets back the concrete type not the interface
- * @param bridgeServer
- * @return
- */
- private BridgeImpl getConfiguredBridge(ActiveMQServer bridgeServer)
- {
- return getConfiguredBridge(bridgeServer, BRIDGE_NAME);
- }
-
- private BridgeImpl getConfiguredBridge(ActiveMQServer bridgeServer, String bridgeName)
- {
- return (BridgeImpl)bridgeServer.getClusterManager().getBridges().get(bridgeName);
- }
-}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/ClosingConnectionTest.java
----------------------------------------------------------------------
diff --git a/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/ClosingConnectionTest.java b/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/ClosingConnectionTest.java
deleted file mode 100644
index cd804e1..0000000
--- a/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/ClosingConnectionTest.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.byteman.tests;
-
-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
-
-import org.apache.activemq.api.core.SimpleString;
-import org.apache.activemq.api.core.client.ClientMessage;
-import org.apache.activemq.api.core.client.ClientProducer;
-import org.apache.activemq.api.core.client.ClientSession;
-import org.apache.activemq.api.core.client.ClientSessionFactory;
-import org.apache.activemq.api.core.client.ServerLocator;
-import org.apache.activemq.api.core.management.ActiveMQServerControl;
-import org.apache.activemq.core.server.ActiveMQServer;
-import org.apache.activemq.core.server.JournalType;
-import org.apache.activemq.core.settings.impl.AddressSettings;
-import org.apache.activemq.tests.integration.IntegrationTestLogger;
-import org.apache.activemq.tests.integration.management.ManagementControlHelper;
-import org.apache.activemq.tests.util.ServiceTestBase;
-import org.jboss.byteman.contrib.bmunit.BMRule;
-import org.jboss.byteman.contrib.bmunit.BMRules;
-import org.jboss.byteman.contrib.bmunit.BMUnitRunner;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-@RunWith(BMUnitRunner.class)
-public class ClosingConnectionTest extends ServiceTestBase
-{
- public static final SimpleString ADDRESS = new SimpleString("SimpleAddress");
-
- private ServerLocator locator;
-
- private ActiveMQServer server;
-
- private static MBeanServer mBeanServer;
-
- private static boolean readyToKill = false;
-
- protected boolean isNetty()
- {
- return true;
- }
-
-
- @Override
- @Before
- public void setUp() throws Exception
- {
- super.setUp();
- mBeanServer = MBeanServerFactory.createMBeanServer();
- server = newActiveMQServer();
- server.getConfiguration().setJournalType(JournalType.NIO);
- server.getConfiguration().setJMXManagementEnabled(true);
- server.start();
- waitForServer(server);
- locator = createFactory(isNetty());
- readyToKill = false;
- }
-
- public static void killConnection() throws InterruptedException
- {
- if (readyToKill)
- {
- // We have to kill the connection in a new thread otherwise Netty won't interrupt the current thread
- Thread closeConnectionThread = new Thread(new Runnable()
- {
- @Override
- public void run()
- {
- try
- {
- ActiveMQServerControl serverControl = ManagementControlHelper.createActiveMQServerControl(mBeanServer);
- serverControl.closeConnectionsForUser("guest");
- readyToKill = false;
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- });
-
- closeConnectionThread.start();
-
- try
- {
- /* We want to simulate a long-running remoting thread here. If closing the connection in the closeConnectionThread
- * interrupts this thread then it will cause sleep() to throw and InterruptedException. Therefore we catch
- * the InterruptedException and re-interrupt the current thread so the interrupt will be passed properly
- * back to the caller. It's a bit of a hack, but I couldn't find any other way to simulate it.
- */
- Thread.sleep(1500);
- }
- catch (InterruptedException e)
- {
- Thread.currentThread().interrupt();
- }
- }
- }
-
- /*
- * Test for https://bugzilla.redhat.com/show_bug.cgi?id=1193085
- * */
- @Test
- @BMRules
- (
- rules =
- {
- @BMRule
- (
- name = "rule to kill connection",
- targetClass = "org.apache.activemq.core.journal.impl.NIOSequentialFile",
- targetMethod = "open(int, boolean)",
- targetLocation = "AT INVOKE java.nio.channels.FileChannel.size()",
- action = "org.apache.activemq.byteman.tests.ClosingConnectionTest.killConnection();"
-
- )
- }
- )
- public void testKillConnection() throws Exception
- {
- locator.setBlockOnNonDurableSend(true);
- locator.setBlockOnDurableSend(true);
- locator.setBlockOnAcknowledge(true);
-
- ClientSessionFactory sf = createSessionFactory(locator);
- ClientSession session = sf.createSession("guest", null, false, true, true, false, 0);
-
- session.createQueue(ADDRESS, ADDRESS, null, true);
-
- ClientProducer producer = session.createProducer(ADDRESS);
-
- ClientMessage message = session.createMessage(true);
- message.getBodyBuffer().writeBytes(new byte[1024]);
-
- for (int i = 0; i < 200; i++)
- {
- producer.send(message);
- }
-
- assertTrue(server.locateQueue(ADDRESS).getPageSubscription().getPagingStore().isPaging());
-
- readyToKill = true;
- try
- {
- for (int i = 0; i < 8; i++)
- {
- producer.send(message);
- }
- fail("Sending message here should result in failure.");
- }
- catch (Exception e)
- {
- IntegrationTestLogger.LOGGER.info("Caught exception: " + e.getMessage());
- }
-
- Thread.sleep(1000);
-
- assertTrue(server.isStarted());
-
- session.close();
- }
-
- private ActiveMQServer newActiveMQServer() throws Exception
- {
- ActiveMQServer server = createServer(true, createDefaultConfig(isNetty()), mBeanServer);
-
- AddressSettings defaultSetting = new AddressSettings();
- defaultSetting.setPageSizeBytes(10 * 1024);
- defaultSetting.setMaxSizeBytes(20 * 1024);
-
- server.getAddressSettingsRepository().addMatch("#", defaultSetting);
-
- return server;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/ClusteredGroupingTest.java
----------------------------------------------------------------------
diff --git a/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/ClusteredGroupingTest.java b/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/ClusteredGroupingTest.java
deleted file mode 100644
index f74d816..0000000
--- a/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/ClusteredGroupingTest.java
+++ /dev/null
@@ -1,473 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.byteman.tests;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.activemq.api.core.ActiveMQNonExistentQueueException;
-import org.apache.activemq.api.core.Message;
-import org.apache.activemq.api.core.SimpleString;
-import org.apache.activemq.api.core.management.ManagementHelper;
-import org.apache.activemq.api.core.management.CoreNotificationType;
-import org.apache.activemq.core.server.ActiveMQServer;
-import org.apache.activemq.core.server.group.impl.GroupingHandlerConfiguration;
-import org.apache.activemq.core.server.group.impl.Response;
-import org.apache.activemq.core.server.management.Notification;
-import org.apache.activemq.tests.integration.cluster.distribution.ClusterTestBase;
-import org.jboss.byteman.contrib.bmunit.BMRule;
-import org.jboss.byteman.contrib.bmunit.BMRules;
-import org.jboss.byteman.contrib.bmunit.BMUnitRunner;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * @author <a href="mailto:andy.taylor@jboss.org">Andy Taylor</a>
- */
-@RunWith(BMUnitRunner.class)
-public class ClusteredGroupingTest extends ClusterTestBase
-{
- @Test
- @BMRules
- (
- rules =
- {
- @BMRule
- (
- name = "blow-up",
- targetClass = "org.apache.activemq.core.server.group.impl.LocalGroupingHandler",
- targetMethod = "removeGrouping",
- targetLocation = "ENTRY",
- action = "org.apache.activemq.byteman.tests.ClusteredGroupingTest.pause($1);"
- ),
- @BMRule
- (
- name = "blow-up2",
- targetClass = "org.apache.activemq.core.server.group.impl.GroupHandlingAbstract",
- targetMethod = "forceRemove",
- targetLocation = "ENTRY",
- action = "org.apache.activemq.byteman.tests.ClusteredGroupingTest.restart2();"
- )
- }
- )
- public void test2serversLocalGoesDown() throws Exception
- {
- setupServer(0, isFileStorage(), isNetty());
- setupServer(1, isFileStorage(), isNetty());
-
- setupClusterConnection("cluster0", "queues", false, 1, 0, 500, isNetty(), 0, 1);
-
- setupClusterConnection("cluster1", "queues", false, 1, 0, 500, isNetty(), 1, 0);
-
- setUpGroupHandler(GroupingHandlerConfiguration.TYPE.LOCAL, 0);
- setUpGroupHandler(GroupingHandlerConfiguration.TYPE.REMOTE, 1);
-
- startServers(0, 1);
-
- setupSessionFactory(0, isNetty());
- setupSessionFactory(1, isNetty());
-
- createQueue(0, "queues.testaddress", "queue0", null, true);
- createQueue(1, "queues.testaddress", "queue0", null, true);
-
- addConsumer(0, 1, "queue0", null);
-
- waitForBindings(0, "queues.testaddress", 1, 0, true);
- waitForBindings(1, "queues.testaddress", 1, 1, true);
-
- waitForBindings(0, "queues.testaddress", 1, 1, false);
- waitForBindings(1, "queues.testaddress", 1, 0, false);
-
- sendWithProperty(0, "queues.testaddress", 1, true, Message.HDR_GROUP_ID, new SimpleString("id1"));
-
- latch = new CountDownLatch(1);
- latch2 = new CountDownLatch(1);
-
- crashAndWaitForFailure(getServer(1));
-
- assertTrue(latch2.await(20000, TimeUnit.MILLISECONDS));
-
- try
- {
- try
- {
- sendWithProperty(0, "queues.testaddress", 1, true, Message.HDR_GROUP_ID, new SimpleString("id1"));
- }
- catch (ActiveMQNonExistentQueueException e)
- {
- fail("did not handle removal of queue");
- }
- }
- finally
- {
- latch.countDown();
- }
- }
-
- @Test
- @BMRules
- (
- rules =
- {
- @BMRule
- (
- name = "blow-up",
- targetClass = "org.apache.activemq.core.server.group.impl.RemoteGroupingHandler",
- targetMethod = "onNotification",
- targetLocation = "ENTRY",
- action = "org.apache.activemq.byteman.tests.ClusteredGroupingTest.pause2($1);"
- ),
- @BMRule(name = "blow-up2",
- targetClass = "org.apache.activemq.core.server.group.impl.RemoteGroupingHandler",
- targetMethod = "remove",
- targetLocation = "ENTRY",
- action = "org.apache.activemq.byteman.tests.ClusteredGroupingTest.restart2();")
- }
- )
- public void test3serversLocalGoesDown() throws Exception
- {
- setupServer(0, isFileStorage(), isNetty());
- setupServer(1, isFileStorage(), isNetty());
- setupServer(2, isFileStorage(), isNetty());
-
- setupClusterConnection("cluster0", "queues", false, 1, 0, 500, isNetty(), 0, 1, 2);
-
- setupClusterConnection("cluster1", "queues", false, 1, 0, 500, isNetty(), 1, 0, 2);
-
- setupClusterConnection("cluster2", "queues", false, 1, 0, 500, isNetty(), 2, 0, 1);
-
- setUpGroupHandler(GroupingHandlerConfiguration.TYPE.LOCAL, 0);
- setUpGroupHandler(GroupingHandlerConfiguration.TYPE.REMOTE, 1);
- setUpGroupHandler(GroupingHandlerConfiguration.TYPE.REMOTE, 2);
-
- startServers(0, 1, 2);
-
- setupSessionFactory(0, isNetty());
- setupSessionFactory(1, isNetty());
- setupSessionFactory(2, isNetty());
-
- createQueue(0, "queues.testaddress", "queue0", null, true);
- createQueue(1, "queues.testaddress", "queue0", null, true);
- createQueue(2, "queues.testaddress", "queue0", null, true);
-
- addConsumer(0, 2, "queue0", null);
-
- waitForBindings(0, "queues.testaddress", 1, 0, true);
- waitForBindings(1, "queues.testaddress", 1, 0, true);
- waitForBindings(2, "queues.testaddress", 1, 1, true);
-
- waitForBindings(0, "queues.testaddress", 2, 1, false);
- waitForBindings(1, "queues.testaddress", 2, 1, false);
- waitForBindings(2, "queues.testaddress", 2, 0, false);
-
- sendWithProperty(1, "queues.testaddress", 1, true, Message.HDR_GROUP_ID, new SimpleString("id1"));
-
- latch = new CountDownLatch(1);
- latch2 = new CountDownLatch(1);
-
- main = Thread.currentThread();
- crashAndWaitForFailure(getServer(2));
-
- assertTrue(latch2.await(20000, TimeUnit.MILLISECONDS));
-
- try
- {
- try
- {
- sendWithProperty(1, "queues.testaddress", 1, true, Message.HDR_GROUP_ID, new SimpleString("id1"));
- }
- catch (ActiveMQNonExistentQueueException e)
- {
- fail("did not handle removal of queue");
- }
- }
- finally
- {
- latch.countDown();
- }
-
- assertHandlersAreSame(getServer(0), getServer(1));
- }
-
- @Test
- @BMRules
- (
- rules =
- {
- @BMRule
- (
- name = "blow-up",
- targetClass = "org.apache.activemq.core.server.group.impl.LocalGroupingHandler",
- targetMethod = "onNotification",
- targetLocation = "ENTRY",
- action = "org.apache.activemq.byteman.tests.ClusteredGroupingTest.pause2($1);"
- ),
- @BMRule(name = "blow-up2",
- targetClass = "org.apache.activemq.core.server.group.impl.LocalGroupingHandler",
- targetMethod = "remove",
- targetLocation = "ENTRY",
- action = "org.apache.activemq.byteman.tests.ClusteredGroupingTest.restart2();")
- }
- )
- public void testLocal3serversLocalGoesDown() throws Exception
- {
- setupServer(0, isFileStorage(), isNetty());
- setupServer(1, isFileStorage(), isNetty());
- setupServer(2, isFileStorage(), isNetty());
-
- setupClusterConnection("cluster0", "queues", false, 1, 0, 500, isNetty(), 0, 1, 2);
-
- setupClusterConnection("cluster1", "queues", false, 1, 0, 500, isNetty(), 1, 0, 2);
-
- setupClusterConnection("cluster2", "queues", false, 1, 0, 500, isNetty(), 2, 0, 1);
-
- setUpGroupHandler(GroupingHandlerConfiguration.TYPE.LOCAL, 0);
- setUpGroupHandler(GroupingHandlerConfiguration.TYPE.REMOTE, 1);
- setUpGroupHandler(GroupingHandlerConfiguration.TYPE.REMOTE, 2);
-
- startServers(0, 1, 2);
-
- setupSessionFactory(0, isNetty());
- setupSessionFactory(1, isNetty());
- setupSessionFactory(2, isNetty());
-
- createQueue(0, "queues.testaddress", "queue0", null, true);
- createQueue(1, "queues.testaddress", "queue0", null, true);
- createQueue(2, "queues.testaddress", "queue0", null, true);
-
- addConsumer(0, 2, "queue0", null);
-
- waitForBindings(0, "queues.testaddress", 1, 0, true);
- waitForBindings(1, "queues.testaddress", 1, 0, true);
- waitForBindings(2, "queues.testaddress", 1, 1, true);
-
- waitForBindings(0, "queues.testaddress", 2, 1, false);
- waitForBindings(1, "queues.testaddress", 2, 1, false);
- waitForBindings(2, "queues.testaddress", 2, 0, false);
-
- sendWithProperty(0, "queues.testaddress", 1, true, Message.HDR_GROUP_ID, new SimpleString("id1"));
-
- latch = new CountDownLatch(1);
- latch2 = new CountDownLatch(1);
-
- main = Thread.currentThread();
- crashAndWaitForFailure(getServer(2));
-
- assertTrue(latch2.await(20000, TimeUnit.MILLISECONDS));
-
- try
- {
- try
- {
- sendWithProperty(0, "queues.testaddress", 1, true, Message.HDR_GROUP_ID, new SimpleString("id1"));
- }
- catch (ActiveMQNonExistentQueueException e)
- {
- fail("did not handle removal of queue");
- }
- }
- finally
- {
- latch.countDown();
- }
-
- assertHandlersAreSame(getServer(0), getServer(1));
- }
-
- @Test
- @BMRules
- (
- rules =
- {
- @BMRule
- (
- name = "blow-up",
- targetClass = "org.apache.activemq.core.server.group.impl.LocalGroupingHandler",
- targetMethod = "onNotification",
- targetLocation = "ENTRY",
- action = "org.apache.activemq.byteman.tests.ClusteredGroupingTest.pause2($1);"
- ),
- @BMRule(name = "blow-up2",
- targetClass = "org.apache.activemq.core.server.group.impl.LocalGroupingHandler",
- targetMethod = "remove",
- targetLocation = "ENTRY",
- action = "org.apache.activemq.byteman.tests.ClusteredGroupingTest.restart2();")
- }
- )
- public void testLocal4serversLocalGoesDown() throws Exception
- {
- setupServer(0, isFileStorage(), isNetty());
- setupServer(1, isFileStorage(), isNetty());
- setupServer(2, isFileStorage(), isNetty());
- setupServer(3, isFileStorage(), isNetty());
-
- setupClusterConnection("cluster0", "queues", false, 1, 0, 500, isNetty(), 0, 1, 2, 3);
-
- setupClusterConnection("cluster1", "queues", false, 1, 0, 500, isNetty(), 1, 0, 2, 3);
-
- setupClusterConnection("cluster2", "queues", false, 1, 0, 500, isNetty(), 2, 0, 1, 3);
-
- setupClusterConnection("cluster3", "queues", false, 1, 0, 500, isNetty(), 3, 1, 2, 3);
-
- setUpGroupHandler(GroupingHandlerConfiguration.TYPE.LOCAL, 0);
- setUpGroupHandler(GroupingHandlerConfiguration.TYPE.REMOTE, 1);
- setUpGroupHandler(GroupingHandlerConfiguration.TYPE.REMOTE, 2);
- setUpGroupHandler(GroupingHandlerConfiguration.TYPE.REMOTE, 3);
-
- startServers(0, 1, 2, 3);
-
- setupSessionFactory(0, isNetty());
- setupSessionFactory(1, isNetty());
- setupSessionFactory(2, isNetty());
- setupSessionFactory(3, isNetty());
-
- createQueue(0, "queues.testaddress", "queue0", null, true);
- createQueue(1, "queues.testaddress", "queue0", null, true);
- createQueue(2, "queues.testaddress", "queue0", null, true);
- createQueue(3, "queues.testaddress", "queue0", null, true);
-
- addConsumer(0, 2, "queue0", null);
-
- waitForBindings(0, "queues.testaddress", 1, 0, true);
- waitForBindings(1, "queues.testaddress", 1, 0, true);
- waitForBindings(2, "queues.testaddress", 1, 1, true);
- waitForBindings(3, "queues.testaddress", 1, 0, true);
-
- waitForBindings(0, "queues.testaddress", 3, 1, false);
- waitForBindings(1, "queues.testaddress", 3, 1, false);
- waitForBindings(2, "queues.testaddress", 3, 0, false);
- waitForBindings(3, "queues.testaddress", 3, 1, false);
-
- sendWithProperty(0, "queues.testaddress", 1, true, Message.HDR_GROUP_ID, new SimpleString("id1"));
-
- latch = new CountDownLatch(1);
- latch2 = new CountDownLatch(1);
-
- main = Thread.currentThread();
- crashAndWaitForFailure(getServer(2));
-
- assertTrue(latch2.await(20000, TimeUnit.MILLISECONDS));
-
- try
- {
- try
- {
- sendWithProperty(0, "queues.testaddress", 1, true, Message.HDR_GROUP_ID, new SimpleString("id1"));
- }
- catch (ActiveMQNonExistentQueueException e)
- {
- fail("did not handle removal of queue");
- }
- }
- finally
- {
- latch.countDown();
- }
- //now restart server
- getServer(2).start();
- waitForBindings(2, "queues.testaddress", 1, 0, true);
- waitForBindings(2, "queues.testaddress", 3, 0, false);
- sendWithProperty(3, "queues.testaddress", 1, true, Message.HDR_GROUP_ID, new SimpleString("id1"));
- Thread.sleep(2000);
- assertHandlersAreSame(getServer(0), getServer(1), getServer(2), getServer(3));
- }
-
- private void assertHandlersAreSame(ActiveMQServer server, ActiveMQServer... qServers)
- {
- SimpleString id = server.getGroupingHandler().getProposal(new SimpleString("id1.queue0"), false).getClusterName();
- for (ActiveMQServer qServer : qServers)
- {
- Response proposal = qServer.getGroupingHandler().getProposal(new SimpleString("id1.queue0"), false);
- if (proposal != null)
- {
- assertEquals(qServer.getIdentity() + " is incorrect", id, proposal.getChosenClusterName());
- }
- }
- }
-
- static CountDownLatch latch;
- static CountDownLatch latch2;
- static Thread main;
-
- public static void pause(SimpleString clusterName)
- {
- if (clusterName.toString().startsWith("queue0"))
- {
- try
- {
- latch2.countDown();
- latch.await();
- }
- catch (InterruptedException e)
- {
- e.printStackTrace();
- }
- }
- }
-
- public static void pause2(Notification notification)
- {
- if (notification.getType() == CoreNotificationType.BINDING_REMOVED)
- {
- SimpleString clusterName = notification.getProperties()
- .getSimpleStringProperty(ManagementHelper.HDR_CLUSTER_NAME);
- boolean inMain = main == Thread.currentThread();
- if (clusterName.toString().startsWith("queue0") && !inMain)
- {
- try
- {
- latch2.countDown();
- latch.await();
- }
- catch (InterruptedException e)
- {
- e.printStackTrace();
- }
- }
- }
- }
-
- public static void restart2()
- {
- latch.countDown();
- }
-
-
- @Override
- @Before
- public void setUp() throws Exception
- {
- super.setUp();
- }
-
- @Override
- @After
- public void tearDown() throws Exception
- {
- closeAllConsumers();
- closeAllSessionFactories();
- closeAllServerLocatorsFactories();
- super.tearDown();
- }
-
- public boolean isNetty()
- {
- return true;
- }
-}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/GroupingTest.java
----------------------------------------------------------------------
diff --git a/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/GroupingTest.java b/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/GroupingTest.java
deleted file mode 100644
index 31d2ba8..0000000
--- a/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/GroupingTest.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.byteman.tests;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.JMSException;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-
-import org.apache.activemq.api.core.ActiveMQNotConnectedException;
-import org.apache.activemq.jms.client.ActiveMQConnectionFactory;
-import org.apache.activemq.spi.core.protocol.RemotingConnection;
-import org.apache.activemq.tests.util.JMSTestBase;
-import org.jboss.byteman.contrib.bmunit.BMRule;
-import org.jboss.byteman.contrib.bmunit.BMRules;
-import org.jboss.byteman.contrib.bmunit.BMUnitRunner;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * GroupingTest
- *
- * @author Andy Taylor
- */
-@RunWith(BMUnitRunner.class)
-public class GroupingTest extends JMSTestBase
-{
- private Queue queue;
- static boolean pause = false;
-
- @Before
- @Override
- public void setUp() throws Exception
- {
- super.setUp();
-
- queue = createQueue("TestQueue");
- }
-
- @After
- @Override
- public void tearDown() throws Exception
- {
- super.tearDown();
- }
-
- protected ConnectionFactory getCF() throws Exception
- {
- return cf;
- }
-
-
- @Test
- @BMRules
- (
- rules =
- {
- @BMRule
- (
- name = "trace clientsessionimpl commit",
- targetClass = "org.apache.activemq.core.server.impl.ServerSessionImpl",
- targetMethod = "rollback",
- targetLocation = "EXIT",
- action = "org.apache.activemq.byteman.tests.GroupingTest.pause();"
- )
- }
- )
- public void testGroupingRollbackOnClose() throws Exception
- {
- Connection sendConnection = null;
- Connection connection = null;
- Connection connection2 = null;
- try
- {
- ActiveMQConnectionFactory fact = (ActiveMQConnectionFactory) getCF();
- fact.setReconnectAttempts(0);
- //fact.setConsumerWindowSize(1000);
- //fact.setTransactionBatchSize(0);
- connection = fact.createConnection();
- RemotingConnection rc = server.getRemotingService().getConnections().iterator().next();
- connection2 = fact.createConnection();
- sendConnection = fact.createConnection();
-
- final Session sendSession = sendConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
- Session session2 = connection2.createSession(true, Session.SESSION_TRANSACTED);
-
- final MessageProducer producer = sendSession.createProducer(queue);
-
- MessageConsumer consumer1 = session.createConsumer(queue);
- MessageConsumer consumer2 = session2.createConsumer(queue);
-
- connection.start();
- connection2.start();
-
- final String jmsxgroupID = null;
-
- Thread t = new Thread(new Runnable()
- {
- @Override
- public void run()
- {
-
- try
- {
- for (int j = 0; j < 10000; j++)
- {
- TextMessage message = sendSession.createTextMessage();
-
- message.setText("Message" + j);
-
- message.setStringProperty("JMSXGroupID", "foo");
-
- producer.send(message);
- }
- }
- catch (JMSException e)
- {
- e.printStackTrace();
- }
- }
- });
- t.start();
-
- //consume 5 msgs from 1st first consumer
- for (int j = 0; j < 5; j++)
- {
- TextMessage tm = (TextMessage) consumer1.receive(10000);
-
- assertNotNull(tm);
-
- assertEquals("Message" + j, tm.getText());
-
- assertEquals(tm.getStringProperty("JMSXGroupID"), "foo");
- }
-
- pause = true;
- rc.fail(new ActiveMQNotConnectedException());
- pause = false;
-
- for (int j = 0; j < 10000; j++)
- {
- TextMessage tm = (TextMessage) consumer2.receive(5000);
-
- assertNotNull(tm);
-
- assertEquals("Message" + j, tm.getText());
-
- assertEquals(tm.getStringProperty("JMSXGroupID"), "foo");
- }
- }
- finally
- {
- if (sendConnection != null)
- {
- sendConnection.close();
- }
- if (connection2 != null)
- {
- connection2.close();
- }
- }
- }
-
-
- public static void pause()
- {
- if (pause)
- {
- try
- {
- System.out.println("pausing after rollback");
- Thread.sleep(500);
- }
- catch (InterruptedException e)
- {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- }
- System.out.println("finished pausing after rollback");
- }
- }
-}
[13/15] activemq-6 git commit: Refactored the testsuite a bit
Posted by jb...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/JMSBridgeReconnectionTest.java
----------------------------------------------------------------------
diff --git a/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/JMSBridgeReconnectionTest.java b/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/JMSBridgeReconnectionTest.java
deleted file mode 100644
index 249e70c..0000000
--- a/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/JMSBridgeReconnectionTest.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.byteman.tests;
-
-import org.apache.activemq.core.client.impl.ClientProducerCredits;
-import org.apache.activemq.core.message.impl.MessageInternal;
-import org.apache.activemq.core.protocol.core.Packet;
-import org.apache.activemq.core.protocol.core.impl.PacketImpl;
-import org.apache.activemq.core.protocol.core.impl.wireformat.SessionSendMessage;
-import org.apache.activemq.jms.bridge.ConnectionFactoryFactory;
-import org.apache.activemq.jms.bridge.QualityOfServiceMode;
-import org.apache.activemq.jms.bridge.impl.JMSBridgeImpl;
-import org.apache.activemq.jms.server.JMSServerManager;
-import org.apache.activemq.tests.integration.jms.bridge.BridgeTestBase;
-import org.jboss.byteman.contrib.bmunit.BMRule;
-import org.jboss.byteman.contrib.bmunit.BMRules;
-import org.jboss.byteman.contrib.bmunit.BMUnitRunner;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-@RunWith(BMUnitRunner.class)
-public class JMSBridgeReconnectionTest extends BridgeTestBase
-{
-
- @Test
- @BMRules
- (
- rules =
- {
- @BMRule
- (
- name = "trace clientsessionimpl send",
- targetClass = "org.apache.activemq.core.protocol.core.impl.ChannelImpl",
- targetMethod = "send",
- targetLocation = "ENTRY",
- action = "org.apache.activemq.byteman.tests.JMSBridgeReconnectionTest.pause($1);"
- ),
- @BMRule
- (
- name = "trace sendRegularMessage",
- targetClass = "org.apache.activemq.core.client.impl.ClientProducerImpl",
- targetMethod = "sendRegularMessage",
- targetLocation = "ENTRY",
- action = "org.apache.activemq.byteman.tests.JMSBridgeReconnectionTest.pause2($1,$2,$3);"
- )
- }
- )
- public void performCrashDestinationStopBridge() throws Exception
- {
- activeMQServer = jmsServer1;
- ConnectionFactoryFactory factInUse0 = cff0;
- ConnectionFactoryFactory factInUse1 = cff1;
- final JMSBridgeImpl bridge =
- new JMSBridgeImpl(factInUse0,
- factInUse1,
- sourceQueueFactory,
- targetQueueFactory,
- null,
- null,
- null,
- null,
- null,
- 1000,
- -1,
- QualityOfServiceMode.DUPLICATES_OK,
- 10,
- -1,
- null,
- null,
- false);
-
- addActiveMQComponent(bridge);
- bridge.setTransactionManager(newTransactionManager());
- bridge.start();
- final CountDownLatch latch = new CountDownLatch(20);
- Thread clientThread = new Thread(new Runnable()
- {
- @Override
- public void run()
- {
- while (bridge.isStarted())
- {
- try
- {
- sendMessages(cf0, sourceQueue, 0, 1, false, false);
- latch.countDown();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- }
- });
-
- clientThread.start();
-
- stopLatch.await(10000, TimeUnit.MILLISECONDS);
-
- bridge.stop();
-
- clientThread.join(5000);
-
- assertTrue(!clientThread.isAlive());
- }
-
- public static void pause(Packet packet)
- {
- if (packet.getType() == PacketImpl.SESS_SEND)
- {
- SessionSendMessage sendMessage = (SessionSendMessage) packet;
- if (sendMessage.getMessage().containsProperty("__HQ_CID") && count < 0 && !stopped)
- {
- try
- {
- activeMQServer.stop();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- stopped = true;
- try
- {
- Thread.sleep(5000);
- }
- catch (InterruptedException e)
- {
- e.printStackTrace();
- }
- stopLatch.countDown();
- }
- }
- }
-
- static JMSServerManager activeMQServer;
- static boolean stopped = false;
- static int count = 20;
- static CountDownLatch stopLatch = new CountDownLatch(1);
- public static void pause2(MessageInternal msgI, boolean sendBlocking, final ClientProducerCredits theCredits)
- {
- if (msgI.containsProperty("__HQ_CID"))
- {
- count--;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/LatencyTest.java
----------------------------------------------------------------------
diff --git a/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/LatencyTest.java b/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/LatencyTest.java
deleted file mode 100644
index 1286cd1..0000000
--- a/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/LatencyTest.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.byteman.tests;
-
-import org.apache.activemq.api.core.client.ClientSession;
-import org.apache.activemq.api.core.client.ClientSessionFactory;
-import org.apache.activemq.api.core.client.ServerLocator;
-import org.apache.activemq.core.server.ActiveMQServer;
-import org.apache.activemq.tests.util.ServiceTestBase;
-import org.jboss.byteman.contrib.bmunit.BMRule;
-import org.jboss.byteman.contrib.bmunit.BMRules;
-import org.jboss.byteman.contrib.bmunit.BMUnitRunner;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-@RunWith(BMUnitRunner.class)
-public class LatencyTest extends ServiceTestBase
-{
- /*
- * simple test to make sure connect still works with some network latency built into netty
- * */
- @Test
- @BMRules
- (
- rules =
- {
- @BMRule
- (
- name = "trace ClientBootstrap.connect",
- targetClass = "org.jboss.netty.bootstrap.ClientBootstrap",
- targetMethod = "connect",
- targetLocation = "ENTRY",
- action = "System.out.println(\"netty connecting\")"
- ),
- @BMRule
- (
- name = "sleep OioWorker.run",
- targetClass = "org.jboss.netty.channel.socket.oio.OioWorker",
- targetMethod = "run",
- targetLocation = "ENTRY",
- action = "Thread.sleep(500)"
- )
- }
- )
- public void testLatency() throws Exception
- {
- ActiveMQServer server = createServer(createDefaultConfig(true));
- server.start();
- ServerLocator locator = createNettyNonHALocator();
- ClientSessionFactory factory = createSessionFactory(locator);
- ClientSession session = factory.createSession();
- session.close();
- server.stop();
- }
-}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/MessageCopyTest.java
----------------------------------------------------------------------
diff --git a/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/MessageCopyTest.java b/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/MessageCopyTest.java
deleted file mode 100644
index 8614971..0000000
--- a/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/MessageCopyTest.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.byteman.tests;
-
-import java.util.ArrayList;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.apache.activemq.api.core.ActiveMQBuffer;
-import org.apache.activemq.api.core.SimpleString;
-import org.apache.activemq.core.protocol.core.impl.wireformat.SessionSendMessage;
-import org.apache.activemq.core.server.impl.ServerMessageImpl;
-import org.apache.activemq.tests.util.RandomUtil;
-import org.jboss.byteman.contrib.bmunit.BMRule;
-import org.jboss.byteman.contrib.bmunit.BMRules;
-import org.jboss.byteman.contrib.bmunit.BMUnitRunner;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * @author Clebert Suconic
- */
-@RunWith(BMUnitRunner.class)
-public class MessageCopyTest
-{
- @Test
- @BMRules
- (
-
- rules =
- {
- @BMRule
- (
- name = "message-copy0",
- targetClass = "org.apache.activemq.core.server.impl.ServerMessageImpl",
- targetMethod = "copy()",
- targetLocation = "ENTRY",
- action = "System.out.println(\"copy\"), waitFor(\"encode-done\")"
- ),
- @BMRule
- (
- name = "message-copy-done",
- targetClass = "org.apache.activemq.core.protocol.core.impl.wireformat.SessionSendMessage",
- targetMethod = "encode(org.apache.activemq.spi.core.protocol.RemotingConnection)",
- targetLocation = "EXIT",
- action = "System.out.println(\"encodeDone\"), signalWake(\"encode-done\", true)"
- ),
- @BMRule
- (
- name = "message-copy1",
- targetClass = "org.apache.activemq.core.buffers.impl.ChannelBufferWrapper",
- targetMethod = "copy(int, int)",
- condition = "Thread.currentThread().getName().equals(\"T1\")",
- targetLocation = "EXIT",
- action = "System.out.println(\"setIndex at \" + Thread.currentThread().getName()), waitFor(\"finish-read\")"
- ),
- @BMRule(
- name = "JMSServer.stop wait-init",
- targetClass = "org.apache.activemq.byteman.tests.MessageCopyTest",
- targetMethod = "simulateRead",
- targetLocation = "EXIT",
- action = "signalWake(\"finish-read\", true)"
- )
- }
- )
- public void testMessageCopyIssue() throws Exception
- {
- final long RUNS = 1;
- final ServerMessageImpl msg = new ServerMessageImpl(123, 18);
-
- msg.setMessageID(RandomUtil.randomLong());
- msg.encodeMessageIDToBuffer();
- msg.setAddress(new SimpleString("Batatantkashf aksjfh aksfjh askfdjh askjfh "));
-
- final AtomicInteger errors = new AtomicInteger(0);
-
- int T1_number = 1;
- int T2_number = 1;
-
- final CountDownLatch latchAlign = new CountDownLatch(T1_number + T2_number);
- final CountDownLatch latchReady = new CountDownLatch(1);
- class T1 extends Thread
- {
- T1()
- {
- super("T1");
- }
-
- @Override
- public void run()
- {
- latchAlign.countDown();
- try
- {
- latchReady.await();
- }
- catch (Exception ignored)
- {
- }
-
- for (int i = 0; i < RUNS; i++)
- {
- try
- {
- ServerMessageImpl newMsg = (ServerMessageImpl) msg.copy();
- }
- catch (Throwable e)
- {
- e.printStackTrace();
- errors.incrementAndGet();
- }
- }
- }
- }
-
- class T2 extends Thread
- {
- T2()
- {
- super("T2");
- }
-
- @Override
- public void run()
- {
- latchAlign.countDown();
- try
- {
- latchReady.await();
- }
- catch (Exception ignored)
- {
- }
-
- for (int i = 0; i < RUNS; i++)
- {
- try
- {
- SessionSendMessage ssm = new SessionSendMessage(msg);
- ActiveMQBuffer buf = ssm.encode(null);
- System.out.println("reading at buf = " + buf);
- simulateRead(buf);
- }
- catch (Throwable e)
- {
- e.printStackTrace();
- errors.incrementAndGet();
- }
- }
- }
- }
-
-
- ArrayList<Thread> threads = new ArrayList<Thread>();
-
- for (int i = 0; i < T1_number; i++)
- {
- T1 t = new T1();
- threads.add(t);
- t.start();
- }
-
- for (int i = 0; i < T2_number; i++)
- {
- T2 t2 = new T2();
- threads.add(t2);
- t2.start();
- }
-
- latchAlign.await();
-
- latchReady.countDown();
-
- for (Thread t : threads)
- {
- t.join();
- }
-
- Assert.assertEquals(0, errors.get());
- }
-
- private void simulateRead(ActiveMQBuffer buf)
- {
- buf.setIndex(buf.capacity() / 2, buf.capacity() / 2);
-
- // ok this is not actually happening during the read process, but changing this shouldn't affect the buffer on copy
- buf.writeBytes(new byte[1024]);
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/OrphanedConsumerTest.java
----------------------------------------------------------------------
diff --git a/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/OrphanedConsumerTest.java b/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/OrphanedConsumerTest.java
deleted file mode 100644
index d90a002..0000000
--- a/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/OrphanedConsumerTest.java
+++ /dev/null
@@ -1,301 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.byteman.tests;
-
-
-import org.apache.activemq.api.core.SimpleString;
-import org.apache.activemq.api.core.client.ClientConsumer;
-import org.apache.activemq.api.core.client.ClientMessage;
-import org.apache.activemq.api.core.client.ClientProducer;
-import org.apache.activemq.api.core.client.ClientSession;
-import org.apache.activemq.api.core.client.ServerLocator;
-import org.apache.activemq.core.client.impl.ClientSessionFactoryImpl;
-import org.apache.activemq.core.server.ActiveMQServer;
-import org.apache.activemq.core.server.Queue;
-import org.apache.activemq.tests.util.ServiceTestBase;
-import org.jboss.byteman.contrib.bmunit.BMRule;
-import org.jboss.byteman.contrib.bmunit.BMRules;
-import org.jboss.byteman.contrib.bmunit.BMUnitRunner;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * @author Clebert Suconic
- */
-@RunWith(BMUnitRunner.class)
-public class OrphanedConsumerTest extends ServiceTestBase
-{
-
- private static boolean conditionActive = true;
-
- public static final boolean isConditionActive()
- {
- return conditionActive;
- }
-
-
- public static final void setConditionActive(boolean _conditionActive)
- {
- conditionActive = _conditionActive;
- }
-
-
- public static void throwException() throws Exception
- {
- throw new InterruptedException("nice.. I interrupted this!");
- }
-
- private ActiveMQServer server;
-
- private ServerLocator locator;
-
- static ActiveMQServer staticServer;
-
- /**
- * {@link #leavingCloseOnTestCountersWhileClosing()} will set this in case of any issues.
- * the test must then validate for this being null
- */
- static AssertionError verification;
-
- /**
- * This static method is an entry point for the byteman rules on {@link #testOrphanedConsumers()}
- * */
- public static void leavingCloseOnTestCountersWhileClosing()
- {
- if (staticServer.getConnectionCount() == 0)
- {
- verification = new AssertionError("The connection was closed before the consumers and sessions, this may cause issues on management leaving Orphaned Consumers!");
- }
-
- if (staticServer.getSessions().size() == 0)
- {
- verification = new AssertionError("The session was closed before the consumers, this may cause issues on management leaving Orphaned Consumers!");
- }
- }
-
-
- @Override
- @Before
- public void setUp() throws Exception
- {
- super.setUp();
- setConditionActive(true);
- /** I'm using the internal method here because closing
- * this locator on tear down would hang.
- * as we are tweaking with the internal state and making it fail */
- locator = internalCreateNonHALocator(true);
- }
-
-
- @Override
- @After
- public void tearDown() throws Exception
- {
- super.tearDown();
- setConditionActive(false);
-
- staticServer = null;
- }
-
-
- /**
- * This is like being two tests in one:
- * I - validating that any exception during the close wouldn't stop connection from being closed
- * II - validating that the connection is only removed at the end of the process and you wouldn't see
- * inconsistencies on management
- * @throws Exception
- */
- @Test
- @BMRules
- (
- rules =
- {
- @BMRule
- (
- name = "closeExit",
- targetClass = "org.apache.activemq.core.server.impl.ServerConsumerImpl",
- targetMethod = "close",
- targetLocation = "AT EXIT",
- condition = "org.apache.activemq.byteman.tests.OrphanedConsumerTest.isConditionActive()",
- action = "System.out.println(\"throwing stuff\");throw new InterruptedException()"
- ),
- @BMRule
- (
- name = "closeEnter",
- targetClass = "org.apache.activemq.core.server.impl.ServerConsumerImpl",
- targetMethod = "close",
- targetLocation = "ENTRY",
- condition = "org.apache.activemq.byteman.tests.OrphanedConsumerTest.isConditionActive()",
- action = "org.apache.activemq.byteman.tests.OrphanedConsumerTest.leavingCloseOnTestCountersWhileClosing()"
- )
-
- }
- )
- public void testOrphanedConsumers() throws Exception
- {
- internalTestOrphanedConsumers(false);
- }
-
-
- /**
- * This is like being two tests in one:
- * I - validating that any exception during the close wouldn't stop connection from being closed
- * II - validating that the connection is only removed at the end of the process and you wouldn't see
- * inconsistencies on management
- * @throws Exception
- */
- @Test
- @BMRules
- (
- rules =
- {
- @BMRule
- (
- name = "closeExit",
- targetClass = "org.apache.activemq.core.server.impl.ServerConsumerImpl",
- targetMethod = "close",
- targetLocation = "AT EXIT",
- condition = "org.apache.activemq.byteman.tests.OrphanedConsumerTest.isConditionActive()",
- action = "System.out.println(\"throwing stuff\");throw new InterruptedException()"
- ),
- @BMRule
- (
- name = "closeEnter",
- targetClass = "org.apache.activemq.core.server.impl.ServerConsumerImpl",
- targetMethod = "close",
- targetLocation = "ENTRY",
- condition = "org.apache.activemq.byteman.tests.OrphanedConsumerTest.isConditionActive()",
- action = "org.apache.activemq.byteman.tests.OrphanedConsumerTest.leavingCloseOnTestCountersWhileClosing()"
- )
-
- }
- )
- public void testOrphanedConsumersByManagement() throws Exception
- {
- internalTestOrphanedConsumers(true);
- }
-
- /**
- *
- * @param useManagement true = it will use a management operation to make the connection failure, false through ping
- * @throws Exception
- */
- private void internalTestOrphanedConsumers(boolean useManagement) throws Exception
- {
- final int NUMBER_OF_MESSAGES = 2;
- server = createServer(true, true);
- server.start();
- staticServer = server;
-
- locator.setBlockOnNonDurableSend(false);
- locator.setBlockOnDurableSend(false);
- locator.setBlockOnAcknowledge(true);
- locator.setConnectionTTL(1000);
- locator.setClientFailureCheckPeriod(100);
- locator.setReconnectAttempts(0);
- // We are not interested on consumer-window-size on this test
- // We want that every message is delivered
- // as we asserting for number of consumers available and round-robin on delivery
- locator.setConsumerWindowSize(-1);
-
- ClientSessionFactoryImpl sf = (ClientSessionFactoryImpl)createSessionFactory(locator);
-
- ClientSession session = sf.createSession(true, true, 0);
-
- session.createQueue("queue", "queue1", true);
- session.createQueue("queue", "queue2", true);
-
- ClientProducer prod = session.createProducer("queue");
-
- ClientConsumer consumer = session.createConsumer("queue1");
- ClientConsumer consumer2 = session.createConsumer("queue2");
-
-
- Queue queue1 = server.locateQueue(new SimpleString("queue1"));
-
- Queue queue2 = server.locateQueue(new SimpleString("queue2"));
-
- session.start();
-
-
- if (!useManagement)
- {
- sf.stopPingingAfterOne();
-
- for (long timeout = System.currentTimeMillis() + 6000; timeout > System.currentTimeMillis() && server.getConnectionCount() != 0; )
- {
- Thread.sleep(100);
- }
-
- // an extra second to avoid races of something closing the session while we are asserting it
- Thread.sleep(1000);
- }
- else
- {
- server.getActiveMQServerControl().closeConnectionsForAddress("127.0.0.1");
- }
-
- if (verification != null)
- {
- throw verification;
- }
-
- assertEquals(0, queue1.getConsumerCount());
- assertEquals(0, queue2.getConsumerCount());
-
- setConditionActive(false);
-
- locator = internalCreateNonHALocator(true);
-
- locator.setBlockOnNonDurableSend(false);
- locator.setBlockOnDurableSend(false);
- locator.setBlockOnAcknowledge(true);
- locator.setReconnectAttempts(0);
- locator.setConsumerWindowSize(-1);
-
- sf = (ClientSessionFactoryImpl)locator.createSessionFactory();
- session = sf.createSession(true, true, 0);
-
-
- session.start();
-
-
- prod = session.createProducer("queue");
-
- for (int i = 0; i < NUMBER_OF_MESSAGES; i++)
- {
- ClientMessage message = session.createMessage(true);
- message.putIntProperty("i", i);
- prod.send(message);
- }
-
- consumer = session.createConsumer("queue1");
- consumer2 = session.createConsumer("queue2");
-
- for (int i = 0; i < NUMBER_OF_MESSAGES; i++)
- {
- assertNotNull(consumer.receive(5000));
- assertNotNull(consumer2.receive(5000));
- }
-
- session.close();
- }
-
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/PagingLeakTest.java
----------------------------------------------------------------------
diff --git a/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/PagingLeakTest.java b/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/PagingLeakTest.java
deleted file mode 100644
index 74c0ec9..0000000
--- a/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/PagingLeakTest.java
+++ /dev/null
@@ -1,273 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.byteman.tests;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.apache.activemq.api.core.SimpleString;
-import org.apache.activemq.api.core.TransportConfiguration;
-import org.apache.activemq.api.core.client.ClientConsumer;
-import org.apache.activemq.api.core.client.ClientMessage;
-import org.apache.activemq.api.core.client.ClientProducer;
-import org.apache.activemq.api.core.client.ClientSession;
-import org.apache.activemq.api.core.client.ClientSessionFactory;
-import org.apache.activemq.api.core.client.ServerLocator;
-import org.apache.activemq.core.config.Configuration;
-import org.apache.activemq.core.paging.cursor.impl.PagePositionImpl;
-import org.apache.activemq.core.server.ActiveMQServer;
-import org.apache.activemq.core.server.ActiveMQServers;
-import org.apache.activemq.core.settings.impl.AddressFullMessagePolicy;
-import org.apache.activemq.core.settings.impl.AddressSettings;
-import org.apache.activemq.tests.util.ServiceTestBase;
-import org.jboss.byteman.contrib.bmunit.BMRule;
-import org.jboss.byteman.contrib.bmunit.BMRules;
-import org.jboss.byteman.contrib.bmunit.BMUnitRunner;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-@RunWith(BMUnitRunner.class)
-public class PagingLeakTest extends ServiceTestBase
-{
-
- private static final AtomicInteger pagePosInstances = new AtomicInteger(0);
-
- public static void newPosition()
- {
- pagePosInstances.incrementAndGet();
- }
-
- public static void deletePosition()
- {
- pagePosInstances.decrementAndGet();
- }
-
- @Before
- public void setup()
- {
- pagePosInstances.set(0);
- }
-
- @Test
- @BMRules
- (
- rules =
- {
- @BMRule
- (
- name = "newPosition",
- targetClass = "org.apache.activemq.core.paging.cursor.impl.PagePositionImpl",
- targetMethod = "<init>()",
- targetLocation = "ENTRY",
- action = "org.apache.activemq.byteman.tests.PagingLeakTest.newPosition()"
- ),
- @BMRule
- (
- name = "finalPosition",
- targetClass = "org.apache.activemq.core.paging.cursor.impl.PagePositionImpl",
- targetMethod = "finalize",
- targetLocation = "ENTRY",
- action = "org.apache.activemq.byteman.tests.PagingLeakTest.deletePosition()"
- )
- }
- )
- public void testValidateLeak() throws Throwable
- {
-
- List<PagePositionImpl> positions = new ArrayList<PagePositionImpl>();
-
- for (int i = 0; i < 300; i++)
- {
- positions.add(new PagePositionImpl(3, 3));
- }
-
- long timeout = System.currentTimeMillis() + 5000;
- while (pagePosInstances.get() != 300 && timeout > System.currentTimeMillis())
- {
- forceGC();
- }
-
- // This is just to validate the rules are correctly applied on byteman
- assertEquals("You have changed something on PagePositionImpl in such way that these byteman rules are no longer working", 300, pagePosInstances.get());
-
- positions.clear();
-
- timeout = System.currentTimeMillis() + 5000;
- while (pagePosInstances.get() != 0 && timeout > System.currentTimeMillis())
- {
- forceGC();
- }
-
- // This is just to validate the rules are correctly applied on byteman
- assertEquals("You have changed something on PagePositionImpl in such way that these byteman rules are no longer working", 0, pagePosInstances.get());
-
- final ArrayList<Exception> errors = new ArrayList<Exception>();
- // A backup that will be waiting to be activated
- Configuration conf = createDefaultConfig(true)
- .setSecurityEnabled(false)
- .addConnectorConfiguration("invm", new TransportConfiguration(INVM_CONNECTOR_FACTORY));
-
- final ActiveMQServer server = ActiveMQServers.newActiveMQServer(conf, true);
- addServer(server);
-
-
- server.start();
-
-
- AddressSettings settings = new AddressSettings();
- settings.setPageSizeBytes(20 * 1024);
- settings.setMaxSizeBytes(200 * 1024);
- settings.setAddressFullMessagePolicy(AddressFullMessagePolicy.PAGE);
-
-
- server.getAddressSettingsRepository().addMatch("#", settings);
-
-
- final SimpleString address = new SimpleString("pgdAddress");
-
- class Consumer extends Thread
- {
- final ServerLocator locator;
- final ClientSessionFactory sf;
- final ClientSession session;
- final ClientConsumer consumer;
-
- final int sleepTime;
- final int maxConsumed;
-
- Consumer(int sleepTime, String suffix, int maxConsumed) throws Exception
- {
-
- server.createQueue(address, address.concat(suffix), null, true, false);
-
- this.sleepTime = sleepTime;
- locator = createInVMLocator(0);
- sf = locator.createSessionFactory();
- session = sf.createSession(true, true);
- consumer = session.createConsumer(address.concat(suffix));
-
- this.maxConsumed = maxConsumed;
- }
-
- public void run()
- {
- try
- {
- session.start();
-
- long lastTime = System.currentTimeMillis();
-
- for (long i = 0; i < maxConsumed; i++)
- {
- ClientMessage msg = consumer.receive(5000);
-
- if (msg == null)
- {
- errors.add(new Exception("didn't receive a message"));
- return;
- }
-
- msg.acknowledge();
-
-
- if (sleepTime > 0)
- {
-
- Thread.sleep(sleepTime);
- }
-
- if (i % 1000 == 0)
- {
- System.out.println("Consumed " + i + " events in " + (System.currentTimeMillis() - lastTime));
- lastTime = System.currentTimeMillis();
- }
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- }
-
-
- int numberOfMessages = 10000;
-
- Consumer consumer1 = new Consumer(100, "-1", 150);
- Consumer consumer2 = new Consumer(0, "-2", numberOfMessages);
-
- final ServerLocator locator = createInVMLocator(0);
- final ClientSessionFactory sf = locator.createSessionFactory();
- final ClientSession session = sf.createSession(true, true);
- final ClientProducer producer = session.createProducer(address);
-
-
- byte[] b = new byte[1024];
-
-
- for (long i = 0; i < numberOfMessages; i++)
- {
- ClientMessage msg = session.createMessage(true);
- msg.getBodyBuffer().writeBytes(b);
- producer.send(msg);
-
- if (i == 1000)
- {
- System.out.println("Starting consumers!!!");
- consumer1.start();
- consumer2.start();
- }
-
- if (i % 1000 == 0)
- {
- validateInstances();
- }
-
- }
-
-
- consumer1.join();
- consumer2.join();
-
- validateInstances();
- Throwable elast = null;
-
- for (Throwable e : errors)
- {
- e.printStackTrace();
- elast = e;
- }
-
- if (elast != null)
- {
- throw elast;
- }
-
- }
-
- private void validateInstances()
- {
- forceGC();
- int count2 = pagePosInstances.get();
- Assert.assertTrue("There is a leak, you shouldn't have this many instances (" + count2 + ")", count2 < 5000);
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/ReplicationBackupTest.java
----------------------------------------------------------------------
diff --git a/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/ReplicationBackupTest.java b/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/ReplicationBackupTest.java
deleted file mode 100644
index 2a15374..0000000
--- a/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/ReplicationBackupTest.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.byteman.tests;
-
-import java.util.concurrent.CountDownLatch;
-
-import org.apache.activemq.api.config.ActiveMQDefaultConfiguration;
-import org.apache.activemq.api.core.TransportConfiguration;
-import org.apache.activemq.core.config.Configuration;
-import org.apache.activemq.core.server.ActiveMQServer;
-import org.apache.activemq.tests.util.ReplicatedBackupUtils;
-import org.apache.activemq.tests.util.ServiceTestBase;
-import org.apache.activemq.tests.util.TransportConfigurationUtils;
-import org.jboss.byteman.contrib.bmunit.BMRule;
-import org.jboss.byteman.contrib.bmunit.BMRules;
-import org.jboss.byteman.contrib.bmunit.BMUnitRunner;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-@RunWith(BMUnitRunner.class)
-public class ReplicationBackupTest extends ServiceTestBase
-{
- private static final CountDownLatch ruleFired = new CountDownLatch(1);
- private ActiveMQServer backupServer;
- private ActiveMQServer liveServer;
-
- /*
- * simple test to induce a potential race condition where the server's acceptors are active, but the server's
- * state != STARTED
- */
- @Test
- @BMRules
- (
- rules =
- {
- @BMRule
- (
- name = "prevent backup annoucement",
- targetClass = "org.apache.activemq.core.server.impl.SharedNothingLiveActivation",
- targetMethod = "run",
- targetLocation = "AT EXIT",
- action = "org.apache.activemq.byteman.tests.ReplicationBackupTest.breakIt();"
- )
- }
- )
- public void testReplicatedBackupAnnouncement() throws Exception
- {
- TransportConfiguration liveConnector = TransportConfigurationUtils.getNettyConnector(true, 0);
- TransportConfiguration liveAcceptor = TransportConfigurationUtils.getNettyAcceptor(true, 0);
- TransportConfiguration backupConnector = TransportConfigurationUtils.getNettyConnector(false, 0);
- TransportConfiguration backupAcceptor = TransportConfigurationUtils.getNettyAcceptor(false, 0);
-
- final String suffix = "_backup";
-
- Configuration backupConfig = createDefaultConfig()
- .setBindingsDirectory(ActiveMQDefaultConfiguration.getDefaultBindingsDirectory() + suffix)
- .setJournalDirectory(ActiveMQDefaultConfiguration.getDefaultJournalDir() + suffix)
- .setPagingDirectory(ActiveMQDefaultConfiguration.getDefaultPagingDir() + suffix)
- .setLargeMessagesDirectory(ActiveMQDefaultConfiguration.getDefaultLargeMessagesDir() + suffix);
-
- Configuration liveConfig = createDefaultConfig();
-
- ReplicatedBackupUtils.configureReplicationPair(backupConfig, backupConnector, backupAcceptor, liveConfig, liveConnector, liveAcceptor);
-
- liveServer = createServer(liveConfig);
-
- // start the live server in a new thread so we can start the backup simultaneously to induce a potential race
- Thread startThread = new Thread(new Runnable()
- {
- @Override
- public void run()
- {
- try
- {
- liveServer.start();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- });
- startThread.start();
-
- ruleFired.await();
-
- backupServer = createServer(backupConfig);
- backupServer.start();
- ServiceTestBase.waitForRemoteBackup(null, 3, true, backupServer);
- }
-
- public static void breakIt()
- {
- ruleFired.countDown();
- try
- {
- /* before the fix this sleep would put the "live" server into a state where the acceptors were started
- * but the server's state != STARTED which would cause the backup to fail to announce
- */
- Thread.sleep(2000);
- }
- catch (InterruptedException e)
- {
- e.printStackTrace();
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/ScaleDownFailoverTest.java
----------------------------------------------------------------------
diff --git a/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/ScaleDownFailoverTest.java b/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/ScaleDownFailoverTest.java
deleted file mode 100644
index 72fa0ad..0000000
--- a/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/ScaleDownFailoverTest.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.byteman.tests;
-
-import org.apache.activemq.api.core.TransportConfiguration;
-import org.apache.activemq.api.core.client.ClientMessage;
-import org.apache.activemq.core.config.ScaleDownConfiguration;
-import org.apache.activemq.core.config.ha.LiveOnlyPolicyConfiguration;
-import org.apache.activemq.core.remoting.impl.netty.TransportConstants;
-import org.apache.activemq.core.server.ActiveMQServer;
-import org.apache.activemq.tests.integration.cluster.distribution.ClusterTestBase;
-import org.jboss.byteman.contrib.bmunit.BMRule;
-import org.jboss.byteman.contrib.bmunit.BMUnitRunner;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-@RunWith(BMUnitRunner.class)
-public class ScaleDownFailoverTest extends ClusterTestBase
-{
- protected static int stopCount = 0;
- private static ActiveMQServer[] staticServers;
-
- @Override
- @Before
- public void setUp() throws Exception
- {
- super.setUp();
- stopCount = 0;
- setupLiveServer(0, isFileStorage(), false, isNetty(), true);
- setupLiveServer(1, isFileStorage(), false, isNetty(), true);
- setupLiveServer(2, isFileStorage(), false, isNetty(), true);
- ScaleDownConfiguration scaleDownConfiguration = new ScaleDownConfiguration();
- ScaleDownConfiguration scaleDownConfiguration2 = new ScaleDownConfiguration();
- scaleDownConfiguration2.setEnabled(false);
- ScaleDownConfiguration scaleDownConfiguration3 = new ScaleDownConfiguration();
- scaleDownConfiguration3.setEnabled(false);
- ((LiveOnlyPolicyConfiguration) servers[0].getConfiguration().getHAPolicyConfiguration()).setScaleDownConfiguration(scaleDownConfiguration);
- ((LiveOnlyPolicyConfiguration) servers[1].getConfiguration().getHAPolicyConfiguration()).setScaleDownConfiguration(scaleDownConfiguration2);
- ((LiveOnlyPolicyConfiguration) servers[2].getConfiguration().getHAPolicyConfiguration()).setScaleDownConfiguration(scaleDownConfiguration3);
- if (isGrouped())
- {
- scaleDownConfiguration.setGroupName("bill");
- scaleDownConfiguration2.setGroupName("bill");
- scaleDownConfiguration3.setGroupName("bill");
- }
- staticServers = servers;
- setupClusterConnection("cluster0", "queues", false, 1, isNetty(), 0, 1, 2);
- setupClusterConnection("cluster1", "queues", false, 1, isNetty(), 1, 0, 2);
- setupClusterConnection("cluster2", "queues", false, 1, isNetty(), 2, 0, 1);
- scaleDownConfiguration.getConnectors().addAll(servers[0].getConfiguration().getClusterConfigurations().iterator().next().getStaticConnectors());
- scaleDownConfiguration2.getConnectors().addAll(servers[1].getConfiguration().getClusterConfigurations().iterator().next().getStaticConnectors());
- scaleDownConfiguration3.getConnectors().addAll(servers[2].getConfiguration().getClusterConfigurations().iterator().next().getStaticConnectors());
-
- startServers(0, 1, 2);
- setupSessionFactory(0, isNetty());
- setupSessionFactory(1, isNetty());
- setupSessionFactory(2, isNetty());
- }
-
- protected boolean isNetty()
- {
- return true;
- }
-
- protected boolean isGrouped()
- {
- return false;
- }
-
- @Override
- @After
- public void tearDown() throws Exception
- {
- closeAllConsumers();
- closeAllSessionFactories();
- closeAllServerLocatorsFactories();
- stopServers(0, 1, 2);
- super.tearDown();
- }
-
-
- @Test
- @BMRule
- (
- name = "blow-up",
- targetClass = "org.apache.activemq.api.core.client.ServerLocator",
- targetMethod = "createSessionFactory(org.apache.activemq.api.core.TransportConfiguration, int, boolean)",
- isInterface = true,
- targetLocation = "ENTRY",
- action = "org.apache.activemq.byteman.tests.ScaleDownFailoverTest.fail($1);"
- )
- public void testScaleDownWhenFirstServerFails() throws Exception
- {
- final int TEST_SIZE = 2;
- final String addressName = "testAddress";
- final String queueName1 = "testQueue1";
- final String queueName2 = "testQueue2";
-
- // create 2 queues on each node mapped to the same address
- createQueue(0, addressName, queueName1, null, false);
- createQueue(0, addressName, queueName2, null, false);
- createQueue(1, addressName, queueName1, null, false);
- createQueue(1, addressName, queueName2, null, false);
- createQueue(2, addressName, queueName1, null, false);
- createQueue(2, addressName, queueName2, null, false);
-
- // send messages to node 0
- send(0, addressName, TEST_SIZE, false, null);
-
- // consume a message from node 0
- addConsumer(0, 0, queueName2, null);
- ClientMessage clientMessage = consumers[0].getConsumer().receive(250);
- Assert.assertNotNull(clientMessage);
- clientMessage.acknowledge();
- removeConsumer(0);
-
- servers[0].stop();
-
- // verify that at least one server stopped
- Assert.assertTrue(!servers[1].isStarted() || !servers[2].isStarted());
-
- int remainingServer;
- if (servers[1].isStarted())
- remainingServer = 1;
- else
- remainingServer = 2;
-
- // get the 2 messages from queue 1
- addConsumer(0, remainingServer, queueName1, null);
- clientMessage = consumers[0].getConsumer().receive(250);
- Assert.assertNotNull(clientMessage);
- clientMessage.acknowledge();
- clientMessage = consumers[0].getConsumer().receive(250);
- Assert.assertNotNull(clientMessage);
- clientMessage.acknowledge();
-
- // ensure there are no more messages on queue 1
- clientMessage = consumers[0].getConsumer().receive(250);
- Assert.assertNull(clientMessage);
- removeConsumer(0);
-
- // get the 1 message from queue 2
- addConsumer(0, remainingServer, queueName2, null);
- clientMessage = consumers[0].getConsumer().receive(250);
- Assert.assertNotNull(clientMessage);
- clientMessage.acknowledge();
-
- // ensure there are no more messages on queue 1
- clientMessage = consumers[0].getConsumer().receive(250);
- Assert.assertNull(clientMessage);
- removeConsumer(0);
- }
-
- public static void fail(TransportConfiguration tc)
- {
- // only kill one server
- if (stopCount == 0)
- {
- try
- {
- for (ActiveMQServer activeMQServer : staticServers)
- {
- if (activeMQServer != null)
- {
- for (TransportConfiguration transportConfiguration : activeMQServer.getConfiguration().getAcceptorConfigurations())
- {
- if (transportConfiguration.getParams().get(TransportConstants.PORT_PROP_NAME).equals(tc.getParams().get(TransportConstants.PORT_PROP_NAME)))
- {
- activeMQServer.stop();
- stopCount++;
- System.out.println("Stopping server listening at: " + tc.getParams().get(TransportConstants.PORT_PROP_NAME));
- }
- }
- }
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/ScaleDownFailureTest.java
----------------------------------------------------------------------
diff --git a/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/ScaleDownFailureTest.java b/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/ScaleDownFailureTest.java
deleted file mode 100644
index c5215b0..0000000
--- a/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/ScaleDownFailureTest.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.byteman.tests;
-
-import org.apache.activemq.api.core.client.ClientMessage;
-import org.apache.activemq.core.config.ScaleDownConfiguration;
-import org.apache.activemq.core.config.ha.LiveOnlyPolicyConfiguration;
-import org.apache.activemq.tests.integration.cluster.distribution.ClusterTestBase;
-import org.jboss.byteman.contrib.bmunit.BMRule;
-import org.jboss.byteman.contrib.bmunit.BMUnitRunner;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-@RunWith(BMUnitRunner.class)
-public class ScaleDownFailureTest extends ClusterTestBase
-{
- @Override
- @Before
- public void setUp() throws Exception
- {
- super.setUp();
- setupLiveServer(0, isFileStorage(), false, isNetty(), true);
- setupLiveServer(1, isFileStorage(), false, isNetty(), true);
- if (isGrouped())
- {
- ScaleDownConfiguration scaleDownConfiguration = new ScaleDownConfiguration();
- scaleDownConfiguration.setGroupName("bill");
- ((LiveOnlyPolicyConfiguration) servers[0].getConfiguration().getHAPolicyConfiguration()).setScaleDownConfiguration(scaleDownConfiguration);
- ((LiveOnlyPolicyConfiguration) servers[1].getConfiguration().getHAPolicyConfiguration()).setScaleDownConfiguration(scaleDownConfiguration);
- }
- setupClusterConnection("cluster0", "queues", false, 1, isNetty(), 0, 1);
- setupClusterConnection("cluster1", "queues", false, 1, isNetty(), 1, 0);
- startServers(0, 1);
- setupSessionFactory(0, isNetty());
- setupSessionFactory(1, isNetty());
- }
-
- protected boolean isNetty()
- {
- return true;
- }
-
- protected boolean isGrouped()
- {
- return false;
- }
-
- @Override
- @After
- public void tearDown() throws Exception
- {
- closeAllConsumers();
- closeAllSessionFactories();
- closeAllServerLocatorsFactories();
- ((LiveOnlyPolicyConfiguration) servers[0].getConfiguration().getHAPolicyConfiguration()).setScaleDownConfiguration(null);
- stopServers(0, 1);
- super.tearDown();
- }
-
- @Test
- @BMRule
- (
- name = "blow-up",
- targetClass = "org.apache.activemq.api.core.client.ServerLocator",
- targetMethod = "createSessionFactory(org.apache.activemq.api.core.TransportConfiguration, int, boolean)",
- isInterface = true,
- targetLocation = "ENTRY",
- action = "throw new Exception()"
- )
- public void testScaleDownWhenRemoteServerIsUnavailable() throws Exception
- {
- final int TEST_SIZE = 1;
- final String addressName = "testAddress";
- final String queueName1 = "testQueue1";
- final String queueName2 = "testQueue2";
-
- // create 2 queues on each node mapped to the same address
- createQueue(0, addressName, queueName1, null, false);
- createQueue(0, addressName, queueName2, null, false);
- createQueue(1, addressName, queueName1, null, false);
- createQueue(1, addressName, queueName2, null, false);
-
- // send messages to node 0
- send(0, addressName, TEST_SIZE, false, null);
-
- // consume a message from node 0
- addConsumer(0, 0, queueName2, null, false);
- ClientMessage clientMessage = consumers[0].getConsumer().receive();
- Assert.assertNotNull(clientMessage);
- clientMessage.acknowledge();
- consumers[0].getSession().commit();
- removeConsumer(0);
-
- servers[0].stop();
-
- addConsumer(0, 1, queueName1, null);
- clientMessage = consumers[0].getConsumer().receive(250);
- Assert.assertNull(clientMessage);
- }
-}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/ScaleDownGroupedFailoverTest.java
----------------------------------------------------------------------
diff --git a/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/ScaleDownGroupedFailoverTest.java b/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/ScaleDownGroupedFailoverTest.java
deleted file mode 100644
index 594dd32..0000000
--- a/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/ScaleDownGroupedFailoverTest.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.byteman.tests;
-
-public class ScaleDownGroupedFailoverTest extends ScaleDownFailoverTest
-{
- protected boolean isGrouped()
- {
- return true;
- }
-}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/ScaleDownGroupedFailureTest.java
----------------------------------------------------------------------
diff --git a/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/ScaleDownGroupedFailureTest.java b/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/ScaleDownGroupedFailureTest.java
deleted file mode 100644
index eb0d996..0000000
--- a/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/ScaleDownGroupedFailureTest.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.byteman.tests;
-
-public class ScaleDownGroupedFailureTest extends ScaleDownFailureTest
-{
- protected boolean isGrouped()
- {
- return true;
- }
-}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/StartStopDeadlockTest.java
----------------------------------------------------------------------
diff --git a/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/StartStopDeadlockTest.java b/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/StartStopDeadlockTest.java
deleted file mode 100644
index 409c811..0000000
--- a/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/StartStopDeadlockTest.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.byteman.tests;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.apache.activemq.api.core.TransportConfiguration;
-import org.apache.activemq.core.config.Configuration;
-import org.apache.activemq.core.config.ha.SharedStoreMasterPolicyConfiguration;
-import org.apache.activemq.core.config.ha.SharedStoreSlavePolicyConfiguration;
-import org.apache.activemq.core.registry.JndiBindingRegistry;
-import org.apache.activemq.core.server.ActiveMQServer;
-import org.apache.activemq.core.server.ActiveMQServers;
-import org.apache.activemq.jms.server.impl.JMSServerManagerImpl;
-import org.apache.activemq.tests.unit.util.InVMNamingContext;
-import org.apache.activemq.tests.util.ServiceTestBase;
-import org.jboss.byteman.contrib.bmunit.BMRule;
-import org.jboss.byteman.contrib.bmunit.BMRules;
-import org.jboss.byteman.contrib.bmunit.BMUnitRunner;
-import org.junit.After;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-/**
- * This test validates a deadlock identified by https://bugzilla.redhat.com/show_bug.cgi?id=959616
- *
- * @author Clebert
- */
-@RunWith(BMUnitRunner.class)
-public class StartStopDeadlockTest extends ServiceTestBase
-{
- /*
- * simple test to make sure connect still works with some network latency built into netty
- * */
- @Test
- @BMRules
- (
-
- rules =
- {
- @BMRule
- (
- name = "Server.start wait-init",
- targetClass = "org.apache.activemq.core.server.impl.ActiveMQServerImpl",
- targetMethod = "initialisePart2",
- targetLocation = "ENTRY",
- condition = "incrementCounter(\"server-Init\") == 2",
- action = "System.out.println(\"server backup init\"), waitFor(\"start-init\")"
- ),
- @BMRule(
- name = "JMSServer.stop wait-init",
- targetClass = "org.apache.activemq.jms.server.impl.JMSServerManagerImpl",
- targetMethod = "stop",
- targetLocation = "ENTRY",
- action = "signalWake(\"start-init\", true)"
- ),
- @BMRule(
- name = "StartStopDeadlockTest tearDown",
- targetClass = "org.apache.activemq.byteman.tests.StartStopDeadlockTest",
- targetMethod = "tearDown",
- targetLocation = "ENTRY",
- action = "deleteCounter(\"server-Init\")"
- )
- }
- )
- public void testDeadlock() throws Exception
- {
-
- // A live server that will always be crashed
- Configuration confLive = createDefaultConfig(true)
- .setSecurityEnabled(false)
- .setHAPolicyConfiguration(new SharedStoreMasterPolicyConfiguration())
- .addConnectorConfiguration("invm", new TransportConfiguration(INVM_CONNECTOR_FACTORY));
- final ActiveMQServer serverLive = ActiveMQServers.newActiveMQServer(confLive);
- serverLive.start();
- addServer(serverLive);
-
-
- // A backup that will be waiting to be activated
- Configuration conf = createDefaultConfig(true)
- .setSecurityEnabled(false)
- .setHAPolicyConfiguration(new SharedStoreSlavePolicyConfiguration())
- .addConnectorConfiguration("invm", new TransportConfiguration(INVM_CONNECTOR_FACTORY));
-
- final ActiveMQServer server = ActiveMQServers.newActiveMQServer(conf, true);
- addServer(server);
-
- final JMSServerManagerImpl jmsServer = new JMSServerManagerImpl(server);
- final InVMNamingContext context = new InVMNamingContext();
- jmsServer.setRegistry(new JndiBindingRegistry(context));
-
- jmsServer.start();
-
- final AtomicInteger errors = new AtomicInteger(0);
- final CountDownLatch align = new CountDownLatch(2);
- final CountDownLatch startLatch = new CountDownLatch(1);
-
-
- Thread tCrasher = new Thread("tStart")
- {
- @Override
- public void run()
- {
- try
- {
- align.countDown();
- startLatch.await();
- System.out.println("Crashing....");
- serverLive.stop(true);
- }
- catch (Exception e)
- {
- errors.incrementAndGet();
- e.printStackTrace();
- }
- }
- };
-
- Thread tStop = new Thread("tStop")
- {
- @Override
- public void run()
- {
- try
- {
- align.countDown();
- startLatch.await();
- jmsServer.stop();
- }
- catch (Exception e)
- {
- errors.incrementAndGet();
- e.printStackTrace();
- }
- }
- };
-
- tCrasher.start();
- tStop.start();
- align.await();
- startLatch.countDown();
-
- tCrasher.join();
- tStop.join();
-
- assertEquals(0, errors.get());
- }
-
- @Override
- @After
- public void tearDown() throws Exception
- {
- super.tearDown();
- }
-}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/StompInternalStateTest.java
----------------------------------------------------------------------
diff --git a/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/StompInternalStateTest.java b/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/StompInternalStateTest.java
deleted file mode 100644
index 05d93d4..0000000
--- a/tests/byteman-tests/src/test/java/org/apache/activemq/byteman/tests/StompInternalStateTest.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.byteman.tests;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.activemq.api.core.TransportConfiguration;
-import org.apache.activemq.api.core.client.ClientSession;
-import org.apache.activemq.api.core.client.ClientSessionFactory;
-import org.apache.activemq.api.core.client.ServerLocator;
-import org.apache.activemq.api.core.management.CoreNotificationType;
-import org.apache.activemq.core.config.Configuration;
-import org.apache.activemq.core.protocol.stomp.StompProtocolManagerFactory;
-import org.apache.activemq.core.remoting.impl.invm.InVMAcceptorFactory;
-import org.apache.activemq.core.remoting.impl.netty.NettyAcceptorFactory;
-import org.apache.activemq.core.remoting.impl.netty.TransportConstants;
-import org.apache.activemq.core.server.ActiveMQServer;
-import org.apache.activemq.core.server.management.Notification;
-import org.apache.activemq.tests.util.ServiceTestBase;
-import org.jboss.byteman.contrib.bmunit.BMRule;
-import org.jboss.byteman.contrib.bmunit.BMRules;
-import org.jboss.byteman.contrib.bmunit.BMUnitRunner;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-@RunWith(BMUnitRunner.class)
-public class StompInternalStateTest extends ServiceTestBase
-{
- private static final String STOMP_QUEUE_NAME = "jms.queue.StompTestQueue";
-
- private static volatile String resultTestStompProtocolManagerLeak = null;
-
- protected ActiveMQServer server = null;
-
- @Test
- @BMRules
- (
- rules =
- {
- @BMRule
- (
- name = "StompProtocolManager Leak Server Rule",
- targetClass = "org.apache.activemq.core.protocol.stomp.StompProtocolManager",
- targetMethod = "onNotification(org.apache.activemq.core.server.management.Notification)",
- targetLocation = "EXIT",
- helper = "org.apache.activemq.byteman.tests.StompInternalStateTest",
- action = "verifyBindingAddRemove($1, $0.destinations)"
- )
- }
- )
- public void testStompProtocolManagerLeak() throws Exception
- {
- ClientSession session = null;
- try
- {
- assertNull(resultTestStompProtocolManagerLeak);
- ServerLocator locator = createNettyNonHALocator();
- ClientSessionFactory factory = createSessionFactory(locator);
- session = factory.createSession();
- session.createTemporaryQueue(STOMP_QUEUE_NAME, STOMP_QUEUE_NAME);
- session.deleteQueue(STOMP_QUEUE_NAME);
-
- assertNull(resultTestStompProtocolManagerLeak);
- }
- finally
- {
- if (session != null)
- {
- session.close();
- }
- }
- }
-
- @Override
- protected Configuration createDefaultConfig(final boolean netty) throws Exception
- {
- Configuration config = super.createDefaultConfig(netty)
- .setSecurityEnabled(false)
- .setPersistenceEnabled(false);
-
- Map<String, Object> params = new HashMap<String, Object>();
- params.put(TransportConstants.PROTOCOLS_PROP_NAME, StompProtocolManagerFactory.STOMP_PROTOCOL_NAME);
- params.put(TransportConstants.PORT_PROP_NAME, TransportConstants.DEFAULT_STOMP_PORT);
- params.put(TransportConstants.STOMP_CONSUMERS_CREDIT, "-1");
- TransportConfiguration stompTransport = new TransportConfiguration(NettyAcceptorFactory.class.getName(), params);
- config.getAcceptorConfigurations().add(stompTransport);
- config.getAcceptorConfigurations().add(new TransportConfiguration(InVMAcceptorFactory.class.getName()));
-
- return config;
- }
-
- @SuppressWarnings("unchecked")
- public void verifyBindingAddRemove(Notification noti, Object obj)
- {
- Set<String> destinations = (Set<String>)obj;
- if (noti.getType() == CoreNotificationType.BINDING_ADDED)
- {
- if (!destinations.contains(STOMP_QUEUE_NAME))
- {
- resultTestStompProtocolManagerLeak += "didn't save the queue when binding added " + destinations;
- }
- }
- else if (noti.getType() == CoreNotificationType.BINDING_REMOVED)
- {
- if (destinations.contains(STOMP_QUEUE_NAME))
- {
- resultTestStompProtocolManagerLeak = "didn't remove the queue when binding removed " + destinations;
- }
- }
- }
-
- @Override
- @Before
- public void setUp() throws Exception
- {
- super.setUp();
- server = createServer(createDefaultConfig(true));
- server.start();
- }
-
- @Override
- @After
- public void tearDown() throws Exception
- {
- server.stop();
- super.tearDown();
- }
-}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/byteman-tests/src/test/java/org/apache/activemq/core/settings/impl/HierarchicalObjectRepositoryTest.java
----------------------------------------------------------------------
diff --git a/tests/byteman-tests/src/test/java/org/apache/activemq/core/settings/impl/HierarchicalObjectRepositoryTest.java b/tests/byteman-tests/src/test/java/org/apache/activemq/core/settings/impl/HierarchicalObjectRepositoryTest.java
deleted file mode 100644
index 4698bb0..0000000
--- a/tests/byteman-tests/src/test/java/org/apache/activemq/core/settings/impl/HierarchicalObjectRepositoryTest.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.core.settings.impl;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-
-import org.jboss.byteman.contrib.bmunit.BMRule;
-import org.jboss.byteman.contrib.bmunit.BMRules;
-import org.jboss.byteman.contrib.bmunit.BMUnitRunner;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-@RunWith(BMUnitRunner.class)
-@BMRules(rules = { @BMRule(name = "modify map during iteration",
- targetClass = "org.apache.activemq.core.settings.impl.HierarchicalObjectRepository",
- targetMethod = "getPossibleMatches(String)", targetLocation = "AT INVOKE java.util.HashMap.put",
- action = "org.apache.activemq.core.settings.impl.HierarchicalObjectRepositoryTest.bum()"), })
-public class HierarchicalObjectRepositoryTest
-{
- private static final String A = "a.";
- private static final int TOTAL = 100;
- private static CountDownLatch latch;
- private static CountDownLatch latch2;
- private ExecutorService executor;
- private HierarchicalObjectRepository<String> repo;
-
- @Before
- public void setUp()
- {
- latch = new CountDownLatch(1);
- latch2 = new CountDownLatch(1);
- executor = Executors.newSingleThreadExecutor();
- repo = new HierarchicalObjectRepository<String>();
- addToRepo(repo, A);
- }
-
- static void addToRepo(HierarchicalObjectRepository<String> repo0, String pattern)
- {
- for (int i = 0; i < TOTAL; i++)
- {
- repo0.addMatch(pattern + i + ".*", String.valueOf(i));
- }
- }
-
- @After
- public void tearDown() throws InterruptedException
- {
- latch.countDown();
- latch2.countDown();
- executor.shutdown();
- executor.awaitTermination(1, TimeUnit.SECONDS);
- }
-
- private class Clearer implements Runnable
- {
- private final int code;
-
- public Clearer(int code)
- {
- this.code = code;
- }
-
- @Override
- public void run()
- {
- try
- {
- latch.await();
- }
- catch (InterruptedException e)
- {
- throw new RuntimeException(e);
- }
-
- switch (code)
- {
- case 0:
- repo.clear();
- break;
- case 1:
- addToRepo(repo, "bb.");
- break;
- case 2:
- for (int i = TOTAL / 2; i < TOTAL; i++)
- {
- repo.removeMatch(A + i + ".*");
- }
- break;
- default:
- throw new RuntimeException();
- }
-
- latch2.countDown();
- }
- }
-
- @Test
- public void testConcurrentModificationsClear()
- {
- executor.execute(new Clearer(0));
- repo.getMatch(A + (TOTAL - 10) + ".foobar");
- Assert.assertEquals("Byteman rule failed?", 0, latch.getCount());
- }
-
- @Test
- public void testConcurrentModificationsAdd()
- {
- executor.execute(new Clearer(1));
- repo.getMatch(A + (TOTAL - 10) + ".foobar");
- Assert.assertEquals("Byteman rule failed?", 0, latch.getCount());
- }
-
- @Test
- public void testConcurrentModificationsRemove()
- {
- executor.execute(new Clearer(2));
- repo.getMatch(A + (TOTAL - 10) + ".foobar");
- Assert.assertEquals("Byteman rule failed?", 0, latch.getCount());
- }
-
- public static void bum()
- {
- latch.countDown();
- try
- {
- latch2.await(3, TimeUnit.SECONDS);
- }
- catch (InterruptedException e)
- {
- // no op
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/concurrent-tests/pom.xml
----------------------------------------------------------------------
diff --git a/tests/concurrent-tests/pom.xml b/tests/concurrent-tests/pom.xml
deleted file mode 100644
index 01c361c..0000000
--- a/tests/concurrent-tests/pom.xml
+++ /dev/null
@@ -1,101 +0,0 @@
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one or more
- ~ contributor license agreements. See the NOTICE file distributed with
- ~ this work for additional information regarding copyright ownership.
- ~ The ASF licenses this file to You under the Apache License, Version 2.0
- ~ (the "License"); you may not use this file except in compliance with
- ~ the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.activemq.tests</groupId>
- <artifactId>activemq-tests-pom</artifactId>
- <version>6.0.1-SNAPSHOT</version>
- </parent>
-
- <artifactId>concurrent-tests</artifactId>
- <packaging>jar</packaging>
- <name>ActiveMQ6 concurrent Tests</name>
-
- <properties>
- <activemq.basedir>${project.basedir}/../..</activemq.basedir>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>activemq-core-client</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- <type>test-jar</type>
- </dependency>
- <dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>activemq-server</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- <type>test-jar</type>
- </dependency>
- <dependency>
- <groupId>org.apache.activemq.tests</groupId>
- <artifactId>unit-tests</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- <type>test-jar</type>
- </dependency>
- <dependency>
- <groupId>org.apache.activemq.tests</groupId>
- <artifactId>integration-tests</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- <type>test-jar</type>
- </dependency>
- <dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>activemq-jms-client</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>activemq-ra</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.activemq</groupId>
- <artifactId>activemq-bootstrap</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <skipTests>${skipConcurrentTests}</skipTests>
- <includes>
- <include>**/*Test.java</include>
- </includes>
- <argLine>${activemq-surefire-argline}</argLine>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/concurrent-tests/src/test/java/org/apache/activemq/tests/concurrent/server/impl/QueueTest.java
----------------------------------------------------------------------
diff --git a/tests/concurrent-tests/src/test/java/org/apache/activemq/tests/concurrent/server/impl/QueueTest.java b/tests/concurrent-tests/src/test/java/org/apache/activemq/tests/concurrent/server/impl/QueueTest.java
deleted file mode 100644
index f0039ff..0000000
--- a/tests/concurrent-tests/src/test/java/org/apache/activemq/tests/concurrent/server/impl/QueueTest.java
+++ /dev/null
@@ -1,231 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.tests.concurrent.server.impl;
-import org.junit.Before;
-import org.junit.After;
-
-import org.junit.Test;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.activemq.api.core.SimpleString;
-import org.apache.activemq.core.server.HandleStatus;
-import org.apache.activemq.core.server.MessageReference;
-import org.apache.activemq.core.server.Queue;
-import org.apache.activemq.core.server.ServerMessage;
-import org.apache.activemq.core.server.impl.QueueImpl;
-import org.apache.activemq.tests.unit.UnitTestLogger;
-import org.apache.activemq.tests.unit.core.server.impl.fakes.FakeConsumer;
-import org.apache.activemq.tests.unit.core.server.impl.fakes.FakeQueueFactory;
-import org.apache.activemq.tests.util.UnitTestCase;
-
-/**
- *
- * A concurrent QueueTest
- *
- * All the concurrent queue tests go in here
- *
- * @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
- *
- */
-public class QueueTest extends UnitTestCase
-{
- private static final UnitTestLogger log = UnitTestLogger.LOGGER;
-
- private FakeQueueFactory queueFactory = new FakeQueueFactory();
-
- @Override
- @Before
- public void setUp() throws Exception
- {
- super.setUp();
- queueFactory = new FakeQueueFactory();
- }
-
- @Override
- @After
- public void tearDown() throws Exception
- {
- queueFactory.stop();
- super.tearDown();
- }
-
- /*
- * Concurrent set consumer not busy, busy then, call deliver while messages are being added and consumed
- */
- @Test
- public void testConcurrentAddsDeliver() throws Exception
- {
- QueueImpl queue = (QueueImpl)queueFactory.createQueue(1,
- new SimpleString("address1"),
- new SimpleString("queue1"),
- null,
- null,
- false,
- false,
- false);
-
- FakeConsumer consumer = new FakeConsumer();
-
- queue.addConsumer(consumer);
-
- final long testTime = 5000;
-
- Sender sender = new Sender(queue, testTime);
-
- Toggler toggler = new Toggler(queue, consumer, testTime);
-
- sender.start();
-
- toggler.start();
-
- sender.join();
-
- toggler.join();
-
- consumer.setStatusImmediate(HandleStatus.HANDLED);
-
- queue.deliverNow();
-
- if (sender.getException() != null)
- {
- throw sender.getException();
- }
-
- if (toggler.getException() != null)
- {
- throw toggler.getException();
- }
-
- assertRefListsIdenticalRefs(sender.getReferences(), consumer.getReferences());
-
- QueueTest.log.info("num refs: " + sender.getReferences().size());
-
- QueueTest.log.info("num toggles: " + toggler.getNumToggles());
-
- }
-
- // Inner classes ---------------------------------------------------------------
-
- class Sender extends Thread
- {
- private volatile Exception e;
-
- private final Queue queue;
-
- private final long testTime;
-
- private volatile int i;
-
- public Exception getException()
- {
- return e;
- }
-
- private final List<MessageReference> refs = new ArrayList<MessageReference>();
-
- public List<MessageReference> getReferences()
- {
- return refs;
- }
-
- Sender(final Queue queue, final long testTime)
- {
- this.testTime = testTime;
-
- this.queue = queue;
- }
-
- @Override
- public void run()
- {
- long start = System.currentTimeMillis();
-
- while (System.currentTimeMillis() - start < testTime)
- {
- ServerMessage message = generateMessage(i);
-
- MessageReference ref = message.createReference(queue);
-
- queue.addTail(ref, false);
-
- refs.add(ref);
-
- i++;
- }
- }
- }
-
- class Toggler extends Thread
- {
- private volatile Exception e;
-
- private final QueueImpl queue;
-
- private final FakeConsumer consumer;
-
- private final long testTime;
-
- private boolean toggle;
-
- private volatile int numToggles;
-
- public int getNumToggles()
- {
- return numToggles;
- }
-
- public Exception getException()
- {
- return e;
- }
-
- Toggler(final QueueImpl queue, final FakeConsumer consumer, final long testTime)
- {
- this.testTime = testTime;
-
- this.queue = queue;
-
- this.consumer = consumer;
- }
-
- @Override
- public void run()
- {
- long start = System.currentTimeMillis();
-
- while (System.currentTimeMillis() - start < testTime)
- {
- if (toggle)
- {
- consumer.setStatusImmediate(HandleStatus.BUSY);
- }
- else
- {
- consumer.setStatusImmediate(HandleStatus.HANDLED);
-
- queue.deliverNow();
- }
- toggle = !toggle;
-
- numToggles++;
- }
- }
- }
-
-}
[05/15] activemq-6 git commit: Refactored the testsuite a bit
Posted by jb...@apache.org.
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/3661829e/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/XARecoveryTest.java
----------------------------------------------------------------------
diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/XARecoveryTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/XARecoveryTest.java
deleted file mode 100644
index 749ab84..0000000
--- a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/XARecoveryTest.java
+++ /dev/null
@@ -1,3052 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.activemq.jms.tests;
-
-import javax.jms.Connection;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.jms.XAConnection;
-import javax.jms.XASession;
-import javax.transaction.xa.XAResource;
-import javax.transaction.xa.Xid;
-
-import com.arjuna.ats.arjuna.common.Uid;
-import com.arjuna.ats.jta.xa.XidImple;
-import org.apache.activemq.core.transaction.impl.XidImpl;
-import org.apache.activemq.jms.tests.util.ProxyAssertSupport;
-import org.junit.Ignore;
-import org.junit.Test;
-
-/**
- * A XARecoveryTest
- *
- * @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
- * @author <a href="mailto:juha@jboss.org">Juha Lindfors</a>
- */
-public class XARecoveryTest extends JMSTestCase
-{
- /*
- * In this test, we have two queues, each with four messages already in them. We send 4 more
- * messages to each queue, and ack the original 4 in a tx Then recover it without restarting the
- * server
- */
- @Test
- public void testComplexTransactionalRecoveryWithoutRestart() throws Exception
- {
- Connection conn1 = null;
-
- XAConnection conn2 = null;
-
- XAConnection conn3 = null;
-
- try
- {
- conn1 = createConnection();
-
- Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageProducer prod1 = sess1.createProducer(queue2);
-
- MessageProducer prod2 = sess1.createProducer(queue3);
-
- TextMessage tm1 = sess1.createTextMessage("tm1");
- TextMessage tm2 = sess1.createTextMessage("tm2");
- TextMessage tm3 = sess1.createTextMessage("tm3");
- TextMessage tm4 = sess1.createTextMessage("tm4");
- TextMessage tm5 = sess1.createTextMessage("tm5");
- TextMessage tm6 = sess1.createTextMessage("tm6");
- TextMessage tm7 = sess1.createTextMessage("tm7");
- TextMessage tm8 = sess1.createTextMessage("tm8");
-
- prod1.send(tm1);
- prod1.send(tm2);
- prod1.send(tm3);
- prod1.send(tm4);
-
- prod2.send(tm5);
- prod2.send(tm6);
- prod2.send(tm7);
- prod2.send(tm8);
-
- conn1.close();
-
- conn2 = createXAConnection();
-
- conn2.start();
-
- XASession sess2 = conn2.createXASession();
-
- XAResource res = sess2.getXAResource();
-
- Xid xid1 = new XidImpl("bq1".getBytes(), 42, "eemeli".getBytes());
-
- res.start(xid1, XAResource.TMNOFLAGS);
-
- MessageProducer prod3 = sess2.createProducer(queue2);
-
- TextMessage tm9 = sess2.createTextMessage("tm9");
- TextMessage tm10 = sess2.createTextMessage("tm10");
- TextMessage tm11 = sess2.createTextMessage("tm11");
- TextMessage tm12 = sess2.createTextMessage("tm12");
-
- prod3.send(tm9);
- prod3.send(tm10);
- prod3.send(tm11);
- prod3.send(tm12);
-
- MessageProducer prod4 = sess2.createProducer(queue3);
-
- TextMessage tm13 = sess2.createTextMessage("tm13");
- TextMessage tm14 = sess2.createTextMessage("tm14");
- TextMessage tm15 = sess2.createTextMessage("tm15");
- TextMessage tm16 = sess2.createTextMessage("tm16");
-
- prod4.send(tm13);
- prod4.send(tm14);
- prod4.send(tm15);
- prod4.send(tm16);
-
- MessageConsumer cons1 = sess2.createConsumer(queue2);
-
- TextMessage rm1 = (TextMessage) cons1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm1);
- ProxyAssertSupport.assertEquals(tm1.getText(), rm1.getText());
-
- TextMessage rm2 = (TextMessage) cons1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm2);
- ProxyAssertSupport.assertEquals(tm2.getText(), rm2.getText());
-
- TextMessage rm3 = (TextMessage) cons1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm3);
- ProxyAssertSupport.assertEquals(tm3.getText(), rm3.getText());
-
- TextMessage rm4 = (TextMessage) cons1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm4);
- ProxyAssertSupport.assertEquals(tm4.getText(), rm4.getText());
-
- Message m = cons1.receive(1000);
-
- ProxyAssertSupport.assertNull(m);
-
- MessageConsumer cons2 = sess2.createConsumer(queue3);
-
- TextMessage rm5 = (TextMessage) cons2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm5);
- ProxyAssertSupport.assertEquals(tm5.getText(), rm5.getText());
-
- TextMessage rm6 = (TextMessage) cons2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm6);
- ProxyAssertSupport.assertEquals(tm6.getText(), rm6.getText());
-
- TextMessage rm7 = (TextMessage) cons2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm7);
- ProxyAssertSupport.assertEquals(tm7.getText(), rm7.getText());
-
- TextMessage rm8 = (TextMessage) cons2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm8);
- ProxyAssertSupport.assertEquals(tm8.getText(), rm8.getText());
-
- m = cons2.receive(1000);
-
- ProxyAssertSupport.assertNull(m);
-
- res.end(xid1, XAResource.TMSUCCESS);
-
- // prepare it
-
- log.trace("Preparing xid " + xid1);
- res.prepare(xid1);
- log.trace("Prepared xid " + xid1);
-
- conn3 = createXAConnection();
-
- XASession sess3 = conn3.createXASession();
-
- XAResource res3 = sess3.getXAResource();
-
- Xid[] xids = res3.recover(XAResource.TMSTARTRSCAN);
- ProxyAssertSupport.assertEquals(1, xids.length);
-
- Xid[] xids2 = res3.recover(XAResource.TMENDRSCAN);
- ProxyAssertSupport.assertEquals(0, xids2.length);
-
- ProxyAssertSupport.assertEquals(xid1, xids[0]);
-
- log.trace("Committing the tx");
-
- // Commit
- res3.commit(xids[0], false);
-
- log.trace("committed the tx");
-
- conn1.close();
-
- conn2.close();
-
- conn1 = createConnection();
-
- conn1.start();
-
- sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- log.trace("creating a consumer");
-
- cons1 = sess1.createConsumer(queue2);
-
- log.trace("created a consumer");
-
- TextMessage rm9 = (TextMessage) cons1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm9);
- ProxyAssertSupport.assertEquals(tm9.getText(), rm9.getText());
-
- TextMessage rm10 = (TextMessage) cons1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm10);
- ProxyAssertSupport.assertEquals(tm10.getText(), rm10.getText());
-
- TextMessage rm11 = (TextMessage) cons1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm11);
- ProxyAssertSupport.assertEquals(tm11.getText(), rm11.getText());
-
- TextMessage rm12 = (TextMessage) cons1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm12);
- ProxyAssertSupport.assertEquals(tm12.getText(), rm12.getText());
-
- m = cons1.receive(1000);
-
- ProxyAssertSupport.assertNull(m);
-
- cons2 = sess1.createConsumer(queue3);
-
- TextMessage rm13 = (TextMessage) cons2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm13);
- ProxyAssertSupport.assertEquals(tm13.getText(), rm13.getText());
-
- TextMessage rm14 = (TextMessage) cons2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm14);
- ProxyAssertSupport.assertEquals(tm14.getText(), rm14.getText());
-
- TextMessage rm15 = (TextMessage) cons2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm15);
- ProxyAssertSupport.assertEquals(tm15.getText(), rm15.getText());
-
- TextMessage rm16 = (TextMessage) cons2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm16);
- ProxyAssertSupport.assertEquals(tm16.getText(), rm16.getText());
-
- m = cons2.receive(1000);
-
- ProxyAssertSupport.assertNull(m);
-
- }
- finally
- {
- if (conn1 != null)
- {
- conn1.close();
- }
-
- if (conn2 != null)
- {
- conn2.close();
- }
-
- if (conn3 != null)
- {
- conn3.close();
- }
- }
- }
-
- /*
- * In this test, we have two queues, each with four messages already in them.
- *
- * We send 4 more messages to each queue, and ack the original 4 in a tx
- *
- * Then recover it without restarting the server, then rollback
- *
- */
- @Test
- public void testComplexTransactionalRecoveryWithoutRestartRollback() throws Exception
- {
- Connection conn1 = null;
-
- XAConnection conn2 = null;
-
- XAConnection conn3 = null;
-
- try
- {
- conn1 = createConnection();
-
- Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageProducer prod1 = sess1.createProducer(queue2);
-
- MessageProducer prod2 = sess1.createProducer(queue3);
-
- TextMessage tm1 = sess1.createTextMessage("tm1");
- TextMessage tm2 = sess1.createTextMessage("tm2");
- TextMessage tm3 = sess1.createTextMessage("tm3");
- TextMessage tm4 = sess1.createTextMessage("tm4");
- TextMessage tm5 = sess1.createTextMessage("tm5");
- TextMessage tm6 = sess1.createTextMessage("tm6");
- TextMessage tm7 = sess1.createTextMessage("tm7");
- TextMessage tm8 = sess1.createTextMessage("tm8");
-
- prod1.send(tm1);
- prod1.send(tm2);
- prod1.send(tm3);
- prod1.send(tm4);
-
- prod2.send(tm5);
- prod2.send(tm6);
- prod2.send(tm7);
- prod2.send(tm8);
-
- conn2 = createXAConnection();
-
- conn2.start();
-
- XASession sess2 = conn2.createXASession();
-
- XAResource res = sess2.getXAResource();
-
- Xid xid1 = new XidImpl("bq1".getBytes(), 42, "eemeli".getBytes());
-
- res.start(xid1, XAResource.TMNOFLAGS);
-
- MessageProducer prod3 = sess2.createProducer(queue2);
-
- TextMessage tm9 = sess2.createTextMessage("tm9");
- TextMessage tm10 = sess2.createTextMessage("tm10");
- TextMessage tm11 = sess2.createTextMessage("tm11");
- TextMessage tm12 = sess2.createTextMessage("tm12");
-
- prod3.send(tm9);
- prod3.send(tm10);
- prod3.send(tm11);
- prod3.send(tm12);
-
- MessageProducer prod4 = sess2.createProducer(queue3);
-
- TextMessage tm13 = sess2.createTextMessage("tm13");
- TextMessage tm14 = sess2.createTextMessage("tm14");
- TextMessage tm15 = sess2.createTextMessage("tm15");
- TextMessage tm16 = sess2.createTextMessage("tm16");
-
- prod4.send(tm13);
- prod4.send(tm14);
- prod4.send(tm15);
- prod4.send(tm16);
-
- MessageConsumer cons1 = sess2.createConsumer(queue2);
-
- TextMessage rm1 = (TextMessage) cons1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm1);
- ProxyAssertSupport.assertEquals(tm1.getText(), rm1.getText());
-
- TextMessage rm2 = (TextMessage) cons1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm2);
- ProxyAssertSupport.assertEquals(tm2.getText(), rm2.getText());
-
- TextMessage rm3 = (TextMessage) cons1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm3);
- ProxyAssertSupport.assertEquals(tm3.getText(), rm3.getText());
-
- TextMessage rm4 = (TextMessage) cons1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm4);
- ProxyAssertSupport.assertEquals(tm4.getText(), rm4.getText());
-
- Message m = cons1.receive(1000);
-
- ProxyAssertSupport.assertNull(m);
-
- MessageConsumer cons2 = sess2.createConsumer(queue3);
-
- TextMessage rm5 = (TextMessage) cons2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm5);
- ProxyAssertSupport.assertEquals(tm5.getText(), rm5.getText());
-
- TextMessage rm6 = (TextMessage) cons2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm6);
- ProxyAssertSupport.assertEquals(tm6.getText(), rm6.getText());
-
- TextMessage rm7 = (TextMessage) cons2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm7);
- ProxyAssertSupport.assertEquals(tm7.getText(), rm7.getText());
-
- TextMessage rm8 = (TextMessage) cons2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm8);
- ProxyAssertSupport.assertEquals(tm8.getText(), rm8.getText());
-
- m = cons2.receive(1000);
-
- ProxyAssertSupport.assertNull(m);
-
- res.end(xid1, XAResource.TMSUCCESS);
-
- // prepare it
-
- res.prepare(xid1);
-
- conn3 = createXAConnection();
-
- XASession sess3 = conn3.createXASession();
-
- XAResource res3 = sess3.getXAResource();
-
- Xid[] xids = res3.recover(XAResource.TMSTARTRSCAN);
- ProxyAssertSupport.assertEquals(1, xids.length);
-
- Xid[] xids2 = res3.recover(XAResource.TMENDRSCAN);
- ProxyAssertSupport.assertEquals(0, xids2.length);
-
- ProxyAssertSupport.assertEquals(xid1, xids[0]);
-
- log.trace("rolling back the tx");
-
- // rollback
- res3.rollback(xids[0]);
-
- log.trace("rolledb back the tx");
-
- conn1.close();
-
- conn2.close();
-
- conn1 = createConnection();
-
- conn1.start();
-
- sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- log.trace("creating a consumer");
-
- cons1 = sess1.createConsumer(queue2);
-
- log.trace("created a consumer");
-
- TextMessage rm9 = (TextMessage) cons1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm9);
- ProxyAssertSupport.assertEquals(tm1.getText(), rm9.getText());
-
- TextMessage rm10 = (TextMessage) cons1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm10);
- ProxyAssertSupport.assertEquals(tm2.getText(), rm10.getText());
-
- TextMessage rm11 = (TextMessage) cons1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm11);
- ProxyAssertSupport.assertEquals(tm3.getText(), rm11.getText());
-
- TextMessage rm12 = (TextMessage) cons1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm12);
- ProxyAssertSupport.assertEquals(tm4.getText(), rm12.getText());
-
- m = cons1.receive(1000);
-
- ProxyAssertSupport.assertNull(m);
-
- cons2 = sess1.createConsumer(queue3);
-
- TextMessage rm13 = (TextMessage) cons2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm13);
- ProxyAssertSupport.assertEquals(tm5.getText(), rm13.getText());
-
- TextMessage rm14 = (TextMessage) cons2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm14);
- ProxyAssertSupport.assertEquals(tm6.getText(), rm14.getText());
-
- TextMessage rm15 = (TextMessage) cons2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm15);
- ProxyAssertSupport.assertEquals(tm7.getText(), rm15.getText());
-
- TextMessage rm16 = (TextMessage) cons2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm16);
- ProxyAssertSupport.assertEquals(tm8.getText(), rm16.getText());
-
- m = cons2.receive(1000);
-
- ProxyAssertSupport.assertNull(m);
- }
- finally
- {
- if (conn1 != null)
- {
- try
- {
- conn1.close();
- }
- catch (Exception e)
- {
- // Ignore
- }
- }
-
- if (conn2 != null)
- {
- try
- {
- conn2.close();
- }
- catch (Exception e)
- {
- // Ignore
- }
- }
-
- if (conn3 != null)
- {
- try
- {
- conn3.close();
- }
- catch (Exception e)
- {
- // Ignore
- }
- }
- }
- }
-
- /*
- * In this test, we have two queues, each with four messages already in them.
- *
- * We send 4 more messages to each queue, and ack the original 4 in a tx
- *
- * Then recover it after restarting the server
- *
- */
- @Test
- public void testComplexTransactionalRecoveryWithRestart() throws Exception
- {
- Connection conn1 = null;
-
- XAConnection conn2 = null;
-
- XAConnection conn3 = null;
-
- try
- {
- conn1 = createConnection();
-
- Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageProducer prod1 = sess1.createProducer(queue2);
-
- MessageProducer prod2 = sess1.createProducer(queue3);
-
- TextMessage tm1 = sess1.createTextMessage("tm1");
- TextMessage tm2 = sess1.createTextMessage("tm2");
- TextMessage tm3 = sess1.createTextMessage("tm3");
- TextMessage tm4 = sess1.createTextMessage("tm4");
- TextMessage tm5 = sess1.createTextMessage("tm5");
- TextMessage tm6 = sess1.createTextMessage("tm6");
- TextMessage tm7 = sess1.createTextMessage("tm7");
- TextMessage tm8 = sess1.createTextMessage("tm8");
-
- prod1.send(tm1);
- prod1.send(tm2);
- prod1.send(tm3);
- prod1.send(tm4);
-
- prod2.send(tm5);
- prod2.send(tm6);
- prod2.send(tm7);
- prod2.send(tm8);
-
- conn2 = createXAConnection();
-
- conn2.start();
-
- XASession sess2 = conn2.createXASession();
-
- XAResource res = sess2.getXAResource();
-
- Xid xid1 = new XidImpl("bq1".getBytes(), 42, "eemeli".getBytes());
-
- res.start(xid1, XAResource.TMNOFLAGS);
-
- MessageProducer prod3 = sess2.createProducer(queue2);
-
- TextMessage tm9 = sess2.createTextMessage("tm9");
- TextMessage tm10 = sess2.createTextMessage("tm10");
- TextMessage tm11 = sess2.createTextMessage("tm11");
- TextMessage tm12 = sess2.createTextMessage("tm12");
-
- prod3.send(tm9);
- prod3.send(tm10);
- prod3.send(tm11);
- prod3.send(tm12);
-
- MessageProducer prod4 = sess2.createProducer(queue3);
-
- TextMessage tm13 = sess2.createTextMessage("tm13");
- TextMessage tm14 = sess2.createTextMessage("tm14");
- TextMessage tm15 = sess2.createTextMessage("tm15");
- TextMessage tm16 = sess2.createTextMessage("tm16");
-
- prod4.send(tm13);
- prod4.send(tm14);
- prod4.send(tm15);
- prod4.send(tm16);
-
- MessageConsumer cons1 = sess2.createConsumer(queue2);
-
- TextMessage rm1 = (TextMessage) cons1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm1);
- ProxyAssertSupport.assertEquals(tm1.getText(), rm1.getText());
-
- TextMessage rm2 = (TextMessage) cons1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm2);
- ProxyAssertSupport.assertEquals(tm2.getText(), rm2.getText());
-
- TextMessage rm3 = (TextMessage) cons1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm3);
- ProxyAssertSupport.assertEquals(tm3.getText(), rm3.getText());
-
- TextMessage rm4 = (TextMessage) cons1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm4);
- ProxyAssertSupport.assertEquals(tm4.getText(), rm4.getText());
-
- Message m = cons1.receive(1000);
-
- ProxyAssertSupport.assertNull(m);
-
- MessageConsumer cons2 = sess2.createConsumer(queue3);
-
- TextMessage rm5 = (TextMessage) cons2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm5);
- ProxyAssertSupport.assertEquals(tm5.getText(), rm5.getText());
-
- TextMessage rm6 = (TextMessage) cons2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm6);
- ProxyAssertSupport.assertEquals(tm6.getText(), rm6.getText());
-
- TextMessage rm7 = (TextMessage) cons2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm7);
- ProxyAssertSupport.assertEquals(tm7.getText(), rm7.getText());
-
- TextMessage rm8 = (TextMessage) cons2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm8);
- ProxyAssertSupport.assertEquals(tm8.getText(), rm8.getText());
-
- m = cons2.receive(1000);
-
- ProxyAssertSupport.assertNull(m);
-
- res.end(xid1, XAResource.TMSUCCESS);
-
- // prepare it
-
- res.prepare(xid1);
-
- conn1.close();
- conn2.close();
-
- conn1 = null;
-
- conn2 = null;
-
- // Now "crash" the server
-
- stopServerPeer();
-
- startServerPeer();
-
- deployAndLookupAdministeredObjects();
-
- conn3 = createXAConnection();
-
- XASession sess3 = conn3.createXASession();
-
- XAResource res3 = sess3.getXAResource();
-
- Xid[] xids = res3.recover(XAResource.TMSTARTRSCAN);
- ProxyAssertSupport.assertEquals(1, xids.length);
-
- Xid[] xids2 = res3.recover(XAResource.TMENDRSCAN);
- ProxyAssertSupport.assertEquals(0, xids2.length);
-
- ProxyAssertSupport.assertEquals(xid1, xids[0]);
-
- log.trace("Committing the tx");
-
- // Commit
- res3.commit(xids[0], false);
-
- log.trace("committed the tx");
-
- conn1 = createConnection();
-
- conn1.start();
-
- sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- log.trace("creating a consumer");
-
- cons1 = sess1.createConsumer(queue2);
-
- log.trace("created a consumer");
-
- TextMessage rm9 = (TextMessage) cons1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm9);
- ProxyAssertSupport.assertEquals(tm9.getText(), rm9.getText());
-
- TextMessage rm10 = (TextMessage) cons1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm10);
- ProxyAssertSupport.assertEquals(tm10.getText(), rm10.getText());
-
- TextMessage rm11 = (TextMessage) cons1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm11);
- ProxyAssertSupport.assertEquals(tm11.getText(), rm11.getText());
-
- TextMessage rm12 = (TextMessage) cons1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm12);
- ProxyAssertSupport.assertEquals(tm12.getText(), rm12.getText());
-
- m = cons1.receive(1000);
-
- ProxyAssertSupport.assertNull(m);
-
- cons2 = sess1.createConsumer(queue3);
-
- TextMessage rm13 = (TextMessage) cons2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm13);
- ProxyAssertSupport.assertEquals(tm13.getText(), rm13.getText());
-
- TextMessage rm14 = (TextMessage) cons2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm14);
- ProxyAssertSupport.assertEquals(tm14.getText(), rm14.getText());
-
- TextMessage rm15 = (TextMessage) cons2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm15);
- ProxyAssertSupport.assertEquals(tm15.getText(), rm15.getText());
-
- TextMessage rm16 = (TextMessage) cons2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm16);
- ProxyAssertSupport.assertEquals(tm16.getText(), rm16.getText());
-
- m = cons2.receive(1000);
-
- ProxyAssertSupport.assertNull(m);
- }
- finally
- {
- if (conn1 != null)
- {
- try
- {
- conn1.close();
- }
- catch (Exception e)
- {
- // Ignore
- }
- }
-
- if (conn2 != null)
- {
- try
- {
- conn2.close();
- }
- catch (Exception e)
- {
- // Ignore
- }
- }
-
- if (conn3 != null)
- {
- try
- {
- conn3.close();
- }
- catch (Exception e)
- {
- // Ignore
- }
- }
- Thread.sleep(1000);
- removeAllMessages(queue2.getQueueName(), true);
- removeAllMessages(queue3.getQueueName(), true);
- }
- }
-
- /*
- * In this test, we have two queues, each with four messages already in them.
- *
- * We send 4 more messages to each queue, and ack the original 4 in a tx
- *
- * Then recover it after restarting the server, then rollback
- *
- */
- @Test
- public void testComplexTransactionalRecoveryWithRestartRollback() throws Exception
- {
- Connection conn1 = null;
-
- XAConnection conn2 = null;
-
- XAConnection conn3 = null;
-
- try
- {
- conn1 = createConnection();
-
- Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageProducer prod1 = sess1.createProducer(queue2);
-
- MessageProducer prod2 = sess1.createProducer(queue3);
-
- TextMessage tm1 = sess1.createTextMessage("tm1");
- TextMessage tm2 = sess1.createTextMessage("tm2");
- TextMessage tm3 = sess1.createTextMessage("tm3");
- TextMessage tm4 = sess1.createTextMessage("tm4");
- TextMessage tm5 = sess1.createTextMessage("tm5");
- TextMessage tm6 = sess1.createTextMessage("tm6");
- TextMessage tm7 = sess1.createTextMessage("tm7");
- TextMessage tm8 = sess1.createTextMessage("tm8");
-
- prod1.send(tm1);
- prod1.send(tm2);
- prod1.send(tm3);
- prod1.send(tm4);
-
- prod2.send(tm5);
- prod2.send(tm6);
- prod2.send(tm7);
- prod2.send(tm8);
-
- conn2 = createXAConnection();
-
- conn2.start();
-
- XASession sess2 = conn2.createXASession();
-
- XAResource res = sess2.getXAResource();
-
- Xid xid1 = new XidImpl("bq1".getBytes(), 42, "eemeli".getBytes());
-
- res.start(xid1, XAResource.TMNOFLAGS);
-
- MessageProducer prod3 = sess2.createProducer(queue2);
-
- TextMessage tm9 = sess2.createTextMessage("tm9");
- TextMessage tm10 = sess2.createTextMessage("tm10");
- TextMessage tm11 = sess2.createTextMessage("tm11");
- TextMessage tm12 = sess2.createTextMessage("tm12");
-
- prod3.send(tm9);
- prod3.send(tm10);
- prod3.send(tm11);
- prod3.send(tm12);
-
- MessageProducer prod4 = sess2.createProducer(queue3);
-
- TextMessage tm13 = sess2.createTextMessage("tm13");
- TextMessage tm14 = sess2.createTextMessage("tm14");
- TextMessage tm15 = sess2.createTextMessage("tm15");
- TextMessage tm16 = sess2.createTextMessage("tm16");
-
- prod4.send(tm13);
- prod4.send(tm14);
- prod4.send(tm15);
- prod4.send(tm16);
-
- MessageConsumer cons1 = sess2.createConsumer(queue2);
-
- TextMessage rm1 = (TextMessage) cons1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm1);
- ProxyAssertSupport.assertEquals(tm1.getText(), rm1.getText());
-
- TextMessage rm2 = (TextMessage) cons1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm2);
- ProxyAssertSupport.assertEquals(tm2.getText(), rm2.getText());
-
- TextMessage rm3 = (TextMessage) cons1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm3);
- ProxyAssertSupport.assertEquals(tm3.getText(), rm3.getText());
-
- TextMessage rm4 = (TextMessage) cons1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm4);
- ProxyAssertSupport.assertEquals(tm4.getText(), rm4.getText());
-
- Message m = cons1.receive(1000);
-
- ProxyAssertSupport.assertNull(m);
-
- MessageConsumer cons2 = sess2.createConsumer(queue3);
-
- TextMessage rm5 = (TextMessage) cons2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm5);
- ProxyAssertSupport.assertEquals(tm5.getText(), rm5.getText());
-
- TextMessage rm6 = (TextMessage) cons2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm6);
- ProxyAssertSupport.assertEquals(tm6.getText(), rm6.getText());
-
- TextMessage rm7 = (TextMessage) cons2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm7);
- ProxyAssertSupport.assertEquals(tm7.getText(), rm7.getText());
-
- TextMessage rm8 = (TextMessage) cons2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm8);
- ProxyAssertSupport.assertEquals(tm8.getText(), rm8.getText());
-
- m = cons2.receive(1000);
-
- ProxyAssertSupport.assertNull(m);
-
- res.end(xid1, XAResource.TMSUCCESS);
-
- // prepare it
-
- res.prepare(xid1);
-
- conn1.close();
- conn2.close();
- conn1 = null;
-
- conn2 = null;
-
- // Now "crash" the server
-
- stopServerPeer();
-
- startServerPeer();
-
- deployAndLookupAdministeredObjects();
-
- conn3 = createXAConnection();
-
- XASession sess3 = conn3.createXASession();
-
- XAResource res3 = sess3.getXAResource();
-
- Xid[] xids = res3.recover(XAResource.TMSTARTRSCAN);
- ProxyAssertSupport.assertEquals(1, xids.length);
-
- Xid[] xids2 = res3.recover(XAResource.TMENDRSCAN);
- ProxyAssertSupport.assertEquals(0, xids2.length);
-
- ProxyAssertSupport.assertEquals(xid1, xids[0]);
-
- log.trace("rolling back the tx");
-
- // rollback
- res3.rollback(xids[0]);
-
- log.trace("rolled back the tx");
-
- Thread.sleep(1000);
-
- conn1 = createConnection();
-
- conn1.start();
-
- sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- log.trace("creating a consumer");
-
- cons1 = sess1.createConsumer(queue2);
-
- log.trace("created a consumer");
-
- TextMessage rm9 = (TextMessage) cons1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm9);
- ProxyAssertSupport.assertEquals(tm1.getText(), rm9.getText());
-
- TextMessage rm10 = (TextMessage) cons1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm10);
- ProxyAssertSupport.assertEquals(tm2.getText(), rm10.getText());
-
- TextMessage rm11 = (TextMessage) cons1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm11);
- ProxyAssertSupport.assertEquals(tm3.getText(), rm11.getText());
-
- TextMessage rm12 = (TextMessage) cons1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm12);
- ProxyAssertSupport.assertEquals(tm4.getText(), rm12.getText());
-
- m = cons1.receive(1000);
-
- ProxyAssertSupport.assertNull(m);
-
- cons2 = sess1.createConsumer(queue3);
-
- TextMessage rm13 = (TextMessage) cons2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm13);
- ProxyAssertSupport.assertEquals(tm5.getText(), rm13.getText());
-
- TextMessage rm14 = (TextMessage) cons2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm14);
- ProxyAssertSupport.assertEquals(tm6.getText(), rm14.getText());
-
- TextMessage rm15 = (TextMessage) cons2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm15);
- ProxyAssertSupport.assertEquals(tm7.getText(), rm15.getText());
-
- TextMessage rm16 = (TextMessage) cons2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm16);
- ProxyAssertSupport.assertEquals(tm8.getText(), rm16.getText());
-
- m = cons2.receive(1000);
-
- ProxyAssertSupport.assertNull(m);
-
- cons1.close();
- }
- finally
- {
- if (conn1 != null)
- {
- try
- {
- conn1.close();
- }
- catch (Exception e)
- {
- // Ignore
- }
- }
-
- if (conn2 != null)
- {
- try
- {
- conn2.close();
- }
- catch (Exception e)
- {
- // Ignore
- }
- }
-
- if (conn3 != null)
- {
- try
- {
- conn3.close();
- }
- catch (Exception e)
- {
- // Ignore
- }
- }
- }
- }
-
- /* Not really necessary - but it does no harm */
- @Test
- public void testComplexTransactional() throws Exception
- {
- Connection conn1 = null;
-
- XAConnection conn2 = null;
-
- XAConnection conn3 = null;
-
- try
- {
- conn1 = createConnection();
-
- Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageProducer prod1 = sess1.createProducer(queue2);
-
- MessageProducer prod2 = sess1.createProducer(queue3);
-
- TextMessage tm1 = sess1.createTextMessage("tm1");
- TextMessage tm2 = sess1.createTextMessage("tm2");
- TextMessage tm3 = sess1.createTextMessage("tm3");
- TextMessage tm4 = sess1.createTextMessage("tm4");
- TextMessage tm5 = sess1.createTextMessage("tm5");
- TextMessage tm6 = sess1.createTextMessage("tm6");
- TextMessage tm7 = sess1.createTextMessage("tm7");
- TextMessage tm8 = sess1.createTextMessage("tm8");
-
- prod1.send(tm1);
- prod1.send(tm2);
- prod1.send(tm3);
- prod1.send(tm4);
-
- prod2.send(tm5);
- prod2.send(tm6);
- prod2.send(tm7);
- prod2.send(tm8);
-
- conn2 = createXAConnection();
-
- conn2.start();
-
- XASession sess2 = conn2.createXASession();
-
- XAResource res = sess2.getXAResource();
-
- Xid xid1 = new XidImpl("bq1".getBytes(), 42, "eemeli".getBytes());
-
- res.start(xid1, XAResource.TMNOFLAGS);
-
- MessageProducer prod3 = sess2.createProducer(queue2);
-
- TextMessage tm9 = sess2.createTextMessage("tm9");
- TextMessage tm10 = sess2.createTextMessage("tm10");
- TextMessage tm11 = sess2.createTextMessage("tm11");
- TextMessage tm12 = sess2.createTextMessage("tm12");
-
- prod3.send(tm9);
- prod3.send(tm10);
- prod3.send(tm11);
- prod3.send(tm12);
-
- MessageProducer prod4 = sess2.createProducer(queue3);
-
- TextMessage tm13 = sess2.createTextMessage("tm13");
- TextMessage tm14 = sess2.createTextMessage("tm14");
- TextMessage tm15 = sess2.createTextMessage("tm15");
- TextMessage tm16 = sess2.createTextMessage("tm16");
-
- prod4.send(tm13);
- prod4.send(tm14);
- prod4.send(tm15);
- prod4.send(tm16);
-
- MessageConsumer cons1 = sess2.createConsumer(queue2);
-
- TextMessage rm1 = (TextMessage) cons1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm1);
- ProxyAssertSupport.assertEquals(tm1.getText(), rm1.getText());
-
- TextMessage rm2 = (TextMessage) cons1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm2);
- ProxyAssertSupport.assertEquals(tm2.getText(), rm2.getText());
-
- TextMessage rm3 = (TextMessage) cons1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm3);
- ProxyAssertSupport.assertEquals(tm3.getText(), rm3.getText());
-
- TextMessage rm4 = (TextMessage) cons1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm4);
- ProxyAssertSupport.assertEquals(tm4.getText(), rm4.getText());
-
- Message m = cons1.receive(1000);
-
- ProxyAssertSupport.assertNull(m);
-
- MessageConsumer cons2 = sess2.createConsumer(queue3);
-
- TextMessage rm5 = (TextMessage) cons2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm5);
- ProxyAssertSupport.assertEquals(tm5.getText(), rm5.getText());
-
- TextMessage rm6 = (TextMessage) cons2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm6);
- ProxyAssertSupport.assertEquals(tm6.getText(), rm6.getText());
-
- TextMessage rm7 = (TextMessage) cons2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm7);
- ProxyAssertSupport.assertEquals(tm7.getText(), rm7.getText());
-
- TextMessage rm8 = (TextMessage) cons2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm8);
- ProxyAssertSupport.assertEquals(tm8.getText(), rm8.getText());
-
- m = cons2.receive(1000);
-
- ProxyAssertSupport.assertNull(m);
-
- res.end(xid1, XAResource.TMSUCCESS);
-
- // prepare it
-
- res.prepare(xid1);
-
- res.commit(xid1, false);
-
- conn1.close();
-
- conn2.close();
-
- conn1 = createConnection();
-
- conn1.start();
-
- sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- cons1 = sess1.createConsumer(queue2);
-
- TextMessage rm9 = (TextMessage) cons1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm9);
- ProxyAssertSupport.assertEquals(tm9.getText(), rm9.getText());
-
- TextMessage rm10 = (TextMessage) cons1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm10);
- ProxyAssertSupport.assertEquals(tm10.getText(), rm10.getText());
-
- TextMessage rm11 = (TextMessage) cons1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm11);
- ProxyAssertSupport.assertEquals(tm11.getText(), rm11.getText());
-
- TextMessage rm12 = (TextMessage) cons1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm12);
- ProxyAssertSupport.assertEquals(tm12.getText(), rm12.getText());
-
- m = cons1.receive(1000);
-
- ProxyAssertSupport.assertNull(m);
-
- cons2 = sess1.createConsumer(queue3);
-
- TextMessage rm13 = (TextMessage) cons2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm13);
- ProxyAssertSupport.assertEquals(tm13.getText(), rm13.getText());
-
- TextMessage rm14 = (TextMessage) cons2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm14);
- ProxyAssertSupport.assertEquals(tm14.getText(), rm14.getText());
-
- TextMessage rm15 = (TextMessage) cons2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm15);
- ProxyAssertSupport.assertEquals(tm15.getText(), rm15.getText());
-
- TextMessage rm16 = (TextMessage) cons2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm16);
- ProxyAssertSupport.assertEquals(tm16.getText(), rm16.getText());
-
- m = cons2.receive(1000);
-
- ProxyAssertSupport.assertNull(m);
- }
- finally
- {
- if (conn1 != null)
- {
- try
- {
- conn1.close();
- }
- catch (Exception e)
- {
- // Ignore
- }
- }
-
- if (conn2 != null)
- {
- try
- {
- conn2.close();
- }
- catch (Exception e)
- {
- // Ignore
- }
- }
-
- if (conn3 != null)
- {
- try
- {
- conn3.close();
- }
- catch (Exception e)
- {
- // Ignore
- }
- }
- }
- }
-
- /* A simple send in a transaction - recovered without restarting the server */
- @Test
- public void testSimpleTransactionalSendRecoveryWithoutRestart() throws Exception
- {
- log.trace("starting testSimpleTransactionalDeliveryRecoveryWithoutRestart");
-
- XAConnection conn1 = null;
-
- Connection conn2 = null;
-
- XAConnection conn3 = null;
-
- try
- {
- conn1 = createXAConnection();
-
- XASession sess1 = conn1.createXASession();
-
- XAResource res1 = sess1.getXAResource();
-
- // Pretend to be a transaction manager by interacting through the XAResources
- Xid xid1 = new XidImpl("bq1".getBytes(), 42, "eemeli".getBytes());
-
- log.trace("Sending message");
-
- // Send message in tx
-
- res1.start(xid1, XAResource.TMNOFLAGS);
-
- MessageProducer prod1 = sess1.createProducer(queue4);
-
- TextMessage tm1 = sess1.createTextMessage("tm1");
-
- prod1.send(tm1);
-
- res1.end(xid1, XAResource.TMSUCCESS);
-
- log.trace("Sent message");
-
- // prepare tx
-
- res1.prepare(xid1);
-
- log.trace("prepared tx");
-
- conn2 = createConnection();
-
- Session sess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageConsumer cons2 = sess2.createConsumer(queue4);
-
- conn2.start();
-
- // Verify message can't be received
-
- Message m = cons2.receive(1000);
-
- ProxyAssertSupport.assertNull(m);
-
- // Now recover
-
- conn3 = createXAConnection();
-
- XASession sess3 = conn3.createXASession();
-
- XAResource res3 = sess3.getXAResource();
-
- Xid[] xids = res3.recover(XAResource.TMSTARTRSCAN);
- ProxyAssertSupport.assertEquals(1, xids.length);
-
- Xid[] xids2 = res3.recover(XAResource.TMENDRSCAN);
- ProxyAssertSupport.assertEquals(0, xids2.length);
-
- ProxyAssertSupport.assertEquals(xid1, xids[0]);
-
- // Verify message still can't be received
-
- m = cons2.receive(1000);
-
- ProxyAssertSupport.assertNull(m);
-
- // Commit the tx
-
- res1.commit(xids[0], false);
-
- // The message should now be available
-
- TextMessage rm1 = (TextMessage) cons2.receive(1000);
-
- ProxyAssertSupport.assertNotNull(rm1);
-
- ProxyAssertSupport.assertEquals(tm1.getText(), rm1.getText());
-
- }
- finally
- {
- if (conn1 != null)
- {
- try
- {
- conn1.close();
- }
- catch (Exception e)
- {
- // Ignore
- }
- }
-
- if (conn2 != null)
- {
- try
- {
- conn2.close();
- }
- catch (Exception e)
- {
- // Ignore
- }
- }
-
- if (conn3 != null)
- {
- try
- {
- conn3.close();
- }
- catch (Exception e)
- {
- // Ignore
- }
- }
- }
- }
-
- /* A simple send in a transaction - recovered after restarting the server */
- @Test
- public void testSimpleTransactionalSendRecoveryWithRestart() throws Exception
- {
- log.trace("starting testSimpleTransactionalDeliveryRecoveryWithRestart");
-
- XAConnection conn1 = null;
-
- Connection conn2 = null;
-
- XAConnection conn3 = null;
-
- try
- {
- conn1 = createXAConnection();
-
- XASession sess1 = conn1.createXASession();
-
- XAResource res1 = sess1.getXAResource();
-
- // Pretend to be a transaction manager by interacting through the XAResources
- Xid xid1 = new XidImpl("bq1".getBytes(), 42, "eemeli".getBytes());
-
- log.trace("Sending message");
-
- // Send message in tx
-
- res1.start(xid1, XAResource.TMNOFLAGS);
-
- MessageProducer prod1 = sess1.createProducer(queue4);
-
- TextMessage tm1 = sess1.createTextMessage("tm1");
-
- prod1.send(tm1);
-
- res1.end(xid1, XAResource.TMSUCCESS);
-
- log.trace("Sent message");
-
- // prepare tx
-
- res1.prepare(xid1);
-
- log.trace("prepared tx");
-
- conn2 = createConnection();
-
- Session sess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageConsumer cons2 = sess2.createConsumer(queue4);
-
- conn2.start();
-
- // Verify message can't be received
-
- Message m = cons2.receive(1000);
-
- ProxyAssertSupport.assertNull(m);
-
- conn1.close();
-
- conn2.close();
-
- conn1 = null;
-
- conn2 = null;
-
- // Now "crash" the server
-
- stopServerPeer();
-
- startServerPeer();
-
- deployAndLookupAdministeredObjects();
-
- conn3 = createXAConnection();
-
- XASession sess3 = conn3.createXASession();
-
- XAResource res3 = sess3.getXAResource();
-
- log.trace("created connection");
-
- Xid[] xids = res3.recover(XAResource.TMSTARTRSCAN);
- ProxyAssertSupport.assertEquals(1, xids.length);
-
- Xid[] xids2 = res3.recover(XAResource.TMENDRSCAN);
- ProxyAssertSupport.assertEquals(0, xids2.length);
-
- ProxyAssertSupport.assertEquals(xid1, xids[0]);
-
- log.trace("recovered");
-
- conn2 = createConnection();
-
- sess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- cons2 = sess2.createConsumer(queue4);
-
- conn2.start();
-
- // Verify message still can't be received
-
- m = cons2.receive(1000);
-
- ProxyAssertSupport.assertNull(m);
-
- log.trace("still can't see message");
-
- // Commit the tx
-
- res3.commit(xids[0], false);
-
- log.trace("committed");
-
- // The message should now be available
-
- TextMessage rm1 = (TextMessage) cons2.receive(1000);
-
- ProxyAssertSupport.assertNotNull(rm1);
-
- ProxyAssertSupport.assertEquals(tm1.getText(), rm1.getText());
-
- }
- finally
- {
- if (conn1 != null)
- {
- try
- {
- conn1.close();
- }
- catch (Exception e)
- {
- // Ignore
- }
- }
-
- if (conn2 != null)
- {
- try
- {
- conn2.close();
- }
- catch (Exception e)
- {
- // Ignore
- }
- }
-
- if (conn3 != null)
- {
- try
- {
- conn3.close();
- }
- catch (Exception e)
- {
- // Ignore
- }
- }
- }
- }
-
- /* A simple acknowledgement in a transaction, recovered without restart */
- @Test
- public void testSimpleTransactionalAcknowledgementRecoveryWithoutRestart() throws Exception
- {
- log.trace("starting testSimpleTransactionalAcknowledgementRecovery");
-
- Connection conn1 = null;
-
- XAConnection conn2 = null;
-
- XAConnection conn3 = null;
-
- try
- {
- // First send a message to the queue
- conn1 = createConnection();
-
- Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageProducer prod = sess1.createProducer(queue4);
-
- TextMessage tm1 = sess1.createTextMessage("tm1");
-
- prod.send(tm1);
-
- conn2 = createXAConnection();
-
- XASession sess2 = conn2.createXASession();
-
- XAResource res1 = sess2.getXAResource();
-
- // Pretend to be a transaction manager by interacting through the XAResources
- Xid xid1 = new XidImpl("bq1".getBytes(), 42, "eemeli".getBytes());
-
- res1.start(xid1, XAResource.TMNOFLAGS);
-
- MessageConsumer cons = sess2.createConsumer(queue4);
-
- conn2.start();
-
- // Consume the message
-
- TextMessage rm1 = (TextMessage) cons.receive(1000);
-
- ProxyAssertSupport.assertNotNull(rm1);
-
- ProxyAssertSupport.assertEquals(tm1.getText(), rm1.getText());
-
- res1.end(xid1, XAResource.TMSUCCESS);
-
- // prepare the tx
-
- res1.prepare(xid1);
-
- // Now recover
-
- conn3 = createXAConnection();
-
- XASession sess3 = conn3.createXASession();
-
- XAResource res3 = sess3.getXAResource();
-
- Xid[] xids = res3.recover(XAResource.TMSTARTRSCAN);
- ProxyAssertSupport.assertEquals(1, xids.length);
-
- Xid[] xids2 = res3.recover(XAResource.TMENDRSCAN);
- ProxyAssertSupport.assertEquals(0, xids2.length);
-
- ProxyAssertSupport.assertEquals(xid1, xids[0]);
-
- // Commit the tx
-
- res1.commit(xids[0], false);
-
- // The message should be acknowldged
-
- conn1.close();
-
- conn2.close();
-
- conn3.close();
-
- conn1 = createConnection();
-
- sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageConsumer cons1 = sess1.createConsumer(queue4);
-
- conn1.start();
-
- Message m = cons1.receive(1000);
-
- ProxyAssertSupport.assertNull(m);
-
- }
- finally
- {
- if (conn1 != null)
- {
- try
- {
- conn1.close();
- }
- catch (Exception e)
- {
- // Ignore
- }
- }
-
- if (conn2 != null)
- {
- try
- {
- conn2.close();
- }
- catch (Exception e)
- {
- // Ignore
- }
- }
-
- if (conn3 != null)
- {
- try
- {
- conn3.close();
- }
- catch (Exception e)
- {
- // Ignore
- }
- }
- }
- }
-
- /* A simple acknowledgement in a transaction, recovered with restart */
- @Test
- public void testSimpleTransactionalAcknowledgementRecoveryWithRestart() throws Exception
- {
- log.trace("starting testSimpleTransactionalAcknowledgementRecoveryWithRestart");
-
- Connection conn1 = null;
-
- XAConnection conn2 = null;
-
- XAConnection conn3 = null;
-
- try
- {
- // First send a message to the queue
- conn1 = createConnection();
-
- Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageProducer prod = sess1.createProducer(queue4);
-
- TextMessage tm1 = sess1.createTextMessage("tm1");
-
- prod.send(tm1);
-
- conn2 = createXAConnection();
-
- XASession sess2 = conn2.createXASession();
-
- XAResource res1 = sess2.getXAResource();
-
- // Pretend to be a transaction manager by interacting through the XAResources
- Xid xid1 = new XidImpl("bq1".getBytes(), 42, "eemeli".getBytes());
-
- res1.start(xid1, XAResource.TMNOFLAGS);
-
- MessageConsumer cons = sess2.createConsumer(queue4);
-
- conn2.start();
-
- // Consume the message
-
- TextMessage rm1 = (TextMessage) cons.receive(1000);
-
- ProxyAssertSupport.assertNotNull(rm1);
-
- ProxyAssertSupport.assertEquals(tm1.getText(), rm1.getText());
-
- res1.end(xid1, XAResource.TMSUCCESS);
-
- // prepare the tx
-
- res1.prepare(xid1);
-
- conn1.close();
-
- conn2.close();
-
- conn1 = null;
-
- conn2 = null;
-
- // Now "crash" the server
-
- stopServerPeer();
-
- startServerPeer();
-
- deployAndLookupAdministeredObjects();
-
- // Now recover
-
- conn3 = createXAConnection();
-
- XASession sess3 = conn3.createXASession();
-
- XAResource res3 = sess3.getXAResource();
-
- Xid[] xids = res3.recover(XAResource.TMSTARTRSCAN);
- ProxyAssertSupport.assertEquals(1, xids.length);
-
- Xid[] xids2 = res3.recover(XAResource.TMENDRSCAN);
- ProxyAssertSupport.assertEquals(0, xids2.length);
-
- ProxyAssertSupport.assertEquals(xid1, xids[0]);
-
- // Commit the tx
-
- res3.commit(xids[0], false);
-
- // The message should be acknowldged
-
- conn3.close();
-
- conn1 = createConnection();
-
- sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageConsumer cons1 = sess1.createConsumer(queue4);
-
- conn1.start();
-
- Message m = cons1.receive(1000);
-
- ProxyAssertSupport.assertNull(m);
-
- }
- finally
- {
- if (conn1 != null)
- {
- try
- {
- conn1.close();
- }
- catch (Exception e)
- {
- // Ignore
- }
- }
-
- if (conn2 != null)
- {
- try
- {
- conn2.close();
- }
- catch (Exception e)
- {
- // Ignore
- }
- }
-
- if (conn3 != null)
- {
- try
- {
- conn3.close();
- }
- catch (Exception e)
- {
- // Ignore
- }
- }
- }
- }
-
- /*
- * In this test, we have 4 messages in a 2 durable subs on the same topic.
- *
- * We ack them, then add four more messages
- *
- * This test tests for the recovery when the same message is in multiple channels
- *
- * We don't restart in this test
- *
- */
- @Test
- public void testRecoveryWithTwoDurableSubsWithoutRestart() throws Exception
- {
- Connection conn1 = null;
-
- XAConnection conn2 = null;
-
- XAConnection conn3 = null;
-
- try
- {
- conn1 = createConnection();
-
- conn1.setClientID("wib1");
-
- Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageProducer prod1 = sess1.createProducer(ActiveMQServerTestCase.topic2);
-
- MessageConsumer sub1 = sess1.createDurableSubscriber(ActiveMQServerTestCase.topic2, "sub1");
-
- MessageConsumer sub2 = sess1.createDurableSubscriber(ActiveMQServerTestCase.topic2, "sub2");
-
- // send four messages
-
- TextMessage tm1 = sess1.createTextMessage("tm1");
- TextMessage tm2 = sess1.createTextMessage("tm2");
- TextMessage tm3 = sess1.createTextMessage("tm3");
- TextMessage tm4 = sess1.createTextMessage("tm4");
-
- prod1.send(tm1);
- prod1.send(tm2);
- prod1.send(tm3);
- prod1.send(tm4);
-
- conn1.close();
-
- // The messages should now be in both durable subs
-
- conn2 = createXAConnection();
-
- conn2.setClientID("wib1");
-
- conn2.start();
-
- XASession sess2 = conn2.createXASession();
-
- XAResource res = sess2.getXAResource();
-
- Xid xid1 = new XidImpl("bq1".getBytes(), 42, "eemeli".getBytes());
-
- res.start(xid1, XAResource.TMNOFLAGS);
-
- // Now send four more messages in a global tx
-
- MessageProducer prod2 = sess2.createProducer(ActiveMQServerTestCase.topic2);
-
- TextMessage tm5 = sess2.createTextMessage("tm5");
- TextMessage tm6 = sess2.createTextMessage("tm6");
- TextMessage tm7 = sess2.createTextMessage("tm7");
- TextMessage tm8 = sess2.createTextMessage("tm8");
-
- prod2.send(tm5);
- prod2.send(tm6);
- prod2.send(tm7);
- prod2.send(tm8);
-
- // And consume the first four from each in the tx
-
- sub1 = sess2.createDurableSubscriber(ActiveMQServerTestCase.topic2, "sub1");
-
- sub2 = sess2.createDurableSubscriber(ActiveMQServerTestCase.topic2, "sub2");
-
- TextMessage rm1 = (TextMessage) sub1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm1);
- ProxyAssertSupport.assertEquals(tm1.getText(), rm1.getText());
-
- TextMessage rm2 = (TextMessage) sub1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm2);
- ProxyAssertSupport.assertEquals(tm2.getText(), rm2.getText());
-
- TextMessage rm3 = (TextMessage) sub1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm3);
- ProxyAssertSupport.assertEquals(tm3.getText(), rm3.getText());
-
- TextMessage rm4 = (TextMessage) sub1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm4);
- ProxyAssertSupport.assertEquals(tm4.getText(), rm4.getText());
-
- Message m = sub1.receive(1000);
-
- ProxyAssertSupport.assertNull(m);
-
- rm1 = (TextMessage) sub2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm1);
- ProxyAssertSupport.assertEquals(tm1.getText(), rm1.getText());
-
- rm2 = (TextMessage) sub2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm2);
- ProxyAssertSupport.assertEquals(tm2.getText(), rm2.getText());
-
- rm3 = (TextMessage) sub2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm3);
- ProxyAssertSupport.assertEquals(tm3.getText(), rm3.getText());
-
- rm4 = (TextMessage) sub2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm4);
- ProxyAssertSupport.assertEquals(tm4.getText(), rm4.getText());
-
- m = sub2.receive(1000);
-
- ProxyAssertSupport.assertNull(m);
-
- res.end(xid1, XAResource.TMSUCCESS);
-
- // prepare it
-
- res.prepare(xid1);
-
- conn3 = createXAConnection();
-
- XASession sess3 = conn3.createXASession();
-
- XAResource res3 = sess3.getXAResource();
-
- // recover
-
- Xid[] xids = res3.recover(XAResource.TMSTARTRSCAN);
- ProxyAssertSupport.assertEquals(1, xids.length);
-
- Xid[] xids2 = res3.recover(XAResource.TMENDRSCAN);
- ProxyAssertSupport.assertEquals(0, xids2.length);
-
- ProxyAssertSupport.assertEquals(xid1, xids[0]);
-
- log.trace("Committing the tx");
-
- // Commit
- res3.commit(xids[0], false);
-
- log.trace("committed the tx");
-
- conn2.close();
-
- conn1 = createConnection();
-
- conn1.setClientID("wib1");
-
- conn1.start();
-
- sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- // Should now see the last 4 messages
-
- sub1 = sess1.createDurableSubscriber(ActiveMQServerTestCase.topic2, "sub1");
-
- sub2 = sess1.createDurableSubscriber(ActiveMQServerTestCase.topic2, "sub2");
-
- TextMessage rm5 = (TextMessage) sub1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm5);
- ProxyAssertSupport.assertEquals(tm5.getText(), rm5.getText());
-
- TextMessage rm6 = (TextMessage) sub1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm6);
- ProxyAssertSupport.assertEquals(tm6.getText(), rm6.getText());
-
- TextMessage rm7 = (TextMessage) sub1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm7);
- ProxyAssertSupport.assertEquals(tm7.getText(), rm7.getText());
-
- TextMessage rm8 = (TextMessage) sub1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm8);
- ProxyAssertSupport.assertEquals(tm8.getText(), rm8.getText());
-
- m = sub1.receive(1000);
-
- ProxyAssertSupport.assertNull(m);
-
- rm5 = (TextMessage) sub2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm5);
- ProxyAssertSupport.assertEquals(tm5.getText(), rm5.getText());
-
- rm6 = (TextMessage) sub2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm6);
- ProxyAssertSupport.assertEquals(tm6.getText(), rm6.getText());
-
- rm7 = (TextMessage) sub2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm7);
- ProxyAssertSupport.assertEquals(tm7.getText(), rm7.getText());
-
- rm8 = (TextMessage) sub2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm8);
- ProxyAssertSupport.assertEquals(tm8.getText(), rm8.getText());
-
- m = sub2.receive(1000);
-
- ProxyAssertSupport.assertNull(m);
-
- sub1.close();
-
- sub2.close();
-
- sess1.unsubscribe("sub1");
-
- sess1.unsubscribe("sub2");
-
- }
- finally
- {
- if (conn1 != null)
- {
- try
- {
- conn1.close();
- }
- catch (Exception e)
- {
- // Ignore
- }
- }
-
- if (conn2 != null)
- {
- try
- {
- conn2.close();
- }
- catch (Exception e)
- {
- // Ignore
- }
- }
-
- if (conn3 != null)
- {
- try
- {
- conn3.close();
- }
- catch (Exception e)
- {
- // Ignore
- }
- }
- }
- }
-
- /*
- * In this test, we have 4 messages in a 2 durable subs on the same topic.
- *
- * We ack them, then add four more messages
- *
- * This test tests for the recovery when the same message is in multiple channels
- *
- * We do restart in this test
- *
- */
- @Test
- public void testRecoveryWithTwoDurableSubsWithRestart() throws Exception
- {
- Connection conn1 = null;
-
- XAConnection conn2 = null;
-
- XAConnection conn3 = null;
-
- try
- {
- conn1 = createConnection();
-
- conn1.setClientID("wib1");
-
- Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageProducer prod1 = sess1.createProducer(ActiveMQServerTestCase.topic2);
-
- MessageConsumer sub1 = sess1.createDurableSubscriber(ActiveMQServerTestCase.topic2, "sub1");
-
- MessageConsumer sub2 = sess1.createDurableSubscriber(ActiveMQServerTestCase.topic2, "sub2");
-
- // send four messages
-
- TextMessage tm1 = sess1.createTextMessage("tm1");
- TextMessage tm2 = sess1.createTextMessage("tm2");
- TextMessage tm3 = sess1.createTextMessage("tm3");
- TextMessage tm4 = sess1.createTextMessage("tm4");
-
- prod1.send(tm1);
- prod1.send(tm2);
- prod1.send(tm3);
- prod1.send(tm4);
-
- conn1.close();
-
- // The messages should now be in both durable subs
-
- conn2 = createXAConnection();
-
- conn2.setClientID("wib1");
-
- conn2.start();
-
- XASession sess2 = conn2.createXASession();
-
- XAResource res = sess2.getXAResource();
-
- Xid xid1 = new XidImpl("bq1".getBytes(), 42, "eemeli".getBytes());
-
- res.start(xid1, XAResource.TMNOFLAGS);
-
- // Now send four more messages in a global tx
-
- MessageProducer prod2 = sess2.createProducer(ActiveMQServerTestCase.topic2);
-
- TextMessage tm5 = sess2.createTextMessage("tm5");
- TextMessage tm6 = sess2.createTextMessage("tm6");
- TextMessage tm7 = sess2.createTextMessage("tm7");
- TextMessage tm8 = sess2.createTextMessage("tm8");
-
- prod2.send(tm5);
- prod2.send(tm6);
- prod2.send(tm7);
- prod2.send(tm8);
-
- // And consume the first four from each in the tx
-
- sub1 = sess2.createDurableSubscriber(ActiveMQServerTestCase.topic2, "sub1");
-
- sub2 = sess2.createDurableSubscriber(ActiveMQServerTestCase.topic2, "sub2");
-
- TextMessage rm1 = (TextMessage) sub1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm1);
- ProxyAssertSupport.assertEquals(tm1.getText(), rm1.getText());
-
- TextMessage rm2 = (TextMessage) sub1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm2);
- ProxyAssertSupport.assertEquals(tm2.getText(), rm2.getText());
-
- TextMessage rm3 = (TextMessage) sub1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm3);
- ProxyAssertSupport.assertEquals(tm3.getText(), rm3.getText());
-
- TextMessage rm4 = (TextMessage) sub1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm4);
- ProxyAssertSupport.assertEquals(tm4.getText(), rm4.getText());
-
- Message m = sub1.receive(1000);
-
- ProxyAssertSupport.assertNull(m);
-
- rm1 = (TextMessage) sub2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm1);
- ProxyAssertSupport.assertEquals(tm1.getText(), rm1.getText());
-
- rm2 = (TextMessage) sub2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm2);
- ProxyAssertSupport.assertEquals(tm2.getText(), rm2.getText());
-
- rm3 = (TextMessage) sub2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm3);
- ProxyAssertSupport.assertEquals(tm3.getText(), rm3.getText());
-
- rm4 = (TextMessage) sub2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm4);
- ProxyAssertSupport.assertEquals(tm4.getText(), rm4.getText());
-
- m = sub2.receive(1000);
-
- ProxyAssertSupport.assertNull(m);
-
- res.end(xid1, XAResource.TMSUCCESS);
-
- // prepare it
-
- res.prepare(xid1);
-
- conn1.close();
- conn2.close();
- conn1 = null;
-
- conn2 = null;
-
- // Now "crash" the server
-
- stopServerPeer();
-
- startServerPeer();
-
- deployAndLookupAdministeredObjects();
-
- conn3 = createXAConnection();
-
- XASession sess3 = conn3.createXASession();
-
- XAResource res3 = sess3.getXAResource();
-
- // recover
-
- Xid[] xids = res3.recover(XAResource.TMSTARTRSCAN);
- ProxyAssertSupport.assertEquals(1, xids.length);
-
- Xid[] xids2 = res3.recover(XAResource.TMENDRSCAN);
- ProxyAssertSupport.assertEquals(0, xids2.length);
-
- ProxyAssertSupport.assertEquals(xid1, xids[0]);
-
- log.trace("Committing the tx");
-
- // Commit
- res3.commit(xids[0], false);
-
- log.trace("committed the tx");
-
- conn1 = createConnection();
-
- conn1.setClientID("wib1");
-
- conn1.start();
-
- sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- // Should now see the last 4 messages
-
- sub1 = sess1.createDurableSubscriber(ActiveMQServerTestCase.topic2, "sub1");
-
- sub2 = sess1.createDurableSubscriber(ActiveMQServerTestCase.topic2, "sub2");
-
- TextMessage rm5 = (TextMessage) sub1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm5);
- ProxyAssertSupport.assertEquals(tm5.getText(), rm5.getText());
-
- TextMessage rm6 = (TextMessage) sub1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm6);
- ProxyAssertSupport.assertEquals(tm6.getText(), rm6.getText());
-
- TextMessage rm7 = (TextMessage) sub1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm7);
- ProxyAssertSupport.assertEquals(tm7.getText(), rm7.getText());
-
- TextMessage rm8 = (TextMessage) sub1.receive(1000);
- ProxyAssertSupport.assertNotNull(rm8);
- ProxyAssertSupport.assertEquals(tm8.getText(), rm8.getText());
-
- m = sub1.receive(1000);
-
- ProxyAssertSupport.assertNull(m);
-
- rm5 = (TextMessage) sub2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm5);
- ProxyAssertSupport.assertEquals(tm5.getText(), rm5.getText());
-
- rm6 = (TextMessage) sub2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm6);
- ProxyAssertSupport.assertEquals(tm6.getText(), rm6.getText());
-
- rm7 = (TextMessage) sub2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm7);
- ProxyAssertSupport.assertEquals(tm7.getText(), rm7.getText());
-
- rm8 = (TextMessage) sub2.receive(1000);
- ProxyAssertSupport.assertNotNull(rm8);
- ProxyAssertSupport.assertEquals(tm8.getText(), rm8.getText());
-
- m = sub2.receive(1000);
-
- ProxyAssertSupport.assertNull(m);
-
- sub1.close();
-
- sub2.close();
-
- sess1.unsubscribe("sub1");
-
- sess1.unsubscribe("sub2");
-
- }
- finally
- {
- if (conn1 != null)
- {
- try
- {
- conn1.close();
- }
- catch (Exception e)
- {
- // Ignore
- }
- }
-
- if (conn2 != null)
- {
- try
- {
- conn2.close();
- }
- catch (Exception e)
- {
- // Ignore
- }
- }
-
- if (conn3 != null)
- {
- try
- {
- conn3.close();
- }
- catch (Exception e)
- {
- // Ignore
- }
- }
- }
- }
-
- /*
- * Send two messages in two transactions.
- * Prepare tx
- * Crash the server
- * Restart the server
- * Make sure the messages can be received
- * NOTE this test only tests transactional sends, not transactional acknowledgments
- *
- */
- @Test
- public void testTransactionalDeliveryRecovery() throws Exception
- {
- log.trace("starting testTransactionalDeliveryRecovery");
-
- XAConnection conn1 = null;
-
- XAConnection conn2 = null;
-
- Connection conn3 = null;
-
- try
- {
- conn1 = createXAConnection();
-
- conn2 = createXAConnection();
-
- XASession sess1 = conn1.createXASession();
-
- XASession sess2 = conn2.createXASession();
-
- XAResource res1 = sess1.getXAResource();
-
- XAResource res2 = sess2.getXAResource();
-
- // Pretend to be a transaction manager by interacting through the XAResources
- Xid xid1 = new XidImpl("bq1".getBytes(), 42, "eemeli".getBytes());
- Xid xid2 = new XidImpl("bq2".getBytes(), 42, "frigtard".getBytes());
-
- log.trace("Sending messages");
-
- // Send two messages in transaction 1
-
- res1.start(xid1, XAResource.TMNOFLAGS);
-
- MessageProducer prod1 = sess1.createProducer(queue4);
-
- TextMessage tm1 = sess1.createTextMessage("tm1");
-
- prod1.send(tm1);
-
- TextMessage tm2 = sess1.createTextMessage("tm2");
-
- prod1.send(tm2);
-
- res1.end(xid1, XAResource.TMSUCCESS);
-
- // Send two messages in transaction 2
-
- res2.start(xid2, XAResource.TMNOFLAGS);
-
- MessageProducer prod2 = sess2.createProducer(queue4);
-
- TextMessage tm3 = sess2.createTextMessage("tm3");
-
- prod2.send(tm3);
-
- TextMessage tm4 = sess2.createTextMessage("tm4");
-
- prod2.send(tm4);
-
- res2.end(xid2, XAResource.TMSUCCESS);
-
- log.trace("Sent messages");
-
- // prepare both txs
-
- res1.prepare(xid1);
- res2.prepare(xid2);
-
- log.trace("prepared messages");
-
- // Now "crash" the server
-
- conn1.close();
-
- conn2.close();
-
- conn1 = null;
-
- conn2 = null;
-
- stopServerPeer();
-
- startServerPeer();
-
- deployAndLookupAdministeredObjects();
-
- conn1 = createXAConnection();
-
- XAResource res = conn1.createXASession().getXAResource();
-
- log.trace("Recovering");
-
- Xid[] xids = res.recover(XAResource.TMSTARTRSCAN);
- ProxyAssertSupport.assertEquals(2, xids.length);
-
- Xid[] xids2 = res.recover(XAResource.TMENDRSCAN);
- ProxyAssertSupport.assertEquals(0, xids2.length);
-
- // They may be in a different order
- ProxyAssertSupport.assertTrue(xids[0].equals(xid1) || xids[1].equals(xid1));
- ProxyAssertSupport.assertTrue(xids[0].equals(xid2) || xids[1].equals(xid2));
-
- // Make sure can't receive the messages
-
- log.trace("Creating conn");
-
- conn3 = createConnection();
-
- Session sessRec = conn3.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageConsumer cons = sessRec.createConsumer(queue4);
- conn3.start();
-
- log.trace("Created conn3");
-
- TextMessage m1 = (TextMessage) cons.receive(1000);
- ProxyAssertSupport.assertNull(m1);
-
- log.trace("committing");
-
- // Commit tx1
-
- res.commit(xid1, false);
-
- log.trace("committed");
-
- // Should now be able to receive tm1 and tm2
-
- m1 = (TextMessage) cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
- ProxyAssertSupport.assertNotNull(m1);
-
- ProxyAssertSupport.assertEquals(tm1.getText(), m1.getText());
-
- TextMessage m2 = (TextMessage) cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
- ProxyAssertSupport.assertNotNull(m2);
-
- ProxyAssertSupport.assertEquals(tm2.getText(), m2.getText());
-
- TextMessage m3 = (TextMessage) cons.receive(1000);
- ProxyAssertSupport.assertNull(m3);
-
- // Now commit tx2
-
- res.commit(xid2, false);
-
- // Should now be able to receive tm3 and tm4
-
- m3 = (TextMessage) cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
- ProxyAssertSupport.assertNotNull(m3);
-
- ProxyAssertSupport.assertEquals(tm3.getText(), m3.getText());
-
- TextMessage m4 = (TextMessage) cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
- ProxyAssertSupport.assertNotNull(m4);
-
- ProxyAssertSupport.assertEquals(tm4.getText(), m4.getText());
-
- TextMessage m5 = (TextMessage) cons.receive(1000);
- ProxyAssertSupport.assertNull(m5);
- }
- finally
- {
- if (conn1 != null)
- {
- try
- {
- conn1.close();
- }
- catch (Exception e)
- {
- // Ignore
- }
- }
-
- if (conn2 != null)
- {
- try
- {
- conn2.close();
- }
- catch (Exception e)
- {
- // Ignore
- }
- }
-
- if (conn3 != null)
- {
- try
- {
- conn3.close();
- }
- catch (Exception e)
- {
- // Ignore
- }
- }
- }
- }
-
- /*
- * This test sends some messages in a couple of txs, crashes then recovers
- * NOTE it does not test transactional acknowledgements
- */
- @Test
- public void testMockCoordinatorRecovery() throws Exception
- {
- XAConnection conn1 = null;
-
- XAConnection conn2 = null;
-
- Connection conn3 = null;
-
- try
- {
-
- conn1 = createXAConnection();
-
- conn2 = createXAConnection();
-
- XASession sess1 = conn1.createXASession();
-
- XASession sess2 = conn2.createXASession();
-
- XAResource res1 = sess1.getXAResource();
-
- XAResource res2 = sess2.getXAResource();
-
- // Pretend to be a transaction manager by interacting through the XAResources
- Xid xid1 = new XidImpl("bq1".getBytes(), 42, "aapeli".getBytes());
- Xid xid2 = new XidImpl("bq2".getBytes(), 42, "belsebub".getBytes());
-
- // Send a message in each tx
-
- res1.start(xid1, XAResource.TMNOFLAGS);
-
- MessageProducer prod1 = sess1.createProducer(queue2);
-
- TextMessage tm1 = sess1.createTextMessage("alpha");
-
- prod1.send(tm1);
-
- res1.end(xid1, XAResource.TMSUCCESS);
-
- res2.start(xid2, XAResource.TMNOFLAGS);
-
- MessageProducer prod2 = sess2.createProducer(queue2);
-
- TextMessage tm2 = sess2.createTextMessage("beta");
-
- prod2.send(tm2);
-
- res2.end(xid2, XAResource.TMSUCCESS);
-
- // prepare both txs
-
- res1.prepare(xid1);
- res2.prepare(xid2);
-
- // Now "crash" the server
-
- stopServerPeer();
-
- startServerPeer();
-
- deployAndLookupAdministeredObjects();
-
- conn1.close();
-
- conn2.close();
-
- conn1 = createXAConnection();
-
- XAResource res = conn1.createXASession().getXAResource();
-
- Xid[] xids = res.recover(XAResource.TMSTARTRSCAN);
- ProxyAssertSupport.assertEquals(2, xids.length);
-
- Xid[] xids2 = res.recover(XAResource.TMENDRSCAN);
- ProxyAssertSupport.assertEquals(0, xids2.length);
-
- ProxyAssertSupport.assertTrue(xids[0].equals(xid1) || xids[1].equals(xid1));
- ProxyAssertSupport.assertTrue(xids[0].equals(xid2) || xids[1].equals(xid2));
-
- res.commit(xid1, false);
-
- res.commit(xid2, false);
-
- conn3 = createConnection();
-
- Session sessRec = conn3.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageConsumer cons = sessRec.createConsumer(queue2);
- conn3.start();
-
- Message msg = cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
-
- TextMessage m1 = (TextMessage) msg;
- ProxyAssertSupport.assertNotNull(m1);
-
- ProxyAssertSupport.assertTrue("alpha".equals(m1.getText()) || "beta".equals(m1.getText()));
-
- TextMessage m2 = (TextMessage) cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
- ProxyAssertSupport.assertNotNull(m2);
-
- ProxyAssertSupport.assertTrue("alpha".equals(m2.getText()) || "beta".equals(m2.getText()));
-
- ProxyAssertSupport.assertTrue(!tm1.getText().equals(tm2.getText()));
-
- Message nullMessage = cons.receive(ActiveMQServerTestCase.MIN_TIMEOUT);
- ProxyAssertSupport.assertTrue(nullMessage == null);
-
- }
- finally
- {
- if (conn1 != null)
- {
- try
- {
- conn1.close();
- }
- catch (Exception e)
- {
- // Ignore
- }
- }
-
- if (conn2 != null)
- {
- try
- {
- conn2.close();
- }
- catch (Exception e)
- {
- // Ignore
- }
- }
-
- if (conn3 != null)
- {
- try
- {
- conn3.close();
- }
- catch (Exception e)
- {
- // Ignore
- }
- }
- }
-
- }
-
- /*
- * This test sends some messages in a couple of txs, crashes then recovers
- * It uses the JBoss TS XId implementation - so we can show compatibility
- * NOTE it does not test transactional acknowledgements
- */
- @Test
- public void testMockCoordinatorRecoveryWithJBossTSXids() throws Exception
- {
- XAConnection conn1 = null;
-
- XAConnection conn2 = null;
-
- Connection conn3 = null;
- conn1 = createXAConnection();
-
- conn2 = createXAConnection();
-
- XASession sess1 = conn1.createXASession();
-
- XASession sess2 = conn2.createXASession();
-
- XAResource res1 = sess1.getXAResource();
-
- XAResource res2 = sess2.getXAResource();
-
- // Pretend to be a transaction manager by interacting through the XAResources
- Xid xid1 = new XidImple(new Uid("cadaver"), true, 666);
- Xid xid2 = new XidImple(new Uid("dalidom"), true, 661); // TODO
-
- // Send a message in each tx
-
- res1.start(xid1, XAResource.TMNOFLAGS);
-
- MessageProducer prod1 = sess1.createProducer(queue1);
-
- TextMessage tm1 = sess1.createTextMessage("testing1");
-
- prod1.send(tm1);
-
- res1.end(xid1, XAResource.TMSUCCESS);
-
- res2.start(xid2, XAResource.TMNOFLAGS);
-
- MessageProducer prod2 = sess2.createProducer(queue1);
-
- TextMessage tm2 = sess2.createTextMessage("testing2");
-
- prod2.send(tm2);
-
- res2.end(xid2, XAResource.TMSUCCESS);
-
- // prepare both txs
-
- res1.prepare(xid1);
- res2.prepare(xid2);
-
- // Now "crash" the server
-
- stopServerPeer();
-
- startServerPeer();
-
- deployAndLookupAdministeredObjects();
-
- conn1.close();
-
- conn2.close();
-
- conn1 = createXAConnection();
-
-
- XAResource res = conn1.createXASession().getXAResource();
- Xid[] xids = res.recover(XAResource.TMSTARTRSCAN);
- ProxyAssertSupport.assertEquals(2, xids.length);
-
- Xid[] xids2 = res.recover(XAResource.TMENDRSCAN);
- ProxyAssertSupport.assertEquals(0, xids2.length);
-
- ProxyAssertSupport.assertTrue(xids[0].equals(xid1) || xids[1].equals(xid1));
- ProxyAssertSupport.assertTrue(xids[0].equals(xid2) || xids[1].equals(xid2));
-
- res.commit(xid1, false);
-
- res.commit(xid2, false);
-
- conn3 = createConnection();
-
- Session sessRec = conn3.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageConsumer cons = sessRec.createConsumer(queue1);
- conn3.start();
-
- TextMessage m1 = (TextMessage) cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
- ProxyAssertSupport.assertNotNull(m1);
- ProxyAssertSupport.assertEquals("testing1", m1.getText());
-
- TextMessage m2 = (TextMessage) cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
- ProxyAssertSupport.assertNotNull(m2);
-
- ProxyAssertSupport.assertEquals("testing2", m2.getText());
- }
-
- @Test
- @Ignore("Ignored because: (i) it was ignored by our pom.xml, (ii) currently it still fails")
- public void testMockCoordinatorRecovery3() throws Exception
- {
- XAConnection conn1 = null;
-
- XAConnection conn2 = null;
-
- Connection conn3 = null;
- conn1 = createXAConnection();
-
-
- conn2 = createXAConnection();
- XASession sess1 = conn1.createXASession();
-
- XASession sess2 = conn2.createXASession();
-
- XAResource res1 = sess1.getXAResource();
-
- XAResource res2 = sess2.getXAResource();
-
- // Pretend to be a transaction manager by interacting through the XAResources
- Xid xid1 = new XidImpl("bq1".getBytes(), 123, "gbtxid1".getBytes());
- Xid xid2 = new XidImpl("bq2".getBytes(), 124, "gbtxid2".getBytes());
-
- // Send a message in each tx
-
- res1.start(xid1, XAResource.TMNOFLAGS);
-
- MessageProducer prod1 = sess1.createProducer(queue1);
-
- TextMessage tm1 = sess1.createTextMessage("testing1");
-
- prod1.send(tm1);
-
- res1.end(xid1, XAResource.TMSUCCESS);
-
- res2.start(xid2, XAResource.TMNOFLAGS);
-
- MessageProducer prod2 = sess2.createProducer(queue1);
-
- TextMessage tm2 = sess2.createTextMessage("testing2");
-
- prod2.send(tm2);
-
- res2.end(xid2, XAResource.TMSUCCESS);
-
- // prepare both txs
-
- res1.prepare(xid1);
- res2.prepare(xid2);
-
- // Now "crash" the server
-
- stopServerPeer();
-
- startServerPeer();
-
- deployAndLookupAdministeredObjects();
-
- conn1.close();
-
- conn2.close();
-
- conn1 = createXAConnection();
-
-
- XAResource res = conn1.createXASession().getXAResource();
-
- Xid[] xids = res.recover(XAResource.TMSTARTRSCAN);
- ProxyAssertSupport.assertEquals(2, xids.length);
-
- Xid[] xids2 = res.recover(XAResource.TMENDRSCAN);
- ProxyAssertSupport.assertEquals(0, xids2.length);
-
- ProxyAssertSupport.assertTrue(xids[0].equals(xid1) || xids[1].equals(xid1));
- ProxyAssertSupport.assertTrue(xids[0].equals(xid2) || xids[1].equals(xid2));
-
- res.commit(xids[0], false);
-
- res.commit(xids[1], false);
-
- conn3 = createConnection();
-
- Session sessRec = conn3.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageConsumer cons = sessRec.createConsumer(queue1);
- conn3.start();
-
- TextMessage m1 = (TextMessage) cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
- ProxyAssertSupport.assertNotNull(m1);
- ProxyAssertSupport.assertEquals("testing1", m1.getText());
-
- TextMessage m2 = (TextMessage) cons.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
- ProxyAssertSupport.assertNotNull(m2);
-
- ProxyAssertSupport.assertEquals("testing2", m2.getText());
- }
-
- @Test
- public void testMultiChannelRecovery() throws Exception
- {
-
- XAConnection conn1 = createXAConnection();
-
-
- XAConnection conn2 = createXAConnection();
-
-
- XASession sess1 = conn1.createXASession();
-
- XASession sess2 = conn2.createXASession();
-
- XAResource res1 = sess1.getXAResource();
-
- XAResource res2 = sess2.getXAResource();
-
- // Pretend to be a transaction manager by interacting through the XAResources
- Xid xid1 = new XidImpl("bq1".getBytes(), 123, "gbtxid1".getBytes());
- Xid xid2 = new XidImpl("bq2".getBytes(), 124, "gbtxid2".getBytes());
-
- // Send a message in each tx
-
- res1.start(xid1, XAResource.TMNOFLAGS);
-
- MessageProducer prod1 = sess1.createProducer(queue2);
- MessageProducer prod2 = sess1.createProducer(queue3);
-
- TextMessage tm1 = sess1.createTextMessage("testing1");
- TextMessage tm2 = sess1.createTextMessage("testing2");
-
- prod1.send(tm1);
- prod2.send(tm2);
-
- res1.end(xid1, XAResource.TMSUCCESS);
-
- res2.start(xid2, XAResource.TMNOFLAGS);
-
- MessageProducer prod3 = sess2.createProducer(queue1);
-
- TextMessage tm3 = sess2.createTextMessage("testing3");
-
- prod3.send(tm3);
-
- res2.end(xid2, XAResource.TMSUCCESS);
-
- // prepare both txs
-
- res1.prepare(xid1);
- res2.prepare(xid2);
-
- // Now "crash" the server
-
- stopServerPeer();
-
- startServerPeer();
-
- deployAndLookupAdministeredObjects();
-
- conn1.close();
-
- conn2.close();
-
- conn1 = createXAConnection();
-
-
- XAResource res = conn1.createXASession().getXAResource();
-
- Xid[] xids = res.recover(XAResource.TMSTARTRSCAN);
- ProxyAssertSupport.assertEquals(2, xids.length);
-
- Xid[] xids2 = res.recover(XAResource.TMENDRSCAN);
- ProxyAssertSupport.assertEquals(0, xids2.length);
-
- ProxyAssertSupport.assertTrue(xids[0].equals(xid1) || xids[1].equals(xid1));
- ProxyAssertSupport.assertTrue(xids[0].equals(xid2) || xids[1].equals(xid2));
-
- res.commit(xids[0], false);
-
- res.commit(xids[1], false);
-
- Connection conn3 = createConnection();
-
- Session sessRec = conn3.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- MessageConsumer cons1 = sessRec.createConsumer(queue2);
- MessageConsumer cons2 = sessRec.createConsumer(queue3);
- MessageConsumer cons3 = sessRec.createConsumer(queue1);
-
- conn3.start();
-
- TextMessage m1 = (TextMessage) cons1.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
- ProxyAssertSupport.assertNotNull(m1);
- ProxyAssertSupport.assertEquals("testing1", m1.getText());
-
- TextMessage m2 = (TextMessage) cons2.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
- ProxyAssertSupport.assertNotNull(m2);
- ProxyAssertSupport.assertEquals("testing2", m2.getText());
-
- TextMessage m3 = (TextMessage) cons3.receive(ActiveMQServerTestCase.MAX_TIMEOUT);
- ProxyAssertSupport.assertNotNull(m3);
- ProxyAssertSupport.assertEquals("testing3", m3.getText());
-
- }
-}