Source Code Cross Referenced for ConfigTest.java in  » EJB-Server-geronimo » kernel » org » apache » geronimo » kernel » 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 » EJB Server geronimo » kernel » org.apache.geronimo.kernel 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         */package org.apache.geronimo.kernel;
017:
018:        import junit.framework.TestCase;
019:        import org.apache.geronimo.gbean.AbstractName;
020:        import org.apache.geronimo.gbean.AbstractNameQuery;
021:        import org.apache.geronimo.gbean.GBeanData;
022:        import org.apache.geronimo.kernel.config.Configuration;
023:        import org.apache.geronimo.kernel.config.ConfigurationData;
024:        import org.apache.geronimo.kernel.config.ConfigurationUtil;
025:        import org.apache.geronimo.kernel.config.EditableConfigurationManager;
026:        import org.apache.geronimo.kernel.config.EditableKernelConfigurationManager;
027:        import org.apache.geronimo.kernel.management.State;
028:        import org.apache.geronimo.kernel.repository.Artifact;
029:        import org.apache.geronimo.kernel.repository.DefaultArtifactManager;
030:        import org.apache.geronimo.kernel.repository.DefaultArtifactResolver;
031:
032:        /**
033:         * @version $Rev: 476049 $ $Date: 2006-11-16 20:35:17 -0800 (Thu, 16 Nov 2006) $
034:         */
035:        public class ConfigTest extends TestCase {
036:            private Kernel kernel;
037:            private AbstractName gbeanName1;
038:            private AbstractName gbeanName2;
039:            private ConfigurationData configurationData;
040:            private EditableConfigurationManager configurationManager;
041:
042:            //    private final String BASE_NAME = "test:J2EEServer=geronimo";
043:
044:            public void testConfigLifecycle() throws Exception {
045:                Artifact configurationId = configurationData.getId();
046:
047:                // load -- config should be running and gbean registered but not started
048:                configurationManager.loadConfiguration(configurationData);
049:                Configuration configuration = configurationManager
050:                        .getConfiguration(configurationId);
051:                AbstractName configurationName = Configuration
052:                        .getConfigurationAbstractName(configurationId);
053:
054:                assertEquals(State.RUNNING_INDEX, kernel
055:                        .getGBeanState(configurationName));
056:                assertNotNull(configuration.getConfigurationClassLoader());
057:
058:                assertFalse(kernel.isLoaded(gbeanName1));
059:                assertFalse(kernel.isLoaded(gbeanName2));
060:
061:                // start -- gbeans should now be started
062:                configurationManager.startConfiguration(configurationId);
063:
064:                assertTrue(kernel.isLoaded(gbeanName1));
065:                assertTrue(kernel.isLoaded(gbeanName2));
066:
067:                assertEquals(State.RUNNING_INDEX, kernel
068:                        .getGBeanState(gbeanName1));
069:                assertEquals(State.RUNNING_INDEX, kernel
070:                        .getGBeanState(gbeanName2));
071:
072:                assertEquals(new Integer(1), kernel.getAttribute(gbeanName1,
073:                        "finalInt"));
074:                assertEquals("1234", kernel.getAttribute(gbeanName1, "value"));
075:                assertEquals(new Integer(3), kernel.getAttribute(gbeanName2,
076:                        "finalInt"));
077:
078:                kernel.setAttribute(gbeanName2, "mutableInt", new Integer(44));
079:                assertEquals(new Integer(44), kernel.getAttribute(gbeanName2,
080:                        "mutableInt"));
081:
082:                kernel.invoke(gbeanName2, "doSetMutableInt",
083:                        new Object[] { new Integer(55) },
084:                        new String[] { "int" });
085:                assertEquals(new Integer(55), kernel.getAttribute(gbeanName2,
086:                        "mutableInt"));
087:
088:                assertEquals("no endpoint", kernel.invoke(gbeanName1,
089:                        "checkEndpoint", null, null));
090:                assertEquals("endpointCheck", kernel.invoke(gbeanName2,
091:                        "checkEndpoint", null, null));
092:
093:                assertEquals(new Integer(0), kernel.invoke(gbeanName1,
094:                        "checkEndpointCollection", null, null));
095:                assertEquals(new Integer(1), kernel.invoke(gbeanName2,
096:                        "checkEndpointCollection", null, null));
097:
098:                kernel.setAttribute(gbeanName2, "endpointMutableInt",
099:                        new Integer(99));
100:                assertEquals(new Integer(99), kernel.getAttribute(gbeanName2,
101:                        "endpointMutableInt"));
102:                assertEquals(new Integer(99), kernel.getAttribute(gbeanName1,
103:                        "mutableInt"));
104:
105:                // stop -- gbeans should now be started, but still registered
106:                configurationManager.stopConfiguration(configurationId);
107:
108:                assertFalse(kernel.isLoaded(gbeanName1));
109:                assertFalse(kernel.isLoaded(gbeanName2));
110:
111:                // unload -- configuration and gbeans should be unloaded
112:                configurationManager.unloadConfiguration(configurationId);
113:
114:                assertFalse(kernel.isLoaded(configurationName));
115:                assertFalse(kernel.isLoaded(gbeanName1));
116:                assertFalse(kernel.isLoaded(gbeanName2));
117:
118:            }
119:
120:            public void testConfigStartStopRestart() throws Exception {
121:                Artifact configurationId = configurationData.getId();
122:
123:                // load -- config should be running and gbean registered but not started
124:                configurationManager.loadConfiguration(configurationData);
125:                Configuration configuration = configurationManager
126:                        .getConfiguration(configurationId);
127:                AbstractName configurationName = Configuration
128:                        .getConfigurationAbstractName(configurationId);
129:
130:                assertEquals(State.RUNNING_INDEX, kernel
131:                        .getGBeanState(configurationName));
132:                assertNotNull(configuration.getConfigurationClassLoader());
133:
134:                assertFalse(kernel.isLoaded(gbeanName1));
135:                assertFalse(kernel.isLoaded(gbeanName2));
136:
137:                // start -- gbeans should now be started
138:                configurationManager.startConfiguration(configurationId);
139:
140:                assertTrue(kernel.isLoaded(gbeanName1));
141:                assertTrue(kernel.isLoaded(gbeanName2));
142:                assertEquals(State.RUNNING_INDEX, kernel
143:                        .getGBeanState(gbeanName1));
144:                assertEquals(State.RUNNING_INDEX, kernel
145:                        .getGBeanState(gbeanName2));
146:
147:                // stop -- gbeans should now be started, but still registered
148:                configurationManager.stopConfiguration(configurationId);
149:
150:                assertFalse(kernel.isLoaded(gbeanName1));
151:                assertFalse(kernel.isLoaded(gbeanName2));
152:
153:                // restart -- gbeans should now be started
154:                configurationManager.startConfiguration(configurationId);
155:
156:                assertTrue(kernel.isLoaded(gbeanName1));
157:                assertTrue(kernel.isLoaded(gbeanName2));
158:                assertEquals(State.RUNNING_INDEX, kernel
159:                        .getGBeanState(gbeanName1));
160:                assertEquals(State.RUNNING_INDEX, kernel
161:                        .getGBeanState(gbeanName2));
162:
163:                // unload -- configuration and gbeans should be unloaded
164:                configurationManager.stopConfiguration(configurationId);
165:                configurationManager.unloadConfiguration(configurationId);
166:
167:                assertFalse(kernel.isLoaded(configurationName));
168:                assertFalse(kernel.isLoaded(gbeanName1));
169:                assertFalse(kernel.isLoaded(gbeanName2));
170:
171:            }
172:
173:            public void testAddToConfig() throws Exception {
174:                Artifact configurationId = configurationData.getId();
175:
176:                // load and start the config
177:                configurationManager.loadConfiguration(configurationData);
178:                Configuration configuration = configurationManager
179:                        .getConfiguration(configurationId);
180:                assertNotNull(configuration.getConfigurationClassLoader());
181:
182:                GBeanData mockBean3 = new GBeanData(MockGBean.getGBeanInfo());
183:                try {
184:                    kernel.getGBeanState(mockBean3.getAbstractName());
185:                    fail("Gbean should not be found yet");
186:                } catch (GBeanNotFoundException e) {
187:                }
188:                mockBean3.setAttribute("value", "1234");
189:                mockBean3.setAttribute("name", "child");
190:                mockBean3.setAttribute("finalInt", new Integer(1));
191:                configurationManager.addGBeanToConfiguration(configurationId,
192:                        "MyMockGMBean3", mockBean3, true);
193:
194:                assertEquals(State.RUNNING_INDEX, kernel
195:                        .getGBeanState(mockBean3.getAbstractName()));
196:                assertEquals(new Integer(1), kernel.getAttribute(mockBean3
197:                        .getAbstractName(), "finalInt"));
198:                assertEquals("1234", kernel.getAttribute(mockBean3
199:                        .getAbstractName(), "value"));
200:                assertEquals("child", kernel.getAttribute(mockBean3
201:                        .getAbstractName(), "name"));
202:            }
203:
204:            protected void setUp() throws Exception {
205:                super .setUp();
206:                kernel = KernelFactory.newInstance().createKernel("test");
207:                kernel.boot();
208:
209:                ConfigurationData bootstrap = new ConfigurationData(
210:                        new Artifact("bootstrap", "bootstrap", "", "car"),
211:                        kernel.getNaming());
212:
213:                GBeanData artifactManagerData = bootstrap.addGBean(
214:                        "ArtifactManager", DefaultArtifactManager.GBEAN_INFO);
215:
216:                GBeanData artifactResolverData = bootstrap.addGBean(
217:                        "ArtifactResolver", DefaultArtifactResolver.GBEAN_INFO);
218:                artifactResolverData.setReferencePattern("ArtifactManager",
219:                        artifactManagerData.getAbstractName());
220:
221:                GBeanData configurationManagerData = bootstrap.addGBean(
222:                        "ConfigurationManager",
223:                        EditableKernelConfigurationManager.GBEAN_INFO);
224:                configurationManagerData.setReferencePattern("ArtifactManager",
225:                        artifactManagerData.getAbstractName());
226:                configurationManagerData.setReferencePattern(
227:                        "ArtifactResolver", artifactResolverData
228:                                .getAbstractName());
229:
230:                ConfigurationUtil.loadBootstrapConfiguration(kernel, bootstrap,
231:                        getClass().getClassLoader());
232:
233:                configurationManager = ConfigurationUtil
234:                        .getEditableConfigurationManager(kernel);
235:
236:                configurationData = new ConfigurationData(new Artifact("test",
237:                        "test", "", "car"), kernel.getNaming());
238:
239:                GBeanData mockBean1 = configurationData.addGBean(
240:                        "MyMockGMBean1", MockGBean.getGBeanInfo());
241:                gbeanName1 = mockBean1.getAbstractName();
242:                mockBean1.setAttribute("value", "1234");
243:                mockBean1.setAttribute("name", "child");
244:                mockBean1.setAttribute("finalInt", new Integer(1));
245:
246:                GBeanData mockBean2 = configurationData.addGBean(
247:                        "MyMockGMBean2", MockGBean.getGBeanInfo());
248:                gbeanName2 = mockBean2.getAbstractName();
249:                mockBean2.setAttribute("value", "5678");
250:                mockBean2.setAttribute("name", "Parent");
251:                mockBean2.setAttribute("finalInt", new Integer(3));
252:                mockBean2.setReferencePattern("MockEndpoint", gbeanName1);
253:                mockBean2.setReferencePattern("EndpointCollection",
254:                        new AbstractNameQuery(gbeanName1, MockGBean
255:                                .getGBeanInfo().getInterfaces()));
256:            }
257:
258:            protected void tearDown() throws Exception {
259:                kernel.shutdown();
260:                super.tearDown();
261:            }
262:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.