KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > displaytag > jsptests > DisabledMediaTest


1 package org.displaytag.jsptests;
2
3 import org.apache.log4j.Level;
4 import org.apache.log4j.Logger;
5 import org.displaytag.tags.ColumnTag;
6 import org.displaytag.test.DisplaytagCase;
7
8 import com.meterware.httpunit.GetMethodWebRequest;
9 import com.meterware.httpunit.HttpInternalErrorException;
10 import com.meterware.httpunit.WebRequest;
11
12
13 /**
14  * Test for #968559.
15  * @author Fabrizio Giustina
16  * @version $Revision: 707 $ ($Author: fgiust $)
17  */

18 public class DisabledMediaTest extends DisplaytagCase
19 {
20
21     /**
22      * @see org.displaytag.test.DisplaytagCase#getJspName()
23      */

24     public String JavaDoc getJspName()
25     {
26         return "disabledmedia.jsp";
27     }
28
29     /**
30      * Should not break on media="foo", since foo could be a valid media not enabled at runtime.
31      * @param jspName jsp name, with full path
32      * @throws Exception any axception thrown during test.
33      */

34     public void doTest(String JavaDoc jspName) throws Exception JavaDoc
35     {
36         // test keep
37
WebRequest request = new GetMethodWebRequest(jspName);
38
39         // save previous level, since we are expeting an excetion I don't want to fill logs
40
Level previousLevel = Logger.getLogger(ColumnTag.class).getLevel();
41         Logger.getLogger(ColumnTag.class).setLevel(Level.OFF);
42
43         try
44         {
45             runner.getResponse(request);
46         }
47         catch (HttpInternalErrorException e)
48         {
49             fail("Should not get any error also if \"foo\" media type is not defined. " + e.getMessage());
50         }
51         finally
52         {
53             Logger.getLogger(ColumnTag.class).setLevel(previousLevel);
54         }
55
56         // ok
57

58     }
59
60 }
Popular Tags