Source Code Cross Referenced for SimplePageTest.java in  » J2EE » wicket » org » apache » wicket » markup » html » basic » 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 » J2EE » wicket » org.apache.wicket.markup.html.basic 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         *
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package org.apache.wicket.markup.html.basic;
018:
019:        import org.apache.wicket.WicketRuntimeException;
020:        import org.apache.wicket.WicketTestCase;
021:        import org.apache.wicket.markup.MarkupException;
022:        import org.apache.wicket.markup.MarkupNotFoundException;
023:        import org.apache.wicket.markup.html.WebMarkupContainer;
024:        import org.apache.wicket.markup.html.border.Border;
025:        import org.apache.wicket.markup.html.panel.Panel;
026:        import org.apache.wicket.util.value.ValueMap;
027:        import org.slf4j.Logger;
028:        import org.slf4j.LoggerFactory;
029:
030:        /**
031:         * Simple application that demonstrates the mock http application code (and
032:         * checks that it is working)
033:         * 
034:         * @author Chris Turner
035:         */
036:        public class SimplePageTest extends WicketTestCase {
037:            private static final Logger log = LoggerFactory
038:                    .getLogger(SimplePageTest.class);
039:
040:            /**
041:             * Create the test.
042:             * 
043:             * @param name
044:             *            The test name
045:             */
046:            public SimplePageTest(String name) {
047:                super (name);
048:            }
049:
050:            /**
051:             * @throws Exception
052:             */
053:            public void testRenderHomePage() throws Exception {
054:                executeTest(SimplePage.class, "SimplePageExpectedResult.html");
055:            }
056:
057:            /**
058:             * @throws Exception
059:             */
060:            public void testRenderHomePage_2() throws Exception {
061:                executeTest(SimplePage.class, "SimplePageExpectedResult.html");
062:
063:                Label label = (Label) tester.getLastRenderedPage().get(
064:                        "myLabel");
065:                assertNotNull(label);
066:                tester.processRequestCycle(label);
067:                String document = tester.getServletResponse().getDocument();
068:                assertNotNull(document);
069:                assertEquals("<span wicket:id=\"myLabel\">Test Label</span>",
070:                        document);
071:
072:                Panel panel = (Panel) tester.getLastRenderedPage().get(
073:                        "myPanel");
074:                assertNotNull(panel);
075:                tester.processRequestCycle(panel);
076:                document = tester.getServletResponse().getDocument();
077:                assertNotNull(document);
078:                assertEquals(
079:                        "<wicket:panel>Inside the panel<span wicket:id=\"label\">mein Label</span></wicket:panel>",
080:                        document);
081:
082:                label = (Label) tester.getLastRenderedPage().get(
083:                        "myPanel:label");
084:                assertNotNull(label);
085:                tester.processRequestCycle(label);
086:                document = tester.getServletResponse().getDocument();
087:                assertNotNull(document);
088:                assertFalse("".equals(document));
089:                assertEquals("<span wicket:id=\"label\">mein Label</span>",
090:                        document);
091:
092:                Border border = (Border) tester.getLastRenderedPage().get(
093:                        "myBorder");
094:                assertNotNull(border);
095:                tester.processRequestCycle(border);
096:                document = tester.getServletResponse().getDocument();
097:                assertNotNull(document);
098:                assertFalse("".equals(document));
099:                assertEquals(
100:                        "<wicket:border>before body - <wicket:body>border</wicket:body> - after body</wicket:border>",
101:                        document);
102:
103:                border = (Border) tester.getLastRenderedPage().get("myBorder2");
104:                assertNotNull(border);
105:                tester.processRequestCycle(border);
106:                document = tester.getServletResponse().getDocument();
107:                assertNotNull(document);
108:                assertFalse("".equals(document));
109:                assertEquals(
110:                        "<span wicket:id=\"myBorder2\" testAttr=\"myValue\"><wicket:border>before body - <wicket:body>border</wicket:body> - after body</wicket:border></span>",
111:                        document);
112:
113:                // do the same test twice. Igor reported a problem with that, so we have to test it.
114:                border = (Border) tester.getLastRenderedPage().get("myBorder2");
115:                assertNotNull(border);
116:                tester.processRequestCycle(border);
117:                document = tester.getServletResponse().getDocument();
118:                assertNotNull(document);
119:                assertFalse("".equals(document));
120:                assertEquals(
121:                        "<span wicket:id=\"myBorder2\" testAttr=\"myValue\"><wicket:border>before body - <wicket:body>border</wicket:body> - after body</wicket:border></span>",
122:                        document);
123:
124:                WebMarkupContainer container = (WebMarkupContainer) tester
125:                        .getLastRenderedPage().get("test");
126:                assertNotNull(container);
127:                tester.processRequestCycle(container);
128:                document = tester.getServletResponse().getDocument();
129:                assertNotNull(document);
130:                assertFalse("".equals(document));
131:                assertEquals(
132:                        "body<span wicket:id=\"myLabel2\">Test Label2</span>",
133:                        document);
134:
135:                label = (Label) tester.getLastRenderedPage().get(
136:                        "test:myLabel2");
137:                assertNotNull(label);
138:                tester.processRequestCycle(label);
139:                document = tester.getServletResponse().getDocument();
140:                assertNotNull(document);
141:                assertFalse("".equals(document));
142:                assertEquals("<span wicket:id=\"myLabel2\">Test Label2</span>",
143:                        document);
144:            }
145:
146:            /**
147:             * @throws Exception
148:             */
149:            public void testRenderHomePage_2a() throws Exception {
150:                // Render the component without having rendered the page previously
151:                SimplePage page = new SimplePage();
152:
153:                Label label = (Label) page.get("myLabel");
154:                assertNotNull(label);
155:                tester.processRequestCycle(label);
156:                String document = tester.getServletResponse().getDocument();
157:                assertNotNull(document);
158:                assertEquals("<span wicket:id=\"myLabel\">Test Label</span>",
159:                        document);
160:
161:                Panel panel = (Panel) page.get("myPanel");
162:                assertNotNull(panel);
163:                tester.processRequestCycle(panel);
164:                document = tester.getServletResponse().getDocument();
165:                assertNotNull(document);
166:                assertEquals(
167:                        "<wicket:panel>Inside the panel<span wicket:id=\"label\">mein Label</span></wicket:panel>",
168:                        document);
169:
170:                label = (Label) page.get("myPanel:label");
171:                assertNotNull(label);
172:                tester.processRequestCycle(label);
173:                document = tester.getServletResponse().getDocument();
174:                assertNotNull(document);
175:                assertFalse("".equals(document));
176:                assertEquals("<span wicket:id=\"label\">mein Label</span>",
177:                        document);
178:
179:                Border border = (Border) page.get("myBorder");
180:                assertNotNull(border);
181:                tester.processRequestCycle(border);
182:                document = tester.getServletResponse().getDocument();
183:                assertNotNull(document);
184:                assertFalse("".equals(document));
185:                assertEquals(
186:                        "<wicket:border>before body - <wicket:body>border</wicket:body> - after body</wicket:border>",
187:                        document);
188:
189:                border = (Border) page.get("myBorder2");
190:                assertNotNull(border);
191:                tester.processRequestCycle(border);
192:                document = tester.getServletResponse().getDocument();
193:                assertNotNull(document);
194:                assertFalse("".equals(document));
195:                assertEquals(
196:                        "<span wicket:id=\"myBorder2\" testAttr=\"myValue\"><wicket:border>before body - <wicket:body>border</wicket:body> - after body</wicket:border></span>",
197:                        document);
198:
199:                // do the same test twice. Igor reported a problem with that, so we have to test it.
200:                border = (Border) page.get("myBorder2");
201:                assertNotNull(border);
202:                tester.processRequestCycle(border);
203:                document = tester.getServletResponse().getDocument();
204:                assertNotNull(document);
205:                assertFalse("".equals(document));
206:                assertEquals(
207:                        "<span wicket:id=\"myBorder2\" testAttr=\"myValue\"><wicket:border>before body - <wicket:body>border</wicket:body> - after body</wicket:border></span>",
208:                        document);
209:
210:                WebMarkupContainer container = (WebMarkupContainer) page
211:                        .get("test");
212:                assertNotNull(container);
213:                tester.processRequestCycle(container);
214:                document = tester.getServletResponse().getDocument();
215:                assertNotNull(document);
216:                assertFalse("".equals(document));
217:                assertEquals(
218:                        "body<span wicket:id=\"myLabel2\">Test Label2</span>",
219:                        document);
220:
221:                label = (Label) page.get("test:myLabel2");
222:                assertNotNull(label);
223:                tester.processRequestCycle(label);
224:                document = tester.getServletResponse().getDocument();
225:                assertNotNull(document);
226:                assertFalse("".equals(document));
227:                assertEquals("<span wicket:id=\"myLabel2\">Test Label2</span>",
228:                        document);
229:            }
230:
231:            /**
232:             * @throws Exception
233:             */
234:            public void testRenderHomePage_2b() throws Exception {
235:                // Render the component without having rendered the page previously
236:                SimplePage page = new SimplePage();
237:
238:                Label label = (Label) page.get("myLabel");
239:                assertNotNull(label);
240:                ValueMap attr = label.getMarkupAttributes();
241:                assertNotNull(attr);
242:                assertEquals("myLabel", attr.getString("wicket:id"));
243:
244:                Panel panel = (Panel) page.get("myPanel");
245:                assertNotNull(panel);
246:                attr = panel.getMarkupAttributes();
247:                assertNotNull(attr);
248:                assertEquals("myPanel", attr.getString("wicket:id"));
249:
250:                label = (Label) page.get("myPanel:label");
251:                assertNotNull(label);
252:                attr = label.getMarkupAttributes();
253:                assertNotNull(attr);
254:                assertEquals("label", attr.getString("wicket:id"));
255:
256:                Border border = (Border) page.get("myBorder");
257:                assertNotNull(border);
258:                attr = border.getMarkupAttributes();
259:                assertNotNull(attr);
260:                assertEquals("myBorder", attr.getString("wicket:id"));
261:
262:                border = (Border) page.get("myBorder2");
263:                assertNotNull(border);
264:                attr = border.getMarkupAttributes();
265:                assertNotNull(attr);
266:                assertEquals("myBorder2", attr.getString("wicket:id"));
267:
268:                // do the same test twice. Igor reported a problem with that, so we have to test it.
269:                border = (Border) page.get("myBorder2");
270:                assertNotNull(border);
271:                attr = border.getMarkupAttributes();
272:                assertNotNull(attr);
273:                assertEquals("myBorder2", attr.getString("wicket:id"));
274:
275:                WebMarkupContainer container = (WebMarkupContainer) page
276:                        .get("test");
277:                assertNotNull(container);
278:                attr = container.getMarkupAttributes();
279:                assertNotNull(attr);
280:                assertEquals("test", attr.getString("wicket:id"));
281:
282:                label = (Label) page.get("test:myLabel2");
283:                assertNotNull(label);
284:                attr = label.getMarkupAttributes();
285:                assertNotNull(attr);
286:                assertEquals("myLabel2", attr.getString("wicket:id"));
287:            }
288:
289:            /**
290:             * @throws Exception
291:             */
292:            public void testRenderHomePage_3() throws Exception {
293:                executeTest(SimplePage_3.class,
294:                        "SimplePageExpectedResult_3.html");
295:            }
296:
297:            /**
298:             * @throws Exception
299:             */
300:            public void testRenderHomePage_4() throws Exception {
301:                boolean hit = false;
302:                try {
303:                    executeTest(SimplePage_4.class,
304:                            "SimplePageExpectedResult_4.html");
305:                } catch (MarkupException mex) {
306:                    hit = true;
307:
308:                    assertNotNull(mex.getMarkupStream());
309:                    assertTrue(mex.getMessage().indexOf("<span>") != -1);
310:                    assertTrue(mex.getMessage().indexOf("SimplePage_4.html") != -1);
311:                }
312:                assertTrue("Did expect a MarkupException", hit);
313:            }
314:
315:            /**
316:             * @throws Exception
317:             */
318:            public void testRenderHomePage_5() throws Exception {
319:                boolean hit = false;
320:                try {
321:                    executeTest(SimplePage_5.class,
322:                            "SimplePageExpectedResult_5.html");
323:                } catch (WicketRuntimeException ex) {
324:                    if ((ex.getCause() != null)
325:                            && (ex.getCause() instanceof  MarkupNotFoundException)) {
326:                        hit = true;
327:                    }
328:                }
329:                assertTrue("Did expect a MarkupNotFoundException", hit);
330:            }
331:
332:            /**
333:             * @throws Exception
334:             */
335:            public void testRenderHomePage_6() throws Exception {
336:                boolean hit = false;
337:                try {
338:                    executeTest(SimplePage_6.class,
339:                            "SimplePageExpectedResult_6.html");
340:                } catch (MarkupException ex) {
341:                    hit = true;
342:                }
343:                assertTrue("Did expect a MarkupException", hit);
344:            }
345:
346:            /**
347:             * @throws Exception
348:             */
349:            public void testRenderHomePage_7() throws Exception {
350:                // This is for issue https://issues.apache.org/jira/browse/WICKET-590
351:                executeTest(SimplePage_7.class,
352:                        "SimplePageExpectedResult_7.html");
353:            }
354:
355:            /**
356:             * @throws Exception
357:             */
358:            public void testRenderHomePage_8() throws Exception {
359:                boolean hit = false;
360:                try {
361:                    executeTest(SimplePage_8.class,
362:                            "SimplePageExpectedResult_8.html");
363:                } catch (MarkupException ex) {
364:                    hit = true;
365:                }
366:                assertTrue("Did expect a MarkupException", hit);
367:            }
368:
369:            /**
370:             * @throws Exception
371:             */
372:            public void testRenderHomePage_9() throws Exception {
373:                executeTest(SimplePage_9.class,
374:                        "SimplePageExpectedResult_9.html");
375:            }
376:
377:            /**
378:             * @throws Exception
379:             */
380:            public void testRenderHomePage_10() throws Exception {
381:                executeTest(SimplePage_10.class,
382:                        "SimplePageExpectedResult_10.html");
383:
384:                Panel panel = (Panel) tester.getLastRenderedPage().get(
385:                        "myPanel");
386:                assertNotNull(panel);
387:                // we need to setup request/response before calling setvisible
388:                tester.setupRequestAndResponse();
389:                tester.createRequestCycle();
390:
391:                panel.setVisible(true);
392:                tester.processRequestCycle(panel);
393:                String document = tester.getServletResponse().getDocument();
394:                assertNotNull(document);
395:                assertEquals(
396:                        "<wicket:panel>Inside the panel<span wicket:id=\"label\">mein Label</span></wicket:panel>",
397:                        document);
398:            }
399:
400:            /**
401:             * @throws Exception
402:             */
403:            public void testRenderHomePage_11() throws Exception {
404:                executeTest(SimplePage_11.class,
405:                        "SimplePageExpectedResult_11.html");
406:            }
407:
408:            /**
409:             * @throws Exception
410:             */
411:            public void testRenderHomePage_12() throws Exception {
412:                executeTest(SimplePage_12.class,
413:                        "SimplePageExpectedResult_12.html");
414:            }
415:
416:            /**
417:             * @throws Exception
418:             */
419:            public void testRenderHomePage_13() throws Exception {
420:                executeTest(SimplePage_13.class,
421:                        "SimplePageExpectedResult_13.html");
422:            }
423:
424:            /**
425:             * @throws Exception
426:             */
427:            public void testRenderHomePage_14() throws Exception {
428:                executeTest(SimplePage_14.class,
429:                        "SimplePageExpectedResult_14.html");
430:            }
431:
432:            /**
433:             * @throws Exception
434:             */
435:            public void testRenderHomePage_15() throws Exception {
436:                executeTest(SimplePage_15.class,
437:                        "SimplePageExpectedResult_15.html");
438:            }
439:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.