1 7 package com.inversoft.junit.internal; 8 9 10 import java.io.IOException ; 11 import java.util.Iterator ; 12 import java.util.Map ; 13 import java.util.Set ; 14 import javax.servlet.ServletException ; 15 import javax.servlet.RequestDispatcher ; 16 import javax.servlet.http.HttpServlet ; 17 import javax.servlet.http.HttpServletRequest ; 18 import javax.servlet.http.HttpServletResponse ; 19 20 21 29 public class HttpProxy extends HttpServlet { 30 31 34 public void doGet(HttpServletRequest request, HttpServletResponse response) 35 throws ServletException , IOException { 36 doPost(request, response); 37 } 38 39 56 public void doPost(HttpServletRequest request, HttpServletResponse response) 57 throws ServletException , IOException { 58 59 Map params = request.getParameterMap(); 60 Set keys = params.keySet(); 61 for (Iterator iterator = keys.iterator(); iterator.hasNext();) { 62 String key = (String ) iterator.next(); 63 System.out.print("-------------------------------- Parmeter [" + key + ", {"); 64 Object [] values = (Object []) params.get(key); 65 for (int i = 0; i < values.length; i++) { 66 Object value = values[i]; 67 System.out.print(value); 68 if (i < values.length - 1) { 69 System.out.print(","); 70 } 71 } 72 System.out.print("}]\n"); 73 } 74 75 RemoteMediator mediator = new RemoteMediator(); 76 try { 77 mediator.mediateServer(request, response); 78 } catch (Throwable t) { 79 if (t instanceof ServletException ) { 80 throw (ServletException ) t; 81 } 82 83 if (t instanceof IOException ) { 84 throw (IOException ) t; 85 } 86 87 throw new ServletException ("Error executing test on the server.", t); 88 } 89 } 90 } 91 | Popular Tags |