Skip to content

Commit

Permalink
JBTM-3358 Update to MicroProfile LRA 1.0-M2
Browse files Browse the repository at this point in the history
  • Loading branch information
xstefank authored and ochaloup committed Sep 22, 2020
1 parent 9c492c3 commit ec82270
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import javax.enterprise.inject.spi.Extension;
import javax.enterprise.util.AnnotationLiteral;
import java.io.IOException;
import java.lang.reflect.Modifier;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -101,12 +102,12 @@ public void observe(@Observes AfterBeanDiscovery event, BeanManager beanManager)
* @return Collected methods wrapped in {@link LRAParticipant} class or null if no non-JAX-RS methods have been found
*/
private LRAParticipant getAsParticipant(ClassInfo classInfo) throws ClassNotFoundException {
if (!isLRAParticipant(classInfo)) {
Class<?> javaClass = getClass().getClassLoader().loadClass(classInfo.name().toString());

if (javaClass.isInterface() || Modifier.isAbstract(javaClass.getModifiers()) || !isLRAParticipant(classInfo)) {
return null;
}

Class<?> javaClass = getClass().getClassLoader().loadClass(classInfo.name().toString());

LRAParticipant participant = new LRAParticipant(javaClass);
return participant.hasNonJaxRsMethods() ? participant : null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

package io.narayana.lra.arquillian;

import org.eclipse.microprofile.lra.tck.LRAClientOps;
import org.eclipse.microprofile.lra.tck.participant.api.WrongHeaderException;
import org.eclipse.microprofile.lra.tck.service.LRAMetricService;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
Expand All @@ -32,6 +34,7 @@ public static WebArchive deploy(String appName) {
return ShrinkWrap.create(WebArchive.class, appName + ".war")
.addPackages(true,
LRAMetricService.class.getPackage(),
org.codehaus.jettison.JSONSequenceTooLargeException.class.getPackage());
org.codehaus.jettison.JSONSequenceTooLargeException.class.getPackage())
.addClasses(LRAClientOps.class, WrongHeaderException.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public void nestedParticipantAfterLRACallTest() {

nestedLRA = URI.create(response.readEntity(String.class));
Assert.assertNotEquals(parentLRA, nestedLRA);
Assert.assertEquals(1, lraMetricService.getMetric(LRAMetricType.Nested, parentLRA));
Assert.assertEquals(1, lraMetricService.getMetric(LRAMetricType.Nested, parentLRA, NestedParticipant.class));
} finally {
if (response != null) {
response.close();
Expand All @@ -118,15 +118,15 @@ public void nestedParticipantAfterLRACallTest() {
// https://issues.redhat.com/browse/JBTM-3330
narayanaLRARecovery.waitForEndPhaseReplay(nestedLRA);

Assert.assertEquals(1, lraMetricService.getMetric(LRAMetricType.Completed, nestedLRA));
Assert.assertEquals(2, lraMetricService.getMetric(LRAMetricType.Nested, parentLRA));
Assert.assertEquals(0, lraMetricService.getMetric(LRAMetricType.AfterLRA, nestedLRA));
Assert.assertEquals(1, lraMetricService.getMetric(LRAMetricType.Completed, nestedLRA, NestedParticipant.class));
Assert.assertEquals(2, lraMetricService.getMetric(LRAMetricType.Nested, parentLRA, NestedParticipant.class));
Assert.assertEquals(0, lraMetricService.getMetric(LRAMetricType.AfterLRA, nestedLRA, NestedParticipant.class));

narayanaLRAClient.closeLRA(parentLRA);
narayanaLRARecovery.waitForEndPhaseReplay(nestedLRA);

Assert.assertEquals("After LRA method for nested LRA enlist should have been called",
1, lraMetricService.getMetric(LRAMetricType.AfterLRA, nestedLRA));
1, lraMetricService.getMetric(LRAMetricType.AfterLRA, nestedLRA, NestedParticipant.class));

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class NestedParticipant {
@Produces(MediaType.TEXT_PLAIN)
public Response enlist(@HeaderParam(LRA.LRA_HTTP_CONTEXT_HEADER) URI lraId,
@HeaderParam(LRA.LRA_HTTP_PARENT_CONTEXT_HEADER) URI parentId) {
lraMetricService.incrementMetric(LRAMetricType.Nested, parentId);
lraMetricService.incrementMetric(LRAMetricType.Nested, parentId, NestedParticipant.class);
return Response.ok(lraId).build();
}

Expand All @@ -68,8 +68,8 @@ public Response enlist(@HeaderParam(LRA.LRA_HTTP_CONTEXT_HEADER) URI lraId,
@Produces(MediaType.TEXT_PLAIN)
public Response complete(@HeaderParam(LRA.LRA_HTTP_CONTEXT_HEADER) URI lraId,
@HeaderParam(LRA.LRA_HTTP_PARENT_CONTEXT_HEADER) URI parentId) {
lraMetricService.incrementMetric(LRAMetricType.Nested, parentId);
lraMetricService.incrementMetric(LRAMetricType.Completed, lraId);
lraMetricService.incrementMetric(LRAMetricType.Nested, parentId, NestedParticipant.class);
lraMetricService.incrementMetric(LRAMetricType.Completed, lraId, NestedParticipant.class);
return Response.ok(ParticipantStatus.Completed).build();
}

Expand All @@ -88,8 +88,8 @@ public Response compensate() {
@Produces(MediaType.TEXT_PLAIN)
public Response afterLRA(@HeaderParam(LRA.LRA_HTTP_ENDED_CONTEXT_HEADER) URI endedLraId,
@HeaderParam(LRA.LRA_HTTP_PARENT_CONTEXT_HEADER) URI parentId) {
lraMetricService.incrementMetric(LRAMetricType.Nested, parentId);
lraMetricService.incrementMetric(LRAMetricType.AfterLRA, endedLraId);
lraMetricService.incrementMetric(LRAMetricType.Nested, parentId, NestedParticipant.class);
lraMetricService.incrementMetric(LRAMetricType.AfterLRA, endedLraId, NestedParticipant.class);
return Response.ok(endedLraId).build();
}
}
4 changes: 2 additions & 2 deletions rts/lra/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
<version.junit>4.12</version.junit>

<version.arquillian>1.2.1.Final</version.arquillian> <!-- cannot use the up-to-date Arquillian https://issues.jboss.org/browse/THORN-2090 -->
<version.microprofile.lra.api>1.0-M1</version.microprofile.lra.api>
<version.microprofile.lra.tck>1.0-M1</version.microprofile.lra.tck>
<version.microprofile.lra.api>1.0-M2</version.microprofile.lra.api>
<version.microprofile.lra.tck>1.0-M2</version.microprofile.lra.tck>

<version.org.jboss.weld.se>3.1.1.Final</version.org.jboss.weld.se>
<version.org.jboss.shrinkwrap>1.2.6</version.org.jboss.shrinkwrap>
Expand Down

0 comments on commit ec82270

Please sign in to comment.