1   /*
2    * Copyright (C) The MetaClass Group. All rights reserved.
3    *
4    * This software is published under the terms of the Spice
5    * Software License version 1.1, a copy of which has been included
6    * with this distribution in the LICENSE.txt file.
7    */
8   package org.codehaus.metaclass.model;
9   
10  import junit.framework.TestCase;
11  
12  /***
13   * @author Peter Donald
14   * @version $Revision: 1.3 $ $Date: 2003/11/28 11:14:54 $
15   */
16  public class FieldDescriptorTestCase
17      extends TestCase
18  {
19      public void testFieldDescriptor()
20          throws Exception
21      {
22          final FieldDescriptor descriptor =
23              new FieldDescriptor( "x",
24                                   "int",
25                                   Attribute.EMPTY_SET,
26                                   Attribute.EMPTY_SET );
27          assertEquals( "name", "x", descriptor.getName() );
28          assertEquals( "type", "int", descriptor.getType() );
29      }
30  
31      public void testNullNamePassedToCtor()
32          throws Exception
33      {
34          try
35          {
36              new FieldDescriptor( null,
37                                   "int",
38                                   Attribute.EMPTY_SET,
39                                   Attribute.EMPTY_SET );
40          }
41          catch( final NullPointerException npe )
42          {
43              assertEquals( "npe.getMessage()", "name", npe.getMessage() );
44              return;
45          }
46          fail( "Expected to fail due to null Name passed into Ctor" );
47      }
48  
49      public void testNulltypePassedToCtor()
50          throws Exception
51      {
52          try
53          {
54              new FieldDescriptor( "blah",
55                                   null,
56                                   Attribute.EMPTY_SET,
57                                   Attribute.EMPTY_SET );
58          }
59          catch( final NullPointerException npe )
60          {
61              assertEquals( "npe.getMessage()", "type", npe.getMessage() );
62              return;
63          }
64          fail( "Expected to fail due to null type passed into Ctor" );
65      }
66  }