Results 1 to 6 of 6
Thread: How to set ClassPath?
- 12-01-2009, 06:45 AM #1
How to set ClassPath?
Hi,
I am writing a sample testcase for my struts applications. I got some errors.
error is
log4j:WARN No appenders could be found for logger (servletunit.struts.MockStrutsTestCase).
log4j:WARN Please initialize the log4j system properly.
For that i got a solution that i have to set class path.But i dont know where and How to set to class path..........
plz help me friends.........
- 12-01-2009, 11:50 AM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
That's not classpath stuff.
That's setting up log4J.
And they're runtime warnings, not errors as such.
- 12-01-2009, 12:45 PM #3
thank u tolls.........
but when i run the test case it shows always a red bar eventhough the logic is correct, I dont know how to handle it, can u check it where the mistake is.....
Test Case Code:
Action Class code:Java Code:public class TestSuccess extends MockStrutsTestCase { protected void setUp() throws Exception { super.setUp(); } protected void tearDown() throws Exception { super.tearDown(); } public TestSuccess(String testName) { super(testName); } public void testSuccessfulLogin() { //setServletConfigFile("/WEB-INF/web.xml"); setRequestPathInfo("/LoginAction"); setConfigFile("/WEB-INF/struts-config.xml"); addRequestParameter("userName","deryl"); addRequestParameter("passWord","radar"); actionPerform(); verifyForward("success"); assertEquals("deryl",(String) getSession().getAttribute("authentication")); verifyNoActionErrors(); } }
In struts Config file I gave mapping like the following:Java Code:public class loginAction extends BaseAction{ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { try { loginform Loginform=(loginform)form; String username = Loginform.getUserName(); String password = Loginform.getPassWord(); ActionErrors errors = new ActionErrors(); if ((!username.equals("deryl")) || (!password.equals("radar"))) errors.add("password",new ActionError("error.password.mismatch")); if (errors.size()>0) { saveErrors(request,errors); return mapping.findForward("ProjectAction"); } // store authentication info on the session HttpSession session = request.getSession(); session.setAttribute("authentication", username); // Forward control to the specified success URI } catch (Exception e) { e.printStackTrace(); } return mapping.findForward("success"); } }
Java Code:<form-beans> <form-bean name="LoginForm" type="loginform"/> </form-beans> <action-mappings> <action path="/LoginAction" type="loginAction" name="LoginForm" scope="request" input="/web/login.jsp"> <forward name="success" path="/web/login.jsp"/> </action> </action-mappings>
- 12-01-2009, 01:02 PM #4
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Can you bit explain how you configured the log4j? Seems that's much related with the log4j, nothing to do with classpath.
- 12-01-2009, 01:34 PM #5
i am using log4j-1.2.9.jar file.When I am running the above mentioned page , it works correctly.But in the case of running testcase only in cosole it showing the warning as mentioned and junit shows red bar always.
- 12-11-2009, 07:24 AM #6
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
What happen in your log, is it actually append on physical file.?
Similar Threads
-
Classpath
By JavaJunkie in forum New To JavaReplies: 1Last Post: 04-07-2009, 07:17 AM -
help me to set classpath
By srinivaspuvvala in forum Java ServletReplies: 3Last Post: 01-18-2009, 07:13 PM -
j3d classpath
By sales1 in forum New To JavaReplies: 3Last Post: 12-23-2008, 01:51 AM -
Classpath
By Preethi in forum New To JavaReplies: 5Last Post: 06-20-2008, 09:00 AM -
Classpath on mac osx
By jacobb in forum JDBCReplies: 0Last Post: 06-12-2008, 09:41 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks