Source Code Cross Referenced for GBeanInfoTest.java in  » EJB-Server-geronimo » kernel » org » apache » geronimo » gbean » 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.gbean 
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.gbean;
017:
018:        import java.io.ByteArrayInputStream;
019:        import java.io.ByteArrayOutputStream;
020:        import java.io.FileInputStream;
021:        import java.io.ObjectInputStream;
022:        import java.io.ObjectOutputStream;
023:        import java.util.List;
024:        import java.util.Set;
025:
026:        import org.apache.geronimo.testsupport.TestSupport;
027:
028:        /**
029:         * @version $Rev: 558235 $ $Date: 2007-07-20 20:47:45 -0700 (Fri, 20 Jul 2007) $
030:         */
031:        public class GBeanInfoTest extends TestSupport {
032:            private static final String CONSTRUCTOR_ARG_0 = "ConstructorArg_0";
033:            private static final String CONSTRUCTOR_ARG_1 = "ConstructorArg_1";
034:
035:            public void testGetGBeanInfo() {
036:                // 1. Test GBean that exists
037:                GBeanInfo gbeanInfo = GBeanInfo.getGBeanInfo(MockGBean.class
038:                        .getName(), MockGBean.class.getClassLoader());
039:                assertNotNull(gbeanInfo);
040:
041:                // 2. Test GBean that doesn't exist
042:                try {
043:                    GBeanInfo.getGBeanInfo("ClassThatDoesNotExist", this 
044:                            .getClass().getClassLoader());
045:                    fail("InvalidConfigurationException expected");
046:                } catch (InvalidConfigurationException expected) {
047:                }
048:
049:                // 3. Test GBean that exist, but doesn't declare a getGBeanInfo()
050:                // method
051:                try {
052:                    GBeanInfo.getGBeanInfo(String.class.getName(), this 
053:                            .getClass().getClassLoader());
054:                    fail("InvalidConfigurationException expected");
055:                } catch (InvalidConfigurationException expected) {
056:                }
057:            }
058:
059:            public void testGetName() {
060:                assertEquals(MockGBean.class.getName(), gbeanInfo.getName());
061:            }
062:
063:            public void testGetClassName() {
064:                assertEquals(MockGBean.class.getName(), gbeanInfo
065:                        .getClassName());
066:            }
067:
068:            public void testGetAttributeSet() {
069:                Set attrSet = gbeanInfo.getAttributes();
070:                assertEquals(6, attrSet.size());
071:                assertTrue(attrSet.contains(persistentAttrInfo));
072:                assertTrue(attrSet.contains(nonPersistentAttrInfo));
073:            }
074:
075:            public void testGetPersistentAttributes() {
076:                List attrList = gbeanInfo.getPersistentAttributes();
077:                assertEquals(3, attrList.size());
078:            }
079:
080:            public void testGetConstructor() {
081:                GConstructorInfo gctorInfo = gbeanInfo.getConstructor();
082:                List attrNameList = gctorInfo.getAttributeNames();
083:                assertEquals(2, attrNameList.size());
084:                assertEquals(CONSTRUCTOR_ARG_0, attrNameList.get(0));
085:                assertEquals(CONSTRUCTOR_ARG_1, attrNameList.get(1));
086:            }
087:
088:            public void testGetOperationsSet() {
089:                Set gbeanOpSet = gbeanInfo.getOperations();
090:                assertEquals(3, gbeanOpSet.size());
091:                assertTrue(gbeanOpSet.contains(opInfo));
092:            }
093:
094:            public void testGetReferencesSet() {
095:                Set gbeanRefSet = gbeanInfo.getReferences();
096:                assertEquals(1, gbeanRefSet.size());
097:                GReferenceInfo newRefInfo = (GReferenceInfo) gbeanRefSet
098:                        .iterator().next();
099:                assertEquals(refInfo.getName(), newRefInfo.getName());
100:            }
101:
102:            public void testToString() {
103:                assertNotNull(gbeanInfo.toString());
104:                assertEquals(gbeanInfo.toString(), MockGBean.getGBeanInfo()
105:                        .toString());
106:            }
107:
108:            public void testBackwardCompatibility() throws Exception {
109:                FileInputStream fis = new FileInputStream(
110:                        resolveFile("src/test/data/gbeaninfo/SERIALIZATION_-6198804067155550221.ser"));
111:                ObjectInputStream is = new ObjectInputStream(fis);
112:                GBeanInfo beanInfo = (GBeanInfo) is.readObject();
113:                assertEquals(GBeanInfo.PRIORITY_NORMAL, beanInfo.getPriority());
114:            }
115:
116:            public void testCurrentSerialization() throws Exception {
117:                GBeanInfo beanInfo = MockGBean.GBEAN_INFO;
118:
119:                ByteArrayOutputStream memOut = new ByteArrayOutputStream();
120:                ObjectOutputStream os = new ObjectOutputStream(memOut);
121:                os.writeObject(beanInfo);
122:
123:                ByteArrayInputStream memIn = new ByteArrayInputStream(memOut
124:                        .toByteArray());
125:                ObjectInputStream is = new ObjectInputStream(memIn);
126:                beanInfo = (GBeanInfo) is.readObject();
127:                assertEquals(GBeanInfo.PRIORITY_CLASSLOADER, beanInfo
128:                        .getPriority());
129:            }
130:
131:            GBeanInfo gbeanInfo;
132:
133:            final static String nonPersistentAttrName = "nonPersistentAttribute";
134:
135:            final static GAttributeInfo nonPersistentAttrInfo = new GAttributeInfo(
136:                    nonPersistentAttrName, String.class.getName(), false,
137:                    false, "getFoo", "setFoo");
138:
139:            final static String persistentAttrName = "persistentAttribute";
140:
141:            final static GAttributeInfo persistentAttrInfo = new GAttributeInfo(
142:                    persistentAttrName, String.class.getName(), true, false,
143:                    "getFoo", "setFoo");
144:
145:            final static GOperationInfo opInfo = new GOperationInfo(
146:                    "operation", "java.lang.Object");
147:
148:            final static GReferenceInfo refInfo = new GReferenceInfo(
149:                    "reference", String.class.getName(),
150:                    String.class.getName(), "setReference", "Fooifier");
151:
152:            public void setUp() throws Exception {
153:                super .setUp();
154:                gbeanInfo = MockGBean.getGBeanInfo();
155:            }
156:
157:            protected void tearDown() throws Exception {
158:                gbeanInfo = null;
159:                super .tearDown();
160:            }
161:
162:            public static final class MockGBean {
163:                public static final GBeanInfo GBEAN_INFO;
164:
165:                static {
166:                    GBeanInfoBuilder infoFactory = GBeanInfoBuilder
167:                            .createStatic(MockGBean.class);
168:
169:                    infoFactory.addAttribute(nonPersistentAttrInfo);
170:                    infoFactory.addAttribute(persistentAttrInfo);
171:
172:                    infoFactory.addOperation(opInfo);
173:                    // These two operations are added automatically
174:                    infoFactory.addOperation("addSomething",
175:                            new Class[] { String.class }); // ignored
176:                    infoFactory.addOperation("removeSomething",
177:                            new Class[] { String.class }); // ignored
178:                    infoFactory.addReference(refInfo);
179:
180:                    infoFactory.addAttribute(CONSTRUCTOR_ARG_0, String.class,
181:                            true);
182:                    infoFactory.addAttribute(CONSTRUCTOR_ARG_1, String.class,
183:                            true);
184:                    infoFactory.setPriority(GBeanInfo.PRIORITY_CLASSLOADER);
185:                    infoFactory.setConstructor(new String[] {
186:                            CONSTRUCTOR_ARG_0, CONSTRUCTOR_ARG_1 });
187:
188:                    GBEAN_INFO = infoFactory.getBeanInfo();
189:                }
190:
191:                public static GBeanInfo getGBeanInfo() {
192:                    return GBEAN_INFO;
193:                }
194:
195:                public MockGBean(String ConstructorArg_0,
196:                        String ConstructorArg_1) {
197:                }
198:
199:                public void setReference(String reference) {
200:                }
201:
202:                public void addSomething(String something) {
203:                }
204:
205:                public String removeSomething(String something) {
206:                    return null;
207:                }
208:            }
209:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.