forked from jbosstm/narayana
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JBTM-3781 Narayana doesn't implement mp.lra.propagation.active config…
… property
- Loading branch information
Showing
4 changed files
with
133 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
rts/lra/test/basic/src/test/java/io/narayana/lra/arquillian/LRAPropagationIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source. | ||
* Copyright 2023, 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 io.narayana.lra.arquillian; | ||
|
||
import io.narayana.lra.arquillian.resource.LRAUnawareResource; | ||
import io.narayana.lra.arquillian.resource.SimpleLRAParticipant; | ||
import jakarta.ws.rs.WebApplicationException; | ||
import jakarta.ws.rs.core.Response; | ||
import org.jboss.arquillian.container.test.api.Deployment; | ||
import org.jboss.arquillian.test.api.ArquillianResource; | ||
import org.jboss.logging.Logger; | ||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.jboss.shrinkwrap.api.spec.WebArchive; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.rules.TestName; | ||
|
||
import java.net.URI; | ||
import java.net.URL; | ||
|
||
import static org.junit.Assert.assertNotEquals; | ||
|
||
public class LRAPropagationIT extends TestBase { | ||
private static final Logger log = Logger.getLogger(LRAPropagationIT.class); | ||
|
||
@ArquillianResource | ||
public URL baseURL; | ||
|
||
@Rule | ||
public TestName testName = new TestName(); | ||
|
||
@Override | ||
public void before() { | ||
super.before(); | ||
log.info("Running test " + testName.getMethodName()); | ||
} | ||
|
||
@Deployment | ||
public static WebArchive deploy() { | ||
return Deployer.deploy(LRAPropagationIT.class.getSimpleName(), LRAUnawareResource.class, SimpleLRAParticipant.class) | ||
.addAsManifestResource( | ||
new StringAsset("mp.lra.propagation.active=false"), "microprofile-config.properties"); | ||
} | ||
|
||
@Test | ||
public void noLRATest() throws WebApplicationException { | ||
URI lraId = lraClient.startLRA(LRAPropagationIT.class.getName()); | ||
|
||
URI returnedLraId = invokeInTransaction(baseURL, LRAUnawareResource.ROOT_PATH, | ||
LRAUnawareResource.RESOURCE_PATH, Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); | ||
|
||
assertNotEquals("While calling non-LRA method the resource should not propagate the LRA id when mp.lra.propagation.active=false", | ||
lraId, returnedLraId); | ||
|
||
lraClient.closeLRA(lraId); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
rts/lra/test/basic/src/test/java/io/narayana/lra/arquillian/resource/LRAUnawareResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package io.narayana.lra.arquillian.resource; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.client.Client; | ||
import jakarta.ws.rs.client.ClientBuilder; | ||
import jakarta.ws.rs.core.Context; | ||
import jakarta.ws.rs.core.Response; | ||
import jakarta.ws.rs.core.UriInfo; | ||
|
||
@ApplicationScoped | ||
@Path(LRAUnawareResource.ROOT_PATH) | ||
public class LRAUnawareResource { | ||
|
||
public static final String ROOT_PATH = "/lra-unaware"; | ||
public static final String RESOURCE_PATH = "/lra-work"; | ||
|
||
@Context | ||
private UriInfo context; | ||
|
||
@GET | ||
@Path(RESOURCE_PATH) | ||
public Response doInLRA() { | ||
try (Client client = ClientBuilder.newClient()) { | ||
// SimpleLRAParticipant.START_LRA_PATH has REQUIRED LRA type meaning that | ||
// if this method propagates LRA context it will be reused in SimpleLRAParticipant | ||
// but if it doesn't, a new LRA will be started | ||
return client.target(context.getBaseUri()) | ||
.path(SimpleLRAParticipant.SIMPLE_PARTICIPANT_RESOURCE_PATH) | ||
.path(SimpleLRAParticipant.START_LRA_PATH) | ||
.request() | ||
.get(); | ||
} | ||
} | ||
} |