1 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 name) { 34 super(name); 35 } 36 37 protected void setUp() throws Exception { 38 super.setUp(); 39 getRootContext(); 40 } 41 42 public void testContextMerge() throws Exception { 43 Context ctx1 = SetUpUtils.getSubctx1(); 44 Context ctx2 = SetUpUtils.getSubctx2(); 45 Context ctx3 = SetUpUtils.getSubctx3(); 46 47 String subcontextName = "TestMerge"; 48 ctx2 = ctx2.createSubcontext(subcontextName); 49 ctx3 = ctx3.createSubcontext(subcontextName); 50 51 String subSubcontextName1 = "AMerge"; 52 String subSubcontextName2 = "BMerge"; 53 String 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 |