[logback-dev] svn commit: r1819 - in logback/trunk: logback-access/src/test/java/ch/qos/logback/access/jetty logback-classic/src/main/java/ch/qos/logback/classic/pattern logback-classic/src/main/java/ch/qos/logback/classic/spi logback-classic/src/test/java/ch/qos/logback/classic logback-classic/src/test/java/ch/qos/logback/classic/net logback-classic/src/test/java/ch/qos/logback/classic/pattern logback-classic/src/test/java/ch/qos/logback/classic/spi logback-classic/src/test/java/ch/qos/logback/classic/spi/special logback-core/src/test/java/ch/qos/logback/core/pattern/parser

noreply.ceki at qos.ch noreply.ceki at qos.ch
Wed Oct 1 15:03:39 CEST 2008


Author: ceki
Date: Wed Oct  1 15:03:39 2008
New Revision: 1819

Added:
   logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/PackagingDataCalculator.java
      - copied, changed from r1817, /logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/ClassPackagingDataCalculator.java
Removed:
   logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/ClassPackagingDataCalculator.java
Modified:
   logback/trunk/logback-access/src/test/java/ch/qos/logback/access/jetty/JettyBasicTest.java
   logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ExtendedThrowableProxyConverter.java
   logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ThrowableProxyConverter.java
   logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/ClassPackagingData.java
   logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/StackTraceElementProxy.java
   logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/ThrowableProxy.java
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/PackageTest.java
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/PatternLayoutTest.java
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketAppenderTest.java
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ExtendedThrowableProxyConverterTest.java
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/BasicCPDCTest.java
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/LoggingEventSerializationTest.java
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/special/CPDCSpecialImpl.java
   logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/AbstractPatternLayoutBaseTest.java
   logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/PackageTest.java
   logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/SamplePatternLayoutTest.java

Log:
- migrate some tests to junit4
- renamed ClassPackagingDataCalculator as PackagingDataCalculator
- added calculatePackagingData method to ThrowableProxy so that converters can
  force calculation of packaging data
- added relevant test cases

Modified: logback/trunk/logback-access/src/test/java/ch/qos/logback/access/jetty/JettyBasicTest.java
==============================================================================
--- logback/trunk/logback-access/src/test/java/ch/qos/logback/access/jetty/JettyBasicTest.java	(original)
+++ logback/trunk/logback-access/src/test/java/ch/qos/logback/access/jetty/JettyBasicTest.java	Wed Oct  1 15:03:39 2008
@@ -22,7 +22,7 @@
   
   @BeforeClass
   static public void startServer() throws Exception {
-    System.out.println("*** JettyBasicTest.startServer called");
+    //System.out.println("*** JettyBasicTest.startServer called");
     requestLogImpl = new RequestLogImpl();
     JettyFixture fixture = new JettyFixture(requestLogImpl);
     fixture.start();
@@ -30,7 +30,7 @@
   
   @AfterClass
   static  public void stopServer() throws Exception {
-    System.out.println("*** JettyBasicTest.stopServer called");
+    //System.out.println("*** JettyBasicTest.stopServer called");
     if(fixture != null) {
       fixture.stop();
     }
@@ -59,7 +59,7 @@
     String result = Util.readToString(connection.getInputStream());
 
     assertEquals("hello world", result);
-
+    //Thread.sleep(100);
     ListAppender appender = (ListAppender) requestLogImpl.getAppender("list");
     assertTrue(appender.list.size()>0);
     AccessEvent event = (AccessEvent) appender.list.get(0);

Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ExtendedThrowableProxyConverter.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ExtendedThrowableProxyConverter.java	(original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ExtendedThrowableProxyConverter.java	Wed Oct  1 15:03:39 2008
@@ -10,20 +10,29 @@
 package ch.qos.logback.classic.pattern;
 
 import ch.qos.logback.classic.spi.ClassPackagingData;
+import ch.qos.logback.classic.spi.LoggingEvent;
 import ch.qos.logback.classic.spi.StackTraceElementProxy;
 import ch.qos.logback.classic.spi.ThrowableDataPoint;
-
+import ch.qos.logback.classic.spi.ThrowableProxy;
 
 public class ExtendedThrowableProxyConverter extends ThrowableProxyConverter {
 
   @Override
   protected void extraData(StringBuilder builder, ThrowableDataPoint tdp) {
+
     StackTraceElementProxy step = tdp.getStackTraceElementProxy();
-    if(step != null) {
+    if (step != null) {
       ClassPackagingData pi = step.getClassPackagingData();
-      if(pi != null) {
-        builder.append(" [").append(pi.getCodeLocation()).append(':').append(pi.getVersion()).append(']');
+      if (pi != null) {
+        builder.append(" [").append(pi.getCodeLocation()).append(':').append(
+            pi.getVersion()).append(']');
       }
     }
   }
+
+  protected void prepareLoggingEvent(LoggingEvent event) {
+    ThrowableProxy tp = event.getThrowableProxy();
+    tp.calculatePackagingData();
+  }
+
 }

Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ThrowableProxyConverter.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ThrowableProxyConverter.java	(original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/pattern/ThrowableProxyConverter.java	Wed Oct  1 15:03:39 2008
@@ -89,6 +89,10 @@
     // nop
   }
   
+  protected void prepareLoggingEvent(LoggingEvent event) {
+    // nop  
+  }
+  
   public String convert(LoggingEvent event) {
     StringBuilder buf = new StringBuilder(32);
 
@@ -134,6 +138,8 @@
       }
     }
 
+    prepareLoggingEvent(event);
+    
     buf.append(tdpArray[0]).append(CoreGlobal.LINE_SEPARATOR);
     for (int i = 1; i < length; i++) {
       String string = tdpArray[i].toString();

Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/ClassPackagingData.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/ClassPackagingData.java	(original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/ClassPackagingData.java	Wed Oct  1 15:03:39 2008
@@ -42,5 +42,37 @@
   public boolean isExact() {
     return exact;
   }
+
+  @Override
+  public int hashCode() {
+    final int PRIME = 31;
+    int result = 1;
+    result = PRIME * result + ((codeLocation == null) ? 0 : codeLocation.hashCode());
+    return result;
+  }
+
+  @Override
+  public boolean equals(Object obj) {
+    if (this == obj)
+      return true;
+    if (obj == null)
+      return false;
+    if (getClass() != obj.getClass())
+      return false;
+    final ClassPackagingData other = (ClassPackagingData) obj;
+    if (codeLocation == null) {
+      if (other.codeLocation != null)
+        return false;
+    } else if (!codeLocation.equals(other.codeLocation))
+      return false;
+    if (exact != other.exact)
+      return false;
+    if (version == null) {
+      if (other.version != null)
+        return false;
+    } else if (!version.equals(other.version))
+      return false;
+    return true;
+  }
   
 }

Copied: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/PackagingDataCalculator.java (from r1817, /logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/ClassPackagingDataCalculator.java)
==============================================================================
--- /logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/ClassPackagingDataCalculator.java	(original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/PackagingDataCalculator.java	Wed Oct  1 15:03:39 2008
@@ -24,13 +24,32 @@
  * @author James Strachan
  * @Ceki G&uuml;lc&uuml;
  */
-public class ClassPackagingDataCalculator {
+public class PackagingDataCalculator {
 
   final static StackTraceElementProxy[] STEP_ARRAY_TEMPLATE = new StackTraceElementProxy[0];
 
   HashMap<String, ClassPackagingData> cache = new HashMap<String, ClassPackagingData>();
 
-  public ClassPackagingDataCalculator() {
+  private static boolean GET_CALLER_CLASS_METHOD_AVAILABLE = false;
+  
+  static {
+    // if either the Reflection class or the getCallerClass method
+    // are unavailable, then we won't invoke Reflection.getCallerClass()
+    // This approach ensures that this class will *run* on JDK's lacking
+    // sun.reflect.Reflection class. However, this class will *not compile*
+    // on JDKs lacking sun.reflect.Reflection.
+    try {
+      Reflection.getCallerClass(2);
+      GET_CALLER_CLASS_METHOD_AVAILABLE = true;
+    } catch(NoClassDefFoundError e) {
+    } catch(NoSuchMethodError e) {
+    } catch(Throwable e) {
+      System.err.println("Unexpected exception");
+      e.printStackTrace();
+    }
+  }
+  
+  public PackagingDataCalculator() {
   }
 
   public void calculate(ThrowableDataPoint[] tdpArray) {
@@ -58,8 +77,11 @@
     
     int missfireCount = 0;
     for (int i = 0; i < commonFrames; i++) {
-      Class callerClass = Reflection.getCallerClass(localFirstCommon + i
+      Class callerClass = null;
+      if(GET_CALLER_CLASS_METHOD_AVAILABLE) {
+        callerClass = Reflection.getCallerClass(localFirstCommon + i
           - missfireCount + 1);
+      }
       StackTraceElementProxy step = stepArray[stepFirstCommon + i];
       String stepClassname = step.ste.getClassName();
       

Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/StackTraceElementProxy.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/StackTraceElementProxy.java	(original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/StackTraceElementProxy.java	Wed Oct  1 15:03:39 2008
@@ -2,8 +2,6 @@
 
 import java.io.Serializable;
 
-
-
 public class StackTraceElementProxy implements Serializable {
 
   private static final long serialVersionUID = -4832130320500439038L;
@@ -11,25 +9,25 @@
   final StackTraceElement ste;
   private String steAsString;
   private ClassPackagingData cpd;
-  
+
   StackTraceElementProxy(StackTraceElement ste) {
-    if(ste == null) {
+    if (ste == null) {
       throw new IllegalArgumentException("ste cannot be null");
     }
     this.ste = ste;
   }
-  
+
   public String getSTEAsString() {
-    if(steAsString == null) {
-      steAsString = "\tat "+ste.toString();
+    if (steAsString == null) {
+      steAsString = "\tat " + ste.toString();
     }
     return steAsString;
   }
-  
+
   void setPackageInfo(ClassPackagingData cpd) {
     this.cpd = cpd;
   }
-  
+
   public ClassPackagingData getClassPackagingData() {
     return cpd;
   }
@@ -48,12 +46,22 @@
     if (getClass() != obj.getClass())
       return false;
     final StackTraceElementProxy other = (StackTraceElementProxy) obj;
-    return ste.equals(other.ste);
+
+    if (!ste.equals(other.ste)) {
+      return false;
+    }
+    if (cpd == null) {
+      if (other.cpd != null) {
+        return false;
+      }
+    } else if (!cpd.equals(other.cpd)) {
+      return false;
+    }
+    return true;
   }
-  
+
   @Override
   public String toString() {
     return getSTEAsString();
   }
-  
 }

Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/ThrowableProxy.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/ThrowableProxy.java	(original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/ThrowableProxy.java	Wed Oct  1 15:03:39 2008
@@ -18,8 +18,9 @@
   private static final long serialVersionUID = 6307784764626694851L;
   private ThrowableDataPoint[] tdpArray;
   private transient final Throwable throwable;
-  private transient ClassPackagingDataCalculator classPackagingDataCalculator;
-
+  private transient PackagingDataCalculator packagingDataCalculator;
+  private boolean calculatedPackageData = false;
+  
   public ThrowableProxy(Throwable throwable) {
     this.throwable = throwable;
     this.tdpArray = ThrowableToDataPointArray.convert(throwable);
@@ -27,18 +28,29 @@
 
   public Throwable getThrowable() {
     return throwable;
-  }
+  } 
 
-  public ClassPackagingDataCalculator getClassPackagingDataCalculator() {
-    // if original instance (non-deserialized), and classPackagingDataCalculator
-    // is not already initialized, then create an instance
+  public PackagingDataCalculator getPackagingDataCalculator() {
+    // if original instance (non-deserialized), and packagingDataCalculator
+    // is not already initialized, then create an instance.
     // here we assume that (throwable == null) for deserialized instances
-    if (throwable != null && classPackagingDataCalculator == null) {
-      classPackagingDataCalculator = new ClassPackagingDataCalculator();
+    if (throwable != null && packagingDataCalculator == null) {
+      packagingDataCalculator = new PackagingDataCalculator();
     }
-    return classPackagingDataCalculator;
+    return packagingDataCalculator;
   }
 
+  public void calculatePackagingData() {
+    if(calculatedPackageData) {
+      return;
+    }
+    PackagingDataCalculator pdc = this.getPackagingDataCalculator();
+    if(pdc != null) {
+      calculatedPackageData = true;
+      pdc.calculate(tdpArray);
+    }
+  }
+	
   /**
    * The data point representation of the throwable proxy.
    */

Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/PackageTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/PackageTest.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/PackageTest.java	Wed Oct  1 15:03:39 2008
@@ -18,7 +18,7 @@
     suite.addTestSuite(LoggerContextTest.class);
     suite.addTestSuite(LoggerPerfTest.class);
     suite.addTest(new JUnit4TestAdapter(DynamicLoggerContextTest.class));
-    suite.addTestSuite(PatternLayoutTest.class);
+    suite.addTest(new JUnit4TestAdapter(PatternLayoutTest.class));
     suite.addTestSuite(BasicLoggerTest.class);
     suite.addTestSuite(MessageFormattingTest.class);
     suite.addTestSuite(MDCTest.class);

Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/PatternLayoutTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/PatternLayoutTest.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/PatternLayoutTest.java	Wed Oct  1 15:03:39 2008
@@ -11,12 +11,13 @@
 
 import static ch.qos.logback.classic.TestConstants.ISO_REGEX;
 import static ch.qos.logback.classic.TestConstants.MAIN_REGEX;
+import static org.junit.Assert.*;
 
 import java.util.ArrayList;
 import java.util.List;
 
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import org.junit.Test;
+
 import ch.qos.logback.classic.pattern.ConverterTest;
 import ch.qos.logback.classic.spi.LoggingEvent;
 import ch.qos.logback.core.Context;
@@ -30,13 +31,10 @@
   LoggingEvent le;
   List optionList = new ArrayList();
 
-  public PatternLayoutTest(String arg0) {
-    super(arg0);
-
+  public PatternLayoutTest() {
+    super();
     Exception ex = new Exception("Bogus exception");
-
     le = makeLoggingEvent(ex);
-    // ex.printStackTrace();
   }
   
   LoggingEvent makeLoggingEvent(Exception ex) {
@@ -53,6 +51,7 @@
     return new PatternLayout();
   }
 
+  @Test
   public void testOK() {
     PatternLayout pl = new PatternLayout();
     pl.setPattern("%d %le [%t] %lo{30} - %m%n");
@@ -66,6 +65,7 @@
     assertTrue(val.matches(regex));
   }
 
+  @Test
   public void testNoExeptionHandler() {
     PatternLayout pl = new PatternLayout();
     pl.setPattern("%m%n");
@@ -76,6 +76,7 @@
     assertTrue(val.contains("java.lang.Exception: Bogus exception"));
   }
 
+  @Test
   public void testCompositePattern() {
     PatternLayout pl = new PatternLayout();
     pl.setPattern("%-56(%d %lo{20}) - %m%n");
@@ -89,6 +90,7 @@
 
   }
   
+  @Test
   public void testNopExeptionHandler() {
     PatternLayout pl = new PatternLayout();
     pl.setPattern("%nopex %m%n");
@@ -99,6 +101,7 @@
     assertTrue(!val.contains("java.lang.Exception: Bogus exception"));
   }
   
+  @Test
   public void testWithParenthesis() {
     PatternLayout pl = new PatternLayout();
     pl.setPattern("\\(%msg:%msg\\) %msg");
@@ -111,6 +114,7 @@
     assertEquals("(Some message:Some message) Some message", val);
   }
   
+  @Test
   public void testWithLettersComingFromLog4j() {
     PatternLayout pl = new PatternLayout();
     //Letters: p = level and c = logger
@@ -123,13 +127,6 @@
     String regex = TestConstants.ISO_REGEX+" INFO "+MAIN_REGEX+" c.q.l.c.pattern.ConverterTest - Some message\\s*";
     assertTrue(val.matches(regex));
   }
-  
-  static public Test suite() {
-    TestSuite suite = new TestSuite();
-    //suite.addTest(new PatternLayoutTest("testNopExeptionHandler"));
-    suite.addTestSuite(PatternLayoutTest.class);
-    return suite;
-  }
 
   @Override
   public Context getContext() {

Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketAppenderTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketAppenderTest.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketAppenderTest.java	Wed Oct  1 15:03:39 2008
@@ -30,7 +30,7 @@
 public class SocketAppenderTest {
 
   static final String LIST_APPENDER_NAME = "la";
-  static final int JOIN__OR_WAIT_TIMEOUT = 200;
+  static final int JOIN_OR_WAIT_TIMEOUT = 200;
   static final int SLEEP_AFTER_LOG = 100;
   
   int port = 4561;
@@ -62,7 +62,7 @@
     Thread.sleep(SLEEP_AFTER_LOG);
 
     simpleSocketServer.close();
-    simpleSocketServer.join(JOIN__OR_WAIT_TIMEOUT);
+    simpleSocketServer.join(JOIN_OR_WAIT_TIMEOUT);
     assertTrue(simpleSocketServer.isClosed());
     assertEquals(1, la.list.size());
 
@@ -82,7 +82,7 @@
     Thread.sleep(SLEEP_AFTER_LOG);
 
     simpleSocketServer.close();
-    simpleSocketServer.join(JOIN__OR_WAIT_TIMEOUT);
+    simpleSocketServer.join(JOIN_OR_WAIT_TIMEOUT);
     assertTrue(simpleSocketServer.isClosed());
     assertEquals(1, la.list.size());
 
@@ -113,7 +113,7 @@
 
     Thread.sleep(SLEEP_AFTER_LOG);
     simpleSocketServer.close();
-    simpleSocketServer.join(JOIN__OR_WAIT_TIMEOUT);
+    simpleSocketServer.join(JOIN_OR_WAIT_TIMEOUT);
     assertTrue(simpleSocketServer.isClosed());
     ListAppender<LoggingEvent> la = getListAppender();
     assertEquals(1, la.list.size());
@@ -138,7 +138,7 @@
     Thread.sleep(SLEEP_AFTER_LOG);
 
     simpleSocketServer.close();
-    simpleSocketServer.join(JOIN__OR_WAIT_TIMEOUT);
+    simpleSocketServer.join(JOIN_OR_WAIT_TIMEOUT);
     assertTrue(simpleSocketServer.isClosed());
     assertEquals(1, la.list.size());
 
@@ -163,7 +163,7 @@
     Thread.sleep(SLEEP_AFTER_LOG);
 
     simpleSocketServer.close();
-    simpleSocketServer.join(JOIN__OR_WAIT_TIMEOUT);
+    simpleSocketServer.join(JOIN_OR_WAIT_TIMEOUT);
     assertTrue(simpleSocketServer.isClosed());
     ListAppender<LoggingEvent> la = getListAppender();
 
@@ -185,11 +185,13 @@
 
     fireServer();
     waitForServerToStart();
+    Thread.sleep(SLEEP_AFTER_LOG); // allow time for client and server to connect
     logger.debug("test msg 2");
     Thread.sleep(SLEEP_AFTER_LOG);
     
     simpleSocketServer.close();
-    simpleSocketServer.join(JOIN__OR_WAIT_TIMEOUT);
+    Thread.sleep(SLEEP_AFTER_LOG);
+    simpleSocketServer.join(JOIN_OR_WAIT_TIMEOUT);
     StatusPrinter.print(lc);
     assertTrue(simpleSocketServer.isClosed());
     assertEquals(1, la.list.size());
@@ -201,7 +203,7 @@
 
   private void waitForServerToStart() throws InterruptedException {
     synchronized (simpleSocketServer) {
-      simpleSocketServer.wait(JOIN__OR_WAIT_TIMEOUT);
+      simpleSocketServer.wait(JOIN_OR_WAIT_TIMEOUT);
     }
   }
 

Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ExtendedThrowableProxyConverterTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ExtendedThrowableProxyConverterTest.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ExtendedThrowableProxyConverterTest.java	Wed Oct  1 15:03:39 2008
@@ -1,17 +1,20 @@
 package ch.qos.logback.classic.pattern;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
 import java.io.PrintWriter;
 import java.io.StringWriter;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import org.junit.After;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 
 import ch.qos.logback.classic.Level;
 import ch.qos.logback.classic.LoggerContext;
+import ch.qos.logback.classic.PatternLayout;
 import ch.qos.logback.classic.spi.LoggingEvent;
 
 public class ExtendedThrowableProxyConverterTest {
@@ -39,13 +42,31 @@
   }
 
   @Test
+  public void integration() {
+    PatternLayout pl = new PatternLayout();
+    pl.setContext(lc);
+    pl.setPattern("%m%n");
+    pl.start();
+    LoggingEvent e = createLoggingEvent(new Exception("x"));
+    String res = pl.doLayout(e);
+
+    // make sure that at least some package data was output
+    Pattern p = Pattern.compile(" \\[junit.*\\]");
+    Matcher m = p.matcher(res);
+    int i = 0;
+    while(m.find()) {
+      i++;
+    }
+    assertTrue(i+ " should be larger than 5", i > 5);
+  }
+
+  @Test
   public void smoke() {
     Exception t = new Exception("smoke");
     verify(t);
   }
 
   @Test
-  @Ignore
   public void nested() {
     Throwable t = makeNestedException(1);
     verify(t);

Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/BasicCPDCTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/BasicCPDCTest.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/BasicCPDCTest.java	Wed Oct  1 15:03:39 2008
@@ -51,14 +51,19 @@
 //    }
 //  }
   
-    
+ 
+  @Test
+  public void integration() throws Exception {
+  
+  }
+  
   @Test
   public void smoke() throws Exception {
     Throwable t = new Throwable("x");
     ThrowableProxy tp = new ThrowableProxy(t);
-    ClassPackagingDataCalculator cpdc = tp.getClassPackagingDataCalculator();
+    PackagingDataCalculator pdc = tp.getPackagingDataCalculator();
     ThrowableDataPoint[] tdpArray = tp.getThrowableDataPointArray();
-    cpdc.calculate(tdpArray);
+    pdc.calculate(tdpArray);
     verify(tdpArray);
     tp.fullDump();
   }
@@ -67,9 +72,9 @@
   public void nested() throws Exception {
     Throwable t = TeztHelper.makeNestedException(3);
     ThrowableProxy tp = new ThrowableProxy(t);
-    ClassPackagingDataCalculator cpdc = tp.getClassPackagingDataCalculator();
+    PackagingDataCalculator pdc = tp.getPackagingDataCalculator();
     ThrowableDataPoint[] tdpArray = tp.getThrowableDataPointArray();
-    cpdc.calculate(tdpArray);
+    pdc.calculate(tdpArray);
     verify(tdpArray);
   }
 
@@ -80,10 +85,10 @@
     } catch (Throwable e) {
       ThrowableProxy tp = new ThrowableProxy(e);
       if (withClassPackagingCalculation) {
-        ClassPackagingDataCalculator cpdc = tp
-            .getClassPackagingDataCalculator();
+        PackagingDataCalculator pdc = tp
+            .getPackagingDataCalculator();
         ThrowableDataPoint[] tdpArray = tp.getThrowableDataPointArray();
-        cpdc.calculate(tdpArray);
+        pdc.calculate(tdpArray);
       }
     }
   }

Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/LoggingEventSerializationTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/LoggingEventSerializationTest.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/LoggingEventSerializationTest.java	Wed Oct  1 15:03:39 2008
@@ -123,17 +123,29 @@
   }
 
   @Test
-  public void xThrowable() throws Exception {
+  public void _Throwable() throws Exception {
     LoggingEvent event = createLoggingEvent();
     Throwable throwable = new Throwable("just testing");
     ThrowableProxy tp = new ThrowableProxy(throwable);
     event.setThrowableProxy(tp);
-
     LoggingEvent remoteEvent = writeAndRead(event);
     checkForEquality(event, remoteEvent);
   }
 
   @Test
+  public void extendendeThrowable() throws Exception {
+    LoggingEvent event = createLoggingEvent();
+    Throwable throwable = new Throwable("just testing");
+    ThrowableProxy tp = new ThrowableProxy(throwable);
+    event.setThrowableProxy(tp);
+    tp.calculatePackagingData();
+
+    LoggingEvent remoteEvent = writeAndRead(event);
+    checkForEquality(event, remoteEvent);
+  }
+  
+  
+  @Test
   public void serializeLargeArgs() throws Exception {
     
     StringBuffer buffer = new StringBuffer();

Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/special/CPDCSpecialImpl.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/special/CPDCSpecialImpl.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/special/CPDCSpecialImpl.java	Wed Oct  1 15:03:39 2008
@@ -1,7 +1,7 @@
 package ch.qos.logback.classic.spi.special;
 
 import ch.qos.logback.classic.spi.CPDCSpecial;
-import ch.qos.logback.classic.spi.ClassPackagingDataCalculator;
+import ch.qos.logback.classic.spi.PackagingDataCalculator;
 import ch.qos.logback.classic.spi.ThrowableProxy;
 
 
@@ -18,8 +18,8 @@
   private void nesting() {
     throwable = new Throwable("x");
     throwableProxy = new ThrowableProxy(throwable);
-    ClassPackagingDataCalculator cpdc = new ClassPackagingDataCalculator();
-    cpdc.calculate(throwableProxy.getThrowableDataPointArray());
+    PackagingDataCalculator pdc = new PackagingDataCalculator();
+    pdc.calculate(throwableProxy.getThrowableDataPointArray());
   }
   
   public Throwable getThrowable() {

Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/AbstractPatternLayoutBaseTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/AbstractPatternLayoutBaseTest.java	(original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/AbstractPatternLayoutBaseTest.java	Wed Oct  1 15:03:39 2008
@@ -9,7 +9,11 @@
  */
 package ch.qos.logback.core.pattern.parser;
 
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
 
 import ch.qos.logback.core.Context;
 import ch.qos.logback.core.ContextBase;
@@ -20,16 +24,13 @@
 import ch.qos.logback.core.util.StatusPrinter;
 
 
-abstract public class AbstractPatternLayoutBaseTest<E> extends TestCase {
-
-  public AbstractPatternLayoutBaseTest(String arg0) {
-    super(arg0);
-  }
-
+abstract public class AbstractPatternLayoutBaseTest<E> {
+  
   abstract public PatternLayoutBase<E> getPatternLayoutBase();
   abstract public E getEventObject();
   abstract public Context getContext();
-   
+  
+  @Test
   public void testUnStarted() {
     PatternLayoutBase<E> plb = getPatternLayoutBase();
     Context context = new ContextBase();
@@ -45,6 +46,7 @@
    * converters. ExceptionalConverter throws an exception if it's convert
    * method is called before being started.
    */
+  @Test
   public void testConverterStart() {
     PatternLayoutBase<E> plb = getPatternLayoutBase();
     plb.setContext(getContext());
@@ -56,6 +58,7 @@
     //System.out.println("========="+result);
   }
 
+  @Test
   public void testStarted() {
     PatternLayoutBase<E> plb = getPatternLayoutBase();
     Context context = new ContextBase();
@@ -66,6 +69,7 @@
     StatusPrinter.print(sm);
   }
 
+  @Test
   public void testNullPattern() {
     //System.out.println("testNullPattern");
     PatternLayoutBase<E> plb = getPatternLayoutBase();

Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/PackageTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/PackageTest.java	(original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/PackageTest.java	Wed Oct  1 15:03:39 2008
@@ -10,6 +10,7 @@
 
 package ch.qos.logback.core.pattern.parser;
 
+import junit.framework.JUnit4TestAdapter;
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
@@ -23,7 +24,7 @@
     suite.addTestSuite(ParserTest.class);
     suite.addTestSuite(FormatInfoTest.class);
     suite.addTestSuite(CompilerTest.class);
-    suite.addTestSuite(SamplePatternLayoutTest.class);
+    suite.addTest(new JUnit4TestAdapter(SamplePatternLayoutTest.class));
     return suite;
   }
 }

Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/SamplePatternLayoutTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/SamplePatternLayoutTest.java	(original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/pattern/parser/SamplePatternLayoutTest.java	Wed Oct  1 15:03:39 2008
@@ -9,6 +9,10 @@
  */
 package ch.qos.logback.core.pattern.parser;
 
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
 import ch.qos.logback.core.Context;
 import ch.qos.logback.core.ContextBase;
 import ch.qos.logback.core.pattern.PatternLayoutBase;
@@ -17,10 +21,6 @@
 public class SamplePatternLayoutTest extends AbstractPatternLayoutBaseTest {
 
   Context context = new ContextBase();
-  public SamplePatternLayoutTest(String arg) {
-    super(arg);
-  }
-  
 
   public PatternLayoutBase<Object> getPatternLayoutBase() {
     return new SamplePatternLayout<Object>();
@@ -30,6 +30,7 @@
     return new Object();
   }
   
+  @Test
   public void testOK() {
     PatternLayoutBase<Object> plb = getPatternLayoutBase();
     Context context = new ContextBase();
@@ -44,6 +45,7 @@
     assertEquals("x123", s);
   }
 
+  @Test
   public void testParentheses() {
     PatternLayoutBase<Object> plb = getPatternLayoutBase();
     Context context = new ContextBase();
@@ -54,6 +56,7 @@
     assertEquals("x(123)", s);
   }
 
+  @Test
   public void testPercentAsLiteral() {
     PatternLayoutBase<Object> plb = getPatternLayoutBase();
     Context context = new ContextBase();


More information about the logback-dev mailing list