Source Code Cross Referenced for TestData.java in  » Content-Management-System » TransferCM » com » methodhead » 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 » Content Management System » TransferCM » com.methodhead 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* 
002:         * Copyright (C) 2006 Methodhead Software LLC.  All rights reserved.
003:         * 
004:         * This file is part of TransferCM.
005:         * 
006:         * TransferCM is free software; you can redistribute it and/or modify it under the
007:         * terms of the GNU General Public License as published by the Free Software
008:         * Foundation; either version 2 of the License, or (at your option) any later
009:         * version.
010:         * 
011:         * TransferCM is distributed in the hope that it will be useful, but WITHOUT ANY
012:         * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
013:         * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
014:         * details.
015:         * 
016:         * You should have received a copy of the GNU General Public License along with
017:         * TransferCM; if not, write to the Free Software Foundation, Inc., 51 Franklin St,
018:         * Fifth Floor, Boston, MA  02110-1301  USA
019:         */
020:
021:        package com.methodhead;
022:
023:        import org.apache.commons.beanutils.*;
024:        import com.methodhead.persistable.*;
025:        import com.methodhead.sitecontext.*;
026:        import com.methodhead.property.*;
027:        import com.methodhead.reg.*;
028:        import com.methodhead.transfer.*;
029:        import com.methodhead.shim.*;
030:        import java.sql.*;
031:        import org.apache.commons.io.*;
032:        import java.io.*;
033:        import java.util.*;
034:        import org.apache.commons.io.filefilter.*;
035:
036:        public class TestData {
037:
038:            // constructors /////////////////////////////////////////////////////////////
039:
040:            // constants ////////////////////////////////////////////////////////////////
041:
042:            // classes //////////////////////////////////////////////////////////////////
043:
044:            // methods //////////////////////////////////////////////////////////////////
045:
046:            public static void createSiteContexts() {
047:                siteContext1 = new SiteContext();
048:                siteContext1.getDomains().add("site1.com");
049:                siteContext1.saveNew();
050:
051:                siteContext2 = new SiteContext();
052:                siteContext2.getDomains().add("site2.com");
053:                siteContext2.getDomains().add("www.site2.com");
054:                siteContext2.saveNew();
055:
056:                siteContext3 = new SiteContext();
057:                siteContext3.getDomains().add("site3.com");
058:                siteContext3.setString("path", "path");
059:                siteContext3.saveNew();
060:            }
061:
062:            public static void createProperties() {
063:                Property
064:                        .setProperty(
065:                                SiteContext.getDefaultContext(),
066:                                SiteExtension.PROPERTY_EXTENSIONS,
067:                                "com.methodhead.transfer.MockExtension,com.methodhead.transfer.MockExtension2",
068:                                "", new Boolean(true));
069:            }
070:
071:            public static void createSiteExtensions() {
072:                createUsers();
073:                createProperties();
074:
075:                siteExtension1 = new SiteExtension();
076:                siteExtension1.setInt("sitecontext_id", siteContext1
077:                        .getInt("id"));
078:                siteExtension1.setString("class_name",
079:                        "com.methodhead.transfer.MockExtension");
080:                siteExtension1.setBoolean("enabled", true);
081:                siteExtension1.saveNew();
082:            }
083:
084:            public static void createSiteContextAikps() throws SQLException {
085:                createDynaClassAndTable();
086:
087:                siteContextAikp1 = new SiteContextAikp(dynaClass);
088:                siteContextAikp1.setSiteContext(siteContext1);
089:                siteContextAikp1.setString("field", "siteContextAikp1");
090:                siteContextAikp1.saveNew();
091:
092:                siteContextAikp2 = new SiteContextAikp(dynaClass);
093:                siteContextAikp2.setSiteContext(siteContext1);
094:                siteContextAikp2.setString("field", "siteContextAikp2");
095:                siteContextAikp2.saveNew();
096:
097:                siteContextAikp3 = new SiteContextAikp(dynaClass);
098:                siteContextAikp3.setSiteContext(siteContext2);
099:                siteContextAikp3.setString("field", "siteContextAikp3");
100:                siteContextAikp3.saveNew();
101:            }
102:
103:            public static void createDynaClassAndTable() throws SQLException {
104:                createSiteContexts();
105:
106:                try {
107:                    ConnectionSingleton.runUpdate("DROP TABLE sitecontextaikp");
108:                } catch (SQLException e) {
109:                }
110:                ConnectionSingleton
111:                        .runUpdate("CREATE TABLE sitecontextaikp (id INT NOT NULL, sitecontext_id INT NOT NULL, field VARCHAR(64) NOT NULL)");
112:
113:                DynaProperty[] dynaProperties = new DynaProperty[] {
114:                        new DynaProperty("id", Integer.class),
115:                        new DynaProperty("sitecontext_id", Integer.class),
116:                        new DynaProperty("field", String.class) };
117:
118:                dynaClass = new BasicDynaClass("sitecontextaikp",
119:                        SiteContextAikp.class, dynaProperties);
120:            }
121:
122:            public static void createRoles() {
123:                createSiteContexts();
124:
125:                role1 = new Role();
126:                role1.setSiteContext(siteContext1);
127:                role1.setName(DefaultTransferPolicy.ROLE_SYSADMIN);
128:
129:                role2 = new Role();
130:                role2.setSiteContext(siteContext1);
131:                role2.setName(DefaultTransferPolicy.ROLE_SITEADMIN);
132:
133:                role3 = new Role();
134:                role3.setSiteContext(siteContext2);
135:                role3.setName(DefaultTransferPolicy.ROLE_WEBMASTER);
136:
137:                role4 = new Role();
138:                role4.setSiteContext(SiteContext.getDefaultContext());
139:                role4.setName(DefaultTransferPolicy.ROLE_SYSADMIN);
140:
141:                role5 = new Role();
142:                role5.setSiteContext(siteContext3);
143:                role5.setName(DefaultTransferPolicy.ROLE_WEBMASTER);
144:            }
145:
146:            public static void createUsers() {
147:                createRoles();
148:
149:                user1 = new User();
150:                user1.setString("password", "password");
151:                user1.getRoles().add(role1);
152:                user1.getRoles().add(role4); // need this for a lot of tests
153:                user1.getContact().setString("firstname", "User1");
154:                user1.getContact().setString("lastname", "BBB");
155:                user1.getContact().setString("email", "test1@methodhead.com");
156:                user1.saveNew();
157:
158:                user2 = new User();
159:                user2.setString("password", "password");
160:                user2.getRoles().add(role2);
161:                user2.getContact().setString("firstname", "User2");
162:                user2.getContact().setString("lastname", "CCC");
163:                user2.getContact().setString("email", "test2@methodhead.com");
164:                user2.saveNew();
165:
166:                user3 = new User();
167:                user3.setString("password", "password");
168:                user3.getRoles().add(role3);
169:                user3.getRoles().add(role5);
170:                user3.getContact().setString("firstname", "User3");
171:                user3.getContact().setString("lastname", "AAA");
172:                user3.getContact().setString("email", "test3@methodhead.com");
173:                user3.saveNew();
174:            }
175:
176:            public static void createPages() {
177:                createSiteContexts();
178:
179:                Panel panel = null;
180:
181:                panel = new Panel();
182:                panel.setName("body");
183:                panel.setModuleClass("com.methodhead.shim.MockModule");
184:
185:                page1 = new Page();
186:                page1.setSiteContext(SiteContext.getDefaultContext());
187:                page1.set("title", "Page1");
188:                page1.set("alttitle", "altPage1");
189:                page1.set("aliasname", "page1");
190:                page1.setBoolean("hidden", false);
191:                page1.setString("template", "template.jsp");
192:                page1.set("metadescription", "metadescription");
193:                page1.set("metakeywords", "metakeywords");
194:                page1.addPanel(panel);
195:                page1.saveNew();
196:
197:                page2 = new Page();
198:                page2.setSiteContext(SiteContext.getDefaultContext());
199:                page2.saveNew();
200:
201:                page3 = new Page();
202:                page3.setSiteContext(SiteContext.getDefaultContext());
203:                page3.saveNew();
204:
205:                page4 = new Page();
206:                page4.setSiteContext(SiteContext.getDefaultContext());
207:                page4.saveNew();
208:
209:                page5 = new Page();
210:                page5.setSiteContext(SiteContext.getDefaultContext());
211:                page5.saveNew();
212:            }
213:
214:            public static void createLinks() {
215:                createPages();
216:
217:                // Link1
218:                //   Link2
219:                //     Link3
220:                //   Link4
221:                //   Link5
222:                link1 = new Link();
223:                link1.setTitle("Link1");
224:                link1.setPageId(page1.getInt("id"));
225:
226:                link2 = new Link();
227:                link2.setTitle("Link2");
228:                link2.setPageId(page2.getInt("id"));
229:
230:                link3 = new Link();
231:                link3.setTitle("Link3");
232:                link3.setPageId(page3.getInt("id"));
233:
234:                link4 = new Link();
235:                link4.setTitle("Link4");
236:                link4.setPageId(page4.getInt("id"));
237:
238:                link5 = new Link();
239:                link5.setTitle("Link5");
240:                link5.setPageId(page5.getInt("id"));
241:
242:                link1.add(link2);
243:                link2.add(link3);
244:                link1.add(link4);
245:                link1.add(link5);
246:            }
247:
248:            public static void createSiteMap() {
249:                createLinks();
250:
251:                siteMap1 = new SiteMap();
252:                siteMap1.setSiteContext(SiteContext.getDefaultContext());
253:                siteMap1.setRoot(link1);
254:                siteMap1.save();
255:            }
256:
257:            public static void createPageNotFoundPage() {
258:                createSiteMap();
259:
260:                pageNotFoundPage = new Page();
261:                pageNotFoundPage
262:                        .setSiteContext(SiteContext.getDefaultContext());
263:                pageNotFoundPage.set("title", "Page Not Found Page");
264:                pageNotFoundPage.set("aliasname", "pagenotfound");
265:                pageNotFoundPage.setBoolean("hidden", false);
266:                pageNotFoundPage.setString("template", "template3.jsp"); // we'll use this to distinguish this page in tests
267:                pageNotFoundPage.saveNew();
268:
269:                pageNotFoundLink = new Link();
270:                pageNotFoundLink.setTitle("Page Not Found Page");
271:                pageNotFoundLink.setPageId(pageNotFoundPage.getInt("id"));
272:
273:                link1.add(pageNotFoundLink);
274:
275:                siteMap1.save();
276:            }
277:
278:            public static void createWebappFiles(File webappDir)
279:                    throws IOException {
280:
281:                //
282:                // delete test files if they exist
283:                //
284:                FileUtils.deleteDirectory(new File(webappDir, "0"));
285:                FileUtils.deleteDirectory(new File(webappDir, "1"));
286:                FileUtils.deleteDirectory(new File(webappDir, "2"));
287:                FileUtils.deleteDirectory(new File(webappDir, "3"));
288:                FileUtils.deleteDirectory(new File(webappDir,
289:                        "WEB-INF/resources"));
290:
291:                //
292:                // copy files; we have to skip svn directories because cactus doesn't seem
293:                // to delete them when starting tests and this hangs up the process
294:                //
295:                for (Iterator iter = FileUtils.iterateFiles(new File(
296:                        "support/webapp", ""), TrueFileFilter.INSTANCE,
297:                        FileFilterUtils.makeSVNAware(TrueFileFilter.INSTANCE)); iter
298:                        .hasNext();) {
299:                    File file = (File) iter.next();
300:                    FileUtils.copyFile(file, new File(webappDir, file.getPath()
301:                            .substring("support/webapp/".length())));
302:                }
303:            }
304:
305:            // properties ///////////////////////////////////////////////////////////////
306:
307:            // attributes ///////////////////////////////////////////////////////////////
308:
309:            public static SiteContext siteContext1 = null;
310:            public static SiteContext siteContext2 = null;
311:            public static SiteContext siteContext3 = null;
312:
313:            public static SiteExtension siteExtension1 = null;
314:
315:            public static SiteContextAikp siteContextAikp1 = null;
316:            public static SiteContextAikp siteContextAikp2 = null;
317:            public static SiteContextAikp siteContextAikp3 = null;
318:
319:            public static DynaClass dynaClass = null;
320:
321:            public static Role role1 = null;
322:            public static Role role2 = null;
323:            public static Role role3 = null;
324:            public static Role role4 = null;
325:            public static Role role5 = null;
326:
327:            public static User user1 = null;
328:            public static User user2 = null;
329:            public static User user3 = null;
330:
331:            public static Page page1 = null;
332:            public static Page page2 = null;
333:            public static Page page3 = null;
334:            public static Page page4 = null;
335:            public static Page page5 = null;
336:            public static Page pageNotFoundPage = null;
337:
338:            public static Link link1 = null;
339:            public static Link link2 = null;
340:            public static Link link3 = null;
341:            public static Link link4 = null;
342:            public static Link link5 = null;
343:            public static Link pageNotFoundLink = null;
344:
345:            public static SiteMap siteMap1 = null;
346:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.