ConfigUtils { public static String getDefNamespace(Reader in) { List<String> defLines = getDefLines(in); String defPackage = getDefKeyword(defLines, "package"); if (!defPackage.isEmpty()) return defPackage; return getDefKeyword(defLines, "namespace"); }  static String getMd5(ConfigPayload payload); static String getMd5(String input); static String getMd5(Utf8Array input); static String getMd5(byte[] input); static String stripSpaces(String str); static String getDefMd5(List<String> lines); static String getDefNamespace(Reader in); static Tuple2<String, String> getNameAndNamespaceFromString(String nameDotNamespace); static ConfigDefinitionKey createConfigDefinitionKeyFromZKString(String nodeName); static ConfigDefinitionKey createConfigDefinitionKeyFromDefFile(File file); static String escapeConfigFormatValue(String input); static String getDefMd5FromRequest(String defMd5, List<String> defContent); static String getCanonicalHostName(); static String getEnvValue(String defaultValue, String... envVars); static boolean isGenerationNewer(long newGen, long oldGen);  }
@Test public void testGetNamespace() { StringReader reader = new StringReader("version=1\nnamespace=a\nint a default=0"); assertThat(ConfigUtils.getDefNamespace(reader), is("a")); reader = new StringReader("namespace=a\nversion=1\nint a default=0"); assertThat(ConfigUtils.getDefNamespace(reader), is("a")); reader = new StringReader("version=1\nint a default=0"); assertThat(ConfigUtils.getDefNamespace(reader), is("")); reader = new StringReader("#comment\nversion=1\n#comment2\nint a default=0"); assertThat(ConfigUtils.getDefNamespace(reader), is("")); try { ConfigUtils.getDefNamespace(null); fail(); } catch (IllegalArgumentException e) { } }