SeverityComparator implements Comparator<LogRecord>, Serializable { private static String toString(final Object o1, final Object o2) { return o1 + ", " + o2; }  Throwable apply(final Throwable chain); final int applyThenCompare(Throwable tc1, Throwable tc2); int compareThrowable(final Throwable t1, final Throwable t2); int compare(final LogRecord o1, final LogRecord o2); @Override boolean equals(final Object o); @Override int hashCode(); boolean isNormal(final Throwable t);  }
@Test public void testByThrownAndInterruptedSub() { LogRecord r1 = new LogRecord(Level.INFO, Level.INFO.toString()); LogRecord r2 = new LogRecord(Level.INFO, Level.INFO.toString()); swapSeq(r1, r2); assertTrue(r1.getSequenceNumber() > r2.getSequenceNumber()); r1.setThrown(headSubIeChain(null)); r2.setThrown(new Error()); assertRecordLessThan(r1, r2); assertTrue(r1.getSequenceNumber() > r2.getSequenceNumber()); r1.setThrown(headSubIeChain(null)); r2.setThrown(new RuntimeException()); assertRecordLessThan(r1, r2); assertTrue(r1.getSequenceNumber() > r2.getSequenceNumber()); r1.setThrown(headSubIeChain(null)); r2.setThrown(new Exception()); assertRecordLessThan(r1, r2); assertTrue(r1.getSequenceNumber() > r2.getSequenceNumber()); r1.setThrown(headSubIeChain(new Error())); r2.setThrown(new Error()); assertRecordLessThan(r1, r2); assertTrue(r1.getSequenceNumber() > r2.getSequenceNumber()); r1.setThrown(headSubIeChain(new RuntimeException())); r2.setThrown(new RuntimeException()); assertRecordLessThan(r1, r2); assertTrue(r1.getSequenceNumber() > r2.getSequenceNumber()); r1.setThrown(headSubIeChain(new Exception())); r2.setThrown(new Exception()); assertRecordLessThan(r1, r2); }
@Test public void testByThrownAndInterruptedIoSub() { LogRecord r1 = new LogRecord(Level.INFO, Level.INFO.toString()); LogRecord r2 = new LogRecord(Level.INFO, Level.INFO.toString()); swapSeq(r1, r2); assertTrue(r1.getSequenceNumber() > r2.getSequenceNumber()); r1.setThrown(headSubIioeChain(null)); r2.setThrown(new Error()); assertRecordLessThan(r1, r2); assertTrue(r1.getSequenceNumber() > r2.getSequenceNumber()); r1.setThrown(headSubIioeChain(null)); r2.setThrown(new RuntimeException()); assertRecordLessThan(r1, r2); assertTrue(r1.getSequenceNumber() > r2.getSequenceNumber()); r1.setThrown(headSubIioeChain(null)); r2.setThrown(new Exception()); assertRecordLessThan(r1, r2); }
@Test public void testByThrownAndThreadDeath() { LogRecord r1 = new LogRecord(Level.INFO, Level.INFO.toString()); LogRecord r2 = new LogRecord(Level.INFO, Level.INFO.toString()); swapSeq(r1, r2); assertTrue(r1.getSequenceNumber() > r2.getSequenceNumber()); r1.setThrown(headTdChain(null)); r2.setThrown(new Error()); assertRecordLessThan(r1, r2); assertTrue(r1.getSequenceNumber() > r2.getSequenceNumber()); r1.setThrown(headTdChain(null)); r2.setThrown(new RuntimeException()); assertRecordLessThan(r1, r2); assertTrue(r1.getSequenceNumber() > r2.getSequenceNumber()); r1.setThrown(headTdChain(null)); r2.setThrown(new Exception()); assertRecordLessThan(r1, r2); assertTrue(r1.getSequenceNumber() > r2.getSequenceNumber()); r1.setThrown(headTdChain(new Error())); r2.setThrown(new Error()); assertRecordLessThan(r1, r2); assertTrue(r1.getSequenceNumber() > r2.getSequenceNumber()); r1.setThrown(headTdChain(new RuntimeException())); r2.setThrown(new RuntimeException()); assertRecordLessThan(r1, r2); assertTrue(r1.getSequenceNumber() > r2.getSequenceNumber()); r1.setThrown(headTdChain(new Exception())); r2.setThrown(new Exception()); assertRecordLessThan(r1, r2); }
@Test public void testByThrownAndThreadDeathSub() { LogRecord r1 = new LogRecord(Level.INFO, Level.INFO.toString()); LogRecord r2 = new LogRecord(Level.INFO, Level.INFO.toString()); swapSeq(r1, r2); assertTrue(r1.getSequenceNumber() > r2.getSequenceNumber()); r1.setThrown(headSubTdChain(null)); r2.setThrown(new Error()); assertRecordLessThan(r1, r2); assertTrue(r1.getSequenceNumber() > r2.getSequenceNumber()); r1.setThrown(headSubTdChain(null)); r2.setThrown(new RuntimeException()); assertRecordLessThan(r1, r2); assertTrue(r1.getSequenceNumber() > r2.getSequenceNumber()); r1.setThrown(headSubTdChain(null)); r2.setThrown(new Exception()); assertRecordLessThan(r1, r2); assertTrue(r1.getSequenceNumber() > r2.getSequenceNumber()); r1.setThrown(headSubTdChain(new Error())); r2.setThrown(new Error()); assertRecordLessThan(r1, r2); assertTrue(r1.getSequenceNumber() > r2.getSequenceNumber()); r1.setThrown(headSubTdChain(new RuntimeException())); r2.setThrown(new RuntimeException()); assertRecordLessThan(r1, r2); assertTrue(r1.getSequenceNumber() > r2.getSequenceNumber()); r1.setThrown(headSubTdChain(new Exception())); r2.setThrown(new Exception()); assertRecordLessThan(r1, r2); }
@Test public void testOfClassLoadReadFailed() { Throwable clrf = new NoClassDefFoundError().initCause( new ClassNotFoundException("", new IOException())); Throwable readFailed = new IOException(); LogRecord r1 = new LogRecord(Level.INFO, Level.INFO.toString()); LogRecord r2 = new LogRecord(Level.INFO, Level.INFO.toString()); r1.setThrown(readFailed); r2.setThrown(clrf); assertRecordLessThan(r1, r2); r1.setThrown(clrf); r2.setThrown(readFailed); assertRecordLessThan(r2, r1); }
@Test public void testOfClassLoadInterrupted() { Throwable cli = new NoClassDefFoundError().initCause( new ClassNotFoundException("", headIioeChain(null))); Throwable iioe = headIioeChain(null); LogRecord r1 = new LogRecord(Level.INFO, Level.INFO.toString()); LogRecord r2 = new LogRecord(Level.INFO, Level.INFO.toString()); r1.setThrown(iioe); r2.setThrown(cli); assertRecordLessThan(r1, r2); r1.setThrown(cli); r2.setThrown(iioe); assertRecordLessThan(r2, r1); }
@Test public void testOfNpeVsIoe() { Throwable readFailed = new IOException(); Throwable npe = new IOException().initCause(new NullPointerException()); LogRecord r1 = new LogRecord(Level.INFO, Level.INFO.toString()); LogRecord r2 = new LogRecord(Level.INFO, Level.INFO.toString()); r1.setThrown(readFailed); r2.setThrown(npe); assertRecordLessThan(r1, r2); r1.setThrown(npe); r2.setThrown(readFailed); assertRecordLessThan(r2, r1); }
@Test public void testToString() { final SeverityComparator a = new SeverityComparator(); assertNotNull(a.toString()); assertEquals(a.toString(), a.toString()); }
@Test public void testLeadingErrorAndInterrupted() { LogRecord r1 = new LogRecord(Level.INFO, Level.INFO.toString()); LogRecord r2 = new LogRecord(Level.INFO, Level.INFO.toString()); swapSeq(r1, r2); assertEquals(r1.getLevel(), r2.getLevel()); assertTrue(r1.getSequenceNumber() > r2.getSequenceNumber()); r1.setThrown(headIeChain(new Error())); r2.setThrown(new Error(headIeChain(null))); assertRecordLessThan(r1, r2); r1.setThrown(headIeChain(new RuntimeException())); r2.setThrown(new Error(headIeChain(null))); assertRecordLessThan(r1, r2); r1.setThrown(headIeChain(new Exception())); r2.setThrown(new Error(headIeChain(null))); assertRecordLessThan(r1, r2); }
@Test public void testByLevel() { LogRecord r1 = new LogRecord(Level.INFO, Level.INFO.toString()); LogRecord r2 = new LogRecord(Level.WARNING, Level.WARNING.toString()); assertTrue(r1.getSequenceNumber() < r2.getSequenceNumber()); assertRecordLessThan(r1, r2); r1.setThrown(new Error()); r2.setThrown(null); assertRecordLessThan(r1, r2); assertEquals(Error.class, r1.getThrown().getClass()); r2.setThrown(new Error()); assertRecordLessThan(r1, r2); assertEquals(Error.class, r1.getThrown().getClass()); r2.setThrown(new RuntimeException()); assertRecordLessThan(r1, r2); assertEquals(Error.class, r1.getThrown().getClass()); r2.setThrown(new Exception()); assertRecordLessThan(r1, r2); assertEquals(Error.class, r1.getThrown().getClass()); r2.setThrown(new InterruptedException()); assertRecordLessThan(r1, r2); r1.setThrown(new RuntimeException()); r2.setThrown(null); assertRecordLessThan(r1, r2); assertEquals(RuntimeException.class, r1.getThrown().getClass()); r2.setThrown(new Error()); assertRecordLessThan(r1, r2); assertEquals(RuntimeException.class, r1.getThrown().getClass()); r2.setThrown(new RuntimeException()); assertRecordLessThan(r1, r2); assertEquals(RuntimeException.class, r1.getThrown().getClass()); r2.setThrown(new Exception()); assertRecordLessThan(r1, r2); assertEquals(RuntimeException.class, r1.getThrown().getClass()); r2.setThrown(new InterruptedException()); assertRecordLessThan(r1, r2); r1.setThrown(new Exception()); r2.setThrown(null); assertRecordLessThan(r1, r2); assertEquals(Exception.class, r1.getThrown().getClass()); r2.setThrown(new Error()); assertRecordLessThan(r1, r2); assertEquals(Exception.class, r1.getThrown().getClass()); r2.setThrown(new RuntimeException()); assertRecordLessThan(r1, r2); assertEquals(Exception.class, r1.getThrown().getClass()); r2.setThrown(new Exception()); assertRecordLessThan(r1, r2); assertEquals(Exception.class, r1.getThrown().getClass()); r2.setThrown(new InterruptedException()); assertRecordLessThan(r1, r2); swapSeq(r1, r2); assertTrue(r1.getSequenceNumber() > r2.getSequenceNumber()); assertRecordLessThan(r1, r2); r1.setThrown(null); r2.setThrown(null); assertTrue(r1.getSequenceNumber() > r2.getSequenceNumber()); assertRecordLessThan(r1, r2); }
@Test public void testByNullAndFrameworkInterrupted() { LogRecord r1 = new LogRecord(Level.INFO, Level.INFO.toString()); LogRecord r2 = new LogRecord(Level.INFO, Level.INFO.toString()); assertEquals(r1.getLevel(), r2.getLevel()); r1.setThrown(this.headWidChain(null)); assertNull(r2.getThrown()); assertRecordLessThan(r1, r2); r1.setThrown(this.headWidChain(new Error())); assertNull(r2.getThrown()); assertRecordLessThan(r1, r2); r1.setThrown(this.headWidChain(new RuntimeException())); assertNull(r2.getThrown()); assertRecordLessThan(r1, r2); r1.setThrown(this.headWidChain(new Exception())); assertNull(r2.getThrown()); assertRecordLessThan(r1, r2); }
@Test public void testByNullAndInterrupted() { LogRecord r1 = new LogRecord(Level.INFO, Level.INFO.toString()); LogRecord r2 = new LogRecord(Level.INFO, Level.INFO.toString()); assertEquals(r1.getLevel(), r2.getLevel()); r1.setThrown(headIeChain(null)); assertNull(r2.getThrown()); assertRecordLessThan(r1, r2); r1.setThrown(headIeChain(new Error())); assertNull(r2.getThrown()); assertRecordLessThan(r1, r2); r1.setThrown(headIeChain(new RuntimeException())); assertNull(r2.getThrown()); assertRecordLessThan(r1, r2); r1.setThrown(headIeChain(new Exception())); assertNull(r2.getThrown()); assertRecordLessThan(r1, r2); }
@Test public void testByNullAndInterruptedSub() { LogRecord r1 = new LogRecord(Level.INFO, Level.INFO.toString()); LogRecord r2 = new LogRecord(Level.INFO, Level.INFO.toString()); assertEquals(r1.getLevel(), r2.getLevel()); r1.setThrown(headSubIeChain(null)); assertNull(r2.getThrown()); assertRecordLessThan(r1, r2); r1.setThrown(headSubIeChain(new Error())); assertNull(r2.getThrown()); assertRecordLessThan(r1, r2); r1.setThrown(headSubIeChain(new RuntimeException())); assertNull(r2.getThrown()); assertRecordLessThan(r1, r2); r1.setThrown(headSubIeChain(new Exception())); assertNull(r2.getThrown()); assertRecordLessThan(r1, r2); }
@Test public void testByNullAndInterruptedIo() { LogRecord r1 = new LogRecord(Level.INFO, Level.INFO.toString()); LogRecord r2 = new LogRecord(Level.INFO, Level.INFO.toString()); assertEquals(r1.getLevel(), r2.getLevel()); r1.setThrown(headIioeChain(null)); assertNull(r2.getThrown()); assertRecordLessThan(r1, r2); r1.setThrown(headIioeChain(new Error())); assertNull(r2.getThrown()); assertRecordLessThan(r1, r2); r1.setThrown(headIioeChain(new RuntimeException())); assertNull(r2.getThrown()); assertRecordLessThan(r1, r2); r1.setThrown(headIioeChain(new Exception())); assertNull(r2.getThrown()); assertRecordLessThan(r1, r2); }
@Test public void testByNullAndInterruptedIoSub() { LogRecord r1 = new LogRecord(Level.INFO, Level.INFO.toString()); LogRecord r2 = new LogRecord(Level.INFO, Level.INFO.toString()); assertEquals(r1.getLevel(), r2.getLevel()); r1.setThrown(headSubIioeChain(null)); assertNull(r2.getThrown()); assertRecordLessThan(r1, r2); r1.setThrown(headSubIioeChain(new Error())); assertNull(r2.getThrown()); assertRecordLessThan(r1, r2); r1.setThrown(headSubIioeChain(new RuntimeException())); assertNull(r2.getThrown()); assertRecordLessThan(r1, r2); r1.setThrown(headSubIioeChain(new Exception())); assertNull(r2.getThrown()); assertRecordLessThan(r1, r2); }
@Test public void testByNullAndThreadDeath() { LogRecord r1 = new LogRecord(Level.INFO, Level.INFO.toString()); LogRecord r2 = new LogRecord(Level.INFO, Level.INFO.toString()); assertEquals(r1.getLevel(), r2.getLevel()); r1.setThrown(headTdChain(null)); assertNull(r2.getThrown()); assertRecordLessThan(r1, r2); r1.setThrown(headTdChain(new Error())); assertNull(r2.getThrown()); assertRecordLessThan(r1, r2); r1.setThrown(headTdChain(new RuntimeException())); assertNull(r2.getThrown()); assertRecordLessThan(r1, r2); r1.setThrown(headTdChain(new Exception())); assertNull(r2.getThrown()); assertRecordLessThan(r1, r2); }
@Test public void testByNullAndThreadDeathSub() { LogRecord r1 = new LogRecord(Level.INFO, Level.INFO.toString()); LogRecord r2 = new LogRecord(Level.INFO, Level.INFO.toString()); assertEquals(r1.getLevel(), r2.getLevel()); r1.setThrown(headSubTdChain(null)); assertNull(r2.getThrown()); assertRecordLessThan(r1, r2); r1.setThrown(headSubTdChain(new Error())); assertNull(r2.getThrown()); assertRecordLessThan(r1, r2); r1.setThrown(headSubTdChain(new RuntimeException())); assertNull(r2.getThrown()); assertRecordLessThan(r1, r2); r1.setThrown(headSubTdChain(new Exception())); assertNull(r2.getThrown()); assertRecordLessThan(r1, r2); }
@Test public void testByNullAndThrown() { LogRecord r1 = new LogRecord(Level.INFO, Level.INFO.toString()); LogRecord r2 = new LogRecord(Level.INFO, Level.INFO.toString()); r1.setSequenceNumber(r2.getSequenceNumber()); r1.setMillis(r2.getMillis()); assertEquals(r1.getLevel(), r2.getLevel()); assertEquals(r1.getSequenceNumber(), r2.getSequenceNumber()); assertEquals(r1.getMillis(), r2.getMillis()); assertNull(r1.getThrown()); r2.setThrown(new Error()); assertRecordLessThan(r1, r2); assertNull(r1.getThrown()); r2.setThrown(new RuntimeException()); assertRecordLessThan(r1, r2); assertNull(r1.getThrown()); r2.setThrown(new Exception()); assertRecordLessThan(r1, r2); }
@Test public void testByNullAndNullSeq() { LogRecord r1 = new LogRecord(Level.INFO, Level.INFO.toString()); LogRecord r2 = new LogRecord(Level.INFO, Level.INFO.toString()); assertTrue(r1.getSequenceNumber() < r2.getSequenceNumber()); assertNull(r1.getThrown()); assertNull(r2.getThrown()); assertRecordLessThan(r1, r2); }
@Test public void testByThrownAndThrownSeq() { LogRecord r1 = new LogRecord(Level.INFO, Level.INFO.toString()); LogRecord r2 = new LogRecord(Level.INFO, Level.INFO.toString()); assertTrue(r1.getSequenceNumber() < r2.getSequenceNumber()); assertTrue(r1.getSequenceNumber() < r2.getSequenceNumber()); r1.setThrown(new Error()); r2.setThrown(new Error()); assertRecordLessThan(r1, r2); assertTrue(r1.getSequenceNumber() < r2.getSequenceNumber()); r1.setThrown(new RuntimeException()); r2.setThrown(new RuntimeException()); assertRecordLessThan(r1, r2); assertTrue(r1.getSequenceNumber() < r2.getSequenceNumber()); r1.setThrown(new Exception()); r2.setThrown(new Exception()); assertRecordLessThan(r1, r2); }
@Test public void testByThrownAndInterrupted() { LogRecord r1 = new LogRecord(Level.INFO, Level.INFO.toString()); LogRecord r2 = new LogRecord(Level.INFO, Level.INFO.toString()); swapSeq(r1, r2); assertTrue(r1.getSequenceNumber() > r2.getSequenceNumber()); r1.setThrown(headIeChain(null)); r2.setThrown(new Error()); assertRecordLessThan(r1, r2); assertTrue(r1.getSequenceNumber() > r2.getSequenceNumber()); r1.setThrown(headIeChain(null)); r2.setThrown(new RuntimeException()); assertRecordLessThan(r1, r2); assertTrue(r1.getSequenceNumber() > r2.getSequenceNumber()); r1.setThrown(headIeChain(null)); r2.setThrown(new Exception()); assertRecordLessThan(r1, r2); assertTrue(r1.getSequenceNumber() > r2.getSequenceNumber()); r1.setThrown(headIeChain(new Error())); r2.setThrown(new Error()); assertRecordLessThan(r1, r2); assertTrue(r1.getSequenceNumber() > r2.getSequenceNumber()); r1.setThrown(headIeChain(new RuntimeException())); r2.setThrown(new RuntimeException()); assertRecordLessThan(r1, r2); assertTrue(r1.getSequenceNumber() > r2.getSequenceNumber()); r1.setThrown(headIeChain(new Exception())); r2.setThrown(new Exception()); assertRecordLessThan(r1, r2); }