Source Code Cross Referenced for TestComponentInstaller.java in  » ESB » open-esb » com » sun » jbi » framework » 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.framework 
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:         * @(#)TestComponentInstaller.java
025:         * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026:         *
027:         * END_HEADER - DO NOT EDIT
028:         */
029:        package com.sun.jbi.framework;
030:
031:        import com.sun.jbi.management.ComponentInstallationContext;
032:
033:        import java.io.File;
034:
035:        import javax.management.ObjectName;
036:
037:        /**
038:         * Tests for the ComponentInstaller class. Note that these test are minimal,
039:         * because the class does nothing more than delegate to the ComponentFramework.
040:         * The tests here are merely to make sure the ComponentFramework methods get
041:         * invoked.
042:         *
043:         * @author Sun Microsystems, Inc.
044:         */
045:        public class TestComponentInstaller extends junit.framework.TestCase {
046:            /**
047:             * EnvironmentContext
048:             */
049:            private EnvironmentContext mEnvironmentContext;
050:
051:            /**
052:             * EnvironmentSetup
053:             */
054:            private EnvironmentSetup mEnvironmentSetup;
055:
056:            /**
057:             * ComponentInstallationContext
058:             */
059:            private ComponentInstallationContext mInstallationContext;
060:
061:            /**
062:             * ComponentInstaller
063:             */
064:            private ComponentInstaller mComponentInstaller;
065:
066:            /**
067:             * Constant for install root
068:             */
069:            private static final String COMP_INSTALL_ROOT = "/as8/domains/domain1/jbi/TestComponent";
070:
071:            /**
072:             * Constant for lifecycle class name
073:             */
074:            private static final String COMP_CLASS_NAME = "com.sun.jbi.framework.TestComponent";
075:
076:            /**
077:             * Constant for component name
078:             */
079:            private static final String COMP_NAME = "TestComponent";
080:
081:            /**
082:             * Constant for workspace root
083:             */
084:            private static final String COMP_WORKSPACE_ROOT = "/as8/domains/domain1/jbi/work/TestComponent";
085:
086:            /**
087:             * The constructor for this testcase, forwards the test name to
088:             * the jUnit TestCase base class.
089:             * @param aTestName String with the name of this test.
090:             */
091:            public TestComponentInstaller(String aTestName) {
092:                super (aTestName);
093:            }
094:
095:            /**
096:             * Setup for the test. This creates the ComponentInstaller instance
097:             * and other objects needed for the tests.
098:             * @throws Exception when set up fails for any reason.
099:             */
100:            public void setUp() throws Exception {
101:                super .setUp();
102:
103:                // Create an EnvironmentContext
104:                mEnvironmentSetup = new EnvironmentSetup();
105:                mEnvironmentContext = mEnvironmentSetup.getEnvironmentContext();
106:
107:                // Start up the Component Registry and Component Framework
108:                mEnvironmentSetup.startup(true, true);
109:
110:                // Create a ComponentInstallationContext
111:                mInstallationContext = new ComponentInstallationContext(
112:                        COMP_NAME, ComponentInstallationContext.BINDING,
113:                        COMP_CLASS_NAME, null, null);
114:                mInstallationContext.setInstallRoot(COMP_INSTALL_ROOT);
115:                mInstallationContext.setWorkspaceRoot(COMP_WORKSPACE_ROOT);
116:
117:                // Create a ComponentInstaller
118:                mComponentInstaller = new ComponentInstaller(
119:                        mInstallationContext, mEnvironmentContext
120:                                .getComponentFramework(), mEnvironmentContext
121:                                .getComponentRegistry());
122:            }
123:
124:            /**
125:             * Cleanup for the test.
126:             * @throws Exception when tearDown fails for any reason.
127:             */
128:            public void tearDown() throws Exception {
129:                mEnvironmentSetup.shutdown(true, true);
130:                super .tearDown();
131:            }
132:
133:            // =============================  test methods ================================
134:
135:            /**
136:             * Test the get method for the installer configuration MBean name.
137:             * @throws Exception if an unexpected error occurs.
138:             */
139:            public void testGetInstallerConfigurationMBean() throws Exception {
140:                // The test is for a fresh install, and will fail because the
141:                // component's installer has not been loaded.
142:                try {
143:                    ObjectName mbn = mComponentInstaller
144:                            .getInstallerConfigurationMBean();
145:                    fail("Expected exception not received");
146:                } catch (javax.jbi.JBIException jbiEx) {
147:                    // Verification
148:                    assertTrue("Incorrect exception received from install(): "
149:                            + jbiEx.getMessage(), (-1 < jbiEx.getMessage()
150:                            .indexOf("not found")));
151:                }
152:            }
153:
154:            /**
155:             * Test the get method for the component install root directory.
156:             * @throws Exception if an unexpected error occurs.
157:             */
158:            public void testGetInstallRoot() throws Exception {
159:                String installRoot = mComponentInstaller.getInstallRoot();
160:                assertEquals("Failure on getInstallRoot(): ", COMP_INSTALL_ROOT
161:                        .replace('/', File.separatorChar), installRoot);
162:            }
163:
164:            /**
165:             * Test the install method.
166:             * @throws Exception if an unexpected error occurs.
167:             */
168:            public void testInstall() throws Exception {
169:                // The test is for a fresh install, and will fail because the
170:                // component's installer has not been loaded.
171:                try {
172:                    ObjectName on = mComponentInstaller.install();
173:                    fail("Expected exception not received");
174:                } catch (javax.jbi.JBIException jbiEx) {
175:                    // Verification
176:                    assertTrue("Incorrect exception received from install(): "
177:                            + jbiEx.getMessage(), (-1 < jbiEx.getMessage()
178:                            .indexOf("not yet been loaded")));
179:                }
180:            }
181:
182:            /**
183:             * Test the method for checking whether the component is installed.
184:             * @throws Exception if an unexpected error occurs.
185:             */
186:            public void testIsInstalled() throws Exception {
187:                boolean installed = mComponentInstaller.isInstalled();
188:                assertFalse(
189:                        "Failure on isInstalled(): returned true, expected false",
190:                        installed);
191:            }
192:
193:            /**
194:             * Test the uninstall method.
195:             * @throws Exception if an unexpected error occurs.
196:             */
197:            public void testUninstall() throws Exception {
198:                try {
199:                    mComponentInstaller.uninstall();
200:                    fail("Expected exception not received");
201:                } catch (javax.jbi.JBIException jbiEx) {
202:                    // Verification
203:                    assertTrue(
204:                            "Incorrect exception received from uninstall(): "
205:                                    + jbiEx.getMessage(), (-1 < jbiEx
206:                                    .getMessage().indexOf(
207:                                            "no Binding installed")));
208:                }
209:            }
210:
211:            /**
212:             * Test the uninstall method with the force flag.
213:             * @throws Exception if an unexpected error occurs.
214:             */
215:            public void testUninstallForce() throws Exception {
216:                try {
217:                    mComponentInstaller.uninstall(true);
218:                    fail("Expected exception not received");
219:                } catch (javax.jbi.JBIException jbiEx) {
220:                    // Verification
221:                    assertTrue(
222:                            "Incorrect exception received from uninstall(): "
223:                                    + jbiEx.getMessage(), (-1 < jbiEx
224:                                    .getMessage().indexOf(
225:                                            "no Binding installed")));
226:                }
227:            }
228:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.