Source Code Cross Referenced for DataDictionaryConfigurationTest.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » core » datadictionary » 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.core.datadictionary 
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.core.datadictionary;
017:
018:        import java.sql.Connection;
019:        import java.sql.ResultSet;
020:        import java.sql.Statement;
021:        import java.util.ArrayList;
022:        import java.util.Collection;
023:        import java.util.HashSet;
024:        import java.util.List;
025:        import java.util.Map;
026:        import java.util.TreeMap;
027:
028:        import javax.sql.DataSource;
029:
030:        import org.apache.commons.lang.StringUtils;
031:        import org.apache.log4j.Logger;
032:        import org.kuali.core.bo.DocumentType;
033:        import org.kuali.core.service.BusinessObjectService;
034:        import org.kuali.core.service.DataDictionaryService;
035:        import org.kuali.kfs.context.KualiTestBase;
036:        import org.kuali.kfs.context.SpringContext;
037:        import org.kuali.test.ConfigureContext;
038:        import org.kuali.test.suite.AnnotationTestSuite;
039:        import org.kuali.test.suite.PreCommitSuite;
040:
041:        @AnnotationTestSuite(PreCommitSuite.class)
042:        @ConfigureContext
043:        public class DataDictionaryConfigurationTest extends KualiTestBase {
044:            private static final Logger LOG = Logger
045:                    .getLogger(DataDictionaryConfigurationTest.class);
046:            private DataDictionary dataDictionary;
047:            private Map<String, Exception> dataDictionaryLoadFailures;
048:            private Map<String, String> dataDictionaryWarnings;
049:
050:            public void testLoadDataDictionaryConfiguration() throws Exception {
051:                loadDataDictionary();
052:                StringBuffer failureMessage = new StringBuffer(
053:                        "Unable to load DataDictionaryEntrys for some file locations:");
054:                for (String key : dataDictionaryLoadFailures.keySet()) {
055:                    failureMessage.append("\n\t").append("key: ").append(key)
056:                            .append(" at location: ").append(
057:                                    dataDictionary.getFileLocationMap()
058:                                            .get(key)).append(" error: ")
059:                            .append(
060:                                    ((Exception) dataDictionaryLoadFailures
061:                                            .get(key)).getMessage());
062:                }
063:                StringBuffer warningMessage = new StringBuffer(
064:                        "Loaded DataDictionaryEntrys for some file locations with warnings:");
065:                for (String key : dataDictionaryWarnings.keySet()) {
066:                    warningMessage.append("\n\t").append("key: ").append(key)
067:                            .append(" at location: ").append(
068:                                    dataDictionary.getFileLocationMap()
069:                                            .get(key)).append(" warning: ")
070:                            .append(dataDictionaryWarnings.get(key));
071:                }
072:                if (dataDictionaryWarnings.size() > 0) {
073:                    System.err.print(warningMessage);
074:                }
075:                assertTrue(failureMessage.toString(),
076:                        dataDictionaryLoadFailures.isEmpty());
077:            }
078:
079:            public void testAllDataDictionaryDocumentTypesExistInDocumentTypeTable()
080:                    throws Exception {
081:                loadDataDictionary();
082:                List<String> documentTypeCodes = new ArrayList<String>();
083:                for (DocumentType type : (Collection<DocumentType>) SpringContext
084:                        .getBean(BusinessObjectService.class).findAll(
085:                                DocumentType.class)) {
086:                    documentTypeCodes.add(type.getFinancialDocumentTypeCode());
087:                }
088:                // Using HashSet since duplicate objects would otherwise be returned
089:                HashSet<DocumentEntry> documentEntries = new HashSet(
090:                        SpringContext.getBean(DataDictionaryService.class)
091:                                .getDataDictionary().getDocumentEntries()
092:                                .values());
093:                List<String> ddEntriesWithMissingTypes = new ArrayList<String>();
094:                for (DocumentEntry documentEntry : documentEntries) {
095:                    String code = documentEntry.getDocumentTypeCode();
096:                    if (!documentTypeCodes.contains(code)
097:                            && !"RUSR".equals(code) && !"PRPL".equals(code)) { //PRPL is added here because two doc types reference it.  This should be fixed
098:                        ddEntriesWithMissingTypes.add(code + " ("
099:                                + documentEntry.getDocumentTypeName() + ")");
100:                    } else {
101:                        documentTypeCodes.remove(code);
102:                    }
103:                }
104:                if (documentTypeCodes.size() > 0) {
105:                    System.err.print("superfluousTypesDefinedInDatabase: "
106:                            + documentTypeCodes);
107:                }
108:
109:                assertEquals(
110:                        "dataDictionaryDocumentTypesNotDefinedInDatabase: "
111:                                + ddEntriesWithMissingTypes, 0,
112:                        ddEntriesWithMissingTypes.size());
113:
114:            }
115:
116:            public void testAllDataDicitionaryDocumentTypesExistInWorkflowDocumentTypeTable()
117:                    throws Exception {
118:                loadDataDictionary();
119:                List<String> workflowDocumentTypeNames = new ArrayList<String>();
120:                DataSource mySource = SpringContext.getBean(DataSource.class);
121:                Connection dbCon = null;
122:                try {
123:
124:                    dbCon = mySource.getConnection();
125:                    Statement dbAsk = dbCon.createStatement();
126:                    ResultSet dbAnswer = dbAsk
127:                            .executeQuery("select DOC_TYP_NM from EN_DOC_TYP_T where DOC_TYP_CUR_IND = 1");
128:                    while (dbAnswer.next()) {
129:                        String docName = dbAnswer.getString(1);
130:                        if (StringUtils.isNotBlank(docName)) {
131:                            workflowDocumentTypeNames.add(docName);
132:                        }
133:                    }
134:                } catch (Exception e) {
135:                    throw (e);
136:                }
137:                // Using HashSet since duplicate objects would otherwise be returned
138:                HashSet<DocumentEntry> documentEntries = new HashSet(
139:                        SpringContext.getBean(DataDictionaryService.class)
140:                                .getDataDictionary().getDocumentEntries()
141:                                .values());
142:                List<String> ddEntriesWithMissingTypes = new ArrayList<String>();
143:                for (DocumentEntry documentEntry : documentEntries) {
144:                    String name = documentEntry.getDocumentTypeName();
145:                    if (!workflowDocumentTypeNames.contains(name)
146:                            && !"RiceUserMaintenanceDocument".equals(name)) {
147:                        ddEntriesWithMissingTypes.add(name);
148:                    } else {
149:                        workflowDocumentTypeNames.remove(name);
150:                    }
151:                }
152:
153:                if (workflowDocumentTypeNames.size() > 0) {
154:                    System.err
155:                            .print("superfluousTypesDefinedInWorkflowDatabase: "
156:                                    + workflowDocumentTypeNames);
157:                }
158:                assertEquals("documentTypesNotDefinedInWorkflowDatabase: "
159:                        + ddEntriesWithMissingTypes, 0,
160:                        ddEntriesWithMissingTypes.size());
161:            }
162:
163:            private void loadDataDictionary() throws Exception {
164:                for (String key : dataDictionary.getFileLocationMap().keySet()) {
165:                    try {
166:                        DataDictionaryEntry entry = dataDictionary
167:                                .getDictionaryObjectEntry(key);
168:                        if (entry == null) {
169:                            dataDictionaryWarnings.put(key,
170:                                    "DataDictionaryEntry is null");
171:                        } else if ((entry instanceof  BusinessObjectEntry)
172:                                && !((BusinessObjectEntry) entry)
173:                                        .getBusinessObjectClass()
174:                                        .getSimpleName().equals(key)) {
175:                            dataDictionaryWarnings
176:                                    .put(
177:                                            key,
178:                                            "BusinessObjectEntry xml file name and business object class simple name are out of sync");
179:                        } else if ((entry instanceof  MaintenanceDocumentEntry)
180:                                && (!(((MaintenanceDocumentEntry) entry)
181:                                        .getBusinessObjectClass()
182:                                        .getSimpleName() + "MaintenanceDocument")
183:                                        .equals(key) || !((MaintenanceDocumentEntry) entry)
184:                                        .getDocumentTypeName().equals(key))) {
185:                            dataDictionaryWarnings
186:                                    .put(
187:                                            key,
188:                                            "MaintenanceDocumentEntry xml file name and business object class simple name or workflow document type name are out of sync");
189:                        } else if ((entry instanceof  TransactionalDocumentEntry)
190:                                && (!((TransactionalDocumentEntry) entry)
191:                                        .getDocumentClass().getSimpleName()
192:                                        .equals(key) || !((TransactionalDocumentEntry) entry)
193:                                        .getDocumentTypeName().equals(key))) {
194:                            dataDictionaryWarnings
195:                                    .put(
196:                                            key,
197:                                            "TransactionalDocumentEntry xml file name and document class simple name or workflow document type name are out of sync");
198:                        }
199:
200:                    } catch (Exception e) {
201:                        dataDictionaryLoadFailures.put(key, e);
202:                    }
203:                }
204:            }
205:
206:            protected void setUp() throws Exception {
207:                super .setUp();
208:                dataDictionary = SpringContext.getBean(
209:                        DataDictionaryService.class).getDataDictionary();
210:                dataDictionaryLoadFailures = new TreeMap();
211:                dataDictionaryWarnings = new TreeMap();
212:            }
213:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.