01: /*
02: * (C) Janne Jalkanen 2005
03: *
04: */
05: package com.ecyrd.jspwiki.ui;
06:
07: import junit.framework.Test;
08: import junit.framework.TestCase;
09: import junit.framework.TestSuite;
10:
11: public class RedirectCommandTest extends TestCase {
12: protected void tearDown() throws Exception {
13: }
14:
15: public void testStaticCommand() {
16: Command a = RedirectCommand.REDIRECT;
17: assertEquals("", a.getRequestContext());
18: assertEquals("", a.getJSP());
19: assertEquals("%u%n", a.getURLPattern());
20: assertNull(a.getContentTemplate());
21: assertNull(a.getTarget());
22: assertEquals(a, RedirectCommand.REDIRECT);
23: }
24:
25: public void testTargetedCommand() {
26: Command a = RedirectCommand.REDIRECT;
27:
28: // Test with local JSP
29: Command b = a.targetedCommand("%uTestPage.jsp");
30: assertEquals("", b.getRequestContext());
31: assertEquals("TestPage.jsp", b.getJSP());
32: assertEquals("%uTestPage.jsp", b.getURLPattern());
33: assertNull(b.getContentTemplate());
34: assertEquals("%uTestPage.jsp", b.getTarget());
35: assertNotSame(RedirectCommand.REDIRECT, b);
36:
37: // Test with non-local URL
38: b = a.targetedCommand("http://www.yahoo.com");
39: assertEquals("", b.getRequestContext());
40: assertEquals("http://www.yahoo.com", b.getJSP());
41: assertEquals("http://www.yahoo.com", b.getURLPattern());
42: assertNull(b.getContentTemplate());
43: assertEquals("http://www.yahoo.com", b.getTarget());
44: assertNotSame(RedirectCommand.REDIRECT, b);
45: }
46:
47: public static Test suite() {
48: return new TestSuite(RedirectCommandTest.class);
49: }
50: }
|