Source Code Cross Referenced for TestRegistryDocument.java in  » ESB » open-esb » com » sun » jbi » management » registry » xml » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » ESB » open esb » com.sun.jbi.management.registry.xml 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * BEGIN_HEADER - DO NOT EDIT
003:         *
004:         * The contents of this file are subject to the terms
005:         * of the Common Development and Distribution License
006:         * (the "License").  You may not use this file except
007:         * in compliance with the License.
008:         *
009:         * You can obtain a copy of the license at
010:         * https://open-esb.dev.java.net/public/CDDLv1.0.html.
011:         * See the License for the specific language governing
012:         * permissions and limitations under the License.
013:         *
014:         * When distributing Covered Code, include this CDDL
015:         * HEADER in each file and include the License file at
016:         * https://open-esb.dev.java.net/public/CDDLv1.0.html.
017:         * If applicable add the following below this CDDL HEADER,
018:         * with the fields enclosed by brackets "[]" replaced with
019:         * your own identifying information: Portions Copyright
020:         * [year] [name of copyright owner]
021:         */
022:
023:        /*
024:         * @(#)TestRegistryDocument.java
025:         * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026:         *
027:         * END_HEADER - DO NOT EDIT
028:         */
029:        package com.sun.jbi.management.registry.xml;
030:
031:        import com.sun.jbi.management.ComponentInfo;
032:        import com.sun.jbi.management.ConfigurationCategory;
033:        import com.sun.jbi.management.system.Util;
034:        import com.sun.jbi.management.registry.RegistryBuilder;
035:
036:        import javax.xml.parsers.DocumentBuilder;
037:        import javax.xml.parsers.DocumentBuilderFactory;
038:        import java.io.File;
039:        import org.w3c.dom.Document;
040:
041:        public class TestRegistryDocument extends junit.framework.TestCase {
042:            /**
043:             * The sample Configuration Directory.
044:             */
045:            private String mConfigDir = null;
046:            private File mRegFile;
047:            private Document mRegistryDocument;
048:
049:            String mRegFilePath;
050:            String mRegGoodFilePath;
051:
052:            public TestRegistryDocument(String aTestName) {
053:                super (aTestName);
054:
055:                String srcroot = System.getProperty("junit.srcroot");
056:                String manage = "/runtime/manage"; // open-esb build
057:                mConfigDir = srcroot + manage + "/bld/test-classes/testdata/";
058:
059:                java.io.File f = new java.io.File(srcroot + manage);
060:                if (!f.exists()) {
061:                    manage = "/shasta/manage"; // mainline/whitney build
062:                    mConfigDir = srcroot + manage + "/bld/regress/testdata/";
063:                }
064:
065:                mRegFilePath = mConfigDir + File.separator + "jbi-registry.xml";
066:                mRegGoodFilePath = mConfigDir + File.separator
067:                        + "jbi-registry-good.xml";
068:
069:                mRegFile = new File(mRegFilePath);
070:
071:            }
072:
073:            public void setUp() throws Exception {
074:                super .setUp();
075:
076:                Util.fileCopy(mRegGoodFilePath, mRegFilePath);
077:
078:                if (mRegFile.canRead()) {
079:                    DocumentBuilderFactory dbf = DocumentBuilderFactory
080:                            .newInstance();
081:                    DocumentBuilder db = dbf.newDocumentBuilder();
082:                    mRegistryDocument = db.parse(mRegFile);
083:                }
084:            }
085:
086:            public void tearDown() throws Exception {
087:
088:            }
089:
090:            /**
091:             * Test getting a configuration attribute value
092:             */
093:            public void testGetConfigurationAttribute() throws Exception {
094:                RegistryDocument regDoc = new RegistryDocument(
095:                        mRegistryDocument);
096:
097:                String value = regDoc.getConfigurationAttribute("domain",
098:                        ConfigurationCategory.Installation, "componentTimeout");
099:                assertEquals("5000", value);
100:            }
101:
102:            /**
103:             * Test getting a configuration attribute value
104:             */
105:            public void testGetOverridenConfigurationAttribute()
106:                    throws Exception {
107:                RegistryDocument regDoc = new RegistryDocument(
108:                        mRegistryDocument);
109:
110:                String value = regDoc.getConfigurationAttribute("clusterA",
111:                        ConfigurationCategory.Installation, "componentTimeout");
112:                assertEquals("4000", value);
113:            }
114:
115:            /**
116:             * Test getting all the attributes in a category
117:             */
118:            public void testGetConfigurationAttributes() throws Exception {
119:                RegistryDocument regDoc = new RegistryDocument(
120:                        mRegistryDocument);
121:
122:                java.util.Map<String, String> values = regDoc
123:                        .getConfigurationAttributes("domain",
124:                                ConfigurationCategory.Deployment);
125:                assertTrue(values.get("startOnDeploy").equals("true"));
126:                assertTrue(values.get("serviceUnitTimeout").equals("5000"));
127:                assertTrue(values.get("deploymentTimeout").equals("6000"));
128:            }
129:
130:            /**
131:             * Test getting all the attributes in a category for a target, which has some
132:             * overrides
133:             */
134:            public void testGetOverridenConfigurationAttributes()
135:                    throws Exception {
136:                RegistryDocument regDoc = new RegistryDocument(
137:                        mRegistryDocument);
138:
139:                java.util.Map<String, String> values = regDoc
140:                        .getConfigurationAttributes("clusterA",
141:                                ConfigurationCategory.Deployment);
142:
143:                assertTrue(values.get("startOnDeploy").equals("false"));
144:            }
145:
146:            /**
147:             * Test getting a missing configuration attribute.
148:             */
149:            public void testGetMissingConfigurationAttribute() throws Exception {
150:                RegistryDocument regDoc = new RegistryDocument(
151:                        mRegistryDocument);
152:
153:                String value = regDoc.getConfigurationAttribute("domain",
154:                        ConfigurationCategory.Installation, "xyz");
155:                assertNull(value);
156:            }
157:
158:            /**
159:             * Test getting component configuration attributes.
160:             */
161:            public void testGetComponentConfigurationAttributes() {
162:                RegistryDocument regDoc = new RegistryDocument(
163:                        mRegistryDocument);
164:
165:                java.util.Properties props = regDoc
166:                        .getComponentConfigurationAttributes("server", true,
167:                                "SunSequencingEngine");
168:                assertNotNull(props);
169:                assertEquals(props.get("HostName"), "tango");
170:                assertEquals(props.get("Port"), "5656");
171:            }
172:
173:            /**
174:             * Test getting component application variables.
175:             */
176:            public void testGetComponentApplicationVariables() {
177:                RegistryDocument regDoc = new RegistryDocument(
178:                        mRegistryDocument);
179:
180:                ComponentInfo.Variable[] vars = regDoc
181:                        .getComponentApplicationVariables("server", true,
182:                                "SunSequencingEngine");
183:                assertNotNull(vars);
184:                assertEquals(2, vars.length);
185:                ComponentInfo.Variable var = vars[0];
186:
187:                assertEquals(var.getName(), "name");
188:                assertEquals(var.getValue(), "Gill Bates");
189:                assertEquals(var.getType(), "STRING");
190:            }
191:
192:            /**
193:             * Test getting component application configuration.
194:             */
195:            public void testGetComponentApplicationConfiguration() {
196:                RegistryDocument regDoc = new RegistryDocument(
197:                        mRegistryDocument);
198:
199:                java.util.Map<String, java.util.Properties> configMap = regDoc
200:                        .getComponentApplicationConfiguration("server", true,
201:                                "SunSequencingEngine");
202:                assertTrue(configMap.containsKey("SEQ_CONFIG1"));
203:                assertTrue(configMap.containsKey("SEQ_CONFIG2"));
204:
205:                // -- Test whether the property values are read correctly
206:                java.util.Properties config1 = configMap.get("SEQ_CONFIG1");
207:                assertTrue(config1.getProperty("configurationName").equals(
208:                        "SEQ_CONFIG1"));
209:                assertTrue(config1.getProperty("initialContextFactory").equals(
210:                        "com.sonicsw.jndi.mfcontext.MFContextFactory"));
211:                assertTrue(config1.getProperty("connectionURL").equals(
212:                        "jndi://cfg1"));
213:
214:                java.util.Properties config2 = configMap.get("SEQ_CONFIG2");
215:                assertTrue(config2.getProperty("configurationName").equals(
216:                        "SEQ_CONFIG2"));
217:                assertTrue(config2.getProperty("initialContextFactory").equals(
218:                        "com.sonicsw.jndi.mfcontext.MFContextFactory"));
219:                assertTrue(config2.getProperty("connectionURL").equals(
220:                        "jndi://cfg2"));
221:            }
222:
223:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.