Package com.nokia.dempsy.container.internal

Examples of com.nokia.dempsy.container.internal.LifecycleHelper


   //  Configuration
   //----------------------------------------------------------------------------

   public void setPrototype(Object prototype) throws ContainerException
   {
      this.prototype = new LifecycleHelper(prototype);
     
      preInitializePrototype(prototype);
     
      if (outputConcurrency > 0)
         setupOutputConcurrency();
View Full Code Here


   @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());
   }
View Full Code Here

   @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));
   }
View Full Code Here

   @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);
   }
View Full Code Here

   @Test(expected=ContainerException.class)
   public void testConstructorFailsIfNotAnnotedAsMP()
   throws Exception
   {
      new LifecycleHelper(new InvalidMP_NoAnnotation());
   }
View Full Code Here

   @Test(expected=ContainerException.class)
   public void testConstructorFailsIfNoCloneMethod()
   throws Exception
   {
      new LifecycleHelper(new InvalidMP_NoClone());
   }
View Full Code Here

   @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")));
   }
View Full Code Here

   @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);
View Full Code Here

   @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);
   }
View Full Code Here

   @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);
   }
View Full Code Here

TOP

Related Classes of com.nokia.dempsy.container.internal.LifecycleHelper

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.