use of java.io.BufferedWriter in project hadoop by apache.
the class TestConfiguration method testGetClass.
public void testGetClass() throws IOException {
out = new BufferedWriter(new FileWriter(CONFIG));
startConfig();
appendProperty("test.class1", "java.lang.Integer");
appendProperty("test.class2", " java.lang.Integer ");
endConfig();
Path fileResource = new Path(CONFIG);
conf.addResource(fileResource);
assertEquals("java.lang.Integer", conf.getClass("test.class1", null).getCanonicalName());
assertEquals("java.lang.Integer", conf.getClass("test.class2", null).getCanonicalName());
}
use of java.io.BufferedWriter in project hadoop by apache.
the class TestConfiguration method testNullValueProperties.
public void testNullValueProperties() throws Exception {
Configuration conf = new Configuration();
conf.setAllowNullValueProperties(true);
out = new BufferedWriter(new FileWriter(CONFIG));
startConfig();
appendProperty("attr", "value", true);
appendProperty("attr", "", true);
endConfig();
Path fileResource = new Path(CONFIG);
conf.addResource(fileResource);
assertEquals("value", conf.get("attr"));
}
use of java.io.BufferedWriter in project hadoop by apache.
the class TestConfiguration method testCommentsInValue.
public void testCommentsInValue() throws IOException {
out = new BufferedWriter(new FileWriter(CONFIG));
startConfig();
appendProperty("my.comment", "this <!--comment here--> contains a comment");
endConfig();
Path fileResource = new Path(CONFIG);
conf.addResource(fileResource);
//two spaces one after "this", one before "contains"
assertEquals("this contains a comment", conf.get("my.comment"));
}
use of java.io.BufferedWriter in project hadoop by apache.
the class TestConfiguration method testRelativeIncludes.
public void testRelativeIncludes() throws Exception {
tearDown();
String relConfig = new File("./tmp/test-config.xml").getAbsolutePath();
String relConfig2 = new File("./tmp/test-config2.xml").getAbsolutePath();
new File(new File(relConfig).getParent()).mkdirs();
out = new BufferedWriter(new FileWriter(relConfig2));
startConfig();
appendProperty("a", "b");
endConfig();
out = new BufferedWriter(new FileWriter(relConfig));
startConfig();
// Add the relative path instead of the absolute one.
addInclude(new File(relConfig2).getName());
appendProperty("c", "d");
endConfig();
// verify that the includes file contains all properties
Path fileResource = new Path(relConfig);
conf.addResource(fileResource);
assertEquals(conf.get("a"), "b");
assertEquals(conf.get("c"), "d");
// Cleanup
new File(relConfig).delete();
new File(relConfig2).delete();
new File(new File(relConfig).getParent()).delete();
}
use of java.io.BufferedWriter in project flink by apache.
the class CommonTestUtils method createTempFile.
/**
* Creates a temporary file that contains the given string.
* The file is written with the platform's default encoding.
*
* <p>The temp file is automatically deleted on JVM exit.
*
* @param contents The contents to be written to the file.
* @return The temp file URI.
*/
public static String createTempFile(String contents) throws IOException {
File f = File.createTempFile("flink_test_", ".tmp");
f.deleteOnExit();
try (BufferedWriter out = new BufferedWriter(new FileWriter(f))) {
out.write(contents);
}
return f.toURI().toString();
}
Aggregations