/** * Test deployment when the container configuration does not exist (see CARGO-1131). */ public void testDeployWhenContainerConfigurationDoesNotExist() { try { new TestableCopyingDeployer(createContainer( createContainerCapability(DeployableType.WAR), "non-existing")); fail("Should have thrown a CargoException here"); } catch (CargoException expected) { assertTrue("Incorrect message: " + expected.getMessage(), expected.getMessage().contains("ram:///non-existing")); } }
/** * Test deployment when the container does not support a given deployable type. */ public void testDeployWhenContainerDoesNotSupportDeployableType() { AbstractCopyingInstalledLocalDeployer deployer = new TestableCopyingDeployer( createContainer(createContainerCapability(DeployableType.EAR), null)); try { deployer.deploy(new WAR("dummy")); fail("Should have thrown a ContainerException here"); } catch (ContainerException expected) { assertEquals("WAR archives are not supported for deployment in [mycontainer]. " + "Got [dummy]", expected.getMessage()); } }
/** * Test deployment of an expanded WAR in a custom context. * @throws Exception If anything goes wrong. */ public void testDeployToNonExistingDirectory() throws Exception { WAR war = new WAR("ram:///some/warfile.war"); this.fsManager.resolveFile(war.getFile()).createFile(); AbstractCopyingInstalledLocalDeployer deployer = new TestableCopyingDeployerWithDifferentDirectory( createContainer(createContainerCapability(DeployableType.WAR), null)); try { deployer.deploy(war); fail("Should have thrown a CargoException here"); } catch (CargoException expected) { assertTrue("Incorrect message: " + expected.getMessage(), expected.getMessage().contains("ram:///webapps-nonexisting")); } }
/** * Test whether two WARs can be deployed to the same context. * @throws Exception If anything goes wrong. */ public void testCanBeDeployedWhenTwoWARsInSameWebContext() throws Exception { AbstractCopyingInstalledLocalDeployer deployer = new TestableCopyingDeployer( createContainer(createContainerCapability(DeployableType.WAR), null)); // Create WARs and make sure the wrapped files exist WAR war1 = new WAR("ram:///path1/warfile.war"); this.fsManager.resolveFile(war1.getFile()).createFile(); WAR war2 = new WAR("ram:///path2/warfile.war"); this.fsManager.resolveFile(war2.getFile()).createFile(); // Deploy the first WAR deployer.deploy(war1); assertTrue(this.fsManager.resolveFile("ram:///webapps/warfile.war").exists()); try { // Deploy the second WAR using the same context as the already deployed WAR deployer.deploy(war2); fail("Expected ContainerException because we deployed two WARs with the same context " + "name."); } catch (ContainerException expected) { assertEquals("Failed to deploy [ram:///path2/warfile.war] to [ram:///webapps]. The " + "required web context is already in use by another application.", expected.getMessage()); } }