1 package org.displaytag.jsptests; 2 3 import org.apache.commons.lang.StringUtils; 4 import org.displaytag.properties.MediaTypeEnum; 5 import org.displaytag.tags.TableTagParameters; 6 import org.displaytag.test.DisplaytagCase; 7 import org.displaytag.test.KnownValue; 8 import org.displaytag.util.ParamEncoder; 9 10 import com.meterware.httpunit.GetMethodWebRequest; 11 import com.meterware.httpunit.WebRequest; 12 import com.meterware.httpunit.WebResponse; 13 14 15 20 public class MediaSupportXmlTest extends DisplaytagCase 21 { 22 23 26 public String getJspName() 27 { 28 return "media.jsp"; 29 } 30 31 36 public void doTest(String jspName) throws Exception 37 { 38 39 ParamEncoder encoder = new ParamEncoder("table"); 40 String mediaParameter = encoder.encodeParameterName(TableTagParameters.PARAMETER_EXPORTTYPE); 41 42 WebRequest request = new GetMethodWebRequest(jspName); 43 request.setParameter(mediaParameter, "" + MediaTypeEnum.XML.getCode()); 44 45 WebResponse response = runner.getResponse(request); 46 47 if (log.isDebugEnabled()) 48 { 49 log.debug("RESPONSE: " + response.getText()); 50 } 51 52 assertEquals("Expected a different content type.", "text/xml", response.getContentType()); 54 55 String output = response.getText(); 56 57 assertTrue("Expected value [" + KnownValue.BEE + "] missing", StringUtils.contains(output, KnownValue.BEE)); 58 assertTrue("Expected value [" + KnownValue.CAMEL + "] missing", StringUtils.contains(output, KnownValue.CAMEL)); 59 assertTrue("Unexpected value [" + KnownValue.ANT + "] found", !StringUtils.contains(output, KnownValue.ANT)); 60 61 } 62 63 } | Popular Tags |