001: package wicket.session;
002:
003: import wicket.AbstractRestartResponseException;
004: import wicket.IPageFactory;
005: import wicket.Page;
006: import wicket.PageParameters;
007: import wicket.WicketTestCase;
008:
009: /**
010: * Default page facotry tests
011: *
012: * @author ivaynberg
013: */
014: public class DefaultPageFactoryTest extends WicketTestCase {
015: /**
016: * @author ivaynberg
017: */
018: public static class AbortAndRespondPage1 extends Page {
019: private static final long serialVersionUID = 1L;
020:
021: /**
022: * Construct.
023: */
024: public AbortAndRespondPage1() {
025: throw new AbstractRestartResponseException() {
026:
027: /**
028: *
029: */
030: private static final long serialVersionUID = 1L;
031:
032: };
033: }
034: }
035:
036: /**
037: * @author ivaynberg
038: */
039: public static class AbortAndRespondPage2 extends Page {
040: private static final long serialVersionUID = 1L;
041:
042: /**
043: * Construct.
044: *
045: * @param params
046: */
047: public AbortAndRespondPage2(PageParameters params) {
048: throw new AbstractRestartResponseException() {
049:
050: /**
051: *
052: */
053: private static final long serialVersionUID = 1L;
054:
055: };
056: }
057:
058: }
059:
060: /**
061: * @author ivaynberg
062: */
063: public static class AbortAndRespondPage3 extends Page {
064: private static final long serialVersionUID = 1L;
065:
066: /**
067: * Construct.
068: */
069: public AbortAndRespondPage3() {
070: throw new AbstractRestartResponseException() {
071:
072: /**
073: *
074: */
075: private static final long serialVersionUID = 1L;
076:
077: };
078: }
079:
080: /**
081: * Construct.
082: *
083: * @param params
084: */
085: public AbortAndRespondPage3(PageParameters params) {
086: throw new AbstractRestartResponseException() {
087:
088: /**
089: *
090: */
091: private static final long serialVersionUID = 1L;
092:
093: };
094: }
095:
096: }
097:
098: final private IPageFactory pageFactory = new DefaultPageFactory();
099:
100: /**
101: * Construct.
102: *
103: * @param name
104: */
105: public DefaultPageFactoryTest(String name) {
106: super (name);
107: }
108:
109: /**
110: * Verifies page factory bubbles AbortAndRespondException
111: */
112: public void testAbortAndRespondContract() {
113: try {
114: application.setupRequestAndResponse();
115: application.createRequestCycle();
116: pageFactory.newPage(AbortAndRespondPage1.class);
117: fail();
118: } catch (AbstractRestartResponseException e) {
119: // noop
120: }
121:
122: try {
123: pageFactory.newPage(AbortAndRespondPage2.class);
124: fail();
125: } catch (AbstractRestartResponseException e) {
126: // noop
127: }
128:
129: try {
130: pageFactory.newPage(AbortAndRespondPage2.class,
131: new PageParameters());
132: fail();
133: } catch (AbstractRestartResponseException e) {
134: // noop
135: }
136:
137: try {
138: pageFactory.newPage(AbortAndRespondPage3.class);
139: fail();
140: } catch (AbstractRestartResponseException e) {
141: // noop
142: }
143:
144: try {
145: pageFactory.newPage(AbortAndRespondPage3.class,
146: new PageParameters());
147: fail();
148: } catch (AbstractRestartResponseException e) {
149: // noop
150: }
151: }
152: }
|