Search in sources :

Example 1 with MessageProcessor

use of net.dempsy.lifecycle.annotation.MessageProcessor in project Dempsy by Dempsy.

the class MessageProcessMessageHandlingTest method testMpMessageTypeInfoOnParameter.

@Test
public void testMpMessageTypeInfoOnParameter() throws Exception {
    final MessageProcessor<TestMpWithMultiLevelMessageTypeParameter> helper = new MessageProcessor<TestMpWithMultiLevelMessageTypeParameter>(new TestMpWithMultiLevelMessageTypeParameter());
    helper.validate();
    final Set<String> mts = helper.messagesTypesHandled();
    assertEquals(1, mts.size());
    exception.expect(IllegalArgumentException.class);
    exception.expectMessage("no handler for messages of type");
    final Message m = new Message("yo");
    final TestMpWithMultiLevelMessageTypeParameter instance = helper.newInstance();
    helper.invoke(instance, km(m));
}
Also used : TestMpWithMultiLevelMessageTypeParameter(net.dempsy.lifecycle.annotations.TestMps.TestMpWithMultiLevelMessageTypeParameter) Message(net.dempsy.lifecycle.annotations.TestMps.Message) MessageProcessor(net.dempsy.lifecycle.annotation.MessageProcessor) Test(org.junit.Test)

Example 2 with MessageProcessor

use of net.dempsy.lifecycle.annotation.MessageProcessor in project Dempsy by Dempsy.

the class MessageProcessMessageHandlingTest method testMpMessageTypeInfo.

@Test
public void testMpMessageTypeInfo() throws Exception {
    final MessageProcessor<TestMpMessageTypeClass> helper = new MessageProcessor<TestMpMessageTypeClass>(new TestMpMessageTypeClass());
    helper.validate();
    final MessageNoTypeInfo m = new MessageNoTypeInfo("yo");
    final TestMpMessageTypeClass instance = helper.newInstance();
    helper.invoke(instance, km(m));
}
Also used : MessageNoTypeInfo(net.dempsy.lifecycle.annotations.TestMps.MessageNoTypeInfo) MessageProcessor(net.dempsy.lifecycle.annotation.MessageProcessor) TestMpMessageTypeClass(net.dempsy.lifecycle.annotations.TestMps.TestMpMessageTypeClass) Test(org.junit.Test)

Example 3 with MessageProcessor

use of net.dempsy.lifecycle.annotation.MessageProcessor in project Dempsy by Dempsy.

the class MessageProcessorTest method testMethodHandleExtraParametersOrderChanged.

@Test
public void testMethodHandleExtraParametersOrderChanged() throws Throwable {
    final MessageProcessor<TestMpExtraParametersChangedOrder> helper = new MessageProcessor<TestMpExtraParametersChangedOrder>(new TestMpExtraParametersChangedOrder());
    helper.validate();
    final TestMpExtraParametersChangedOrder mp = helper.newInstance();
    assertFalse(mp.isActivated());
    helper.activate(mp, "activate");
    assertTrue(mp.isActivated());
    assertFalse(mp.ispassivateCalled());
    helper.passivate(mp);
    assertTrue(mp.ispassivateCalled());
}
Also used : MessageProcessor(net.dempsy.lifecycle.annotation.MessageProcessor) TestMpExtraParametersChangedOrder(net.dempsy.lifecycle.annotations.TestMps.TestMpExtraParametersChangedOrder) Test(org.junit.Test)

Example 4 with MessageProcessor

use of net.dempsy.lifecycle.annotation.MessageProcessor in project Dempsy by Dempsy.

the class MessageProcessMessageHandlingTest method testMessageTypeResolution.

@Test
public void testMessageTypeResolution() throws Exception {
    final MessageProcessor<TestMp> helper = new MessageProcessor<TestMp>(new TestMp());
    helper.validate();
    final Message m = new Message("yo");
    final TestMp instance = helper.newInstance();
    helper.invoke(instance, km(m));
}
Also used : Message(net.dempsy.lifecycle.annotations.TestMps.Message) MessageProcessor(net.dempsy.lifecycle.annotation.MessageProcessor) TestMp(net.dempsy.lifecycle.annotations.TestMps.TestMp) Test(org.junit.Test)

Example 5 with MessageProcessor

use of net.dempsy.lifecycle.annotation.MessageProcessor in project Dempsy by Dempsy.

the class MessageProcessMessageHandlingTest method testMpMessageTypeInfoOnReturn.

@Test
public void testMpMessageTypeInfoOnReturn() throws Exception {
    final MessageProcessor<TestMpWithReturn> helper = new MessageProcessor<TestMpWithReturn>(new TestMpWithReturn());
    helper.validate();
    final Message m = new Message("yo");
    final TestMpWithReturn instance = helper.newInstance();
    final List<KeyedMessageWithType> kms = helper.invoke(instance, km(m));
    assertEquals(1, kms.size());
    assertNotNull(kms.get(0).messageTypes);
    assertEquals(1, kms.get(0).messageTypes.length);
}
Also used : KeyedMessageWithType(net.dempsy.messages.KeyedMessageWithType) Message(net.dempsy.lifecycle.annotations.TestMps.Message) MessageProcessor(net.dempsy.lifecycle.annotation.MessageProcessor) TestMpWithReturn(net.dempsy.lifecycle.annotations.TestMps.TestMpWithReturn) Test(org.junit.Test)

Aggregations

MessageProcessor (net.dempsy.lifecycle.annotation.MessageProcessor)21 Test (org.junit.Test)21 ArrayList (java.util.ArrayList)5 List (java.util.List)5 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)5 Activation (net.dempsy.lifecycle.annotation.Activation)5 MessageHandler (net.dempsy.lifecycle.annotation.MessageHandler)5 MessageKey (net.dempsy.lifecycle.annotation.MessageKey)5 MessageType (net.dempsy.lifecycle.annotation.MessageType)5 Mp (net.dempsy.lifecycle.annotation.Mp)5 Serializable (java.io.Serializable)4 Arrays (java.util.Arrays)4 Collections (java.util.Collections)4 Map (java.util.Map)4 Set (java.util.Set)4 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)4 Collectors (java.util.stream.Collectors)4 ClusterId (net.dempsy.config.ClusterId)4 Adaptor (net.dempsy.messages.Adaptor)4 Dispatcher (net.dempsy.messages.Dispatcher)4