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


001:        /*
002:         * Copyright 2006-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.module.gl.util;
017:
018:        import java.io.BufferedReader;
019:        import java.io.IOException;
020:        import java.io.InputStream;
021:        import java.io.InputStreamReader;
022:        import java.text.DateFormat;
023:        import java.text.SimpleDateFormat;
024:        import java.util.ArrayList;
025:        import java.util.Arrays;
026:        import java.util.Date;
027:        import java.util.List;
028:
029:        /**
030:         * Utilities for helping set up and run GL tests, mostly giving GL unit test writers the ability
031:         * to load flat files of String-formatted origin entries from the classpath
032:         */
033:        public class GeneralLedgerTestHelper {
034:
035:            /**
036:             * Loads a file of String-formatted Origin Entries from the class path
037:             * 
038:             * @param nameOfOutputOriginEntryFileFromFis the name of the file to load
039:             * @return a List of origin entries
040:             * @throws IOException thrown if the file cannot be read
041:             */
042:            static public List loadOutputOriginEntriesFromClasspath(
043:                    String nameOfOutputOriginEntryFileFromFis)
044:                    throws IOException {
045:                return loadOutputOriginEntriesFromClasspath(
046:                        nameOfOutputOriginEntryFileFromFis, null);
047:            }
048:
049:            /**
050:             * This method differs from OriginEntryServiceImpl.loadFlatFile in that it loads a file using a classloader instead of loading a
051:             * file from an absolute file path. This allows and in fact requires that the file from which the entries will be loaded be
052:             * checked into the source repository along with this test.
053:             * 
054:             * @param nameOfOutputOriginEntryFileFromFis the name of the file to load
055:             * @return a List of origin entries
056:             * @throws IOException  thrown if the file cannot be read
057:             */
058:            static public List loadOutputOriginEntriesFromClasspath(
059:                    String nameOfOutputOriginEntryFileFromFis, Date date)
060:                    throws IOException {
061:                ClassLoader classLoader = Thread.currentThread()
062:                        .getContextClassLoader();
063:                InputStream inputStream = classLoader
064:                        .getResourceAsStream(nameOfOutputOriginEntryFileFromFis);
065:
066:                BufferedReader reader = new BufferedReader(
067:                        new InputStreamReader(inputStream));
068:
069:                List expectedOutputOriginEntries = new ArrayList();
070:                String line = null;
071:                DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
072:                char[] dateChars = null == date ? null : dateFormat
073:                        .format(date).toCharArray();
074:
075:                while (null != (line = reader.readLine())) {
076:                    // correct for differences in line format
077:                    char[] lineChars = new char[173];
078:                    Arrays.fill(lineChars, ' ');
079:                    char[] lineA = line.toCharArray();
080:                    System.arraycopy(lineA, 0, lineChars, 0, lineA.length);
081:                    // converts the + at pos 91 to a space
082:                    lineChars[91] = ' ';
083:                    int idx = 92;
084:                    do {
085:                        // converts leading 0 characters for amount to spaces
086:                        if ('0' != lineChars[idx]) {
087:                            break;
088:                        } else {
089:                            lineChars[idx] = ' ';
090:                        }
091:                    } while (103 > idx++);
092:
093:                    if (null != date) { // splice in the date
094:
095:                        for (int i = 0; i < dateChars.length; i++) {
096:                            lineChars[109 + i] = dateChars[i];
097:                        }
098:
099:                    }
100:
101:                    String lin2 = new String(lineChars);
102:
103:                    // KULRNE-34: in FIS, doc numbers were 9 characters long, and in Kuali, they are 14
104:                    // it means we need to add 5 spaces after the doc number
105:                    // first char after doc number is at array pos 46
106:
107:                    String prefix = lin2.substring(0, 46);
108:                    String suffix = lin2.substring(46);
109:
110:                    lin2 = prefix + "     " + suffix;
111:
112:                    // now we add 5 characters to reference doc number
113:                    // reference doc number ends 11 spaces from end (see OriginEntryFull.java)
114:                    prefix = lin2.substring(0, lin2.length() - 11);
115:                    suffix = lin2.substring(lin2.length() - 11);
116:
117:                    lin2 = prefix + "     " + suffix;
118:
119:                    // the string is too long, so we truncate 10 characters off from it
120:                    lin2 = lin2.substring(0, lin2.length() - 10);
121:
122:                    expectedOutputOriginEntries.add(lin2);
123:                }
124:
125:                return expectedOutputOriginEntries;
126:            }
127:
128:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.