1 16 17 package org.apache.tester; 18 19 20 import java.io.*; 21 import java.util.Map ; 22 import javax.servlet.*; 23 import javax.servlet.http.*; 24 25 32 33 public class GetParameterMap00 extends GenericServlet { 34 35 public void service(ServletRequest request, ServletResponse response) 36 throws IOException, ServletException { 37 38 response.setContentType("text/plain"); 39 PrintWriter writer = response.getWriter(); 40 String errors = ""; 41 Map map = request.getParameterMap(); 42 if (map == null) 43 errors += " getParameterMap() returned null."; 44 else { 45 if (map.size() != 2) 46 errors += " map size is " + map.size() + "."; 47 String value1[] = (String []) map.get("BestLanguage"); 48 if (value1 == null) 49 errors += " BestLanguage is NULL."; 50 else if (value1.length != 1) 51 errors += " BestLanguage has " + value1.length + " values."; 52 else if (!value1[0].equals("Java")) 53 errors += " BestLanguage is " + value1 + "."; 54 String value2[] = (String []) map.get("BestJSP"); 55 if (value2 == null) 56 errors += " BestJSP is NULL."; 57 else if (value2.length != 1) 58 errors += " BestJSP has " + value2.length + " values."; 59 else if (!value2[0].equals("Java2")) 60 errors += " BestJSP is " + value2 + "."; 61 try { 62 map.put("ABC", "XYZ"); 63 errors += " map.put() was allowed."; 64 if (map.get("ABC") != null) 65 errors += " map is not immutable."; 66 } catch (Throwable t) { 67 ; 68 } 69 } 70 71 if (errors.equals("")) 72 writer.println("GetParameterMap00 PASSED"); 73 else { 74 writer.println("GetParameterMap00 FAILED:" + errors); 75 } 76 while (true) { 77 String message = StaticLogger.read(); 78 if (message == null) 79 break; 80 writer.println(message); 81 } 82 StaticLogger.reset(); 83 84 } 85 86 } 87 | Popular Tags |