You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by rw...@apache.org on 2003/02/05 00:26:31 UTC

cvs commit: jakarta-commons-sandbox/jux/src/test/org/apache/commons/jux String.ser TestAll.java TestObjectObjectTestCase.java TestStringObjectTestCase.java

rwaldhoff    2003/02/04 15:26:30

  Added:       jux      .cvsignore LICENSE.txt build.properties.sample
                        build.xml maven.xml project.properties project.xml
               jux/src/conf checkstyle.properties
               jux/src/java/org/apache/commons/jux ObjectTestCase.java
               jux/src/test/org/apache/commons/jux String.ser TestAll.java
                        TestObjectObjectTestCase.java
                        TestStringObjectTestCase.java
  Log:
  initial import
  
  Revision  Changes    Path
  1.1                  jakarta-commons-sandbox/jux/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  .classpath
  .project
  build.properties
  dist
  target
  tmp
  *.log
  *.gz
  
  
  
  1.1                  jakarta-commons-sandbox/jux/LICENSE.txt
  
  Index: LICENSE.txt
  ===================================================================
  /* 
   * $Header: /home/cvs/jakarta-commons-sandbox/jux/LICENSE.txt,v 1.1 2003/02/04 23:26:25 rwaldhoff Exp $
   * ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived 
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  
  
  
  1.1                  jakarta-commons-sandbox/jux/build.properties.sample
  
  Index: build.properties.sample
  ===================================================================
  root=/java/jars
  junit.jar=${root}/junit.jar
  
  
  
  1.1                  jakarta-commons-sandbox/jux/build.xml
  
  Index: build.xml
  ===================================================================
  <project name="jux" default="test" basedir=".">
  <!--
    Commons-JUX Ant Build File
    $Id: build.xml,v 1.1 2003/02/04 23:26:26 rwaldhoff Exp $
  -->
  
  <!-- ========== Initialize Properties ===================================== -->
  
  
    <property file="build.properties"/>                       <!-- Component local   -->
    <property file="../build.properties"/>                    <!-- Commons (sandbox) local     -->
    <property file="../../jakarta-commons/build.properties"/> <!-- Commons local     -->
    <property file="${user.home}/build.properties"/>          <!-- User local        -->
  
  
  <!-- ========== External Dependencies ===================================== -->
  
  
    <!-- The directories corresponding to your necessary dependencies -->
    <property name="junit.home"              value="/usr/local/junit3.7"/>
  
  
  <!-- ========== Derived Values ============================================ -->
  
  
    <!-- The locations of necessary jar files -->
    <property name="junit.jar"               value="${junit.home}/junit.jar"/>
  
  
  <!-- ========== Component Declarations ==================================== -->
  
  
    <!-- The name of this component -->
    <property name="component.name"          value="jux"/>
  
    <!-- The primary package name of this component -->
    <property name="component.package"       value="org.apache.commons.jux"/>
  
    <!-- The title of this component -->
    <property name="component.title"         value="JUX - JUnit Extensions"/>
  
    <!-- The current version number of this component -->
    <property name="component.version"       value="1.0-dev"/>
  
    <!-- The base directory for compilation targets -->
    <property name="build.home"              value="target"/>
  
    <!-- The base directory for component configuration files -->
    <property name="conf.home"               value="src/conf"/>
  
    <!-- The base directory for distribution targets -->
    <property name="dist.home"               value="${build.home}/dist"/>
  
    <!-- The base directory for component sources -->
    <property name="source.home"             value="src/java"/>
  
    <!-- The base directory for unit test sources -->
    <property name="test.home"               value="src/test"/>
  
  
  <!-- ========== Compiler Defaults ========================================= -->
  
  
    <!-- Should Java compilations set the 'debug' compiler option? -->
    <property name="compile.debug"           value="true"/>
  
    <!-- Should Java compilations set the 'deprecation' compiler option? -->
    <property name="compile.deprecation"     value="false"/>
  
    <!-- Should Java compilations set the 'optimize' compiler option? -->
    <property name="compile.optimize"        value="true"/>
  
    <!-- Construct compile classpath -->
    <path id="compile.classpath">
      <pathelement location="${build.home}/classes"/>
      <pathelement location="${junit.jar}"/>
    </path>
  
  
  <!-- ========== Test Execution Defaults =================================== -->
  
  
    <!-- Construct unit test classpath -->
    <path id="test.classpath">
      <pathelement location="${build.home}/classes"/>
      <pathelement location="${build.home}/tests"/>
      <pathelement location="${junit.jar}"/>
    </path>
  
    <!-- Should all tests fail if one does? -->
    <property name="test.failonerror"        value="true"/>
  
    <!-- The test runner to execute -->
    <property name="test.runner"             value="junit.textui.TestRunner"/>
  
    <property name="test.entry"              value="org.apache.commons.jux.TestAll"/>
  
  <!-- ========== Executable Targets ======================================== -->
  
  
    <target name="init"
     description="Initialize and evaluate conditionals">
      <echo message="-------- ${component.name} ${component.version} --------"/>
      <filter  token="name"                  value="${component.package}"/>
      <filter  token="version"               value="${component.version}"/>
    </target>
  
  
    <target name="prepare" depends="init"
     description="Prepare build directory">
      <mkdir dir="${build.home}"/>
      <mkdir dir="${build.home}/classes"/>
      <mkdir dir="${build.home}/conf"/>
      <mkdir dir="${build.home}/tests"/>
    </target>
  
  
    <target name="static" depends="prepare"
     description="Copy static files to build directory">
      <tstamp/>
      <copy  todir="${build.home}/conf" filtering="on">
        <fileset dir="${conf.home}" includes="*.MF"/>
      </copy>
    </target>
  
  
    <target name="compile" depends="static"
     description="Compile shareable components">
      <javac  srcdir="${source.home}"
             destdir="${build.home}/classes"
               debug="${compile.debug}"
         deprecation="${compile.deprecation}"
            optimize="${compile.optimize}">
        <classpath refid="compile.classpath"/>
      </javac>
      <copy    todir="${build.home}/classes" filtering="on">
        <fileset dir="${source.home}" excludes="**/*.java"/>
      </copy>
    </target>
  
  
    <target name="compile.tests" depends="compile"
     description="Compile unit test cases">
      <javac  srcdir="${test.home}"
             destdir="${build.home}/tests"
               debug="${compile.debug}"
         deprecation="${compile.deprecation}"
            optimize="${compile.optimize}">
        <classpath refid="test.classpath"/>
      </javac>
      <copy    todir="${build.home}/tests" filtering="on">
        <fileset dir="${test.home}" excludes="**/*.java"/>
      </copy>
    </target>
  
  
    <target name="clean"
     description="Clean build and distribution directories">
      <delete    dir="${build.home}"/>
      <delete    dir="${dist.home}"/>
    </target>
  
  
    <target name="javadoc" depends="compile"
     description="Create component Javadoc documentation">
      <mkdir      dir="${dist.home}"/>
      <mkdir      dir="${dist.home}/docs"/>
      <mkdir      dir="${dist.home}/docs/api"/>
      <javadoc sourcepath="${source.home}"
                  destdir="${dist.home}/docs/api"
             packagenames="org.apache.commons.*"
                   author="true"
                  private="true"
                  version="true"
                 doctitle="&lt;h1&gt;${component.title} (Version ${component.version})&lt;/h1&gt;"
              windowtitle="${component.title} (Version ${component.version})"
                   bottom="Copyright (c) 2003 - Apache Software Foundation">
  <!--
                 overview="src/java/overview.html"
  -->
        <classpath  refid="compile.classpath"/>
      </javadoc>
    </target>
  
  
    <target name="dist" depends="test,javadoc"
     description="Create binary distribution">
      <mkdir      dir="${dist.home}"/>
      <copy      file="LICENSE.txt"
                todir="${dist.home}"/>
      <mkdir      dir="${build.home}/classes/META-INF"/>
      <copy      file="LICENSE.txt"
               tofile="${build.home}/classes/META-INF/LICENSE.txt"/>
  <!--
      <copy      file="RELEASE-NOTES.txt"
                todir="${dist.home}"/>
  -->              
      <jar    jarfile="${dist.home}/commons-${component.name}.jar"
              basedir="${build.home}/classes"/>
    </target>
  
  
  <!-- ========== Unit Test Targets ========================================= -->
  
  
    <target name="test" depends="compile.tests">
      <java classname="${test.runner}" fork="yes" failonerror="${test.failonerror}">
        <arg value="${test.entry}"/>
        <classpath refid="test.classpath"/>
      </java>
    </target>
  
  </project>
  
  
  
  1.1                  jakarta-commons-sandbox/jux/maven.xml
  
  Index: maven.xml
  ===================================================================
  <project default="test" xmlns:j="jelly:core" xmlns:maven="jelly:maven" xmlns:doc="doc">
  
    <!-- copy the serialized files into test classpath -->
    <postGoal name="test:compile">
      <copy todir="${maven.build.dest}">
          <fileset dir="src/test">
              <include name="**/*.ser"/>
          </fileset>
      </copy>
    </postGoal>
    
    <!-- copy the serialized files into test classpath -->
    <postGoal name="clover:on">
      <j:set var="maven.junit.sysproperties" value="${maven.junit.sysproperties} org.apache.commons.jux:with-clover"/>
      <j:set var="org.apache.commons.jux:with-clover" value="true"/>
    </postGoal>
    
  </project>
  
  
  
  1.1                  jakarta-commons-sandbox/jux/project.properties
  
  Index: project.properties
  ===================================================================
  maven.checkstyle.properties=src/conf/checkstyle.properties
  
  maven.javadoc.author=false
  maven.javadoc.links=http://java.sun.com/products/jdk/1.4/docs/api
  
  maven.compile.debug=on
  maven.compile.deprecation=off
  maven.compile.optimize=off
  
  maven.jarResources.basedir=src/java
  maven.jar.excludes=**/package.html
  maven.junit.fork=true
  
  clover.excludes=**/Test*.java
  
  
  
  1.1                  jakarta-commons-sandbox/jux/project.xml
  
  Index: project.xml
  ===================================================================
  <?xml version="1.0"?>
  <project> 
    <pomVersion>3</pomVersion>
    <name>commons-jux</name>
    <id>commons-jux</id>
    <currentVersion>1.0-dev</currentVersion>
  
    <organization>
      <name>Apache Software Foundation</name>
      <url>http://jakarta.apache.org</url>
      <logo>http://jakarta.apache.org/images/jakarta-logo-blue.gif</logo>
    </organization>
    <!-- <logo>/images/logo.jpg</logo> -->
  
    <inceptionYear>2003</inceptionYear>
    <package>org.apache.commons.jux</package>
  
    <shortDescription>Commons JUnit Extensions</shortDescription>
  
    <!-- Gump integration -->
    <gumpRepositoryId>jakarta</gumpRepositoryId>
  
    <description>
       A common set of JUnit extensions, largely
       for test inheritance.
    </description>
  
    <url>http://jakarta.apache.org/commons/sandbox/jux/</url>
    <issueTrackingUrl>http://issues.apache.org/bugzilla</issueTrackingUrl>
    <siteAddress>jakarta.apache.org</siteAddress>
    <siteDirectory>/www/jakarta.apache.org/commons/sandbox/jux/</siteDirectory>
    <distributionDirectory>/www/jakarta.apache.org/builds/jakarta-commons-sandbox/jux/</distributionDirectory>
    <repository>
      <connection>scm:cvs:pserver:anoncvs@cvs.apache.org:/home/cvspublic:jakarta-commons-sandbox/jux</connection>
      <url>http://cvs.apache.org/viewcvs/jakarta-commons-sandbox/jux/</url>
    </repository>
  
    <mailingLists>
      <mailingList>
        <name>Commons User List</name>
        <subscribe>commons-user-subscribe@jakarta.apache.org</subscribe>
        <unsubscribe>commons-user-unsubscribe@jakarta.apache.org</unsubscribe>
        <archive>http://archives.apache.org/eyebrowse/SummarizeList?listName=commons-user@jakarta.apache.org</archive>
      </mailingList>
      <mailingList>
        <name>Commons Developer List</name>
        <subscribe>commons-dev-subscribe@jakarta.apache.org</subscribe>
        <unsubscribe>commons-dev-unsubscribe@jakarta.apache.org</unsubscribe>
        <archive>http://archives.apache.org/eyebrowse/SummarizeList?listName=commons-dev@jakarta.apache.org</archive>
      </mailingList>
    </mailingLists>
  
    <developers>
      <developer>
        <name>Rodney Waldhoff</name>
        <id>rwaldhoff</id>
        <email>rwaldhoff@apache.org</email>
      </developer>
    </developers>
  
  
    <dependencies>
      <dependency>
        <id>junit</id>
        <version>3.7</version>
      </dependency>
  
      <!-- these two are required by maven -->
      <dependency><id>xml-apis</id><version>2.0.2</version></dependency>
      <dependency><id>xerces</id><version>2.0.2</version></dependency>
      <!-- /these two are required by maven -->
  
    </dependencies>
  
    <build>
      <nagEmailAddress>commons-dev@jakarta.apache.org</nagEmailAddress>
      <sourceDirectory>src/java</sourceDirectory>
      <unitTestSourceDirectory>src/test</unitTestSourceDirectory>
      <unitTest>
        <includes>
          <include>org/apache/commons/jux/TestAll.java</include>
        </includes>
      </unitTest>
    </build>
  </project>
  
  
  
  
  1.1                  jakarta-commons-sandbox/jux/src/conf/checkstyle.properties
  
  Index: checkstyle.properties
  ===================================================================
  # http://checkstyle.sf.net/config_javadoc.html
  checkstyle.javadoc.scope = public
  checkstyle.require.packagehtml = true
  checkstyle.require.version = false
  checkstyle.allow.noauthor = true
  
  # http://checkstyle.sf.net/config_naming.html
  checkstyle.pattern.const = ^[A-Z](_?[A-Z0-9]+)*$
  checkstyle.pattern.static = ^[a-z][a-zA-Z0-9]*$
  checkstyle.pattern.parameter = ^[a-z][a-zA-Z0-9]*$
  checkstyle.pattern.package = ^[a-z]+(\.[a-z][a-z0-9]*)*$
  checkstyle.pattern.type = ^[A-Z][a-zA-Z0-9]*$
  checkstyle.pattern.method = ^[a-z][a-zA-Z0-9]*$
  checkstyle.pattern.localvar = ^[a-z][a-zA-Z0-9]*$
  checkstyle.pattern.localfinalvar = ^[a-z][a-zA-Z0-9]*$
  
  # http://checkstyle.sf.net/config_header.html
  checkstyle.header.ignore.line = 1,2,3,4,5,6
  
  # http://checkstyle.sf.net/config_import.html
  checkstyle.illegal.imports = sun,com
  
  # http://checkstyle.sf.net/config_sizes.html
  checkstyle.maxlinelen = 120
  # be overly strict here for while
  checkstyle.maxmethodlen = 25
  checkstyle.maxconstructorlen = 25
  checkstyle.maxfilelen = 300
  checkstyle.maxparameters = 4
  
  # http://checkstyle.sf.net/config_whitespace.html
  checkstyle.allow.tabs = false
  checkstyle.ignore.whitespace = true
  checkstyle.paren.pad = nopad
  checkstyle.wrap.operator = eol
  
  # http://checkstyle.sf.net/config_modifiers.html
  checkstyle.pattern.publicmember = ^$
  
  # http://checkstyle.sf.net/config_blocks.html
  checkstyle.block.try = stmt
  checkstyle.block.catch = stmt
  checkstyle.block.finally = stmt
  checkstyle.lcurly.type = eol
  checkstyle.lcurly.method = eol
  checkstyle.lcurly.other = eol
  checkstyle.rcurly = same
  
  # http://checkstyle.sf.net/config_misc.html
  checkstyle.illegal.instantiations = java.lang.Boolean,java.lang.String
  
  
  
  1.1                  jakarta-commons-sandbox/jux/src/java/org/apache/commons/jux/ObjectTestCase.java
  
  Index: ObjectTestCase.java
  ===================================================================
  /* 
   * $Header: /home/cvs/jakarta-commons-sandbox/jux/src/java/org/apache/commons/jux/ObjectTestCase.java,v 1.1 2003/02/04 23:26:27 rwaldhoff Exp $
   * ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived 
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  package org.apache.commons.jux;
  
  import java.io.ByteArrayInputStream;
  import java.io.ByteArrayOutputStream;
  import java.io.InputStream;
  import java.io.ObjectInputStream;
  import java.io.ObjectOutputStream;
  import java.io.Serializable;
  
  import junit.framework.TestCase;
  
  /**
   * @version $Revision: 1.1 $ $Date: 2003/02/04 23:26:27 $
   * @author Rodney Waldhoff
   */
  public abstract class ObjectTestCase extends TestCase {
  
      // Constructor
      // ------------------------------------------------------------------------
  
      public ObjectTestCase(String testName) {
          super(testName);
      }
  
      // Framework
      // ------------------------------------------------------------------------
      
      /** 
       * Return some non-<code>null</code> instance of the object
       * to be tested.
       * Repeated invocations of this method should generally 
       * return distinct instances, which may or may not be equal,
       * but this doesn't necessarily need to be the case. 
       */
      protected abstract Object makeObject() throws Exception;
      
      /** 
       * Return some non-<code>null</code> instance of the object
       * to be tested.
       * The values returned by multiple invocations of htis
       * method MUST be equal.  This is the instance of the
       * object compared to the canonical serialized form,
       * if any.
       * The default implementation invokes {@link #makeObject}. 
       */
      protected Object makeCanonicalInstance() throws Exception {
          return makeObject();
      }
  
      /** 
       * Return an {@link InputStream} from which I can
       * read the "canonical" instance, or <code>null</code>
       * if none is available.
       * The default implementation returns <code>null</code>. 
       */
      protected InputStream getSerializedCanonicalInstanceStream() throws Exception {
          return null;
      }
      
      /** 
       * Return <code>true</code> if 
       * {@link #testObjectToString} should fail 
       * when <code>{@link #makeObject makeObject()}.toString</code>
       * returns the same value as the default 
       * <code>Object.toString</code>, false otherwise.
       * The default implementation returns <code>true</code>.
       */
      protected boolean mustOverrideToString() {
          return true;
      }        
         
      protected boolean equalsImpliesToStringEquals() {
          return true;
      }        
      
      protected boolean notEqualImpliesNotToStringEqual() {
          return true;
      }        
  
      protected boolean notEqualImpliesNotHashCodeEqual() {
          return true;
      }        
  
      protected boolean isSerializable() {
          return true;
      }        
  
      protected boolean serializedCloneIsEqual() {
          return true;
      }        
      
      // Tests
      // ------------------------------------------------------------------------    
  
      public final void testObjectEquals() throws Exception {
          Object obj = makeObject();
          assertEquals("equals must be reflexive",obj,obj);
          assertEquals("hashCode must be reflexive",obj.hashCode(),obj.hashCode());
          assertTrue("non-null object should not equal null",! obj.equals(null) ); 
          
          assertObjectsAreEqual(obj,obj);
          
          Object obj2 = makeObject();
          if(obj.equals(obj2)) {
              assertEquals("equals implies hash equals",obj.hashCode(),obj2.hashCode());
              assertEquals("equals must be symmetric",obj2,obj);
              assertObjectsAreEqual(obj,obj2);
          } else {
              assertTrue("equals must be symmetric",! obj2.equals(obj));
              assertObjectsAreNotEqual(obj,obj2);
          }
      }
  
      public final void testObjectSerializeDeserializeThenCompare() throws Exception {
          Object obj = makeObject();
          if(isSerializable() && obj instanceof Serializable) {
              ByteArrayOutputStream buffer = new ByteArrayOutputStream();
              ObjectOutputStream out = new ObjectOutputStream(buffer);
              out.writeObject(obj);
              out.close();
              
              ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
              Object dest = in.readObject();
              in.close();
              if(serializedCloneIsEqual()) {
                  assertObjectsAreEqual(obj,dest);
              }
          }
      }
  
      public final void testObjectSerializedCanonicalForm() throws Exception {       
          if(!skipSerializedCanonicalTests()) {
              ObjectInputStream oin = null;
              try {
                  InputStream in = getSerializedCanonicalInstanceStream();
                  if(null != in) {
                      oin = new ObjectInputStream(in);
                      Object deser = oin.readObject();
                      assertNotNull(deser);
                      if(serializedCloneIsEqual()) {
                          assertObjectsAreEqual(makeCanonicalInstance(),deser);
                      }
                  }
              } finally {
                  if(null != oin) {
                      oin.close();
                  }
              }
          } else {
              System.out.println("Skipping " + 
                  this.getClass().getName() + 
                  ".testObjectSerializedCanonicalForm since testObjectSerializedCanonicalForm returned true");
          }
      }
  
      public final void testObjectToString() throws Exception {
          Object obj = makeObject();
          assertNotNull("toString should never return null",obj.toString());
          if(mustOverrideToString()) {
              assertTrue(
                  obj.getClass().getName()  + " should override toString(), found \"" + obj.toString() + "\"",
                  !obj.toString().equals(objectToString(obj)));
          }
      }
  
      // protected utils
      // ------------------------------------------------------------------------
      protected void assertObjectsAreEqual(Object a, Object b) {
          assertObjectsAreEqual(a,b,equalsImpliesToStringEquals());
      }
  
      protected void assertObjectsAreEqual(Object a, Object b, boolean compareToString) {
          assertEquals(a,b);
          assertEquals(b,a);
          assertEquals(a.hashCode(),b.hashCode()); 
          if(compareToString) {
              assertEquals(a.toString(),b.toString());
          }
      }
      
      protected void assertObjectsAreNotEqual(Object a, Object b) {
          assertObjectsAreNotEqual(a,b,notEqualImpliesNotToStringEqual(),notEqualImpliesNotHashCodeEqual());
      }
  
      protected void assertObjectsAreNotEqual(Object a, Object b, boolean compareToString, boolean compareHash) {
          assertTrue(!a.equals(b));
          assertTrue(!b.equals(a));
          if(compareHash) {
              assertTrue(a.hashCode() != b.hashCode());
          }
          if(compareToString) {
              assertTrue(!a.toString().equals(b.toString()));
          }
      }
      
      // private utils
      // ------------------------------------------------------------------------
      /** Returns the equivalent to Object.toString for the given Object. */
      private String objectToString(Object obj) {
          return obj.getClass().getName() + "@" + Integer.toHexString(obj.hashCode());
      }
  
      private boolean skipSerializedCanonicalTests() {
          return Boolean.getBoolean("org.apache.commons.jux:with-clover");
      }
      
  }
  
  
  1.1                  jakarta-commons-sandbox/jux/src/test/org/apache/commons/jux/String.ser
  
  	<<Binary file>>
  
  
  1.1                  jakarta-commons-sandbox/jux/src/test/org/apache/commons/jux/TestAll.java
  
  Index: TestAll.java
  ===================================================================
  /* 
   * $Header: /home/cvs/jakarta-commons-sandbox/jux/src/test/org/apache/commons/jux/TestAll.java,v 1.1 2003/02/04 23:26:27 rwaldhoff Exp $
   * ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived 
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  package org.apache.commons.jux;
  
  import junit.framework.Test;
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  
  /**
   * @version $Revision: 1.1 $ $Date: 2003/02/04 23:26:27 $
   * @author Rodney Waldhoff
   */
  public class TestAll extends TestCase {
      public TestAll(String testName) {
          super(testName);
      }
  
      public static Test suite() {
          TestSuite suite = new TestSuite();
          suite.addTest(TestObjectObjectTestCase.suite());
          suite.addTest(TestStringObjectTestCase.suite());
          return suite;
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jux/src/test/org/apache/commons/jux/TestObjectObjectTestCase.java
  
  Index: TestObjectObjectTestCase.java
  ===================================================================
  /* 
   * $Header: /home/cvs/jakarta-commons-sandbox/jux/src/test/org/apache/commons/jux/TestObjectObjectTestCase.java,v 1.1 2003/02/04 23:26:29 rwaldhoff Exp $
   * ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived 
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  package org.apache.commons.jux;
  
  import junit.framework.Test;
  import junit.framework.TestSuite;
  
  /**
   * @version $Revision: 1.1 $ $Date: 2003/02/04 23:26:29 $
   * @author Rodney Waldhoff
   */
  public class TestObjectObjectTestCase extends ObjectTestCase {
  
      // Conventional
      // ------------------------------------------------------------------------
  
      public TestObjectObjectTestCase(String testName) {
          super(testName);
      }
      
      public static Test suite() {
          return new TestSuite(TestObjectObjectTestCase.class);
      }    
  
      // Framework
      // ------------------------------------------------------------------------
      
      /**
       * @see org.apache.commons.jux.ObjectTestCase#makeObject()
       */
      protected Object makeObject() throws Exception {
          return new Object();
      }
      
      /**
       * @see org.apache.commons.jux.ObjectTestCase#mustOverrideToString()
       */
      protected boolean mustOverrideToString() {
          return false;
      }
  
  }
  
  
  1.1                  jakarta-commons-sandbox/jux/src/test/org/apache/commons/jux/TestStringObjectTestCase.java
  
  Index: TestStringObjectTestCase.java
  ===================================================================
  /* 
   * $Header: /home/cvs/jakarta-commons-sandbox/jux/src/test/org/apache/commons/jux/TestStringObjectTestCase.java,v 1.1 2003/02/04 23:26:29 rwaldhoff Exp $
   * ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived 
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  package org.apache.commons.jux;
  
  import java.io.InputStream;
  
  import junit.framework.Test;
  import junit.framework.TestSuite;
  
  /**
   * @version $Revision: 1.1 $ $Date: 2003/02/04 23:26:29 $
   * @author Rodney Waldhoff
   */
  public class TestStringObjectTestCase extends ObjectTestCase {
  
      // Conventional
      // ------------------------------------------------------------------------
  
      public TestStringObjectTestCase(String testName) {
          super(testName);
      }
      
      public static Test suite() {
          return new TestSuite(TestStringObjectTestCase.class);
      }    
  
      // Framework
      // ------------------------------------------------------------------------
      
      /**
       * @see org.apache.commons.jux.ObjectTestCase#makeObject()
       */
      protected Object makeObject() throws Exception {
          return new String("This is the basic String returned by makeObject.");
      }    
  
      /**
       * @see org.apache.commons.jux.ObjectTestCase#makeCanonicalInstance()
       */
      protected Object makeCanonicalInstance() throws Exception {
          return new String("This is the basic String returned by makeCanonicalInstance.");
      }
         
      /**
       * @see org.apache.commons.jux.ObjectTestCase#getSerializedCanonicalInstanceStream()
       */
      protected InputStream getSerializedCanonicalInstanceStream() {
          InputStream stream = this.getClass().getResourceAsStream("String.ser");
          assertNotNull(stream);
          return stream;
      }
  
  }
  
  

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