Source Code Cross Referenced for FriendlyPersonTest.java in  » J2EE » openejb3 » org » superbiz » 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 » J2EE » openejb3 » org.superbiz 
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.superbiz;
017:
018:        import junit.framework.TestCase;
019:
020:        import javax.naming.InitialContext;
021:        import javax.naming.Context;
022:        import java.util.Locale;
023:        import java.util.Properties;
024:
025:        /**
026:         * @author <a href="mailto:david.blevins@visi.com">David Blevins</a>
027:         * 
028:         * @version $Rev: 601953 $ $Date: 2007-12-06 17:09:47 -0800 $
029:         */
030:        public class FriendlyPersonTest extends TestCase {
031:            private InitialContext initialContext;
032:
033:            protected void setUp() throws Exception {
034:                Properties properties = new Properties();
035:                properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
036:                        "org.apache.openejb.client.LocalInitialContextFactory");
037:                initialContext = new InitialContext(properties);
038:            }
039:
040:            /**
041:             * Here we lookup and test the FriendlyPerson bean via its EJB 2.1 EJBHome and EJBObject interfaces
042:             *
043:             * @throws Exception
044:             */
045:            public void testEjbHomeAndEjbObject() throws Exception {
046:                Object object = initialContext
047:                        .lookup("FriendlyPersonRemoteHome");
048:                FriendlyPersonEjbHome home = (FriendlyPersonEjbHome) object;
049:                FriendlyPersonEjbObject friendlyPerson = home.create();
050:
051:                friendlyPerson.setDefaultLanguage("en");
052:
053:                assertEquals("Hello David!", friendlyPerson.greet("David"));
054:                assertEquals("Hello Amelia!", friendlyPerson.greet("Amelia"));
055:
056:                friendlyPerson.setLanguagePreferences("Amelia", "es");
057:
058:                assertEquals("Hello David!", friendlyPerson.greet("David"));
059:                assertEquals("Hola Amelia!", friendlyPerson.greet("Amelia"));
060:
061:                // Amelia took some French, let's see if she remembers
062:                assertEquals("Bonjour Amelia!", friendlyPerson.greet("fr",
063:                        "Amelia"));
064:
065:                // Dave should take some Polish and if he had, he could say Hi in Polish
066:                assertEquals("Witaj Dave!", friendlyPerson.greet("pl", "Dave"));
067:
068:                // Let's see if I speak Portuguese
069:                assertEquals("Sorry, I don't speak "
070:                        + new Locale("pt").getDisplayLanguage() + ".",
071:                        friendlyPerson.greet("pt", "David"));
072:
073:                // Ok, well I've been meaning to learn, so...
074:                friendlyPerson.addGreeting("pt", "Ola {0}!");
075:
076:                assertEquals("Ola David!", friendlyPerson.greet("pt", "David"));
077:            }
078:
079:            /**
080:             * Here we lookup and test the FriendlyPerson bean via its EJB 2.1 EJBLocalHome and EJBLocalObject interfaces
081:             *
082:             * @throws Exception
083:             */
084:            public void testEjbLocalHomeAndEjbLocalObject() throws Exception {
085:                Object object = initialContext
086:                        .lookup("FriendlyPersonLocalHome");
087:                FriendlyPersonEjbLocalHome home = (FriendlyPersonEjbLocalHome) object;
088:                FriendlyPersonEjbLocalObject friendlyPerson = home.create();
089:
090:                friendlyPerson.setDefaultLanguage("en");
091:
092:                assertEquals("Hello David!", friendlyPerson.greet("David"));
093:                assertEquals("Hello Amelia!", friendlyPerson.greet("Amelia"));
094:
095:                friendlyPerson.setLanguagePreferences("Amelia", "es");
096:
097:                assertEquals("Hello David!", friendlyPerson.greet("David"));
098:                assertEquals("Hola Amelia!", friendlyPerson.greet("Amelia"));
099:
100:                // Amelia took some French, let's see if she remembers
101:                assertEquals("Bonjour Amelia!", friendlyPerson.greet("fr",
102:                        "Amelia"));
103:
104:                // Dave should take some Polish and if he had, he could say Hi in Polish
105:                assertEquals("Witaj Dave!", friendlyPerson.greet("pl", "Dave"));
106:
107:                // Let's see if I speak Portuguese
108:                assertEquals("Sorry, I don't speak "
109:                        + new Locale("pt").getDisplayLanguage() + ".",
110:                        friendlyPerson.greet("pt", "David"));
111:
112:                // Ok, well I've been meaning to learn, so...
113:                friendlyPerson.addGreeting("pt", "Ola {0}!");
114:
115:                assertEquals("Ola David!", friendlyPerson.greet("pt", "David"));
116:            }
117:
118:            /**
119:             * Here we lookup and test the FriendlyPerson bean via its EJB 3.0 business remote interface
120:             *
121:             * @throws Exception
122:             */
123:            public void testBusinessRemote() throws Exception {
124:                Object object = initialContext.lookup("FriendlyPersonRemote");
125:
126:                FriendlyPersonRemote friendlyPerson = (FriendlyPersonRemote) object;
127:
128:                friendlyPerson.setDefaultLanguage("en");
129:
130:                assertEquals("Hello David!", friendlyPerson.greet("David"));
131:                assertEquals("Hello Amelia!", friendlyPerson.greet("Amelia"));
132:
133:                friendlyPerson.setLanguagePreferences("Amelia", "es");
134:
135:                assertEquals("Hello David!", friendlyPerson.greet("David"));
136:                assertEquals("Hola Amelia!", friendlyPerson.greet("Amelia"));
137:
138:                // Amelia took some French, let's see if she remembers
139:                assertEquals("Bonjour Amelia!", friendlyPerson.greet("fr",
140:                        "Amelia"));
141:
142:                // Dave should take some Polish and if he had, he could say Hi in Polish
143:                assertEquals("Witaj Dave!", friendlyPerson.greet("pl", "Dave"));
144:
145:                // Let's see if I speak Portuguese
146:                assertEquals("Sorry, I don't speak "
147:                        + new Locale("pt").getDisplayLanguage() + ".",
148:                        friendlyPerson.greet("pt", "David"));
149:
150:                // Ok, well I've been meaning to learn, so...
151:                friendlyPerson.addGreeting("pt", "Ola {0}!");
152:
153:                assertEquals("Ola David!", friendlyPerson.greet("pt", "David"));
154:            }
155:
156:            /**
157:             * Here we lookup and test the FriendlyPerson bean via its EJB 3.0 business local interface
158:             *
159:             * @throws Exception
160:             */
161:            public void testBusinessLocal() throws Exception {
162:                Object object = initialContext.lookup("FriendlyPersonLocal");
163:
164:                FriendlyPersonLocal friendlyPerson = (FriendlyPersonLocal) object;
165:
166:                friendlyPerson.setDefaultLanguage("en");
167:
168:                assertEquals("Hello David!", friendlyPerson.greet("David"));
169:                assertEquals("Hello Amelia!", friendlyPerson.greet("Amelia"));
170:
171:                friendlyPerson.setLanguagePreferences("Amelia", "es");
172:
173:                assertEquals("Hello David!", friendlyPerson.greet("David"));
174:                assertEquals("Hola Amelia!", friendlyPerson.greet("Amelia"));
175:
176:                // Amelia took some French, let's see if she remembers
177:                assertEquals("Bonjour Amelia!", friendlyPerson.greet("fr",
178:                        "Amelia"));
179:
180:                // Dave should take some Polish and if he had, he could say Hi in Polish
181:                assertEquals("Witaj Dave!", friendlyPerson.greet("pl", "Dave"));
182:
183:                // Let's see if I speak Portuguese
184:                assertEquals("Sorry, I don't speak "
185:                        + new Locale("pt").getDisplayLanguage() + ".",
186:                        friendlyPerson.greet("pt", "David"));
187:
188:                // Ok, well I've been meaning to learn, so...
189:                friendlyPerson.addGreeting("pt", "Ola {0}!");
190:
191:                assertEquals("Ola David!", friendlyPerson.greet("pt", "David"));
192:            }
193:
194:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.