Provides a mock container for testing Click Pages.
Use the {@link #start()} and {@link #stop()} methods to control the life cycleof the container. Each call to
start / stop instantiates new mock instances for the container.
To instantiate a container you must specify a web application directory where your page templates and other resources like images, javascript and stylesheets are available.
You can set the
web application root to refer to your actual live project's web directory.
For example if you are busy developing a web application located under
'c:\dev\myapp\web', you can start the MockContainerTest as follows:
public class MyTest extends junit.framework.TestCase { public void testMyPage() { MockContainer container = new MockContainer("c:/dev/myapp/web"); container.start(); container.setParameter("param", "one"); MyPage page = (MyPage) container.testPage(MyPage.class); Assert.assertEquals("one", page.getParam()); container.stop(); } }
Together with a valid web application directory you also need to have the click.xml available, either in the WEB-INF/click.xml directory or on your classpath.
Taking the above example further, if your application is developed under
'c:\dev\myapp\web', click.xml would be available at
'WEB-INF\click.xml'. The full path would be
'c:\dev\myapp\web\WEB-INF\click.xml'.
Alternatively click.xml can also be specified on the classpath. For example you can save click.xml in your
src folder eg:
'c:\dev\myapp\web\src\click.xml'. Below is an example click.xml to get up and running quickly:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <click-app charset="UTF-8"> <pages package="com.mycorp.pages"/> <mode value="trace"/> </click-app>