@Test
 public void testMetadata() {
   try {
     IServer s = ServerCreationTestUtils.createMockServerWithRuntime(serverType, serverType);
     IServerWorkingCopy wc = s.createWorkingCopy();
     wc.setAttribute(IDeployableServer.DEPLOY_DIRECTORY_TYPE, IDeployableServer.DEPLOY_METADATA);
     s = wc.save(true, null);
     String[] folders = getAdditions().getDeployLocationFolders(s);
     assertEquals(1, folders.length);
     assertTrue(folders[0].contains("metadata"));
   } catch (CoreException ce) {
     fail("Unable to save changes to server");
   }
 }
  @Test
  public void testMetadataWithCustomModule() {
    try {
      // Create the server
      IServer s = ServerCreationTestUtils.createMockServerWithRuntime(serverType, serverType);
      IServerWorkingCopy wc = s.createWorkingCopy();
      wc.setAttribute(IDeployableServer.DEPLOY_DIRECTORY_TYPE, IDeployableServer.DEPLOY_METADATA);
      s = wc.save(true, null);

      // Create the project
      projNum++;
      String projName = "Project" + projNum;
      IDataModel dm =
          CreateProjectOperationsUtility.getWebDataModel(
              projName, null, null, null, null, JavaEEFacetConstants.WEB_24, false);
      try {
        OperationTestCase.runAndVerify(dm);
      } catch (Exception e) {
        fail("Unable to create test web project: " + e.getMessage());
      }
      IProject p = ResourceUtils.findProject(projName);
      assertTrue(p.exists());
      IModule projMod = ServerUtil.getModule(p);

      // Set the custom setting. For now, just override output name
      wc = s.createWorkingCopy();
      AbstractPublishingTest.setCustomDeployOverride(wc, projMod, "newName.war", null, null);
      s = wc.save(true, null);

      // verify no change vs standard metadata
      String[] folders = getAdditions().getDeployLocationFolders(s);
      assertEquals(1, folders.length);
      assertTrue(folders[0].contains("metadata"));

      // Change it to now make some other output folder
      wc = s.createWorkingCopy();
      AbstractPublishingTest.setCustomDeployOverride(
          wc, projMod, "newName.war", "/home/user/deploy", null);
      s = wc.save(true, null);
      folders = getAdditions().getDeployLocationFolders(s);
      assertEquals(2, folders.length);
      assertTrue(folders[0].contains("metadata"));
      assertTrue(folders[1].equals("/home/user/deploy"));

    } catch (CoreException ce) {
      fail("Unable to save changes to server");
    }
  }
  @Test
  public void testRemoteGetsNoAdditionsInvalidMode() {
    // This test ensures that 'remote' servers are not handled by the standard listeners
    IServer s = ServerCreationTestUtils.createMockServerWithRuntime(serverType, serverType);
    try {
      IServerWorkingCopy wc = s.createWorkingCopy();
      wc.setAttribute(IDeployableServer.SERVER_MODE, "mock5unknown");
      s = wc.save(true, null);
    } catch (CoreException ce) {
      fail("Could not set server mode to non-local");
    }
    boolean accepts = new LocalJBoss7DeploymentScannerAdditions().accepts(s);
    assertFalse(accepts);
    accepts = new JMXServerDeploymentScannerAdditions().accepts(s);
    assertFalse(accepts);

    Job j1 = new LocalJBoss7DeploymentScannerAdditions().getUpdateDeploymentScannerJob(s);
    assertNull(j1);
    Job j2 = new JMXServerDeploymentScannerAdditions().getUpdateDeploymentScannerJob(s);
    assertNull(j2);
  }
  @Test
  public void testNoAdditionsRemovalsFromSettings() {
    // This test ensures that 'remote' servers are not handled by the standard listeners
    IServer s = ServerCreationTestUtils.createMockServerWithRuntime(serverType, serverType);
    try {
      IServerWorkingCopy wc = s.createWorkingCopy();
      wc.setAttribute(IJBossToolingConstants.PROPERTY_ADD_DEPLOYMENT_SCANNERS, false);
      wc.setAttribute(IJBossToolingConstants.PROPERTY_REMOVE_DEPLOYMENT_SCANNERS, false);
      s = wc.save(true, null);
    } catch (CoreException ce) {
      fail("Could not set server mode to non-local");
    }

    // Accepts will also check if the proper server type is here
    ServerExtendedProperties props =
        (ServerExtendedProperties) s.loadAdapter(ServerExtendedProperties.class, null);
    boolean usesManagement =
        props != null
            && props.getMultipleDeployFolderSupport()
                == ServerExtendedProperties.DEPLOYMENT_SCANNER_AS7_MANAGEMENT_SUPPORT;
    boolean usesJMX =
        props != null
            && props.getMultipleDeployFolderSupport()
                == ServerExtendedProperties.DEPLOYMENT_SCANNER_JMX_SUPPORT;

    boolean accepts = new LocalJBoss7DeploymentScannerAdditions().accepts(s);
    assertEquals(accepts, usesManagement);
    accepts = new JMXServerDeploymentScannerAdditions().accepts(s);
    assertEquals(accepts, usesJMX);

    Job j1 = new LocalJBoss7DeploymentScannerAdditions().getUpdateDeploymentScannerJob(s);
    assertNull(j1);
    Job j2 = new JMXServerDeploymentScannerAdditions().getUpdateDeploymentScannerJob(s);
    assertNull(j2);
    Job j3 = new LocalJBoss7DeploymentScannerAdditions().getRemoveDeploymentScannerJob(s);
    assertNull(j3);
    Job j4 = new JMXServerDeploymentScannerAdditions().getRemoveDeploymentScannerJob(s);
    assertNull(j4);
  }
 @After
 public void tearDown() throws Exception {
   ServerCreationTestUtils.deleteAllServersAndRuntimes();
 }