KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > inversoft > verge > util > test > RequestContextTest


1 /*
2  * Copyright (c) 2003, Inversoft
3  *
4  * This software is distribuable under the GNU Lesser General Public License.
5  * For more information visit gnu.org.
6  */

7 package com.inversoft.verge.util.test;
8
9
10 import com.inversoft.error.BasicError;
11 import com.inversoft.error.PropertyError;
12 import com.inversoft.junit.WebTestCase;
13 import com.inversoft.verge.util.RequestContext;
14
15
16 /**
17  * <p>
18  * This class tests tests the methods on RequestContext
19  * </p>
20  *
21  * @author Brian Pontarelli
22  */

23 public class RequestContextTest extends WebTestCase {
24
25     /**
26      * Instantiates a new <code>RequestContextTest</code>
27      */

28     public RequestContextTest(String JavaDoc name) {
29         super(name);
30         setLocal(true);
31     }
32
33
34     /**
35      * Tests that the RequestContext correctly stores basic and property errors
36      */

37     public void testAll() {
38
39         BasicError basic = new BasicError("basic test");
40         PropertyError property = new PropertyError("propertyName", "property test");
41
42         RequestContext context = new RequestContext(request);
43         context.addError(basic);
44         context.addError(property);
45
46         assertTrue("Should be be true", context.hasErrors());
47         assertTrue("Should be be true", context.hasPropertyErrors("propertyName"));
48         assertTrue("Should be same basic", context.getBasicErrors().get(0) == basic);
49         assertTrue("Should be same property", context.getPropertyErrors().get(0) == property);
50         assertTrue("Should be same property", context.getPropertyErrors("propertyName").get(0) == property);
51
52         // Test that the lists are not live
53
context.getBasicErrors().clear();
54         context.getPropertyErrors().clear();
55         assertTrue("Should be same basic", context.getBasicErrors().get(0) == basic);
56         assertTrue("Should be same property", context.getPropertyErrors().get(0) == property);
57     }
58 }
59
Popular Tags