I've never used that base test class, but usually when I write a unit test for a Struts action, I isolate everything around and just verify the result string of the method executed ("success", "error", "input" etc). The test never executes the result.
Nils-H On Wed, Dec 17, 2008 at 6:07 PM, Milan Milanovic <milanmilanov...@yahoo.com> wrote: > > I'm not sure too, just because of that I'm asking you this :-). > > > Paweł Wielgus wrote: >> >> Then You definitively should read the servlet specs, >> i'm not sure if servletContext is present or real under junit - is it? >> >> Best greetings, >> Paweł Wielgus. >> >> 2008/12/17 Milan Milanovic <milanmilanov...@yahoo.com>: >>> >>> No, I'm runing test from my Eclipse 3.3 environment (right click to class >>> -> >>> Run As -> JUnit 4 test). >>> >>> >>> Paweł Wielgus wrote: >>>> >>>> Hi Milan, >>>> are You running your app from war file? >>>> If yes, servletContext.getRealPath(...) might not work, >>>> if i remember it correct, it is in servlet specification. >>>> >>>> Best greetings, >>>> Paweł Wielgus. >>>> >>>> 2008/12/17 Milan Milanovic <milanmilanov...@yahoo.com>: >>>>> >>>>> I tried to set location programatically, and from my test I tried to >>>>> set >>>>> different paths, e.g.: "WebContent/reports/" and >>>>> "\\WebContet\\reports\\", >>>>> but every time I get FileNotFoundException from >>>>> servletContext.getRealPath(...) method. >>>>> >>>>> >>>>> Milan Milanovic wrote: >>>>>> >>>>>> Hi, >>>>>> >>>>>> I have defined a following Struts 2 action which show one simple PDF >>>>>> report: >>>>>> >>>>>> <action name="showReport" method="showReport" class="ReportAction"> >>>>>> <result name="success" type="jasper"> >>>>>> /reports/MainReport.jasper >>>>>> parameters >>>>>> connection >>>>>> PDF >>>>>> </result> >>>>>> </action> >>>>>> >>>>>> And I'm trying to test with JUnit 4 this action by using >>>>>> BaseStrutsTestCase class ( >>>>>> http://depressedprogrammer.wordpress.com/2007/06/18/unit-testing-struts-2-actions-spring-junit/ >>>>>> http://depressedprogrammer.wordpress.com/2007/06/18/unit-testing-struts-2-actions-spring-junit/ >>>>>> ). But I have a problem because JasperReportsResult is trying to find >>>>>> location of my report by using finalLocation parameter of its >>>>>> doExecute(...) method. The problem is that this file is not found >>>>>> during >>>>>> test, while, when application is running on server IT IS found. So, >>>>>> how >>>>>> can I solve this problem, i.e., how to pass correct location to >>>>>> doExecute >>>>>> method of JasperReportsResult during Junit test, or maybe I can pass >>>>>> this >>>>>> somehow ? >>>>>> >>>>>> -- >>>>>> Thx, M. >>>>>> >>>>> >>>>> -- >>>>> View this message in context: >>>>> http://www.nabble.com/-S2--Problem-with-testing-S2-Action-when-JasperResult-type-is-used-tp21037498p21054572.html >>>>> Sent from the Struts - User mailing list archive at Nabble.com. >>>>> >>>>> >>>>> --------------------------------------------------------------------- >>>>> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org >>>>> For additional commands, e-mail: user-h...@struts.apache.org >>>>> >>>>> >>>> >>>> >>> >>> -- >>> View this message in context: >>> http://www.nabble.com/-S2--Problem-with-testing-S2-Action-when-JasperResult-type-is-used-tp21037498p21056441.html >>> Sent from the Struts - User mailing list archive at Nabble.com. >>> >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org >>> For additional commands, e-mail: user-h...@struts.apache.org >>> >>> >> >> > > -- > View this message in context: > http://www.nabble.com/-S2--Problem-with-testing-S2-Action-when-JasperResult-type-is-used-tp21037498p21057142.html > Sent from the Struts - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > >