Source Code Cross Referenced for TestJNDI.java in  » Testing » mockrunner-0.4 » com » mockrunner » test » ejb » 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 » Testing » mockrunner 0.4 » com.mockrunner.test.ejb 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.mockrunner.test.ejb;
002:
003:        import java.util.Hashtable;
004:        import java.util.Properties;
005:
006:        import javax.naming.Context;
007:        import javax.naming.Name;
008:        import javax.naming.NameParser;
009:        import javax.naming.NamingEnumeration;
010:        import javax.naming.NamingException;
011:        import javax.naming.spi.InitialContextFactory;
012:
013:        import org.mockejb.jndi.MockContext;
014:        import org.mockejb.jndi.MockContextFactory;
015:
016:        public class TestJNDI {
017:            public static void saveProperties(Properties properties) {
018:                String factory = System
019:                        .getProperty(Context.INITIAL_CONTEXT_FACTORY);
020:                if (null != factory
021:                        && !factory.equals(MockContextFactory.class.getName())) {
022:                    properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
023:                            factory);
024:                }
025:                String urlPrefix = System.getProperty(Context.URL_PKG_PREFIXES);
026:                if (null != urlPrefix && !urlPrefix.equals("org.mockejb.jndi")) {
027:                    properties.setProperty(Context.URL_PKG_PREFIXES, factory);
028:                }
029:            }
030:
031:            public static void restoreProperties(Properties properties) {
032:                if (null != properties
033:                        .getProperty(Context.INITIAL_CONTEXT_FACTORY)) {
034:                    System
035:                            .setProperty(
036:                                    Context.INITIAL_CONTEXT_FACTORY,
037:                                    properties
038:                                            .getProperty(Context.INITIAL_CONTEXT_FACTORY));
039:                } else {
040:                    System.getProperties().remove(
041:                            Context.INITIAL_CONTEXT_FACTORY);
042:                }
043:                if (null != properties.getProperty(Context.URL_PKG_PREFIXES)) {
044:                    System.setProperty(Context.URL_PKG_PREFIXES, properties
045:                            .getProperty(Context.URL_PKG_PREFIXES));
046:                } else {
047:                    System.getProperties().remove(Context.URL_PKG_PREFIXES);
048:                }
049:            }
050:
051:            public static void unbind(Context context) throws Exception {
052:                try {
053:                    context.unbind("myJNDIName");
054:                } catch (NamingException exc) {
055:                    //ignore
056:                }
057:                try {
058:                    context.unbind("javax.transaction.UserTransaction");
059:                } catch (NamingException exc) {
060:                    //ignore
061:                }
062:                try {
063:                    context.unbind("java:comp/UserTransaction");
064:                } catch (NamingException exc) {
065:                    //ignore
066:                }
067:            }
068:
069:            public static class TestContextFactory implements 
070:                    InitialContextFactory {
071:                public Context getInitialContext(Hashtable env)
072:                        throws NamingException {
073:                    return new TestContext();
074:                }
075:            }
076:
077:            public static class TestContext implements  Context {
078:                public Object addToEnvironment(String propName, Object propVal)
079:                        throws NamingException {
080:                    return null;
081:                }
082:
083:                public void bind(Name name, Object obj) throws NamingException {
084:
085:                }
086:
087:                public void bind(String name, Object obj)
088:                        throws NamingException {
089:
090:                }
091:
092:                public void close() throws NamingException {
093:
094:                }
095:
096:                public Name composeName(Name name, Name prefix)
097:                        throws NamingException {
098:                    return null;
099:                }
100:
101:                public String composeName(String name, String prefix)
102:                        throws NamingException {
103:                    return null;
104:                }
105:
106:                public Context createSubcontext(Name name)
107:                        throws NamingException {
108:                    return null;
109:                }
110:
111:                public Context createSubcontext(String name)
112:                        throws NamingException {
113:                    return null;
114:                }
115:
116:                public void destroySubcontext(Name name) throws NamingException {
117:
118:                }
119:
120:                public void destroySubcontext(String name)
121:                        throws NamingException {
122:
123:                }
124:
125:                public Hashtable getEnvironment() throws NamingException {
126:                    return null;
127:                }
128:
129:                public String getNameInNamespace() throws NamingException {
130:                    return null;
131:                }
132:
133:                public NameParser getNameParser(Name name)
134:                        throws NamingException {
135:                    return null;
136:                }
137:
138:                public NameParser getNameParser(String name)
139:                        throws NamingException {
140:                    return null;
141:                }
142:
143:                public NamingEnumeration list(Name name) throws NamingException {
144:                    return null;
145:                }
146:
147:                public NamingEnumeration list(String name)
148:                        throws NamingException {
149:                    return null;
150:                }
151:
152:                public NamingEnumeration listBindings(Name name)
153:                        throws NamingException {
154:                    return null;
155:                }
156:
157:                public NamingEnumeration listBindings(String name)
158:                        throws NamingException {
159:                    return null;
160:                }
161:
162:                public Object lookup(Name name) throws NamingException {
163:                    return null;
164:                }
165:
166:                public Object lookup(String name) throws NamingException {
167:                    return "TestObject";
168:                }
169:
170:                public Object lookupLink(Name name) throws NamingException {
171:                    return null;
172:                }
173:
174:                public Object lookupLink(String name) throws NamingException {
175:                    return null;
176:                }
177:
178:                public void rebind(Name name, Object obj)
179:                        throws NamingException {
180:
181:                }
182:
183:                public void rebind(String name, Object obj)
184:                        throws NamingException {
185:
186:                }
187:
188:                public Object removeFromEnvironment(String propName)
189:                        throws NamingException {
190:                    return null;
191:                }
192:
193:                public void rename(Name oldName, Name newName)
194:                        throws NamingException {
195:
196:                }
197:
198:                public void rename(String oldName, String newName)
199:                        throws NamingException {
200:
201:                }
202:
203:                public void unbind(Name name) throws NamingException {
204:
205:                }
206:
207:                public void unbind(String name) throws NamingException {
208:
209:                }
210:            }
211:
212:            public static class NullContext extends MockContext {
213:                public NullContext() {
214:                    super(null);
215:                }
216:            }
217:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.