Source Code Cross Referenced for BeanContextServicesSupportTest.java in  » Apache-Harmony-Java-SE » java-package » java » beans » beancontext » 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 » Apache Harmony Java SE » java package » java.beans.beancontext 
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:         */
017:
018:        /**
019:         * @author Sergey A. Krivenko
020:         * @version $Revision: 1.5.2.2 $
021:         */package java.beans.beancontext;
022:
023:        import java.util.Locale;
024:
025:        import junit.framework.Test;
026:        import junit.framework.TestCase;
027:        import junit.framework.TestSuite;
028:
029:        /**
030:         * Test class for java.beans.beancontext.BeanContextServicesSupport.
031:         * <p>
032:         * 
033:         * @author Sergey A. Krivenko
034:         * @version $Revision: 1.5.2.2 $
035:         */
036:
037:        public class BeanContextServicesSupportTest extends TestCase {
038:
039:            /** STANDARD BEGINNING * */
040:
041:            /**
042:             * No arguments constructor to enable serialization.
043:             * <p>
044:             */
045:            public BeanContextServicesSupportTest() {
046:                super ();
047:            }
048:
049:            /**
050:             * Constructs this test case with the given name.
051:             * <p>
052:             * 
053:             * @param name -
054:             *            The name for this test case.
055:             *            <p>
056:             */
057:            public BeanContextServicesSupportTest(String name) {
058:                super (name);
059:            }
060:
061:            /** TEST CONSTRUCTORS * */
062:
063:            /**
064:             * Test constructor with BeanContextServices, Locale, boolean, boolean
065:             * parameters.
066:             * <p>
067:             * 
068:             * @see BeanContextServicesSupport#BeanContextServicesSupport(
069:             *      BeanContextServices, Locale, boolean, boolean)
070:             */
071:            public void testConstructorBeanContextServicesLocalebooleanboolean() {
072:                new BeanContextServicesSupport(null, null, true, true);
073:            }
074:
075:            /**
076:             * Test constructor with BeanContextServices, Locale, boolean parameters
077:             * 
078:             * @see BeanContextServicesSupport#BeanContextServicesSupport(
079:             *      BeanContextServices, Locale, boolean)
080:             */
081:            public void testConstructorBeanContextServicesLocaleboolean() {
082:                new BeanContextServicesSupport(null, null, true);
083:            }
084:
085:            /**
086:             * Test constructor with BeanContextServices, Locale parameters.
087:             * <p>
088:             * 
089:             * @see BeanContextServicesSupport#BeanContextServicesSupport(
090:             *      BeanContextServices, Locale)
091:             */
092:            public void testConstructorBeanContextServicesLocale() {
093:                new BeanContextServicesSupport(null, null);
094:            }
095:
096:            /**
097:             * Test constructor with BeanContextServices parameter.
098:             * <p>
099:             * 
100:             * @see BeanContextServicesSupport#BeanContextServicesSupport(
101:             *      BeanContextServices)
102:             */
103:            public void testConstructorBeanContextServices() {
104:                new BeanContextServicesSupport(null);
105:            }
106:
107:            /**
108:             * * Test constructor with no parameters.
109:             * <p>
110:             * 
111:             * @see BeanContextServicesSupport#BeanContextServicesSupport()
112:             */
113:            public void testConstructor() {
114:                new BeanContextServicesSupport();
115:            }
116:
117:            /** TEST METHODS * */
118:
119:            /**
120:             * Test method createBCSChild() with Object, Object parameters.
121:             * <p>
122:             */
123:            public void testCreateBCSChildObjectObject() {
124:                // Just call the method
125:                BeanContextServicesSupport sup = new BeanContextServicesSupport();
126:                sup.createBCSChild(new Object(), new Object());
127:            }
128:
129:            /**
130:             * Test method addService() with Class, BeanContextServiceProvider, boolean
131:             * parameters.
132:             * <p>
133:             */
134:            public void testAddServiceClassBeanContextServiceProviderboolean() {
135:                // Instantiate services and add service
136:                BeanContextServicesSupport sup = new BeanContextServicesSupport();
137:                sup.addService(Object.class, getProvider(), true);
138:
139:                assertEquals("One service should be registered", 1,
140:                        sup.services.size());
141:            }
142:
143:            /**
144:             * Test method revokeService() with Class, BeanContextServiceProvider,
145:             * boolean parameters.
146:             * <p>
147:             */
148:            public void testRevokeServiceClassBeanContextServiceProviderboolean() {
149:                // Instantiate services, add and remove service
150:                BeanContextServicesSupport sup = new BeanContextServicesSupport();
151:                BeanContextServiceProvider pr = getProvider();
152:                sup.addService(Object.class, pr, true);
153:                sup.revokeService(Object.class, pr, true);
154:
155:                assertEquals("No service should be registered", 0, sup.services
156:                        .size());
157:            }
158:
159:            /**
160:             * Test method addService() with Class, BeanContextServiceProvider
161:             * parameters.
162:             * <p>
163:             */
164:            public void testAddServiceClassBeanContextServiceProvider() {
165:                // Instantiate services and add service
166:                BeanContextServicesSupport sup = new BeanContextServicesSupport();
167:                sup.addService(Object.class, getProvider());
168:            }
169:
170:            /**
171:             * Test method hasService() with Class parameter.
172:             * <p>
173:             */
174:            public void testHasServiceClass() {
175:                // Instantiate services and add service
176:                BeanContextServicesSupport sup = new BeanContextServicesSupport();
177:                Class<?> cl = new Object().getClass();
178:                sup.addService(cl, getProvider(), true);
179:
180:                assertTrue("Service not found", sup.hasService(cl));
181:            }
182:
183:            /**
184:             * Test method getBeanContextServicesPeer() with no parameters.
185:             * <p>
186:             */
187:            public void testGetBeanContextServicesPeer() {
188:                // Instantiate services
189:                BeanContextServicesSupport sup = new BeanContextServicesSupport();
190:
191:                assertTrue("The objects are not equal", sup
192:                        .getBeanContextServicesPeer().equals(sup));
193:            }
194:
195:            /**
196:             * Test method releaseBeanContextResources() with no parameters.
197:             * <p>
198:             */
199:            public void testReleaseBeanContextResources() {
200:                // Instantiate services
201:                BeanContextServicesSupport sup = new BeanContextServicesSupport();
202:                sup.releaseBeanContextResources();
203:
204:                assertNull("The resources are not released", sup.proxy);
205:            }
206:
207:            /**
208:             * Test method initializeBeanContextResources() with no parameters.
209:             * <p>
210:             */
211:            public void testInitializeBeanContextResources() {
212:                // Instantiate services
213:                BeanContextServicesSupport sup = new BeanContextServicesSupport();
214:                sup.initializeBeanContextResources();
215:
216:                // if (sup.proxy == null) {
217:                // fail("The resources are not initialized");
218:                // }
219:            }
220:
221:            /**
222:             * Test method hasService() with Class=null parameter.
223:             * <p>
224:             */
225:            public void test_hasServiceLjava_lang_Class() {
226:                BeanContextServicesSupport obj = new BeanContextServicesSupport();
227:                try {
228:                    obj.hasService(null);
229:                    fail("NullPointerException expected");
230:                } catch (NullPointerException t) {
231:                }
232:            }
233:
234:            /**
235:             * Test method removeBeanContextServicesListener() with
236:             * BeanContextServicesListener=null parameter.
237:             * <p>
238:             */
239:            public void test_removeBeanContextServicesListenerLjava_beans_beancontext_BeanContextServicesListener() {
240:                BeanContextServicesSupport obj = new BeanContextServicesSupport();
241:                try {
242:                    obj.removeBeanContextServicesListener(null);
243:                    fail("NullPointerException expected");
244:                } catch (NullPointerException t) {
245:                }
246:            }
247:
248:            /**
249:             * Test method serviceAvailable() with BeanContextServiceAvailableEvent=null
250:             * parameter.
251:             * <p>
252:             */
253:            public void test_serviceAvailableLjava_beans_beancontext_BeanContextServiceAvailableEvent() {
254:                BeanContextServicesSupport obj = new BeanContextServicesSupport();
255:                try {
256:                    obj.serviceAvailable(null);
257:                    fail("NullPointerException expected");
258:                } catch (NullPointerException t) {
259:                }
260:            }
261:
262:            /**
263:             * Test method serviceRevoked() with BeanContextServiceRevokedEvent=null
264:             * parameter.
265:             * <p>
266:             */
267:            public void test_serviceRevokedLjava_beans_beancontext_BeanContextServiceRevokedEvent() {
268:                BeanContextServicesSupport obj = new BeanContextServicesSupport();
269:                try {
270:                    obj.serviceRevoked(null);
271:                    fail("NullPointerException expected");
272:                } catch (NullPointerException t) {
273:                }
274:            }
275:
276:            /** UTILITY METHODS * */
277:
278:            /**
279:             * Fake implementation of provider
280:             */
281:            @SuppressWarnings("unchecked")
282:            private BeanContextServiceProvider getProvider() {
283:
284:                return new BeanContextServiceProvider() {
285:
286:                    public java.util.Iterator getCurrentServiceSelectors(
287:                            BeanContextServices bcs, Class serviceClass) {
288:
289:                        return bcs.getCurrentServiceSelectors(serviceClass);
290:                    }
291:
292:                    public Object getService(BeanContextServices bcs,
293:                            Object requestor, Class serviceClass,
294:                            Object serviceSelector) {
295:
296:                        return null;
297:                    }
298:
299:                    public void releaseService(BeanContextServices bcs,
300:                            Object requestor, Object service) {
301:                    }
302:                };
303:            }
304:
305:            /** STANDARD ENDING * */
306:
307:            /**
308:             * Start testing from the command line.
309:             * <p>
310:             */
311:            public static Test suite() {
312:                return new TestSuite(BeanContextServicesSupportTest.class);
313:            }
314:
315:            /**
316:             * Start testing from the command line.
317:             * <p>
318:             * 
319:             * @param args -
320:             *            Command line parameters.
321:             *            <p>
322:             */
323:            public static void main(String args[]) {
324:                junit.textui.TestRunner.run(suite());
325:            }
326:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.