ManagementRedeployer { public void run(final String persistencePath, final String cloudifyHomePath) throws IOException { if (persistencePath == null) { return; } final File persistenceDir = new File(persistencePath); if (persistenceDir.exists() && !persistenceDir.isDirectory()) { throw new IllegalStateException("The persistence location: " + persistencePath + " should either not exist or be a directory"); } if (!persistenceDir.exists()) { return; } final File deployDir = new File(persistenceDir, CloudifyConstants.PERSISTENCE_DIRECTORY_DEPLOY_RELATIVE_PATH); if (!deployDir.exists()) { return; } final File restDir = findServiceDeployDir(deployDir, CloudifyConstants.MANAGEMENT_REST_SERVICE_NAME); final File webuiDir = findServiceDeployDir(deployDir, CloudifyConstants.MANAGEMENT_WEBUI_SERVICE_NAME); if (!restDir.exists() && !webuiDir.exists()) { return; } if (restDir.exists() ^ webuiDir.exists()) { logger.warning("Found only one of the management service deployed: REST: " + restDir.exists() + ", Web-UI: " + webuiDir.exists() + ". " + "This is not a normal deployment scenario. Please check for configuration problems. " + "Only the deployed service will be installed"); } if (restDir.exists()) { logger.info("Updating REST service deployment"); final File restFile = findRestDeploymentFile(cloudifyHomePath); switchDeploymentContent(restDir, restFile); restRedeployed = true; } if (webuiDir.exists()) { logger.info("Updating Web-UI service deployment"); final File webuiFile = findWebuiDeploymentFile(cloudifyHomePath); switchDeploymentContent(webuiDir, webuiFile); webuiRedeployed = true; } }  void run(final String persistencePath, final String cloudifyHomePath); boolean isRestRedeployed(); boolean isWebuiRedeployed();  }
@Test public void testRun() throws Exception { final File restIndex2 = new File(persistenceMockDir + "/deploy/" + CloudifyConstants.MANAGEMENT_REST_SERVICE_NAME + "/index2.html"); final File webuiIndex2 = new File(persistenceMockDir + "/deploy/" + CloudifyConstants.MANAGEMENT_WEBUI_SERVICE_NAME + "/index2.html"); Assert.assertTrue(!restIndex2.exists()); Assert.assertTrue(!webuiIndex2.exists()); ManagementRedeployer fixture = new ManagementRedeployer(); fixture.run(this.persistenceMockDir.getAbsolutePath(), this.cloudifyHomeMockDir.getAbsolutePath()); Assert.assertTrue(restIndex2.exists()); Assert.assertTrue(webuiIndex2.exists()); Assert.assertTrue(fixture.isRestRedeployed()); Assert.assertTrue(fixture.isWebuiRedeployed()); }