KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > servletunit > FilterChainSimulator


1 // StrutsTestCase - a JUnit extension for testing Struts actions
2
// within the context of the ActionServlet.
3
// Copyright (C) 2002 Deryl Seale
4
//
5
// This library is free software; you can redistribute it and/or
6
// modify it under the terms of the Apache Software License as
7
// published by the Apache Software Foundation; either version 1.1
8
// of the License, or (at your option) any later version.
9
//
10
// This library 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
// Apache Software Foundation Licens for more details.
14
//
15
// You may view the full text here: http://www.apache.org/LICENSE.txt
16

17 package servletunit;
18
19 import javax.servlet.FilterChain JavaDoc;
20 import javax.servlet.ServletRequest JavaDoc;
21 import javax.servlet.ServletResponse JavaDoc;
22
23 /**
24  * A unit testing tool for simulating a FilterChain <p>
25  *
26  *
27  * @author Sean Pritchard
28  * May 11, 2002
29  * @version 1.0
30  */

31
32 public class FilterChainSimulator implements FilterChain JavaDoc {
33
34     private ServletRequest JavaDoc request = null;
35     private ServletResponse JavaDoc response = null;
36     private boolean doFilterCalled = false;
37
38
39     /**
40      * Constructor for the FilterChainSimulator object
41      */

42     public FilterChainSimulator() { }
43
44
45     /**
46      * Description of the Method
47      *
48      * @param parm1 The request
49      * @param parm2 The response
50      * @exception javax.servlet.ServletException
51      * @exception java.io.IOException Description of the Exception
52      */

53     public void doFilter(ServletRequest JavaDoc parm1, ServletResponse JavaDoc parm2) throws javax.servlet.ServletException JavaDoc, java.io.IOException JavaDoc {
54         request = parm1;
55         response = parm2;
56         doFilterCalled = true;
57     }
58
59
60     /**
61      * Gets the request passed in as a parameter of the doFilter call.
62      *
63      * @return The request value
64      */

65     public ServletRequest JavaDoc getRequest() {
66         return request;
67     }
68
69
70     /**
71      * * Gets the response passed in as a parameter of the doFilter call.
72      *
73      * @return The response value
74      */

75     public ServletResponse JavaDoc getResponse() {
76         return response;
77     }
78
79
80     /**
81      * Indicates whether doFilter has been called.
82      *
83      * @return true if doFilter has been called
84      */

85     public boolean doFilterCalled() {
86         return doFilterCalled;
87     }
88 }
89
Popular Tags