try {
// given
File testFile = new File("src/test/java/org/junithelper/core/generator/IndentationProviderTest.java");
FileWriter writer = FileWriterFactory.create(testFile);
String preparedSource = IOUtil.readAsString(
IOUtil.getResourceAsStream("IndentationProviderTestBefore.txt"), "UTF-8");
writer.writeText(preparedSource);
// when
String[] args = new String[] { "src/main/java/org/junithelper/core/generator/IndentationProvider.java" };
System.setProperty("junithelper.skipConfirming", "true");
System.setProperty("junithelper.configProperties",
"src/test/resources/junithelper-config_softTabs.properties");
MakeTestCommand.main(args);
// then
Thread.sleep(100L);
InputStream is = new FileInputStream(testFile);
String source = IOUtil.readAsString(is, "UTF-8");
String expected = IOUtil.readAsString(IOUtil
.getResourceAsStream("IndentationProviderTestSoftTabsSize2.txt"), "UTF-8");
assertThat(source, is(equalTo(expected))); // TEST
} finally {
File testFile = new File("src/test/java/org/junithelper/core/generator/IndentationProviderTest.java");
FileWriter writer = FileWriterFactory.create(testFile);
String preparedSource = IOUtil.readAsString(IOUtil.getResourceAsStream("IndentationProviderTestAfter.txt"),
"UTF-8");
writer.writeText(preparedSource);
}
}