Examples of DroneContext


Examples of org.jboss.arquillian.drone.impl.DroneContext

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

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

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

      MockDroneConfiguration configuration = context.get(MockDroneConfiguration.class);
      Assert.assertNull("There is no MockDroneConfiguration with @Default qualifier", configuration);

      configuration = context.get(MockDroneConfiguration.class, Different.class);
      Assert.assertNotNull("MockDroneConfiguration is stored with @Different qualifier", configuration);

      Assert.assertEquals("MockDroneConfiguration field is set via System properties", MockDroneFactory.FIELD_OVERRIDE, configuration.getField());

      manager.getContext(ClassContext.class).deactivate();
View Full Code Here

Examples of org.jboss.arquillian.drone.impl.DroneContext

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

      manager.fire(new BeforeClass(this.getClass()));

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

      SeleniumConfiguration configuration = context.get(SeleniumConfiguration.class);
      Assert.assertEquals("SeleniumConfiguration has *testbrowser set as browser", "*testbrowser", configuration.getBrowser());
   }
View Full Code Here

Examples of org.jboss.arquillian.drone.spi.DroneContext

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

        DroneContext context = getManager().getContext(ApplicationContext.class).getObjectStore().get(DroneContext
                .class);
        Assert.assertNotNull("DroneContext was created in the context", context);

        GlobalDroneConfiguration globalDroneConfiguration = context.getGlobalDroneConfiguration
                (GlobalDroneConfiguration.class);
        Assert.assertNotNull("Global Drone configuration was created", globalDroneConfiguration);
        Assert.assertEquals("Drone timeout is set to " + timeout + " seconds", timeout,
                globalDroneConfiguration.getInstantiationTimeoutInSeconds());
View Full Code Here

Examples of org.jboss.arquillian.drone.spi.DroneContext

        Assert.assertTrue("Configurator is of MockDronePriorityFactory type",
                registry.getEntryFor(MockDrone.class, Configurator.class) instanceof MockDronePriorityFactory);

        getManager().fire(new BeforeClass(this.getClass()));

        DroneContext context = getManager().getContext(ApplicationContext.class).getObjectStore().get(DroneContext
                .class);
        Assert.assertNotNull("Drone object holder was created in the context", context);

        DronePoint<MockDrone> dronePoint = new DronePointImpl<MockDrone>(MockDrone.class,DronePoint.Lifecycle.CLASS,
                AnnotationMocks.drone());

        MockDroneConfiguration configuration = context.get(dronePoint).getConfigurationAs(MockDroneConfiguration.class);
        Assert.assertEquals("MockDrone configuration was created by MockDronePriorityFactory",
                MockDronePriorityFactory.MOCK_DRONE_PRIORITY_FACTORY_FIELD, configuration.getField());
    }
View Full Code Here

Examples of org.jboss.arquillian.drone.spi.DroneContext

        Method testDummyMethod = DummyClass.class.getMethod("testDummyMethod");

        getManager().getContext(TestContext.class).activate(instance);
        fire(new BeforeSuite());

        DroneContext context = getManager()
            .getContext(ApplicationContext.class).getObjectStore().get(DroneContext.class);
        Assert.assertNotNull("DroneContext was created in the context", context);

        DroneRegistry registry = getManager().getContext(SuiteContext.class).getObjectStore().get(DroneRegistry.class);
        Assert.assertNotNull("Drone registry was created in the context", registry);
View Full Code Here

Examples of org.jboss.arquillian.drone.spi.DroneContext

        createDroneCallable(registry, dronePoint);
    }

    private <DRONE> void configureDrone(DroneRegistry registry, DronePoint<DRONE> dronePoint) {
        ArquillianDescriptor descriptor = arquillianDescriptor.get();
        DroneContext context = droneContext.get();
        Validate.stateNotNull(descriptor, "ArquillianDescriptor should not be null");
        Validate.stateNotNull(context, "DroneContext should be available while working with method scoped instances");

        if (context.get(dronePoint).hasConfiguration()) {
            logger.log(Level.WARNING, "Could not configure drone for injection point {0}, " +
                    "because it was already configured!", dronePoint);
            return;
        }

        Configurator<DRONE, ?> configurator = registry.getEntryFor(dronePoint.getDroneType(), Configurator.class);

        beforeDroneConfiguredEvent.fire(new BeforeDroneConfigured(configurator, dronePoint));

        // If nobody else provided the configuration, we have to do it
        if (!context.get(dronePoint).hasConfiguration()) {
            DroneConfiguration configuration = configurator.createConfiguration(descriptor, dronePoint);

            context.get(dronePoint).setConfiguration(configuration);
        }

        afterDroneConfiguredEvent.fire(new AfterDroneConfigured(dronePoint));
    }
View Full Code Here

Examples of org.jboss.arquillian.drone.spi.DroneContext

        afterDroneConfiguredEvent.fire(new AfterDroneConfigured(dronePoint));
    }

    private <DRONE> void createDroneCallable(DroneRegistry registry, final DronePoint<DRONE> dronePoint) {
        final DroneContext context = droneContext.get();

        if (context.get(dronePoint).hasFutureInstance()) {
            logger.log(Level.WARNING, "Could not create drone callable for injection point {0}, " +
                    "because it was already created!", dronePoint);
            return;
        }

        final Instantiator instantiator = registry.getEntryFor(dronePoint.getDroneType(), Instantiator.class);
        if (logger.isLoggable(Level.FINE)) {
            logger.fine("Using instantiator defined in class: " + instantiator.getClass().getName() + ", " +
                    "with precedence " + instantiator.getPrecedence());
        }

        beforeDroneCallableCreatedEvent.fire(new BeforeDroneCallableCreated(instantiator, dronePoint));

        // create future instance
        CachingCallable<DRONE> futureDrone = new CachingCallableImpl<DRONE>() {
            @Override
            protected DRONE createInstance() throws Exception {
                DroneConfiguration<?> configuration = context
                        .get(dronePoint)
                        .getConfigurationAs(DroneConfiguration.class);
                return (DRONE) instantiator.createInstance(configuration);
            }
        };

        context.get(dronePoint).setFutureInstance(futureDrone);

        afterDroneCallableCreatedEvent.fire(new AfterDroneCallableCreated(dronePoint));
    }
View Full Code Here

Examples of org.jboss.arquillian.drone.spi.DroneContext

    @Inject
    private Instance<DroneContext> droneContext;

    public void destroyDrone(@Observes DestroyDrone command) {
        DroneContext context = droneContext.get();
        DronePoint<?> dronePoint = command.getDronePoint();
        // FIXME this condition might not be valid anymore!
        if (dronePoint == null || !context.contains(dronePoint)) {
            return;
        }

        boolean wasInstantiated = context.get(dronePoint).isInstantiated();
        if (wasInstantiated) {
            Destructor destructor = getDestructorFor(dronePoint.getDroneType());

            droneLifecycleEvent.fire(new BeforeDroneDestroyed(dronePoint));

            // we need to get drone once again, at it might get modified by observers on previous event
            Object drone = context.get(dronePoint).getInstance();

            destructor.destroyInstance(drone);
        }

        if (wasInstantiated) {
            droneLifecycleEvent.fire(new AfterDroneDestroyed(dronePoint));
        }

        context.remove(dronePoint);
    }
View Full Code Here

Examples of org.jboss.arquillian.drone.spi.DroneContext

    @Inject
    private Event<DroneLifecycleEvent> droneLifecycleEvent;

    @Override
    public void enrich(Object testCase) {
        DroneContext context = droneContext.get();

        Map<Field, DronePoint<?>> injectionPoints = InjectionPoints.fieldsInClass(droneContext.get(),
                testCase.getClass());

        for (Field field : injectionPoints.keySet()) {
            // omit setting if already set
            if (SecurityActions.getFieldValue(testCase, field) != null) {
                log.log(Level.FINER, "Skipped injection of field {0}", field.getName());
                continue;
            }

            DronePoint<?> dronePoint = injectionPoints.get(field);

            ensureInjectionPointPrepared(dronePoint);

            log.log(Level.FINE, "Injecting @Drone for field {0}, injection point {1}",
                    new Object[] { dronePoint.getDroneType().getSimpleName(), dronePoint }
            );

            Object drone = context.get(dronePoint).getInstance();
            Validate.stateNotNull(drone, "Retrieved a null from Drone Context, " +
                            "which is not a valid Drone browser object. \nClass: {0}, field: {1}, injection point: {2}",
                    testCase.getClass().getName(), field.getName(), dronePoint
            );
            SecurityActions.setFieldValue(testCase, field, drone);
View Full Code Here

Examples of org.jboss.arquillian.drone.spi.DroneContext

        }
    }

    @Override
    public Object[] resolve(Method method) {
        DroneContext context = droneContext.get();
        DronePoint<?>[] dronePoints = InjectionPoints.parametersInMethod(droneContext.get(), method);
        Object[] resolution = new Object[dronePoints.length];
        for (int i = 0; i < dronePoints.length; i++) {
            DronePoint<?> dronePoint = dronePoints[i];
            if (dronePoint == null) {
                resolution[i] = null;
                continue;
            }

            ensureInjectionPointPrepared(dronePoint);

            log.log(Level.FINE, "Injecting @Drone for method {0}, injection point {1}",
                    new Object[] { method.getName(), dronePoint }
            );

            Object drone = context.get(dronePoint).getInstance();
            Validate.stateNotNull(drone, "Retrieved a null from Drone Context, which is not a valid Drone browser " +
                    "object" +
                    ".\nMethod: {0}, injection point: {1},", method.getName(), dronePoint);
            resolution[i] = drone;
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.