1 15 package org.apache.tapestry.test; 16 17 import java.util.Arrays ; 18 19 import org.apache.hivemind.test.HiveMindTestCase; 20 21 27 public class TestRequestDescriptor extends HiveMindTestCase 28 { 29 private static class Assertion implements ResponseAssertion 30 { 31 private boolean _executed; 32 33 public void execute(ScriptedTestSession session) 34 { 35 _executed = true; 36 } 37 38 boolean getExecuted() 39 { 40 return _executed; 41 } 42 } 43 44 public void testAdd() 45 { 46 RequestDescriptor d = new RequestDescriptor(); 47 48 d.addParameter("frank", "burns"); 49 50 assertListsEqual(new String [] 51 { "burns" }, d.getParameterValues("frank")); 52 } 53 54 public void testGetNames() 55 { 56 RequestDescriptor d = new RequestDescriptor(); 57 58 assertListsEqual(new Object [0], d.getParameterNames()); 59 60 d.addParameter("flintstone", "fred"); 61 d.addParameter("rubble", "barney"); 62 63 String [] names = d.getParameterNames(); 64 65 67 Arrays.sort(names); 68 69 assertListsEqual(new String [] 70 { "flintstone", "rubble" }, names); 71 } 72 73 public void testAddMultiple() 74 { 75 RequestDescriptor d = new RequestDescriptor(); 76 77 d.addParameter("flintstone", "fred"); 78 d.addParameter("flintstone", "wilma"); 79 d.addParameter("flintstone", "dino"); 80 81 assertListsEqual(new String [] 82 { "fred", "wilma", "dino" }, d.getParameterValues("flintstone")); 83 } 84 85 public void testGetUnknown() 86 { 87 RequestDescriptor d = new RequestDescriptor(); 88 89 assertNull(d.getParameterValues("unknown")); 90 } 91 92 public void testServletName() 93 { 94 RequestDescriptor d = new RequestDescriptor(); 95 96 assertNull(d.getServletName()); 97 98 d.setServletName("servlet"); 99 100 assertEquals("servlet", d.getServletName()); 101 } 102 103 public void testExecuteAssertions() 104 { 105 RequestDescriptor d = new RequestDescriptor(); 106 107 Assertion a1 = new Assertion(); 108 Assertion a2 = new Assertion(); 109 110 d.addAssertion(a1); 111 d.addAssertion(a2); 112 113 d.executeAssertions(null); 114 115 assertEquals(true, a1.getExecuted()); 116 assertEquals(true, a2.getExecuted()); 117 } 118 119 } | Popular Tags |