#310 - Allow for topic/patterns with '#' and end of line comments

This commit is contained in:
Gustavo De Micheli
2017-08-23 09:43:51 +02:00
parent c81fab62e6
commit 89174178c6
2 changed files with 56 additions and 18 deletions
@@ -44,9 +44,12 @@ public class ACLFileParserTest {
}
@Test(expected = ParseException.class)
public void testParseInvalidComment() throws ParseException {
public void testParseInvalidPaddedComment() throws ParseException {
Reader conf = new StringReader(" #simple comment");
ACLFileParser.parse(conf);
AuthorizationsCollector authorizations = ACLFileParser.parse(conf);
// Verify
assertTrue(authorizations.isEmpty());
}
@Test
@@ -59,4 +62,33 @@ public class ACLFileParserTest {
assertTrue(authorizations.canWrite(new Topic("/weather/italy/anemometer"), "", ""));
}
@Test
public void testParseValidEndLineComment() throws ParseException {
Reader conf = new StringReader("topic /weather/italy/anemometer #simple comment");
AuthorizationsCollector authorizations = ACLFileParser.parse(conf);
// Verify
assertTrue(authorizations.canRead(new Topic("/weather/italy/anemometer"), "", ""));
assertTrue(authorizations.canWrite(new Topic("/weather/italy/anemometer"), "", ""));
}
@Test
public void testParseValidPoundTopicWithEndLineComment() throws ParseException {
Reader conf = new StringReader("topic /weather/italy/anemometer/# #simple comment");
AuthorizationsCollector authorizations = ACLFileParser.parse(conf);
// Verify
assertTrue(authorizations.canRead(new Topic("/weather/italy/anemometer/#"), "", ""));
assertTrue(authorizations.canWrite(new Topic("/weather/italy/anemometer/#"), "", ""));
}
@Test
public void testParseValidPlusTopicWithEndLineComment() throws ParseException {
Reader conf = new StringReader("topic /weather/+/anemometer #simple comment");
AuthorizationsCollector authorizations = ACLFileParser.parse(conf);
// Verify
assertTrue(authorizations.canRead(new Topic("/weather/+/anemometer"), "", ""));
assertTrue(authorizations.canWrite(new Topic("/weather/+/anemometer"), "", ""));
}
}