1 7 package com.inversoft.verge.mvc.controller.test; 8 9 10 import com.inversoft.junit.WebTestCase; 11 import com.inversoft.verge.mvc.MVCException; 12 import com.inversoft.verge.mvc.controller.DefaultLongTxnHandler; 13 import com.inversoft.verge.mvc.controller.GenericResult; 14 15 16 23 public class DefaultLongTxnHandlerTest extends WebTestCase { 24 25 28 public DefaultLongTxnHandlerTest(String name) { 29 super(name); 30 setLocal(true); 31 } 32 33 34 37 public void testStartURL() { 38 DefaultLongTxnHandler h = new DefaultLongTxnHandler(); 39 try { 40 h.handleStartLongTxn(request, response, "/testURL"); 41 assertEquals("/testURL", getRequest().getRequestDispatcher().getURL()); 42 assertFalse(getRequest().getRequestDispatcher().isForwarded()); 43 assertTrue(getRequest().getRequestDispatcher().isIncluded()); 44 } catch (MVCException mvce) { 45 fail(mvce.toString()); 46 } 47 } 48 49 52 public void testStartNoURL() { 53 DefaultLongTxnHandler h = new DefaultLongTxnHandler(); 54 try { 55 h.handleStartLongTxn(request, response, null); 56 assertNull(getRequest().getRequestDispatcher()); 57 } catch (MVCException mvce) { 58 fail(mvce.toString()); 59 } 60 } 61 62 65 public void testEndURL() { 66 DefaultLongTxnHandler h = new DefaultLongTxnHandler(); 67 GenericResult r = new GenericResult("/testDoneURL", null, true); 68 try { 69 h.handleEndLongTxn(request, response, "/testURL", r); 70 assertEquals("/testURL", getRequest().getRequestDispatcher().getURL()); 71 assertFalse(getRequest().getRequestDispatcher().isForwarded()); 72 assertTrue(getRequest().getRequestDispatcher().isIncluded()); 73 assertSame(r, request.getAttribute(DefaultLongTxnHandler.RESULT_PARAMETER)); 74 } catch (MVCException mvce) { 75 fail(mvce.toString()); 76 } 77 } 78 79 82 public void testEndNoURL() { 83 DefaultLongTxnHandler h = new DefaultLongTxnHandler(); 84 GenericResult r = new GenericResult("/testDoneURL", null, true); 85 try { 86 h.handleEndLongTxn(request, response, null, r); 87 assertNull(getRequest().getRequestDispatcher()); 88 assertEquals("<head><meta http-equiv='REFRESH' content='0;url=/testDoneURL'/></head></html>", 89 getResponse().getText()); 90 } catch (MVCException mvce) { 91 fail(mvce.toString()); 92 } 93 } 94 95 99 public void testEndNoURLEncode() { 100 getResponse().setEncode(true); 101 102 DefaultLongTxnHandler h = new DefaultLongTxnHandler(); 103 GenericResult r = new GenericResult("/testDoneURL", null, true); 104 try { 105 h.handleEndLongTxn(request, response, null, r); 106 assertNull(getRequest().getRequestDispatcher()); 107 assertEquals("<head><meta http-equiv='REFRESH' content='0;url=/testDoneURL#encodeRedirect'/></head></html>", 108 getResponse().getText()); 109 } catch (MVCException mvce) { 110 fail(mvce.toString()); 111 } 112 } 113 } | Popular Tags |