1 20 package org.apache.cactus.sample.servlet.unit; 21 22 import org.apache.cactus.ServletTestCase; 23 import org.apache.cactus.WebRequest; 24 25 30 public class TestHttpParameters extends ServletTestCase 31 { 32 39 public void beginMultiValueParameters(WebRequest theRequest) 40 { 41 theRequest.addParameter("multivalue", "value 1"); 42 theRequest.addParameter("multivalue", "value 2"); 43 } 44 45 49 public void testMultiValueParameters() 50 { 51 String [] values = request.getParameterValues("multivalue"); 52 53 if (values[0].equals("value 1")) 54 { 55 assertEquals("value 2", values[1]); 56 } 57 else if (values[0].equals("value 2")) 58 { 59 assertEquals("value 1", values[1]); 60 } 61 else 62 { 63 fail("Shoud have returned a vector with the " 64 + "values \"value 1\" and \"value 2\""); 65 } 66 } 67 68 70 76 public void beginSeveralParameters(WebRequest theRequest) 77 { 78 theRequest.addParameter("PostParameter1", "EMPLOYEE0145", 79 WebRequest.POST_METHOD); 80 theRequest.addParameter("PostParameter2", "W", WebRequest.GET_METHOD); 81 theRequest.addParameter("PostParameter3", "07/08/2002", 82 WebRequest.POST_METHOD); 83 theRequest.addParameter("PostParameter4", "/tas/ViewSchedule.esp", 84 WebRequest.GET_METHOD); 85 } 86 87 90 public void testSeveralParameters() 91 { 92 assertEquals("parameter4", "/tas/ViewSchedule.esp", 93 request.getParameter("PostParameter4")); 94 assertEquals("parameter1", "EMPLOYEE0145", 95 request.getParameter("PostParameter1")); 96 assertEquals("parameter2", "W", request.getParameter("PostParameter2")); 97 assertEquals("parameter3", "07/08/2002", 98 request.getParameter("PostParameter3")); 99 } 100 101 } 102 | Popular Tags |