1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.jdtaus.core.container.it;
22
23 import java.util.Locale;
24 import junit.framework.Assert;
25 import junit.framework.TestCase;
26 import org.jdtaus.core.container.Container;
27
28
29
30
31
32
33
34 public class ContainerTest extends TestCase
35 {
36
37
38
39 private Container container;
40
41
42 public ContainerTest()
43 {
44 super();
45 }
46
47
48
49
50
51
52
53 public Container getContainer()
54 {
55 return this.container;
56 }
57
58
59
60
61
62
63 public final void setContainer( final Container value )
64 {
65 this.container = value;
66 }
67
68
69
70
71 public void testGetDependency() throws Exception
72 {
73 try
74 {
75 this.getContainer().getDependency( (Object) null, "TEST" );
76 throw new AssertionError( "Expected 'NullPointerException' not thrown." );
77 }
78 catch ( final NullPointerException e )
79 {
80 Assert.assertNotNull( e.getMessage() );
81 System.out.println( e.toString() );
82 }
83
84 try
85 {
86 this.getContainer().getDependency( this, null );
87 throw new AssertionError( "Expected 'NullPointerException' not thrown." );
88 }
89 catch ( final NullPointerException e )
90 {
91 Assert.assertNotNull( e.getMessage() );
92 System.out.println( e.toString() );
93 }
94 }
95
96 public void testGetMessage() throws Exception
97 {
98 try
99 {
100 this.getContainer().getMessage( (Object) null, "TEST", Locale.getDefault(), null );
101 throw new AssertionError( "Expected 'NullPointerException' not thrown." );
102 }
103 catch ( final NullPointerException e )
104 {
105 Assert.assertNotNull( e.getMessage() );
106 System.out.println( e.toString() );
107 }
108 try
109 {
110 this.getContainer().getMessage( this, null, Locale.getDefault(), null );
111 throw new AssertionError( "Expected 'NullPointerException' not thrown." );
112 }
113 catch ( final NullPointerException e )
114 {
115 Assert.assertNotNull( e.getMessage() );
116 System.out.println( e.toString() );
117 }
118 try
119 {
120 this.getContainer().getMessage( this, "TEST", null, null );
121 throw new AssertionError( "Expected 'NullPointerException' not thrown." );
122 }
123 catch ( final NullPointerException e )
124 {
125 Assert.assertNotNull( e.getMessage() );
126 System.out.println( e.toString() );
127 }
128 }
129
130 public void testGetObject() throws Exception
131 {
132 try
133 {
134 this.getContainer().getObject( (Class) null );
135 throw new AssertionError( "Expected 'NullPointerException' not thrown." );
136 }
137 catch ( final NullPointerException e )
138 {
139 Assert.assertNotNull( e.getMessage() );
140 System.out.println( e.toString() );
141 }
142
143 try
144 {
145 this.getContainer().getObject( (Class) null, "TEST" );
146 throw new AssertionError( "Expected 'NullPointerException' not thrown." );
147 }
148 catch ( final NullPointerException e )
149 {
150 Assert.assertNotNull( e.getMessage() );
151 System.out.println( e.toString() );
152 }
153 try
154 {
155 this.getContainer().getObject( this.getClass(), null );
156 throw new AssertionError( "Expected 'NullPointerException' not thrown." );
157 }
158 catch ( final NullPointerException e )
159 {
160 Assert.assertNotNull( e.getMessage() );
161 System.out.println( e.toString() );
162 }
163 }
164
165 public void testGetProperty() throws Exception
166 {
167 try
168 {
169 this.getContainer().getProperty( (Object) null, "TEST" );
170 throw new AssertionError( "Expected 'NullPointerException' not thrown." );
171 }
172 catch ( final NullPointerException e )
173 {
174 Assert.assertNotNull( e.getMessage() );
175 System.out.println( e.toString() );
176 }
177 try
178 {
179 this.getContainer().getProperty( this, null );
180 throw new AssertionError( "Expected 'NullPointerException' not thrown." );
181 }
182 catch ( final NullPointerException e )
183 {
184 Assert.assertNotNull( e.getMessage() );
185 System.out.println( e.toString() );
186 }
187 }
188
189
190 }