DbusLogAccumulator acc = new DbusLogAccumulator(3);
Logger log = Logger.getLogger(TestDbusLogAccumulator.class);
MyLogger mlog = new MyLogger(TestDbusLogAccumulator.class.getName());
mlog.setLogger(log);
acc.addMessage(new DebugMessage("MSG %d", 1));
acc.addMessage(new DebugMessage("MSG %s", "TWO"));
acc.addMessage(new DebugMessage("MSG 3"));
acc.addMessage(new DebugMessage("MSG %d", 4));
acc.addMessage(new DebugMessage("MSG %s", "FIVE"));
acc.addMessage(new DebugMessage("MSG 6"));
acc.addMessage("MSG 7");
Assert.assertEquals(7, acc.getTotalNumberOfMessages());
Assert.assertEquals(3, acc.getNumberOfMessages());
acc.prettyLog(mlog, Level.ERROR);
Assert.assertFalse(mlog.verifyError("MSG 1"));
Assert.assertFalse(mlog.verifyError("MSG TWO"));
Assert.assertFalse(mlog.verifyError("MSG 3"));
Assert.assertFalse(mlog.verifyError("MSG 4"));
Assert.assertTrue(mlog.verifyError("MSG FIVE"));
Assert.assertTrue(mlog.verifyError("MSG 6"));
Assert.assertTrue(mlog.verifyError("MSG 7"));
acc.reset();
mlog.setLevel(Level.DEBUG);
acc.addMessage(new DebugMessage("MSG1 %d", 1));
acc.addMessage(new DebugMessage("MSG1 %s", "TWO"));
acc.addMessage(new DebugMessage("MSG1 3"));
acc.addMessage(new DebugMessage("MSG1 %d", 4));
acc.addMessage(new DebugMessage("MSG1 %s", "FIVE"));
acc.addMessage(new DebugMessage("MSG1 6"));
acc.addMessage("MSG1 7");
Exception e = new Exception("Exception 1");
acc.addMessage(new DebugMessage("MSG1 %d", 8).setException(e));
Assert.assertEquals(8, acc.getTotalNumberOfMessages());
Assert.assertEquals(3, acc.getNumberOfMessages());