1
2
3
4
5
6
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 MethodDescriptorTestCase
17 extends TestCase
18 {
19 public void testNullNamePassedToCtor()
20 throws Exception
21 {
22 try
23 {
24 new MethodDescriptor( null,
25 "int",
26 ParameterDescriptor.EMPTY_SET,
27 Attribute.EMPTY_SET,
28 Attribute.EMPTY_SET );
29 }
30 catch( final NullPointerException npe )
31 {
32 assertEquals( "npe.getMessage()", "name", npe.getMessage() );
33 return;
34 }
35 fail( "Expected to fail due to null name passed into Ctor" );
36 }
37
38 public void testNullReturnTypePassedToCtor()
39 throws Exception
40 {
41 try
42 {
43 new MethodDescriptor( "doMagic",
44 null,
45 ParameterDescriptor.EMPTY_SET,
46 Attribute.EMPTY_SET,
47 Attribute.EMPTY_SET );
48 }
49 catch( final NullPointerException npe )
50 {
51 assertEquals( "npe.getMessage()", "returnType", npe.getMessage() );
52 return;
53 }
54 fail( "Expected to fail due to null returnType passed into Ctor" );
55 }
56
57 public void testNullParametersPassedToCtor()
58 throws Exception
59 {
60 try
61 {
62 new MethodDescriptor( "doMagic",
63 "int",
64 null,
65 Attribute.EMPTY_SET,
66 Attribute.EMPTY_SET );
67 }
68 catch( final NullPointerException npe )
69 {
70 assertEquals( "npe.getMessage()", "parameters", npe.getMessage() );
71 return;
72 }
73 fail( "Expected to fail due to null parameters passed into Ctor" );
74 }
75
76 public void testNullInParametersPassedToCtor()
77 throws Exception
78 {
79 try
80 {
81 new MethodDescriptor( "doMagic",
82 "int",
83 new ParameterDescriptor[]{null},
84 Attribute.EMPTY_SET,
85 Attribute.EMPTY_SET );
86 }
87 catch( final NullPointerException npe )
88 {
89 assertEquals( "npe.getMessage()",
90 "parameters[0]",
91 npe.getMessage() );
92 return;
93 }
94 fail( "Expected to fail due to null parameters[0] passed into Ctor" );
95 }
96 }