use of org.apache.sling.repoinit.parser.impl.RepoInitParserImpl in project sling by apache.
the class ParserTest method checkResult.
@Test
public void checkResult() throws ParseException, IOException {
final String expected = IOUtils.toString(tc.expected, DEFAULT_ENCODING).trim();
try {
final StringWriter sw = new StringWriter();
final OperationVisitor v = new OperationToStringVisitor(new PrintWriter(sw));
final List<Operation> result = new RepoInitParserImpl(tc.input).parse();
for (Operation o : result) {
o.accept(v);
}
sw.flush();
String actual = sw.toString().trim();
// normalize line endings to ensure tests run on windows as well
actual = actual.replaceAll("\r\n", "\n");
assertEquals(expected, actual);
} finally {
tc.close();
}
}
use of org.apache.sling.repoinit.parser.impl.RepoInitParserImpl in project sling by apache.
the class ParsingErrorsTest method checkResult.
@Test
public void checkResult() throws ParseException, IOException {
final StringReader r = new StringReader(input);
boolean noException = false;
try {
new RepoInitParserImpl(r).parse();
noException = true;
} catch (Exception e) {
assertEquals("for input " + input, expected, e.getClass());
} catch (Error err) {
assertEquals("for input " + input, expected, err.getClass());
} finally {
r.close();
}
if (noException && expected != null) {
fail("Expected a " + expected.getSimpleName() + " for [" + input + "]");
}
}
Aggregations