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

JMS - Quarkus support #110

Open
npapageorgopoulos opened this issue Jul 3, 2024 · 1 comment
Open

JMS - Quarkus support #110

npapageorgopoulos opened this issue Jul 3, 2024 · 1 comment

Comments

@npapageorgopoulos
Copy link

How would be the configuration via jms or amqp on an activemq topic
and I asume the syntax would be with CitrusEndpoints?

@npapageorgopoulos
Copy link
Author

I created a similar test to Kafka sample but doesnt really seem to work:

@QuarkusTest
@CitrusSupport
@CitrusConfiguration(classes = { EndpointConfig.class })
public class MyIntegrationTests {

    @CitrusEndpoint
    JmsEndpoint todoJmsEndpoint;


    @CitrusResource
    TestCaseRunner t;

    @Test
    public void testSendTodoMessage() throws IOException {
        String addTodoEntryPayload = new String(Files.readAllBytes(Paths.get("src/test/resources/mocks/addTodoEntry.json")));

        t.when(send(todoJmsEndpoint)
                .message()
                .header("_type", "JSONObject")
                .body(addTodoEntryPayload));
    }
}

Where My endpoint class is the bellow, that i Bind it accordingly:


public class EndpointConfig {

    private static final Logger logger = LoggerFactory.getLogger(EndpointConfig.class);

    @ConfigProperty(name = "citrus.jms.url")
    String brokerUrl;

    @ConfigProperty(name = "citrus.jms.username")
    String username;

    @ConfigProperty(name = "citrus.jms.password")
    String password;

    @ConfigProperty(name = "citrus.jms.destinations.inbound")
    String inboundDestination;


    @BindToRegistry
    public ConnectionFactory connectionFactory() {
        logger.info("Creating ConnectionFactory with URL: {}", brokerUrl);
        JmsConnectionFactory connectionFactory = new JmsConnectionFactory(brokerUrl);
        connectionFactory.setUsername(username);
        connectionFactory.setPassword(password);
        return connectionFactory;
    }

    @BindToRegistry
    public JmsEndpoint todoJmsEndpoint(ConnectionFactory connectionFactory) {
        logger.info("Creating JmsEndpoint for inbound destination: {}", inboundDestination);
        return CitrusEndpoints.jms()
                .asynchronous()
                .connectionFactory(connectionFactory)
                .destination(inboundDestination)
                .build();
    }
}

the exception i am receiving is:

org.junit.jupiter.api.extension.TestInstantiationException: Failed to create test instance

	at io.quarkus.test.junit.QuarkusTestExtension.initTestState(QuarkusTestExtension.java:788)
	at io.quarkus.test.junit.QuarkusTestExtension.interceptTestClassConstructor(QuarkusTestExtension.java:754)
	at java.base/java.util.Optional.orElseGet(Optional.java:364)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
Caused by: java.lang.IllegalArgumentException: wrong number of arguments: 0 expected: 1
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at org.citrusframework.annotations.CitrusAnnotations.lambda$parseConfiguration$7(CitrusAnnotations.java:249)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
	at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:1024)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
	at org.citrusframework.annotations.CitrusAnnotations.parseConfiguration(CitrusAnnotations.java:246)
	at org.citrusframework.annotations.CitrusAnnotations.parseConfiguration(CitrusAnnotations.java:224)
	at org.citrusframework.CitrusContext.parseConfiguration(CitrusContext.java:135)
	at org.citrusframework.annotations.CitrusAnnotations.parseConfiguration(CitrusAnnotations.java:240)
	at org.citrusframework.CitrusContext.parseConfiguration(CitrusContext.java:148)
	at org.citrusframework.quarkus.CitrusTestResource.inject(CitrusTestResource.java:86)
	at io.quarkus.test.common.TestResourceManager.inject(TestResourceManager.java:165)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at io.quarkus.test.junit.QuarkusTestExtension.createActualTestInstance(QuarkusTestExtension.java:799)
	at io.quarkus.test.junit.QuarkusTestExtension.initTestState(QuarkusTestExtension.java:782)
	... 4 more

2024-07-07 21:25:43,886 INFO  [org.cit.rep.LoggingReporter] (main) 
2024-07-07 21:25:43,886 INFO  [org.cit.rep.LoggingReporter] (main) TEST SUCCESS MyIntegrationTests (ubi.example.tests)
2024-07-07 21:25:43,886 INFO  [org.cit.rep.LoggingReporter] (main) ------------------------------------------------------------------------
2024-07-07 21:25:43,886 INFO  [org.cit.rep.LoggingReporter] (main) 

org.junit.jupiter.api.extension.TestInstantiationException: Failed to create test instance

	at io.quarkus.test.junit.QuarkusTestExtension.initTestState(QuarkusTestExtension.java:788)
	at io.quarkus.test.junit.QuarkusTestExtension.interceptTestClassConstructor(QuarkusTestExtension.java:754)
	at java.base/java.util.Optional.orElseGet(Optional.java:364)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
Caused by: org.citrusframework.exceptions.CitrusRuntimeException: Unable to find bean reference for type 'class org.citrusframework.jms.endpoint.JmsEndpoint'
	at org.citrusframework.spi.SimpleReferenceResolver.lambda$resolve$1(SimpleReferenceResolver.java:23)
	at java.base/java.util.Optional.orElseThrow(Optional.java:403)
	at org.citrusframework.spi.SimpleReferenceResolver.resolve(SimpleReferenceResolver.java:23)
	at org.citrusframework.annotations.CitrusEndpointAnnotations.lambda$injectEndpoints$0(CitrusEndpointAnnotations.java:69)
	at org.citrusframework.util.ReflectionHelper.doWithFields(ReflectionHelper.java:115)
	at org.citrusframework.annotations.CitrusEndpointAnnotations.injectEndpoints(CitrusEndpointAnnotations.java:40)
	at org.citrusframework.annotations.CitrusAnnotations.injectEndpoints(CitrusAnnotations.java:95)
	at org.citrusframework.quarkus.CitrusTestResource.inject(CitrusTestResource.java:87)
	at io.quarkus.test.common.TestResourceManager.inject(TestResourceManager.java:165)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at io.quarkus.test.junit.QuarkusTestExtension.createActualTestInstance(QuarkusTestExtension.java:799)
	at io.quarkus.test.junit.QuarkusTestExtension.initTestState(QuarkusTestExtension.java:782)
	... 4 more

@npapageorgopoulos npapageorgopoulos changed the title JMS support JMS - Quarkus support Jul 7, 2024
@npapageorgopoulos npapageorgopoulos changed the title JMS - Quarkus support Question about: JMS - Quarkus support Jul 10, 2024
@npapageorgopoulos npapageorgopoulos changed the title Question about: JMS - Quarkus support JMS - Quarkus support Jul 10, 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