MatDeLong (2) [Avatar] Offline
Hey, I don't know if this is the best place to post a question related to Cactus and JSP Unit testing, but I'll try anyway!

I have the Cactus ant integration working, and cactus tasks successfully run. However, I can not successfully forward to a jsp page on my server. Here are my testXX and endXXX methods:

public void testConfig() throws Exception {
// Create a bean to be used on the forwarded page.
// Set properties on this bean to confirm that the form
// fields reference the correct bean properties.+
DirectoryBean bean = new DirectoryBean();
bean.setName("EMBT Cactus Test Name");
bean.setDescription("EMBT Cactus Test Description");

public void endConfig(WebResponse theResponse) throws SAXException, IOException {
WebTable[] tables = theResponse.getTables();
HashMap<String, WebTable> tableMap = new HashMap<String, WebTable>();

// Populate a hash map with all tables on page, with
// their identifiers as the key
// This is done so each table can be tested
// individually, but requires all tables
// on a given page to have unique identifiers.
for (int i = 0; i < tables.length; ++i) {
tableMap.put(tables[i].getID(), tables[i]);

//Evaluate a particular table, given its unique

WebTable table = tableMap.get("contentTable");
assertNotNull("Table is null", table);
assertEquals("Names not equal",
"EMBT Cactus Test Name",
assertEquals("Description not equal",
"EMBT Cactus Test Description",

The error I get is that the table comes up being null in the endXXX() method. I believe this is because the pageContext.forward does not successfully return the page.

Any advice would be greatly appreciated!


MatDeLong (2) [Avatar] Offline
Re: Cactus JspTestCase
I tried testing with a simple JSP page that was more just like HTML and it worked fine. I think my problem is because of the page itself and how it's formatted, so here is an example, so that maybe you can see where I'm going wrong with the testing:


<%@ include file="/html/portlet/administration/directory/init.jsp" %>

<f: view>
<f: loadBundle basename="resources/Language" var="messages"/>
<t: aliasBeansScope>
<t: aliasBean alias="#{portletBean}" value="#{administrationBean}" />
<t: aliasBean alias="#{currentPage}" value="#{adminDirectoryAddPage}" />

<tiles: insert page="/html/portlet/common/template.jsp" flush="false">
<tiles: put name="portlet_menu" value="/html/portlet/common/menu.jsp" />
<tiles: put name="breadcrumb" value="/html/portlet/common/breadcrumb.jsp" />
<tiles: put name="portlet_actions" value="/html/portlet/common/actions.jsp" />
<tiles: put name="portlet_help_tip" value="/html/portlet/common/helptip.jsp" />
<tiles: put name="portlet_title" type="String">
<t: outputText value="#{messages.title_directory_configuration_1}" />
</tiles: put>

<tiles: put name="portlet_content" type="String" >

<t: saveState value="#{directory}"/>
<h: form id="step1">

<table id="contentTable" border="0" cellspacing="1" cellpadding="2" class="list" width="95%">
<td class="portlet-section-alternate" width="200">
<t: outputText value="#{messages.column_name}" styleClass="portlet-font" style="font-size: x-small;" />
<td class="portlet-section-body">
<h:outputFormat value="#{messages[]}" styleClass="portlet-msg-error" style="font-size: x-small;">
<f: param value="#{messages.column_name}" />
</h: outputFormat>
<t:outputText value="<br>" escape="false" rendered="#{!empty}" />
<t: inputText id="name" value="#{}" size="50" maxlength="128" styleClass="form-text" />