public void asssertContainsException(Class<?> scanExceptionClass) { assertTrue(containsException(scanExceptionClass)); }
@Test public void withCorruptFile() throws JoranException, IOException { String tmpOut = copyToTemp(INVALID); System.setProperty(INCLUDE_KEY, tmpOut); tc.doConfigure(TOP_BY_FILE); assertEquals(Status.ERROR, statusChecker.getHighestLevel(0)); assertTrue(statusChecker.containsException(SAXParseException.class)); // we like to erase the temp file in order to see // if http://jira.qos.ch/browse/LBCORE-122 was fixed File f = new File(tmpOut); assertTrue(f.exists()); assertTrue(f.delete()); }
@Test public void malformedURL() throws JoranException { System.setProperty(INCLUDE_KEY, "htp://logback.qos.ch"); tc.doConfigure(TOP_BY_URL); assertEquals(Status.ERROR, statusChecker.getHighestLevel(0)); assertTrue(statusChecker.containsException(MalformedURLException.class)); }
@Test public void charset() { setter.setProperty("charset", "UTF-8"); assertEquals(Charset.forName("UTF-8"), house.getCharset()); house.setCharset(null); setter.setProperty("charset", "UTF"); assertNull(house.getCharset()); StatusChecker checker = new StatusChecker(context); checker.containsException(UnsupportedCharsetException.class); } }
@Test public void errorsOutForInvalidXmlAtFoundPath() throws JoranException { final String xml = "<x>" + "<findInclude>" + "<include file='"+ INVALID +"'/>" + "<include file='nonexistent.txt'/>" + "<include file='"+ SECOND_FILE +"'/>" + "</findInclude>" + "<stack name='C'/>" + "</x>"; final ByteArrayInputStream stream = new ByteArrayInputStream(xml.getBytes()); tc.doConfigure(stream); assertEquals(Status.ERROR, statusChecker.getHighestLevel(0)); assertTrue(statusChecker.containsException(SAXParseException.class)); verifyConfig("C"); }