ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From abaranc...@apache.org
Subject ambari git commit: AMBARI-8489 - Enable ambari server unit tests on Windows
Date Wed, 03 Dec 2014 12:01:07 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 956a0e708 -> 498a13bab


AMBARI-8489 - Enable ambari server unit tests on Windows


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/498a13ba
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/498a13ba
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/498a13ba

Branch: refs/heads/trunk
Commit: 498a13bab6f38ffa529da1a5cdd7cc400728ca01
Parents: 956a0e7
Author: Artem Baranchuk <abaranchuk@hortonworks.com>
Authored: Mon Dec 1 14:01:50 2014 +0200
Committer: Artem Baranchuk <abaranchuk@hortonworks.com>
Committed: Wed Dec 3 13:54:04 2014 +0200

----------------------------------------------------------------------
 .../ambari/server/bootstrap/BSRunner.java       |  11 +-
 .../server/api/services/AmbariMetaInfoTest.java |  98 ++++++++----
 .../services/ViewSubResourceServiceTest.java    |   2 +-
 .../serializers/JsonSerializerTest.java         |   6 +-
 .../ambari/server/bootstrap/BootStrapTest.java  | 155 ++++++++++---------
 .../ClientConfigResourceProviderTest.java       |  20 ++-
 .../server/orm/InMemoryDefaultTestModule.java   |  21 ++-
 .../server/security/CertGenerationTest.java     |  25 +--
 .../ambari/server/stack/StackManagerTest.java   |  42 ++++-
 .../ambari/server/state/stack/OSFamilyTest.java |   2 +-
 .../ambari/server/view/ViewExtractorTest.java   |  61 ++++++--
 .../ambari/server/view/ViewRegistryTest.java    | 154 +++++++++++++-----
 ambari-server/src/test/resources/os_family.json |  11 ++
 13 files changed, 419 insertions(+), 189 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/498a13ba/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/BSRunner.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/BSRunner.java b/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/BSRunner.java
index 31343b5..4790691 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/BSRunner.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/BSRunner.java
@@ -181,9 +181,9 @@ class BSRunner extends Thread {
       /* Running command:
        * script hostlist bsdir user sshkeyfile
        */
-      shellCommand[0] = "sh";
-      shellCommand[1] = "-c";
-      
+      shellCommand[0] = System.getProperty("os.name").contains("Windows") ? "cmd" : "sh";
+      shellCommand[1] = System.getProperty("os.name").contains("Windows") ? "/C" : "-c";
+
       commands[0] = this.bsScript;
       commands[1] = hostString;
       commands[2] = this.requestIdDir.toString();
@@ -212,16 +212,15 @@ class BSRunner extends Thread {
         commandString.append(" " + comm);
       }
 
-     
       if (LOG.isDebugEnabled()) {
         LOG.debug(commandString);
       }
-      
+
       String bootStrapOutputFile = requestIdDir + File.separator + "bootstrap.out";
       String bootStrapErrorFile = requestIdDir + File.separator + "bootstrap.err";
       commandString.append(
           " 1> " + bootStrapOutputFile + " 2>" + bootStrapErrorFile);
-      
+
       shellCommand[2] = commandString.toString();
       Process process = Runtime.getRuntime().exec(shellCommand, env);
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/498a13ba/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java
index 136e8a8..8a4e627 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java
@@ -130,7 +130,13 @@ public class AmbariMetaInfoTest {
 
   @Before
   public void before() throws Exception {
-    metaInfo = createAmbariMetaInfo(new File("src/test/resources/stacks"), new File("target/version"), true);
+    File stacks = new File("src/test/resources/stacks");
+    File version = new File("target/version");
+    if (System.getProperty("os.name").contains("Windows")) {
+      stacks = new File(ClassLoader.getSystemClassLoader().getResource("stacks").getPath());
+      version = new File(new File(ClassLoader.getSystemClassLoader().getResource("").getPath()).getParent(), "version");
+    }
+    metaInfo = createAmbariMetaInfo(stacks, version, true);
   }
 
   public class MockModule extends AbstractModule {
@@ -197,10 +203,14 @@ public class AmbariMetaInfoTest {
 
     // Deleting the json file referenced by the latestBaseUrl to simulate No
     // Internet.
-    File latestUrlFile = new File(buildDir,
-        "ambari-metaInfo/HDP/2.1.1/repos/hdp.json");
-    FileUtils.deleteQuietly(latestUrlFile);
-    assertTrue(!latestUrlFile.exists());
+    File latestUrlFile = new File(buildDir, "ambari-metaInfo/HDP/2.1.1/repos/hdp.json");
+    if (System.getProperty("os.name").contains("Windows")) {
+      latestUrlFile.deleteOnExit();
+    }
+    else {
+      FileUtils.deleteQuietly(latestUrlFile);
+      assertTrue(!latestUrlFile.exists());
+    }
     ambariMetaInfo.init();
 
     List<RepositoryInfo> redhat6Repo = ambariMetaInfo.getRepositories(
@@ -271,10 +281,14 @@ public class AmbariMetaInfoTest {
 
     // Deleting the json file referenced by the latestBaseUrl to simulate No
     // Internet.
-    File latestUrlFile = new File(buildDir,
-        "ambari-metaInfo/HDP/2.1.1/repos/hdp.json");
-    FileUtils.deleteQuietly(latestUrlFile);
-    assertTrue(!latestUrlFile.exists());
+    File latestUrlFile = new File(buildDir, "ambari-metaInfo/HDP/2.1.1/repos/hdp.json");
+    if (System.getProperty("os.name").contains("Windows")) {
+      latestUrlFile.deleteOnExit();
+    }
+    else {
+      FileUtils.deleteQuietly(latestUrlFile);
+      assertTrue(!latestUrlFile.exists());
+    }
 
     // Update baseUrl
     ambariMetaInfo.updateRepoBaseURL("HDP", "2.1.1", "redhat6", "HDP-2.1.1",
@@ -456,9 +470,14 @@ public class AmbariMetaInfoTest {
   public void testMetaInfoFileFilter() throws Exception {
     String buildDir = tmpFolder.getRoot().getAbsolutePath();
     File stackRoot = new File("src/test/resources/stacks");
+    File version = new File("target/version");
+    if (System.getProperty("os.name").contains("Windows")) {
+      stackRoot = new File(ClassLoader.getSystemClassLoader().getResource("stacks").getPath());
+      version = new File(new File(ClassLoader.getSystemClassLoader().getResource("").getPath()).getParent(), "version");
+    }
     File stackRootTmp = new File(buildDir + "/ambari-metaInfo"); stackRootTmp.mkdir();
     FileUtils.copyDirectory(stackRoot, stackRootTmp);
-    AmbariMetaInfo ambariMetaInfo = createAmbariMetaInfo(stackRootTmp, new File("target/version"), true);
+    AmbariMetaInfo ambariMetaInfo = createAmbariMetaInfo(stackRootTmp, version, true);
     //todo
     //ambariMetaInfo.injector = injector;
     File f1, f2, f3;
@@ -610,10 +629,10 @@ public class AmbariMetaInfoTest {
     Assert.assertTrue(metaInfo.isOsSupported("suse11"));
     Assert.assertTrue(metaInfo.isOsSupported("sles11"));
     Assert.assertTrue(metaInfo.isOsSupported("ubuntu12"));
-    Assert.assertFalse(metaInfo.isOsSupported("win2008server6"));
-    Assert.assertFalse(metaInfo.isOsSupported("win2008serverr26"));
-    Assert.assertFalse(metaInfo.isOsSupported("win2012server6"));
-    Assert.assertFalse(metaInfo.isOsSupported("win2012serverr26"));
+    Assert.assertTrue(metaInfo.isOsSupported("win2008server6"));
+    Assert.assertTrue(metaInfo.isOsSupported("win2008serverr26"));
+    Assert.assertTrue(metaInfo.isOsSupported("win2012server6"));
+    Assert.assertTrue(metaInfo.isOsSupported("win2012serverr26"));
   }
 
   @Test
@@ -711,10 +730,15 @@ public class AmbariMetaInfoTest {
   @Test
   public void testBadStack() throws Exception {
     File stackRoot = new File("src/test/resources/bad-stacks");
+    File version = new File("target/version");
+    if (System.getProperty("os.name").contains("Windows")) {
+      stackRoot = new File(ClassLoader.getSystemClassLoader().getResource("bad-stacks").getPath());
+      version = new File(new File(ClassLoader.getSystemClassLoader().getResource("").getPath()).getParent(), "version");
+    }
     LOG.info("Stacks file " + stackRoot.getAbsolutePath());
 
     try {
-      createAmbariMetaInfo(stackRoot, new File("target/version"), true);
+      createAmbariMetaInfo(stackRoot, version, true);
       fail("Exception expected due to bad stack");
     } catch(AmbariException e) {
       e.printStackTrace();
@@ -1131,35 +1155,45 @@ public class AmbariMetaInfoTest {
 
   @Test
   public void testHooksDirInheritance() throws Exception {
+    String hookAssertionTemplate = "HDP/%s/hooks";
+    if (System.getProperty("os.name").contains("Windows")) {
+      hookAssertionTemplate = "HDP\\%s\\hooks";
+    }
     // Test hook dir determination in parent
     StackInfo stackInfo = metaInfo.getStack(STACK_NAME_HDP, "2.0.6");
-    Assert.assertEquals("HDP/2.0.6/hooks", stackInfo.getStackHooksFolder());
+    Assert.assertEquals(String.format(hookAssertionTemplate, "2.0.6"), stackInfo.getStackHooksFolder());
     // Test hook dir inheritance
     stackInfo = metaInfo.getStack(STACK_NAME_HDP, "2.0.7");
-    Assert.assertEquals("HDP/2.0.6/hooks", stackInfo.getStackHooksFolder());
+    Assert.assertEquals(String.format(hookAssertionTemplate, "2.0.6"), stackInfo.getStackHooksFolder());
     // Test hook dir override
     stackInfo = metaInfo.getStack(STACK_NAME_HDP, "2.0.8");
-    Assert.assertEquals("HDP/2.0.8/hooks", stackInfo.getStackHooksFolder());
+    Assert.assertEquals(String.format(hookAssertionTemplate, "2.0.8"), stackInfo.getStackHooksFolder());
   }
 
 
   @Test
   public void testServicePackageDirInheritance() throws Exception {
+    String assertionTemplate07 = "HDP/2.0.7/services/%s/package";
+    String assertionTemplate08 = "HDP/2.0.8/services/%s/package";
+    if (System.getProperty("os.name").contains("Windows")) {
+      assertionTemplate07 = "HDP\\2.0.7\\services\\%s\\package";
+      assertionTemplate08 = "HDP\\2.0.8\\services\\%s\\package";
+    }
     // Test service package dir determination in parent
     ServiceInfo service = metaInfo.getService(STACK_NAME_HDP, "2.0.7", "HBASE");
-    Assert.assertEquals("HDP/2.0.7/services/HBASE/package",
+    Assert.assertEquals(String.format(assertionTemplate07, "HBASE"),
             service.getServicePackageFolder());
 
     service = metaInfo.getService(STACK_NAME_HDP, "2.0.7", "HDFS");
-    Assert.assertEquals("HDP/2.0.7/services/HDFS/package",
+    Assert.assertEquals(String.format(assertionTemplate07, "HDFS"),
             service.getServicePackageFolder());
     // Test service package dir inheritance
     service = metaInfo.getService(STACK_NAME_HDP, "2.0.8", "HBASE");
-    Assert.assertEquals("HDP/2.0.7/services/HBASE/package",
+    Assert.assertEquals(String.format(assertionTemplate07, "HBASE"),
             service.getServicePackageFolder());
     // Test service package dir override
     service = metaInfo.getService(STACK_NAME_HDP, "2.0.8", "HDFS");
-    Assert.assertEquals("HDP/2.0.8/services/HDFS/package",
+    Assert.assertEquals(String.format(assertionTemplate08, "HDFS"),
             service.getServicePackageFolder());
   }
 
@@ -1599,14 +1633,19 @@ public class AmbariMetaInfoTest {
     }
   }
 
-  private TestAmbariMetaInfo setupTempAmbariMetaInfo(String buildDir, boolean replayMocks)
-      throws Exception {
+  private TestAmbariMetaInfo setupTempAmbariMetaInfo(String buildDir, boolean replayMocks) throws Exception {
     File stackRootTmp = new File(buildDir + "/ambari-metaInfo");
     File stackRoot = new File("src/test/resources/stacks");
+    File version = new File("target/version");
+
+    if (System.getProperty("os.name").contains("Windows")) {
+      stackRoot = new File(ClassLoader.getSystemClassLoader().getResource("stacks").getPath());
+      version = new File(new File(ClassLoader.getSystemClassLoader().getResource("").getPath()).getParent(), "version");
+    }
+
     stackRootTmp.mkdir();
     FileUtils.copyDirectory(stackRoot, stackRootTmp);
-    TestAmbariMetaInfo ambariMetaInfo = createAmbariMetaInfo(stackRootTmp, new File(
-        "target/version"), replayMocks);
+    TestAmbariMetaInfo ambariMetaInfo = createAmbariMetaInfo(stackRootTmp, version, replayMocks);
 
     return ambariMetaInfo;
   }
@@ -1685,7 +1724,12 @@ public class AmbariMetaInfoTest {
 
       //OSFamily
       Configuration config = createNiceMock(Configuration.class);
-      expect(config.getSharedResourcesDirPath()).andReturn("./src/test/resources").anyTimes();
+      if (System.getProperty("os.name").contains("Windows")) {
+        expect(config.getSharedResourcesDirPath()).andReturn(ClassLoader.getSystemClassLoader().getResource("").getPath()).anyTimes();
+      }
+      else {
+        expect(config.getSharedResourcesDirPath()).andReturn("./src/test/resources").anyTimes();
+      }
       replay(config);
       osFamily = new OsFamily(config);
       f = c.getDeclaredField("os_family");

http://git-wip-us.apache.org/repos/asf/ambari/blob/498a13ba/ambari-server/src/test/java/org/apache/ambari/server/api/services/ViewSubResourceServiceTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/services/ViewSubResourceServiceTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/services/ViewSubResourceServiceTest.java
index aaa0d62..25b477f 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/api/services/ViewSubResourceServiceTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/api/services/ViewSubResourceServiceTest.java
@@ -146,7 +146,7 @@ public class ViewSubResourceServiceTest extends BaseServiceTest {
         "  }\n" +
         "}";
 
-    assertEquals(expected, o);
+    assertEquals(expected, o.toString().replace("\r", ""));
 
     verify(uriInfo, resource);
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/498a13ba/ambari-server/src/test/java/org/apache/ambari/server/api/services/serializers/JsonSerializerTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/services/serializers/JsonSerializerTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/services/serializers/JsonSerializerTest.java
index 4bd12d3..2ea45dc 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/api/services/serializers/JsonSerializerTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/api/services/serializers/JsonSerializerTest.java
@@ -72,7 +72,7 @@ public class JsonSerializerTest {
     replay(uriInfo, resource/*, resource2*/);
 
     //execute test
-    Object o = new JsonSerializer().serialize(result);
+    Object o = new JsonSerializer().serialize(result).toString().replace("\r", "");
 
     String expected = "{\n" +
         "  \"href\" : \"this is an href\",\n" +
@@ -126,7 +126,7 @@ public class JsonSerializerTest {
     replay(uriInfo, resource);
 
     //execute test
-    Object o = new JsonSerializer().serialize(result);
+    Object o = new JsonSerializer().serialize(result).toString().replace("\r", "");
 
     String expected = "{\n" +
         "  \"resources\" : [\n" +
@@ -182,7 +182,7 @@ public class JsonSerializerTest {
     replay(uriInfo, resource/*, resource2*/);
 
     //execute test
-    Object o = new JsonSerializer().serialize(result);
+    Object o = new JsonSerializer().serialize(result).toString().replace("\r", "");
     String expected = "[\n" +
     "  {\n" +
     "    \"href\" : \"this is an href\",\n" +

http://git-wip-us.apache.org/repos/asf/ambari/blob/498a13ba/ambari-server/src/test/java/org/apache/ambari/server/bootstrap/BootStrapTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/bootstrap/BootStrapTest.java b/ambari-server/src/test/java/org/apache/ambari/server/bootstrap/BootStrapTest.java
index a213f21..0172b29 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/bootstrap/BootStrapTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/bootstrap/BootStrapTest.java
@@ -59,19 +59,25 @@ public class BootStrapTest extends TestCase {
   @Test
   public void testRun() throws Exception {
     Properties properties = new Properties();
-    String bootdir =  temp.newFolder("bootdir").toString();
-    String metadetadir =  temp.newFolder("metadetadir").toString();
-    String serverVersionFilePath =  temp.newFolder("serverVersionFilePath").toString();
+    String bootdir = temp.newFolder("bootdir").toString();
+    String metadetadir = temp.newFolder("metadetadir").toString();
+    String serverVersionFilePath = temp.newFolder("serverVersionFilePath").toString();
     LOG.info("Bootdir is " + bootdir);
     LOG.info("Metadetadir is " + metadetadir);
     LOG.info("ServerVersionFilePath is " + serverVersionFilePath);
-    properties.setProperty(Configuration.BOOTSTRAP_DIR,
-       bootdir);
+
+    String sharedResourcesDir = "src/test/resources/";
+    if (System.getProperty("os.name").contains("Windows")) {
+      sharedResourcesDir = ClassLoader.getSystemClassLoader().getResource("").getPath();
+    }
+
+    properties.setProperty(Configuration.BOOTSTRAP_DIR, bootdir);
     properties.setProperty(Configuration.BOOTSTRAP_SCRIPT, "echo");
     properties.setProperty(Configuration.SRVR_KSTR_DIR_KEY, "target" + File.separator + "classes");
     properties.setProperty(Configuration.METADETA_DIR_PATH, metadetadir);
     properties.setProperty(Configuration.SERVER_VERSION_FILE, serverVersionFilePath);
-    properties.setProperty(Configuration.SHARED_RESOURCES_DIR_KEY, "src/test/resources/");
+    properties.setProperty(Configuration.SHARED_RESOURCES_DIR_KEY, sharedResourcesDir);
+
     Configuration conf = new Configuration(properties);
     AmbariMetaInfo ambariMetaInfo = new AmbariMetaInfo(conf);
     BootStrapImpl impl = new BootStrapImpl(conf, ambariMetaInfo);
@@ -91,12 +97,12 @@ public class BootStrapTest extends TestCase {
     LOG.info("Status " + status.getStatus());
     int num = 0;
     while ((status.getStatus() == BSStat.RUNNING) && (num < 500)) {
-        status = impl.getStatus(response.getRequestId());
-        Thread.sleep(100);
-        num++;
+      status = impl.getStatus(response.getRequestId());
+      Thread.sleep(100);
+      num++;
     }
     LOG.info("Status: log " + status.getLog() + " status=" + status.getStatus()
-        );
+    );
     /* Note its an echo command so it should echo host1,host2 */
     Assert.assertTrue(status.getLog().contains("host1,host2"));
     Assert.assertEquals(BSStat.SUCCESS, status.getStatus());
@@ -104,68 +110,75 @@ public class BootStrapTest extends TestCase {
     Assert.assertFalse(new File(bootdir + File.separator + "1" + File.separator + "host_pass").exists());
   }
 
-    @Test
-    public void testHostFailure() throws Exception {
-        Properties properties = new Properties();
-        String bootdir =  temp.newFolder("bootdir").toString();
-        String metadetadir =  temp.newFolder("metadetadir").toString();
-        String serverVersionFilePath =  temp.newFolder("serverVersionFilePath").toString();
-        LOG.info("Bootdir is " + bootdir);
-        LOG.info("Metadetadir is " + metadetadir);
-        LOG.info("ServerVersionFilePath is " + serverVersionFilePath);
-        properties.setProperty(Configuration.BOOTSTRAP_DIR,
-                bootdir);
-        properties.setProperty(Configuration.BOOTSTRAP_SCRIPT, "echo");
-        properties.setProperty(Configuration.SRVR_KSTR_DIR_KEY, "target" + File.separator + "classes");
-        properties.setProperty(Configuration.METADETA_DIR_PATH, metadetadir);
-        properties.setProperty(Configuration.SERVER_VERSION_FILE, serverVersionFilePath);
-      properties.setProperty(Configuration.SHARED_RESOURCES_DIR_KEY, "src/test/resources/");
-        Configuration conf = new Configuration(properties);
-        AmbariMetaInfo ambariMetaInfo = new AmbariMetaInfo(conf);
-        BootStrapImpl impl = new BootStrapImpl(conf, ambariMetaInfo);
-        impl.init();
-        SshHostInfo info = new SshHostInfo();
-        info.setSshKey("xyz");
-        ArrayList<String> hosts = new ArrayList<String>();
-        hosts.add("host1");
-        hosts.add("host2");
-        info.setHosts(hosts);
-        info.setUser("user");
-        info.setPassword("passwd");
-        BSResponse response = impl.runBootStrap(info);
-        long requestId = response.getRequestId();
-        LOG.info("Response id from bootstrap " + requestId);
-    /* create failed done file for host2 */
-        File requestDir = new File(bootdir, Long.toString(requestId));
-    /* wait while directory is created */
-        int num = 0;
-        while (!requestDir.exists() && num<500) {
-            Thread.sleep(100);
-            num++;
-        }
-        if (!requestDir.exists()) {
-            LOG.warn("RequestDir does not exists");
-        }
-        FileUtils.writeStringToFile(new File(requestDir, "host1.done"), "0");
-        FileUtils.writeStringToFile(new File(requestDir, "host2.done"), "1");
-    /* do a query */
-        BootStrapStatus status = impl.getStatus(response.getRequestId());
-        LOG.info("Status " + status.getStatus());
-        num = 0;
-        while ((status.getStatus() == BSStat.RUNNING) && (num < 500)) {
-            status = impl.getStatus(response.getRequestId());
-            Thread.sleep(100);
-            num++;
-        }
-        LOG.info("Status: log " + status.getLog() + " status=" + status.getStatus()
-        );
-    /* Note its an echo command so it should echo host1,host2 */
-        Assert.assertTrue(status.getLog().contains("host1,host2"));
-        Assert.assertEquals(BSStat.ERROR, status.getStatus());
-        Assert.assertEquals("DONE", status.getHostsStatus().get(0).getStatus());
-        Assert.assertEquals("FAILED", status.getHostsStatus().get(1).getStatus());
+  @Test
+  public void testHostFailure() throws Exception {
+    Properties properties = new Properties();
+    String bootdir = temp.newFolder("bootdir").toString();
+    String metadetadir = temp.newFolder("metadetadir").toString();
+    String serverVersionFilePath = temp.newFolder("serverVersionFilePath").toString();
+    LOG.info("Bootdir is " + bootdir);
+    LOG.info("Metadetadir is " + metadetadir);
+    LOG.info("ServerVersionFilePath is " + serverVersionFilePath);
+
+    String sharedResourcesDir = "src/test/resources/";
+    String serverKSTRDir = "target" + File.separator + "classes";
+    if (System.getProperty("os.name").contains("Windows")) {
+      sharedResourcesDir = ClassLoader.getSystemClassLoader().getResource("").getPath();
+      serverKSTRDir = new File(new File(ClassLoader.getSystemClassLoader().getResource("").getPath()).getParent(), "classes").getPath();
     }
 
+    properties.setProperty(Configuration.BOOTSTRAP_DIR, bootdir);
+    properties.setProperty(Configuration.BOOTSTRAP_SCRIPT, "echo");
+    properties.setProperty(Configuration.SRVR_KSTR_DIR_KEY, serverKSTRDir);
+    properties.setProperty(Configuration.METADETA_DIR_PATH, metadetadir);
+    properties.setProperty(Configuration.SERVER_VERSION_FILE, serverVersionFilePath);
+    properties.setProperty(Configuration.SHARED_RESOURCES_DIR_KEY, sharedResourcesDir);
+    Configuration conf = new Configuration(properties);
+    AmbariMetaInfo ambariMetaInfo = new AmbariMetaInfo(conf);
+    BootStrapImpl impl = new BootStrapImpl(conf, ambariMetaInfo);
+    impl.init();
+    SshHostInfo info = new SshHostInfo();
+    info.setSshKey("xyz");
+    ArrayList<String> hosts = new ArrayList<String>();
+    hosts.add("host1");
+    hosts.add("host2");
+    info.setHosts(hosts);
+    info.setUser("user");
+    info.setPassword("passwd");
+    BSResponse response = impl.runBootStrap(info);
+    long requestId = response.getRequestId();
+    LOG.info("Response id from bootstrap " + requestId);
+      /* create failed done file for host2 */
+    File requestDir = new File(bootdir, Long.toString(requestId));
+      /* wait while directory is created */
+    int num = 0;
+    while (!requestDir.exists() && num < 500) {
+      Thread.sleep(100);
+      num++;
+    }
+    if (!requestDir.exists()) {
+      LOG.warn("RequestDir does not exists");
+    }
+    FileUtils.writeStringToFile(new File(requestDir, "host1.done"), "0");
+    FileUtils.writeStringToFile(new File(requestDir, "host2.done"), "1");
+      /* do a query */
+    BootStrapStatus status = impl.getStatus(response.getRequestId());
+    LOG.info("Status " + status.getStatus());
+    num = 0;
+    while ((status.getStatus() == BSStat.RUNNING) && (num < 500)) {
+      status = impl.getStatus(response.getRequestId());
+      Thread.sleep(100);
+      num++;
+    }
+    LOG.info("Status: log " + status.getLog() + " status=" + status.getStatus()
+    );
+      /* Note its an echo command so it should echo host1,host2 */
+    Assert.assertTrue(status.getLog().contains("host1,host2"));
+    Assert.assertEquals(BSStat.ERROR, status.getStatus());
+    Assert.assertEquals("DONE", status.getHostsStatus().get(0).getStatus());
+    Assert.assertEquals("FAILED", status.getHostsStatus().get(1).getStatus());
+  }
+
 
   @Test
   public void testPolling() throws Exception {
@@ -180,7 +193,7 @@ public class BootStrapTest extends TestCase {
     listHosts.add("host1");
     listHosts.add("host2");
     BSHostStatusCollector collector = new BSHostStatusCollector(tmpFolder,
-        listHosts);
+            listHosts);
     collector.run();
     List<BSHostStatus> polledHostStatus = collector.getHostStatus();
     Assert.assertTrue(polledHostStatus.size() == 2);

http://git-wip-us.apache.org/repos/asf/ambari/blob/498a13ba/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClientConfigResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClientConfigResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClientConfigResourceProviderTest.java
index 1f5d9aa..7f353a5 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClientConfigResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClientConfigResourceProviderTest.java
@@ -196,11 +196,16 @@ public class ClientConfigResourceProviderTest {
     String stackVersion = "V1";
 
     String stackRoot="/tmp/stacks/S1/V1";
-
     String packageFolder="PIG/package";
 
+    if (System.getProperty("os.name").contains("Windows")) {
+      stackRoot = "\\tmp\\stacks\\S1\\V1";
+      packageFolder = "PIG\\package";
+    }
+
+    File stackRootFile = new File(stackRoot);
     HashMap<String, Host> hosts = new HashMap<String, Host>();
-    hosts.put(hostName,host);
+    hosts.put(hostName, host);
     HashMap<String, Service> services = new HashMap<String, Service>();
     services.put(serviceName,service);
     HashMap<String, ServiceComponent> serviceComponentMap = new HashMap<String, ServiceComponent>();
@@ -264,7 +269,7 @@ public class ClientConfigResourceProviderTest {
             (String) anyObject(), (String) anyObject())).andReturn(componentInfo).anyTimes();
     expect(componentInfo.getCommandScript()).andReturn(commandScriptDefinition);
     expect(componentInfo.getClientConfigFiles()).andReturn(clientConfigFileDefinitionList);
-    expect(ambariMetaInfo.getStackRoot()).andReturn(new File(stackRoot));
+    expect(ambariMetaInfo.getStackRoot()).andReturn(stackRootFile);
     expect(cluster.getConfig("hive-site", null)).andReturn(clusterConfig);
     expect(cluster.getDesiredConfigs()).andReturn(desiredConfigMap);
     expect(clusters.getHostsForCluster(clusterName)).andReturn(hosts);
@@ -286,6 +291,15 @@ public class ClientConfigResourceProviderTest {
     String commandLine = "ambari-python-wrap /tmp/stacks/S1/V1/PIG/package/null generate_configs null " +
             "/tmp/stacks/S1/V1/PIG/package /var/lib/ambari-server/tmp/structured-out.json " +
             "INFO /var/lib/ambari-server/tmp";
+
+    if (System.getProperty("os.name").contains("Windows")) {
+      String absoluteStackRoot = stackRootFile.getAbsolutePath();
+      commandLine = "ambari-python-wrap " + absoluteStackRoot +
+              "\\PIG\\package\\null generate_configs null " +
+              absoluteStackRoot + "\\PIG\\package /var/lib/ambari-server/tmp\\structured-out.json " +
+              "INFO /var/lib/ambari-server/tmp";
+    }
+
     ProcessBuilder processBuilder = PowerMock.createNiceMock(ProcessBuilder.class);
     PowerMock.expectNew(ProcessBuilder.class,Arrays.asList(commandLine.split("\\s+"))).andReturn(processBuilder).once();
     expect(processBuilder.start()).andReturn(process).once();

http://git-wip-us.apache.org/repos/asf/ambari/blob/498a13ba/ambari-server/src/test/java/org/apache/ambari/server/orm/InMemoryDefaultTestModule.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/orm/InMemoryDefaultTestModule.java b/ambari-server/src/test/java/org/apache/ambari/server/orm/InMemoryDefaultTestModule.java
index 7c33bba..621caba 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/orm/InMemoryDefaultTestModule.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/orm/InMemoryDefaultTestModule.java
@@ -23,6 +23,7 @@ import org.apache.ambari.server.configuration.Configuration;
 import org.apache.ambari.server.controller.ControllerModule;
 import org.springframework.beans.factory.config.BeanDefinition;
 
+import java.io.File;
 import java.util.Collections;
 import java.util.Properties;
 import java.util.Set;
@@ -58,14 +59,20 @@ public class InMemoryDefaultTestModule extends AbstractModule {
 
   @Override
   protected void configure() {
+    String stacks = "src/test/resources/stacks";
+    String version = "target/version";
+    String sharedResourcesDir = "src/test/resources/";
+    if (System.getProperty("os.name").contains("Windows")) {
+      stacks = ClassLoader.getSystemClassLoader().getResource("stacks").getPath();
+      version = new File(new File(ClassLoader.getSystemClassLoader().getResource("").getPath()).getParent(), "version").getPath();
+      sharedResourcesDir = ClassLoader.getSystemClassLoader().getResource("").getPath();
+    }
+
     properties.setProperty(Configuration.SERVER_PERSISTENCE_TYPE_KEY, "in-memory");
-    properties.setProperty(Configuration.METADETA_DIR_PATH,
-        "src/test/resources/stacks");
-    properties.setProperty(Configuration.SERVER_VERSION_FILE,
-            "target/version");
-    properties.setProperty(Configuration.OS_VERSION_KEY,
-        "centos5");
-    properties.setProperty(Configuration.SHARED_RESOURCES_DIR_KEY, "src/test/resources/");
+    properties.setProperty(Configuration.METADETA_DIR_PATH, stacks);
+    properties.setProperty(Configuration.SERVER_VERSION_FILE, version);
+    properties.setProperty(Configuration.OS_VERSION_KEY, "centos5");
+    properties.setProperty(Configuration.SHARED_RESOURCES_DIR_KEY, sharedResourcesDir);
 
     try {
       install(new BeanDefinitionsCachingTestControllerModule(properties));

http://git-wip-us.apache.org/repos/asf/ambari/blob/498a13ba/ambari-server/src/test/java/org/apache/ambari/server/security/CertGenerationTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/security/CertGenerationTest.java b/ambari-server/src/test/java/org/apache/ambari/server/security/CertGenerationTest.java
index 9ce76c9..10645b9 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/security/CertGenerationTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/security/CertGenerationTest.java
@@ -109,15 +109,22 @@ public class CertGenerationTest {
     //Test using actual ca.config.
     try {
       File caConfig = new File("conf/unix/ca.config");
-      File caConfigTest  =
-        new File(temp.getRoot().getAbsolutePath(), "ca.config");
+      if (System.getProperty("os.name").contains("Windows")) {
+        caConfig = new File(new File(ClassLoader.getSystemClassLoader().getResource("").getPath()).getParentFile().getParentFile(), "conf\\windows\\ca.config");
+      }
+      File caConfigTest = new File(temp.getRoot().getAbsolutePath(), "ca.config");
       File newCertsDir = new File(temp.getRoot().getAbsolutePath(), "newcerts");
       newCertsDir.mkdirs();
       File indexTxt = new File(temp.getRoot().getAbsolutePath(), "index.txt");
       indexTxt.createNewFile();
 
       String content = IOUtils.toString(new FileInputStream(caConfig));
-      content = content.replaceAll("/var/lib/ambari-server/keys/db", temp.getRoot().getAbsolutePath());
+      if (System.getProperty("os.name").contains("Windows")) {
+        content = content.replace("keystore\\\\db", temp.getRoot().getAbsolutePath().replace("\\", "\\\\"));
+      }
+      else {
+        content = content.replaceAll("/var/lib/ambari-server/keys/db", temp.getRoot().getAbsolutePath());
+      }
       IOUtils.write(content, new FileOutputStream(caConfigTest));
     } catch (IOException e) {
       e.printStackTrace();
@@ -134,25 +141,19 @@ public class CertGenerationTest {
 	
   @Test
   public void testServerCertGen() throws Exception {
-
-    File serverCrt = new File(temp.getRoot().getAbsoluteFile() +
-    						  File.separator + Configuration.SRVR_CRT_NAME_DEFAULT);
+    File serverCrt = new File(temp.getRoot().getAbsoluteFile() + File.separator + Configuration.SRVR_CRT_NAME_DEFAULT);
     Assert.assertTrue(serverCrt.exists());
   }
 
   @Test
   public void testServerKeyGen() throws Exception {
-
-    File serverKey = new File(temp.getRoot().getAbsoluteFile() +
-    						  File.separator + Configuration.SRVR_KEY_NAME_DEFAULT);
+    File serverKey = new File(temp.getRoot().getAbsoluteFile() + File.separator + Configuration.SRVR_KEY_NAME_DEFAULT);
     Assert.assertTrue(serverKey.exists());
   }
 
   @Test
   public void testServerKeystoreGen() throws Exception {
-
-    File serverKeyStrore = new File(temp.getRoot().getAbsoluteFile() +
-    						  File.separator + Configuration.KSTR_NAME_DEFAULT);
+    File serverKeyStrore = new File(temp.getRoot().getAbsoluteFile() + File.separator + Configuration.KSTR_NAME_DEFAULT);
     Assert.assertTrue(serverKeyStrore.exists());
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/498a13ba/ambari-server/src/test/java/org/apache/ambari/server/stack/StackManagerTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/stack/StackManagerTest.java b/ambari-server/src/test/java/org/apache/ambari/server/stack/StackManagerTest.java
index 0502e1a..940c65a 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/stack/StackManagerTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/stack/StackManagerTest.java
@@ -67,7 +67,11 @@ public class StackManagerTest {
   }
 
   public static StackManager createTestStackManager() throws Exception {
-    return createTestStackManager("./src/test/resources/stacks/");
+    String stack = "./src/test/resources/stacks/";
+    if (System.getProperty("os.name").contains("Windows")) {
+      stack = ClassLoader.getSystemClassLoader().getResource("stacks").getPath();
+    }
+    return createTestStackManager(stack);
   }
 
   public static StackManager createTestStackManager(String stackRoot) throws Exception {
@@ -76,7 +80,12 @@ public class StackManagerTest {
       dao = createNiceMock(MetainfoDAO.class);
       actionMetadata = createNiceMock(ActionMetadata.class);
       Configuration config = createNiceMock(Configuration.class);
-      expect(config.getSharedResourcesDirPath()).andReturn("./src/test/resources").anyTimes();
+      if (System.getProperty("os.name").contains("Windows")) {
+        expect(config.getSharedResourcesDirPath()).andReturn(ClassLoader.getSystemClassLoader().getResource("").getPath()).anyTimes();
+      }
+      else {
+        expect(config.getSharedResourcesDirPath()).andReturn("./src/test/resources").anyTimes();
+      }
       replay(config);
       osFamily = new OsFamily(config);
 
@@ -291,7 +300,12 @@ public class StackManagerTest {
     // overridden value
     assertEquals("Apache Hadoop Stream processing framework (Extended)", stormService.getComment());
     assertEquals("New version", stormService.getVersion());
-    assertEquals("OTHER/1.0/services/STORM/package", stormService.getServicePackageFolder());
+    if (System.getProperty("os.name").contains("Windows")) {
+      assertEquals("OTHER\\1.0\\services\\STORM\\package", stormService.getServicePackageFolder());
+    }
+    else {
+      assertEquals("OTHER/1.0/services/STORM/package", stormService.getServicePackageFolder());
+    }
     // compare components
     List<ComponentInfo> stormServiceComponents = stormService.getComponents();
     List<ComponentInfo> baseStormServiceComponents = baseStormService.getComponents();
@@ -514,8 +528,12 @@ public class StackManagerTest {
     OsFamily osFamily = createNiceMock(OsFamily.class);
     replay(actionMetadata);
     try {
-    new StackManager(new File("./src/test/resources/stacks_with_cycle/"),
-        new StackContext(null, actionMetadata, osFamily));
+      String stacksCycle1 = "./src/test/resources/stacks_with_cycle/";
+      if (System.getProperty("os.name").contains("Windows")) {
+        stacksCycle1 = ClassLoader.getSystemClassLoader().getResource("stacks_with_cycle").getPath();
+      }
+      new StackManager(new File(stacksCycle1),
+              new StackContext(null, actionMetadata, osFamily));
       fail("Expected exception due to cyclic stack");
     } catch (AmbariException e) {
       // expected
@@ -523,8 +541,12 @@ public class StackManagerTest {
     }
 
     try {
-      new StackManager(new File("./src/test/resources/stacks_with_cycle2/"),
-          new StackContext(null, actionMetadata, osFamily));
+      String stacksCycle2 = "./src/test/resources/stacks_with_cycle2/";
+      if (System.getProperty("os.name").contains("Windows")) {
+        stacksCycle2 = ClassLoader.getSystemClassLoader().getResource("stacks_with_cycle2").getPath();
+      }
+      new StackManager(new File(stacksCycle2),
+              new StackContext(null, actionMetadata, osFamily));
       fail("Expected exception due to cyclic stack");
     } catch (AmbariException e) {
       // expected
@@ -584,8 +606,12 @@ public class StackManagerTest {
     // ensure that service check is added for HDFS
     actionMetadata.addServiceCheckAction("HDFS");
     replay(dao, actionMetadata, osFamily);
+    String singleStack = "./src/test/resources/single_stack";
+    if (System.getProperty("os.name").contains("Windows")) {
+      singleStack = ClassLoader.getSystemClassLoader().getResource("single_stack").getPath();
+    }
     StackManager stackManager = new StackManager(
-        new File("./src/test/resources/single_stack".replace("/", File.separator)),
+        new File(singleStack.replace("/", File.separator)),
         new StackContext(dao, actionMetadata, osFamily));
 
     Collection<StackInfo> stacks = stackManager.getStacks();

http://git-wip-us.apache.org/repos/asf/ambari/blob/498a13ba/ambari-server/src/test/java/org/apache/ambari/server/state/stack/OSFamilyTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/stack/OSFamilyTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/stack/OSFamilyTest.java
index e4aa8f7..7957860 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/stack/OSFamilyTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/stack/OSFamilyTest.java
@@ -46,7 +46,7 @@ public class OSFamilyTest {
    Set<String> expected_oslist = new HashSet<String>(Arrays.asList(
       "redhat6", "oraclelinux5", "suse11", "fedora6", "opensuse11",
       "centos6", "fedora5","centos5", "ubuntu12", "redhat5", "sles11",
-      "oraclelinux6", "debian12", "sled11"
+      "oraclelinux6", "debian12", "sled11", "win2012server6", "win2012serverr26", "win2008serverr26", "win2008server6"
    ));
 
    Assert.assertNotNull(actual_oslist);

http://git-wip-us.apache.org/repos/asf/ambari/blob/498a13ba/ambari-server/src/test/java/org/apache/ambari/server/view/ViewExtractorTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/view/ViewExtractorTest.java b/ambari-server/src/test/java/org/apache/ambari/server/view/ViewExtractorTest.java
index 047c8a3..02ec916 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/view/ViewExtractorTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/view/ViewExtractorTest.java
@@ -90,13 +90,20 @@ public class ViewExtractorTest {
     expect(configuration.getViewExtractionThreadPoolCoreSize()).andReturn(2).anyTimes();
     expect(configuration.getViewExtractionThreadPoolMaxSize()).andReturn(3).anyTimes();
     expect(configuration.getViewExtractionThreadPoolTimeout()).andReturn(10000L).anyTimes();
-
-    expect(viewArchive.getAbsolutePath()).andReturn(
-        "/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}").anyTimes();
+    if (System.getProperty("os.name").contains("Windows")) {
+      expect(viewArchive.getAbsolutePath()).andReturn("\\var\\lib\\ambari-server\\resources\\views\\work\\MY_VIEW{1.0.0}").anyTimes();
+    }
+    else {
+      expect(viewArchive.getAbsolutePath()).andReturn("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}").anyTimes();
+    }
 
     expect(archiveDir.exists()).andReturn(false);
-    expect(archiveDir.getAbsolutePath()).andReturn(
-        "/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}").anyTimes();
+    if (System.getProperty("os.name").contains("Windows")) {
+      expect(archiveDir.getAbsolutePath()).andReturn("\\var\\lib\\ambari-server\\resources\\views\\work\\MY_VIEW{1.0.0}").anyTimes();
+    }
+    else {
+      expect(archiveDir.getAbsolutePath()).andReturn("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}").anyTimes();
+    }
     expect(archiveDir.mkdir()).andReturn(true);
     expect(archiveDir.toURI()).andReturn(new URI("file:./"));
 
@@ -151,7 +158,12 @@ public class ViewExtractorTest {
 
     ViewExtractor viewExtractor = getViewExtractor(viewDefinition);
 
-    Assert.assertTrue(viewExtractor.ensureExtractedArchiveDirectory("/var/lib/ambari-server/resources/views/work"));
+    if (System.getProperty("os.name").contains("Windows")) {
+      Assert.assertTrue(viewExtractor.ensureExtractedArchiveDirectory("\\var\\lib\\ambari-server\\resources\\views\\work"));
+    }
+    else {
+      Assert.assertTrue(viewExtractor.ensureExtractedArchiveDirectory("/var/lib/ambari-server/resources/views/work"));
+    }
 
     verify(extractedArchiveDir, viewArchive, archiveDir, entryFile, classesDir, libDir, metaInfDir, viewJarFile,
         jarEntry, fos, configuration, viewDir, fileEntry, viewDAO);
@@ -165,7 +177,12 @@ public class ViewExtractorTest {
 
     viewExtractor = getViewExtractor(viewDefinition);
 
-    Assert.assertTrue(viewExtractor.ensureExtractedArchiveDirectory("/var/lib/ambari-server/resources/views/work"));
+    if (System.getProperty("os.name").contains("Windows")) {
+      Assert.assertTrue(viewExtractor.ensureExtractedArchiveDirectory("\\var\\lib\\ambari-server\\resources\\views\\work"));
+    }
+    else {
+      Assert.assertTrue(viewExtractor.ensureExtractedArchiveDirectory("/var/lib/ambari-server/resources/views/work"));
+    }
 
     verify(extractedArchiveDir);
 
@@ -178,8 +195,12 @@ public class ViewExtractorTest {
 
     viewExtractor = getViewExtractor(viewDefinition);
 
-    Assert.assertFalse(viewExtractor.ensureExtractedArchiveDirectory("/var/lib/ambari-server/resources/views/work"));
-
+    if (System.getProperty("os.name").contains("Windows")) {
+      Assert.assertFalse(viewExtractor.ensureExtractedArchiveDirectory("\\var\\lib\\ambari-server\\resources\\views\\work"));
+    }
+    else {
+      Assert.assertFalse(viewExtractor.ensureExtractedArchiveDirectory("/var/lib/ambari-server/resources/views/work"));
+    }
     verify(extractedArchiveDir);
   }
 
@@ -190,12 +211,22 @@ public class ViewExtractorTest {
 
     Map<String, File> files = new HashMap<String, File>();
 
-    files.put("/var/lib/ambari-server/resources/views/work", extractedArchiveDir);
-    files.put("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}", archiveDir);
-    files.put("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}/view.xml", entryFile);
-    files.put("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}/WEB-INF/classes", classesDir);
-    files.put("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}/WEB-INF/lib", libDir);
-    files.put("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}/META-INF", metaInfDir);
+    if (System.getProperty("os.name").contains("Windows")) {
+      files.put("\\var\\lib\\ambari-server\\resources\\views\\work", extractedArchiveDir);
+      files.put("\\var\\lib\\ambari-server\\resources\\views\\work\\MY_VIEW{1.0.0}", archiveDir);
+      files.put("\\var\\lib\\ambari-server\\resources\\views\\work\\MY_VIEW{1.0.0}\\view.xml", entryFile);
+      files.put("\\var\\lib\\ambari-server\\resources\\views\\work\\MY_VIEW{1.0.0}\\WEB-INF/classes", classesDir);
+      files.put("\\var\\lib\\ambari-server\\resources\\views\\work\\MY_VIEW{1.0.0}\\WEB-INF/lib", libDir);
+      files.put("\\var\\lib\\ambari-server\\resources\\views\\work\\MY_VIEW{1.0.0}\\META-INF", metaInfDir);
+    }
+    else {
+      files.put("/var/lib/ambari-server/resources/views/work", extractedArchiveDir);
+      files.put("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}", archiveDir);
+      files.put("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}/view.xml", entryFile);
+      files.put("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}/WEB-INF/classes", classesDir);
+      files.put("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}/WEB-INF/lib", libDir);
+      files.put("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}/META-INF", metaInfDir);
+    }
 
     Map<File, FileOutputStream> outputStreams = new HashMap<File, FileOutputStream>();
     outputStreams.put(entryFile, fos);

http://git-wip-us.apache.org/repos/asf/ambari/blob/498a13ba/ambari-server/src/test/java/org/apache/ambari/server/view/ViewRegistryTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/view/ViewRegistryTest.java b/ambari-server/src/test/java/org/apache/ambari/server/view/ViewRegistryTest.java
index e956826..26a9b36 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/view/ViewRegistryTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/view/ViewRegistryTest.java
@@ -50,6 +50,7 @@ import java.util.jar.JarInputStream;
 
 import javax.xml.bind.JAXBException;
 
+import junit.framework.TestListener;
 import org.apache.ambari.server.api.resources.SubResourceDefinition;
 import org.apache.ambari.server.configuration.Configuration;
 import org.apache.ambari.server.controller.spi.Resource;
@@ -234,13 +235,22 @@ public class ViewRegistryTest {
     }
 
     Map<String, File> files = new HashMap<String, File>();
-
-    files.put("/var/lib/ambari-server/resources/views/work", extractedArchiveDir);
-    files.put("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}", archiveDir);
-    files.put("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}/view.xml", entryFile);
-    files.put("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}/WEB-INF/classes", classesDir);
-    files.put("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}/WEB-INF/lib", libDir);
-    files.put("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}/META-INF", metaInfDir);
+    if (System.getProperty("os.name").contains("Windows")) {
+      files.put("\\var\\lib\\ambari-server\\resources\\views\\work", extractedArchiveDir);
+      files.put("\\var\\lib\\ambari-server\\resources\\views\\work\\MY_VIEW{1.0.0}", archiveDir);
+      files.put("\\var\\lib\\ambari-server\\resources\\views\\work\\MY_VIEW{1.0.0}\\view.xml", entryFile);
+      files.put("\\var\\lib\\ambari-server\\resources\\views\\work\\MY_VIEW{1.0.0}\\WEB-INF/classes", classesDir);
+      files.put("\\var\\lib\\ambari-server\\resources\\views\\work\\MY_VIEW{1.0.0}\\WEB-INF/lib", libDir);
+      files.put("\\var\\lib\\ambari-server\\resources\\views\\work\\MY_VIEW{1.0.0}\\META-INF", metaInfDir);
+    }
+    else {
+      files.put("/var/lib/ambari-server/resources/views/work", extractedArchiveDir);
+      files.put("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}", archiveDir);
+      files.put("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}/view.xml", entryFile);
+      files.put("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}/WEB-INF/classes", classesDir);
+      files.put("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}/WEB-INF/lib", libDir);
+      files.put("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}/META-INF", metaInfDir);
+    }
 
     Map<File, FileOutputStream> outputStreams = new HashMap<File, FileOutputStream>();
     outputStreams.put(entryFile, fos);
@@ -250,7 +260,12 @@ public class ViewRegistryTest {
 
     // set expectations
     expect(configuration.getViewsDir()).andReturn(viewDir);
-    expect(viewDir.getAbsolutePath()).andReturn("/var/lib/ambari-server/resources/views");
+    if (System.getProperty("os.name").contains("Windows")) {
+      expect(viewDir.getAbsolutePath()).andReturn("\\var\\lib\\ambari-server\\resources\\views");
+    }
+    else {
+      expect(viewDir.getAbsolutePath()).andReturn("/var/lib/ambari-server/resources/views");
+    }
 
     expect(configuration.getViewExtractionThreadPoolCoreSize()).andReturn(2).anyTimes();
     expect(configuration.getViewExtractionThreadPoolMaxSize()).andReturn(3).anyTimes();
@@ -259,11 +274,20 @@ public class ViewRegistryTest {
     expect(viewDir.listFiles()).andReturn(new File[]{viewArchive});
 
     expect(viewArchive.isDirectory()).andReturn(false);
-    expect(viewArchive.getAbsolutePath()).andReturn("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}").anyTimes();
+    if (System.getProperty("os.name").contains("Windows")) {
+      expect(viewArchive.getAbsolutePath()).andReturn("\\var\\lib\\ambari-server\\resources\\views\\work\\MY_VIEW{1.0.0}").anyTimes();
+    }
+    else {
+      expect(viewArchive.getAbsolutePath()).andReturn("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}").anyTimes();
+    }
 
     expect(archiveDir.exists()).andReturn(false);
-    expect(archiveDir.getAbsolutePath()).andReturn(
-        "/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}").anyTimes();
+    if (System.getProperty("os.name").contains("Windows")) {
+      expect(archiveDir.getAbsolutePath()).andReturn("\\var\\lib\\ambari-server\\resources\\views\\work\\MY_VIEW{1.0.0}").anyTimes();
+    }
+    else {
+      expect(archiveDir.getAbsolutePath()).andReturn("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}").anyTimes();
+    }
     expect(archiveDir.mkdir()).andReturn(true);
     expect(archiveDir.toURI()).andReturn(new URI("file:./"));
 
@@ -380,12 +404,22 @@ public class ViewRegistryTest {
 
     Map<String, File> files = new HashMap<String, File>();
 
-    files.put("/var/lib/ambari-server/resources/views/work", extractedArchiveDir);
-    files.put("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}", archiveDir);
-    files.put("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}/view.xml", entryFile);
-    files.put("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}/WEB-INF/classes", classesDir);
-    files.put("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}/WEB-INF/lib", libDir);
-    files.put("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}/META-INF", metaInfDir);
+    if (System.getProperty("os.name").contains("Windows")) {
+      files.put("\\var\\lib\\ambari-server\\resources\\views\\work", extractedArchiveDir);
+      files.put("\\var\\lib\\ambari-server\\resources\\views\\work\\MY_VIEW{1.0.0}", archiveDir);
+      files.put("\\var\\lib\\ambari-server\\resources\\views\\work\\MY_VIEW{1.0.0}\\view.xml", entryFile);
+      files.put("\\var\\lib\\ambari-server\\resources\\views\\work\\MY_VIEW{1.0.0}\\WEB-INF/classes", classesDir);
+      files.put("\\var\\lib\\ambari-server\\resources\\views\\work\\MY_VIEW{1.0.0}\\WEB-INF/lib", libDir);
+      files.put("\\var\\lib\\ambari-server\\resources\\views\\work\\MY_VIEW{1.0.0}\\META-INF", metaInfDir);
+    }
+    else {
+      files.put("/var/lib/ambari-server/resources/views/work", extractedArchiveDir);
+      files.put("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}", archiveDir);
+      files.put("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}/view.xml", entryFile);
+      files.put("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}/WEB-INF/classes", classesDir);
+      files.put("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}/WEB-INF/lib", libDir);
+      files.put("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}/META-INF", metaInfDir);
+    }
 
     Map<File, FileOutputStream> outputStreams = new HashMap<File, FileOutputStream>();
     outputStreams.put(entryFile, fos);
@@ -395,7 +429,12 @@ public class ViewRegistryTest {
 
     // set expectations
     expect(configuration.getViewsDir()).andReturn(viewDir);
-    expect(viewDir.getAbsolutePath()).andReturn("/var/lib/ambari-server/resources/views");
+    if (System.getProperty("os.name").contains("Windows")) {
+      expect(viewDir.getAbsolutePath()).andReturn("\\var\\lib\\ambari-server\\resources\\views");
+    }
+    else {
+      expect(viewDir.getAbsolutePath()).andReturn("/var/lib/ambari-server/resources/views");
+    }
 
     expect(configuration.getViewExtractionThreadPoolCoreSize()).andReturn(2).anyTimes();
     expect(configuration.getViewExtractionThreadPoolMaxSize()).andReturn(3).anyTimes();
@@ -404,11 +443,20 @@ public class ViewRegistryTest {
     expect(viewDir.listFiles()).andReturn(new File[]{viewArchive});
 
     expect(viewArchive.isDirectory()).andReturn(false);
-    expect(viewArchive.getAbsolutePath()).andReturn("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}");
+    if (System.getProperty("os.name").contains("Windows")) {
+      expect(viewArchive.getAbsolutePath()).andReturn("\\var\\lib\\ambari-server\\resources\\views\\work\\MY_VIEW{1.0.0}");
+    }
+    else {
+      expect(viewArchive.getAbsolutePath()).andReturn("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}");
+    }
 
     expect(archiveDir.exists()).andReturn(false);
-    expect(archiveDir.getAbsolutePath()).andReturn(
-        "/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}").anyTimes();
+    if (System.getProperty("os.name").contains("Windows")) {
+      expect(archiveDir.getAbsolutePath()).andReturn("\\var\\lib\\ambari-server\\resources\\views\\work\\MY_VIEW{1.0.0}").anyTimes();
+    }
+    else {
+      expect(archiveDir.getAbsolutePath()).andReturn("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}").anyTimes();
+    }
     expect(archiveDir.mkdir()).andReturn(true);
     expect(archiveDir.toURI()).andReturn(new URI("file:./"));
 
@@ -1062,13 +1110,24 @@ public class ViewRegistryTest {
 
     Map<String, File> files = new HashMap<String, File>();
 
-    files.put("/var/lib/ambari-server/resources/views/my_view-1.0.0.jar", viewArchive);
-    files.put("/var/lib/ambari-server/resources/views/work", extractedArchiveDir);
-    files.put("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}", archiveDir);
-    files.put("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}/view.xml", entryFile);
-    files.put("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}/WEB-INF/classes", classesDir);
-    files.put("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}/WEB-INF/lib", libDir);
-    files.put("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}/META-INF", metaInfDir);
+    if (System.getProperty("os.name").contains("Windows")) {
+      files.put("\\var\\lib\\ambari-server\\resources\\views\\my_view-1.0.0.jar", viewArchive);
+      files.put("\\var\\lib\\ambari-server\\resources\\views\\work", extractedArchiveDir);
+      files.put("\\var\\lib\\ambari-server\\resources\\views\\work\\MY_VIEW{1.0.0}", archiveDir);
+      files.put("\\var\\lib\\ambari-server\\resources\\views\\work\\MY_VIEW{1.0.0}\\view.xml", entryFile);
+      files.put("\\var\\lib\\ambari-server\\resources\\views\\work\\MY_VIEW{1.0.0}\\WEB-INF\\classes", classesDir);
+      files.put("\\var\\lib\\ambari-server\\resources\\views\\work\\MY_VIEW{1.0.0}\\WEB-INF\\lib", libDir);
+      files.put("\\var\\lib\\ambari-server\\resources\\views\\work\\MY_VIEW{1.0.0}\\META-INF", metaInfDir);
+    }
+    else {
+      files.put("/var/lib/ambari-server/resources/views/my_view-1.0.0.jar", viewArchive);
+      files.put("/var/lib/ambari-server/resources/views/work", extractedArchiveDir);
+      files.put("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}", archiveDir);
+      files.put("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}/view.xml", entryFile);
+      files.put("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}/WEB-INF/classes", classesDir);
+      files.put("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}/WEB-INF/lib", libDir);
+      files.put("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}/META-INF", metaInfDir);
+    }
 
     Map<File, FileOutputStream> outputStreams = new HashMap<File, FileOutputStream>();
     outputStreams.put(entryFile, fos);
@@ -1078,20 +1137,39 @@ public class ViewRegistryTest {
 
     // set expectations
     expect(configuration.getViewsDir()).andReturn(viewDir);
-    expect(viewDir.getAbsolutePath()).andReturn("/var/lib/ambari-server/resources/views");
+    if (System.getProperty("os.name").contains("Windows")) {
+      expect(viewDir.getAbsolutePath()).andReturn("\\var\\lib\\ambari-server\\resources\\views");
+    }
+    else {
+      expect(viewDir.getAbsolutePath()).andReturn("/var/lib/ambari-server/resources/views");
+    }
 
     expect(configuration.getViewExtractionThreadPoolCoreSize()).andReturn(2).anyTimes();
     expect(configuration.getViewExtractionThreadPoolMaxSize()).andReturn(3).anyTimes();
     expect(configuration.getViewExtractionThreadPoolTimeout()).andReturn(10000L).anyTimes();
 
-    expect(viewArchive.getAbsolutePath()).andReturn("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}").anyTimes();
+    if (System.getProperty("os.name").contains("Windows")) {
+      expect(viewArchive.getAbsolutePath()).andReturn("\\var\\lib\\ambari-server\\resources\\views\\work\\MY_VIEW{1.0.0}").anyTimes();
+    }
+    else {
+      expect(viewArchive.getAbsolutePath()).andReturn("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}").anyTimes();
+    }
 
     expect(archiveDir.exists()).andReturn(false);
-    expect(archiveDir.getAbsolutePath()).andReturn(
-        "/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}").anyTimes();
+    if (System.getProperty("os.name").contains("Windows")) {
+      expect(archiveDir.getAbsolutePath()).andReturn("\\var\\lib\\ambari-server\\resources\\views\\work\\MY_VIEW{1.0.0}").anyTimes();
+    }
+    else {
+      expect(archiveDir.getAbsolutePath()).andReturn("/var/lib/ambari-server/resources/views/work/MY_VIEW{1.0.0}").anyTimes();
+    }
 
     Capture<ViewEntity> viewEntityCapture = new Capture<ViewEntity>();
-    expect(viewExtractor.ensureExtractedArchiveDirectory("/var/lib/ambari-server/resources/views/work")).andReturn(true);
+    if (System.getProperty("os.name").contains("Windows")) {
+      expect(viewExtractor.ensureExtractedArchiveDirectory("\\var\\lib\\ambari-server\\resources\\views\\work")).andReturn(true);
+    }
+    else {
+      expect(viewExtractor.ensureExtractedArchiveDirectory("/var/lib/ambari-server/resources/views/work")).andReturn(true);
+    }
     expect(viewExtractor.extractViewArchive(capture(viewEntityCapture), eq(viewArchive), eq(archiveDir))).andReturn(null);
 
     // replay mocks
@@ -1100,8 +1178,14 @@ public class ViewRegistryTest {
 
     TestViewArchiveUtility archiveUtility = new TestViewArchiveUtility(viewConfigs, files, outputStreams, jarFiles);
 
-    Assert.assertTrue(ViewRegistry.extractViewArchive("/var/lib/ambari-server/resources/views/my_view-1.0.0.jar",
-        viewExtractor, archiveUtility, configuration, true));
+    if (System.getProperty("os.name").contains("Windows")) {
+      Assert.assertTrue(ViewRegistry.extractViewArchive("\\var\\lib\\ambari-server\\resources\\views\\my_view-1.0.0.jar",
+              viewExtractor, archiveUtility, configuration, true));
+    }
+    else {
+      Assert.assertTrue(ViewRegistry.extractViewArchive("/var/lib/ambari-server/resources/views/my_view-1.0.0.jar",
+              viewExtractor, archiveUtility, configuration, true));
+    }
 
     // verify mocks
     verify(configuration, viewDir, extractedArchiveDir, viewArchive, archiveDir, entryFile, classesDir,

http://git-wip-us.apache.org/repos/asf/ambari/blob/498a13ba/ambari-server/src/test/resources/os_family.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/resources/os_family.json b/ambari-server/src/test/resources/os_family.json
index 3cf0fed..df55b61 100644
--- a/ambari-server/src/test/resources/os_family.json
+++ b/ambari-server/src/test/resources/os_family.json
@@ -30,5 +30,16 @@
     "versions": [
       11
     ]
+  },
+  "winsrv": {
+    "distro": [
+      "win2008server",
+      "win2008serverr2",
+      "win2012server",
+      "win2012serverr2"
+    ],
+    "versions": [
+      6
+    ]
   }
 }


Mime
View raw message