source: trunk/autoquest-httpmonitor-test/src/test/java/de/ugoe/cs/autoquest/httpmonitor/DummyServlet.java @ 1567

Last change on this file since 1567 was 1567, checked in by pharms, 10 years ago
  • next solved issue with reused buffers
File size: 2.9 KB
Line 
1//   Copyright 2012 Georg-August-Universität Göttingen, Germany
2//
3//   Licensed under the Apache License, Version 2.0 (the "License");
4//   you may not use this file except in compliance with the License.
5//   You may obtain a copy of the License at
6//
7//       http://www.apache.org/licenses/LICENSE-2.0
8//
9//   Unless required by applicable law or agreed to in writing, software
10//   distributed under the License is distributed on an "AS IS" BASIS,
11//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12//   See the License for the specific language governing permissions and
13//   limitations under the License.
14
15package de.ugoe.cs.autoquest.httpmonitor;
16
17import java.io.IOException;
18
19import javax.servlet.ServletException;
20import javax.servlet.http.HttpServlet;
21import javax.servlet.http.HttpServletRequest;
22import javax.servlet.http.HttpServletResponse;
23
24/**
25 * @author Patrick Harms
26 */
27class DummyServlet extends HttpServlet {
28
29    /**  */
30    private static final long serialVersionUID = 1L;
31   
32    /** */
33    private String requestMessage;
34   
35    /** */
36    private String responseMessage;
37
38    /* (non-Javadoc)
39     * @see org.mortbay.jetty.servlet.DefaultServlet#doGet(HttpServletRequest, HttpServletResponse)
40     */
41    @Override
42    protected void doGet(HttpServletRequest request, HttpServletResponse response)
43        throws ServletException, IOException
44    {
45        requestMessage = AbstractTC.readStreamContentToString(request.getInputStream());
46       
47        System.err.println("responding on get with:   " + responseMessage);
48        response.getOutputStream().write(responseMessage.getBytes());
49    }
50
51    /* (non-Javadoc)
52     * @see org.mortbay.jetty.servlet.DefaultServlet#doPost(HttpServletRequest, HttpServletResponse)
53     */
54    @Override
55    protected void doPost(HttpServletRequest request, HttpServletResponse response)
56        throws ServletException, IOException
57    {
58        requestMessage = AbstractTC.readStreamContentToString(request.getInputStream());
59       
60        System.err.println("responding on post with:  " + responseMessage);
61        response.getOutputStream().write(responseMessage.getBytes());
62    }
63
64    /* (non-Javadoc)
65     * @see org.mortbay.jetty.servlet.DefaultServlet#doTrace(HttpServletRequest, HttpServletResponse)
66     */
67    @Override
68    protected void doTrace(HttpServletRequest request, HttpServletResponse response)
69        throws ServletException, IOException
70    {
71        requestMessage = AbstractTC.readStreamContentToString(request.getInputStream());
72       
73        System.err.println("responding on trace with: " + responseMessage);
74        response.getOutputStream().write(responseMessage.getBytes());
75    }
76
77    /**
78     *
79     */
80    void setResponse(String responseMessage) {
81        this.responseMessage = responseMessage;
82    }
83
84    /**
85     *
86     */
87    String getRequest() {
88        return this.requestMessage;
89    }
90}
Note: See TracBrowser for help on using the repository browser.