CmUtils { public static boolean isValidRack(String rack) { Pattern rackPattern = Pattern.compile("(/[a-zA-Z0-9\\.\\-\\_]+)+"); return rackPattern.matcher(rack).matches(); }  static String distroVersionOfHadoopStack(HadoopStack stack); static boolean isValidRack(String rack); static String getConfDir();  }
@Test public void testIsValidRack() { Assert.assertTrue(CmUtils.isValidRack("/rack")); Assert.assertTrue(CmUtils.isValidRack("/rack-01")); Assert.assertTrue(CmUtils.isValidRack("/.rack-01")); Assert.assertTrue(CmUtils.isValidRack("/_rack-01")); Assert.assertTrue(CmUtils.isValidRack("/rack-01/rack-02")); Assert.assertFalse(CmUtils.isValidRack("rack-01/rack-02")); }