### Question:
ACLFileParser { public static AuthorizationsCollector parse(File file) throws ParseException { if (file == null) { LOG.warn("parsing NULL file, so fallback on default configuration!"); return AuthorizationsCollector.emptyImmutableCollector(); } if (!file.exists()) { LOG.warn( String.format( "parsing not existing file %s, so fallback on default configuration!", file.getAbsolutePath())); return AuthorizationsCollector.emptyImmutableCollector(); } try { Reader reader = Files.newBufferedReader(file.toPath(), UTF_8); return parse(reader); } catch (IOException fex) { LOG.warn( String.format( "parsing not existing file %s, so fallback on default configuration!", file.getAbsolutePath()), fex); return AuthorizationsCollector.emptyImmutableCollector(); } } private  ACLFileParser(); static AuthorizationsCollector parse(File file); static AuthorizationsCollector parse(Reader reader);  }### Answer:
@Test public void testParseEmpty() throws ParseException { Reader conf = new StringReader(" "); AuthorizationsCollector authorizations = ACLFileParser.parse(conf); assertTrue(authorizations.isEmpty()); }
@Test public void testParseValidComment() throws ParseException { Reader conf = new StringReader("#simple comment"); AuthorizationsCollector authorizations = ACLFileParser.parse(conf); assertTrue(authorizations.isEmpty()); }
@Test(expected = ParseException.class) public void testParseInvalidPaddedComment() throws ParseException { Reader conf = new StringReader(" #simple comment"); AuthorizationsCollector authorizations = ACLFileParser.parse(conf); assertTrue(authorizations.isEmpty()); }
@Test public void testParseSingleLineACL() throws ParseException { Reader conf = new StringReader("topic /weather/italy/anemometer"); AuthorizationsCollector authorizations = ACLFileParser.parse(conf); assertTrue(authorizations.canRead(new Topic("/weather/italy/anemometer"), "", "")); 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); 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); 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); assertTrue(authorizations.canRead(new Topic("/weather/+/anemometer"), "", "")); assertTrue(authorizations.canWrite(new Topic("/weather/+/anemometer"), "", "")); }