public void verifyExpectedExceptionDuringDeploy(@Observes EventContext<DeployDeployment> context) throws Exception { DeploymentDescription deployment = context.getEvent().getDeployment().getDescription(); boolean deploymentExceptionThrown = true; try { context.proceed(); if (deployment.getExpectedException() != null) { deploymentExceptionThrown = false; throw new RuntimeException( "Expected exception of type " + deployment.getExpectedException().getName() + " during deployment of " + deployment.getName() + ", but no exception was thrown."); } } catch (Exception e) { // if exception is not thrown from the deployment, rethrow it (we threw it). if (!deploymentExceptionThrown) { throw e; } if (deployment.getExpectedException() != null) { if (!containsType(e, deployment.getExpectedException())) { throw e; } } else { throw e; } } }
public void verifyExpectedExceptionDuringDeploy(@Observes EventContext<DeployDeployment> context) throws Exception { DeploymentDescription deployment = context.getEvent().getDeployment().getDescription(); boolean deploymentExceptionThrown = true; try { context.proceed(); if (deployment.getExpectedException() != null) { deploymentExceptionThrown = false; throw new RuntimeException( "Expected exception of type " + deployment.getExpectedException().getName() + " during deployment of " + deployment.getName() + ", but no exception was thrown."); } } catch (Exception e) { // if exception is not thrown from the deployment, rethrow it (we threw it). if (!deploymentExceptionThrown) { throw e; } if (deployment.getExpectedException() != null) { if (!containsType(e, deployment.getExpectedException())) { throw e; } } else { throw e; } } }
@Override public Void call() throws Exception { DeployableContainer<?> deployableContainer = event.getDeployableContainer(); Deployment deployment = event.getDeployment(); DeploymentDescription deploymentDescription = deployment.getDescription(); /* * TODO: should the DeploymentDescription producer some how be automatically registered ? * Or should we just 'know' who is the first one to create the context */ deploymentDescriptionProducer.set(deploymentDescription); deploymentProducer.set(deployment); deployEvent.fire(new BeforeDeploy(deployableContainer, deploymentDescription)); try { if (deploymentDescription.isArchiveDeployment()) { protocolMetadata.set(deployableContainer.deploy( deploymentDescription.getTestableArchive() != null ? deploymentDescription.getTestableArchive() : deploymentDescription.getArchive())); } else { deployableContainer.deploy(deploymentDescription.getDescriptor()); } deployment.deployed(); } catch (Exception e) { deployment.deployedWithError(e); throw e; } deployEvent.fire(new AfterDeploy(deployableContainer, deploymentDescription)); return null; } });
@Override public Void call() throws Exception { DeployableContainer<?> deployableContainer = event.getDeployableContainer(); Deployment deployment = event.getDeployment(); DeploymentDescription deploymentDescription = deployment.getDescription(); /* * TODO: should the DeploymentDescription producer some how be automatically registered ? * Or should we just 'know' who is the first one to create the context */ deploymentDescriptionProducer.set(deploymentDescription); deploymentProducer.set(deployment); deployEvent.fire(new BeforeDeploy(deployableContainer, deploymentDescription)); try { if (deploymentDescription.isArchiveDeployment()) { protocolMetadata.set(deployableContainer.deploy( deploymentDescription.getTestableArchive() != null ? deploymentDescription.getTestableArchive() : deploymentDescription.getArchive())); } else { deployableContainer.deploy(deploymentDescription.getDescriptor()); } deployment.deployed(); } catch (Exception e) { deployment.deployedWithError(e); throw e; } deployEvent.fire(new AfterDeploy(deployableContainer, deploymentDescription)); return null; } });