Skip to content

Commit

Permalink
*** empty log message ***
Browse files Browse the repository at this point in the history
  • Loading branch information
aibba committed Aug 7, 2003
1 parent d31cf8e commit 75bc383
Show file tree
Hide file tree
Showing 12 changed files with 86 additions and 52 deletions.
2 changes: 0 additions & 2 deletions LICENSE-jdom.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/*--

$Id: LICENSE-jdom.txt,v 1.1 2003/08/04 13:40:30 aibba Exp $

Copyright (C) 2000-2003 Jason Hunter & Brett McLaughlin.
All rights reserved.

Expand Down
49 changes: 19 additions & 30 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* ====================================================================
* The Apache Software License, Version 1.1
* Mockrunner Software License, Version 1.1
* based on Apache Software License, version 1.1.
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
* Copyright (c) 2003 Alwin Ibba. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
Expand All @@ -18,42 +18,31 @@
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* "This product includes software developed by Alwin Ibba."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [email protected].
* 4. The name "Mockrunner" must not be used to endorse or promote
* products derived from this software without prior written
* permission. For written permission, please contact
* alwin.ibba AT mockrunner.com
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
* 5. Products derived from this software may not be called "Mockrunner",
* nor may "Mockrunner" appear in their name, without prior written
* permission of the author.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* Portions of this software are based upon public domain software
* originally written at the National Center for Supercomputing Applications,
* University of Illinois, Urbana-Champaign.
*/


2 changes: 1 addition & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<tstamp/>

<property name="version" value="0.2"/>
<property name="version" value="0.1.5"/>
<property name="timestamp" value="${DSTAMP}-${TSTAMP}"/>

<property name="build" value="build"/>
Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,5 @@ nekohtml.jar

For suggestions, remarks or questions you can use the forums on
Sourceforge (http://sourceforge.net/projects/mockrunner/) or
write me an email (alwin.ibba@mockrunner.com).
write me an email (alwin.ibba AT mockrunner.com).

7 changes: 5 additions & 2 deletions releasenotes.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

mockrunner-0.2:
mockrunner-0.1.5:

- reorganized package structure. ActionTestModule and
ActionTestCaseAdapter are in com.mockrunner.struts
Expand All @@ -8,8 +8,11 @@ mockrunner-0.2:
- improved the TagTestModule. It supports nested tag and
is able to perform the tag lifecycle as in the real
container.
- added ServletTestModule with servlet and filter support
- implemented parsing of HTML output
- added some useful methods to ActionTestModule
- added third party jars to release
- added third party jars to release (except for the big
Xerces and Struts jars)

mockrunner-0.1:

Expand Down
13 changes: 13 additions & 0 deletions src/com/mockrunner/example/servlet/ImageButtonFilterTest.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
package com.mockrunner.example.servlet;

import javax.servlet.http.HttpServletRequest;

import com.mockrunner.mock.MockHttpServletRequest;
import com.mockrunner.servlet.ServletTestCaseAdapter;

/**
* Example test for the {@link ImageButtonFilter}.
* Demonstrates the usage of the filter test features in
* {@link com.mockrunner.servlet.ServletTestModule}
* resp. {@link com.mockrunner.servlet.ServletTestCaseAdapter}.
*/
public class ImageButtonFilterTest extends ServletTestCaseAdapter
{
private ImageButtonFilter filter;
Expand All @@ -21,5 +29,10 @@ public void testImageButtonParameter()
request.setupAddParameter("image.x", "123");
request.setupAddParameter("image.y", "456");
doFilter();
HttpServletRequest filteredRequest = (HttpServletRequest)getFilteredRequest();
assertEquals("value", filteredRequest.getParameter("param"));
assertEquals("123", filteredRequest.getParameter("image"));
assertNull(filteredRequest.getParameter("image.x"));
assertNull(filteredRequest.getParameter("image.y"));
}
}
2 changes: 1 addition & 1 deletion src/com/mockrunner/example/servlet/LogoutServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void doGet(HttpServletRequest request, HttpServletResponse response) thro
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
String logout = request.getParameter("logout");
if(null != logout && logout.equals("true"))
if(null != logout)
{
request.getSession().invalidate();
request.getRequestDispatcher("/html/goodbye.html").forward(request, response);
Expand Down
18 changes: 12 additions & 6 deletions src/com/mockrunner/example/servlet/LogoutServletTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
/**
* Example test for {@link LogoutServlet}.
* Demonstrates the usage of {@link com.mockrunner.servlet.ServletTestModule}
* resp. {@link com.mockrunner.servlet.ServletTestCaseAdapter}.
* resp. {@link com.mockrunner.servlet.ServletTestCaseAdapter}
* with and without a filter.
*/
public class LogoutServletTest extends ServletTestCaseAdapter
{
Expand All @@ -15,16 +16,21 @@ protected void setUp() throws Exception
createServlet(LogoutServlet.class);
}

public void testDoNoLogout() throws Exception
public void testDoLogout() throws Exception
{
getMockObjectFactory().getMockRequest().setupAddParameter("logout", "false");
getMockObjectFactory().getMockRequest().setupAddParameter("logout", "true");
doPost();
assertTrue(getMockObjectFactory().getMockSession().isValid());
assertFalse(getMockObjectFactory().getMockSession().isValid());
}

public void testDoLogout() throws Exception
public void testDoLogoutWithFilteredImageButton() throws Exception
{
getMockObjectFactory().getMockRequest().setupAddParameter("logout", "true");
getMockObjectFactory().getMockRequest().setupAddParameter("logout.x", "11");
getMockObjectFactory().getMockRequest().setupAddParameter("logout.y", "11");
doPost();
assertTrue(getMockObjectFactory().getMockSession().isValid());
createFilter(ImageButtonFilter.class);
setDoChain(true);
doPost();
assertFalse(getMockObjectFactory().getMockSession().isValid());
}
Expand Down
4 changes: 2 additions & 2 deletions src/com/mockrunner/servlet/ServletTestModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public void service()
* Returns the last request from the filter chain. Since
* filters can replace the request with a request wrapper,
* this method makes only sense after calling at least
* one filter, e.g. after calling {@link #doFilter} or
* one filter, i.e. after calling {@link #doFilter} or
* after calling one servlet method with <i>doChain</i>
* set to <code>true</code>.
* @return the filtered request
Expand All @@ -270,7 +270,7 @@ public ServletRequest getFilteredRequest()
* Returns the last resposne from the filter chain. Since
* filters can replace the resposne with a resposne wrapper,
* this method makes only sense after calling at least
* one filter, e.g. after calling {@link #doFilter} or
* one filter, i.e. after calling {@link #doFilter} or
* after calling one servlet method with <i>doChain</i>
* set to <code>true</code>.
* @return the filtered resposne
Expand Down
2 changes: 1 addition & 1 deletion src/com/mockrunner/tag/TagTestModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ public void clearOutput()

/**
* Gets the output data the current tag has rendered. Makes only sense
* after calling at least [@link #doStartTag} or [@link #processTagLifecycle}
* after calling at least {@link #doStartTag} or {@link #processTagLifecycle}
* @return the output data
*/
public String getOutput()
Expand Down
2 changes: 2 additions & 0 deletions src/com/mockrunner/test/AllTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import junit.framework.Test;
import junit.framework.TestSuite;

import com.mockrunner.example.servlet.ImageButtonFilterTest;
import com.mockrunner.example.servlet.LogoutServletTest;
import com.mockrunner.example.servlet.RedirectServletTest;
import com.mockrunner.example.struts.AuthenticationActionTest;
Expand Down Expand Up @@ -34,6 +35,7 @@ public static Test suite()
suite.addTest(new TestSuite(AuthenticationActionTest.class));
suite.addTest(new TestSuite(StoreDataActionTest.class));
suite.addTest(new TestSuite(OrderActionTest.class));
suite.addTest(new TestSuite(ImageButtonFilterTest.class));
//$JUnit-END$
return suite;
}
Expand Down
35 changes: 29 additions & 6 deletions src/com/mockrunner/util/XmlUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.jdom.Element;
import org.jdom.input.DOMBuilder;
import org.jdom.output.XMLOutputter;
import org.w3c.dom.ls.DOMInput;
import org.xml.sax.InputSource;

/**
Expand Down Expand Up @@ -112,7 +113,7 @@ public static DOMParser getHTMLParser()
* Parses the specified HTML with the NekoHTML parser.
* If you want to use another HTML parser or configure
* the NekoHTML parser with special features, you can use
* the {@link #parse} method.
* the <code>parse</code> methods.
* @param source the HTML as String
* @return the parsed document as org.w3c.dom.Document
*/
Expand All @@ -131,11 +132,13 @@ public static org.w3c.dom.Document parseHTML(String source)

/**
* Parses the specified XML with the specified parser.
* The main purpose of this method is to use a custom
* HTML parser. If you can live with the NekoHTML parser
* and its default features, you can use {@link #parseHTML}.
* @param parser the <code>DOMParser</code>, e.g. the one
* returned by {@link #getHTMLParser}
* The main purpose of this method is to use the NekoHTML
* parser with custom features and properties. If you can live
* with the settings provided by Mockrunner, you can use
* {@link #parseHTML}.
* @param parser the parser (must extend
* <code>org.apache.xerces.parsers.DOMParser</code>),
* e.g. the one returned by {@link #getHTMLParser}
* @param source the XML as String
* @return the parsed document as org.w3c.dom.Document
*/
Expand All @@ -152,4 +155,24 @@ public static org.w3c.dom.Document parse(DOMParser parser, String source)
throw new RuntimeException(exc.getMessage());
}
}

/**
* Parses the specified XML with the specified parser.
* The main purpose of this method is to use a custom parser.
* @param parser the parser
* @param data the data as <code>DOMInput</code>
* @return the parsed document as org.w3c.dom.Document
*/
public static org.w3c.dom.Document parse(org.w3c.dom.ls.DOMParser parser, DOMInput data)
{
try
{
return parser.parse(data);
}
catch(Exception exc)
{
exc.printStackTrace();
throw new RuntimeException(exc.getMessage());
}
}
}

0 comments on commit 75bc383

Please sign in to comment.