You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-cvs@jakarta.apache.org by ce...@apache.org on 2002/02/08 12:16:48 UTC

cvs commit: jakarta-log4j/src/java/org/apache/log4j/test/serialization/T compile.sample.bat compile.sample.sh T12.java

ceki        02/02/08 03:16:48

  Modified:    src/java/org/apache/log4j/test/serialization README
                        SerializationUT.java
               src/java/org/apache/log4j/test/serialization/T T12.java
  Added:       src/java/org/apache/log4j/test/serialization/T
                        compile.sample.bat compile.sample.sh
  Log:
  Preliminary tests show that we can read 1.2 generated events from 1.1.3 and vice versa.
  
  Revision  Changes    Path
  1.2       +31 -0     jakarta-log4j/src/java/org/apache/log4j/test/serialization/README
  
  Index: README
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/test/serialization/README,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- README	8 Feb 2002 10:29:52 -0000	1.1
  +++ README	8 Feb 2002 11:16:46 -0000	1.2
  @@ -1,5 +1,36 @@
  +             =======================
  +             Serialization unit test
  +             =======================
   
   Running the serialization test is not for the faint of heart. It is
   complicated because we are trying to read or write two different
   versions of the same class. This requires unusual classloading
   techniques.
  +
  +Compiling
  +=========
  +
  +step1)
  +
  +The file SerializationUT.java must be compiled with only the Java
  +rt.jar and junit.jar on the class path. The compilation must be
  +carried out from the directory where this README file is located.
  +
  +step2)
  +
  +Compile the files T/T113.java and T/T12.java. See the files
  +compile.sample.bat and compile.sample.sh under the T/
  +directory. Compilations must be carried in T/.
  +
  +Running
  +=======
  +Tests use the same classpath and are run as follows:
  +
  +  1) cd to $LOG4J_HOME/src/java/org/apache/log4j/test/serialization
  +   
  +     This is where this README file is located.
  +
  +  2) Run
  +    
  +         java junit.textui.TestRunner SerializationUT
  +
  
  
  
  1.3       +59 -0     jakarta-log4j/src/java/org/apache/log4j/test/serialization/SerializationUT.java
  
  Index: SerializationUT.java
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/test/serialization/SerializationUT.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SerializationUT.java	21 Jan 2002 23:14:50 -0000	1.2
  +++ SerializationUT.java	8 Feb 2002 11:16:47 -0000	1.3
  @@ -87,6 +87,10 @@
     void tearDown() {
     }
   
  +
  +  /**
  +     Test writing in 1.1.3 and reading from 1.1.3. Here we are testing
  +     the test.  */
     public 
     void test1() throws Exception {
       
  @@ -111,6 +115,9 @@
       assertEquals(witness, outHt);
     }
   
  +  /**
  +     Test writing 1.2 and reading from 1.2. Here we are testing the test.
  +  */
     public 
     void test2() throws Exception {
       
  @@ -135,6 +142,56 @@
       assertEquals(witness, outHt);
     }
   
  +  /**
  +     Test writing 1.1.3 and reading from 1.2. 
  +  */
  +  public 
  +  void test3() throws Exception {
  +    
  +    Hashtable inHt = new Hashtable();
  +    Hashtable witness = new Hashtable();
  +
  +    inHt.put("categoryName", "a.b.c");
  +    inHt.put("priorityStr", "DEBUG");
  +    inHt.put("message", "hello");
  +   
  +    witness.put("categoryName", "a.b.c");
  +    witness.put("priorityStr", "DEBUG");
  +    witness.put("renderedMessage", "hello");
  +    byte[] buf = (byte[]) serMethod113.invoke(o113, new Object[] {inHt});
  +    Hashtable outHt = (Hashtable) deserMethod12a7.invoke(o12a7, new Object[] {buf});
  +    //System.out.println("witness"+witness);
  +    //System.out.println("outHt  "+outHt);
  +    assertEquals(witness, outHt);
  +  }
  +
  +  /**
  +     Test writing 1.2 and reading from 1.1.3.
  +  */
  +  public 
  +  void test4() throws Exception {
  +    
  +    Hashtable inHt = new Hashtable();
  +    Hashtable witness = new Hashtable();
  +
  +    inHt.put("categoryName", "a.b.c");
  +    inHt.put("priorityStr", "DEBUG");
  +    inHt.put("message", "hello");
  +   
  +    witness.put("categoryName", "a.b.c");
  +    witness.put("priorityStr", "DEBUG");
  +    witness.put("renderedMessage", "hello");
  +
  +    byte[] buf = (byte[]) serMethod12a7.invoke(o12a7, new Object[] {inHt});
  +
  +    Hashtable outHt = (Hashtable) deserMethod113.invoke(o113, new Object[] {buf});
  +
  +    //System.out.println("witness"+witness);
  +    //System.out.println("outHt  "+outHt);
  +
  +    assertEquals(witness, outHt);
  +  }
  +
    
     public
     static
  @@ -142,6 +199,8 @@
       TestSuite suite = new TestSuite();
       suite.addTest(new SerializationUT("test1"));
       suite.addTest(new SerializationUT("test2"));
  +    suite.addTest(new SerializationUT("test3"));
  +    suite.addTest(new SerializationUT("test4"));
       return suite;
     }   
   }
  
  
  
  1.2       +2 -3      jakarta-log4j/src/java/org/apache/log4j/test/serialization/T/T12.java
  
  Index: T12.java
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/test/serialization/T/T12.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- T12.java	21 Jan 2002 23:07:12 -0000	1.1
  +++ T12.java	8 Feb 2002 11:16:47 -0000	1.2
  @@ -1,8 +1,7 @@
   
   import java.io.*;
   
  -import org.apache.log4j.Category;
  -import org.apache.log4j.Priority;
  +import org.apache.log4j.*;
   import org.apache.log4j.spi.LoggingEvent;
   
   import java.util.Hashtable;
  @@ -27,7 +26,7 @@
   
         LoggingEvent event = new LoggingEvent("org.apache.log4j.Category", 
   					    category, 
  -					    Priority.toPriority((String)ht.get("priorityStr")),
  +					    Level.toLevel((String)ht.get("priorityStr")),
   					    ht.get("message"), 
   					    (Throwable) ht.get("throwable"));
         event.getThreadName();
  
  
  
  1.1                  jakarta-log4j/src/java/org/apache/log4j/test/serialization/T/compile.sample.bat
  
  Index: compile.sample.bat
  ===================================================================
  
  @REM This little script compiles the files T113.java and T12.java with
  @REM different classpaths.
  @REM
  @REM You have to set the classpath to point to rt.jar depending on your
  @REM environment.
  
  set CLASSPATH=.;%JAVA_HOME%\jre\lib\rt.jar;log4j-1.1.3.jar
  
  echo [%CLASSPATH%]
  
  javac T113.java
  
  set CLASSPATH=.;%JAVA_HOME%\jre\lib\rt.jar;log4j-1.2alpha7.jar
  javac -deprecation T12.java
  
  
  1.1                  jakarta-log4j/src/java/org/apache/log4j/test/serialization/T/compile.sample.sh
  
  Index: compile.sample.sh
  ===================================================================
  
  # This little Unix script compiles the files T113.java and T12.java
  # with different classpaths.
  
  # You have to set the classpath to point to rt.jar depending on your
  # environment.
  
  CLASSPATH=".:$JAVA_HOME/jre/lib/rt.jar:log4j-1.1.3.jar"
  javac -deprecation T113.java
  
  CLASSPATH=".:$JAVA_HOME/jre/lib/rt.jar:log4j-1.2alpha7.jar"
  javac -deprecation T12.java
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>