Source Code Cross Referenced for SiteContextActionTest.java in  » Content-Management-System » TransferCM » com » methodhead » transfer » 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.transfer 
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.transfer;
022:
023:        import java.util.*;
024:        import java.sql.*;
025:        import java.io.*;
026:        import junit.framework.*;
027:        import org.apache.log4j.*;
028:        import com.methodhead.persistable.*;
029:        import com.methodhead.test.*;
030:        import servletunit.struts.*;
031:        import org.apache.struts.action.*;
032:        import org.apache.cactus.*;
033:        import com.methodhead.sitecontext.*;
034:        import com.methodhead.reg.*;
035:        import com.methodhead.aikp.*;
036:        import com.methodhead.auth.*;
037:        import com.methodhead.property.*;
038:        import com.methodhead.*;
039:
040:        public class SiteContextActionTest extends CactusStrutsTestCase {
041:
042:            SiteContext siteContext = null;
043:            SiteExtension siteExtension = null;
044:            List list = null;
045:            Extension[] extensions = null;
046:            DynaActionForm form = null;
047:            User user = null;
048:
049:            static {
050:                TestUtils.initLogger();
051:            }
052:
053:            public SiteContextActionTest(String name) {
054:                super (name);
055:            }
056:
057:            public void setUp() {
058:                try {
059:                    super .setUp();
060:
061:                    ConnectionSingleton.runBatchUpdate(new FileReader(
062:                            "webapp/WEB-INF/db/transfer-reset.sql"));
063:                } catch (Exception e) {
064:                    fail(e.getMessage());
065:                }
066:            }
067:
068:            public void tearDown() throws Exception {
069:                super .tearDown();
070:            }
071:
072:            /*
073:             public void testDoDelete() {
074:             TestData.createUsers();
075:
076:             //
077:             // delete the site context
078:             //
079:             setRequestPathInfo( "/siteContext.do" );
080:             addRequestParameter( "action", "delete" );
081:             addRequestParameter( "id", "1" );
082:             actionPerform();
083:
084:             verifyForwardPath( "/siteContext.do?action=list" );
085:
086:             //
087:             // user/site context association should have been deleted
088:             //
089:             user = new User();
090:             user.load( new IntKey( "1" ) );
091:
092:             assertEquals( 0, user.getRoles().size() );
093:             }
094:             */
095:
096:            public void testDoInitExtension() {
097:                TestData.createSiteExtensions();
098:                AuthUtil.setUser(request, TestData.user1);
099:                MockExtension.setInit(false);
100:                MockExtension2.setInit(false);
101:
102:                //
103:                // init MockExtension2
104:                //
105:                setRequestPathInfo("/initExtension");
106:                addRequestParameter("id", "1");
107:                addRequestParameter("classname",
108:                        "com.methodhead.transfer.MockExtension2");
109:                actionPerform();
110:
111:                verifyForwardPath("/siteContext.do?action=edit&id=1");
112:
113:                siteExtension = new SiteExtension();
114:                list = siteExtension
115:                        .loadAllForSiteContext(TestData.siteContext1);
116:
117:                //
118:                // should have two modules enabled
119:                //
120:                assertEquals(2, list.size());
121:
122:                siteExtension = (SiteExtension) list.get(0);
123:                assertEquals("com.methodhead.transfer.MockExtension",
124:                        siteExtension.getString("class_name"));
125:                assertEquals(true, siteExtension.getBoolean("enabled"));
126:
127:                siteExtension = (SiteExtension) list.get(1);
128:                assertEquals("com.methodhead.transfer.MockExtension2",
129:                        siteExtension.getString("class_name"));
130:                assertEquals(true, siteExtension.getBoolean("enabled"));
131:
132:                //
133:                // mockmodule should have been inited
134:                //
135:                assertEquals(false, MockExtension.getInit());
136:                assertEquals(true, MockExtension2.getInit());
137:            }
138:
139:            public void testDoDestroyExtension() {
140:                TestData.createSiteExtensions();
141:                AuthUtil.setUser(request, TestData.user1);
142:                MockExtension.setDestroy(0);
143:                MockExtension2.setDestroy(0);
144:
145:                //
146:                // destroy MockExtension
147:                //
148:                setRequestPathInfo("/destroyExtension");
149:                addRequestParameter("id", "1");
150:                addRequestParameter("classname",
151:                        "com.methodhead.transfer.MockExtension2");
152:                actionPerform();
153:
154:                verifyForward("confirm");
155:            }
156:
157:            public void testDoDestroyExtensionConfirm() {
158:                TestData.createSiteExtensions();
159:                AuthUtil.setUser(request, TestData.user1);
160:                MockExtension.setDestroy(0);
161:                MockExtension2.setDestroy(0);
162:
163:                //
164:                // destroy MockExtension
165:                //
166:                setRequestPathInfo("/destroyExtension");
167:                addRequestParameter("id", "1");
168:                addRequestParameter("classname",
169:                        "com.methodhead.transfer.MockExtension");
170:                addRequestParameter("confirm", "Confirm");
171:                actionPerform();
172:
173:                verifyForwardPath("/siteContext.do?action=edit&id=1");
174:
175:                siteExtension = new SiteExtension();
176:                list = siteExtension
177:                        .loadAllForSiteContext(TestData.siteContext1);
178:
179:                //
180:                // should have zero modules enabled
181:                //
182:                assertEquals(0, list.size());
183:
184:                //
185:                // MockModule2 should have been destroyed for site context 1
186:                //
187:                assertEquals(1, MockExtension.getDestroy());
188:                assertEquals(0, MockExtension2.getDestroy());
189:            }
190:
191:            public void testDoDisableExtension() {
192:                TestData.createSiteExtensions();
193:                AuthUtil.setUser(request, TestData.user1);
194:
195:                //
196:                // disable MockExtension
197:                //
198:                setRequestPathInfo("/disableExtension");
199:                addRequestParameter("id", "1");
200:                addRequestParameter("classname",
201:                        "com.methodhead.transfer.MockExtension");
202:                actionPerform();
203:
204:                verifyForwardPath("/siteContext.do?action=edit&id=1");
205:
206:                siteExtension = new SiteExtension();
207:                list = siteExtension
208:                        .loadAllForSiteContext(TestData.siteContext1);
209:
210:                //
211:                // should have MockExtension disabled
212:                //
213:                assertEquals(1, list.size());
214:
215:                siteExtension = (SiteExtension) list.get(0);
216:                assertEquals("com.methodhead.transfer.MockExtension",
217:                        siteExtension.getString("class_name"));
218:                assertEquals(false, siteExtension.getBoolean("enabled"));
219:            }
220:
221:            public void testDoEnableExtension() {
222:                TestData.createSiteExtensions();
223:                AuthUtil.setUser(request, TestData.user1);
224:
225:                //
226:                // disable MockExtension
227:                //
228:                siteExtension = new SiteExtension();
229:                siteExtension.load(TestData.siteContext1,
230:                        "com.methodhead.transfer.MockExtension");
231:                siteExtension.setBoolean("enabled", false);
232:                siteExtension.save();
233:
234:                //
235:                // enable MockExtension
236:                //
237:                setRequestPathInfo("/enableExtension");
238:                addRequestParameter("id", "1");
239:                addRequestParameter("classname",
240:                        "com.methodhead.transfer.MockExtension");
241:                actionPerform();
242:
243:                verifyForwardPath("/siteContext.do?action=edit&id=1");
244:
245:                siteExtension = new SiteExtension();
246:                list = siteExtension
247:                        .loadAllForSiteContext(TestData.siteContext1);
248:
249:                //
250:                // should have MockExtension disabled
251:                //
252:                assertEquals(1, list.size());
253:
254:                siteExtension = (SiteExtension) list.get(0);
255:                assertEquals("com.methodhead.transfer.MockExtension",
256:                        siteExtension.getString("class_name"));
257:                assertEquals(true, siteExtension.getBoolean("enabled"));
258:            }
259:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.