package de.superx.sec; import java.util.Set; import org.junit.Assert; import org.junit.Test; public class HttpGetAccessListParserTest { @Test public void testParser() { String validInput = "# ein Kommentar\n\n \r#comment\r1234\r\n"; Set validList = HttpGetAccessListParser.parseList(validInput); Assert.assertTrue("id '1234' should be parsed from input", validList.contains(Integer.valueOf(1234))); Assert.assertFalse("id '123' should _not_ be parsed from input", validList.contains(Integer.valueOf(123))); String invalidInput = "# ein Kommentar\n12a34\n \r#comment\r1234\r\n"; Set invalidList = null; try { invalidList = HttpGetAccessListParser.parseList(invalidInput); } catch(NumberFormatException e) { // exception should be thrown :) } Assert.assertNull("'invalidList' should _not_ have been parsed and this be 'null'", invalidList); } }