ArtifactDeployer { public void deploy() throws Exception { List<SimpleKey> subkeys = configView.simpleSubkeys(ConfigKey.of("thorntail", "deployment")); for (SimpleKey subkey : subkeys) { String spec = subkey.name(); if (!spec.contains(":")) { continue; } String[] parts = spec.split(":"); String groupId = parts[0]; int p = parts[1].lastIndexOf('.'); String artifactId; String packaging; if (p == -1) { artifactId = parts[1]; packaging = "jar"; } else { artifactId = parts[1].substring(0, p); packaging = parts[1].substring(p + 1); } JavaArchive artifact = Swarm.artifact(groupId + ":" + artifactId + ":" + packaging + ":*", artifactId + "." + packaging); deployer.get().deploy(artifact, spec); } }  void deploy();  }
@Test public void testDeploy() throws Exception { System.setProperty("thorntail.deployment.[com.foo:app.war]", ""); ArtifactDeployer artifactDeployer = new ArtifactDeployer(); artifactDeployer.configView = new ConfigViewImpl(); JavaArchive archive = stubArtifactLookup("com.foo:app:war:*", "app.war"); RuntimeDeployer runtimeDeployer = stubRuntimeDeployer(artifactDeployer); artifactDeployer.deploy(); verify(runtimeDeployer).deploy(archive, "com.foo:app.war"); }
@Test public void testDeployBackwardCompatibility() throws Exception { System.setProperty("swarm.deployment.[com.foo:app.war]", ""); ArtifactDeployer artifactDeployer = new ArtifactDeployer(); artifactDeployer.configView = new ConfigViewImpl(); JavaArchive archive = stubArtifactLookup("com.foo:app:war:*", "app.war"); RuntimeDeployer runtimeDeployer = stubRuntimeDeployer(artifactDeployer); artifactDeployer.deploy(); verify(runtimeDeployer).deploy(archive, "com.foo:app.war"); }
@Test public void testDeploy_artifactIdWithDot() throws Exception { System.setProperty("thorntail.deployment.[com.ibm:wsmq.jmsra.rar]", ""); ArtifactDeployer artifactDeployer = new ArtifactDeployer(); artifactDeployer.configView = new ConfigViewImpl(); JavaArchive archive = stubArtifactLookup("com.ibm:wsmq.jmsra:rar:*", "wsmq.jmsra.rar"); RuntimeDeployer runtimeDeployer = stubRuntimeDeployer(artifactDeployer); artifactDeployer.deploy(); verify(runtimeDeployer).deploy(archive, "com.ibm:wsmq.jmsra.rar"); }
@Test public void testDeploy_artifactIdWithDotBackwardCompatibility() throws Exception { System.setProperty("swarm.deployment.[com.ibm:wsmq.jmsra.rar]", ""); ArtifactDeployer artifactDeployer = new ArtifactDeployer(); artifactDeployer.configView = new ConfigViewImpl(); JavaArchive archive = stubArtifactLookup("com.ibm:wsmq.jmsra:rar:*", "wsmq.jmsra.rar"); RuntimeDeployer runtimeDeployer = stubRuntimeDeployer(artifactDeployer); artifactDeployer.deploy(); verify(runtimeDeployer).deploy(archive, "com.ibm:wsmq.jmsra.rar"); }
@Test public void testDeploy_artifactIdWithNoExtension() throws Exception { System.setProperty("thorntail.deployment.[com.foo:artifact]", ""); ArtifactDeployer artifactDeployer = new ArtifactDeployer(); artifactDeployer.configView = new ConfigViewImpl(); JavaArchive archive = stubArtifactLookup("com.foo:artifact:jar:*", "artifact.jar"); RuntimeDeployer runtimeDeployer = stubRuntimeDeployer(artifactDeployer); artifactDeployer.deploy(); verify(runtimeDeployer).deploy(archive, "com.foo:artifact"); }
@Test public void testDeploy_artifactIdWithNoExtensionBackwardCompatible() throws Exception { System.setProperty("swarm.deployment.[com.foo:artifact]", ""); ArtifactDeployer artifactDeployer = new ArtifactDeployer(); artifactDeployer.configView = new ConfigViewImpl(); JavaArchive archive = stubArtifactLookup("com.foo:artifact:jar:*", "artifact.jar"); RuntimeDeployer runtimeDeployer = stubRuntimeDeployer(artifactDeployer); artifactDeployer.deploy(); verify(runtimeDeployer).deploy(archive, "com.foo:artifact"); }