### Question:
DailyLogListener extends RotateLogListener { protected void logDebugEx(String msg, Throwable e){ ByteArrayOutputStream os = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(os); ps.println(msg); e.printStackTrace(ps); ps.close(); logDebug(os.toString()); } DailyLogListener(); void setConfiguration(Configuration cfg); void deleteOldLogs(); String getSuffix(); void setSuffix(String suffix); String getPrefix(); void setPrefix(String prefix); int getRotateCount(); void setRotateCount(int rotateCount); DateFormat getDateFmt(); void setDateFmt(DateFormat dateFmt); String getLastDate(); void setLastDate(String lastDate); String getCompressedSuffix(); void setCompressedSuffix(String compressedSuffix); long getMaxAge(); void setMaxAge(long maxAge); String getDeleteRegex(); void setDeleteRegex(String deleteRegex); int getCompressionFormat(); void setCompressionFormat(int compressionFormat); int getCompressionBufferSize(); void setCompressionBufferSize(int compressionBufferSize);  }### Answer:
@Test public void testLogDebugEx() throws Throwable { DailyLogListener dailyLogListener = new DailyLogListener(); dailyLogListener.logDebugEx("testDailyLogListenerMsg", new NullPointerException("testDailyLogListenerParam1")); assertNotNull(dailyLogListener.p, "dailyLogListener.p"); }
@Test public void testLogDebugExThrowsNullPointerException() throws Throwable { DailyLogListener dailyLogListener = new DailyLogListener(); try { dailyLogListener.logDebugEx("testDailyLogListenerMsg", null); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getMessage(), "ex.getMessage()"); } else { assertEquals("Cannot invoke \"java.lang.Throwable.printStackTrace(java.io.PrintStream)\" because \"e\" is null", ex.getMessage(), "ex.getMessage()"); } assertNotNull(dailyLogListener.p, "dailyLogListener.p"); } }