/** * @param deploymentMethod * @return */ private TargetDescription generateTarget(Method deploymentMethod) { if (deploymentMethod.isAnnotationPresent(TargetsContainer.class)) { return new TargetDescription(deploymentMethod.getAnnotation(TargetsContainer.class).value()); } return TargetDescription.DEFAULT; }
private void throwNoContainerFound(TargetDescription target) { throw new ValidationException("DeploymentScenario contains a target (" + target.getName() + ") not matching any defined Container in the registry.\n" + "Please include at least 1 Deployable Container on your Classpath."); }
/** * Get all {@link DeploymentDescription} defined to be deployed during Test startup for a specific {@link * TargetDescription} ordered. * * @param target * The Target to filter on * * @return A List of found {@link DeploymentDescription}. Will return a empty list if none are found. */ public List<Deployment> startupDeploymentsFor(TargetDescription target) { Validate.notNull(target, "Target must be specified"); List<Deployment> startupDeployments = new ArrayList<Deployment>(); for (Deployment deployment : deployments) { DeploymentDescription desc = deployment.getDescription(); if (desc.managed() && target.equals(desc.getTarget())) { startupDeployments.add(deployment); } } // sort them by order Collections.sort(startupDeployments, new Comparator<Deployment>() { public int compare(Deployment o1, Deployment o2) { return new Integer(o1.getDescription().getOrder()).compareTo(o2.getDescription().getOrder()); } }); return Collections.unmodifiableList(startupDeployments); }
private void throwNoContainerFound(TargetDescription target) { throw new ValidationException("DeploymentScenario contains a target (" + target.getName() + ") not matching any defined Container in the registry.\n" + "Please include at least 1 Deployable Container on your Classpath."); }
/** * Get all {@link DeploymentDescription} defined to be deployed during Test startup for a specific {@link * TargetDescription} ordered. * * @param target * The Target to filter on * * @return A List of found {@link DeploymentDescription}. Will return a empty list if none are found. */ public List<Deployment> startupDeploymentsFor(TargetDescription target) { Validate.notNull(target, "Target must be specified"); List<Deployment> startupDeployments = new ArrayList<Deployment>(); for (Deployment deployment : deployments) { DeploymentDescription desc = deployment.getDescription(); if (desc.managed() && target.equals(desc.getTarget())) { startupDeployments.add(deployment); } } // sort them by order Collections.sort(startupDeployments, new Comparator<Deployment>() { public int compare(Deployment o1, Deployment o2) { return new Integer(o1.getDescription().getOrder()).compareTo(o2.getDescription().getOrder()); } }); return Collections.unmodifiableList(startupDeployments); }
/** * @param targetsContainer * @return */ private TargetDescription generateTarget(TargetsContainer targetsContainer) { if (targetsContainer != null) { return new TargetDescription(targetsContainer.value()); } return TargetDescription.DEFAULT; }
private void throwNoMatchFound(ContainerRegistry conReg, TargetDescription target) { throw new ValidationException("DeploymentScenario contains a target (" + target.getName() + ") not matching any defined Container in the registry.\n" + "Possible causes are: None of the " + conReg.getContainers().size() + " Containers are marked as default or you have defined a " + "@" + org.jboss.arquillian.container.test.api.Deployment.class.getSimpleName() + " with a @" + TargetsContainer.class.getSimpleName() + " of value (" + target.getName() + ") that " + "does not match any found/configured Containers (" + toString(conReg) + "), see arquillian.xml container@qualifier"); }
/** * Validate that a deployment with a archive of the same name does not have the same taget */ private void validateNotSameArchiveAndSameTarget(DeploymentDescription deployment) { if (!deployment.isArchiveDeployment()) { return; } for (Deployment existing : archiveDeployments(deployments)) { if (existing.getDescription().getArchive().getName().equals(deployment.getArchive().getName())) { if (existing.getDescription().getTarget().equals(deployment.getTarget())) { throw new IllegalArgumentException("Can not add multiple " + Archive.class.getName() + " archive deployments with the same archive name " + deployment.getName() + " that target the same target " + deployment.getTarget()); } } } } }
/** * @param targetsContainer * @return */ private TargetDescription generateTarget(TargetsContainer targetsContainer) { if (targetsContainer != null) { return new TargetDescription(targetsContainer.value()); } return TargetDescription.DEFAULT; }
private void throwNoMatchFound(ContainerRegistry conReg, TargetDescription target) { throw new ValidationException("DeploymentScenario contains a target (" + target.getName() + ") not matching any defined Container in the registry.\n" + "Possible causes are: None of the " + conReg.getContainers().size() + " Containers are marked as default or you have defined a " + "@" + org.jboss.arquillian.container.test.api.Deployment.class.getSimpleName() + " with a @" + TargetsContainer.class.getSimpleName() + " of value (" + target.getName() + ") that " + "does not match any found/configured Containers (" + toString(conReg) + "), see arquillian.xml container@qualifier"); }
/** * Validate that a deployment with a archive of the same name does not have the same taget */ private void validateNotSameArchiveAndSameTarget(DeploymentDescription deployment) { if (!deployment.isArchiveDeployment()) { return; } for (Deployment existing : archiveDeployments(deployments)) { if (existing.getDescription().getArchive().getName().equals(deployment.getArchive().getName())) { if (existing.getDescription().getTarget().equals(deployment.getTarget())) { throw new IllegalArgumentException("Can not add multiple " + Archive.class.getName() + " archive deployments with the same archive name " + deployment.getName() + " that target the same target " + deployment.getTarget()); } } } } }
/** * @param deploymentMethod * @return */ private TargetDescription generateTarget(Method deploymentMethod) { if (deploymentMethod.isAnnotationPresent(TargetsContainer.class)) { return new TargetDescription(deploymentMethod.getAnnotation(TargetsContainer.class).value()); } return TargetDescription.DEFAULT; }
private String createFileName(DeploymentDescription deployment, Archive<?> archive) { // TODO: where do we get TestClass name from ? return deployment.getTarget().getName() + "_" + deployment.getName() + "_" + archive.getName(); }
@Override public boolean isStarted(String containerQualifier) { ContainerRegistry registry = containerRegistry.get(); if (registry == null) { throw new IllegalArgumentException("No container registry in context"); } if (!containerExists(registry.getContainers(), containerQualifier)) { throw new IllegalArgumentException("No container found in registry with name " + containerQualifier); } Container container = registry.getContainer(new TargetDescription(containerQualifier)); return container.getState() == Container.State.STARTED; }
private String createFileName(DeploymentDescription deployment, Archive<?> archive) { // TODO: where do we get TestClass name from ? return deployment.getTarget().getName() + "_" + deployment.getName() + "_" + archive.getName(); }
@Override public boolean isStarted(String containerQualifier) { ContainerRegistry registry = containerRegistry.get(); if (registry == null) { throw new IllegalArgumentException("No container registry in context"); } if (!containerExists(registry.getContainers(), containerQualifier)) { throw new IllegalArgumentException("No container found in registry with name " + containerQualifier); } Container container = registry.getContainer(new TargetDescription(containerQualifier)); return container.getState() == Container.State.STARTED; }
public void observeBeforeDeploy(@Observes BeforeDeploy event) { DeploymentReport deploymentReport = new DeploymentReport(); DeploymentDescription description = event.getDeployment(); deploymentReport.setArchiveName(description.getArchive().getName()); deploymentReport.setName(description.getName()); int order = description.getOrder(); if (order > 0) { deploymentReport.setOrder(order); } String protocol = description.getProtocol().getName(); if (!protocol.equals("_DEFAULT_")) { deploymentReport.setProtocol(protocol); } else { deploymentReport.setProtocol("_DEFAULT_"); } deploymentReport.setTarget(description.getTarget().getName()); boolean reported = false; for (ContainerReport containerReport : reporter.get().getLastTestSuiteReport().getContainerReports()) { if (containerReport.getQualifier().equals(deploymentReport.getTarget())) { containerReport.getDeploymentReports().add(deploymentReport); reported = true; break; } } if (!reported) { if (reporter.get().getLastTestSuiteReport().getContainerReports().size() == 1) { reporter.get().getLastTestSuiteReport().getContainerReports().get(0).getDeploymentReports().add(deploymentReport); } } }