KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > config > serverbeans > validation > FrameHolderTest


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.enterprise.config.serverbeans.validation;
25
26 import junit.framework.*;
27 /**
28  *
29  * @author <a HREF="mailto:toby.h.ferguson@sun.com">Toby H Ferguson</a>
30  * @version $Revision: 1.3 $
31  */

32
33 public class FrameHolderTest extends TestCase {
34     public void testEquality(){
35         FrameHolder fh1 = new FrameHolder();
36         FrameHolder fh2 = new FrameHolder();
37         assertEquals(fh1, fh2);
38         assertFalse(fh1.equals(new Object JavaDoc()));
39         assertFalse(fh1.equals(null));
40         assertEquals(fh1, fh1);
41         fh1.getDomainFrame().put("k", "v");
42         assertFalse(fh1.equals(fh2));
43         assertFalse(fh2.equals(fh1));
44     }
45     
46     public void testBasics() {
47         FrameHolder fh = new FrameHolder();
48         assertNotNull(fh.getDomainFrame());
49         fh.getDomainFrame().put("k", "v");
50         assertNotNull(fh.getConfigFrame("config0"));
51         fh.getConfigFrame("config0").inheritFrom(fh.getDomainFrame());
52         assertEquals("v", fh.getConfigFrame("config0").lookup("k"));
53         assertNotNull(fh.getConfigFrame("config1"));
54         assertFalse(fh.getConfigFrame("config0").equals(fh.getConfigFrame("config1")));
55         assertNotNull(fh.getServerFrame("frame0"));
56         fh.getServerFrame("frame0").inheritFrom(fh.getConfigFrame("config0"));
57         assertEquals("v", fh.getServerFrame("frame0").lookup("k"));
58         assertNotNull(fh.getClusterFrame("frame0"));
59         fh.getConfigFrame("config1").put("k", "config");
60         fh.getClusterFrame("frame0").inheritFrom(fh.getConfigFrame("config1"));
61         fh.getServerFrame("frame1").inheritFrom(fh.getClusterFrame("frame0"));
62         assertEquals("config", fh.getServerFrame("frame1").lookup("k"));
63     }
64
65     public FrameHolderTest(String JavaDoc name){
66         super(name);
67     }
68
69     protected void setUp() {
70     }
71
72     protected void tearDown() {
73     }
74
75     private void nyi(){
76         fail("Not Yet Implemented");
77     }
78
79     public static void main(String JavaDoc args[]){
80         if (args.length == 0){
81             junit.textui.TestRunner.run(FrameHolderTest.class);
82         } else {
83             junit.textui.TestRunner.run(makeSuite(args));
84         }
85     }
86     private static TestSuite makeSuite(String JavaDoc args[]){
87         final TestSuite ts = new TestSuite();
88         for (int i = 0; i < args.length; i++){
89             ts.addTest(new FrameHolderTest(args[i]));
90         }
91         return ts;
92     }
93 }
94
Popular Tags