@SuppressWarnings("unused") public void methodOne(@Observes Object event) { Assert.assertNotNull(object); Assert.assertNull(object.get()); object.set(new Object()); methodOneWasCalled = true; }
public void createRequest(@Observes Before event, WeldManager manager) { BoundRequestContext requestContext = manager.instance().select(BoundRequestContext.class).get(); CDIRequestMap map = new CDIRequestMap(); requestContext.associate(map); requestContext.activate(); requestMap.set(map); }
public void createSession(@Observes AfterDeploy event, WeldManager manager) { BoundSessionContext sessionContext = manager.instance().select(BoundSessionContext.class).get(); CDISessionMap map = new CDISessionMap(); sessionContext.associate(map); sessionContext.activate(); sessionMap.set(map); }
public void createConversation(@Observes(precedence = -1) Before event, WeldManager manager) { if (!enableConversationScope) { return; } CDIConversationID id = conversationId.get(); if (id == null) { id = new CDIConversationID(null); // when null creates a new empty conversation id. } BoundRequest request = new MutableBoundRequest(requestMap.get(), sessionMap.get()); this.boundRequest.set(request); BoundConversationContext conversationContext = manager.instance().select(BoundConversationContext.class).get(); conversationContext.associate(request); conversationContext.activate(id.getId()); }
public void execute(@Observes Test event) throws Exception { ContainerContext containerContext = containerContextProvider.get(); DeploymentContext deploymentContext = deploymentContextProvider.get(); // TODO : move as a abstract/SPI on TestMethodExecutor DeploymentTargetDescription target = null; if (event.getTestMethod().isAnnotationPresent(DeploymentTarget.class)) { target = new DeploymentTargetDescription( event.getTestMethod().getAnnotation(DeploymentTarget.class).value()); } else { target = DeploymentTargetDescription.DEFAULT; } DeploymentScenario scenario = deploymentScenario.get(); try { DeploymentDescription deployment = scenario.getDeployment(target); Container container = containerRegistry.get().getContainer(deployment.getTarget()); containerContext.activate(container.getName()); try { // TODO: split up local vs remote execution in two handlers, fire a new set of events // LocalExecute RemoteExecute deploymentContext.activate(deployment); if (scenario.getRunMode() == RunModeType .AS_CLIENT) // TODO: DeploymentScenario should not depend on RunModeType API { testResult.set(executeLocal(event)); } else { testResult.set(executeRemote(event, deployment, container)); } } finally { deploymentContext.deactivate(); } } finally { containerContext.deactivate(); } }
public void destroySession(@Observes BeforeUnDeploy event, WeldManager manager) { BoundSessionContext sessionContext = manager.instance().select(BoundSessionContext.class).get(); CDISessionMap map = sessionMap.get(); if (map != null) { try { sessionContext.invalidate(); sessionContext.deactivate(); } finally { sessionContext.dissociate(map); } } }
public void destroyRequest(@Observes After event, WeldManager manager) { BoundRequestContext requestContext = manager.instance().select(BoundRequestContext.class).get(); CDIRequestMap map = requestMap.get(); if (map != null) { try { requestContext.invalidate(); requestContext.deactivate(); } finally { requestContext.dissociate(map); map.clear(); } } }
public void destroyConversation(@Observes(precedence = 1) After event, WeldManager manager) { if (!enableConversationScope) { return; } BoundConversationContext conversationContext = manager.instance().select(BoundConversationContext.class).get(); if (!conversationContext.getCurrentConversation().isTransient()) { conversationId.set( new CDIConversationID(conversationContext.getCurrentConversation().getId())); } else { conversationId.set(new CDIConversationID(null)); } BoundRequest request = boundRequest.get(); try { conversationContext.invalidate(); conversationContext.deactivate(); } finally { conversationContext.dissociate(request); } }