public void testScheduleRefreshHandlerAllModules() throws Exception {
    // Tests both the CloudFoundryServerBehaviour refresh handler as well as
    // the test harness refresh listener
    String prefix = "testScheduleRefreshHandlerAllModules";
    createWebApplicationProject();

    CloudFoundryApplicationModule appModule = deployAndWaitForDeploymentEvent(prefix);

    // Test the server-wide refresh of all modules without specifying a
    // selected module.
    ModulesRefreshListener refreshListener =
        ModulesRefreshListener.getListener(
            null, cloudServer, CloudServerEvent.EVENT_SERVER_REFRESHED);
    cloudServer.getBehaviour().getRefreshHandler().scheduleRefreshAll();

    assertModuleRefreshedAndDispose(refreshListener, CloudServerEvent.EVENT_SERVER_REFRESHED);

    refreshListener =
        ModulesRefreshListener.getListener(
            null, cloudServer, CloudServerEvent.EVENT_SERVER_REFRESHED);

    cloudServer.getBehaviour().getRefreshHandler().scheduleRefreshAll(null);

    assertModuleRefreshedAndDispose(refreshListener, CloudServerEvent.EVENT_SERVER_REFRESHED);

    refreshListener =
        ModulesRefreshListener.getListener(
            null, cloudServer, CloudServerEvent.EVENT_SERVER_REFRESHED);

    cloudServer.getBehaviour().getRefreshHandler().scheduleRefreshAll(appModule.getLocalModule());

    assertModuleRefreshedAndDispose(refreshListener, CloudServerEvent.EVENT_SERVER_REFRESHED);
  }
  public void testFireEventAppChanged() throws Exception {
    // Tests the general event handler

    String prefix = "testFireEventAppChanged";
    createWebApplicationProject();

    String expectedAppName = harness.getDefaultWebAppName(prefix);

    deployAndWaitForDeploymentEvent(prefix);

    final IModule module = cloudServer.getExistingCloudModule(expectedAppName).getLocalModule();

    ModulesRefreshListener refreshListener =
        ModulesRefreshListener.getListener(
            expectedAppName, cloudServer, CloudServerEvent.EVENT_APPLICATION_REFRESHED);

    IRunnableWithProgress runnable =
        new IRunnableWithProgress() {

          @Override
          public void run(IProgressMonitor monitor)
              throws InvocationTargetException, InterruptedException {
            ServerEventHandler.getDefault().fireApplicationRefreshed(cloudServer, module);
          }
        };

    asynchExecuteOperation(runnable);

    assertModuleRefreshedAndDispose(refreshListener, CloudServerEvent.EVENT_APPLICATION_REFRESHED);
  }
  public void testScheduleRefreshHandlerAllModuleInstances() throws Exception {

    String prefix = "testScheduleRefreshHandlerAllModuleInstances";
    createWebApplicationProject();

    CloudFoundryApplicationModule appModule = deployAndWaitForDeploymentEvent(prefix);

    // Test the server-wide refresh of all modules including refreshing
    // instances of a selected module
    ModulesRefreshListener refreshListener =
        ModulesRefreshListener.getListener(
            null, cloudServer, CloudServerEvent.EVENT_SERVER_REFRESHED);

    cloudServer.getBehaviour().getRefreshHandler().scheduleRefreshAll(appModule.getLocalModule());

    assertModuleRefreshedAndDispose(refreshListener, CloudServerEvent.EVENT_SERVER_REFRESHED);
  }
  public void testScheduleRefreshHandlerRefreshApplication() throws Exception {
    // Tests both the CloudFoundryServerBehaviour refresh handler as well as
    // the test harness refresh listener
    String prefix = "testScheduleRefreshHandlerRefreshApplication";
    createWebApplicationProject();

    CloudFoundryApplicationModule appModule = deployAndWaitForDeploymentEvent(prefix);

    // Test the server-wide refresh of all modules therefore do not pass the
    // app name
    ModulesRefreshListener refreshListener =
        ModulesRefreshListener.getListener(
            appModule.getDeployedApplicationName(),
            cloudServer,
            CloudServerEvent.EVENT_APPLICATION_REFRESHED);

    cloudServer
        .getBehaviour()
        .getRefreshHandler()
        .schedulesRefreshApplication(appModule.getLocalModule());

    assertModuleRefreshedAndDispose(refreshListener, CloudServerEvent.EVENT_APPLICATION_REFRESHED);
  }