public ProtocolDescription getProtocolDescription() { return deploymentDescription == null ? null : deploymentDescription.getProtocol(); }
public ProtocolDescription getProtocolDescription() { return deploymentDescription == null ? null : deploymentDescription.getProtocol(); }
public Set<ProtocolDescription> protocols() { Set<ProtocolDescription> protocols = new HashSet<ProtocolDescription>(); for (Deployment dep : deployments) { protocols.add(dep.getDescription().getProtocol()); } return protocols; }
public Set<ProtocolDescription> protocols() { Set<ProtocolDescription> protocols = new HashSet<ProtocolDescription>(); for (Deployment dep : deployments) { protocols.add(dep.getDescription().getProtocol()); } return protocols; }
@SuppressWarnings("unchecked") @Before public void setup() throws Exception { bind(ApplicationScoped.class, Container.class, container); bind(ApplicationScoped.class, DeploymentDescription.class, deploymentDescription); bind(ApplicationScoped.class, ProtocolMetaData.class, protocolMetaData); bind(ApplicationScoped.class, ProtocolRegistry.class, protocolRegistry); Mockito.when(deploymentDescription.getProtocol()).thenReturn(new ProtocolDescription("TEST")); Mockito.when(protocolRegistry.getProtocol(Mockito.any(ProtocolDescription.class))).thenReturn(protocolDefinition); Mockito.when(protocolDefinition.getProtocol()).thenReturn(protocol); Mockito.when(protocol.getExecutor( Mockito.any(ProtocolConfiguration.class), Mockito.any(ProtocolMetaData.class), Mockito.any(CommandCallback.class))).thenAnswer(new Answer<ContainerMethodExecutor>() { @Override public ContainerMethodExecutor answer(InvocationOnMock invocation) throws Throwable { return new TestContainerMethodExecutor((CommandCallback) invocation.getArguments()[2]); } }); Mockito.when(testExecutor.getInstance()).thenReturn(this); Mockito.when(testExecutor.getMethod()).thenReturn( getTestMethod("shouldReactivePreviousContextsOnRemoteEvents")); }
@SuppressWarnings("unchecked") @Before public void setup() throws Exception { bind(ApplicationScoped.class, Container.class, container); bind(ApplicationScoped.class, DeploymentDescription.class, deploymentDescription); bind(ApplicationScoped.class, ProtocolMetaData.class, protocolMetaData); bind(ApplicationScoped.class, ProtocolRegistry.class, protocolRegistry); Mockito.when(deploymentDescription.getProtocol()).thenReturn(new ProtocolDescription("TEST")); Mockito.when(protocolRegistry.getProtocol(Mockito.any(ProtocolDescription.class))).thenReturn(protocolDefinition); Mockito.when(protocolDefinition.getProtocol()).thenReturn(protocol); Mockito.when(protocol.getExecutor( Mockito.any(ProtocolConfiguration.class), Mockito.any(ProtocolMetaData.class), Mockito.any(CommandCallback.class))).thenAnswer(new Answer<ContainerMethodExecutor>() { @Override public ContainerMethodExecutor answer(InvocationOnMock invocation) throws Throwable { return new TestContainerMethodExecutor((CommandCallback) invocation.getArguments()[2]); } }); Mockito.when(testExecutor.getInstance()).thenReturn(this); Mockito.when(testExecutor.getMethod()).thenReturn( getTestMethod("shouldReactivePreviousContextsOnRemoteEvents")); }
@Override public List<DeploymentDescription> generate(TestClass testClass) { List<DeploymentDescription> deployments = super.generate(testClass); List<DeploymentDescription> updatedDeployments = new ArrayList<DeploymentDescription>(); for (DeploymentDescription currentDeploymentDescription : deployments) { if (currentDeploymentDescription.getArchive() instanceof PortletArchive) { DeploymentDescription newDescription = new DeploymentDescription(currentDeploymentDescription.getName(), currentDeploymentDescription.getArchive().as(WebArchive.class)); newDescription.shouldBeTestable(currentDeploymentDescription.testable()) .shouldBeManaged(currentDeploymentDescription.managed()) .setOrder(currentDeploymentDescription.getOrder()) .setTarget(currentDeploymentDescription.getTarget()) .setProtocol(currentDeploymentDescription.getProtocol()) .setExpectedException(currentDeploymentDescription.getExpectedException()); updatedDeployments.add(newDescription); } else { updatedDeployments.add(currentDeploymentDescription); } } return updatedDeployments; } }
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); } } }
ProtocolDefinition protocolDefinition = protoReg.getProtocol(description.getProtocol()); if (protocolDefinition == null) { protocolDefinition = protoReg.getProtocol(
ProtocolDefinition protocolDefinition = protoReg.getProtocol(description.getProtocol()); if (protocolDefinition == null) { protocolDefinition = protoReg.getProtocol(
public void execute(@Observes RemoteExecutionEvent event) throws Exception { Container container = this.container.get(); DeploymentDescription deployment = this.deployment.get(); ProtocolRegistry protoReg = protocolRegistry.get(); // if no default marked or specific protocol defined in the registry, use the DeployableContainers defaultProtocol. ProtocolDefinition protocol = protoReg.getProtocol(deployment.getProtocol()); if (protocol == null) { protocol = protoReg.getProtocol(container.getDeployableContainer().getDefaultProtocol()); } ProtocolConfiguration protocolConfiguration; if (container.hasProtocolConfiguration(protocol.getProtocolDescription())) { protocolConfiguration = protocol.createProtocolConfiguration( container.getProtocolConfiguration(protocol.getProtocolDescription()).getProtocolProperties()); } else { protocolConfiguration = protocol.createProtocolConfiguration(); } ContainerMethodExecutor executor = getContainerMethodExecutor(protocol, protocolConfiguration); testResult.set(executor.invoke(event.getExecutor())); }
public void execute(@Observes RemoteExecutionEvent event) throws Exception { Container container = this.container.get(); DeploymentDescription deployment = this.deployment.get(); ProtocolRegistry protoReg = protocolRegistry.get(); // if no default marked or specific protocol defined in the registry, use the DeployableContainers defaultProtocol. ProtocolDefinition protocol = protoReg.getProtocol(deployment.getProtocol()); if (protocol == null) { protocol = protoReg.getProtocol(container.getDeployableContainer().getDefaultProtocol()); } ProtocolConfiguration protocolConfiguration; if (container.hasProtocolConfiguration(protocol.getProtocolDescription())) { protocolConfiguration = protocol.createProtocolConfiguration( container.getProtocolConfiguration(protocol.getProtocolDescription()).getProtocolProperties()); } else { protocolConfiguration = protocol.createProtocolConfiguration(); } ContainerMethodExecutor executor = getContainerMethodExecutor(protocol, protocolConfiguration); testResult.set(executor.invoke(event.getExecutor())); }
@Test public void shouldHandleMultipleDeploymentsAllDefault() throws Exception { List<DeploymentDescription> scenario = generate(MultiDeploymentsDefault.class); Assert.assertNotNull(scenario); Assert.assertEquals( "Verify all deployments were found", 2, scenario.size()); for (DeploymentDescription deployment : scenario) { Assert.assertEquals( "Verify deployment has default target", TargetDescription.DEFAULT, deployment.getTarget()); Assert.assertEquals( "Verify deployment has default protocol", ProtocolDescription.DEFAULT, deployment.getProtocol()); Assert.assertEquals(-1, deployment.getOrder()); Assert.assertEquals(true, deployment.managed()); Assert.assertTrue(Validate.isArchiveOfType(JavaArchive.class, deployment.getArchive())); } }
@Test public void shouldHandleMultipleDeploymentsAllDefault() throws Exception { List<DeploymentDescription> scenario = generate(MultiDeploymentsDefault.class); Assert.assertNotNull(scenario); Assert.assertEquals( "Verify all deployments were found", 2, scenario.size()); for (DeploymentDescription deployment : scenario) { Assert.assertEquals( "Verify deployment has default target", TargetDescription.DEFAULT, deployment.getTarget()); Assert.assertEquals( "Verify deployment has default protocol", ProtocolDescription.DEFAULT, deployment.getProtocol()); Assert.assertEquals(-1, deployment.getOrder()); Assert.assertEquals(true, deployment.managed()); Assert.assertTrue(Validate.isArchiveOfType(JavaArchive.class, deployment.getArchive())); } }
"Verify deployment has specified protocol", new ProtocolDescription("protocol-first"), deploymentDesc.getProtocol()); "Verify deployment has specified protocol", new ProtocolDescription("protocol-second"), deploymentDesc.getProtocol());
"Verify deployment has specified protocol", new ProtocolDescription("protocol-first"), deploymentDesc.getProtocol()); "Verify deployment has specified protocol", new ProtocolDescription("protocol-second"), deploymentDesc.getProtocol());