initialize.stopDerbyServer();
}
@Test
public void testAppDeployment () throws Exception {
ApplicationDeployment appDep = appcatalog.getApplicationDeployment();
ApplicationInterface appInt = appcatalog.getApplicationInterface();
ComputeResource computeRs = appcatalog.getComputeResource();
ComputeResourceDescription cm = new ComputeResourceDescription();
cm.setHostName("localhost");
cm.setResourceDescription("test compute host");
String hostId = computeRs.addComputeResource(cm);
ApplicationModule module = new ApplicationModule();
module.setAppModuleName("WRF");
module.setAppModuleVersion("1.0.0");
String wrfModuleId = appInt.addApplicationModule(module);
ApplicationDeploymentDescription description = new ApplicationDeploymentDescription();
description.setAppModuleId(wrfModuleId);
description.setComputeHostId(hostId);
description.setExecutablePath("/home/a/b/c");
description.setAppDeploymentDescription("test app deployment");
description.addToModuleLoadCmds("cmd1");
description.addToModuleLoadCmds("cmd2");
List<SetEnvPaths> libPrepandPaths = new ArrayList<SetEnvPaths>();
libPrepandPaths.add(createSetEnvPath("name1", "val1"));
libPrepandPaths.add(createSetEnvPath("name2", "val2"));
description.setLibPrependPaths(libPrepandPaths);
List<SetEnvPaths> libApendPaths = new ArrayList<SetEnvPaths>();
libApendPaths.add(createSetEnvPath("name3", "val3"));
libApendPaths.add(createSetEnvPath("name4", "val4"));
description.setLibAppendPaths(libApendPaths);
List<SetEnvPaths> appEvns = new ArrayList<SetEnvPaths>();
appEvns.add(createSetEnvPath("name5", "val5"));
appEvns.add(createSetEnvPath("name6", "val6"));
description.setSetEnvironment(appEvns);
String appDepId = appDep.addApplicationDeployment(description);
ApplicationDeploymentDescription app = null;
if (appDep.isAppDeploymentExists(appDepId)){
app = appDep.getApplicationDeployement(appDepId);
System.out.println("*********** application deployment desc ********* : " + app.getAppDeploymentDescription());
}
description.setAppDeploymentDescription("test app deployment2");
appDep.updateApplicationDeployment(appDepId, description);
if (appDep.isAppDeploymentExists(appDepId)){
app = appDep.getApplicationDeployement(appDepId);
System.out.println("*********** application deployment desc ********* : " + app.getAppDeploymentDescription());
}
Map<String, String> moduleIdFilter = new HashMap<String, String>();
moduleIdFilter.put(AbstractResource.ApplicationDeploymentConstants.APP_MODULE_ID, wrfModuleId);
List<ApplicationDeploymentDescription> applicationDeployements = appDep.getApplicationDeployements(moduleIdFilter);
System.out.println("******** Size of App deployments for module *********** : " + applicationDeployements.size());
Map<String, String> hostFilter = new HashMap<String, String>();
hostFilter.put(AbstractResource.ApplicationDeploymentConstants.COMPUTE_HOST_ID, hostId);
List<ApplicationDeploymentDescription> applicationDeployementsForHost = appDep.getApplicationDeployements(hostFilter);
System.out.println("******** Size of App deployments for host *********** : " + applicationDeployementsForHost.size());
List<String> allApplicationDeployementIds = appDep.getAllApplicationDeployementIds();
System.out.println("******** Size of all App deployments ids *********** : " + allApplicationDeployementIds.size());
List<ApplicationDeploymentDescription> allApplicationDeployements = appDep.getAllApplicationDeployements();
System.out.println("******** Size of all App deployments *********** : " + allApplicationDeployements.size());
assertTrue("App interface saved successfully", app != null);
}