private void testStartStop2(final String filename) throws Exception { FileDeploymentManager fdm = new FileDeploymentManager(Long.MAX_VALUE); FileDeploymentManagerTest.log.debug("Filename is " + filename); File file = new File("target/test-classes/"); file.mkdirs(); file = new File("target/test-classes/" + filename); FileDeploymentManagerTest.log.debug(file.getAbsoluteFile()); file.createNewFile(); FakeDeployer deployer = new FakeDeployer(filename); fdm.start(); try { fdm.registerDeployer(deployer); URI expected = file.toURI(); URI deployedUrl = deployer.deployedUri; Assert.assertTrue(expected.toString().equalsIgnoreCase(deployedUrl.toString())); deployer.deployedUri = null; fdm.start(); Assert.assertNull(deployer.deployedUri); fdm.stop(); } finally { file.delete(); fdm.stop(); } }
public void testUndeployAndDeployAgain() throws Exception { FileDeploymentManager fdm = new FileDeploymentManager(Long.MAX_VALUE); fdm.start(); String filename = "fdm_test_file.xml1"; File file = new File("target/test-classes/"); file.mkdirs(); file = new File("target/test-classes/" + filename); file.createNewFile(); FakeDeployer deployer = new FakeDeployer(filename); try { URI uri = file.toURI(); deployer.deploy(uri); fdm.registerDeployer(deployer); Assert.assertEquals(1, fdm.getDeployers().size()); Assert.assertTrue(fdm.getDeployers().contains(deployer)); Assert.assertEquals(1, fdm.getDeployed().size()); Assert.assertEquals(file.toURI(), deployer.deployedUri); deployer.deployedUri = null; file.delete(); // This should cause undeployment deployer.undeploy(uri); Assert.assertEquals(file.toURI(), deployer.unDeployedUri); fdm.run(); Assert.assertEquals(1, fdm.getDeployers().size()); Assert.assertTrue(fdm.getDeployers().contains(deployer)); Assert.assertEquals(0, fdm.getDeployed().size()); // Recreate file and it should be redeployed file.createNewFile(); deployer.deploy(uri); fdm.run(); Assert.assertEquals(1, fdm.getDeployers().size()); Assert.assertTrue(fdm.getDeployers().contains(deployer)); Assert.assertEquals(1, fdm.getDeployed().size()); Assert.assertEquals(file.toURI(), deployer.deployedUri); } finally { file.delete(); fdm.stop(); } }