Search in sources :

Example 6 with ActiveMQTextMessage

use of org.apache.activemq.artemis.jms.client.ActiveMQTextMessage in project UVMS-ActivityModule-APP by UnionVMS.

the class ActivityEventServiceBeanTest method setUp.

@Before
@SneakyThrows
public void setUp() {
    nonUniqueIdsMessage = new ActiveMQTextMessage(session);
    Whitebox.setInternalState(nonUniqueIdsMessage, "text", new SimpleString(getStrRequest1()));
    Whitebox.setInternalState(nonUniqueIdsMessage, "jmsCorrelationID", "SomeCorrId");
    nonUniqueIdsMessageEventMessage = new EventMessage(nonUniqueIdsMessage);
    faAndTripIdsFromTripIdsMessage = new ActiveMQTextMessage(session);
    Whitebox.setInternalState(faAndTripIdsFromTripIdsMessage, "text", new SimpleString(getStrRequest2()));
    Whitebox.setInternalState(faAndTripIdsFromTripIdsMessage, "jmsCorrelationID", "SomeCorrId");
    faAndTripIdsFromTripIdsEventMessage = new EventMessage(faAndTripIdsFromTripIdsMessage);
    getNonUniqueIdsResponse = JAXBMarshaller.unmarshallTextMessage(getResponseStr1(), GetNonUniqueIdsResponse.class);
    getFishingActivitiesForTripResponse = JAXBMarshaller.unmarshallTextMessage(getResponseStr2(), GetFishingActivitiesForTripResponse.class);
}
Also used : EventMessage(eu.europa.ec.fisheries.uvms.activity.message.event.carrier.EventMessage) GetNonUniqueIdsResponse(eu.europa.ec.fisheries.uvms.activity.model.schemas.GetNonUniqueIdsResponse) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) GetFishingActivitiesForTripResponse(eu.europa.ec.fisheries.uvms.activity.model.schemas.GetFishingActivitiesForTripResponse) ActiveMQTextMessage(org.apache.activemq.artemis.jms.client.ActiveMQTextMessage) Before(org.junit.Before) SneakyThrows(lombok.SneakyThrows)

Example 7 with ActiveMQTextMessage

use of org.apache.activemq.artemis.jms.client.ActiveMQTextMessage in project UVMS-ActivityModule-APP by UnionVMS.

the class ActivityMessageConsumerBeanTest method testOnMessageMethod.

@Test
@SneakyThrows
public void testOnMessageMethod() {
    mockStatic(MappedDiagnosticContext.class);
    PowerMockito.doNothing().when(MappedDiagnosticContext.class, "addMessagePropertiesToThreadMappedDiagnosticContext", Mockito.any(TextMessage.class));
    for (ActivityModuleMethod moduleMethod : ActivityModuleMethod.values()) {
        GetNonUniqueIdsRequest request = new GetNonUniqueIdsRequest();
        request.setMethod(moduleMethod);
        ActiveMQTextMessage textMessage = new ActiveMQTextMessage(session);
        final String strReq = JAXBMarshaller.marshallJaxBObjectToString(request);
        Whitebox.setInternalState(textMessage, "text", new SimpleString(strReq));
        consumer.onMessage(textMessage);
        PowerMockito.verifyStatic();
        MappedDiagnosticContext.addMessagePropertiesToThreadMappedDiagnosticContext(textMessage);
    }
    verify(mapToSubscriptionRequest, times(1)).fire(any(EventMessage.class));
    verify(receiveFishingActivityEvent, times(2)).fire(any(EventMessage.class));
    verify(getFishingTripListEvent, times(1)).fire(any(EventMessage.class));
    verify(getFACatchSummaryReportEvent, times(1)).fire(any(EventMessage.class));
    verify(getNonUniqueIdsRequest, times(1)).fire(any(EventMessage.class));
}
Also used : ActivityModuleMethod(eu.europa.ec.fisheries.uvms.activity.model.schemas.ActivityModuleMethod) EventMessage(eu.europa.ec.fisheries.uvms.activity.message.event.carrier.EventMessage) GetNonUniqueIdsRequest(eu.europa.ec.fisheries.uvms.activity.model.schemas.GetNonUniqueIdsRequest) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ActiveMQTextMessage(org.apache.activemq.artemis.jms.client.ActiveMQTextMessage) TextMessage(javax.jms.TextMessage) ActiveMQTextMessage(org.apache.activemq.artemis.jms.client.ActiveMQTextMessage) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test) SneakyThrows(lombok.SneakyThrows)

Example 8 with ActiveMQTextMessage

use of org.apache.activemq.artemis.jms.client.ActiveMQTextMessage in project UVMS-ActivityModule-APP by UnionVMS.

the class ActivityMessageConsumerBeanTest method testThrowing.

@Test
@SneakyThrows
public void testThrowing() {
    mockStatic(MappedDiagnosticContext.class);
    PowerMockito.doNothing().when(MappedDiagnosticContext.class, "addMessagePropertiesToThreadMappedDiagnosticContext", Mockito.any(TextMessage.class));
    ReceiveSalesReportRequest request = new ReceiveSalesReportRequest();
    request.setMethod(ExchangeModuleMethod.RECEIVE_SALES_REPORT);
    ActiveMQTextMessage textMessage = new ActiveMQTextMessage(session);
    final String strReq = JAXBMarshaller.marshallJaxBObjectToString(request);
    Whitebox.setInternalState(textMessage, "text", new SimpleString(strReq));
    consumer.onMessage(textMessage);
    PowerMockito.verifyStatic();
    MappedDiagnosticContext.addMessagePropertiesToThreadMappedDiagnosticContext(textMessage);
    verify(errorEvent, times(1)).fire(any(EventMessage.class));
}
Also used : EventMessage(eu.europa.ec.fisheries.uvms.activity.message.event.carrier.EventMessage) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ReceiveSalesReportRequest(eu.europa.ec.fisheries.schema.exchange.module.v1.ReceiveSalesReportRequest) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ActiveMQTextMessage(org.apache.activemq.artemis.jms.client.ActiveMQTextMessage) TextMessage(javax.jms.TextMessage) ActiveMQTextMessage(org.apache.activemq.artemis.jms.client.ActiveMQTextMessage) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test) SneakyThrows(lombok.SneakyThrows)

Aggregations

ActiveMQTextMessage (org.apache.activemq.artemis.jms.client.ActiveMQTextMessage)8 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)6 Test (org.junit.Test)6 TextMessage (javax.jms.TextMessage)4 EventMessage (eu.europa.ec.fisheries.uvms.activity.message.event.carrier.EventMessage)3 Connection (javax.jms.Connection)3 Session (javax.jms.Session)3 SneakyThrows (lombok.SneakyThrows)3 ActiveMQConnectionFactory (org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory)3 MessageProducer (javax.jms.MessageProducer)2 TopicSession (javax.jms.TopicSession)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 ReceiveSalesReportRequest (eu.europa.ec.fisheries.schema.exchange.module.v1.ReceiveSalesReportRequest)1 ActivityModuleMethod (eu.europa.ec.fisheries.uvms.activity.model.schemas.ActivityModuleMethod)1 GetFishingActivitiesForTripResponse (eu.europa.ec.fisheries.uvms.activity.model.schemas.GetFishingActivitiesForTripResponse)1 GetNonUniqueIdsRequest (eu.europa.ec.fisheries.uvms.activity.model.schemas.GetNonUniqueIdsRequest)1 GetNonUniqueIdsResponse (eu.europa.ec.fisheries.uvms.activity.model.schemas.GetNonUniqueIdsResponse)1 MessageConsumer (javax.jms.MessageConsumer)1 ActiveMQNotConnectedException (org.apache.activemq.artemis.api.core.ActiveMQNotConnectedException)1 ClientMessage (org.apache.activemq.artemis.api.core.client.ClientMessage)1