Package org.jboss.arquillian.impl.core.spi.context

Examples of org.jboss.arquillian.impl.core.spi.context.SuiteContext


   {
      ManagerImpl manager = ManagerBuilder.from()
         .context(SuiteContextImpl.class)
         .extension(TestExtension.class).create();

      SuiteContext context = manager.getContext(SuiteContext.class);
      try
      {
         context.activate();
         // bind something to the context so our Instance<Object> is resolved
         context.getObjectStore().add(Object.class, new Object());
        
         manager.fire("some string");
        
         Assert.assertTrue(manager.getExtension(TestExtension.class).wasCalled);
        
      }
      finally
      {
         context.deactivate();
         context.destroy();
      }
   }
View Full Code Here


   {
      ManagerImpl manager = ManagerBuilder.from()
         .context(SuiteContextImpl.class)
         .context(ClassContextImpl.class).create();

      SuiteContext suiteContext = manager.getContext(SuiteContext.class);
      ClassContext classContext = manager.getContext(ClassContext.class);

      try
      {
         suiteContext.activate();
         classContext.activate(this.getClass());
        
         Object testObject = new Object();
        
         manager.bind(SuiteScoped.class, Object.class, testObject);
        
         Assert.assertEquals(
               "Verify value was bound to the correct context",
               testObject,
               suiteContext.getObjectStore().get(Object.class));

         Assert.assertNull(
               "Verify value was not bound to any other context",
               classContext.getObjectStore().get(Object.class));
      }
      finally
      {
         classContext.deactivate();
         classContext.destroy(this.getClass());
         suiteContext.deactivate();
         suiteContext.destroy();
      }
   }
View Full Code Here

public class ContextActivationTestCase
{
   @Test
   public void shouldBeAbleToReceiveObjectAfterReActivation()
   {
      SuiteContext context = new SuiteContextImpl();

      try
      {
         Assert.assertFalse(context.isActive());
        
         context.activate();
         Assert.assertTrue(context.isActive());
        
         ObjectStore store = context.getObjectStore();
         store.add(Boolean.class, true);
        
         Assert.assertEquals(
               "Verify that we can get objects from a active context",
               new Boolean(true),
               store.get(Boolean.class));
        
         context.deactivate();
         Assert.assertFalse(context.isActive());
        
         try
         {
            context.getObjectStore();
            Assert.fail("Trying to get ObjectStore outside active context should have thrown Exception");
         }
         catch (Exception e) {
         }
  
         context.activate();
         store = context.getObjectStore();
  
         Assert.assertEquals(
               "Verify that we can get objects from a active context",
               new Boolean(true),
               store.get(Boolean.class));
      }
      finally
      {
         context.deactivate();
         context.destroy();
      }
     
   }
View Full Code Here

  
   @Test
   public void shouldNotBeAbleToReadFromDifferentThread() throws Exception
   {
      final CountDownLatch latch = new CountDownLatch(1);
      final SuiteContext context = new SuiteContextImpl();
      try
      {
         context.activate();
         context.getObjectStore().add(Object.class, new Object());
        
         Thread thread = new Thread()
         {
            public void run()
            {
               Assert.assertFalse(context.isActive());
              
               latch.countDown();
            };
         };
         thread.start();
        
         if(!latch.await(1, TimeUnit.SECONDS))
         {
            Assert.fail("Thread never called?");
         }
      }
      finally
      {
         context.deactivate();
         context.destroy();
      }
   }
View Full Code Here

         .extensions(
               TestObserverOne.class,
               TestObserverTwo.class,
               TestObserverTree.class).create();
     
      SuiteContext context = manager.getContext(SuiteContext.class);
      try
      {
         context.activate();
         context.getObjectStore().add(Object.class, new Object());
        
        
         manager.fire("some string event");

         Assert.assertTrue(manager.getExtension(TestObserverOne.class).wasCalled);
         Assert.assertTrue(manager.getExtension(TestObserverTwo.class).wasCalled);
         Assert.assertTrue(manager.getExtension(TestObserverTree.class).wasCalled);
        
         Assert.assertNotNull(
               "Verify instance was bound to context",
               context.getObjectStore().get(Object.class));
        
         ContainerContext containerContext = manager.getContext(ContainerContext.class);
         Assert.assertFalse(containerContext.isActive());
        
         containerContext.activate("");
         try
         {
            Assert.assertNotNull(
                  "Should have set a Double in container scope",
                  containerContext.getObjectStore().get(Double.class));
         }
         finally
         {
            containerContext.deactivate();
            containerContext.destroy("");
         }
      }
      finally
      {
         context.deactivate();
         context.destroy();
      }
   }
View Full Code Here

   {
      ManagerImpl manager = ManagerBuilder.from()
         .context(SuiteContextImpl.class).create();

      Object testObject = new Object();
      SuiteContext context = manager.getContext(SuiteContext.class);
      try
      {
         context.activate();
         context.getObjectStore().add(Object.class, testObject);
        
         Instance<Object> instance = InstanceImpl.of(Object.class, SuiteScoped.class, manager);
        
         Assert.assertEquals(
               "Verify expected object was returned",
               testObject, instance.get());
      }
      finally
      {
         context.deactivate();
         context.destroy();
      }
   }
View Full Code Here

   {
      ManagerImpl manager = ManagerBuilder.from()
         .context(SuiteContextImpl.class)
         .extension(TestObserver.class).create();

      SuiteContext context = manager.getContext(SuiteContext.class);
      try
      {
         context.activate();
        
         InstanceProducer<Object> instance = InstanceImpl.of(Object.class, SuiteScoped.class, manager);
         instance.set(new Object());

         Assert.assertTrue(manager.getExtension(TestObserver.class).wasCalled);
      }
      finally
      {
         context.deactivate();
         context.destroy();
      }
   }
View Full Code Here

   @Inject
   private Instance<TestContext> testContextInstance;
  
   public void createSuiteContext(@Observes EventContext<SuiteEvent> context)
   {
      SuiteContext suiteContext = this.suiteContextInstance.get();
      try
      {
         suiteContext.activate();
         context.proceed();
      }
      finally
      {
         suiteContext.deactivate();
      }
   }
View Full Code Here

TOP

Related Classes of org.jboss.arquillian.impl.core.spi.context.SuiteContext

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.