KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > api > registry > mergedctx > ReusedContextTest


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.api.registry.mergedctx;
20
21 import org.netbeans.api.registry.Context;
22 import org.netbeans.api.registry.ContextTest;
23
24 public class ReusedContextTest extends ContextTest {
25     private Context rootCtx;
26
27     protected Context getRootContext() {
28         if (rootCtx == null)
29             rootCtx = SetUpUtils.getSimpleContext(super.getContext());
30         return rootCtx;
31     }
32
33     public ReusedContextTest(String JavaDoc name) {
34         super(name);
35     }
36
37     protected void setUp() throws Exception JavaDoc {
38         super.setUp();
39         getRootContext();
40     }
41
42     public void testContextMerge() throws Exception JavaDoc {
43         Context ctx1 = SetUpUtils.getSubctx1();
44         Context ctx2 = SetUpUtils.getSubctx2();
45         Context ctx3 = SetUpUtils.getSubctx3();
46
47         String JavaDoc subcontextName = "TestMerge";
48         ctx2 = ctx2.createSubcontext(subcontextName);
49         ctx3 = ctx3.createSubcontext(subcontextName);
50
51         String JavaDoc subSubcontextName1 = "AMerge";
52         String JavaDoc subSubcontextName2 = "BMerge";
53         String JavaDoc subSubcontextName3 = "CMerge";
54
55         ctx2.createSubcontext(subSubcontextName2);
56         ctx3.createSubcontext(subSubcontextName3);
57
58
59         Context test = rootCtx.getSubcontext(subcontextName);
60         assertTrue(test != null);
61         assertTrue(test.getSubcontext(subSubcontextName2) != null);
62         assertTrue(test.getSubcontext(subSubcontextName3) != null);
63
64         ctx1 = ctx1.createSubcontext(subcontextName);
65         ctx1.createSubcontext(subSubcontextName1);
66
67         assertTrue(test != null);
68         assertTrue(test.getSubcontext(subSubcontextName1) != null);
69         assertTrue(test.getSubcontext(subSubcontextName2) != null);
70         assertTrue(test.getSubcontext(subSubcontextName3) != null);
71     }
72 }
73
Popular Tags