You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by re...@apache.org on 2022/12/13 01:12:18 UTC

[cxf] branch main updated: Fix ws_transaction samples

This is an automated email from the ASF dual-hosted git repository.

reta pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cxf.git


The following commit(s) were added to refs/heads/main by this push:
     new 74c7505654 Fix ws_transaction samples
74c7505654 is described below

commit 74c75056545e2d33d2534f17ee810c27793ff275
Author: Andriy Redko <dr...@gmail.com>
AuthorDate: Mon Dec 12 20:11:50 2022 -0500

    Fix ws_transaction samples
---
 .../release/samples/ws_transaction/client/pom.xml  |  5 ---
 .../java/sample/ws/service/BridgeFromJTATest.java  | 25 +++++++-------
 .../src/test/java/sample/ws/service/XTSConfig.java |  9 +++++
 .../main/release/samples/ws_transaction/pom.xml    | 39 +++++++++++-----------
 .../src/main/java/sample/ws/XTSConfig.java         | 33 ++++++++++++++++--
 .../ws_first/src/main/resources/wstx_handlers.xml  |  2 +-
 .../src/main/java/sample/ws/XTSConfig.java         | 31 +++++++++++++++++
 .../ws_second/src/main/resources/wstx_handlers.xml |  2 +-
 8 files changed, 104 insertions(+), 42 deletions(-)

diff --git a/distribution/src/main/release/samples/ws_transaction/client/pom.xml b/distribution/src/main/release/samples/ws_transaction/client/pom.xml
index 7e9c963334..6a76a851c4 100644
--- a/distribution/src/main/release/samples/ws_transaction/client/pom.xml
+++ b/distribution/src/main/release/samples/ws_transaction/client/pom.xml
@@ -39,10 +39,5 @@
             <artifactId>spring-boot-sample-ws-cxf-second-service</artifactId>
             <version>${project.version}</version>
         </dependency>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-        </dependency>
     </dependencies>
 </project>
diff --git a/distribution/src/main/release/samples/ws_transaction/client/src/test/java/sample/ws/service/BridgeFromJTATest.java b/distribution/src/main/release/samples/ws_transaction/client/src/test/java/sample/ws/service/BridgeFromJTATest.java
index 357f5232ae..1585375b04 100644
--- a/distribution/src/main/release/samples/ws_transaction/client/src/test/java/sample/ws/service/BridgeFromJTATest.java
+++ b/distribution/src/main/release/samples/ws_transaction/client/src/test/java/sample/ws/service/BridgeFromJTATest.java
@@ -19,20 +19,19 @@
 
 package sample.ws.service;
 
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
-import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.context.TestPropertySource;
 
 import jakarta.transaction.UserTransaction;
 
-@RunWith(SpringRunner.class)
 @SpringBootTest(classes = SampleWsApplication.class, webEnvironment = WebEnvironment.DEFINED_PORT)
+@TestPropertySource(properties = "server.port=8080")
 public class  BridgeFromJTATest {
 
     @Autowired
@@ -42,13 +41,13 @@ public class  BridgeFromJTATest {
     private SecondServiceAT secondClient;
 
 
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         firstClient = FirstClient.newInstance();
         secondClient = SecondClient.newInstance();
     }
 
-    @After
+    @AfterEach
     public void teardownTest() throws Exception {
         rollbackIfActive(ut);
         try {
@@ -74,8 +73,8 @@ public class  BridgeFromJTATest {
         int counter2 = secondClient.getCounter();
         ut.commit();
 
-        Assert.assertEquals(1, counter1);
-        Assert.assertEquals(1, counter2);
+        Assertions.assertEquals(1, counter1);
+        Assertions.assertEquals(1, counter2);
     }
 
     @Test
@@ -90,8 +89,8 @@ public class  BridgeFromJTATest {
         int counter2 = secondClient.getCounter();
         ut.commit();
 
-        Assert.assertEquals(0, counter1);
-        Assert.assertEquals(0, counter2);
+        Assertions.assertEquals(0, counter1);
+        Assertions.assertEquals(0, counter2);
     }
 
 
diff --git a/distribution/src/main/release/samples/ws_transaction/client/src/test/java/sample/ws/service/XTSConfig.java b/distribution/src/main/release/samples/ws_transaction/client/src/test/java/sample/ws/service/XTSConfig.java
index 2ea5948b03..bb6f1e5b7f 100644
--- a/distribution/src/main/release/samples/ws_transaction/client/src/test/java/sample/ws/service/XTSConfig.java
+++ b/distribution/src/main/release/samples/ws_transaction/client/src/test/java/sample/ws/service/XTSConfig.java
@@ -27,6 +27,10 @@ import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.DependsOn;
 
+import com.arjuna.ats.internal.jta.transaction.arjunacore.UserTransactionImple;
+
+import jakarta.transaction.UserTransaction;
+
 @Configuration
 public class XTSConfig {
     @Bean(name = "xtsService", initMethod = "start", destroyMethod = "stop")
@@ -44,4 +48,9 @@ public class XTSConfig {
     public OutboundBridgeRecoveryManager outboundBridgeRecoveryManager() {
         return new OutboundBridgeRecoveryManager();
     }
+    
+    @Bean
+    public UserTransaction userTransaction() {
+        return new UserTransactionImple();
+    }
 }
diff --git a/distribution/src/main/release/samples/ws_transaction/pom.xml b/distribution/src/main/release/samples/ws_transaction/pom.xml
index 83945260dd..984661309d 100644
--- a/distribution/src/main/release/samples/ws_transaction/pom.xml
+++ b/distribution/src/main/release/samples/ws_transaction/pom.xml
@@ -58,25 +58,6 @@
                 </exclusion>
             </exclusions>
         </dependency>
-        <dependency>
-            <groupId>me.snowdrop</groupId>
-            <artifactId>narayana-spring-boot-starter</artifactId>
-            <version>${cxf.narayana.spring.boot.version}</version>
-            <exclusions>
-                <exclusion>
-                    <groupId>org.jboss.narayana</groupId>
-                    <artifactId>jbosstxbridge</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.jboss.narayana</groupId>
-                    <artifactId>jbosstxts</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.jboss.narayana.jta</groupId>
-                    <artifactId>narayana-jta</artifactId>
-                </exclusion>
-            </exclusions>
-        </dependency>
         <dependency>
             <groupId>org.jboss.narayana.jta</groupId>
             <artifactId>narayana-jta-jakarta</artifactId>
@@ -91,6 +72,22 @@
             <artifactId>jbosstxbridge-jakarta</artifactId>
             <version>${cxf.jboss.narayana.version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.jboss.ws</groupId>
+            <artifactId>jbossws-api</artifactId>
+            <version>2.0.0.Final</version>
+        </dependency>
+        <dependency>
+            <groupId>org.jboss.ws.cxf</groupId>
+            <artifactId>jbossws-cxf-client</artifactId>
+            <version>6.1.0.Final</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.apache.cxf</groupId>
+                    <artifactId>*</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-data-jpa</artifactId>
@@ -101,6 +98,10 @@
             <artifactId>h2</artifactId>
             <version>${cxf.h2.version}</version>
         </dependency>
+        <dependency>
+            <groupId>com.sun.xml.messaging.saaj</groupId>
+            <artifactId>saaj-impl</artifactId>
+        </dependency>
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-test</artifactId>
diff --git a/distribution/src/main/release/samples/ws_transaction/ws_first/src/main/java/sample/ws/XTSConfig.java b/distribution/src/main/release/samples/ws_transaction/ws_first/src/main/java/sample/ws/XTSConfig.java
index 460720d2df..83923d5cdb 100644
--- a/distribution/src/main/release/samples/ws_transaction/ws_first/src/main/java/sample/ws/XTSConfig.java
+++ b/distribution/src/main/release/samples/ws_transaction/ws_first/src/main/java/sample/ws/XTSConfig.java
@@ -22,15 +22,18 @@ package sample.ws;
 import org.jboss.jbossts.XTSService;
 import org.jboss.jbossts.txbridge.inbound.InboundBridgeRecoveryManager;
 import org.jboss.jbossts.xts.environment.WSCEnvironmentBean;
-import org.jboss.jbossts.xts.environment.XTSEnvironmentBean;
 import org.jboss.jbossts.xts.environment.XTSPropertyManager;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.DependsOn;
+import org.springframework.transaction.jta.JtaTransactionManager;
 
-import java.util.ArrayList;
-import java.util.List;
+import com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple;
+
+import jakarta.transaction.TransactionManager;
+import jakarta.transaction.TransactionSynchronizationRegistry;
+import jakarta.transaction.UserTransaction;
 
 @Configuration
 public class XTSConfig {
@@ -51,4 +54,28 @@ public class XTSConfig {
     public InboundBridgeRecoveryManager inboundBridgeRecoveryManager() {
         return new InboundBridgeRecoveryManager();
     }
+    
+    @Bean
+    public UserTransaction narayanaUserTransaction() {
+        return com.arjuna.ats.jta.UserTransaction.userTransaction();
+    }
+
+    @Bean
+    public TransactionManager narayanaTransactionManager() {
+        return com.arjuna.ats.jta.TransactionManager.transactionManager();
+    }
+
+    @Bean
+    public TransactionSynchronizationRegistry narayanaTransactionSynchronizationRegistry() {
+        return new TransactionSynchronizationRegistryImple();
+    }
+
+    @Bean
+    public JtaTransactionManager transactionManager(UserTransaction userTransaction,
+            TransactionManager transactionManager,
+            TransactionSynchronizationRegistry transactionSynchronizationRegistry) {
+        JtaTransactionManager jtaTransactionManager = new JtaTransactionManager(userTransaction, transactionManager);
+        jtaTransactionManager.setTransactionSynchronizationRegistry(transactionSynchronizationRegistry);
+        return jtaTransactionManager;
+    }
 }
diff --git a/distribution/src/main/release/samples/ws_transaction/ws_first/src/main/resources/wstx_handlers.xml b/distribution/src/main/release/samples/ws_transaction/ws_first/src/main/resources/wstx_handlers.xml
index 2f565ddc39..b13d39a012 100644
--- a/distribution/src/main/release/samples/ws_transaction/ws_first/src/main/resources/wstx_handlers.xml
+++ b/distribution/src/main/release/samples/ws_transaction/ws_first/src/main/resources/wstx_handlers.xml
@@ -17,7 +17,7 @@
   specific language governing permissions and limitations
   under the License.
 -->
-<handler-chains xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee">
+<handler-chains xmlns="https://jakarta.ee/xml/ns/jakartaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee">
     <handler-chain>
         <handler>
             <handler-name>BridgeHandler</handler-name>
diff --git a/distribution/src/main/release/samples/ws_transaction/ws_second/src/main/java/sample/ws/XTSConfig.java b/distribution/src/main/release/samples/ws_transaction/ws_second/src/main/java/sample/ws/XTSConfig.java
index f1c04a8f6f..46cbdbe958 100644
--- a/distribution/src/main/release/samples/ws_transaction/ws_second/src/main/java/sample/ws/XTSConfig.java
+++ b/distribution/src/main/release/samples/ws_transaction/ws_second/src/main/java/sample/ws/XTSConfig.java
@@ -28,6 +28,13 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.DependsOn;
+import org.springframework.transaction.jta.JtaTransactionManager;
+
+import com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple;
+
+import jakarta.transaction.TransactionManager;
+import jakarta.transaction.TransactionSynchronizationRegistry;
+import jakarta.transaction.UserTransaction;
 
 @Configuration
 public class XTSConfig {
@@ -48,4 +55,28 @@ public class XTSConfig {
     public InboundBridgeRecoveryManager inboundBridgeRecoveryManager() {
         return new InboundBridgeRecoveryManager();
     }
+
+    @Bean
+    public UserTransaction narayanaUserTransaction() {
+        return com.arjuna.ats.jta.UserTransaction.userTransaction();
+    }
+
+    @Bean
+    public TransactionManager narayanaTransactionManager() {
+        return com.arjuna.ats.jta.TransactionManager.transactionManager();
+    }
+
+    @Bean
+    public TransactionSynchronizationRegistry narayanaTransactionSynchronizationRegistry() {
+        return new TransactionSynchronizationRegistryImple();
+    }
+
+    @Bean
+    public JtaTransactionManager transactionManager(UserTransaction userTransaction,
+            TransactionManager transactionManager,
+            TransactionSynchronizationRegistry transactionSynchronizationRegistry) {
+        JtaTransactionManager jtaTransactionManager = new JtaTransactionManager(userTransaction, transactionManager);
+        jtaTransactionManager.setTransactionSynchronizationRegistry(transactionSynchronizationRegistry);
+        return jtaTransactionManager;
+    }
 }
diff --git a/distribution/src/main/release/samples/ws_transaction/ws_second/src/main/resources/wstx_handlers.xml b/distribution/src/main/release/samples/ws_transaction/ws_second/src/main/resources/wstx_handlers.xml
index 2f565ddc39..b13d39a012 100644
--- a/distribution/src/main/release/samples/ws_transaction/ws_second/src/main/resources/wstx_handlers.xml
+++ b/distribution/src/main/release/samples/ws_transaction/ws_second/src/main/resources/wstx_handlers.xml
@@ -17,7 +17,7 @@
   specific language governing permissions and limitations
   under the License.
 -->
-<handler-chains xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee">
+<handler-chains xmlns="https://jakarta.ee/xml/ns/jakartaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee">
     <handler-chain>
         <handler>
             <handler-name>BridgeHandler</handler-name>