Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' of https://github.com/jbosstm/narayana

  • Loading branch information...
commit d126523809f3b1a1ddf583b13fc04f5bb99e4fbc 2 parents 74cabf5 + e0d0103
@liweinan authored
Showing with 5,301 additions and 168 deletions.
  1. +26 −0 ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/common/CoordinatorEnvironmentBean.java
  2. +45 −2 ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/BasicAction.java
  3. +8 −0 ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/TwoPhaseOutcome.java
  4. +2 −0  ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/TxControl.java
  5. +95 −0 ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/OnePhaseCommitUnitTest.java
  6. +0 −1  ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/resources/BasicRecord.java
  7. +173 −0 ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/resources/OnePhaseAbstractRecord.java
  8. +140 −0 ArjunaJTS/jtax/tests/classes/WedgedResourceDemonstrator.java
  9. +4 −3 ArjunaJTS/jts/classes/com/arjuna/ats/internal/jts/orbspecific/coordinator/ArjunaTransactionImple.java
  10. +6 −1 ArjunaJTS/jts/classes/com/arjuna/ats/internal/jts/resources/ExtendedResourceRecord.java
  11. +4 −0 ArjunaJTS/jts/tests/classes/com/hp/mwtests/ts/jts/local/transactions/TransactionTest1.java
  12. +98 −0 XTS/WSTX/classes/com/arjuna/mw/wst11/client/AbstractWSTXHandler.java
  13. +46 −0 XTS/WSTX/classes/com/arjuna/mw/wst11/client/DisabledWSTXHandler.java
  14. +46 −0 XTS/WSTX/classes/com/arjuna/mw/wst11/client/EnabledWSTXHandler.java
  15. +28 −9 XTS/WSTX/classes/com/arjuna/mw/wst11/client/JaxBaseHeaderContextProcessor.java
  16. +19 −7 XTS/WSTX/classes/com/arjuna/mw/wst11/client/JaxWSHeaderContextProcessor.java
  17. +86 −0 XTS/WSTX/classes/com/arjuna/mw/wst11/client/WSTXFeature.java
  18. +6 −0 XTS/WSTX/pom.xml
  19. +10 −0 XTS/localjunit/pom.xml
  20. +251 −17 XTS/localjunit/unit/pom.xml
  21. +188 −0 XTS/localjunit/unit/src/test/java/com/arjuna/wstx/tests/arq/ba/AbstractContextPropagationTest.java
  22. +262 −0 XTS/localjunit/unit/src/test/java/com/arjuna/wstx/tests/arq/ba/DisabledContextPropagationTest.java
  23. +261 −0 XTS/localjunit/unit/src/test/java/com/arjuna/wstx/tests/arq/ba/EnabledContextPropagationTest.java
  24. +188 −0 XTS/localjunit/unit/src/test/java/com/arjuna/wstx/tests/arq/basic/AbstractContextPropagationTest.java
  25. +263 −0 XTS/localjunit/unit/src/test/java/com/arjuna/wstx/tests/arq/basic/DisabledContextPropagationTest.java
  26. +265 −0 XTS/localjunit/unit/src/test/java/com/arjuna/wstx/tests/arq/basic/EnabledContextPropagationTest.java
  27. +26 −0 XTS/localjunit/unit/src/test/java/com/arjuna/wstx/tests/common/TestService.java
  28. +31 −0 XTS/localjunit/unit/src/test/java/com/arjuna/wstx/tests/common/TestServiceAT.java
  29. +88 −0 XTS/localjunit/unit/src/test/java/com/arjuna/wstx/tests/common/TestServiceATClient.java
  30. +97 −0 XTS/localjunit/unit/src/test/java/com/arjuna/wstx/tests/common/TestServiceATImple.java
  31. +31 −0 XTS/localjunit/unit/src/test/java/com/arjuna/wstx/tests/common/TestServiceBA.java
  32. +88 −0 XTS/localjunit/unit/src/test/java/com/arjuna/wstx/tests/common/TestServiceBAClient.java
  33. +117 −0 XTS/localjunit/unit/src/test/java/com/arjuna/wstx/tests/common/TestServiceBAImple.java
  34. +63 −0 XTS/localjunit/unit/src/test/java/com/arjuna/wstx/tests/common/TestServiceClient.java
  35. +39 −0 XTS/localjunit/unit/src/test/java/com/arjuna/wstx/tests/common/TestServiceImple.java
  36. +12 −0 XTS/localjunit/unit/src/test/resources/arquillian.xml
  37. +21 −0 XTS/localjunit/unit/src/test/resources/context-handlers.xml
  38. +0 −15 fileio/pom.xml
  39. +2 −2 pom.xml
  40. +6 −2 qa/TaskImpl.properties
  41. +3 −2 qa/tests/src/org/jboss/jbossts/qa/junit/testgroup/TestGroup_jtsremote.java
  42. +0 −2  rest-tx/webservice/pom.xml
  43. +1 −1  tools/maven/NOTICE.txt
  44. +2 −1  tools/maven/bin/m2.conf
  45. +18 −5 tools/maven/bin/mvn
  46. +0 −1  tools/maven/bin/mvn.bat
  47. +18 −5 tools/maven/bin/mvnDebug
  48. +0 −1  tools/maven/bin/mvnDebug.bat
  49. +17 −5 tools/maven/bin/mvnyjp
  50. +246 −1 tools/maven/conf/settings.xml
  51. BIN  tools/maven/lib/aether-api-1.13.1.jar
  52. BIN  tools/maven/lib/aether-api-1.9.jar
  53. BIN  tools/maven/lib/aether-connector-wagon-1.13.1.jar
  54. BIN  tools/maven/lib/aether-connector-wagon-1.9.jar
  55. BIN  tools/maven/lib/aether-impl-1.13.1.jar
  56. BIN  tools/maven/lib/aether-impl-1.9.jar
  57. BIN  tools/maven/lib/aether-spi-1.13.1.jar
  58. BIN  tools/maven/lib/aether-spi-1.9.jar
  59. BIN  tools/maven/lib/aether-util-1.13.1.jar
  60. BIN  tools/maven/lib/aether-util-1.9.jar
  61. +2 −0  tools/maven/lib/ext/README.txt
  62. BIN  tools/maven/lib/maven-aether-provider-3.0.2.jar
  63. BIN  tools/maven/lib/maven-aether-provider-3.0.5.jar
  64. BIN  tools/maven/lib/maven-artifact-3.0.2.jar
  65. BIN  tools/maven/lib/maven-artifact-3.0.5.jar
  66. BIN  tools/maven/lib/{maven-compat-3.0.2.jar → maven-compat-3.0.5.jar}
  67. BIN  tools/maven/lib/maven-core-3.0.2.jar
  68. BIN  tools/maven/lib/maven-core-3.0.5.jar
  69. BIN  tools/maven/lib/maven-embedder-3.0.2.jar
  70. BIN  tools/maven/lib/maven-embedder-3.0.5.jar
  71. BIN  tools/maven/lib/maven-model-3.0.2.jar
  72. BIN  tools/maven/lib/maven-model-3.0.5.jar
  73. BIN  tools/maven/lib/maven-model-builder-3.0.2.jar
  74. BIN  tools/maven/lib/maven-model-builder-3.0.5.jar
  75. BIN  tools/maven/lib/{maven-plugin-api-3.0.2.jar → maven-plugin-api-3.0.5.jar}
  76. BIN  tools/maven/lib/{maven-repository-metadata-3.0.2.jar → maven-repository-metadata-3.0.5.jar}
  77. BIN  tools/maven/lib/{maven-settings-3.0.2.jar → maven-settings-3.0.5.jar}
  78. BIN  tools/maven/lib/{maven-settings-builder-3.0.2.jar → maven-settings-builder-3.0.5.jar}
  79. BIN  tools/maven/lib/nekohtml-1.9.6.2.jar
  80. BIN  tools/maven/lib/plexus-cipher-1.4.jar
  81. BIN  tools/maven/lib/plexus-cipher-1.7.jar
  82. BIN  tools/maven/lib/plexus-utils-2.0.4.jar
  83. BIN  tools/maven/lib/plexus-utils-2.0.6.jar
  84. BIN  tools/maven/lib/sisu-guava-0.9.9.jar
  85. BIN  tools/maven/lib/sisu-guice-2.9.1-noaop.jar
  86. BIN  tools/maven/lib/sisu-guice-3.1.0-no_aop.jar
  87. BIN  tools/maven/lib/sisu-inject-bean-1.4.3.1.jar
  88. BIN  tools/maven/lib/sisu-inject-bean-2.3.0.jar
  89. BIN  tools/maven/lib/sisu-inject-plexus-1.4.3.1.jar
  90. BIN  tools/maven/lib/sisu-inject-plexus-2.3.0.jar
  91. BIN  tools/maven/lib/wagon-file-1.0-beta-7.jar
  92. BIN  tools/maven/lib/wagon-file-2.4.jar
  93. BIN  tools/maven/lib/wagon-http-2.4-shaded.jar
  94. BIN  tools/maven/lib/wagon-http-lightweight-1.0-beta-7.jar
  95. BIN  tools/maven/lib/wagon-http-shared-1.0-beta-7.jar
  96. BIN  tools/maven/lib/wagon-provider-api-1.0-beta-7.jar
  97. BIN  tools/maven/lib/wagon-provider-api-2.4.jar
  98. BIN  tools/maven/lib/xercesMinimal-1.9.6.2.jar
  99. +115 −0 txbridge/pom.xml
  100. +214 −0 txbridge/src/main/java/org/jboss/jbossts/txbridge/outbound/AbstractJTAOverWSATHandler.java
  101. +47 −0 txbridge/src/main/java/org/jboss/jbossts/txbridge/outbound/DisabledJTAOverWSATHandler.java
  102. +47 −0 txbridge/src/main/java/org/jboss/jbossts/txbridge/outbound/EnabledJTAOverWSATHandler.java
  103. +67 −0 txbridge/src/main/java/org/jboss/jbossts/txbridge/outbound/JTAOverWSATFeature.java
  104. +5 −4 txbridge/src/test/java/org/jboss/jbossts/txbridge/tests/common/AbstractBasicTests.java
  105. +13 −0 txbridge/src/test/java/org/jboss/jbossts/txbridge/tests/outbound/client/CommonTestService.java
  106. +269 −0 txbridge/src/test/java/org/jboss/jbossts/txbridge/tests/outbound/client/TestATClient.java
  107. +30 −0 txbridge/src/test/java/org/jboss/jbossts/txbridge/tests/outbound/client/TestATService.java
  108. +30 −0 txbridge/src/test/java/org/jboss/jbossts/txbridge/tests/outbound/client/TestNonATService.java
  109. +402 −0 txbridge/src/test/java/org/jboss/jbossts/txbridge/tests/outbound/junit/DisabledContextPropagationTests.java
  110. +398 −0 txbridge/src/test/java/org/jboss/jbossts/txbridge/tests/outbound/junit/EnabledContextPropagationTests.java
  111. +71 −0 txbridge/src/test/java/org/jboss/jbossts/txbridge/tests/outbound/service/TestATServiceImpl.java
  112. +57 −0 txbridge/src/test/java/org/jboss/jbossts/txbridge/tests/outbound/service/TestATServiceParticipant.java
  113. +56 −0 txbridge/src/test/java/org/jboss/jbossts/txbridge/tests/outbound/service/TestNonATServiceImpl.java
  114. +5 −0 txframework/pom.xml
  115. +4 −3 ...ork/src/test/java/org/jboss/narayana/txframework/functional/rest/at/simpleEJB/IndirectTXManagementTest.java
  116. +4 −16 txframework/src/test/java/org/jboss/narayana/txframework/functional/ws/at/bridged/ATBridgeClient.java
  117. +4 −17 txframework/src/test/java/org/jboss/narayana/txframework/functional/ws/at/simplePOJO/ATClient.java
  118. +7 −13 txframework/src/test/java/org/jboss/narayana/txframework/functional/ws/ba/bridged/BABridgedClient.java
  119. +4 −16 ...va/org/jboss/narayana/txframework/functional/ws/ba/coordinatorCompletion/BACoordinatorCompletionClient.java
  120. +4 −16 ...va/org/jboss/narayana/txframework/functional/ws/ba/participantCompletion/BAParticipantCompletionClient.java
View
26 ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/common/CoordinatorEnvironmentBean.java
@@ -53,6 +53,7 @@
@FullPropertyName(name = "com.arjuna.ats.arjuna.coordinator.transactionLog.writeOptimisation")
private volatile boolean writeOptimisation = false;
+ private volatile boolean dynamic1PC = true;
private volatile boolean readonlyOptimisation = true;
private volatile boolean classicPrepare = false;
private volatile boolean enableStatistics = false;
@@ -195,6 +196,31 @@ public void setCommitOnePhase(boolean commitOnePhase)
{
this.commitOnePhase = commitOnePhase;
}
+
+ /**
+ * Returns true if dynamic one phase commit optimization is to be used. This means that
+ * if the first N-1 participants in the intentions list return read-only then commit_one_phase
+ * will be called on the last participant.
+ *
+ * Default: true
+ * Equivalent deprecated property: com.arjuna.ats.arjuna.coordinator.dynamic1PC
+ *
+ * @return true if one phase commit is enabled, false otherwise.
+ */
+ public boolean getDynamic1PC()
+ {
+ return dynamic1PC;
+ }
+
+ /**
+ * Sets if dynamic one phase commit behaviour is enabled or not.
+ *
+ * @param dynamic1PC true to enable, false to disable.
+ */
+ public void setDynamic1PC(boolean dynamic1PC)
+ {
+ this.dynamic1PC = dynamic1PC;
+ }
/**
* Returns true if heuristic outcomes should be recorded.
View
47 ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/BasicAction.java
@@ -1948,6 +1948,13 @@ protected synchronized final void phase2Abort (boolean reportHeuristics)
}
}
+ /*
+ * Various optimisations which are possible during synchronous prepare are
+ * not possible for asynchronous prepare due to lack of ordering. For instance
+ * dynamically determining one-phase optimisation while running through the
+ * intentions list and getting read-only responses from N-1 participants.
+ */
+
protected int async_prepare(boolean reportHeuristics) {
int p = TwoPhaseOutcome.PREPARE_OK;
Collection<AbstractRecord> lastResourceRecords = new ArrayList<AbstractRecord>();
@@ -2006,7 +2013,10 @@ protected int async_prepare(boolean reportHeuristics) {
* all the records indicate that they are readonly records. Such records do
* not take part in the second phase commit processing.
*
- * @return <code>TwoPhaseOutcome</code> indicating outcome.
+ * @return <code>TwoPhaseOutcome</code> indicating outcome. Note that if
+ * 1PC optimisation is enabled then it is possible for prepare to dynamically
+ * optimise and commit if the first N-1 participants return read-only, causing the
+ * protcol to commit the last participant rather than go through prepare.
*/
protected synchronized final int prepare (boolean reportHeuristics)
@@ -2081,6 +2091,22 @@ protected synchronized final int prepare (boolean reportHeuristics)
}
}
+ /*
+ * Now let's see if we are able to dynamically optimise 1PC. As we went
+ * through prepare, if the first N-1 participants returned read-only
+ * then we returned read-only from doPrepare but left one entry on
+ * the intentions list.
+ */
+
+ if ((p == TwoPhaseOutcome.PREPARE_READONLY) && (pendingList.size() == 1))
+ {
+ onePhaseCommit(reportHeuristics);
+
+ ActionManager.manager().remove(get_uid());
+
+ return TwoPhaseOutcome.PREPARE_ONE_PHASE_COMMITTED;
+ }
+
if ((p != TwoPhaseOutcome.PREPARE_OK)
&& (p != TwoPhaseOutcome.PREPARE_READONLY))
{
@@ -2485,7 +2511,7 @@ private int doPrepare (boolean reportHeuristics)
*/
int overallTwoPhaseOutcome = TwoPhaseOutcome.PREPARE_READONLY;
-
+
/*
* March down the pendingList and pass the head of the list to the
* main work routine until either we run out of elements, or one of
@@ -2507,6 +2533,23 @@ private int doPrepare (boolean reportHeuristics)
}
keepGoing = ( individualTwoPhaseOutcome == TwoPhaseOutcome.PREPARE_OK) || ( individualTwoPhaseOutcome == TwoPhaseOutcome.PREPARE_READONLY);
+
+ /*
+ * If we are allowed to do dynamic 1PC optimisation then check to see if the first N-1
+ * participants returned read-only and there's a single entry left on the
+ * intentions list.
+ */
+
+ if (keepGoing && TxControl.dynamic1PC)
+ {
+ /*
+ * If N-1 returned read-only and 1 record left then exit prepare now and force
+ * a call to commitOnePhase on the last record.
+ */
+
+ if ((pendingList.size() == 1) && (overallTwoPhaseOutcome == TwoPhaseOutcome.PREPARE_READONLY))
+ keepGoing = false;
+ }
}
return overallTwoPhaseOutcome;
View
8 ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/TwoPhaseOutcome.java
@@ -53,6 +53,11 @@
public class TwoPhaseOutcome
{
+ /*
+ * WARNING!!
+ * Do not re-order this list.
+ */
+
public static final int PREPARE_OK = 0; // prepared OK
public static final int PREPARE_NOTOK = 1; // did not prepare so force roll back
public static final int PREPARE_READONLY = 2; // only used to read the state, so no need for second phase
@@ -65,6 +70,7 @@
public static final int NOT_PREPARED = 9; // participant told to do second phase operation when it hadn't seen the first phase
public static final int ONE_PHASE_ERROR = 10; // WARNING this has different meanings depending upon nested or top-level usage.
public static final int INVALID_TRANSACTION = 11; // invalid!
+ public static final int PREPARE_ONE_PHASE_COMMITTED = 12; // dynamic one-phase commit optimisation during prepare
public TwoPhaseOutcome (int outcome)
{
@@ -113,6 +119,8 @@ public static String stringForm (int res)
return "TwoPhaseOutcome.ONE_PHASE_ERROR";
case INVALID_TRANSACTION:
return "TwoPhaseOutcome.INVALID_TRANSACTION";
+ case PREPARE_ONE_PHASE_COMMITTED:
+ return "TwoPhaseOutcome.PREPARE_ONE_PHASE_COMMITTED";
default:
return "Unknown";
}
View
2  ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/TxControl.java
@@ -222,6 +222,8 @@ private final static synchronized void removeTransactionStatusManager ()
static final boolean readonlyOptimisation = arjPropertyManager.getCoordinatorEnvironmentBean().isReadonlyOptimisation();
+ static final boolean dynamic1PC = arjPropertyManager.getCoordinatorEnvironmentBean().getDynamic1PC();
+
/**
* flag which is true if transaction service is enabled and false if it is disabled
*/
View
95 ...re/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/OnePhaseCommitUnitTest.java
@@ -0,0 +1,95 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+package com.hp.mwtests.ts.arjuna.atomicaction;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+import com.arjuna.ats.arjuna.AtomicAction;
+import com.arjuna.ats.arjuna.coordinator.ActionStatus;
+import com.arjuna.ats.arjuna.coordinator.BasicAction;
+import com.arjuna.ats.internal.arjuna.thread.ThreadActionData;
+import com.hp.mwtests.ts.arjuna.resources.BasicRecord;
+import com.hp.mwtests.ts.arjuna.resources.OnePhaseAbstractRecord;
+
+public class OnePhaseCommitUnitTest
+{
+ @Test
+ public void testBasic () throws Exception
+ {
+ AtomicAction A = new AtomicAction();
+ OnePhaseAbstractRecord rec = new OnePhaseAbstractRecord();
+
+ A.begin();
+
+ A.add(rec);
+
+ A.commit();
+
+ assertTrue(rec.onePhaseCalled());
+ }
+
+ @Test
+ public void testFailed () throws Exception
+ {
+ AtomicAction A = new AtomicAction();
+ OnePhaseAbstractRecord rec1 = new OnePhaseAbstractRecord();
+ BasicRecord rec2 = new BasicRecord();
+
+ A.begin();
+
+ A.add(rec1);
+ A.add(rec2);
+
+ A.commit();
+
+ assertTrue(!rec1.onePhaseCalled());
+ }
+
+ @Test
+ public void testDynamic () throws Exception
+ {
+ AtomicAction A = new AtomicAction();
+ OnePhaseAbstractRecord rec1 = new OnePhaseAbstractRecord();
+ OnePhaseAbstractRecord rec2 = new OnePhaseAbstractRecord();
+
+ A.begin();
+
+ /*
+ * Because these are the same record type, we know that they will
+ * be called in the order in which they were registered.
+ *
+ * There are two records, so 1PC will not be triggered initially. But
+ * the first record will return read-only from prepare, which will
+ * then trigger 1PC to happen dynamically.
+ */
+
+ A.add(rec1);
+ A.add(rec2);
+
+ A.commit();
+
+ assertTrue(!rec1.onePhaseCalled());
+ assertTrue(rec2.onePhaseCalled());
+ }
+}
View
1  ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/resources/BasicRecord.java
@@ -85,7 +85,6 @@ public int topLevelPrepare()
public void print(PrintWriter strm)
{
- strm.println("Shutdown for:");
super.print(strm);
}
View
173 ...aCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/resources/OnePhaseAbstractRecord.java
@@ -0,0 +1,173 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+/*
+ * Copyright (C) 2004,
+ *
+ * Arjuna Technologies Limited,
+ * Newcastle upon Tyne,
+ * Tyne and Wear,
+ * UK.
+ *
+ * $Id: BasicRecord.java 2342 2006-03-30 13:06:17Z $
+ */
+
+package com.hp.mwtests.ts.arjuna.resources;
+
+import java.io.PrintWriter;
+
+import com.arjuna.ats.arjuna.common.Uid;
+import com.arjuna.ats.arjuna.coordinator.AbstractRecord;
+import com.arjuna.ats.arjuna.coordinator.RecordType;
+import com.arjuna.ats.arjuna.coordinator.TwoPhaseOutcome;
+import com.arjuna.ats.arjuna.state.InputObjectState;
+import com.arjuna.ats.arjuna.state.OutputObjectState;
+
+public class OnePhaseAbstractRecord extends AbstractRecord
+{
+
+ public OnePhaseAbstractRecord()
+ {
+ super(new Uid());
+ }
+
+ public boolean onePhaseCalled ()
+ {
+ return _onePhaseCalled;
+ }
+
+ public int typeIs()
+ {
+ return RecordType.USER_DEF_FIRST0;
+ }
+
+ public int nestedOnePhaseCommit ()
+ {
+ _onePhaseCalled = true;
+
+ return TwoPhaseOutcome.FINISH_OK;
+ }
+
+ public int topLevelOnePhaseCommit ()
+ {
+ _onePhaseCalled = true;
+
+ return TwoPhaseOutcome.FINISH_OK;
+ }
+
+ public int nestedAbort()
+ {
+ return TwoPhaseOutcome.FINISH_ERROR;
+ }
+
+ public int nestedCommit()
+ {
+ return TwoPhaseOutcome.FINISH_ERROR;
+ }
+
+ public int nestedPrepare()
+ {
+ return TwoPhaseOutcome.PREPARE_NOTOK;
+ }
+
+ public int topLevelAbort()
+ {
+ return TwoPhaseOutcome.FINISH_ERROR;
+ }
+
+ public int topLevelCommit()
+ {
+ return TwoPhaseOutcome.FINISH_ERROR;
+ }
+
+ public int topLevelPrepare()
+ {
+ return TwoPhaseOutcome.PREPARE_READONLY;
+ }
+
+ public void print(PrintWriter strm)
+ {
+ super.print(strm);
+ }
+
+ public boolean doSave()
+ {
+ return true;
+ }
+
+ public boolean save_state(OutputObjectState os, int ot)
+ {
+ return true;
+ }
+
+ public boolean restore_state(InputObjectState os, int ot)
+ {
+ return true;
+ }
+
+ public String type()
+ {
+ return "/StateManager/AbstractRecord/OnePhaseAbstractRecord";
+ }
+
+ public boolean shouldAdd(AbstractRecord a)
+ {
+ return false;
+ }
+
+ public boolean shouldMerge(AbstractRecord a)
+ {
+ return false;
+ }
+
+ public boolean shouldReplace(AbstractRecord a)
+ {
+ return false;
+ }
+
+ public boolean shouldAlter(AbstractRecord a)
+ {
+ return false;
+ }
+
+ public void merge(AbstractRecord a)
+ {
+ }
+
+ public void alter(AbstractRecord a)
+ {
+ }
+
+ /**
+ * @return <code>Object</code> to be used to order.
+ */
+
+ public Object value()
+ {
+ return null;
+ }
+
+ public void setValue(Object o)
+ {
+ }
+
+ private boolean _onePhaseCalled = false;
+}
+
View
140 ArjunaJTS/jtax/tests/classes/WedgedResourceDemonstrator.java
@@ -0,0 +1,140 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a full listing
+ * of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+
+import static org.junit.Assert.fail;
+
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.TransactionManager;
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+
+import org.junit.Test;
+import org.omg.CORBA.SystemException;
+import org.omg.CORBA.ORBPackage.InvalidName;
+
+import com.arjuna.ats.arjuna.recovery.RecoveryManager;
+import com.arjuna.orbportability.OA;
+import com.arjuna.orbportability.ORB;
+import com.arjuna.orbportability.RootOA;
+
+public class WedgedResourceDemonstrator {
+
+ @Test
+ public void testWedge() throws InvalidName, SystemException,
+ NotSupportedException, javax.transaction.SystemException,
+ IllegalStateException, RollbackException, SecurityException,
+ HeuristicMixedException, HeuristicRollbackException,
+ InterruptedException {
+
+ String mode = "jts";
+ if (mode.equals("jts")) {
+ ORB myORB = ORB.getInstance("test");
+ RootOA myOA = OA.getRootOA(myORB);
+
+ myORB.initORB(new String[0], null);
+ myOA.initOA();
+
+ com.arjuna.ats.internal.jts.ORBManager.setORB(myORB);
+ com.arjuna.ats.internal.jts.ORBManager.setPOA(myOA);
+
+ RecoveryManager.manager().initialize();
+ }
+
+ TransactionManager transactionManager = mode.equals("jts") ? new com.arjuna.ats.internal.jta.transaction.jts.TransactionManagerImple()
+ : new com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionManagerImple();
+ transactionManager.setTransactionTimeout(2);
+ transactionManager.begin();
+ transactionManager.getTransaction().enlistResource(
+ new TimeoutOnFirstRollbackResource());
+
+ // Business logic
+ Thread.currentThread().sleep(5000);
+
+ try {
+ transactionManager.commit();
+ fail("Should not have been able to commit");
+ } catch (RollbackException e) {
+ // This is fine
+ } finally {
+ if (mode.equals("jts")) {
+ RecoveryManager.manager().terminate();
+
+ ORB myORB = ORB.getInstance("test");
+ RootOA myOA = OA.getRootOA(myORB);
+ myOA.destroy();
+ myORB.shutdown();
+ }
+ }
+ }
+
+ private static class TimeoutOnFirstRollbackResource implements XAResource {
+
+ public void rollback(Xid arg0) throws XAException {
+ synchronized (this) {
+ long initialTime = System.currentTimeMillis();
+ try {
+ // This would wait forever in theory, I have reduced it
+ // just so the app will be able to clean up
+ this.wait(7000);
+ } catch (InterruptedException e) {
+ throw new NullPointerException(
+ "Interrupted, simulating jacorb");
+ }
+ }
+ }
+
+ public void commit(Xid arg0, boolean arg1) throws XAException {
+ }
+
+ public void end(Xid arg0, int arg1) throws XAException {
+ }
+
+ public void forget(Xid arg0) throws XAException {
+ }
+
+ public int getTransactionTimeout() throws XAException {
+ return 0;
+ }
+
+ public boolean isSameRM(XAResource arg0) throws XAException {
+ return false;
+ }
+
+ public int prepare(Xid arg0) throws XAException {
+ return 0;
+ }
+
+ public Xid[] recover(int arg0) throws XAException {
+ return null;
+ }
+
+ public boolean setTransactionTimeout(int arg0) throws XAException {
+ return false;
+ }
+
+ public void start(Xid arg0, int arg1) throws XAException {
+ }
+ }
+}
View
7 ...s/classes/com/arjuna/ats/internal/jts/orbspecific/coordinator/ArjunaTransactionImple.java
@@ -390,9 +390,10 @@ public void commit (boolean report_heuristics) throws HeuristicMixed,
}
destroyAction();
- }
- else
- {
+ } else if (outcome == ActionStatus.ABORTED || outcome == ActionStatus.H_ROLLBACK) {
+ throw new TRANSACTION_ROLLEDBACK(ExceptionCodes.FAILED_TO_COMMIT,
+ CompletionStatus.COMPLETED_NO);
+ } else {
/*
* Differentiate between us committing the transaction and some
* other thread doing it.
View
7 ArjunaJTS/jts/classes/com/arjuna/ats/internal/jts/resources/ExtendedResourceRecord.java
@@ -525,8 +525,13 @@ public int topLevelCommit ()
return TwoPhaseOutcome.FINISH_ERROR;
}
+ catch (Exception e2)
+ {
+ e2.printStackTrace();
+
+ return TwoPhaseOutcome.FINISH_ERROR;
+ }
}
-
return TwoPhaseOutcome.FINISH_OK;
}
View
4 ArjunaJTS/jts/tests/classes/com/hp/mwtests/ts/jts/local/transactions/TransactionTest1.java
@@ -122,6 +122,10 @@ public void test() throws Exception
{
System.err.println("Nested commit failed! "+e1);
}
+ catch (TRANSACTION_ROLLEDBACK e1)
+ {
+ System.err.println("Nested commit failed! "+e1);
+ }
catch (Exception e2)
{
fail("Nested commit threw unexpected exception: "+e2);
View
98 XTS/WSTX/classes/com/arjuna/mw/wst11/client/AbstractWSTXHandler.java
@@ -0,0 +1,98 @@
+package com.arjuna.mw.wst11.client;
+
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.handler.soap.SOAPHandler;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+
+/**
+ *
+ * @author <a href="mailto:gytis@redhat.com">Gytis Trikleris</a>
+ *
+ */
+public abstract class AbstractWSTXHandler implements SOAPHandler<SOAPMessageContext> {
+
+ /**
+ * Delegate handler does all the work if context propagation is enabled.
+ */
+ private final JaxWSHeaderContextProcessor delegateHandler = new JaxWSHeaderContextProcessor();
+
+ /**
+ * Delegates message handling to the JaxWSHeaderContextProcessor if either WSTXFeature or default context propagation is
+ * enabled.
+ *
+ * @see com.arjuna.mw.wst11.client.JaxWSHeaderContextProcessor#handleMessage(SOAPMessageContext, boolean)
+ *
+ * @param context
+ * @return true
+ */
+ @Override
+ public boolean handleMessage(SOAPMessageContext context) {
+ if (isContextPropagationEnabled(context)) {
+ return delegateHandler.handleMessage(context, isMustUnderstand(context));
+ }
+
+ return true;
+ }
+
+ /**
+ * Delegates fault handling to the JaxWSHeaderContextProcessor if either WSTXFeature or default context propagation is
+ * enabled.
+ *
+ * @see com.arjuna.mw.wst11.client.JaxWSHeaderContextProcessor#handleFault(SOAPMessageContext)
+ *
+ * @param context
+ * @return true
+ */
+ @Override
+ public boolean handleFault(SOAPMessageContext context) {
+ if (isContextPropagationEnabled(context)) {
+ return delegateHandler.handleFault(context);
+ }
+
+ return true;
+ }
+
+ /**
+ * Delegates to the JaxWSHeaderContextProcessor.
+ *
+ * @see com.arjuna.mw.wst11.client.JaxWSHeaderContextProcessor#close(MessageContext)
+ *
+ * @param context
+ */
+ @Override
+ public void close(MessageContext context) {
+ delegateHandler.close(context);
+ }
+
+ /**
+ * Delegates to the JaxWSHeaderContextProcessor.
+ *
+ * @see com.arjuna.mw.wst11.client.JaxWSHeaderContextProcessor#getHeaders()
+ */
+ @Override
+ public Set<QName> getHeaders() {
+ return delegateHandler.getHeaders();
+ }
+
+ /**
+ * MustUnderstand parameter of WS-AT/WS-BA header must be set to true if WSTXFeature is enabled.
+ *
+ * @param context
+ * @return
+ */
+ private boolean isMustUnderstand(SOAPMessageContext context) {
+ return WSTXFeature.ENABLED_VALUE.equals(context.get(WSTXFeature.REQUEST_CONTEXT_KEY));
+ }
+
+ /**
+ * Checks if WSTXHandler should propagate WS-AT/WS-BA context.
+ *
+ * @param context
+ * @return true|false
+ */
+ protected abstract boolean isContextPropagationEnabled(SOAPMessageContext context);
+
+}
View
46 XTS/WSTX/classes/com/arjuna/mw/wst11/client/DisabledWSTXHandler.java
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package com.arjuna.mw.wst11.client;
+
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+
+/**
+ * This handler is used when <code>default-context-propagation</code> is disabled. It handles messages only if WSTXFeature is
+ * enabled.
+ *
+ * @author <a href="mailto:gytis@redhat.com">Gytis Trikleris</a>
+ *
+ */
+public final class DisabledWSTXHandler extends AbstractWSTXHandler {
+
+ /**
+ * @see com.arjuna.mw.wst11.client.AbstractWSTXHandler#isContextPropagationEnabled(SOAPMessageContext)
+ *
+ * @return true if WSTXFeature is present and is enabled, false otherwise.
+ */
+ @Override
+ protected boolean isContextPropagationEnabled(SOAPMessageContext context) {
+ return WSTXFeature.ENABLED_VALUE.equals(context.get(WSTXFeature.REQUEST_CONTEXT_KEY));
+ }
+
+}
View
46 XTS/WSTX/classes/com/arjuna/mw/wst11/client/EnabledWSTXHandler.java
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package com.arjuna.mw.wst11.client;
+
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+
+/**
+ * This handler is used when <code>default-context-propagation</code> is enabled. It handles every message unless WSTXFeature is
+ * disabled.
+ *
+ * @author <a href="mailto:gytis@redhat.com">Gytis Trikleris</a>
+ *
+ */
+public final class EnabledWSTXHandler extends AbstractWSTXHandler {
+
+ /**
+ * @see com.arjuna.mw.wst11.client.AbstractWSTXHandler#isContextPropagationEnabled(SOAPMessageContext)
+ *
+ * @return false if WSTXFeature is present and is disabled, true otherwise.
+ */
+ @Override
+ protected boolean isContextPropagationEnabled(SOAPMessageContext context) {
+ return !WSTXFeature.DISABLED_VALUE.equals(context.get(WSTXFeature.REQUEST_CONTEXT_KEY));
+ }
+
+}
View
37 XTS/WSTX/classes/com/arjuna/mw/wst11/client/JaxBaseHeaderContextProcessor.java
@@ -20,22 +20,29 @@
*/
package com.arjuna.mw.wst11.client;
+import java.util.Iterator;
+
+import javax.xml.soap.Name;
+import javax.xml.soap.SOAPEnvelope;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPHeader;
+import javax.xml.soap.SOAPHeaderElement;
+import javax.xml.soap.SOAPMessage;
+
+import org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType;
+
import com.arjuna.mw.wsc11.context.Context;
-import com.arjuna.mw.wst.*;
+import com.arjuna.mw.wst.TxContext;
import com.arjuna.mw.wst.common.SOAPUtil;
-import com.arjuna.mw.wst11.common.CoordinationContextHelper;
import com.arjuna.mw.wst11.BusinessActivityManagerFactory;
import com.arjuna.mw.wst11.TransactionManager;
import com.arjuna.mw.wst11.TransactionManagerFactory;
+import com.arjuna.mw.wst11.common.CoordinationContextHelper;
import com.arjuna.mw.wstx.logging.wstxLogger;
+import com.arjuna.mwlabs.wst11.at.context.TxContextImple;
import com.arjuna.webservices11.wsat.AtomicTransactionConstants;
import com.arjuna.webservices11.wsba.BusinessActivityConstants;
import com.arjuna.webservices11.wscoor.CoordinationConstants;
-import com.arjuna.mwlabs.wst11.at.context.TxContextImple;
-import org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType;
-
-import javax.xml.soap.*;
-import java.util.Iterator;
/**
* Common base class for classes used to perform
@@ -46,11 +53,23 @@
{
/**
* Handle the request.
+ *
* @param soapMessage The current message context.
*/
-
public boolean handleOutboundMessage(final SOAPMessage soapMessage)
{
+ return handleOutboundMessage(soapMessage, true);
+ }
+
+ /**
+ * Handle the request.
+ *
+ * @param soapMessage The current message context.
+ * @param mustUnderstand Value of MustUnderstand attribute.
+ * @return
+ */
+ public boolean handleOutboundMessage(final SOAPMessage soapMessage, boolean mustUnderstand)
+ {
if (soapMessage == null)
{
return true ;
@@ -114,7 +133,7 @@ else if (baContext != null)
final Name name = env.createName(CoordinationConstants.WSCOOR_ELEMENT_COORDINATION_CONTEXT, CoordinationConstants.WSCOOR_PREFIX, CoordinationConstants.WSCOOR_NAMESPACE) ;
final SOAPHeaderElement headerElement = header.addHeaderElement(name) ;
headerElement.addNamespaceDeclaration(CoordinationConstants.WSCOOR_PREFIX, CoordinationConstants.WSCOOR_NAMESPACE) ;
- headerElement.setMustUnderstand(true) ;
+ headerElement.setMustUnderstand(mustUnderstand) ;
CoordinationContextHelper.serialise(coordinationContext, headerElement) ;
}
}
View
26 XTS/WSTX/classes/com/arjuna/mw/wst11/client/JaxWSHeaderContextProcessor.java
@@ -20,16 +20,16 @@
*/
package com.arjuna.mw.wst11.client;
-import com.arjuna.webservices11.wscoor.CoordinationConstants;
-import com.arjuna.mw.wst11.client.JaxBaseHeaderContextProcessor;
+import java.util.HashSet;
+import java.util.Set;
import javax.xml.namespace.QName;
import javax.xml.soap.SOAPMessage;
import javax.xml.ws.handler.MessageContext;
import javax.xml.ws.handler.soap.SOAPHandler;
import javax.xml.ws.handler.soap.SOAPMessageContext;
-import java.util.HashSet;
-import java.util.Set;
+
+import com.arjuna.webservices11.wscoor.CoordinationConstants;
/**
* The class is used to perform WS-Transaction context insertion
@@ -46,11 +46,22 @@
*/
public boolean handleMessage(SOAPMessageContext msgContext)
{
+ return handleMessage(msgContext, true);
+ }
+
+ /**
+ * Process a message. Determines if it is inbound or outbound and dispatches accordingly.
+ *
+ * @param msgContext
+ * @param mustUnderstand
+ * @return true
+ */
+ public boolean handleMessage(SOAPMessageContext msgContext, boolean mustUnderstand) {
Boolean outbound = (Boolean)msgContext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
if (outbound == null)
throw new IllegalStateException("Cannot obtain required property: " + MessageContext.MESSAGE_OUTBOUND_PROPERTY);
- return outbound ? handleOutbound(msgContext) : handleInbound(msgContext);
+ return outbound ? handleOutbound(msgContext, mustUnderstand) : handleInbound(msgContext);
}
/**
@@ -109,12 +120,13 @@ protected boolean handleInbound(SOAPMessageContext messageContext)
* Process the tx thread context and attach serialized version as msg header
*
* @param messageContext
+ * @param mustUnderstand
* @return true
*/
- protected boolean handleOutbound(SOAPMessageContext messageContext)
+ protected boolean handleOutbound(SOAPMessageContext messageContext, boolean mustUnderstand)
{
final SOAPMessage soapMessage = messageContext.getMessage() ;
- return handleOutboundMessage(soapMessage);
+ return handleOutboundMessage(soapMessage, mustUnderstand);
}
}
View
86 XTS/WSTX/classes/com/arjuna/mw/wst11/client/WSTXFeature.java
@@ -0,0 +1,86 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2013, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a full listing
+ * of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+
+package com.arjuna.mw.wst11.client;
+
+import javax.xml.ws.BindingProvider;
+
+import org.jboss.ws.api.configuration.AbstractClientFeature;
+
+/**
+ * Web service feature is used to enable or disable WS-AT/WS-BA context propagation for specific port.
+ *
+ * @author <a href="mailto:paul.robinson@redhat.com">Paul Robinson</a>
+ * @author <a href="mailto:gytis@redhat.com">Gytis Trikleris</a>
+ */
+public final class WSTXFeature extends AbstractClientFeature {
+
+ /**
+ * Key to store WSTXFeature's enabled/disabled value in SOAP header.
+ */
+ public static final String REQUEST_CONTEXT_KEY = "WSTXFeature";
+
+ /**
+ * Value to indicate that WSTXFeature is enabled.
+ */
+ public static final String ENABLED_VALUE = "true";
+
+ /**
+ * Value to indicate that WSTXFeature is disabled.
+ */
+ public static final String DISABLED_VALUE = "false";
+
+ /**
+ * Default constructor creates instance of enabled WSTXFeature.
+ */
+ public WSTXFeature() {
+ this(true);
+ }
+
+ /**
+ * Parametrised constructor creates either enabled or disabled WSTXFeature based on <code>enabled</code> parameter.
+ *
+ * @param enabled true to create enabled WSTXFeature, false to create disabled WSTXFeature.
+ */
+ public WSTXFeature(final boolean enabled) {
+ super(WSTXFeature.class.getName());
+ this.enabled = enabled;
+ }
+
+ /**
+ * Sets <code>REQUEST_CONTEXT_KEY</code> value to <code>ENABLED_VALUE</code> if WSTXFeature is enabled.
+ *
+ * Sets <code>REQUEST_CONTEXT_KEY</code> value to <code>DISABLED_VALUE</code> if WSTXFeature is disabled and
+ * <code>REQUEST_CONTEXT_KEY</code> value was not already set by another feature.
+ */
+ @Override
+ protected void initializeBindingProvider(BindingProvider bp) {
+ if (enabled) {
+ bp.getRequestContext().put(REQUEST_CONTEXT_KEY, ENABLED_VALUE);
+ } else {
+ if (!bp.getRequestContext().containsKey(REQUEST_CONTEXT_KEY)) {
+ // Disable handler only if another feature does not require it.
+ bp.getRequestContext().put(REQUEST_CONTEXT_KEY, DISABLED_VALUE);
+ }
+ }
+ }
+
+}
View
6 XTS/WSTX/pom.xml
@@ -50,6 +50,7 @@
<include>com/arjuna/mw/wst11/BusinessActivityManagerFactory.class</include>
<include>com/arjuna/mw/wst11/client/JaxWSHeaderContextProcessor.class</include>
<include>com/arjuna/mw/wst11/client/JaxBaseHeaderContextProcessor.class</include>
+ <include>com/arjuna/mw/wst11/client/WSTXFeature.class</include>
<include>com/arjuna/mw/wst11/service/JaxWSHeaderContextProcessor.class</include>
<include>com/arjuna/mw/wst11/service/JaxWSSubordinateHeaderContextProcessor.class</include>
<include>com/arjuna/mw/wst11/service/JaxBaseHeaderContextProcessor.class</include>
@@ -127,5 +128,10 @@
<groupId>org.jboss.narayana.xts</groupId>
<artifactId>wsas</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.jboss.ws</groupId>
+ <artifactId>jbossws-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
</project>
View
10 XTS/localjunit/pom.xml
@@ -63,6 +63,16 @@
<dependencies>
<dependency>
+ <groupId>org.jboss.spec.javax.ejb</groupId>
+ <artifactId>jboss-ejb-api_3.1_spec</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.ws</groupId>
+ <artifactId>jbossws-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
<groupId>org.jboss.narayana.xts</groupId>
<artifactId>jbossxts</artifactId>
<scope>provided</scope>
View
268 XTS/localjunit/unit/pom.xml
@@ -1,19 +1,253 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- JBoss, Home of Professional Open Source Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated by the @authors tag. All rights reserved. See the copyright.txt in the distribution
- for a full listing of individual contributors. This copyrighted material is made available to anyone wishing to use, modify, copy, or redistribute it subject to the terms and conditions of the GNU Lesser
- General Public License, v. 2.1. This program is distributed in the hope that it will be useful, but WITHOUT A WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License, v.2.1 along with this distribution; if not, write to the Free
- Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -->
-<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">
- <parent>
- <groupId>org.jboss.narayana.xts</groupId>
- <artifactId>localjunit</artifactId>
- <version>5.0.0.M2-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <artifactId>localjunit-unit-tests</artifactId>
- <packaging>jar</packaging>
- <name>unit tests</name>
- <description>unit tests</description>
+<!-- JBoss, Home of Professional Open Source Copyright 2008, Red Hat Middleware
+ LLC, and others contributors as indicated by the @authors tag. All rights
+ reserved. See the copyright.txt in the distribution for a full listing of
+ individual contributors. This copyrighted material is made available to anyone
+ wishing to use, modify, copy, or redistribute it subject to the terms and
+ conditions of the GNU Lesser General Public License, v. 2.1. This program
+ is distributed in the hope that it will be useful, but WITHOUT A WARRANTY;
+ without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the GNU Lesser General Public License for more details. You
+ should have received a copy of the GNU Lesser General Public License, v.2.1
+ along with this distribution; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -->
+<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">
+ <parent>
+ <groupId>org.jboss.narayana.xts</groupId>
+ <artifactId>localjunit</artifactId>
+ <version>5.0.0.M2-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>localjunit-unit-tests</artifactId>
+ <packaging>jar</packaging>
+ <name>unit tests</name>
+ <description>unit tests</description>
+
+ <properties>
+ <skipEnabledPropagationTests>false</skipEnabledPropagationTests>
+ <skipDisabledPropagationTests>false</skipDisabledPropagationTests>
+ <version.plugin.antrun>1.7</version.plugin.antrun>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-test</id>
+ <configuration>
+ <excludes>
+ <exclude>**/DisabledContextPropagationTest.java</exclude>
+ </excludes>
+ </configuration>
+ </execution>
+ <execution>
+ <id>disabled-context-propagation-test</id>
+ <phase>test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <systemProperties>
+ <arquillian.launch>jboss-as-disabled-context-propagation</arquillian.launch>
+ </systemProperties>
+ <includes>
+ <include>**/DisabledContextPropagationTest.java</include>
+ </includes>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>${version.plugin.antrun}</version>
+ <executions>
+ <execution>
+ <id>create-disabled-context-propagation-configuration</id>
+ <phase>process-test-sources</phase>
+ <configuration>
+ <skip>true</skip>
+ <target unless="skipTests">
+ <copy
+ file="${env.JBOSS_HOME}/standalone/configuration/standalone-xts.xml"
+ tofile="${env.JBOSS_HOME}/standalone/configuration/test-disabled-context-propagation-standalone-xts.xml" />
+ <replaceregexp
+ match="&lt;default-context-propagation enabled=&quot;true&quot;/&gt;"
+ replace="&lt;default-context-propagation enabled=&quot;false&quot;/&gt;"
+ file="${env.JBOSS_HOME}/standalone/configuration/test-disabled-context-propagation-standalone-xts.xml" />
+ </target>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>delete-disabled-context-propagation-configuration</id>
+ <phase>test</phase>
+ <configuration>
+ <skip>true</skip>
+ <target unless="skipTests">
+ <delete
+ file="${env.JBOSS_HOME}/standalone/configuration/test-disabled-context-propagation-standalone-xts.xml" />
+ </target>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-clean-plugin</artifactId>
+ <configuration>
+ <filesets>
+ <fileset>
+ <directory>${env.JBOSS_HOME}/standalone/configuration</directory>
+ <includes>
+ <include>test-disabled-context-propagation-standalone-xts.xml</include>
+ </includes>
+ </fileset>
+ </filesets>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <profiles>
+ <profile>
+ <id>arq-remote</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-test</id>
+ <configuration>
+ <skip>${skipEnabledPropagationTests}</skip>
+ </configuration>
+ </execution>
+ <execution>
+ <id>disabled-context-propagation-test</id>
+ <configuration>
+ <skip>${skipDisabledPropagationTests}</skip>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>create-disabled-context-propagation-configuration</id>
+ <configuration>
+ <skip>${maven.test.skip}</skip>
+ </configuration>
+ </execution>
+ <execution>
+ <id>delete-disabled-context-propagation-configuration</id>
+ <configuration>
+ <skip>${maven.test.skip}</skip>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>arq</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-test</id>
+ <configuration>
+ <skip>${skipEnabledPropagationTests}</skip>
+ </configuration>
+ </execution>
+ <execution>
+ <id>disabled-context-propagation-test</id>
+ <configuration>
+ <skip>${skipDisabledPropagationTests}</skip>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>create-disabled-context-propagation-configuration</id>
+ <configuration>
+ <skip>${maven.test.skip}</skip>
+ </configuration>
+ </execution>
+ <execution>
+ <id>delete-disabled-context-propagation-configuration</id>
+ <configuration>
+ <skip>${maven.test.skip}</skip>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>arqIPv6</id>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-test</id>
+ <configuration>
+ <skip>${skipEnabledPropagationTests}</skip>
+ </configuration>
+ </execution>
+ <execution>
+ <id>disabled-context-propagation-test</id>
+ <configuration>
+ <skip>${skipDisabledPropagationTests}</skip>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>create-disabled-context-propagation-configuration</id>
+ <configuration>
+ <skip>${maven.test.skip}</skip>
+ </configuration>
+ </execution>
+ <execution>
+ <id>delete-disabled-context-propagation-configuration</id>
+ <configuration>
+ <skip>${maven.test.skip}</skip>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
</project>
View
188 ...junit/unit/src/test/java/com/arjuna/wstx/tests/arq/ba/AbstractContextPropagationTest.java
@@ -0,0 +1,188 @@
+package com.arjuna.wstx.tests.arq.ba;
+
+import java.net.MalformedURLException;
+import java.util.List;
+
+import org.junit.After;
+import org.junit.Assert;
+
+import com.arjuna.mw.wst11.UserBusinessActivity;
+import com.arjuna.mw.wst11.UserBusinessActivityFactory;
+import com.arjuna.wstx.tests.common.TestService;
+import com.arjuna.wstx.tests.common.TestServiceBA;
+import com.arjuna.wstx.tests.common.TestServiceBAClient;
+import com.arjuna.wstx.tests.common.TestServiceClient;
+
+/**
+ *
+ * @author <a href="mailto:gytis@redhat.com">Gytis Trikleris</a>
+ *
+ */
+public abstract class AbstractContextPropagationTest {
+
+ @After
+ public void after() {
+ UserBusinessActivity userBusinessActivity = UserBusinessActivityFactory.userBusinessActivity();
+
+ cancelIfActive(userBusinessActivity);
+ }
+
+ /**
+ * Creates and resets WS-AT and WS-BA unaware client.
+ *
+ * @return TestService
+ */
+ protected TestService getClientWithoutFeature() {
+ TestService client;
+
+ try {
+ client = TestServiceClient.getClientWithoutFeature();
+ } catch (MalformedURLException e) {
+ throw new RuntimeException("Client creation failed.", e);
+ }
+
+ client.reset();
+
+ return client;
+ }
+
+ /**
+ * Creates and resets WS-AT and WS-BA unaware client with WSTXFeature.
+ *
+ * @param isWSTXFeatureEnabled
+ * @return TestService
+ */
+ protected TestService getClientWithFeature(final boolean isWSTXFeatureEnabled) {
+ TestService client;
+
+ try {
+ client = TestServiceClient.getClientWithWSTXFeature(isWSTXFeatureEnabled);
+ } catch (MalformedURLException e) {
+ throw new RuntimeException("Client creation failed.", e);
+ }
+
+ client.reset();
+
+ return client;
+ }
+
+ /**
+ * Creates and resets WS-BA aware client.
+ *
+ * @return TestServiceBA
+ */
+ protected TestServiceBA getBAClientWithoutFeature() {
+ TestServiceBA client;
+
+ try {
+ client = TestServiceBAClient.getClientWithoutFeature();
+ } catch (MalformedURLException e) {
+ throw new RuntimeException("Client creation failed.", e);
+ }
+
+ client.reset();
+
+ return client;
+ }
+
+ /**
+ * Creates and resets WS-BA aware client with WSTXFeature.
+ *
+ * @param isWSTXFeatureEnabled
+ * @return TestServiceBA
+ */
+ protected TestServiceBA getBAClientWithFeature(final boolean isWSTXFeatureEnabled) {
+ TestServiceBA client;
+
+ try {
+ client = TestServiceBAClient.getClientWithWSTXFeature(isWSTXFeatureEnabled);
+ } catch (MalformedURLException e) {
+ throw new RuntimeException("Client creation failed.", e);
+ }
+
+ client.reset();
+
+ return client;
+ }
+
+ /**
+ * Creates and resets WS-BA aware client with manually added handler.
+ *
+ * @return TestServiceBA
+ */
+ protected TestServiceBA getBAClientWithManuallyAddedHandler() {
+ TestServiceBA client;
+
+ try {
+ client = TestServiceBAClient.getClientWithManuallyAddedHandler();
+ } catch (MalformedURLException e) {
+ throw new RuntimeException("Client creation failed.", e);
+ }
+
+ client.reset();
+
+ return client;
+ }
+
+ /**
+ * Begins business activity.
+ */
+ protected void beginActivity() {
+ UserBusinessActivity userBusinessActivity = UserBusinessActivityFactory.userBusinessActivity();
+
+ try {
+ userBusinessActivity.begin();
+ } catch (Exception e) {
+ throw new RuntimeException("Begin business activity failed.", e);
+ }
+ }
+
+ /**
+ * Closes current business activity.
+ */
+ protected void closeActivity() {
+ UserBusinessActivity userBusinessActivity = UserBusinessActivityFactory.userBusinessActivity();
+
+ try {
+ userBusinessActivity.close();
+ } catch (Exception e) {
+ throw new RuntimeException("Close business activity failed.", e);
+ }
+ }
+
+ /**
+ * Cancels current business activity.
+ */
+ protected void cancelActivity() {
+ UserBusinessActivity userBusinessActivity = UserBusinessActivityFactory.userBusinessActivity();
+
+ try {
+ userBusinessActivity.cancel();
+ } catch (Exception e) {
+ throw new RuntimeException("Cancel business activity failed.", e);
+ }
+ }
+
+ /**
+ * Cancels given activity if it's active.
+ *
+ * @param userBusinessActivity
+ */
+ protected void cancelIfActive(UserBusinessActivity userBusinessActivity) {
+ try {
+ userBusinessActivity.cancel();
+ } catch (Throwable t) {
+ }
+ }
+
+ /**
+ * Compares and asserts two invocation lists.
+ *
+ * @param actual
+ * @param expected
+ */
+ protected void assertInvocations(List<String> actual, String... expected) {
+ Assert.assertArrayEquals(expected, actual.toArray());
+ }
+
+}
View
262 ...junit/unit/src/test/java/com/arjuna/wstx/tests/arq/ba/DisabledContextPropagationTest.java
@@ -0,0 +1,262 @@
+package com.arjuna.wstx.tests.arq.ba;
+
+import javax.xml.ws.soap.SOAPFaultException;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import com.arjuna.mw.wst11.client.WSTXFeature;
+import com.arjuna.wstx.tests.arq.WarDeployment;
+import com.arjuna.wstx.tests.common.TestService;
+import com.arjuna.wstx.tests.common.TestServiceBA;
+import com.arjuna.wstx.tests.common.TestServiceBAClient;
+import com.arjuna.wstx.tests.common.TestServiceBAImple;
+import com.arjuna.wstx.tests.common.TestServiceClient;
+import com.arjuna.wstx.tests.common.TestServiceImple;
+
+/**
+ *
+ * Tests WSTXFeature and DisabledWSTXHandler with WS-BA protocol.
+ *
+ * <code>default-context-propagation</code> in standalone.xml has to be disabled.
+ *
+ * @author <a href="mailto:gytis@redhat.com">Gytis Trikleris</a>
+ *
+ */
+@RunWith(Arquillian.class)
+public final class DisabledContextPropagationTest extends AbstractContextPropagationTest {
+
+ @Deployment
+ public static WebArchive getDeployment() {
+ return WarDeployment.getDeployment(AbstractContextPropagationTest.class, TestService.class, TestServiceImple.class,
+ TestServiceClient.class, TestServiceBA.class, TestServiceBAImple.class, TestServiceBAClient.class,
+ WSTXFeature.class).addAsResource("context-handlers.xml");
+ }
+
+ /**
+ * Tests close without WSTXFeature and with disabled WSTX handler.
+ *
+ * No coordination calls are expected.
+ */
+ @Test
+ public void testCloseWithoutFeature() {
+ TestServiceBA client = getBAClientWithoutFeature();
+
+ beginActivity();
+ client.increment();
+ closeActivity();
+
+ assertInvocations(client.getBusinessActivityInvocations());
+ }
+
+ /**
+ * Tests cancel without WSTXFeature and with disabled WSTX handler.
+ *
+ * No coordination calls are expected.
+ */
+ @Test
+ public void testCancelWithoutFeature() throws Exception {
+ TestServiceBA client = getBAClientWithoutFeature();
+
+ beginActivity();
+ client.increment();
+ cancelActivity();
+
+ assertInvocations(client.getBusinessActivityInvocations());
+ }
+
+ /**
+ * Tests service invocation without BA context, WSTXFeature, and with disabled WSTX handler.
+ *
+ * No coordination calls are expected.
+ */
+ @Test
+ public void testNoActivityWithoutFeature() {
+ TestServiceBA client = getBAClientWithoutFeature();
+
+ client.increment();
+
+ assertInvocations(client.getBusinessActivityInvocations());
+ }
+
+ /**
+ * Tests invocation to the BA-unaware service without BA context, WSTXFeature, and with disabled WSTX handler.
+ *
+ * No coordination calls are expected.
+ */
+ @Test
+ public void testNonTransactionalServiceWithoutFeature() {
+ TestService client = getClientWithoutFeature();
+
+ beginActivity();
+ client.increment();
+ closeActivity();
+ }
+
+ /**
+ * Tests close with enabled WSTXFeature and with disabled WSTX handler.
+ *
+ * "complete", "confirmCompleted", and "close" calls are expected.
+ */
+ @Test
+ public void testCloseWithEnabledFeature() {
+ TestServiceBA client = getBAClientWithFeature(true);
+
+ beginActivity();
+ client.increment();
+ closeActivity();
+
+ assertInvocations(client.getBusinessActivityInvocations(), "complete", "confirmCompleted", "close");
+ }
+
+ /**
+ * Tests cancel with enabled WSTXFeature and with disabled WSTX handler.
+ *
+ * "cancel" call is expected.
+ */
+ @Test
+ public void testCancelWithEnabledFeature() throws Exception {
+ TestServiceBA client = getBAClientWithFeature(true);
+
+ beginActivity();
+ client.increment();
+ cancelActivity();
+
+ assertInvocations(client.getBusinessActivityInvocations(), "cancel");
+ }
+
+ /**
+ * Tests service invocation without BA context but with enabled WSTXFeature and with disabled WSTX handler.
+ *
+ * No coordination calls are expected.
+ */
+ @Test
+ public void testNoActivityWithEnabledFeature() {
+ TestServiceBA client = getBAClientWithFeature(true);
+
+ client.increment();
+
+ assertInvocations(client.getBusinessActivityInvocations());
+ }
+
+ /**
+ * Tests invocation to the BA-unaware service without BA context but with enabled WSTXFeature and with disabled WSTX
+ * handler.
+ *
+ * SOAPFaultException is expected.
+ */
+ @Test
+ public void testNonTransactionalServiceWithEnabledFeature() {
+ TestService client = getClientWithFeature(true);
+
+ beginActivity();
+
+ try {
+ client.increment();
+ throw new RuntimeException("SOAPFaultException was expected");
+ } catch (SOAPFaultException e) {
+ // TODO for some reason <code>@Test(expected = SOAPFaultException.class)</code> did not work.
+ }
+ }
+
+ /**
+ * Tests close with disabled WSTXFeature and with disabled WSTX handler.
+ *
+ * No coordination calls are expected.
+ */
+ @Test
+ public void testCloseWithDisabledFeature() {
+ TestServiceBA client = getBAClientWithFeature(false);
+
+ beginActivity();
+ client.increment();
+ closeActivity();
+
+ assertInvocations(client.getBusinessActivityInvocations());
+ }
+
+ /**
+ * Tests cancel with disabled WSTXFeature and with disabled WSTX handler.
+ *
+ * No coordination calls are expected.
+ */
+ @Test
+ public void testCancelWithDisabledFeature() throws Exception {
+ TestServiceBA client = getBAClientWithFeature(false);
+
+ beginActivity();
+ client.increment();
+ cancelActivity();
+
+ assertInvocations(client.getBusinessActivityInvocations());
+ }
+
+ /**
+ * Tests service invocation without BA context but with disabled WSTXFeature and with disabled WSTX handler.
+ *
+ * No coordination calls are expected.
+ */
+ @Test
+ public void testNoActivityWithDisabledFeature() {
+ TestServiceBA client = getBAClientWithFeature(false);
+
+ client.increment();
+
+ assertInvocations(client.getBusinessActivityInvocations());
+ }
+
+ /**
+ * Tests invocation to the BA-unaware service without BA context but with disabled WSTXFeature and with disabled WSTX
+ * handler.
+ *
+ * No coordination calls are expected.
+ */
+ @Test
+ public void testNonTransactionalServiceWithDisabledFeature() {
+ TestService client = getClientWithFeature(false);
+
+ beginActivity();
+ client.increment();
+ closeActivity();
+ }
+
+ /**
+ * Tests service invocation using client which registers JaxWSHeaderContextProcessor with binding provider manually.
+ *
+ * "complete", "confirmCompleted", and "close" calls are expected.
+ *
+ * @throws InterruptedException
+ */
+ @Test
+ public void testCloseWithFeatureUnawareClient() throws InterruptedException {
+ TestServiceBA client = getBAClientWithManuallyAddedHandler();
+
+ beginActivity();
+ client.increment();
+ closeActivity();
+
+ assertInvocations(client.getBusinessActivityInvocations(), "complete", "confirmCompleted", "close");
+ }
+
+ /**
+ * Tests service invocation using client which registers JaxWSHeaderContextProcessor with binding provider manually.
+ *
+ * "cancel" call is expected.
+ *
+ * @throws InterruptedException
+ */
+ @Test
+ public void testCancelWithFeatureUnawareClient() {
+ TestServiceBA client = getBAClientWithManuallyAddedHandler();
+
+ beginActivity();
+ client.increment();
+ cancelActivity();
+
+ assertInvocations(client.getBusinessActivityInvocations(), "cancel");
+ }
+
+}
View
261 ...ljunit/unit/src/test/java/com/arjuna/wstx/tests/arq/ba/EnabledContextPropagationTest.java
@@ -0,0 +1,261 @@
+package com.arjuna.wstx.tests.arq.ba;
+
+import javax.xml.ws.soap.SOAPFaultException;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import com.arjuna.mw.wst11.client.WSTXFeature;
+import com.arjuna.wstx.tests.arq.WarDeployment;
+import com.arjuna.wstx.tests.common.TestService;
+import com.arjuna.wstx.tests.common.TestServiceBA;
+import com.arjuna.wstx.tests.common.TestServiceBAClient;
+import com.arjuna.wstx.tests.common.TestServiceBAImple;
+import com.arjuna.wstx.tests.common.TestServiceClient;
+import com.arjuna.wstx.tests.common.TestServiceImple;
+
+/**
+ *
+ * Tests WSTXFeature and EnabledWSTXHandler with WS-BA protocol.
+ *
+ * <code>default-context-propagation</code> in standalone.xml has to be enabled.
+ *
+ * @author <a href="mailto:gytis@redhat.com">Gytis Trikleris</a>
+ *
+ */
+@RunWith(Arquillian.class)
+public final class EnabledContextPropagationTest extends AbstractContextPropagationTest {
+
+ @Deployment
+ public static WebArchive getDeployment() {
+ return WarDeployment.getDeployment(AbstractContextPropagationTest.class, TestService.class, TestServiceImple.class,
+ TestServiceClient.class, TestServiceBA.class, TestServiceBAImple.class, TestServiceBAClient.class,
+ WSTXFeature.class).addAsResource("context-handlers.xml");
+ }
+
+ /**
+ * Tests close without WSTXFeature and with enabled WSTX handler.
+ *
+ * "complete", "confirmCompleted", and "close" calls are expected.
+ */
+ @Test
+ public void testCloseWithoutFeature() {
+ TestServiceBA client = getBAClientWithoutFeature();
+
+ beginActivity();
+ client.increment();
+ closeActivity();
+
+ assertInvocations(client.getBusinessActivityInvocations(), "complete", "confirmCompleted", "close");
+ }
+
+ /**
+ * Tests cancel without WSTXFeature and with enabled WSTX handler.
+ *
+ * "cancel" call is expected.
+ */
+ @Test
+ public void testCancelWithoutFeature() throws Exception {
+ TestServiceBA client = getBAClientWithoutFeature();
+
+ beginActivity();
+ client.increment();
+ cancelActivity();
+
+ assertInvocations(client.getBusinessActivityInvocations(), "cancel");
+ }
+
+ /**
+ * Tests service invocation without BA context, WSTXFeature, and with enabled WSTX handler.
+ *
+ * No coordination calls are expected.
+ */
+ @Test
+ public void testNoActivityWithoutFeature() {
+ TestServiceBA client = getBAClientWithoutFeature();
+
+ client.increment();
+
+ assertInvocations(client.getBusinessActivityInvocations());
+ }
+
+ /**
+ * Tests invocation to the BA-unaware service without BA context, WSTXFeature, and with enabled WSTX handler.
+ *
+ * No coordination calls are expected.
+ */
+ @Test
+ public void testNonTransactionalServiceWithoutFeature() {
+ TestService client = getClientWithoutFeature();
+
+ beginActivity();
+ client.increment();
+ closeActivity();
+ }
+
+ /**
+ * Tests close with enabled WSTXFeature and with enabled WSTX handler.
+ *
+ * "complete", "confirmCompleted", and "close" calls are expected.
+ */
+ @Test
+ public void testCloseWithEnabledFeature() {
+ TestServiceBA client = getBAClientWithFeature(true);
+
+ beginActivity();
+ client.increment();
+ closeActivity();
+
+ assertInvocations(client.getBusinessActivityInvocations(), "complete", "confirmCompleted", "close");
+ }
+
+ /**
+ * Tests cancel with enabled WSTXFeature and with enabled WSTX handler.
+ *
+ * "cancel" call is expected.
+ */
+ @Test
+ public void testCancelWithEnabledFeature() throws Exception {
+ TestServiceBA client = getBAClientWithFeature(true);
+
+ beginActivity();
+ client.increment();
+ cancelActivity();
+
+ assertInvocations(client.getBusinessActivityInvocations(), "cancel");
+ }
+
+ /**
+ * Tests service invocation without BA context but with enabled WSTXFeature and with enabled WSTX handler.
+ *
+ * No coordination calls are expected.
+ */
+ @Test
+ public void testNoActivityWithEnabledFeature() {
+ TestServiceBA client = getBAClientWithFeature(true);
+
+ client.increment();
+
+ assertInvocations(client.getBusinessActivityInvocations());
+ }
+
+ /**
+ * Tests invocation to the BA-unaware service without BA context but with enabled WSTXFeature and with enabled WSTX handler.
+ *
+ * SOAPFaultException is expected.
+ */
+ @Test
+ public void testNonTransactionalServiceWithEnabledFeature() {
+ TestService client = getClientWithFeature(true);
+
+ beginActivity();
+
+ try {
+ client.increment();
+ throw new RuntimeException("SOAPFaultException was expected");
+ } catch (SOAPFaultException e) {
+ // TODO for some reason <code>@Test(expected = SOAPFaultException.class)</code> did not work.
+ }
+ }
+
+ /**
+ * Tests close with disabled WSTXFeature and with enabled WSTX handler.
+ *
+ * No coordination calls are expected.
+ */
+ @Test
+ public void testCloseWithDisabledFeature() {
+ TestServiceBA client = getBAClientWithFeature(false);
+
+ beginActivity();
+ client.increment();
+ closeActivity();
+
+ assertInvocations(client.getBusinessActivityInvocations());
+ }
+
+ /**
+ * Tests cancel with disabled WSTXFeature and with enabled WSTX handler.
+ *
+ * No coordination calls are expected.
+ */
+ @Test
+ public void testCancelWithDisabledFeature() throws Exception {
+ TestServiceBA client = getBAClientWithFeature(false);
+
+ beginActivity();
+ client.increment();
+ cancelActivity();
+
+ assertInvocations(client.getBusinessActivityInvocations());
+ }
+
+ /**
+ * Tests service invocation without BA context but with disabled WSTXFeature and with enabled WSTX handler.
+ *
+ * No coordination calls are expected.
+ */
+ @Test
+ public void testNoActivityWithDisabledFeature() {
+ TestServiceBA client = getBAClientWithFeature(false);
+
+ client.increment();
+
+ assertInvocations(client.getBusinessActivityInvocations());
+ }
+
+ /**
+ * Tests invocation to the BA-unaware service without BA context but with disabled WSTXFeature and with enabled WSTX
+ * handler.
+ *
+ * No coordination calls are expected.
+ */
+ @Test
+ public void testNonTransactionalServiceWithDisabledFeature() {
+ TestService client = getClientWithFeature(false);
+
+ beginActivity();
+ client.increment();
+ closeActivity();
+ }
+
+ /**
+ * Tests service invocation using client which registers JaxWSHeaderContextProcessor with binding provider manually.
+ *
+ * "complete", "confirmCompleted", and "close" calls are expected.
+ *
+ * @throws InterruptedException
+ */
+ @Test
+ public void testCloseWithFeatureUnawareClient() throws InterruptedException {
+ TestServiceBA client = getBAClientWithManuallyAddedHandler();
+
+ beginActivity();
+ client.increment();
+ closeActivity();
+
+ assertInvocations(client.getBusinessActivityInvocations(), "complete", "confirmCompleted", "close");
+ }
+
+ /**
+ * Tests service invocation using client which registers JaxWSHeaderContextProcessor with binding provider manually.
+ *
+ * "cancel" call is expected.
+ *
+ * @throws InterruptedException
+ */
+ @Test
+ public void testCancelWithFeatureUnawareClient() {
+ TestServiceBA client = getBAClientWithManuallyAddedHandler();
+
+ beginActivity();
+ client.increment();
+ cancelActivity();
+
+ assertInvocations(client.getBusinessActivityInvocations(), "cancel");
+ }
+
+}
View
188 ...it/unit/src/test/java/com/arjuna/wstx/tests/arq/basic/AbstractContextPropagationTest.java
@@ -0,0 +1,188 @@
+package com.arjuna.wstx.tests.arq.basic;
+
+import java.net.MalformedURLException;
+import java.util.List;
+
+import org.junit.After;
+import org.junit.Assert;
+
+import com.arjuna.mw.wst11.UserTransaction;
+import com.arjuna.mw.wst11.UserTransactionFactory;
+import com.arjuna.wstx.tests.common.TestService;
+import com.arjuna.wstx.tests.common.TestServiceAT;
+import com.arjuna.wstx.tests.common.TestServiceATClient;
+import com.arjuna.wstx.tests.common.TestServiceClient;
+
+/**
+ *
+ * @author <a href="mailto:gytis@redhat.com">Gytis Trikleris</a>
+ *
+ */
+public abstract class AbstractContextPropagationTest {
+
+ @After
+ public void after() {
+ UserTransaction userTransaction = UserTransactionFactory.userTransaction();
+
+ rollbackIfActive(userTransaction);
+ }
+
+ /**
+ * Creates and resets WS-AT and WS-BA unaware client.
+ *
+ * @return TestService
+ */
+ protected TestService getClientWithoutFeature() {
+ TestService client;
+
+ try {
+ client = TestServiceClient.getClientWithoutFeature();
+ } catch (MalformedURLException e) {
+ throw new RuntimeException("Client creation failed.", e);
+ }
+
+ client.reset();
+
+ return client;
+ }
+
+ /**
+ * Creates and resets WS-AT and WS-BA unaware client with WSTXFeature.
+ *
+ * @param isWSTXFeatureEnabled
+ * @return TestServiceClient
+ */
+ protected TestService getClientWithFeature(final boolean isWSTXFeatureEnabled) {
+ TestService client;
+
+ try {
+ client = TestServiceClient.getClientWithWSTXFeature(isWSTXFeatureEnabled);
+ } catch (MalformedURLException e) {
+ throw new RuntimeException("Client creation failed.", e);
+ }
+
+ client.reset();
+
+ return client;
+ }
+
+ /**
+ * Creates and resets WS-AT aware client.
+ *
+ * @return TestServiceAT
+ */
+ protected TestServiceAT getATClientWithoutFeature() {
+ TestServiceAT client;
+
+ try {
+ client = TestServiceATClient.getClientWithoutFeature();
+ } catch (MalformedURLException e) {
+ throw new RuntimeException("Client creation failed.", e);
+ }
+
+ client.reset();
+
+ return client;
+ }
+
+ /**
+ * Creates and resets WS-AT aware client with WSTXFeature.
+ *
+ * @param isWSTXFeatureEnabled
+ * @return TestServiceAT
+ */
+ protected TestServiceAT getATClientWithFeature(final boolean isWSTXFeatureEnabled) {
+ TestServiceAT client;
+
+ try {
+ client = TestServiceATClient.getClientWithWSTXFeature(isWSTXFeatureEnabled);
+ } catch (MalformedURLException e) {
+ throw new RuntimeException("Client creation failed.", e);
+ }
+
+ client.reset();
+
+ return client;
+ }