Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/maven/org.wildfly.common-wildfly-…
Browse files Browse the repository at this point in the history
…common-1.7.0.Final
  • Loading branch information
tadamski authored Jan 15, 2024
2 parents bba9b19 + 3f2bea3 commit 4c9c9ce
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up JDK ${{ inputs.jdk-distribution }} ${{ inputs.jdk-version }}
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: ${{ inputs.jdk-distribution }}
java-version: ${{ inputs.jdk-version }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up JDK ${{ matrix.jdk-distribution }} ${{ matrix.jdk-version }}
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: ${{ matrix.jdk-distribution }}
java-version: ${{ matrix.jdk-version }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ejb-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up JDK ${{ matrix.jdk-distribution }} ${{ matrix.jdk-version }}
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: ${{ matrix.jdk-distribution }}
java-version: ${{ matrix.jdk-version }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/wildfly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up JDK ${{ matrix.jdk-distribution }} ${{ matrix.jdk-version }}
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: ${{ matrix.jdk-distribution }}
java-version: ${{ matrix.jdk-version }}
Expand Down
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<parent>
<groupId>org.jboss</groupId>
<artifactId>jboss-parent</artifactId>
<version>40</version>
<version>41</version>
<relativePath/>
</parent>

Expand Down Expand Up @@ -53,13 +53,13 @@
<version.org.jboss.logmanager>2.0.7.Final</version.org.jboss.logmanager>
<version.org.jboss.narayana>7.0.0.Final</version.org.jboss.narayana>
<version.org.jboss.remoting>5.0.27.Final</version.org.jboss.remoting>
<version.org.jboss.xnio>3.8.10.Final</version.org.jboss.xnio>
<version.org.jboss.xnio>3.8.12.Final</version.org.jboss.xnio>
<version.org.kohsuke.metainf-services>1.11</version.org.kohsuke.metainf-services>
<version.org.wildfly.common>1.7.0.Final</version.org.wildfly.common>
<version.org.wildfly.elytron>2.2.2.Final</version.org.wildfly.elytron>
<version.org.wildfly.naming-client>2.0.1.Final</version.org.wildfly.naming-client>
<version.bridger>1.6.Final</version.bridger>
<version.org.jboss.byteman>4.0.18</version.org.jboss.byteman>
<version.org.jboss.byteman>4.0.22</version.org.jboss.byteman>

<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
Expand Down Expand Up @@ -216,7 +216,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.wildfly.transaction.client.provider.jboss.TestTransactionManager;
import org.wildfly.transaction.client.provider.jboss.TestTransactionProvider;
import org.wildfly.transaction.client.provider.jboss.TestXAResource;
import org.wildfly.transaction.client.provider.jboss.TestXAResourceRecoveryRegistry;
import org.wildfly.transaction.client.provider.jboss.TestXid;

import javax.transaction.xa.XAResource;
Expand All @@ -40,9 +41,11 @@
*/
public class LocalUserTransactionTestCase {

private static final TestXAResourceRecoveryRegistry testXAResourceRecoveryRegistry = new TestXAResourceRecoveryRegistry();

@BeforeClass
public static void init() {
final LocalTransactionContext transactionContext = new LocalTransactionContext(new TestTransactionProvider(500, Path.of("./target")));
final LocalTransactionContext transactionContext = new LocalTransactionContext(new TestTransactionProvider(500, Path.of("./target"), testXAResourceRecoveryRegistry));
LocalTransactionContext.getContextManager().setGlobalDefault(transactionContext);
}

Expand Down Expand Up @@ -207,4 +210,28 @@ public void outflowedTransactionTest() throws Exception {
Assert.assertFalse(TestTransactionManager.rolledback);
}

@Test
public void removeXAResourceRecoveryTest() throws Exception {
ContextTransactionManager tm = ContextTransactionManager.getInstance();
Assert.assertNull(tm.stateRef.get().transaction);
tm.begin();
Assert.assertTrue(TestTransactionProvider.newTransactionCreated);
Assert.assertNotNull(tm.stateRef.get().transaction);

Transaction t = tm.stateRef.get().transaction;
Assert.assertNotNull(t);
Assert.assertTrue(t instanceof LocalTransaction);
LocalTransaction lt = (LocalTransaction) t;

tm.commit();
Assert.assertNull(tm.stateRef.get().transaction);
Assert.assertTrue(TestTransactionManager.committed);
Assert.assertFalse(TestTransactionManager.rolledback);

TestTransactionProvider testTransactionProvider = (TestTransactionProvider) lt.getProvider();
Assert.assertNotNull(testXAResourceRecoveryRegistry.getXaResourceRecovery());

testTransactionProvider.removeXAResourceRecovery(testXAResourceRecoveryRegistry);
Assert.assertNull(testXAResourceRecoveryRegistry.getXaResourceRecovery());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import jakarta.transaction.Synchronization;
import jakarta.transaction.SystemException;
import jakarta.transaction.Transaction;
import org.jboss.tm.XAResourceRecoveryRegistry;
import org.wildfly.common.Assert;
import org.wildfly.transaction.client.SimpleXid;

Expand All @@ -42,6 +43,12 @@ public TestTransactionProvider(final int staleTransactionTime,
super(new TestExtendedJBossXATerminator(), staleTransactionTime, new TestTransactionManager(), new TestXAResourceRecoveryRegistry(), xaRecoveryPath);
}

public TestTransactionProvider(final int staleTransactionTime,
final Path xaRecoveryPath,
final XAResourceRecoveryRegistry xaResourceRecoveryRegistry) {
super(new TestExtendedJBossXATerminator(), staleTransactionTime, new TestTransactionManager(), xaResourceRecoveryRegistry, xaRecoveryPath);
}

@Override
public Transaction createNewTransaction(int timeout) throws SystemException, SecurityException {
newTransactionCreated = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,21 @@

public class TestXAResourceRecoveryRegistry implements XAResourceRecoveryRegistry {

private XAResourceRecovery xaResourceRecovery;

public TestXAResourceRecoveryRegistry(){}

@Override
public void addXAResourceRecovery(XAResourceRecovery xaResourceRecovery) {

this.xaResourceRecovery = xaResourceRecovery;
}

@Override
public void removeXAResourceRecovery(XAResourceRecovery xaResourceRecovery) {
this.xaResourceRecovery = null;
}

public XAResourceRecovery getXaResourceRecovery() {
return xaResourceRecovery;
}
}

0 comments on commit 4c9c9ce

Please sign in to comment.