Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only request/response interactions can be used with an HTTP test target #185

Closed
l2c0r3 opened this issue Feb 20, 2024 · 1 comment
Closed

Comments

@l2c0r3
Copy link

l2c0r3 commented Feb 20, 2024

Hello everyone

I have created a contract from the message consumer:

Now I would like to have it checked the produced messages.

For that I wrote following Test:

@QuarkusTest
@TestProfile(SignatureTestProfile.class)
@Provider("SignPdfProvider")
@Consumer("signPdfConsumer")
@PactFolder("pacts")
public class SignPdfJmsProviderContractTest {


    @Inject
    Messageproducer messageproducer;

    @PactVerifyProvider("a signPdfRequest Message")
    void testASignPdfRequestMessage(PactVerificationContext context) {
        context.verifyInteraction();
        messageproducer.produceMessage();
    }

    @TestTemplate
    @ExtendWith(PactVerificationInvocationContextProvider.class)
    void pactVerificationTestTemplate(PactVerificationContext context) {
        context.verifyInteraction();
    }
}

However, I get the following error message:

java.lang.UnsupportedOperationException: Only request/response interactions can be used with an HTTP test target at au.com.dius.pact.provider.junit5.HttpTestTarget.prepareRequest(TestTarget.kt:98) at au.com.dius.pact.provider.junit5.PactVerificationExtension.beforeTestExecution(PactVerificationExtension.kt:136) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeTestExecutionCallbacks$5(TestMethodTestDescriptor.java:191)

Dependencies:

  • quarkus-pact-provider: 1.1.0
  • Quarkus: 2.16.12.Final

Many thanks for your support

@l2c0r3
Copy link
Author

l2c0r3 commented Feb 21, 2024

Found the solution. Unfortunately, it is not a Quarkus test (pact-foundation/pact-jvm#1506)

@Provider("SignPdfProvider")
@Consumer("signPdfConsumer")
@PactFolder("pacts")
@ExtendWith(MockitoExtension.class)
public class SignPdfJmsProviderContractTest {
    @Mock
    ...
    @InjectMocks
    SignPdfService signPdfService;

    @BeforeEach
    void before(PactVerificationContext context) {
        context.setTarget(new MessageTestTarget());
    }

    @TestTemplate
    @ExtendWith(PactVerificationInvocationContextProvider.class)
    void pactVerificationTestTemplate(PactVerificationContext context) {
        context.verifyInteraction();
    }

    @PactVerifyProvider("a signPdfRequest Message")
    public String testASignPdfRequestMessage() {
         // return Body of JMS Message
    }
}

@l2c0r3 l2c0r3 closed this as completed Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant