logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From carn...@apache.org
Subject cvs commit: logging-log4j/tests/witness/serialization exception.bin info.bin location.bin mdc.bin ndc.bin simple.bin
Date Mon, 18 Jul 2005 17:10:38 GMT
carnold     2005/07/18 10:10:35

  Modified:    src/java/org/apache/log4j Tag: v1_2-branch Level.java
                        Priority.java
               tests    Tag: v1_2-branch build.xml
  Added:       tests/src/java/org/apache/log4j Tag: v1_2-branch
                        CoreTestSuite.java LevelTest.java
               tests/src/java/org/apache/log4j/spi Tag: v1_2-branch
                        LoggingEventTest.java
               tests/src/java/org/apache/log4j/util Tag: v1_2-branch
                        SerializationTestHelper.java
               tests/witness/serialization Tag: v1_2-branch exception.bin
                        info.bin location.bin mdc.bin ndc.bin simple.bin
  Log:
  Bug 26433: Level serialization and event serialization tests for 1.2
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.8.2.2   +59 -1     logging-log4j/src/java/org/apache/log4j/Level.java
  
  Index: Level.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/Level.java,v
  retrieving revision 1.8.2.1
  retrieving revision 1.8.2.2
  diff -u -r1.8.2.1 -r1.8.2.2
  --- Level.java	24 May 2005 05:06:17 -0000	1.8.2.1
  +++ Level.java	18 Jul 2005 17:03:39 -0000	1.8.2.2
  @@ -18,6 +18,11 @@
   //                Nicholas Wolff
   
   package org.apache.log4j;
  +import java.io.IOException;
  +import java.io.ObjectInputStream;
  +import java.io.ObjectOutputStream;
  +import java.io.ObjectStreamException;
  +import java.io.Serializable;
   
   /**
      Defines the minimum set of levels recognized by the system, that is
  @@ -31,7 +36,7 @@
      @author Ceki Gülcü
   
    */
  -public class Level extends Priority {
  +public class Level extends Priority implements Serializable {
   
   
     /**
  @@ -73,6 +78,11 @@
     final static public Level ALL = new Level(ALL_INT, "ALL", 7);
   
     /**
  +   * Serialization version id.
  +   */
  +  static final long serialVersionUID = 3491141966387921974L;
  +
  +  /**
        Instantiate a Level object.
      */
     protected
  @@ -144,4 +154,52 @@
       if(s.equals("OFF")) return Level.OFF;
       return defaultLevel;
     }
  +
  +    /**
  +     * Custom deserialization of Level.
  +     * @param s serialization stream.
  +     * @throws IOException if IO exception.
  +     * @throws ClassNotFoundException if class not found.
  +     */
  +    private void readObject(final ObjectInputStream s) throws IOException, ClassNotFoundException
{
  +      s.defaultReadObject();
  +      level = s.readInt();
  +      syslogEquivalent = s.readInt();
  +      levelStr = s.readUTF();
  +      if (levelStr == null) {
  +          levelStr = "";
  +      }
  +    }
  +
  +    /**
  +     * Serialize level.
  +     * @param s serialization stream.
  +     * @throws IOException if exception during serialization.
  +     */
  +    private void writeObject(final ObjectOutputStream s) throws IOException {
  +        s.defaultWriteObject();
  +        s.writeInt(level);
  +        s.writeInt(syslogEquivalent);
  +        s.writeUTF(levelStr);
  +    }
  +
  +    /**
  +     * Resolved deserialized level to one of the stock instances.
  +     * May be overriden in classes derived from Level.
  +     * @return resolved object.
  +     * @throws ObjectStreamException if exception during resolution.
  +     */
  +    private Object readResolve() throws ObjectStreamException {
  +        //
  +        //  if the deserizalized object is exactly an instance of Level
  +        //
  +        if (getClass() == Level.class) {
  +            return toLevel(level);
  +        }
  +        //
  +        //   extension of Level can't substitute stock item
  +        //
  +        return this;
  +    }
  +
   }
  
  
  
  1.23.2.5  +14 -5     logging-log4j/src/java/org/apache/log4j/Priority.java
  
  Index: Priority.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/Priority.java,v
  retrieving revision 1.23.2.4
  retrieving revision 1.23.2.5
  diff -u -r1.23.2.4 -r1.23.2.5
  --- Priority.java	24 May 2005 05:06:17 -0000	1.23.2.4
  +++ Priority.java	18 Jul 2005 17:03:49 -0000	1.23.2.5
  @@ -17,7 +17,7 @@
   // Contributors:  Kitching Simon <Simon.Kitching@orange.ch>
   
   package org.apache.log4j;
  -  
  +
   /**
      <font color="#AA4444">Refrain from using this class directly, use
      the {@link Level} class instead</font>.
  @@ -25,9 +25,9 @@
      @author Ceki G&uuml;lc&uuml; */
   public class Priority {
   
  -  int level;
  -  String levelStr;
  -  int syslogEquivalent;
  +  transient int level;
  +  transient String levelStr;
  +  transient int syslogEquivalent;
   
     public final static int OFF_INT = Integer.MAX_VALUE;
     public final static int FATAL_INT = 50000;
  @@ -63,7 +63,16 @@
      */
     final static public Priority DEBUG = new Level(DEBUG_INT, "DEBUG", 7);
   
  -  
  +
  +  /**
  +    * Default constructor for deserialization.
  +    */
  +  protected Priority() {
  +      level = DEBUG_INT;
  +      levelStr = "DEBUG";
  +      syslogEquivalent = 7;
  +  }
  +
     /**
        Instantiate a level object.
      */
  
  
  
  No                   revision
  No                   revision
  1.16.2.9  +10 -1     logging-log4j/tests/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/logging-log4j/tests/build.xml,v
  retrieving revision 1.16.2.8
  retrieving revision 1.16.2.9
  diff -u -r1.16.2.8 -r1.16.2.9
  --- build.xml	1 Jul 2005 04:38:34 -0000	1.16.2.8
  +++ build.xml	18 Jul 2005 17:04:51 -0000	1.16.2.9
  @@ -116,7 +116,7 @@
     <!-- unit tests. Regression tests compare output with a previously     -->
     <!-- created witness file.                                             -->
     <!-- ================================================================= -->  
  -  <target name="regression" depends="Minimum, Logger, DOM, CustomLevel, 
  +  <target name="regression" depends="Core, Minimum, Logger, DOM, CustomLevel, 
                                        CustomLogger,  
                                        HierarchyThreshold, DefaultInit, SocketServer, 
                                        XMLLayout, AsyncAppender, 
  @@ -133,6 +133,15 @@
     <!-- ================================================================= -->
     <!-- ============== Regression and Unit Tests follow ================= -->  
     <!-- ================================================================= -->
  +    <target name="Core" depends="build">
  +      <junit printsummary="yes" fork="yes" haltonfailure="yes">
  +        <classpath refid="tests.classpath"/>
  +        <formatter type="plain" usefile="false"/>
  +        <test name="org.apache.log4j.CoreTestSuite" />
  +      </junit>
  +    </target>
  +
  +
     <target name="Minimum" depends="build">
       <junit printsummary="yes" fork="yes" haltonfailure="yes">
         <classpath refid="tests.classpath"/>
  
  
  
  No                   revision
  No                   revision
  1.5.2.1   +0 -4      logging-log4j/tests/src/java/org/apache/log4j/CoreTestSuite.java
  
  Index: CoreTestSuite.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/tests/src/java/org/apache/log4j/CoreTestSuite.java,v
  retrieving revision 1.5
  retrieving revision 1.5.2.1
  diff -u -r1.5 -r1.5.2.1
  --- CoreTestSuite.java	18 Jul 2005 16:17:35 -0000	1.5
  +++ CoreTestSuite.java	18 Jul 2005 17:05:45 -0000	1.5.2.1
  @@ -34,10 +34,6 @@
       public static Test suite() {
           TestSuite s = new TestSuite();
           s.addTestSuite(LoggingEventTest.class);
  -        s.addTestSuite(org.apache.log4j.pattern.NameAbbreviatorTest.class);
  -        s.addTestSuite(org.apache.log4j.pattern.PatternParserTest.class);
  -        s.addTestSuite(org.apache.log4j.rolling.helper.FileNamePatternTestCase.class);
  -        s.addTestSuite(org.apache.log4j.pattern.FormattingInfoTest.class);
           s.addTestSuite(org.apache.log4j.LevelTest.class);
           return s;
       }
  
  
  
  1.1.2.1   +0 -0      logging-log4j/tests/src/java/org/apache/log4j/LevelTest.java
  
  
  
  
  No                   revision
  No                   revision
  1.5.2.1   +11 -11    logging-log4j/tests/src/java/org/apache/log4j/spi/LoggingEventTest.java
  
  Index: LoggingEventTest.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/tests/src/java/org/apache/log4j/spi/LoggingEventTest.java,v
  retrieving revision 1.5
  retrieving revision 1.5.2.1
  diff -u -r1.5 -r1.5.2.1
  --- LoggingEventTest.java	18 Jul 2005 16:18:21 -0000	1.5
  +++ LoggingEventTest.java	18 Jul 2005 17:07:02 -0000	1.5.2.1
  @@ -22,7 +22,7 @@
   import org.apache.log4j.Logger;
   import org.apache.log4j.MDC;
   import org.apache.log4j.NDC;
  -import org.apache.log4j.spi.location.LocationInfo;
  +import org.apache.log4j.spi.LocationInfo;
   import org.apache.log4j.util.SerializationTestHelper;
   
   
  @@ -52,9 +52,9 @@
       LoggingEvent event =
         new LoggingEvent(
           root.getClass().getName(), root, Level.INFO, "Hello, world.", null);
  -    event.prepareForDeferredProcessing();
  +//    event.prepareForDeferredProcessing();
   
  -    int[] skip = new int[] { 358, 359, 360, 361, 362 };
  +    int[] skip = new int[] { 352, 353, 354, 355, 356 };
       SerializationTestHelper.assertSerializationEquals(
         "witness/serialization/simple.bin", event, skip, Integer.MAX_VALUE);
     }
  @@ -71,9 +71,9 @@
       LoggingEvent event =
         new LoggingEvent(
           root.getClass().getName(), root, Level.INFO, "Hello, world.", ex);
  -    event.prepareForDeferredProcessing();
  +//    event.prepareForDeferredProcessing();
   
  -    int[] skip = new int[] { 358, 359, 360, 361, 362, 600, 734, 735, 1511 };
  +    int[] skip = new int[] { 352, 353, 354, 355, 356 };
       SerializationTestHelper.assertSerializationEquals(
         "witness/serialization/exception.bin", event, skip, 1089);
     }
  @@ -90,9 +90,9 @@
         new LoggingEvent(
           root.getClass().getName(), root, Level.INFO, "Hello, world.", null);
       LocationInfo info = event.getLocationInformation();
  -    event.prepareForDeferredProcessing();
  +//    event.prepareForDeferredProcessing();
   
  -    int[] skip = new int[] { 354, 355, 356, 357, 358, 359, 360, 361, 362 };
  +    int[] skip = new int[] { 352, 353, 354, 355, 356 };
       SerializationTestHelper.assertSerializationEquals(
         "witness/serialization/location.bin", event, skip, Integer.MAX_VALUE);
     }
  @@ -109,9 +109,9 @@
       LoggingEvent event =
         new LoggingEvent(
           root.getClass().getName(), root, Level.INFO, "Hello, world.", null);
  -    event.prepareForDeferredProcessing();
  +//    event.prepareForDeferredProcessing();
   
  -    int[] skip = new int[] { 354, 355, 356, 357, 358, 359, 360, 361, 362 };
  +    int[] skip = new int[] { 352, 353, 354, 355, 356 };
       SerializationTestHelper.assertSerializationEquals(
         "witness/serialization/ndc.bin", event, skip, Integer.MAX_VALUE);
     }
  @@ -128,9 +128,9 @@
       LoggingEvent event =
         new LoggingEvent(
           root.getClass().getName(), root, Level.INFO, "Hello, world.", null);
  -    event.prepareForDeferredProcessing();
  +//    event.prepareForDeferredProcessing();
   
  -    int[] skip = new int[] { 354, 355, 356, 357, 358, 359, 360, 361, 362 };
  +    int[] skip = new int[] { 352, 353, 354, 355, 356 };
       SerializationTestHelper.assertSerializationEquals(
         "witness/serialization/mdc.bin", event, skip, Integer.MAX_VALUE);
     }
  
  
  
  No                   revision
  No                   revision
  1.1.2.1   +0 -0      logging-log4j/tests/src/java/org/apache/log4j/util/SerializationTestHelper.java
  
  
  
  
  No                   revision
  No                   revision
  1.1.2.1   +2 -4      logging-log4j/tests/witness/serialization/exception.bin
  
  	<<Binary file>>
  
  
  1.1.2.1   +0 -0      logging-log4j/tests/witness/serialization/info.bin
  
  	<<Binary file>>
  
  
  1.1.2.1   +2 -6      logging-log4j/tests/witness/serialization/location.bin
  
  	<<Binary file>>
  
  
  1.1.2.1   +3 -4      logging-log4j/tests/witness/serialization/mdc.bin
  
  	<<Binary file>>
  
  
  1.1.2.1   +2 -4      logging-log4j/tests/witness/serialization/ndc.bin
  
  	<<Binary file>>
  
  
  1.1.2.1   +2 -4      logging-log4j/tests/witness/serialization/simple.bin
  
  	<<Binary file>>
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Mime
View raw message