1 package org.displaytag.jsptests; 2 3 import java.util.HashSet; 4 import java.util.Set; 5 6 import org.displaytag.test.DisplaytagCase; 7 8 import com.meterware.httpunit.GetMethodWebRequest; 9 import com.meterware.httpunit.WebLink; 10 import com.meterware.httpunit.WebRequest; 11 import com.meterware.httpunit.WebResponse; 12 13 14 /** 15 * Tests for "media" attribute support. 16 * @author Fabrizio Giustina 17 * @version $Revision: 707 $ ($Author: fgiust $) 18 */ 19 public class ExportLinksTest extends DisplaytagCase 20 { 21 22 /** 23 * @see org.displaytag.test.DisplaytagCase#getJspName() 24 */ 25 public String getJspName() 26 { 27 return "media.jsp"; 28 } 29 30 /** 31 * Test that headers are correctly removed. 32 * @param jspName jsp name, with full path 33 * @throws Exception any axception thrown during test. 34 */ 35 public void doTest(String jspName) throws Exception 36 { 37 // test keep 38 WebRequest request = new GetMethodWebRequest(jspName); 39 WebResponse response = runner.getResponse(request); 40 41 WebLink[] links = response.getLinks(); 42 43 assertEquals("4 links were expected: csv, excel, xml, pdf.", 4, links.length); 44 45 Set linkTexts = new HashSet(); 46 for (int j = 0; j < links.length; j++) 47 { 48 String url = links[j].getURLString(); 49 log.debug(url); 50 if (linkTexts.contains(url)) 51 { 52 fail("Found duplicated link in export banner: " + url); 53 } 54 linkTexts.add(url); 55 } 56 57 } 58 59 }