use of com.tvd12.properties.file.exception.PropertiesFileException in project properties-file by tvd12.
the class BaseFileWriter method write.
/* (non-Javadoc)
* @see com.tvd12.properties.file.writer.FileWriter#write(java.util.Properties, java.io.File)
*/
@Override
public void write(Properties properties, File file) {
try (ByteArrayOutputStream out = write(properties)) {
if (!file.exists()) {
file.createNewFile();
}
byte[] bytes = encode(out);
writeBytes0(file, bytes);
} catch (IOException e) {
throw new PropertiesFileException("Can not write properties to file", e);
}
}
use of com.tvd12.properties.file.exception.PropertiesFileException in project properties-file by tvd12.
the class PropertiesFileReaderTest method loadInputStreamTest.
@SuppressWarnings("unchecked")
@Test(expectedExceptions = { PropertiesFileException.class })
public void loadInputStreamTest() throws PropertiesFileException, IOException {
InputStream stream = mock(InputStream.class);
when(stream.read()).thenThrow(IOException.class);
new BaseFileReader().loadInputStream(stream);
}
use of com.tvd12.properties.file.exception.PropertiesFileException 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);
}
use of com.tvd12.properties.file.exception.PropertiesFileException in project properties-file by tvd12.
the class PropertiesFileReaderTest method testWithValidData2.
@Test
public void testWithValidData2() throws PropertiesFileException {
File file = new File(getClass().getClassLoader().getResource("classes.properties").getFile());
assertNotNull(new BaseFileReader().read(Lists.newArrayList(file, file)));
assertNotNull(new BaseFileReader().read(Lists.newArrayList(file, file)));
}
use of com.tvd12.properties.file.exception.PropertiesFileException 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");
}
Aggregations