• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JUnit and Cactus using strutstestCase

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hopefully there are some experts there. I've been working on this for days and am so frustrated I'm about to quit. Currently it is failing within the action class and throwing an exception. Please let me know what additional info I can give to make this more clear. Here is my test case:

package gov.wapa.snr.pbs.actionTests;

import servletunit.struts.CactusStrutsTestCase;
import gov.wapa.snr.pbs.actionForms.TypeTablesForm;

import java.util.ArrayList;

import org.apache.cactus.client.authentication.FormAuthentication;
import org.apache.cactus.WebRequest;

/**
* User: Holmes
* Date: Aug 13, 2004
* Time: 12:26:48 PM
* All software and source code property of WAPA/DOE
*/

public class TestTypeTablesAction extends CactusStrutsTestCase {

public void beginFormAuthentication(WebRequest theRequest) throws Exception {
theRequest.setAuthentication(new FormAuthentication("weblogic", "weblogic"));
}

public void testFormAuthentication() {
assertEquals("weblogic", request.getUserPrincipal().getName());
assertEquals("weblogic", request.getRemoteUser());
assertTrue("User not in 'PBSadmin' role", request.isUserInRole("PBSadmin"));
}

public void beginNoTypeTable(WebRequest theRequest) {

theRequest.setAuthentication(new FormAuthentication("weblogic", "weblogic"));
theRequest.addParameter("Menu2Load", "TabbedHome");
theRequest.addParameter("menuSelected2", "-1");
theRequest.addParameter("menuSelected", "3");
}

public void testNoTypeTable() {

/*setRequestPathInfo("/welcome.do");
actionPerform();*/

setConfigFile("/WEB-INF/struts-config.xml");
setRequestPathInfo("/systemTables_other.do");
actionPerform();
System.out.println("Actual forward in NoTypeTable: " + getActualForward());
TypeTablesForm form = (TypeTablesForm) getActionForm();
assertNotNull("typeTablesForm is null", form);
ArrayList methodNames = form.getSystemDelegateMethodNames();
assertNotNull("Method names in Form Bean is null", methodNames);
verifyTilesForward("failure", "systemTables_other");
verifyNoActionErrors();
}

public void beginWithTypeTable(WebRequest theRequest) {

theRequest.setAuthentication(new FormAuthentication("weblogic", "weblogic"));
theRequest.addParameter("Menu2Load", "TabbedHome");
theRequest.addParameter("menuSelected2", "-1");
theRequest.addParameter("menuSelected", "3");
}

public void testWithTypeTable() {

setConfigFile("/WEB-INF/struts-config.xml");
setRequestPathInfo("/systemTables_other.do");
addRequestParameter("typeTable", "AddressTypes");
actionPerform();
System.out.println("Actual forward in WithTypeTable: " + getActualForward());
TypeTablesForm form = (TypeTablesForm) getActionForm();
;
assertNotNull("typeTablesForm is null", form);
ArrayList methodNames = form.getSystemDelegateMethodNames();
assertNotNull("Method names in Form Bean is null", methodNames);
assertNotNull("typeTable is Null", form.getTypeTable());
assertNotNull("getAlign is Null", form.getAlign());
assertNotNull("ColumnNameOne is null", form.getColumnNameOne());
assertNotNull("columnNameTwo is null", form.getColumnNameTwo());
assertNotNull("columnOne is null", form.getColumnOne());
assertNotNull("columnTwo is null", form.getColumnTwo());
assertNotNull("tableType is null", form.getTypeTable());
verifyTilesForward("success", "systemTables_other");
verifyNoActionErrors();
}
}
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Steve,

The exception stack trace would be nice (along with some kind of a pointer to which line in your test class the exception points to).
 
Steve P Holmes
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I figured out the problem. Turns out there was NOTHING wrong with my configuration and the tests were running fine. They were failing where they should have been there were some actual errors in the code.

But you could help me with something else. I can't seem to get the server side logging working. The client seems to be working fine but I'm getting:

log4j:WARN No appenders could be found for logger (org.apache.cactus.internal.server.ServerTestCaseCaller).
log4j:WARN Please initialize the log4j system properly.

I've got the logging_server.properties in the classes directory of WEB-INF on the server. Any thoughts?
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Steve P Holmes:
I've got the logging_server.properties in the classes directory of WEB-INF on the server. Any thoughts?

Have you told your logging framework that it should read its configuration from WEB-INF/logging_server.properties?
 
Steve P Holmes
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do I do that?
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Steve P Holmes:
How do I do that?


Try starting the server with -Dlog4j.configuration=/opt/foo/bar/WEB-INF/logging_server.properties
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Or, you could use a servlet to initialize the Log4J properties as described in the Log4J manual (search for "Initialization servlet" close to the bottom of the page).
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic