KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > wsmgmt > repository > impl > cache > CacheMgrTest


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 package com.sun.enterprise.admin.wsmgmt.repository.impl.cache;
24
25 import java.util.List JavaDoc;
26 import java.util.ArrayList JavaDoc;
27 import java.util.Iterator JavaDoc;
28 import java.util.Map JavaDoc;
29 import java.util.Collection JavaDoc;
30
31 /**
32  * Test class for cache manager object.
33  *
34  * @author Nazrul Islam
35  * @since J2SE 5.0
36  */

37 class CacheMgrTest {
38
39     public static void testSave() {
40         CacheMgr mgr = CacheMgr.getInstance();
41         List JavaDoc ejbModules = new ArrayList JavaDoc();
42         List JavaDoc webModules = new ArrayList JavaDoc();
43
44         ejbModules.add("ejb1.jar");
45         webModules.add("web1.war");
46         mgr.addJ2eeApplication("app1", ejbModules, webModules);
47
48         List JavaDoc ejbModules2 = new ArrayList JavaDoc();
49         List JavaDoc webModules2 = new ArrayList JavaDoc();
50         ejbModules2.add("ejb2.jar");
51         webModules2.add("web2.war");
52         ejbModules2.add("ejb3.jar");
53         webModules2.add("web3.war");
54         mgr.addJ2eeApplication("app2", ejbModules2, webModules2);
55
56         mgr.addEjbModule("ejb-module1");
57         mgr.addWebModule("web-module1");
58
59         mgr.save();
60     }
61
62     public static void testLoad() {
63         CacheMgr mgr = CacheMgr.getInstance();
64
65         System.out.println("J2EE APPLICATION:");
66         Map JavaDoc apps = mgr.getJ2eeApplications();
67         Collection JavaDoc values = apps.values();
68         for (Iterator JavaDoc iter=values.iterator(); iter.hasNext();) {
69             J2eeApplication app = (J2eeApplication) iter.next();
70             System.out.println("\t"+app.getName()+"="+app.getPersistentValue());
71         }
72
73         System.out.println("EJB MODULES:");
74         Map JavaDoc ejbModules = mgr.getEjbModules();
75         Collection JavaDoc ejbValues = ejbModules.values();
76         for (Iterator JavaDoc iter=ejbValues.iterator(); iter.hasNext();) {
77             String JavaDoc ejbModule = (String JavaDoc) iter.next();
78             System.out.println("\t"+ejbModule);
79         }
80
81         System.out.println("WEB MODULES:");
82         Map JavaDoc webModules = mgr.getWebModules();
83         Collection JavaDoc webValues = webModules.values();
84         for (Iterator JavaDoc iter=webValues.iterator(); iter.hasNext();) {
85             String JavaDoc webModule = (String JavaDoc) iter.next();
86             System.out.println("\t"+webModule);
87         }
88     }
89
90     public static void main(String JavaDoc[] args) {
91         testSave();
92         testLoad();
93     }
94 }
95
Popular Tags