Search in sources :

Example 51 with DefaultMessage

use of org.apache.camel.impl.DefaultMessage in project camel by apache.

the class BeanInfoAMoreComplexOverloadedTest method testRequestA.

public void testRequestA() throws Exception {
    BeanInfo beanInfo = new BeanInfo(context, Bean.class);
    Message message = new DefaultMessage();
    message.setBody(new RequestA());
    Exchange exchange = new DefaultExchange(context);
    exchange.setIn(message);
    MethodInvocation methodInvocation = beanInfo.createInvocation(new Bean(), exchange);
    Method method = methodInvocation.getMethod();
    assertEquals("doSomething", method.getName());
    assertEquals(RequestA.class, method.getGenericParameterTypes()[0]);
}
Also used : DefaultMessage(org.apache.camel.impl.DefaultMessage) DefaultExchange(org.apache.camel.impl.DefaultExchange) Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) Message(org.apache.camel.Message) DefaultMessage(org.apache.camel.impl.DefaultMessage) Method(java.lang.reflect.Method)

Example 52 with DefaultMessage

use of org.apache.camel.impl.DefaultMessage in project camel by apache.

the class BeanInfoOverloadedTest method testBeanInfoOverloaded.

public void testBeanInfoOverloaded() throws Exception {
    BeanInfo beanInfo = new BeanInfo(context, Bean.class);
    Message message = new DefaultMessage();
    message.setBody(new RequestB());
    Exchange exchange = new DefaultExchange(context);
    exchange.setIn(message);
    MethodInvocation methodInvocation = beanInfo.createInvocation(new Bean(), exchange);
    Method method = methodInvocation.getMethod();
    assertEquals("doSomething", method.getName());
    assertEquals(RequestB.class, method.getGenericParameterTypes()[0]);
}
Also used : DefaultMessage(org.apache.camel.impl.DefaultMessage) DefaultExchange(org.apache.camel.impl.DefaultExchange) Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) Message(org.apache.camel.Message) DefaultMessage(org.apache.camel.impl.DefaultMessage) Method(java.lang.reflect.Method)

Example 53 with DefaultMessage

use of org.apache.camel.impl.DefaultMessage in project camel by apache.

the class DockerConfigurationTest method testPropertyfromEndpointProperties.

@Test
public void testPropertyfromEndpointProperties() {
    String host = "camelhost";
    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put(DockerHelper.transformFromHeaderName(DockerConstants.DOCKER_HOST), host);
    configuration.setParameters(parameters);
    Message message = new DefaultMessage();
    String configurationProp = DockerHelper.getProperty(DockerConstants.DOCKER_HOST, configuration, message, String.class);
    assertEquals(host, configurationProp);
}
Also used : DefaultMessage(org.apache.camel.impl.DefaultMessage) Message(org.apache.camel.Message) DefaultMessage(org.apache.camel.impl.DefaultMessage) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 54 with DefaultMessage

use of org.apache.camel.impl.DefaultMessage in project camel by apache.

the class SplitAttachmentsExpression method extractAttachment.

private Message extractAttachment(Message inMessage, String attachmentName) throws Exception {
    final Message outMessage = new DefaultMessage();
    outMessage.setHeader(HEADER_NAME, attachmentName);
    Object attachment = inMessage.getAttachment(attachmentName).getContent();
    if (attachment instanceof InputStream) {
        outMessage.setBody(readMimePart((InputStream) attachment));
        return outMessage;
    } else if (attachment instanceof String || attachment instanceof byte[]) {
        outMessage.setBody(attachment);
        return outMessage;
    } else {
        return null;
    }
}
Also used : DefaultMessage(org.apache.camel.impl.DefaultMessage) Message(org.apache.camel.Message) DefaultMessage(org.apache.camel.impl.DefaultMessage) InputStream(java.io.InputStream)

Example 55 with DefaultMessage

use of org.apache.camel.impl.DefaultMessage in project webcert by sklintyg.

the class RouteTest method testWiretappingOfSignedMessages.

@Test
public void testWiretappingOfSignedMessages() throws ModuleException, InterruptedException, IOException {
    notificationAggregator.whenAnyExchangeReceived(exchange -> {
        Message msg = new DefaultMessage();
        exchange.setOut(msg);
    });
    // Given
    when(moduleApi.getIntygFromUtlatande(any())).thenReturn(NotificationTestHelper.createIntyg("luae_fs"));
    notificationWSClient.expectedMessageCount(0);
    notificationWSClientV3.expectedMessageCount(0);
    notificationAggregator.expectedMessageCount(0);
    permanentErrorHandlerEndpoint.expectedMessageCount(0);
    temporaryErrorHandlerEndpoint.expectedMessageCount(0);
    signatWireTap.expectedMessageCount(1);
    // When
    Map<String, Object> headers = new HashMap<>();
    headers.put(NotificationRouteHeaders.INTYGS_TYP, "luae_fs");
    headers.put(NotificationRouteHeaders.HANDELSE, HandelsekodEnum.SIGNAT.value());
    producerTemplate.sendBodyAndHeaders(createNotificationMessage(SchemaVersion.VERSION_3, "luae_fs"), headers);
    // Then
    assertIsSatisfied(notificationWSClient);
    assertIsSatisfied(notificationWSClientV3);
    assertIsSatisfied(notificationAggregator);
    assertIsSatisfied(permanentErrorHandlerEndpoint);
    assertIsSatisfied(temporaryErrorHandlerEndpoint);
    assertIsSatisfied(signatWireTap);
}
Also used : DefaultMessage(org.apache.camel.impl.DefaultMessage) Message(org.apache.camel.Message) DefaultMessage(org.apache.camel.impl.DefaultMessage) HashMap(java.util.HashMap) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Aggregations

DefaultMessage (org.apache.camel.impl.DefaultMessage)66 Message (org.apache.camel.Message)59 Exchange (org.apache.camel.Exchange)32 Test (org.junit.Test)31 DefaultExchange (org.apache.camel.impl.DefaultExchange)24 HashMap (java.util.HashMap)19 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)11 CamelContext (org.apache.camel.CamelContext)7 Producer (org.apache.camel.Producer)6 VolumeProducer (org.apache.camel.component.openstack.cinder.producer.VolumeProducer)6 GlanceProducer (org.apache.camel.component.openstack.glance.GlanceProducer)6 ProjectProducer (org.apache.camel.component.openstack.keystone.producer.ProjectProducer)6 NetworkProducer (org.apache.camel.component.openstack.neutron.producer.NetworkProducer)6 KeypairProducer (org.apache.camel.component.openstack.nova.producer.KeypairProducer)6 ContainerProducer (org.apache.camel.component.openstack.swift.producer.ContainerProducer)6 DefaultHeadersMapFactory (org.apache.camel.impl.DefaultHeadersMapFactory)6 NotificationMessage (se.inera.intyg.common.support.modules.support.api.notification.NotificationMessage)5 IOException (java.io.IOException)4 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4 Method (java.lang.reflect.Method)3