Source Code Cross Referenced for TestGenericQueryImpl.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:         * @(#)TestGenericQueryImpl.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.ConfigurationCategory;
032:        import com.sun.jbi.management.registry.GenericQuery;
033:        import com.sun.jbi.management.registry.Registry;
034:        import com.sun.jbi.management.registry.RegistryBuilder;
035:        import com.sun.jbi.management.registry.RegistryException;
036:
037:        import com.sun.jbi.management.repository.Repository;
038:        import com.sun.jbi.management.repository.ArchiveType;
039:
040:        import com.sun.jbi.management.system.Util;
041:
042:        import java.io.File;
043:        import java.math.BigInteger;
044:        import java.util.List;
045:
046:        public class TestGenericQueryImpl extends junit.framework.TestCase {
047:            /**
048:             * The sample Configuration Directory.
049:             */
050:            private String mConfigDir = null;
051:            private File mRegFile;
052:            String mRegFilePath;
053:            String mRegGoodFilePath;
054:            String mComponentZipPath;
055:            String mSharedLibraryZipPath;
056:            String mServiceAssemblyZipPath;
057:
058:            static final String COMPONENT_NAME = "SunSequencingEngine";
059:            static final String SHARED_LIBRARY_NAME = "SunWSDLSharedLibrary";
060:            static final String SERVICE_ASSEMBLY_NAME = "CompositeApplication";
061:            static final String SERVICE_UNIT_NAME = "ESB_ADMIN_SERVICE_UNIT_1";
062:
063:            public TestGenericQueryImpl(String aTestName) {
064:                super (aTestName);
065:
066:                String srcroot = System.getProperty("junit.srcroot");
067:                String manage = "/runtime/manage"; // open-esb build
068:                mConfigDir = srcroot + manage + "/bld/test-classes/testdata/";
069:
070:                java.io.File f = new java.io.File(srcroot + manage);
071:                if (!f.exists()) {
072:                    manage = "/shasta/manage"; // mainline/whitney build
073:                    mConfigDir = srcroot + manage + "/bld/regress/testdata/";
074:                }
075:
076:                mRegFilePath = mConfigDir + File.separator + "jbi-registry.xml";
077:                mRegGoodFilePath = mConfigDir + File.separator
078:                        + "jbi-registry-good.xml";
079:                mComponentZipPath = mConfigDir + "component.zip";
080:                mServiceAssemblyZipPath = mConfigDir + "service-assembly.zip";
081:                mSharedLibraryZipPath = mConfigDir + "wsdlsl.jar";
082:
083:                mRegFile = new File(mRegFilePath);
084:
085:            }
086:
087:            public void setUp() throws Exception {
088:                super .setUp();
089:                if (mRegFile.exists()) {
090:                    mRegFile.delete();
091:                }
092:                Util.fileCopy(mRegGoodFilePath, mRegFilePath);
093:            }
094:
095:            public void tearDown() throws Exception {
096:                // -- restore registry.xml
097:                RegistryBuilder.destroyRegistry();
098:                Util.fileCopy(mRegGoodFilePath, mRegFilePath);
099:            }
100:
101:            /**
102:             * @throws Exception if an unexpected error occurs
103:             */
104:            public void testGetClustersDeployingServiceAssembly()
105:                    throws Exception {
106:                Registry reg = Util.createRegistry(true);
107:                GenericQuery query = reg.getGenericQuery();
108:
109:                List<String> clusters = query
110:                        .getClustersDeployingServiceAssembly(SERVICE_ASSEMBLY_NAME);
111:
112:                assertTrue(clusters.contains("clusterA"));
113:
114:            }
115:
116:            /**
117:             * @throws Exception if an unexpected error occurs
118:             */
119:            public void testGetClustersInstallingComponent() throws Exception {
120:                Registry reg = Util.createRegistry(true);
121:                GenericQuery query = reg.getGenericQuery();
122:
123:                List<String> clusters = query
124:                        .getClustersInstallingComponent(COMPONENT_NAME);
125:                assertTrue(clusters.contains("clusterA"));
126:            }
127:
128:            /**
129:             * @throws Exception if an unexpected error occurs
130:             */
131:            public void testGetClustersInstallingSharedLibrary()
132:                    throws Exception {
133:                Registry reg = Util.createRegistry(true);
134:                GenericQuery query = reg.getGenericQuery();
135:
136:                List<String> clusters = query
137:                        .getClustersInstallingSharedLibrary(SHARED_LIBRARY_NAME);
138:                assertTrue(clusters.contains("clusterA"));
139:
140:            }
141:
142:            public void testGetComponentInstallationDescriptor()
143:                    throws Exception {
144:                Registry reg = Util.createRegistry(true);
145:                GenericQuery query = reg.getGenericQuery();
146:
147:                Repository repository = reg.getRegistrySpec()
148:                        .getManagementContext().getRepository();
149:
150:                repository.addArchive(ArchiveType.COMPONENT, mComponentZipPath);
151:
152:                String jbiXml = query
153:                        .getComponentInstallationDescriptor(COMPONENT_NAME);
154:                assertTrue(jbiXml.startsWith("<?xml"));
155:                repository.purge();
156:            }
157:
158:            public void testGetSharedLibraryInstallationDescriptor()
159:                    throws Exception {
160:                Registry reg = Util.createRegistry(true);
161:                GenericQuery query = reg.getGenericQuery();
162:
163:                Repository repository = reg.getRegistrySpec()
164:                        .getManagementContext().getRepository();
165:
166:                repository.addArchive(ArchiveType.SHARED_LIBRARY,
167:                        mSharedLibraryZipPath);
168:
169:                String jbiXml = query
170:                        .getSharedLibraryInstallationDescriptor(SHARED_LIBRARY_NAME);
171:                assertTrue(jbiXml.startsWith("<?xml"));
172:                repository.purge();
173:            }
174:
175:            public void testGetServiceAssemblyDeploymentDescriptor()
176:                    throws Exception {
177:                Registry reg = Util.createRegistry(true);
178:                GenericQuery query = reg.getGenericQuery();
179:
180:                Repository repository = reg.getRegistrySpec()
181:                        .getManagementContext().getRepository();
182:
183:                repository.addArchive(ArchiveType.SERVICE_ASSEMBLY,
184:                        mServiceAssemblyZipPath);
185:
186:                String jbiXml = query
187:                        .getServiceAssemblyDeploymentDescriptor(SERVICE_ASSEMBLY_NAME);
188:                assertTrue(jbiXml.startsWith("<?xml"));
189:                repository.purge();
190:            }
191:
192:            public void testGetServiceUnitDeploymentDescriptor()
193:                    throws Exception {
194:                Registry reg = Util.createRegistry(true);
195:                GenericQuery query = reg.getGenericQuery();
196:
197:                Repository repository = reg.getRegistrySpec()
198:                        .getManagementContext().getRepository();
199:
200:                repository.addArchive(ArchiveType.SERVICE_ASSEMBLY,
201:                        mServiceAssemblyZipPath);
202:
203:                String jbiXml = query.getServiceUnitDeploymentDescriptor(
204:                        SERVICE_ASSEMBLY_NAME, SERVICE_UNIT_NAME);
205:                assertTrue(jbiXml.startsWith("<?xml"));
206:                repository.purge();
207:            }
208:
209:            public void testIsServiceAssemblyDeployed() throws Exception {
210:                Registry reg = Util.createRegistry(true);
211:                GenericQuery query = reg.getGenericQuery();
212:
213:                assertFalse(query.isServiceAssemblyDeployed("SA"));
214:                assertTrue(query
215:                        .isServiceAssemblyDeployed(SERVICE_ASSEMBLY_NAME));
216:            }
217:
218:            /**
219:             * This method is used to test the system-install attribute
220:             */
221:            public void testIsSystemComponent() throws Exception {
222:                Registry reg = Util.createRegistry(true);
223:                GenericQuery query = reg.getGenericQuery();
224:
225:                assertFalse(query.isSystemComponent("SunSequencingEngine"));
226:                assertFalse(query.isSystemComponent("SunJMSBinding"));
227:            }
228:
229:            /**
230:             * This method is used to test the system-install attribute for a 
231:             * shared library
232:             */
233:            public void testIsSystemSharedLibrary() throws Exception {
234:                Registry reg = Util.createRegistry(true);
235:                GenericQuery query = reg.getGenericQuery();
236:
237:                assertFalse(query.isSystemSharedLibrary("SunWSDLSharedLibrary"));
238:
239:            }
240:
241:            /**
242:             * Test getting the component file name
243:             */
244:            public void testGetComponentFileName() throws Exception {
245:                Registry reg = Util.createRegistry(true);
246:                GenericQuery query = reg.getGenericQuery();
247:
248:                assertEquals(query.getComponentFileName(COMPONENT_NAME),
249:                        "sequenceengine.zip");
250:                assertNull(query.getComponentFileName("xyz"));
251:            }
252:
253:            /**
254:             * Test getting the shared library file name
255:             */
256:            public void testGetSharedLibraryFileName() throws Exception {
257:                Registry reg = Util.createRegistry(true);
258:                GenericQuery query = reg.getGenericQuery();
259:
260:                assertEquals(query
261:                        .getSharedLibraryFileName(SHARED_LIBRARY_NAME),
262:                        "wsdlsl.jar");
263:
264:                assertNull(query.getSharedLibraryFileName("xyz"));
265:            }
266:
267:            /**
268:             * Test getting the service assembly file name
269:             */
270:            public void testGetServiceAssemblyFileName() throws Exception {
271:                Registry reg = Util.createRegistry(true);
272:                GenericQuery query = reg.getGenericQuery();
273:
274:                assertEquals(query
275:                        .getServiceAssemblyFileName(SERVICE_ASSEMBLY_NAME),
276:                        "service-assembly.zip");
277:
278:                assertNull(query.getServiceAssemblyFileName("xyz"));
279:            }
280:
281:            /**
282:             * Test isComponentRegistered(), the component should be removed from the
283:             * registry, since there is no repos entry and a false is returned
284:             */
285:            public void testIsComponentRegistered() throws Exception {
286:                Registry reg = Util.createRegistry(true);
287:                GenericQuery query = reg.getGenericQuery();
288:
289:                assertTrue(query.isComponentRegistered(COMPONENT_NAME));
290:            }
291:
292:            /**
293:             * Test isSharedLibraryRegistered(), the library should be removed from the
294:             * registry, since there is no repos entry and a false is returned
295:             */
296:            public void testIsSharedLibraryRegistered() throws Exception {
297:                Registry reg = Util.createRegistry(true);
298:                GenericQuery query = reg.getGenericQuery();
299:
300:                assertTrue(query.isSharedLibraryRegistered(SHARED_LIBRARY_NAME));
301:            }
302:
303:            /**
304:             * Test isServiceAssemblyRegistered(), the sa should be removed from the
305:             * registry, since there is no repos entry and a false is returned
306:             */
307:            public void testIsServiceAssemblyRegistered() throws Exception {
308:                Registry reg = Util.createRegistry(true);
309:                GenericQuery query = reg.getGenericQuery();
310:
311:                Repository repository = reg.getRegistrySpec()
312:                        .getManagementContext().getRepository();
313:
314:                repository.addArchive(ArchiveType.COMPONENT, mComponentZipPath);
315:                assertTrue(query
316:                        .isServiceAssemblyRegistered(SERVICE_ASSEMBLY_NAME));
317:
318:                com.sun.jbi.ComponentQuery compQuery = reg
319:                        .getComponentQuery("server");
320:
321:                com.sun.jbi.ComponentInfo compInfo = compQuery
322:                        .getComponentInfo(COMPONENT_NAME);
323:                assertNotNull(compInfo);
324:
325:                List<com.sun.jbi.ServiceUnitInfo> suList = compInfo
326:                        .getServiceUnitList();
327:
328:                assertFalse(suList.isEmpty());
329:                repository.purge();
330:            }
331:
332:            /**
333:             * Test getting a configuration attribute from the domain-configuration
334:             */
335:            public void testGetAttribute() throws Exception {
336:                Registry reg = Util.createRegistry(true);
337:                GenericQuery query = reg.getGenericQuery();
338:
339:                String attrValue = query.getAttribute("domain",
340:                        ConfigurationCategory.Installation, "componentTimeout");
341:
342:                assertTrue("5000".equals(attrValue));
343:            }
344:
345:            /**
346:             * Test getting a configuration attribute for a target which is not overriden.
347:             */
348:            public void testGetAttributeForTarget() throws Exception {
349:                Registry reg = Util.createRegistry(true);
350:                GenericQuery query = reg.getGenericQuery();
351:
352:                String attrValue = query.getAttribute("clusterB",
353:                        ConfigurationCategory.Installation, "componentTimeout");
354:
355:                assertTrue("5000".equals(attrValue));
356:            }
357:
358:            /**
359:             * Test getting a configuration attribute for a target which is overriden.
360:             */
361:            public void testGetAttributeForOverridenTarget() throws Exception {
362:                Registry reg = Util.createRegistry(true);
363:                GenericQuery query = reg.getGenericQuery();
364:
365:                String attrValue = query.getAttribute("clusterA",
366:                        ConfigurationCategory.Installation, "componentTimeout");
367:
368:                assertTrue("4000".equals(attrValue));
369:            }
370:
371:            /**
372:             * Test getting a missing configuration attribute, should get back a null.
373:             */
374:            public void testGetNonExistantAttribute() throws Exception {
375:                Registry reg = Util.createRegistry(true);
376:                GenericQuery query = reg.getGenericQuery();
377:
378:                String attrValue = query.getAttribute("clusterA",
379:                        ConfigurationCategory.Installation, "someTimeout");
380:
381:                assertNull(attrValue);
382:            }
383:
384:            /**
385:             * Test if domain config exists
386:             */
387:            public void testIsGlobalConfigurationDefined() throws Exception {
388:                Registry reg = Util.createRegistry(true);
389:                GenericQuery query = reg.getGenericQuery();
390:                assertTrue(query.isGlobalConfigurationDefined());
391:            }
392:
393:            /**
394:             * This method is used to test the method getComponentUpgradeNumber.
395:             * upgrade-number is an optional attribute. For a component that does not have
396:             * it would return 0.
397:             */
398:            public void testGetComponentUpgradeNumber() throws Exception {
399:                Registry reg = Util.createRegistry(true);
400:                GenericQuery query = reg.getGenericQuery();
401:                assertEquals(query
402:                        .getComponentUpgradeNumber("SunSequencingEngine"),
403:                        BigInteger.ZERO);
404:                assertEquals(query.getComponentUpgradeNumber("SunJMSBinding"),
405:                        BigInteger.ONE);
406:            }
407:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.