Search in sources :

Example 1 with LifecycleHelper

use of com.nokia.dempsy.container.internal.LifecycleHelper in project Dempsy by Dempsy.

the class MpContainer method setPrototype.

//----------------------------------------------------------------------------
//  Configuration
//----------------------------------------------------------------------------
public void setPrototype(Object prototype) throws ContainerException {
    this.prototype = new LifecycleHelper(prototype);
    preInitializePrototype(prototype);
    if (outputConcurrency > 0)
        setupOutputConcurrency();
}
Also used : LifecycleHelper(com.nokia.dempsy.container.internal.LifecycleHelper)

Example 2 with LifecycleHelper

use of com.nokia.dempsy.container.internal.LifecycleHelper in project Dempsy by Dempsy.

the class TestInvocation method testIsMessageSupported.

@Test
public void testIsMessageSupported() throws Exception {
    InvocationTestMP prototype = new InvocationTestMP();
    LifecycleHelper invoker = new LifecycleHelper(prototype);
    assertTrue(invoker.isMessageSupported("foo"));
    assertTrue(invoker.isMessageSupported(new Integer(1)));
    assertTrue(invoker.isMessageSupported(new Double(1.5)));
    assertFalse(invoker.isMessageSupported(new Object()));
    assertFalse(invoker.isMessageSupported(new StringBuilder("foo")));
}
Also used : LifecycleHelper(com.nokia.dempsy.container.internal.LifecycleHelper) Test(org.junit.Test)

Example 3 with LifecycleHelper

use of com.nokia.dempsy.container.internal.LifecycleHelper in project Dempsy by Dempsy.

the class TestInvocation method testLifecycleHelperEqualityAndHashcodeDelegateToMP.

//----------------------------------------------------------------------------
//  Test Cases
//----------------------------------------------------------------------------
@Test
public void testLifecycleHelperEqualityAndHashcodeDelegateToMP() throws Exception {
    LifecycleHelper helper1a = new LifecycleHelper(new InvocationTestMP());
    LifecycleHelper helper1b = new LifecycleHelper(new InvocationTestMP());
    LifecycleHelper helper2 = new LifecycleHelper(new LifecycleEqualityTestMP());
    assertTrue("same MP class means euqal helpers", helper1a.equals(helper1b));
    assertFalse("different MP class means not-equal helpers", helper1a.equals(helper2));
    assertTrue("same hashcode for same MP class", helper1a.hashCode() == helper1b.hashCode());
    assertFalse("different hashcode for different MP class (I hope)", helper1a.hashCode() == helper2.hashCode());
}
Also used : LifecycleHelper(com.nokia.dempsy.container.internal.LifecycleHelper) Test(org.junit.Test)

Example 4 with LifecycleHelper

use of com.nokia.dempsy.container.internal.LifecycleHelper in project Dempsy by Dempsy.

the class TestInvocation method testInvocationFailureNoHandler.

@Test(expected = ContainerException.class)
public void testInvocationFailureNoHandler() throws Exception {
    InvocationTestMP prototype = new InvocationTestMP();
    LifecycleHelper invoker = new LifecycleHelper(prototype);
    InvocationTestMP instance = (InvocationTestMP) invoker.newInstance();
    BasicStatsCollector statsCollector = new BasicStatsCollector();
    invoker.invoke(instance, new Object(), statsCollector);
}
Also used : BasicStatsCollector(com.nokia.dempsy.monitoring.basic.BasicStatsCollector) LifecycleHelper(com.nokia.dempsy.container.internal.LifecycleHelper) Test(org.junit.Test)

Example 5 with LifecycleHelper

use of com.nokia.dempsy.container.internal.LifecycleHelper in project Dempsy by Dempsy.

the class TestInvocation method testInvocationCommonSuperclass.

@Test
public void testInvocationCommonSuperclass() throws Exception {
    InvocationTestMP prototype = new InvocationTestMP();
    LifecycleHelper invoker = new LifecycleHelper(prototype);
    InvocationTestMP instance = (InvocationTestMP) invoker.newInstance();
    BasicStatsCollector statsCollector = new BasicStatsCollector();
    Integer message1 = new Integer(1);
    Object o = invoker.invoke(instance, message1, statsCollector);
    assertEquals(message1, instance.lastNumberHandlerValue);
    assertNull(o);
    Double message2 = new Double(1.5);
    invoker.invoke(instance, message2, statsCollector);
    assertEquals(message2, instance.lastNumberHandlerValue);
}
Also used : BasicStatsCollector(com.nokia.dempsy.monitoring.basic.BasicStatsCollector) LifecycleHelper(com.nokia.dempsy.container.internal.LifecycleHelper) Test(org.junit.Test)

Aggregations

LifecycleHelper (com.nokia.dempsy.container.internal.LifecycleHelper)10 Test (org.junit.Test)9 BasicStatsCollector (com.nokia.dempsy.monitoring.basic.BasicStatsCollector)4