/** * Accuracy test case for logError. * * @throws Exception to JUnit */ @SuppressWarnings("unchecked") @Test public void testLogError1() throws Exception { ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); Constructor privateCtor = BasicLog.class.getDeclaredConstructor(String.class, PrintStream.class); privateCtor.setAccessible(true); Log log = (Log) privateCtor.newInstance("name", new PrintStream(byteStream)); Helper.logError(new IllegalArgumentException("test error"), "methodName", log); String out = byteStream.toString(); assertTrue("Should contain 'test error'", out.indexOf("test error") != -1); }
/** * Accuracy test case for logError. * * @throws Exception to JUnit */ @Test public void testLogError2() throws Exception { IllegalArgumentException iae = new IllegalArgumentException("test error"); assertTrue("should be same with iae", iae == Helper.logError(iae, "aa", null)); }