|
24 | 24 | import static org.eclipse.microprofile.lra.tck.participant.api.AfterLRAListener.AFTER_LRA_LISTENER_WORK;
|
25 | 25 | import static org.eclipse.microprofile.lra.tck.participant.api.AfterLRAParticipant.AFTER_LRA_PARTICIPANT_PATH;
|
26 | 26 | import static org.eclipse.microprofile.lra.tck.participant.api.AfterLRAParticipant.AFTER_LRA_PARTICIPANT_WORK;
|
| 27 | +import static org.eclipse.microprofile.lra.tck.participant.api.LRAOnClassParticipant.LRA_PARTICIPANT_PATH; |
| 28 | +import static org.eclipse.microprofile.lra.tck.participant.api.LRAOnClassParticipant.LRA_PARTICIPANT_WORK; |
| 29 | +import static org.eclipse.microprofile.lra.tck.participant.api.LRAOnClassParticipantCompensate.LRA_PARTICIPANT_PATH_COMPENSATE; |
| 30 | +import static org.eclipse.microprofile.lra.tck.participant.api.LRAOnClassParticipantCompensate.LRA_PARTICIPANT_START; |
27 | 31 | import static org.eclipse.microprofile.lra.tck.participant.api.LraResource.ACCEPT_WORK;
|
28 | 32 | import static org.eclipse.microprofile.lra.tck.participant.api.LraResource.CANCEL_PATH;
|
29 | 33 | import static org.eclipse.microprofile.lra.tck.participant.api.LraResource.LRA_RESOURCE_PATH;
|
|
47 | 51 | import java.util.stream.IntStream;
|
48 | 52 |
|
49 | 53 | import org.eclipse.microprofile.lra.annotation.AfterLRA;
|
| 54 | +import org.eclipse.microprofile.lra.annotation.ws.rs.LRA; |
50 | 55 | import org.eclipse.microprofile.lra.tck.participant.api.AfterLRAListener;
|
51 | 56 | import org.eclipse.microprofile.lra.tck.participant.api.AfterLRAParticipant;
|
52 | 57 | import org.eclipse.microprofile.lra.tck.participant.api.GenericLRAException;
|
| 58 | +import org.eclipse.microprofile.lra.tck.participant.api.LRAOnClassParticipant; |
| 59 | +import org.eclipse.microprofile.lra.tck.participant.api.LRAOnClassParticipantCompensate; |
53 | 60 | import org.eclipse.microprofile.lra.tck.participant.api.LraResource;
|
54 | 61 | import org.eclipse.microprofile.lra.tck.participant.api.NoLRAResource;
|
55 | 62 | import org.eclipse.microprofile.lra.tck.participant.api.ParticipatingTckResource;
|
@@ -698,4 +705,59 @@ private void multiLevelNestedActivity(CompletionType how, int nestedCnt) throws
|
698 | 705 | resourcePath.getUri() + ")", 1);
|
699 | 706 | }
|
700 | 707 | }
|
| 708 | + |
| 709 | + /** |
| 710 | + * TCK test to verify that classes annotated with {@link LRA} are notified correctly the participant has afterLRA |
| 711 | + * method |
| 712 | + * |
| 713 | + * @throws InterruptedException |
| 714 | + * when waiting for the finishing the callbacks is interrupted |
| 715 | + */ |
| 716 | + @Test |
| 717 | + public void testLRAParticipantAnnotationOnClass() throws WebApplicationException, InterruptedException { |
| 718 | + URI lra = lraClient.startLRA(null, lraClientId(), lraTimeout(), ChronoUnit.MILLIS); |
| 719 | + WebTarget resourcePath = tckSuiteTarget.path(LRA_PARTICIPANT_PATH).path(LRA_PARTICIPANT_WORK); |
| 720 | + Response response = resourcePath |
| 721 | + .request().header(LRA_HTTP_CONTEXT_HEADER, lra).put(Entity.text("")); |
| 722 | + checkStatusAndCloseResponse(Response.Status.OK, response, resourcePath); |
| 723 | + lraClient.closeLRA(lra); |
| 724 | + lraTestService.waitForCallbacks(lra); |
| 725 | + |
| 726 | + // verify that the LRA is now in one of the terminal states |
| 727 | + lraMetric.assertFinished("testLRAParticipantAnnotationOnClass: LRA did not finish", lra, |
| 728 | + LRAOnClassParticipant.class); |
| 729 | + |
| 730 | + // verify that the resource was notified of the final state of the LRA |
| 731 | + lraMetric.assertClosed("testLRAParticipantAnnotationOnClass: end synchronization was not invoked on resource " + |
| 732 | + resourcePath.getUri(), lra, LRAOnClassParticipant.class); |
| 733 | + } |
| 734 | + |
| 735 | + /** |
| 736 | + * TCK test to verify that classes annotated with {@link LRA} are notified correctly the participant has afterLRA |
| 737 | + * and compensate methods |
| 738 | + * |
| 739 | + * @throws InterruptedException |
| 740 | + * when waiting for the finishing the callbacks is interrupted |
| 741 | + */ |
| 742 | + @Test |
| 743 | + public void testLRAParticipantAnnotationOnClassWithCompensate() |
| 744 | + throws WebApplicationException, InterruptedException { |
| 745 | + URI lra = lraClient.startLRA(null, lraClientId(), lraTimeout(), ChronoUnit.MILLIS); |
| 746 | + WebTarget resourcePath = tckSuiteTarget.path(LRA_PARTICIPANT_PATH_COMPENSATE).path(LRA_PARTICIPANT_START); |
| 747 | + Response response = resourcePath |
| 748 | + .request().header(LRA_HTTP_CONTEXT_HEADER, lra).put(Entity.text("")); |
| 749 | + checkStatusAndCloseResponse(Response.Status.OK, response, resourcePath); |
| 750 | + lraClient.closeLRA(lra); |
| 751 | + lraTestService.waitForCallbacks(lra); |
| 752 | + |
| 753 | + // verify that the LRA is now in one of the terminal states |
| 754 | + lraMetric.assertFinished("testLRAParticipantAnnotationOnClassWithCompensate: LRA did not finish", lra, |
| 755 | + LRAOnClassParticipantCompensate.class); |
| 756 | + |
| 757 | + // verify that the resource was notified of the final state of the LRA |
| 758 | + lraMetric.assertClosed( |
| 759 | + "testLRAParticipantAnnotationOnClassWithCompensate: end synchronization was not invoked on resource " + |
| 760 | + resourcePath.getUri(), |
| 761 | + lra, LRAOnClassParticipantCompensate.class); |
| 762 | + } |
701 | 763 | }
|
0 commit comments