Skip to content

Commit

Permalink
Test Debug
Browse files Browse the repository at this point in the history
  • Loading branch information
stevesamson committed Jul 3, 2024
1 parent c7bd3c5 commit 5e66d5f
Showing 1 changed file with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void run() {

}
}
private void createConfFile(String fileName, boolean inConf, String envVar,
private String createConfFile(String fileName, boolean inConf, String envVar,
Map<String, String> properties) throws IOException {
File tmpDir = new File(System.getProperty("java.io.tmpdir"));
File dir = new File(tmpDir, randomFileName());
Expand All @@ -98,19 +98,30 @@ private void createConfFile(String fileName, boolean inConf, String envVar,
File confFile = new File(dir, fileName);
confFile.deleteOnExit();
FileWriter writer = new FileWriter(confFile);
StringBuilder sb = new StringBuilder("<configuration>\n");
writer.write("<configuration>\n");
for (Map.Entry<String, String> entry : properties.entrySet()) {
sb.append(" <property>\n");
writer.write(" <property>\n");
writer.write(" <name>");
sb.append(" <name>");
writer.write(entry.getKey());
sb.append(entry.getKey());
writer.write("</name>\n");
sb.append("</name>\n");
writer.write(" <value>");
sb.append(" <value>");
writer.write(entry.getValue());
sb.append(entry.getValue());
writer.write("</value>\n");
sb.append("</value>\n");
writer.write(" </property>\n");
sb.append(" </property>\n");
}
writer.write("</configuration>\n");
sb.append("</configuration>\n");
writer.close();
return sb.toString();
}

private String randomFileName() {
Expand Down Expand Up @@ -210,9 +221,10 @@ public void readHiveSiteWithHiveConfDir() throws IOException {

@Test
public void readHiveSiteWithHiveHomeDir() throws IOException {
createConfFile("hive-site.xml", true, "HIVE_HOME", instaMap(
String confStr = createConfFile("hive-site.xml", true, "HIVE_HOME", instaMap(
"test.bool", "false"
));
System.out.println(String.format("DBUG: Check for key - %s, val - %s in %s looking for %s", "test.bool","false", confStr, ConfVars.BOOLEAN_TEST_ENTRY));
conf = MetastoreConf.newMetastoreConf();
Assert.assertFalse(MetastoreConf.getBoolVar(conf, ConfVars.BOOLEAN_TEST_ENTRY));
}
Expand All @@ -229,9 +241,11 @@ public void readHiveMetastoreSiteWithHiveConfDir() throws IOException {

@Test
public void readHiveMetastoreSiteWithHiveHomeDir() throws IOException {
createConfFile("hivemetastore-site.xml", true, "HIVE_HOME", instaMap(
String confStr = createConfFile("hivemetastore-site.xml", true, "HIVE_HOME", instaMap(
"test.bool", "false"
));

System.out.println(String.format("DBUG: Check for key - %s, val - %s in %s looking for %s", "test.bool","false", confStr, ConfVars.BOOLEAN_TEST_ENTRY));
conf = MetastoreConf.newMetastoreConf();
Assert.assertFalse(MetastoreConf.getBoolVar(conf, ConfVars.BOOLEAN_TEST_ENTRY));
}
Expand Down

0 comments on commit 5e66d5f

Please sign in to comment.