Package org.jboss.arquillian.spi

Examples of org.jboss.arquillian.spi.TestEnricher


   @Test
   public void shouldBeAbleToInjectBaseContext() throws Exception
   {
      InitialContext context = new InitialContext();
      bind(ApplicationScoped.class, InitialContext.class, context);
      TestEnricher enricher = new ArquillianResourceTestEnricher();
      injector.get().inject(enricher);

      ContextClass test = new ContextClass();
      enricher.enrich(test);
     
      Assert.assertEquals(context, test.context);
   }
View Full Code Here


   public void shouldBeAbleToInjectServlet() throws Exception
   {
      InitialContext context = new InitialContext();
      bind(ApplicationScoped.class, InitialContext.class, context);
     
      TestEnricher enricher = new ArquillianResourceTestEnricher();
      injector.get().inject(enricher);

      InitialContextClass test = new InitialContextClass();
      enricher.enrich(test);
     
      Assert.assertEquals(context, test.context);
   }
View Full Code Here

   @Test
   public void shouldBeAbleToInjectBaseContext() throws Exception
   {
      bind(ApplicationScoped.class, ProtocolMetaData.class, new ProtocolMetaData().addContext(new HTTPContext("TEST", 8080)));
      TestEnricher enricher = new ArquillianResourceTestEnricher();
      injector.get().inject(enricher);

      URLBaseContextClass test = new URLBaseContextClass();
      enricher.enrich(test);
     
      Assert.assertEquals("http://TEST:8080", test.url.toExternalForm());
   }
View Full Code Here

   {
      bind(ApplicationScoped.class, ProtocolMetaData.class,
            new ProtocolMetaData().addContext(new HTTPContext("TEST", 8080)
            .add(new Servlet(URLServletContextClass.class.getSimpleName(), "/test"))));
     
      TestEnricher enricher = new ArquillianResourceTestEnricher();
      injector.get().inject(enricher);

      URLServletContextClass test = new URLServletContextClass();
      enricher.enrich(test);
     
      Assert.assertEquals("http://TEST:8080/test/", test.url.toExternalForm());
   }
View Full Code Here

   @Test
   @SuppressWarnings("rawtypes")
   public void testMethodQualifer() throws Exception
   {
      TestEnricher testEnricher = new DroneTestEnricher();

      manager.getContext(ClassContext.class).activate(MethodEnrichedClass.class);

      Mockito.when(serviceLoader.all(Configurator.class))
            .thenReturn(Arrays.<Configurator> asList(new MockDroneFactory()));
      Mockito.when(serviceLoader.all(Instantiator.class))
            .thenReturn(Arrays.<Instantiator> asList(new MockDroneFactory()));
      Mockito.when(serviceLoader.all(Destructor.class))
            .thenReturn(Arrays.<Destructor> asList(new MockDroneFactory()));
      Mockito.when(serviceLoader.all(TestEnricher.class))
            .thenReturn(Arrays.<TestEnricher> asList(testEnricher));

      manager.fire(new BeforeSuite());

      DroneRegistry registry = manager.getContext(SuiteContext.class).getObjectStore().get(DroneRegistry.class);
      Assert.assertNotNull("Drone registry was created in the context", registry);

      Assert.assertTrue("Configurator is of mock type", registry.getConfiguratorFor(MockDroneInstance.class) instanceof MockDroneFactory);

      manager.fire(new BeforeClass(MethodEnrichedClass.class));

      MethodContext mc = manager.getContext(ClassContext.class).getObjectStore().get(MethodContext.class);
      Assert.assertNotNull("Method context object holder was created in the context", mc);

      Object instance = new MethodEnrichedClass();
      Method testMethod = MethodEnrichedClass.class.getMethod("testMethodEnrichment", MockDroneInstance.class);

      manager.inject(testEnricher);
      Object[] parameters = testEnricher.resolve(testMethod);
      testMethod.invoke(instance, parameters);
   }
View Full Code Here

TOP

Related Classes of org.jboss.arquillian.spi.TestEnricher

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.