use of com.nokia.dempsy.container.internal.LifecycleHelper in project Dempsy by Dempsy.
the class TestInvocation method testActivateReturns.
@Test
public void testActivateReturns() throws Exception {
ActivateReturns prototype = new ActivateReturns();
LifecycleHelper invoker = new LifecycleHelper(prototype);
ActivateReturns instance = (ActivateReturns) invoker.newInstance();
assertNotNull("instantiation failed; null instance", instance);
assertNotSame("instantiation failed; returned prototype", prototype, instance);
assertFalse("instance activated before activation method called", instance.isActivated);
assertTrue(invoker.activate(instance, null, "ABC".getBytes()));
assertTrue("instance was not activated", instance.isActivated);
assertEquals("ABC", instance.activationValue);
ActivateReturns.returnValue = false;
assertFalse(invoker.activate(instance, null, "DEF".getBytes()));
assertEquals("DEF", instance.activationValue);
}
use of com.nokia.dempsy.container.internal.LifecycleHelper in project Dempsy by Dempsy.
the class TestInvocation method testLifeCycleMethods.
@Test
public void testLifeCycleMethods() throws Exception {
InvocationTestMP prototype = new InvocationTestMP();
LifecycleHelper invoker = new LifecycleHelper(prototype);
InvocationTestMP instance = (InvocationTestMP) invoker.newInstance();
assertNotNull("instantiation failed; null instance", instance);
assertNotSame("instantiation failed; returned prototype", prototype, instance);
assertFalse("instance activated before activation method called", instance.isActivated);
assertTrue(invoker.activate(instance, null, "ABC".getBytes()));
assertTrue("instance was not activated", instance.isActivated);
assertEquals("ABC", instance.activationValue);
assertFalse("instance passivated before passivation method called", instance.isPassivated);
byte[] data = invoker.passivate(instance);
assertTrue("instance was not passivated", instance.isPassivated);
assertEquals("ABC", new String(data));
}
use of com.nokia.dempsy.container.internal.LifecycleHelper in project Dempsy by Dempsy.
the class TestInvocation method testInvocationFailureNullMessage.
@Test(expected = NullPointerException.class)
public void testInvocationFailureNullMessage() throws Exception {
InvocationTestMP prototype = new InvocationTestMP();
LifecycleHelper invoker = new LifecycleHelper(prototype);
InvocationTestMP instance = (InvocationTestMP) invoker.newInstance();
BasicStatsCollector statsCollector = new BasicStatsCollector();
invoker.invoke(instance, null, statsCollector);
}
use of com.nokia.dempsy.container.internal.LifecycleHelper in project Dempsy by Dempsy.
the class TestInvocation method testOutput.
@Test
public void testOutput() throws Exception {
InvocationTestMP prototype = new InvocationTestMP();
LifecycleHelper invoker = new LifecycleHelper(prototype);
InvocationTestMP instance = (InvocationTestMP) invoker.newInstance();
assertFalse("instance says it did output before method called", instance.outputCalled);
invoker.invokeOutput(instance);
assertTrue("output method was not called", instance.outputCalled);
}
use of com.nokia.dempsy.container.internal.LifecycleHelper in project Dempsy by Dempsy.
the class TestInvocation method testInvocationExactClass.
@Test
public void testInvocationExactClass() throws Exception {
InvocationTestMP prototype = new InvocationTestMP();
LifecycleHelper invoker = new LifecycleHelper(prototype);
InvocationTestMP instance = (InvocationTestMP) invoker.newInstance();
BasicStatsCollector statsCollector = new BasicStatsCollector();
// pre-condition assertion
assertNull(prototype.lastStringHandlerValue);
assertNull(instance.lastStringHandlerValue);
String message = "foo";
Object o = invoker.invoke(instance, message, statsCollector);
assertEquals(new Integer(42), o);
// we assert that the prototype is still null to check for bad code
assertNull(prototype.lastStringHandlerValue);
assertEquals(message, instance.lastStringHandlerValue);
}
Aggregations