1 /* Reattore HTTP Server
2
3 Copyright (C) 2002 Michael Hope <michaelh@juju.net.nz>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19 $Id: MockHttpRequest.java,v 1.7 2003/02/16 06:28:08 michaelh Exp $
20 */
21
22 package test.juju.reattore.core.intercept.impl;
23
24 import java.util.*;
25
26 import juju.reattore.protocol.http.HttpRequest;
27 import juju.reattore.io.ByteSource;
28
29 /*** Mock implementation of HttpRequest that serves static data.
30 */
31 public class MockHttpRequest
32 implements HttpRequest {
33
34 private String method;
35 private String path;
36 private String query = "";
37 private String originalPath;
38
39 private Map headers = new HashMap();
40
41 /*** Create a new mock request
42
43 @param method The method to return
44 @param path The path to return
45 */
46 public MockHttpRequest(String method, String path) {
47 this.method = method;
48 this.path = path;
49 this.originalPath = path;
50 }
51
52 public String getMethod() {
53 return method;
54 }
55
56 public String getPath() {
57 return path;
58 }
59
60 public String getQueryString() {
61 return query;
62 }
63
64 public ByteSource getBody() {
65 return null;
66 }
67
68 public int getNumHeaders() {
69 return 0;
70 }
71
72 public String getOriginalPath() {
73 return originalPath;
74 }
75
76 public String getVersion() {
77 return "";
78 }
79
80 public void changePath(String to) {
81 path = to;
82 }
83
84 public void addHeader(String name, String val) {
85 headers.put(name, val);
86 }
87
88 public String getHeader(String name) {
89 return (String)headers.get(name);
90 }
91
92 public Set getHeaders() {
93 return headers.entrySet();
94 }
95 }
This page was automatically generated by Maven