Source Code Cross Referenced for KSBTestCase.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » bus » test » 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 » ERP CRM Financial » Kuali Financial System » org.kuali.bus.test 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2007 The Kuali Foundation
003:         *
004:         * Licensed under the Educational Community License, Version 1.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         * http://www.opensource.org/licenses/ecl1.php
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:        package org.kuali.bus.test;
017:
018:        import java.util.ArrayList;
019:        import java.util.Arrays;
020:        import java.util.List;
021:        import java.util.Map;
022:
023:        import javax.xml.namespace.QName;
024:
025:        import org.kuali.bus.services.KSBServiceLocator;
026:        import org.kuali.rice.config.Config;
027:        import org.kuali.rice.core.Core;
028:        import org.kuali.rice.exceptions.RiceRuntimeException;
029:        import org.kuali.rice.lifecycle.Lifecycle;
030:        import org.kuali.rice.resourceloader.GlobalResourceLoader;
031:        import org.kuali.rice.resourceloader.ResourceLoader;
032:        import org.kuali.rice.resourceloader.SpringResourceLoader;
033:        import org.kuali.rice.test.RiceTestCase;
034:        import org.mortbay.jetty.webapp.WebAppClassLoader;
035:        import org.springframework.context.ApplicationContext;
036:
037:        import edu.iu.uis.eden.messaging.bam.BAMService;
038:        import edu.iu.uis.eden.messaging.bam.BAMTargetEntry;
039:        import edu.iu.uis.eden.messaging.resourceloading.KSBResourceLoaderFactory;
040:        import edu.iu.uis.eden.server.TestClient1;
041:        import edu.iu.uis.eden.server.TestClient2;
042:
043:        public class KSBTestCase extends RiceTestCase {
044:
045:            private TestClient1 testClient1;
046:            private TestClient2 testClient2;
047:            private ResourceLoader springContextResourceLoader;
048:
049:            @Override
050:            public void setUp() throws Exception {
051:                // because we're stopping and starting so many times we need to clear the core before
052:                // another set of RLs get put in the core. This is because we are sometimes using
053:                // the GRL to fetch a specific servers spring file out for testing purposes.
054:                Core.destroy();
055:                super .setUp();
056:                if (startClient1() || startClient2()) {
057:                    ((Runnable) KSBResourceLoaderFactory
058:                            .getRemoteResourceLocator()).run();
059:                }
060:                //	new SQLDataLoader("classpath:db/DefaultTestData.sql", ";").runSql();
061:            }
062:
063:            @Override
064:            protected List<String> getConfigLocations() {
065:                return Arrays
066:                        .asList(new String[] { "classpath:META-INF/ksb-test-config.xml" });
067:            }
068:
069:            @Override
070:            protected String getDerbySQLFileLocation() {
071:                return "classpath:db/derby/bus.sql";
072:            }
073:
074:            @Override
075:            protected String getModuleName() {
076:                return "ksb";
077:            }
078:
079:            @Override
080:            protected List<String> getTablesToClear() {
081:                List<String> tables = new ArrayList<String>();
082:                tables.add("EN_MSG_QUE_T");
083:                tables.add("EN_MSG_PAYLOAD_T");
084:                tables.add("EN_BAM_T");
085:                tables.add("EN_BAM_PARAM_T");
086:                tables.add("EN_SERVICE_DEF_DUEX_T");
087:                return tables;
088:            }
089:
090:            @Override
091:            protected List<Lifecycle> getPerTestLifecycles() {
092:                List<Lifecycle> lifecycles = super .getPerTestLifecycles();
093:                this .springContextResourceLoader = new SpringResourceLoader(
094:                        new QName("ksbtestharness"), "KSBTestHarnessSpring.xml");
095:                lifecycles.add(this .springContextResourceLoader);
096:                if (startClient1()) {
097:                    this .testClient1 = new TestClient1();
098:                    lifecycles.add(this .testClient1);
099:                }
100:                if (startClient2()) {
101:                    this .testClient2 = new TestClient2();
102:                    lifecycles.add(this .testClient2);
103:                }
104:                return lifecycles;
105:            }
106:
107:            public boolean startClient1() {
108:                return false;
109:            }
110:
111:            public boolean startClient2() {
112:                return false;
113:            }
114:
115:            public TestClient1 getTestClient1() {
116:                return this .testClient1;
117:            }
118:
119:            public TestClient2 getTestClient2() {
120:                return this .testClient2;
121:            }
122:
123:            public static boolean verifyServiceCallsViaBam(QName serviceName,
124:                    String methodName, boolean serverInvocation)
125:                    throws Exception {
126:                BAMService bamService = KSBServiceLocator.getBAMService();
127:                List<BAMTargetEntry> bamCalls = null;
128:                if (methodName == null) {
129:                    bamCalls = bamService.getCallsForService(serviceName);
130:                } else {
131:                    bamCalls = bamService.getCallsForService(serviceName,
132:                            methodName);
133:                }
134:
135:                if (bamCalls.size() == 0) {
136:                    return false;
137:                }
138:                for (BAMTargetEntry bamEntry : bamCalls) {
139:                    if (bamEntry.getServerInvocation() && serverInvocation) {
140:                        return true;
141:                    } else if (!serverInvocation) {
142:                        return true;
143:                    }
144:                }
145:                return false;
146:            }
147:
148:            public static Object getServiceFromWebAppResourceLoader(
149:                    String serviceName) {
150:                Map<ClassLoader, Config> configs = Core.getCONFIGS();
151:                for (Map.Entry<ClassLoader, Config> configEntry : configs
152:                        .entrySet()) {
153:                    if (configEntry.getKey() instanceof  WebAppClassLoader) {
154:                        ClassLoader old = Thread.currentThread()
155:                                .getContextClassLoader();
156:                        // to make GRL select services from correct classloader
157:                        Thread.currentThread().setContextClassLoader(
158:                                configEntry.getKey());
159:                        try {
160:                            return GlobalResourceLoader.getService(serviceName);
161:                        } finally {
162:                            Thread.currentThread().setContextClassLoader(old);
163:                        }
164:                    }
165:                }
166:                throw new RiceRuntimeException("Couldn't find service "
167:                        + serviceName + " in WebApp Resource Loader");
168:            }
169:
170:            public static Object getServiceFromTestClient1SpringContext(
171:                    String serviceName) {
172:                Map<ClassLoader, Config> configs = Core.getCONFIGS();
173:                for (Map.Entry<ClassLoader, Config> configEntry : configs
174:                        .entrySet()) {
175:                    if (configEntry.getKey() instanceof  WebAppClassLoader) {
176:                        ClassLoader old = Thread.currentThread()
177:                                .getContextClassLoader();
178:                        // to make GRL select services from correct classloader
179:                        Thread.currentThread().setContextClassLoader(
180:                                configEntry.getKey());
181:                        try {
182:                            // TestClient1SpringContext found in web.xml of TestClient1
183:                            ApplicationContext appContext = (ApplicationContext) Core
184:                                    .getCurrentContextConfig().getObject(
185:                                            "TestClient1SpringContext");
186:
187:                            return appContext.getBean(serviceName);
188:                        } finally {
189:                            Thread.currentThread().setContextClassLoader(old);
190:                        }
191:                    }
192:                }
193:                throw new RiceRuntimeException("Couldn't find service "
194:                        + serviceName + " in TestClient1 Spring Context");
195:            }
196:
197:            public ResourceLoader getSpringContextResourceLoader() {
198:                return this .springContextResourceLoader;
199:            }
200:
201:            public void setSpringContextResourceLoader(
202:                    ResourceLoader testHarnessResourceLoader) {
203:                this.springContextResourceLoader = testHarnessResourceLoader;
204:            }
205:
206:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.