cvs commit: spice/sandbox/metaclass/src/test/org/realityforge/metaclass/model ClassDescriptorTestCase.java

Peter Donald <[email protected]>
Newsgroups gmane.comp.java.spice.cvs
Message-ID <[email protected]>
donaldp     03/10/28 03:37:25

  Added:       sandbox/metaclass/src/test/org/realityforge/metaclass/model
                        ClassDescriptorTestCase.java
  Log:
  Add ClassDescriptor testcase
  
  Revision  Changes    Path
  1.1                  spice/sandbox/metaclass/src/test/org/realityforge/metaclass/model/ClassDescriptorTestCase.java
  
  Index: ClassDescriptorTestCase.java
  ===================================================================
  /*
   * Copyright (C) The Spice Group. All rights reserved.
   *
   * This software is published under the terms of the Spice
   * Software License version 1.1, a copy of which has been included
   * with this distribution in the LICENSE.txt file.
   */
  package org.realityforge.metaclass.model;
  
  import junit.framework.TestCase;
  
  /**
   *
   * @author <a href="mailto:peter at realityforge.org">Peter Donald</a>
   * @version $Revision: 1.1 $ $Date: 2003/10/28 11:37:25 $
   */
  public class ClassDescriptorTestCase
      extends TestCase
  {
      public void testNullNamePassedToCtor()
          throws Exception
      {
          try
          {
              new ClassDescriptor( null,
                                   Attribute.EMPTY_SET,
                                   FieldDescriptor.EMPTY_SET,
                                   MethodDescriptor.EMPTY_SET );
          }
          catch( final NullPointerException npe )
          {
              assertEquals( "npe.getMessage()", "name", npe.getMessage() );
              return;
          }
          fail( "Expected to fail due to null name passed into Ctor" );
      }
  
      public void testNullFieldsPassedToCtor()
          throws Exception
      {
          try
          {
              new ClassDescriptor( "MyClass",
                                   Attribute.EMPTY_SET,
                                   null,
                                   MethodDescriptor.EMPTY_SET );
          }
          catch( final NullPointerException npe )
          {
              assertEquals( "npe.getMessage()", "fields", npe.getMessage() );
              return;
          }
          fail( "Expected to fail due to null fields passed into Ctor" );
      }
  
      public void testNullInFieldsPassedToCtor()
          throws Exception
      {
          try
          {
              new ClassDescriptor( "MyClass",
                                   Attribute.EMPTY_SET,
                                   new FieldDescriptor[]{null},
                                   MethodDescriptor.EMPTY_SET );
          }
          catch( final NullPointerException npe )
          {
              assertEquals( "npe.getMessage()", "fields[0]", npe.getMessage() );
              return;
          }
          fail( "Expected to fail due to null fields[0] passed into Ctor" );
      }
  
      public void testNullMethodsPassedToCtor()
          throws Exception
      {
          try
          {
              new ClassDescriptor( "MyClass",
                                   Attribute.EMPTY_SET,
                                   FieldDescriptor.EMPTY_SET,
                                   null );
          }
          catch( final NullPointerException npe )
          {
              assertEquals( "npe.getMessage()", "methods", npe.getMessage() );
              return;
          }
          fail( "Expected to fail due to null methods passed into Ctor" );
      }
  
      public void testNullInMethodsPassedToCtor()
          throws Exception
      {
          try
          {
              new ClassDescriptor( "MyClass",
                                   Attribute.EMPTY_SET,
                                   FieldDescriptor.EMPTY_SET,
                                   new MethodDescriptor[]{null} );
          }
          catch( final NullPointerException npe )
          {
              assertEquals( "npe.getMessage()", "methods[0]", npe.getMessage() );
              return;
          }
          fail( "Expected to fail due to null methods[0] passed into Ctor" );
      }
  
      public void testClassDescriptor()
          throws Exception
      {
          final ClassDescriptor descriptor =
              new ClassDescriptor( "X",
                                   Attribute.EMPTY_SET,
                                   FieldDescriptor.EMPTY_SET,
                                   MethodDescriptor.EMPTY_SET );
          assertEquals( "name", "X", descriptor.getName() );
          assertEquals( "fields.length", 0, descriptor.getFields().length );
          assertEquals( "methods.length", 0, descriptor.getMethods().length );
      }
  }
  
  
  


-------------------------------------------------------
This SF.net email is sponsored by: The SF.net Donation Program.
Do you like what SourceForge.net is doing for the Open
Source Community?  Make a contribution, and help us add new
features and functionality. Click here: http://sourceforge.net/donate/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.