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


001:        package com.mockrunner.test.consistency;
002:
003:        import java.io.File;
004:        import java.io.FilenameFilter;
005:        import java.net.URL;
006:        import java.util.ArrayList;
007:        import java.util.Arrays;
008:        import java.util.List;
009:
010:        import junit.framework.Test;
011:        import junit.framework.TestSuite;
012:
013:        import com.mockrunner.example.connector.AccountDAOTest;
014:        import com.mockrunner.example.ejb.UserLoginSessionTest;
015:        import com.mockrunner.example.jdbc.BookstoreTest;
016:        import com.mockrunner.example.jms.StockQuotePublisherTest;
017:        import com.mockrunner.example.servlet.RedirectServletTest;
018:        import com.mockrunner.example.struts.AuthenticationActionTest;
019:        import com.mockrunner.example.tag.TableEnumTagTest;
020:        import com.mockrunner.gen.jar.MockrunnerJars;
021:
022:        public class MockrunnerJarTestConfiguration {
023:            public final static String RELEASE_DIR = "bin";
024:            public final static String BUILD_DIR = "buildjdk1.6jee5";
025:            public final static String LIB_DIR = "lib";
026:            public final static String JDK13_DIR = "jdk1.3";
027:            public final static String JDK14_DIR = "jdk1.4";
028:            public final static String JDK15_DIR = "jdk1.5";
029:            public final static String JDK16_DIR = "jdk1.6";
030:            public final static String J2EE13_DIR = "j2ee1.3";
031:            public final static String J2EE14_DIR = "j2ee1.4";
032:            public final static String JEE5_DIR = "jee5";
033:            public final static String THIRD_PARTY_DIR = "jar";
034:
035:            public final static String ALL_REFERENCE_TEST = AllReferenceTests.class
036:                    .getName();
037:            public final static String JDBC_REFERENCE_TEST = BookstoreTest.class
038:                    .getName();
039:            public final static String EJB_REFERENCE_TEST = UserLoginSessionTest.class
040:                    .getName();
041:            public final static String JMS_REFERENCE_TEST = StockQuotePublisherTest.class
042:                    .getName();
043:            public final static String SERVLET_REFERENCE_TEST = RedirectServletTest.class
044:                    .getName();
045:            public final static String STRUTS_REFERENCE_TEST = AuthenticationActionTest.class
046:                    .getName();
047:            public final static String TAG_REFERENCE_TEST = TableEnumTagTest.class
048:                    .getName();
049:            public final static String CONNECTOR_REFERENCE_TEST = AccountDAOTest.class
050:                    .getName();
051:
052:            public Mapping[] createMappings() {
053:                try {
054:                    List jdk13j2ee13Jars = getReleasedJars(JDK13_DIR,
055:                            J2EE13_DIR);
056:                    List jdk14j2ee13Jars = getReleasedJars(JDK14_DIR,
057:                            J2EE13_DIR);
058:                    List jdk14j2ee14Jars = getReleasedJars(JDK14_DIR,
059:                            J2EE14_DIR);
060:                    List jdk15j2ee13Jars = getReleasedJars(JDK15_DIR,
061:                            J2EE13_DIR);
062:                    List jdk15j2ee14Jars = getReleasedJars(JDK15_DIR,
063:                            J2EE14_DIR);
064:                    List jdk15jee5Jars = getReleasedJars(JDK15_DIR, JEE5_DIR);
065:                    List jdk16j2ee13Jars = getReleasedJars(JDK16_DIR,
066:                            J2EE13_DIR);
067:                    List jdk16j2ee14Jars = getReleasedJars(JDK16_DIR,
068:                            J2EE14_DIR);
069:                    List jdk16jee5Jars = getReleasedJars(JDK16_DIR, JEE5_DIR);
070:                    List jee5ThirdPartyJarURLs = getURLFromFileList(getThirdPartyJarsJEE5());
071:                    List j2ee14ThirdPartyJarURLs = getURLFromFileList(getThirdPartyJarsJ2EE14());
072:                    List j2ee13ThirdPartyJarURLs = getURLFromFileList(getThirdPartyJarsJ2EE13());
073:                    List jdk13j2ee13mappings = createMappings(jdk13j2ee13Jars,
074:                            j2ee13ThirdPartyJarURLs);
075:                    List jdk14j2ee13mappings = createMappings(jdk14j2ee13Jars,
076:                            j2ee13ThirdPartyJarURLs);
077:                    List jdk14j2ee14mappings = createMappings(jdk14j2ee14Jars,
078:                            j2ee14ThirdPartyJarURLs);
079:                    List jdk15j2ee13mappings = createMappings(jdk15j2ee13Jars,
080:                            j2ee13ThirdPartyJarURLs);
081:                    List jdk15j2ee14mappings = createMappings(jdk15j2ee14Jars,
082:                            j2ee14ThirdPartyJarURLs);
083:                    List jdk15jee5mappings = createMappings(jdk15jee5Jars,
084:                            jee5ThirdPartyJarURLs);
085:                    List jdk16j2ee13mappings = createMappings(jdk16j2ee13Jars,
086:                            j2ee13ThirdPartyJarURLs);
087:                    List jdk16j2ee14mappings = createMappings(jdk16j2ee14Jars,
088:                            j2ee14ThirdPartyJarURLs);
089:                    List jdk16jee5mappings = createMappings(jdk16jee5Jars,
090:                            jee5ThirdPartyJarURLs);
091:                    List resultList = new ArrayList();
092:                    resultList.addAll(jdk13j2ee13mappings);
093:                    resultList.addAll(jdk14j2ee13mappings);
094:                    resultList.addAll(jdk14j2ee14mappings);
095:                    resultList.addAll(jdk15j2ee13mappings);
096:                    resultList.addAll(jdk15j2ee14mappings);
097:                    resultList.addAll(jdk15jee5mappings);
098:                    resultList.addAll(jdk16j2ee13mappings);
099:                    resultList.addAll(jdk16j2ee14mappings);
100:                    resultList.addAll(jdk16jee5mappings);
101:                    return (Mapping[]) resultList
102:                            .toArray(new Mapping[resultList.size()]);
103:                } catch (Exception exc) {
104:                    throw new RuntimeException(exc);
105:                }
106:            }
107:
108:            private List createMappings(List jars, List thirdpartyJarURLs)
109:                    throws Exception {
110:                List mappings = new ArrayList();
111:                for (int ii = 0; ii < jars.size(); ii++) {
112:                    File currentFile = (File) jars.get(ii);
113:                    String name = currentFile.getName();
114:                    String referenceTest = getReferenceTest(name);
115:                    List urls = new ArrayList();
116:                    urls.add(currentFile.toURI().toURL());
117:                    urls.add(new File(BUILD_DIR).toURI().toURL());
118:                    urls.addAll(thirdpartyJarURLs);
119:                    Mapping currentMapping = new Mapping(referenceTest,
120:                            (URL[]) urls.toArray(new URL[urls.size()]));
121:                    mappings.add(currentMapping);
122:                }
123:                return mappings;
124:            }
125:
126:            private String getReferenceTest(String jarName) {
127:                if (jarName.indexOf("servlet") > -1) {
128:                    return SERVLET_REFERENCE_TEST;
129:                } else if (jarName.indexOf("tag") > -1) {
130:                    return TAG_REFERENCE_TEST;
131:                } else if (jarName.indexOf("struts") > -1) {
132:                    return STRUTS_REFERENCE_TEST;
133:                } else if (jarName.indexOf("jms") > -1) {
134:                    return JMS_REFERENCE_TEST;
135:                } else if (jarName.indexOf("ejb") > -1) {
136:                    return EJB_REFERENCE_TEST;
137:                } else if (jarName.indexOf("jdbc") > -1) {
138:                    return JDBC_REFERENCE_TEST;
139:                } else if (jarName.indexOf("jca") > -1) {
140:                    return CONNECTOR_REFERENCE_TEST;
141:                }
142:                return ALL_REFERENCE_TEST;
143:            }
144:
145:            private List getURLFromFileList(List list) throws Exception {
146:                List urlList = new ArrayList();
147:                for (int ii = 0; ii < list.size(); ii++) {
148:                    File currentFile = (File) list.get(ii);
149:                    urlList.add(currentFile.toURI().toURL());
150:                }
151:                return urlList;
152:            }
153:
154:            public List getThirdPartyJarsJEE5() {
155:                String jarDirName = getBaseDir() + THIRD_PARTY_DIR;
156:                return new ArrayList(Arrays.asList(new File(jarDirName)
157:                        .listFiles(new JarFileFilter())));
158:            }
159:
160:            public List getThirdPartyJarsJ2EE14() {
161:                List resultList = getThirdPartyJarsWithoutJEE5Jars();
162:                String jarDirName = getBaseDir() + THIRD_PARTY_DIR
163:                        + File.separator + J2EE14_DIR;
164:                resultList.addAll(Arrays.asList(new File(jarDirName)
165:                        .listFiles(new JarFileFilter())));
166:                return resultList;
167:            }
168:
169:            public List getThirdPartyJarsJ2EE13() {
170:                List resultList = getThirdPartyJarsWithoutJEE5Jars();
171:                String jarDirName = getBaseDir() + THIRD_PARTY_DIR
172:                        + File.separator + J2EE13_DIR;
173:                resultList.addAll(Arrays.asList(new File(jarDirName)
174:                        .listFiles(new JarFileFilter())));
175:                return resultList;
176:            }
177:
178:            private List getThirdPartyJarsWithoutJEE5Jars() {
179:                List fileList = getThirdPartyJarsJEE5();
180:                List resultList = new ArrayList();
181:                for (int ii = 0; ii < fileList.size(); ii++) {
182:                    File currentFile = (File) fileList.get(ii);
183:                    if (!isJEE5StandardInterfaceOrJEE5OnlyJar(currentFile)) {
184:                        resultList.add(currentFile);
185:                    }
186:                }
187:                return resultList;
188:            }
189:
190:            private boolean isJEE5StandardInterfaceOrJEE5OnlyJar(
191:                    File currentFile) {
192:                if (MockrunnerJars.getStandardInterfaceJars().contains(
193:                        currentFile.getName()))
194:                    return true;
195:                if (MockrunnerJars.getJEE5OnlyJars().contains(
196:                        currentFile.getName()))
197:                    return true;
198:                return false;
199:            }
200:
201:            public List getReleasedJars(String jdkDir, String j2eeDir) {
202:                String jarDirName = getBaseDir() + LIB_DIR + File.separator
203:                        + jdkDir + File.separator + j2eeDir;
204:                return listFiles(jarDirName);
205:            }
206:
207:            private List listFiles(String jarDirName) {
208:                File[] jarFiles = new File(jarDirName)
209:                        .listFiles(new JarFileFilter());
210:                return Arrays.asList(jarFiles);
211:            }
212:
213:            private String getBaseDir() {
214:                File releaseDir = new File(RELEASE_DIR);
215:                String jarDirName = releaseDir.getAbsolutePath()
216:                        + File.separator;
217:                return jarDirName + releaseDir.list()[0] + File.separator;
218:            }
219:
220:            private class JarFileFilter implements  FilenameFilter {
221:                public boolean accept(File dir, String name) {
222:                    if (name.endsWith(".jar"))
223:                        return true;
224:                    return false;
225:                }
226:            }
227:
228:            public class Mapping {
229:                private String testClass;
230:                private URL[] urls;
231:
232:                public Mapping(String testClass, URL[] urls) {
233:                    this .testClass = testClass;
234:                    this .urls = urls;
235:                }
236:
237:                public String getTestClass() {
238:                    return testClass;
239:                }
240:
241:                public URL[] getUrls() {
242:                    return urls;
243:                }
244:            }
245:
246:            public static class AllReferenceTests {
247:                public static Test suite() {
248:                    TestSuite suite = new TestSuite("AllReferenceTests");
249:                    suite.addTest(new TestSuite(BookstoreTest.class));
250:                    suite.addTest(new TestSuite(UserLoginSessionTest.class));
251:                    suite.addTest(new TestSuite(StockQuotePublisherTest.class));
252:                    suite.addTest(new TestSuite(RedirectServletTest.class));
253:                    suite
254:                            .addTest(new TestSuite(
255:                                    AuthenticationActionTest.class));
256:                    suite.addTest(new TestSuite(TableEnumTagTest.class));
257:                    suite.addTest(new TestSuite(AccountDAOTest.class));
258:                    return suite;
259:                }
260:            }
261:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.