avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcconn...@apache.org
Subject cvs commit: avalon-sandbox/meta/api/src/test/org/apache/avalon/meta/info/test InfoDescriptorTestCase.java
Date Fri, 11 Jul 2003 14:58:06 GMT
mcconnell    2003/07/11 07:58:06

  Added:       meta/api/src/test/org/apache/avalon/meta/info/test
                        InfoDescriptorTestCase.java
  Log:
  InfoDescriptor test-case addition.
  
  Revision  Changes    Path
  1.1                  avalon-sandbox/meta/api/src/test/org/apache/avalon/meta/info/test/InfoDescriptorTestCase.java
  
  Index: InfoDescriptorTestCase.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, 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 "Jakarta", "Avalon", "Excalibur" 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 (INCLU-
   DING, 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.avalon.meta.info.test;
  
  import junit.framework.TestCase;
  import org.apache.avalon.meta.info.InfoDescriptor;
  import org.apache.avalon.meta.info.Descriptor;
  import org.apache.avalon.framework.Version;
  
  import java.io.*;
  import java.util.Properties;
  
  /**
   * InfoDescriptorTestCase does XYZ
   *
   * @author <a href="mcconnell.at.apache.org">Stephen McConnell</a>
   * @version CVS $ Revision: 1.1 $
   */
  public class InfoDescriptorTestCase extends AbstractDescriptorTestCase
  {
      private final String m_name = "name";
      private final String m_classname = InfoDescriptorTestCase.class.getName();
      private final Version m_version = Version.getVersion("1.2.3");
      private final String m_lifestyle = InfoDescriptor.SINGLETON;
  
      public InfoDescriptorTestCase ( String name )
      {
          super( name );
      }
  
      protected Descriptor getDescriptor()
      {
          return new InfoDescriptor(
            m_name, m_classname, m_version, m_lifestyle, getProperties());
      }
  
      protected void checkDescriptor( Descriptor desc )
      {
          super.checkDescriptor( desc );
          InfoDescriptor info = (InfoDescriptor) desc;
          assertEquals( m_name, info.getName() );
          assertEquals( m_classname, info.getClassname() );
          assertEquals( m_version, info.getVersion() );
          assertEquals( m_lifestyle, info.getLifestyle() );
      }
  
      public void testSerialization() throws IOException, ClassNotFoundException
      {
          File file = new File("name.test");
          InfoDescriptor original = (InfoDescriptor) getDescriptor();
          ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(file));
          oos.writeObject(original);
          oos.close();
  
          ObjectInputStream ois = new ObjectInputStream( new FileInputStream(file));
          InfoDescriptor serialized = (InfoDescriptor)ois.readObject();
          ois.close();
          file.delete();
  
          checkDescriptor( serialized );
          assertEquals( original, serialized );
          assertEquals( original.hashCode(), serialized.hashCode() );
      }
  
  }
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org


Mime
View raw message