use of com.tvd12.properties.file.writer.BaseFileWriter in project properties-file by tvd12.
the class PropertiesFileWriterTest method test.
@Test
public void test() throws PropertiesFileException {
Properties properties = new Properties();
properties.setProperty("hello", "word");
new BaseFileWriter().write(properties, "hello.output_test");
}
use of com.tvd12.properties.file.writer.BaseFileWriter in project properties-file by tvd12.
the class BaseFileWriterTest method test1.
@Test
public void test1() {
String filePath1 = "BaseFileWriterTestFile1.txt";
File file1 = new File(filePath1);
if (file1.exists())
file1.delete();
Properties properties = new Properties();
properties.setProperty("a", "1");
properties.setProperty("b", "2");
BaseFileWriter fileWriter = new BaseFileWriter();
fileWriter.write(properties, file1);
}
use of com.tvd12.properties.file.writer.BaseFileWriter in project properties-file by tvd12.
the class BaseFileWriterTest method test3.
@Test(expectedExceptions = { PropertiesFileException.class })
public void test3() {
String filePath1 = "BaseFileWriterTestFile3.txt";
final File file1 = new File(filePath1);
if (file1.exists())
file1.delete();
Properties properties = new Properties();
properties.setProperty("a", "1");
properties.setProperty("b", "2");
BaseFileWriter fileWriter = new BaseFileWriter() {
@Override
protected FileOutputStream newFileOutputStream(File file) throws FileNotFoundException {
return new FileOutputStream(file) {
@Override
public void write(byte[] b) throws IOException {
throw new IOException();
}
};
}
};
fileWriter.write(properties, file1);
}
use of com.tvd12.properties.file.writer.BaseFileWriter in project properties-file by tvd12.
the class BaseFileWriterTest method test4.
@Test(expectedExceptions = { PropertiesFileException.class })
public void test4() {
String filePath1 = "BaseFileWriterTestFile3.txt";
final File file1 = new File(filePath1);
if (file1.exists())
file1.delete();
Properties properties = new Properties();
properties.setProperty("a", "1");
properties.setProperty("b", "2");
BaseFileWriter fileWriter = new BaseFileWriter() {
@Override
protected FileOutputStream newFileOutputStream(File file) throws FileNotFoundException {
return new FileOutputStream(file) {
@Override
public void close() throws IOException {
throw new IOException();
}
};
}
};
fileWriter.write(properties, file1);
}
use of com.tvd12.properties.file.writer.BaseFileWriter in project properties-file by tvd12.
the class PropertiesFileWriterTest method writeToOuputStreamInvalidCase.
@Test(expectedExceptions = { PropertiesFileException.class })
public void writeToOuputStreamInvalidCase() throws PropertiesFileException, IOException {
Properties properties = mock(Properties.class);
doThrow(IOException.class).when(properties).store(any(OutputStream.class), any(String.class));
new BaseFileWriter().write(properties);
}
Aggregations