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
43
44
45
46
47 public Container getContainer()
48 {
49 return this.container;
50 }
51
52
53
54
55
56
57 public final void setContainer( final Container value )
58 {
59 this.container = value;
60 }
61
62
63
64
65 public void testGetDependency() throws Exception
66 {
67 try
68 {
69 this.getContainer().getDependency( (Object) null, "TEST" );
70 throw new AssertionError( "Expected 'NullPointerException' not thrown." );
71 }
72 catch ( NullPointerException e )
73 {
74 Assert.assertNotNull( e.getMessage() );
75 System.out.println( e.toString() );
76 }
77
78 try
79 {
80 this.getContainer().getDependency( this, null );
81 throw new AssertionError( "Expected 'NullPointerException' not thrown." );
82 }
83 catch ( NullPointerException e )
84 {
85 Assert.assertNotNull( e.getMessage() );
86 System.out.println( e.toString() );
87 }
88 }
89
90 public void testGetMessage() throws Exception
91 {
92 try
93 {
94 this.getContainer().getMessage( (Object) null, "TEST", Locale.getDefault(), null );
95 throw new AssertionError( "Expected 'NullPointerException' not thrown." );
96 }
97 catch ( NullPointerException e )
98 {
99 Assert.assertNotNull( e.getMessage() );
100 System.out.println( e.toString() );
101 }
102 try
103 {
104 this.getContainer().getMessage( this, null, Locale.getDefault(), null );
105 throw new AssertionError( "Expected 'NullPointerException' not thrown." );
106 }
107 catch ( NullPointerException e )
108 {
109 Assert.assertNotNull( e.getMessage() );
110 System.out.println( e.toString() );
111 }
112 try
113 {
114 this.getContainer().getMessage( this, "TEST", null, null );
115 throw new AssertionError( "Expected 'NullPointerException' not thrown." );
116 }
117 catch ( NullPointerException e )
118 {
119 Assert.assertNotNull( e.getMessage() );
120 System.out.println( e.toString() );
121 }
122 }
123
124 public void testGetObject() throws Exception
125 {
126 try
127 {
128 this.getContainer().getObject( (Class) null );
129 throw new AssertionError( "Expected 'NullPointerException' not thrown." );
130 }
131 catch ( NullPointerException e )
132 {
133 Assert.assertNotNull( e.getMessage() );
134 System.out.println( e.toString() );
135 }
136
137 try
138 {
139 this.getContainer().getObject( (Class) null, "TEST" );
140 throw new AssertionError( "Expected 'NullPointerException' not thrown." );
141 }
142 catch ( NullPointerException e )
143 {
144 Assert.assertNotNull( e.getMessage() );
145 System.out.println( e.toString() );
146 }
147 try
148 {
149 this.getContainer().getObject( this.getClass(), null );
150 throw new AssertionError( "Expected 'NullPointerException' not thrown." );
151 }
152 catch ( NullPointerException e )
153 {
154 Assert.assertNotNull( e.getMessage() );
155 System.out.println( e.toString() );
156 }
157 }
158
159 public void testGetProperty() throws Exception
160 {
161 try
162 {
163 this.getContainer().getProperty( (Object) null, "TEST" );
164 throw new AssertionError( "Expected 'NullPointerException' not thrown." );
165 }
166 catch ( NullPointerException e )
167 {
168 Assert.assertNotNull( e.getMessage() );
169 System.out.println( e.toString() );
170 }
171 try
172 {
173 this.getContainer().getProperty( this, null );
174 throw new AssertionError( "Expected 'NullPointerException' not thrown." );
175 }
176 catch ( NullPointerException e )
177 {
178 Assert.assertNotNull( e.getMessage() );
179 System.out.println( e.toString() );
180 }
181 }
182
183
184 }