Re: Cactus test case
Hi Raghunandan , The Cactus project has a really good documentation. One point to start is the sample projects. Have a look at the sample projects, that come with the distribution, and once you run these sample projects, try to look in them what part of the HTTP layer is tested with Cactus - cookies, request/session attributes, parameters, etc. Then try to test those things in your servlet. Some links to the Cactus documentation: http://jakarta.apache.org/cactus/writing/howto_testcase_servlet.html http://jakarta.apache.org/cactus/integration/index.html Cheers, Petar. 2008/2/7, Raghunandan B [EMAIL PROTECTED]: Hi, How do i write cactus test case to test this servlet import java.io.*; import javax.servlet.http.*; import javax.servlet.*; import java.net.*; import java.util.*; public class SampleServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType(text/html); PrintWriter out = response.getWriter(); String title = Session Tracking Example; HttpSession session = request.getSession(true); String heading; Integer accessCount = (Integer)session.getAttribute(accessCount); if (accessCount == null) { accessCount = new Integer(0); } else { accessCount = new Integer(accessCount.intValue() + 1); } // Use setAttribute instead of putValue in version 2.2. session.setAttribute(accessCount, accessCount); out.println( BODY\n+ p align=center+ Session ID + session.getId() + br + Creation Time\n + new Date(session.getCreationTime()) + \n + br + Time of Last Access\n + new Date(session.getLastAccessedTime()) + \n +br + Number of Previous Accesses\n + accessCount + \n + /p+ /BODY/HTML); } /** Handle GET and POST requests identically. */ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request, response); } } Regards, Raghu -- Regards, Petar! Karlovo, Bulgaria. EOOXML Objections http://www.grokdoc.net/index.php/EOOXML_objections Public PGP Key at: https://keyserver1.pgp.com/vkd/DownloadKey.event?keyid=0x19658550C3110611 Key Fingerprint: A369 A7EE 61BC 93A3 CDFF 55A5 1965 8550 C311 0611
Re: Cactus test case
Hi Raghunandan , if you go through this site you will get answer for your question. http://www.onjava.com/pub/a/onjava/2004/09/22/test-struts.html Regards, Jeyaseelan.A Anadocs IT Solutions Pvt, Adyar, Chennai-20, Cell - 9962290394. - Original Message From: Raghunandan B [EMAIL PROTECTED] To: cactus-user@jakarta.apache.org Sent: Thursday, 7 February, 2008 12:54:05 AM Subject: Re:Cactus test case Hi, How do i write cactus test case to test this servlet import java.io.*; import javax.servlet.http.*; import javax.servlet.*; import java.net.*; import java.util.*; public class SampleServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType(text/html); PrintWriter out = response.getWriter(); String title = Session Tracking Example; HttpSession session = request.getSession(true); String heading; Integer accessCount = (Integer)session.getAttribute(accessCount); if (accessCount == null) { accessCount = new Integer(0); } else { accessCount = new Integer(accessCount.intValue() + 1); } // Use setAttribute instead of putValue in version 2.2. session.setAttribute(accessCount, accessCount); out.println( BODY\n+ p align=center+ Session ID + session.getId() + br + Creation Time\n + new Date(session.getCreationTime()) + \n + br + Time of Last Access\n + new Date(session.getLastAccessedTime()) + \n +br + Number of Previous Accesses\n + accessCount + \n + /p+ /BODY/HTML); } /** Handle GET and POST requests identically. */ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request, response); } } Regards, Raghu
Re: class hierarchy and extending a Cactus Test Case
Hi, In article [EMAIL PROTECTED], Wed, 18 Jul 2007 16:16:56 -0500, Jay Baker [EMAIL PROTECTED] wrote: jbaker.work Thank you for your interest. Let's say that I have a base class that is used jbaker.work for regular (not in container) test cases. Call this MyBaseTestCase. I have jbaker.work other test classes that extend this base class. The base class provides jbaker.work services that I need and the current design uses inheritance. For example, jbaker.work it uses a template pattern approach to enforce that some metadata is jbaker.work available. So we have: Thank you. I could understand better. Many of testing-frameworks use the template pattern and have their own base-class (not an interface) to be inherited. As Java doesn't support multiple inheritance, I think it is better to have separated utility class which provides services currently provided by your MyBaseTestCase class so that you can utilize such service independently of object hierarchy of its client. By doing so, you could avoid similar issue when you will try other frameworks, eg. StrutsTestCase. In article [EMAIL PROTECTED], Tue, 17 Jul 2007 11:11:25 -0500, Jay Baker [EMAIL PROTECTED] wrote: jbaker.work It seems that I have four choices. [snip] jbaker.work 4. Change the design of existing code base that I have so this is not an jbaker.work issue. I can't really afford to do this at this time due to the effort and jbaker.work risk involved. If I were you, I would take this approach. To minimize the risk you are worrying about, you would change only codes that relate to Cactus for this time. # I suggest step-by-step refactoring. Best Regards, Kazuhito SUGURI - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: class hierarchy and extending a Cactus Test Case
Hi, In article [EMAIL PROTECTED], Tue, 17 Jul 2007 11:11:25 -0500, Jay Baker [EMAIL PROTECTED] wrote: jbaker.work I am using ServletTestCase. Extending this test case works just fine. No jbaker.work problem. However, I have an existing object hierarchy that I would like to jbaker.work preserve. Although all of the Cactus documentation discusses extending one jbaker.work of the Cactus tests, I figured I could just implement some appropriate jbaker.work interface(s) and use delegation. As I read further, I understood the use of jbaker.work publicly accessible attributes of the various Cactus test cases. If this jbaker.work access were done through getters and setters, I would have no problem. I cannot understand what you want to do, so am having questions. Q1: What is the object for which you want to preserve its object hierarchy? Q2: What is the relation of the object and Cactus? Q3: How should the object and Cactus work together? A safe example would be helpful. Best Regards, Kazuhito SUGURI - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: class hierarchy and extending a Cactus Test Case
Thank you for your interest. Let's say that I have a base class that is used for regular (not in container) test cases. Call this MyBaseTestCase. I have other test classes that extend this base class. The base class provides services that I need and the current design uses inheritance. For example, it uses a template pattern approach to enforce that some metadata is available. So we have: public class TestCase03 extends MyBaseTestCase { ... } Now I want to add in container testing using Cactus. I could do: public class TestCase04 extends ServletTestCase { ... } but I don't want to because of the existing hierarchy I have. So I tried: public class TestCase04 extends MyBaseTestCase implements CactusTestCase { ...} and delegated to an instance of ServletTestCase for the implementation of the CactusTestCase interface. That did not work however. To check things out, I created my own class MyCactusBaseTestCase that looks very much like ServletTestCase but it extends MyBaseTestCase. This works, but I would prefer to not rely on the source code of ServletTestCase. I hope that clarifies things a bit and thanks for your help. -- Jay On 7/18/07, Kazuhito SUGURI [EMAIL PROTECTED] wrote: Hi, In article [EMAIL PROTECTED], Tue, 17 Jul 2007 11:11:25 -0500, Jay Baker [EMAIL PROTECTED] wrote: jbaker.work I am using ServletTestCase. Extending this test case works just fine. No jbaker.work problem. However, I have an existing object hierarchy that I would like to jbaker.work preserve. Although all of the Cactus documentation discusses extending one jbaker.work of the Cactus tests, I figured I could just implement some appropriate jbaker.work interface(s) and use delegation. As I read further, I understood the use of jbaker.work publicly accessible attributes of the various Cactus test cases. If this jbaker.work access were done through getters and setters, I would have no problem. I cannot understand what you want to do, so am having questions. Q1: What is the object for which you want to preserve its object hierarchy? Q2: What is the relation of the object and Cactus? Q3: How should the object and Cactus work together? A safe example would be helpful. Best Regards, Kazuhito SUGURI - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
class hierarchy and extending a Cactus Test Case
I searched the archives but, surprisingly, I could not find anything on this. I am using ServletTestCase. Extending this test case works just fine. No problem. However, I have an existing object hierarchy that I would like to preserve. Although all of the Cactus documentation discusses extending one of the Cactus tests, I figured I could just implement some appropriate interface(s) and use delegation. As I read further, I understood the use of publicly accessible attributes of the various Cactus test cases. If this access were done through getters and setters, I would have no problem. It seems that I have four choices. 1. Implement some arcane introspective state listener such that I can transfer state changes in my base class to a delegate Cactus class. I'm not even sure how to do that off the top of my head and I don't like the idea very much. 2. Copy implementation from an appropriate Cactus class to my base class. I also don't like this. It is poor design and couples my base class too closely to this version of Cactus. Of course, it would work. 3. Discuss contributing to Cactus such that the framework will permit a design that could use delegation. This would be fine, but it can not meet the time frame requirements that I have. 4. Change the design of existing code base that I have so this is not an issue. I can't really afford to do this at this time due to the effort and risk involved. Any suggestions from others that have been down this road before? -- Jay
Help in Cactus Test Case
HI I am getting the following error when I run the cactus test case. Could you pl help me. org.apache.cactus.util.ChainedRuntimeException: Failed to get the test results. This is probably due to an error that happened on the server side when trying to execute the tests. Here is what was returned by the server : [Error 404: File not found: ServletRedirector ] at org.apache.cactus.client.AbstractHttpClient.dispatch2_doTest(LogAspect.aj(1k):120) at org.apache.cactus.client.AbstractHttpClient.around2_doTest(LogAspect.aj(1k):1218) at org.apache.cactus.client.AbstractHttpClient.doTest(LogAspect.aj(1k):104) at org.apache.cactus.AbstractWebTestCase.runGenericTest(AbstractWebTestCase.java:260) at org.apache.cactus.ServletTestCase.runTest(ServletTestCase.java:133) at org.apache.cactus.AbstractTestCase.runBare(AbstractTestCase.java:195) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:131) at junit.framework.TestSuite.runTest(TestSuite.java:173) at junit.framework.TestSuite.run(TestSuite.java:168) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:329) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:218) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:151) org.apache.cactus.client.ParsingException: Not a valid response at org.apache.cactus.client.WebTestResultParser.readRootElement(LogAspect.aj(1k):140) at org.apache.cactus.client.WebTestResultParser.dispatch29_parse(LogAspect.aj(1k):101) at org.apache.cactus.client.WebTestResultParser.around29_parse(LogAspect.aj(1k):1218) at org.apache.cactus.client.WebTestResultParser.parse(LogAspect.aj(1k):96) at org.apache.cactus.client.AbstractHttpClient.callGetResult(LogAspect.aj(1k):230) at org.apache.cactus.client.AbstractHttpClient.dispatch2_doTest(LogAspect.aj(1k):114) at org.apache.cactus.client.AbstractHttpClient.around2_doTest(LogAspect.aj(1k):1218) at org.apache.cactus.client.AbstractHttpClient.doTest(LogAspect.aj(1k):104) at org.apache.cactus.AbstractWebTestCase.runGenericTest(AbstractWebTestCase.java:260) at org.apache.cactus.ServletTestCase.runTest(ServletTestCase.java:133) at org.apache.cactus.AbstractTestCase.runBare(AbstractTestCase.java:195) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:131) at junit.framework.TestSuite.runTest(TestSuite.java:173) at junit.framework.TestSuite.run(TestSuite.java:168) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:329) CactusJspTest.java at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:218) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:151) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Help in Cactus Test Case
The error says Error 404: File not found: ServletRedirector. It means you redirector is not set up correctly and cannot be access from Cactus client side. Please check the configuration tutorial on the cactus web page for setting it up correctly. You can test your redirector is set up correctly by using: http://localhost:8080/webapp/ServletRedirector?Cactus_Service=RUN_TEST where webapp is your webapp context. Replace the port by the port you're using. Note to self and to cactus developersWe should probably have an AspectJ checking aspect that would call this URL once to verify that the redirector is set up correctly and report a nice error message if not. What do you think? /Note to self and to cactus developers Thanks -Vincent -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: 03 July 2003 10:26 To: [EMAIL PROTECTED] Subject: Help in Cactus Test Case HI I am getting the following error when I run the cactus test case. Could you pl help me. org.apache.cactus.util.ChainedRuntimeException: Failed to get the test results. This is probably due to an error that happened on the server side when trying to execute the tests. Here is what was returned by the server : [Error 404: File not found: ServletRedirector ] at org.apache.cactus.client.AbstractHttpClient.dispatch2_doTest(LogAspect.a j( 1k):120) at org.apache.cactus.client.AbstractHttpClient.around2_doTest(LogAspect.aj( 1k ):1218) at org.apache.cactus.client.AbstractHttpClient.doTest(LogAspect.aj(1k):104) at org.apache.cactus.AbstractWebTestCase.runGenericTest(AbstractWebTestCase .j ava:260) at org.apache.cactus.ServletTestCase.runTest(ServletTestCase.java:133) at org.apache.cactus.AbstractTestCase.runBare(AbstractTestCase.java:195) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:131) at junit.framework.TestSuite.runTest(TestSuite.java:173) at junit.framework.TestSuite.run(TestSuite.java:168) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTe st Runner.java:329) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRun ne r.java:218) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRu nn er.java:151) org.apache.cactus.client.ParsingException: Not a valid response at org.apache.cactus.client.WebTestResultParser.readRootElement(LogAspect.a j( 1k):140) at org.apache.cactus.client.WebTestResultParser.dispatch29_parse(LogAspect. aj (1k):101) at org.apache.cactus.client.WebTestResultParser.around29_parse(LogAspect.aj (1 k):1218) at org.apache.cactus.client.WebTestResultParser.parse(LogAspect.aj(1k):96) at org.apache.cactus.client.AbstractHttpClient.callGetResult(LogAspect.aj(1 k) :230) at org.apache.cactus.client.AbstractHttpClient.dispatch2_doTest(LogAspect.a j( 1k):114) at org.apache.cactus.client.AbstractHttpClient.around2_doTest(LogAspect.aj( 1k ):1218) at org.apache.cactus.client.AbstractHttpClient.doTest(LogAspect.aj(1k):104) at org.apache.cactus.AbstractWebTestCase.runGenericTest(AbstractWebTestCase .j ava:260) at org.apache.cactus.ServletTestCase.runTest(ServletTestCase.java:133) at org.apache.cactus.AbstractTestCase.runBare(AbstractTestCase.java:195) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:131) at junit.framework.TestSuite.runTest(TestSuite.java:173) at junit.framework.TestSuite.run(TestSuite.java:168) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTe st Runner.java:329) CactusJspTest.java at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRun ne r.java:218) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRu nn er.java:151) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Cactus test case problem
Hello Vincent- Is this anomaly specific to Swing What about AWT Could we use commons-logging with AWT or should AWT implementations exclude commons-logging as with Swing? Many Thanks, -Martin - Original Message - From: Vincent Massol [EMAIL PROTECTED] To: 'Cactus Users List' [EMAIL PROTECTED] Cc: 'Martin' [EMAIL PROTECTED] Sent: Saturday, February 01, 2003 4:48 AM Subject: RE: Cactus test case problem Hi Martin, I think I know what the error is (see http://jakarta.apache.org/cactus/faq.html#faq8). It has to do with the fact that Kumar is using the Swing Test Runner and this later is using a reloadable class runner that has classloading issues with commons-logging. Thus commons-logging needs to be excluded from that loader. Thanks for your help! -Vincent -Original Message- From: Martin [mailto:[EMAIL PROTECTED]] Sent: 02 September 2002 03:26 To: Cactus Users List Cc: [EMAIL PROTECTED] Subject: Re: Cactus test case problem Kumar- Can we see the code for class SophiewebServlet() Something in the constructor is causing your new SophiewebServlet constructor to fail and return a null -Martin - Original Message - From: Vincent Massol [EMAIL PROTECTED] To: 'Cactus Users List' [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Friday, January 31, 2003 4:20 PM Subject: RE: Cactus test case problem Hi Kumar, See the Cactus FAQ: http://jakarta.apache.org/cactus/faq.html#faq8 -Vincent -Original Message- From: Kumar, Kiran (MED, TCS) [mailto:[EMAIL PROTECTED]] Sent: 29 January 2003 04:21 To: 'Cactus Users List' Subject: Cactus test case problem Hi I am new to JUnit frame work as such and cactus in particular. I have installed cactus and set all the class paths correctly. But when i run the test class for my servlet it threw me this exception. Can somebody help me out in finding the exact root cause of the problem. junit.framework.AssertionFailedError: Exception in constructor: testDefaultConstructor (org.apache.commons.logging.LogConfigurationException: java.lang.ClassCastException: org.apache.commons.logging.impl.LogFactoryImpl at org.apache.commons.logging.LogFactory.newFactory(LogFactory.java:506) at org.apache.commons.logging.LogFactory.getFactory(LogFactory.java:350) at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:381) at org.apache.cactus.util.JUnitVersionHelper.around146_getTestCaseName(JUni tVersionHelper.java;org/apache/cactus/util/log/LogAspect.aj(1k):1170) Cactus test case problem, Kumar, Kiran (MED, TCS) Re: Cactus test case problem, Martin Re: Cactus test case problem, Martin RE: Cactus test case problem, Vincent Massol Re: Cactus test case problem, Martin RE: Cactus test case problem, Vincent Massol -- Chronological -- -- Thread -- [EMAIL PROTECTED]"> Reply via email to Cactus test case problem, Kumar, Kiran (MED, TCS) Re: Cactus test case problem, Martin Re: Cactus test case problem, Martin RE: Cactus test case problem, Vincent Massol Re: Cactus test case problem, Martin RE: Cactus test case problem, Vincent Massol -- Chronological -- -- Thread -- [EMAIL PROTECTED]"> Reply via email to Cactus test case problem, Kumar, Kiran (MED, TCS) Re: Cactus test case problem, Martin Re: Cactus test case problem, Martin RE: Cactus test case problem, Vincent Massol Re: Cactus test case problem, Martin RE: Cactus test case problem, Vincent Massol -- Chronological -- -- Thread -- [EMAIL PROTECTED]"> Reply via email to Cactus test case problem, Kumar, Kiran (MED, TCS) Re: Cactus test case problem, Martin Re: Cactus test case problem, Martin RE: Cactus test case problem, Vincent Massol Re: Cactus test case problem, Martin RE: Cactus test case problem, Vincent Massol -- Chronological -- -- Thread -- [EMAIL PROTECTED]"> Reply via email to Cactus test case problem, Kumar, Kiran (MED, TCS) Re: Cactus test case problem, Martin Re: Cactus test case problem, Martin RE: Cactus test case problem, Vincent Massol Re: Cactus test case problem, Martin RE: Cactus test case problem, Vincent Massol -- Chronological -- -- Thread -- [EMAIL PROTECTED]"> Reply via email to Cactus test case problem, Kumar, Kiran (MED, TCS) Re: Cactus test case problem, Martin Re: Cactus test case problem, Martin RE:
RE: Cactus test case problem
Hi Martin, Please have a look at the FAQ entry: http://junit.sourceforge.net/doc/faq/faq.htm#running_8 To answer your question: - it is not an anomaly of JUnit. It is by design :-) - you can use commons-logging with any JUnit Test Runner (simply put it in the excluded list) - I believe it is the same with the AWT Runner as the JUnit FAQ says GUI Runners. If you want to be sure, you'll need to check the sources... ;-) -Vincent -Original Message- From: Martin [mailto:[EMAIL PROTECTED]] Sent: 02 September 2002 15:41 To: Cactus Users List Subject: Re: Cactus test case problem Hello Vincent- Is this anomaly specific to Swing What about AWT Could we use commons-logging with AWT or should AWT implementations exclude commons-logging as with Swing? Many Thanks, -Martin - Original Message - From: Vincent Massol [EMAIL PROTECTED] To: 'Cactus Users List' [EMAIL PROTECTED] Cc: 'Martin' [EMAIL PROTECTED] Sent: Saturday, February 01, 2003 4:48 AM Subject: RE: Cactus test case problem Hi Martin, I think I know what the error is (see http://jakarta.apache.org/cactus/faq.html#faq8). It has to do with the fact that Kumar is using the Swing Test Runner and this later is using a reloadable class runner that has classloading issues with commons-logging. Thus commons-logging needs to be excluded from that loader. Thanks for your help! -Vincent -Original Message- From: Martin [mailto:[EMAIL PROTECTED]] Sent: 02 September 2002 03:26 To: Cactus Users List Cc: [EMAIL PROTECTED] Subject: Re: Cactus test case problem Kumar- Can we see the code for class SophiewebServlet() Something in the constructor is causing your new SophiewebServlet constructor to fail and return a null -Martin - Original Message - From: Vincent Massol [EMAIL PROTECTED] To: 'Cactus Users List' [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Friday, January 31, 2003 4:20 PM Subject: RE: Cactus test case problem Hi Kumar, See the Cactus FAQ: http://jakarta.apache.org/cactus/faq.html#faq8 -Vincent -Original Message- From: Kumar, Kiran (MED, TCS) [mailto:[EMAIL PROTECTED]] Sent: 29 January 2003 04:21 To: 'Cactus Users List' Subject: Cactus test case problem Hi I am new to JUnit frame work as such and cactus in particular. I have installed cactus and set all the class paths correctly. But when i run the test class for my servlet it threw me this exception. Can somebody help me out in finding the exact root cause of the problem. junit.framework.AssertionFailedError: Exception in constructor: testDefaultConstructor (org.apache.commons.logging.LogConfigurationException: java.lang.ClassCastException: org.apache.commons.logging.impl.LogFactoryImpl at org.apache.commons.logging.LogFactory.newFactory(LogFactory.java:506) at org.apache.commons.logging.LogFactory.getFactory(LogFactory.java:350) at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:381) at org.apache.cactus.util.JUnitVersionHelper.around146_getTestCaseName(JUni tVersionHelper.java;org/apache/cactus/util/log/LogAspect.aj(1k):1170) at org.apache.cactus.util.JUnitVersionHelper.getTestCaseName(JUnitVersionHe lper.java;org/apache/cactus/util/log/LogAspect.aj(1k):103) at org.apache.cactus.AbstractTestCase.init(AbstractTestCase.java:124) at org.apache.cactus.AbstractWebTestCase.init(AbstractWebTestCase.java:86 ) at org.apache.cactus.ServletTestCase.init(ServletTestCase.java:119) at com.ge.sophieweb.controler.test.TestSophiewebServlet.init(TestSophiewe bServlet.java:26) at java.lang.reflect.Constructor.newInstance(Native Method) at & RE: A question cactus-user -- Chronological -- Find -- Thread -- RE: A question From: Vincent Massol Subject: RE: A question Date: Fri, 31 Jan 2003 12:21:06 -0800 RE: Cactus test case problem Vincent Massol Sat, 01 Feb 2003 13:27:56 -0800 Hi Tony, You should have a look at the following FAQ entry: http://jakarta.apache.org/cactus/faq.html#faq4 Cactus is about unit testing and there is no order of execution of the JUnit testXXX() methods (same principle as JUnit). You shouldn't rely on a first call setting up some state. Consequently, Cactus starts a new Session for each test. If you need to set up some object in the session, you can do it either in the setUp() method or at the beginning of your testXXX() method. Note that in Cactus 1.5, I have added a new API called WebRequest.getSessionCookie() which allows you to get a cookie before the test begins as shown below. But this is only to sup
RE: Cactus test case problem
Hi Martin, I think I know what the error is (see http://jakarta.apache.org/cactus/faq.html#faq8). It has to do with the fact that Kumar is using the Swing Test Runner and this later is using a reloadable class runner that has classloading issues with commons-logging. Thus commons-logging needs to be excluded from that loader. Thanks for your help! -Vincent -Original Message- From: Martin [mailto:[EMAIL PROTECTED]] Sent: 02 September 2002 03:26 To: Cactus Users List Cc: [EMAIL PROTECTED] Subject: Re: Cactus test case problem Kumar- Can we see the code for class SophiewebServlet() Something in the constructor is causing your new SophiewebServlet constructor to fail and return a null -Martin - Original Message - From: Vincent Massol [EMAIL PROTECTED] To: 'Cactus Users List' [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Friday, January 31, 2003 4:20 PM Subject: RE: Cactus test case problem Hi Kumar, See the Cactus FAQ: http://jakarta.apache.org/cactus/faq.html#faq8 -Vincent -Original Message- From: Kumar, Kiran (MED, TCS) [mailto:[EMAIL PROTECTED]] Sent: 29 January 2003 04:21 To: 'Cactus Users List' Subject: Cactus test case problem Hi I am new to JUnit frame work as such and cactus in particular. I have installed cactus and set all the class paths correctly. But when i run the test class for my servlet it threw me this exception. Can somebody help me out in finding the exact root cause of the problem. junit.framework.AssertionFailedError: Exception in constructor: testDefaultConstructor (org.apache.commons.logging.LogConfigurationException: java.lang.ClassCastException: org.apache.commons.logging.impl.LogFactoryImpl at org.apache.commons.logging.LogFactory.newFactory(LogFactory.java:506) at org.apache.commons.logging.LogFactory.getFactory(LogFactory.java:350) at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:381) at org.apache.cactus.util.JUnitVersionHelper.around146_getTestCaseName(JUni tVersionHelper.java;org/apache/cactus/util/log/LogAspect.aj(1k):1170) at org.apache.cactus.util.JUnitVersionHelper.getTestCaseName(JUnitVersionHe lper.java;org/apache/cactus/util/log/LogAspect.aj(1k):103) at org.apache.cactus.AbstractTestCase.init(AbstractTestCase.java:124) at org.apache.cactus.AbstractWebTestCase.init(AbstractWebTestCase.java:86 ) at org.apache.cactus.ServletTestCase.init(ServletTestCase.java:119) at com.ge.sophieweb.controler.test.TestSophiewebServlet.init(TestSophiewe bServlet.java:26) at java.lang.reflect.Constructor.newInstance(Native Method) at com.ge.sophieweb.controler.test.TestSophiewebServlet.suite(TestSophieweb Servlet.java:39) at junit.runner.BaseTestRunner.getTest(BaseTestRunner.java:53) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1450) at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractB utton.java:1504) at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.ja va:378) at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:250) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonList ener.java:216) at java.awt.Component.processMouseEvent(Component.java:3715) at java.awt.Component.processEvent(Component.java:3544) at java.awt.Container.processEvent(Container.java:1164) at java.awt.Component.dispatchEventImpl(Component.java:2593) at java.awt.Container.dispatchEventImpl(Container.java:1213) at java.awt.Component.dispatchEvent(Component.java:2497) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:2451) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:2216) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:2125) at java.awt.Container.dispatchEventImpl(Container.java:1200) at java.awt.Window.dispatchEventImpl(Window.java:926) at java.awt.Component.dispatchEvent(Component.java:2497) at java.awt.EventQueue.dispatchEvent(EventQueue.java:339) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThrea d.java:131) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread. java:98) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) at java.awt.EventDispatchThread.run(EventDispatchThread.java:85) ) this is the line of code which actually failed... public void testDefaultConstructor() { assertNotNull(new SophiewebServlet()); } Thanks and Regards Kiran Kumar -Original Message- From: Vincent Massol [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 28, 2003 7:17 PM To: 'Cactus Users List' Subject: RE: getRequestDispatcher()/JSP Test problem - more... Hi Franck
Re: Cactus test case problem
Kumar- Can we see the code for class SophiewebServlet() Something in the constructor is causing your new SophiewebServlet constructor to fail and return a null -Martin - Original Message - From: Vincent Massol [EMAIL PROTECTED] To: 'Cactus Users List' [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Friday, January 31, 2003 4:20 PM Subject: RE: Cactus test case problem Hi Kumar, See the Cactus FAQ: http://jakarta.apache.org/cactus/faq.html#faq8 -Vincent -Original Message- From: Kumar, Kiran (MED, TCS) [mailto:[EMAIL PROTECTED]] Sent: 29 January 2003 04:21 To: 'Cactus Users List' Subject: Cactus test case problem Hi I am new to JUnit frame work as such and cactus in particular. I have installed cactus and set all the class paths correctly. But when i run the test class for my servlet it threw me this exception. Can somebody help me out in finding the exact root cause of the problem. junit.framework.AssertionFailedError: Exception in constructor: testDefaultConstructor (org.apache.commons.logging.LogConfigurationException: java.lang.ClassCastException: org.apache.commons.logging.impl.LogFactoryImpl at org.apache.commons.logging.LogFactory.newFactory(LogFactory.java:506) at org.apache.commons.logging.LogFactory.getFactory(LogFactory.java:350) at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:381) at org.apache.cactus.util.JUnitVersionHelper.around146_getTestCaseName(JUni tVersionHelper.java;org/apache/cactus/util/log/LogAspect.aj(1k):1170) at org.apache.cactus.util.JUnitVersionHelper.getTestCaseName(JUnitVersionHe lper.java;org/apache/cactus/util/log/LogAspect.aj(1k):103) at org.apache.cactus.AbstractTestCase.init(AbstractTestCase.java:124) at org.apache.cactus.AbstractWebTestCase.init(AbstractWebTestCase.java:86 ) at org.apache.cactus.ServletTestCase.init(ServletTestCase.java:119) at com.ge.sophieweb.controler.test.TestSophiewebServlet.init(TestSophiewe bServlet.java:26) at java.lang.reflect.Constructor.newInstance(Native Method) at com.ge.sophieweb.controler.test.TestSophiewebServlet.suite(TestSophieweb Servlet.java:39) at junit.runner.BaseTestRunner.getTest(BaseTestRunner.java:53) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1450) at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractB utton.java:1504) at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.ja va:378) at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:250) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonList ener.java:216) at java.awt.Component.processMouseEvent(Component.java:3715) at java.awt.Component.processEvent(Component.java:3544) at java.awt.Container.processEvent(Container.java:1164) at java.awt.Component.dispatchEventImpl(Component.java:2593) at java.awt.Container.dispatchEventImpl(Container.java:1213) at java.awt.Component.dispatchEvent(Component.java:2497) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:2451) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:2216) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:2125) at java.awt.Container.dispatchEventImpl(Container.java:1200) at java.awt.Window.dispatchEventImpl(Window.java:926) at java.awt.Component.dispatchEvent(Component.java:2497) at java.awt.EventQueue.dispatchEvent(EventQueue.java:339) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThrea d.java:131) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread. java:98) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) at java.awt.EventDispatchThread.run(EventDispatchThread.java:85) ) this is the line of code which actually failed... public void testDefaultConstructor() { assertNotNull(new SophiewebServlet()); } Thanks and Regards Kiran Kumar -Original Message- From: Vincent Massol [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 28, 2003 7:17 PM To: 'Cactus Users List' Subject: RE: getRequestDispatcher()/JSP Test probl Cactus test case problem, Kumar, Kiran (MED, TCS) Re: Cactus test case problem, Martin Re: Cactus test case problem, Martin RE: Cactus test case problem, Vincent Massol Re: Cactus test case problem, Martin RE: Cactus test case problem, Vincent Massol -- Chronological -- -- Thread -- Reply via email to Cactus test case problem, Kumar, Kiran (MED, TCS) Re: Cactus test case problem, Martin Re: Cactus test case problem, Martin RE: Cactus test case problem, Vincent Massol Re: Cactus test case problem, Martin RE: Cactus test case problem, Vincent Massol
Re: Cactus test case problem
Kumar- Can we see the code for class SophiewebServlet() Something in the constructor is causing your new SophiewebServlet constructor to fail and return a null -Martin - Original Message - From: Vincent Massol [EMAIL PROTECTED] To: 'Cactus Users List' [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Friday, January 31, 2003 4:20 PM Subject: RE: Cactus test case problem Hi Kumar, See the Cactus FAQ: http://jakarta.apache.org/cactus/faq.html#faq8 -Vincent -Original Message- From: Kumar, Kiran (MED, TCS) [mailto:[EMAIL PROTECTED]] Sent: 29 January 2003 04:21 To: 'Cactus Users List' Subject: Cactus test case problem Hi I am new to JUnit frame work as such and cactus in particular. I have installed cactus and set all the class paths correctly. But when i run the test class for my servlet it threw me this exception. Can somebody help me out in finding the exact root cause of the problem. junit.framework.AssertionFailedError: Exception in constructor: testDefaultConstructor (org.apache.commons.logging.LogConfigurationException: java.lang.ClassCastException: org.apache.commons.logging.impl.LogFactoryImpl at org.apache.commons.logging.LogFactory.newFactory(LogFactory.java:506) at org.apache.commons.logging.LogFactory.getFactory(LogFactory.java:350) at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:381) at org.apache.cactus.util.JUnitVersionHelper.around146_getTestCaseName(JUni tVersionHelper.java;org/apache/cactus/util/log/LogAspect.aj(1k):1170) at org.apache.cactus.util.JUnitVersionHelper.getTestCaseName(JUnitVersionHe lper.java;org/apache/cactus/util/log/LogAspect.aj(1k):103) at org.apache.cactus.AbstractTestCase.init(AbstractTestCase.java:124) at org.apache.cactus.AbstractWebTestCase.init(AbstractWebTestCase.java:86 ) at org.apache.cactus.ServletTestCase.init(ServletTestCase.java:119) at com.ge.sophieweb.controler.test.TestSophiewebServlet.init(TestSophiewe bServlet.java:26) at java.lang.reflect.Constructor.newInstance(Native Method) at com.ge.sophieweb.controler.test.TestSophiewebServlet.suite(TestSophieweb Servlet.java:39) at junit.runner.BaseTestRunner.getTest(BaseTestRunner.java:53) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1450) at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractB utton.java:1504) at javax.swing.DefaultButtonModel.fireAc Cactus test case problem, Kumar, Kiran (MED, TCS) Re: Cactus test case problem, Martin Re: Cactus test case problem, Martin RE: Cactus test case problem, Vincent Massol Re: Cactus test case problem, Martin RE: Cactus test case problem, Vincent Massol -- Chronological -- -- Thread -- [EMAIL PROTECTED]"> Reply via email to Cactus test case problem, Kumar, Kiran (MED, TCS) Re: Cactus test case problem, Martin Re: Cactus test case problem, Martin RE: Cactus test case problem, Vincent Massol Re: Cactus test case problem, Martin RE: Cactus test case problem, Vincent Massol -- Chronological -- -- Thread -- [EMAIL PROTECTED]"> Reply via email to Cactus test case problem, Kumar, Kiran (MED, TCS) Re: Cactus test case problem, Martin Re: Cactus test case problem, Martin RE: Cactus test case problem, Vincent Massol Re: Cactus test case problem, Martin RE: Cactus test case problem, Vincent Massol -- Chronological -- -- Thread -- [EMAIL PROTECTED]"> Reply via email to Cactus test case problem, Kumar, Kiran (MED, TCS) Re: Cactus test case problem, Martin Re: Cactus test case problem, Martin RE: Cactus test case problem, Vincent Massol Re: Cactus test case problem, Martin RE: Cactus test case problem, Vincent Massol -- Chronological -- -- Thread -- [EMAIL PROTECTED]"> Reply via email to Cactus test case problem, Kumar, Kiran (MED, TCS) Re: Cactus test case problem, Martin Re: Cactus test case problem, Martin RE: Cactus test case problem, Vincent Massol Re: Cactus test case problem, Martin RE: Cactus test case problem, Vincent Massol -- Chronological -- -- Thread -- [EMAIL PROTECTED]"> Reply via email to Cactus test case problem, Kumar, Kiran (MED, TCS) Re: Cactus test case problem, Martin Re: Cactus test case problem, Martin RE: Cactus test case problem, Vincent Massol Re: Cactus test case problem, Martin RE: Cactus test case problem, Vincent Massol
RE: How to pass parameters to a Cactus Test Case
Hi Marc, Good question. Several solutions that comes to mind : 1/ In beginXXX() send the parameter using and WebRequest.addParameter() and get it on the server side by calling request.getParameter() (in your setUp() for example). Agreed this is not nice as it modified your test case 2/ In Cactus 1.4dev every property defined in Cactus.properties is exposed as a Java System property. Thus you can add your own properties there and get them in your code using System.getProperty(). You'll have to put it in both cactus.properties (client side and server side) though (you can copy the same file to both locations). Would that do for you ? -Vincent -Original Message- From: Brette, Marc [mailto:[EMAIL PROTECTED]] Sent: 23 May 2002 10:02 To: 'Cactus Users List' Subject: How to pass parameters to a Cactus Test Case Hi, I have a Cactus test that should be used against several configurations. To fix ideas, this test accesses a database and I would like to use this same test when my database is SQLServer or Oracle. In my application, the database to use is defined by a configuration file. An easy to use method would be to give the file name as a command line argument of the test runner, and call the same test with different parameter in my Makefile/Ant but : - this should be given both to the test runner and of the web server - I already pass an argument (my server root path) as a System property (using -DrootPath=...), and I expect other tests to need such runtime argument. - It would be simpler to have such parameter defined in the Makefile/Ant, rather than hard-coded in the test. Does anybody have a method to provide such runtime argument to a test ? (note that this is already a JUnit problem, but with Cactus, as we have several JVM, the problem is worse) Thanks, Marc -- To unsubscribe, e-mail: mailto:cactus-user- [EMAIL PROTECTED] For additional commands, e-mail: mailto:cactus-user- [EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: How to pass parameters to a Cactus Test Case
Well, it answer my question as it confirm there is no standard method to do what I want :-) I will keep in mind the 1st method however (I still have to figure out how to pass the argument for it to be available in beginXXX). The 2nd method implies that for each execution of my test, I would need a different cactus.properties, which is not easily manageable. Thanks ! -Original Message- From: Vincent Massol [mailto:[EMAIL PROTECTED]] Sent: 23 May 2002 11:26 To: 'Cactus Users List' Subject: RE: How to pass parameters to a Cactus Test Case Hi Marc, Good question. Several solutions that comes to mind : 1/ In beginXXX() send the parameter using and WebRequest.addParameter() and get it on the server side by calling request.getParameter() (in your setUp() for example). Agreed this is not nice as it modified your test case 2/ In Cactus 1.4dev every property defined in Cactus.properties is exposed as a Java System property. Thus you can add your own properties there and get them in your code using System.getProperty(). You'll have to put it in both cactus.properties (client side and server side) though (you can copy the same file to both locations). Would that do for you ? -Vincent -Original Message- From: Brette, Marc [mailto:[EMAIL PROTECTED]] Sent: 23 May 2002 10:02 To: 'Cactus Users List' Subject: How to pass parameters to a Cactus Test Case Hi, I have a Cactus test that should be used against several configurations. To fix ideas, this test accesses a database and I would like to use this same test when my database is SQLServer or Oracle. In my application, the database to use is defined by a configuration file. An easy to use method would be to give the file name as a command line argument of the test runner, and call the same test with different parameter in my Makefile/Ant but : - this should be given both to the test runner and of the web server - I already pass an argument (my server root path) as a System property (using -DrootPath=...), and I expect other tests to need such runtime argument. - It would be simpler to have such parameter defined in the Makefile/Ant, rather than hard-coded in the test. Does anybody have a method to provide such runtime argument to a test ? (note that this is already a JUnit problem, but with Cactus, as we have several JVM, the problem is worse) Thanks, Marc -- To unsubscribe, e-mail: mailto:cactus-user- [EMAIL PROTECTED] For additional commands, e-mail: mailto:cactus-user- [EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]