@Test public void testRejectWindowsRoot() { assertEquals("should reject Windows root", "--canonicalRoot cannot be a root directory", CanonicalRootValidator.validate("C:" + File.separator, "--canonicalRoot")); }
public static String validate(String setting, String elementDescription) { if (!setting.endsWith(File.separator)) { return elementDescription + " must end with a separator"; } if (setting.matches("\\w:(?:[/\\\\]*)")) { return elementDescription + " cannot be a root directory"; } if (!setting.matches(".*[^/\\\\].*")) { return elementDescription + " cannot be the root directory"; } return null; }
CanonicalRootValidator { public static String validate(String setting, String elementDescription) { if (!setting.endsWith(File.separator)) { return elementDescription + " must end with a separator"; } if (setting.matches("\\w:(?:[/\\\\]*)")) { return elementDescription + " cannot be a root directory"; } if (!setting.matches(".*[^/\\\\].*")) { return elementDescription + " cannot be the root directory"; } return null; } }
CanonicalRootValidator { public static String validate(String setting, String elementDescription) { if (!setting.endsWith(File.separator)) { return elementDescription + " must end with a separator"; } if (setting.matches("\\w:(?:[/\\\\]*)")) { return elementDescription + " cannot be a root directory"; } if (!setting.matches(".*[^/\\\\].*")) { return elementDescription + " cannot be the root directory"; } return null; } private  CanonicalRootValidator(); }
CanonicalRootValidator { public static String validate(String setting, String elementDescription) { if (!setting.endsWith(File.separator)) { return elementDescription + " must end with a separator"; } if (setting.matches("\\w:(?:[/\\\\]*)")) { return elementDescription + " cannot be a root directory"; } if (!setting.matches(".*[^/\\\\].*")) { return elementDescription + " cannot be the root directory"; } return null; } private  CanonicalRootValidator(); static String validate(String setting, String elementDescription); }
CanonicalRootValidator { public static String validate(String setting, String elementDescription) { if (!setting.endsWith(File.separator)) { return elementDescription + " must end with a separator"; } if (setting.matches("\\w:(?:[/\\\\]*)")) { return elementDescription + " cannot be a root directory"; } if (!setting.matches(".*[^/\\\\].*")) { return elementDescription + " cannot be the root directory"; } return null; } private  CanonicalRootValidator(); static String validate(String setting, String elementDescription);  }