@Override public Void call() throws Exception { delegate.deploy(descriptor); return null; } });
@SuppressWarnings("unchecked") @Override public ProtocolMetaData call() throws Exception { return delegate.deploy(archive); } });
@SuppressWarnings("unchecked") @Override public ProtocolMetaData call() throws Exception { return delegate.deploy(archive); } });
@Override public Void call() throws Exception { delegate.deploy(descriptor); return null; } });
public boolean deploy(InputStream archive, String name) throws IOException { exception = null; if (name.endsWith("ear")) { swArchive = ShrinkWrap.create(EnterpriseArchive.class, name); } else if (name.endsWith("war")) { swArchive = ShrinkWrap.create(WebArchive.class, name); } else if (name.endsWith("jar")) { swArchive = ShrinkWrap.create(JavaArchive.class, name); } else { throw new RuntimeException("Unkown archive extension: " + name); } swArchive.as(ZipImporter.class).importFrom(archive); try { deployableContainer.deploy(this.swArchive); return true; } catch (org.jboss.arquillian.container.spi.client.container.DeploymentException e) { exception = e; return false; } }
@Override public void reloadContext() throws DeploymentException { Archive<?> archive = mssContainer.getArchive(); deployableContainer.undeploy(archive); deployableContainer.deploy(archive); }
public void deployPortal(@Observes AfterStart afterStartEvent) throws DeploymentException { Collection<PortletContainerDeploymentProvider> providers = loader.get().all(PortletContainerDeploymentProvider.class); for (PortletContainerDeploymentProvider provider : providers) { Archive<?> tmp = provider.build(); deployments.add(tmp); afterStartEvent.getDeployableContainer().deploy(tmp); tmp = null; } }
public void deployPortal(@Observes AfterStart afterStartEvent) throws DeploymentException { Collection<PortletContainerDeploymentProvider> providers = loader.get().all(PortletContainerDeploymentProvider.class); for (PortletContainerDeploymentProvider provider : providers) { Archive<?> tmp = provider.build(); deployments.add(tmp); afterStartEvent.getDeployableContainer().deploy(tmp); tmp = null; } }
public synchronized void doServiceDeploy(@Observes(precedence = 1) BeforeDeploy event, Container container, ServiceArchiveHolder archiveHolder) { // already deployed? if (serviceArchiveDeployed.contains(container.getName())) { archiveHolder.deploymentExistsAndRemove(event.getDeployment().getName()); // cleanup return; } // only deploy the service if the deployment has been enriched by the jmx-as7 protocol if (archiveHolder.deploymentExistsAndRemove(event.getDeployment().getName())) { JavaArchive serviceArchive = (JavaArchive) archiveHolder.getArchive(); try { log.infof("Deploy arquillian service: %s", serviceArchive); final Map<String, String> props = container.getContainerConfiguration().getContainerProperties(); //MASSIVE HACK //write the management connection props to the archive, so we can access them from the server final ByteArrayOutputStream bytes = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(bytes); out.writeObject(props.get("managementPort")); out.writeObject(NetworkUtils.formatPossibleIpv6Address(props.get("managementAddress"))); out.writeObject(NetworkUtils.formatPossibleIpv6Address(props.get("managementProtocol"))); out.writeObject(props.get("authenticationConfig")); out.close(); serviceArchive.addAsManifestResource(new ByteArrayAsset(bytes.toByteArray()), "org.jboss.as.managementConnectionProps"); DeployableContainer<?> deployableContainer = container.getDeployableContainer(); deployableContainer.deploy(serviceArchive); serviceArchiveDeployed.add(container.getName()); } catch (Throwable th) { log.error("Cannot deploy arquillian service", th); } } }
public synchronized void doServiceDeploy(@Observes(precedence = 1) BeforeDeploy event, Container container, ServiceArchiveHolder archiveHolder) { // already deployed? if (serviceArchiveDeployed.contains(container.getName())) { archiveHolder.deploymentExistsAndRemove(event.getDeployment().getName()); // cleanup return; } // only deploy the service if the deployment has been enriched by the jmx-as7 protocol if (archiveHolder.deploymentExistsAndRemove(event.getDeployment().getName())) { JavaArchive serviceArchive = (JavaArchive) archiveHolder.getArchive(); try { log.infof("Deploy arquillian service: %s", serviceArchive); final Map<String, String> props = container.getContainerConfiguration().getContainerProperties(); //MASSIVE HACK //write the management connection props to the archive, so we can access them from the server final ByteArrayOutputStream bytes = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(bytes); out.writeObject(props.get("managementPort")); out.writeObject(NetworkUtils.formatPossibleIpv6Address(props.get("managementAddress"))); out.writeObject(NetworkUtils.formatPossibleIpv6Address(props.get("managementProtocol"))); out.writeObject(props.get("authenticationConfig")); out.close(); serviceArchive.addAsManifestResource(new ByteArrayAsset(bytes.toByteArray()), "org.jboss.as.managementConnectionProps"); DeployableContainer<?> deployableContainer = container.getDeployableContainer(); deployableContainer.deploy(serviceArchive); serviceArchiveDeployed.add(container.getName()); } catch (Throwable th) { log.error("Cannot deploy arquillian service", th); } } }
public synchronized void doServiceDeploy(@Observes BeforeDeploy event, Container container, ServiceArchiveHolder archiveHolder) { // already deployed? if (serviceArchiveDeployed.contains(container.getName())) { archiveHolder.deploymentExistsAndRemove(event.getDeployment().getName()); // cleanup return; } // only deploy the service if the deployment has been enriched by the jmx-as7 protocol if (archiveHolder.deploymentExistsAndRemove(event.getDeployment().getName())) { JavaArchive serviceArchive = (JavaArchive) archiveHolder.getArchive(); try { log.infof("Deploy arquillian service: %s", serviceArchive); final Map<String, String> props = container.getContainerConfiguration().getContainerProperties(); //MASSIVE HACK //write the management connection props to the archive, so we can access them from the server final ByteArrayOutputStream bytes = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(bytes); out.writeObject(props.get("managementPort")); out.writeObject(NetworkUtils.formatPossibleIpv6Address(props.get("managementAddress"))); out.close(); serviceArchive.addAsManifestResource(new ByteArrayAsset(bytes.toByteArray()), "org.jboss.as.managementConnectionProps"); DeployableContainer<?> deployableContainer = container.getDeployableContainer(); deployableContainer.deploy(serviceArchive); serviceArchiveDeployed.add(container.getName()); } catch (Throwable th) { log.error("Cannot deploy arquillian service", th); } } }
@Test public void shouldDeployAllManagedDeployments() throws Exception { registry.create(container1, serviceLoader).setState(State.STARTED); registry.create(container2, serviceLoader).setState(State.STARTED); fire(new DeployManagedDeployments()); assertEventFired(DeployDeployment.class, 3); assertEventFiredInContext(DeployDeployment.class, ContainerContext.class); assertEventFiredInContext(DeployDeployment.class, DeploymentContext.class); assertEventFired(BeforeDeploy.class, 3); assertEventFiredInContext(BeforeDeploy.class, ContainerContext.class); assertEventFiredInContext(BeforeDeploy.class, DeploymentContext.class); assertEventFired(AfterDeploy.class, 3); assertEventFiredInContext(AfterDeploy.class, ContainerContext.class); assertEventFiredInContext(AfterDeploy.class, DeploymentContext.class); verify(deployableContainer1, times(1)).deploy(isA(Archive.class)); verify(deployableContainer1, times(1)).deploy(isA(Descriptor.class)); verify(deployableContainer2, times(1)).deploy(isA(Archive.class)); InOrder ordered = inOrder(deployableContainer1, deployableContainer2); ordered.verify(deployableContainer2, times(1)).deploy( scenario.deployment(new DeploymentTargetDescription(DEPLOYMENT_2_NAME)) .getDescription() .getTestableArchive()); ordered.verify(deployableContainer1, times(1)).deploy( scenario.deployment(new DeploymentTargetDescription(DEPLOYMENT_1_NAME)).getDescription().getArchive()); ordered.verify(deployableContainer1, times(1)).deploy( scenario.deployment(new DeploymentTargetDescription(DEPLOYMENT_4_NAME)).getDescription().getDescriptor()); }
@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; } });
@Before public void setup() throws Exception { when(deployableContainer1.deploy(isA(Archive.class))).thenReturn(protocolMetaData); when(deployableContainer1.getConfigurationClass()).thenReturn(DummyContainerConfiguration.class); when(deployableContainer2.deploy(isA(Archive.class))).thenReturn(protocolMetaData); when(deployableContainer2.getConfigurationClass()).thenReturn(DummyContainerConfiguration.class); when(serviceLoader.onlyOne(eq(DeployableContainer.class))).thenReturn(deployableContainer1, deployableContainer2);
@Test public void shouldCatchExceptionInDeploymentContext() throws Exception { registry.create(container1, serviceLoader).setState(State.STARTED); registry.create(container2, serviceLoader).setState(State.STARTED); when(deployableContainer1.deploy(isA(Archive.class))).thenThrow(new DeploymentException("_TEST_")); try { fire(new DeployManagedDeployments()); } catch (Exception e) { if (!(e instanceof DeploymentException)) { throw e; } } assertEventFired(DeploymentException.class, 1); assertEventFiredInContext(DeploymentException.class, ContainerContext.class); assertEventFiredInContext(DeploymentException.class, DeploymentContext.class); assertEventFiredTyped(Throwable.class, 1); }