Hi Howard,

Is getServeletContext considered part of Servlet API? I have following in a
service and got NullPointerException  when calling getServletContext in
T5.1. It seems to me more problems encountered with PageTester when the app
uses services, how to use pageTester to do some real testing is quite
challenging.

Angelo


  final private ApplicationGlobals globals;

    public MyServicesImpl(ApplicationGlobals globals) {
        this.globals = globals;
    }

    public String fileName() {

        String infoName =
globals.getServletContext().getInitParameter("info.file.name");
        return infoName;

    }

Howard Lewis Ship wrote:
> 
> I believe this problem is fixed in 5.1.  I did some major surgery on
> PageTester, and it now simulates the Tapestry Request, Response,
> Session and Context objects (not the Servlet API ones, however). This
> means you can test much more of your application beyond pages,
> including Dispatchers contributed to MasterDispatcher, and other
> filters as well.
> 
> On Sat, Feb 14, 2009 at 7:12 AM, Angelo Chen <angelochen...@yahoo.com.hk>
> wrote:
>>
>> Hi,
>>
>> I'm trying to add some page test into a running application, code is just
>> simple:
>>
>>        PageTester tester = new PageTester(appPackage, appName,
>> "src/main/webapp");
>>        PageTester tester = new PageTester(appPackage, appName,
>> "src/main/webapp");
>>    Document doc = tester.renderPage("Index");
>>
>> but I got an nullPointer exception when MyServices refers to globals:
>>
>>        public MyServicesImp(ApplicationGlobals globals) {
>>                String infoName =
>> globals.getServletContext().getInitParameter("info.file.name");
>>        }
>>
>> adding this into AppModule fix the error:
>>
>> public static void
>> contributeAliasOverrides(Configuration<AliasContribution>
>> conf) {
>>   conf.add(AliasContribution.create(ApplicationGlobals.class,
>> EasyMock.createMock(ApplicationGlobals.class)));
>> }
>>
>> but another error comes out:
>> Caused by: java.lang.RuntimeException: Exception constructing service
>> 'ComponentMessagesSource': Error invoking service builder method
>> org.apache.tapestry5.internal.services.InternalModule.buildComponentMessagesSource(AssetFactory,
>> String) (at InternalModule.java:132) (for service
>> 'ComponentMessagesSource'): Parameter context was null.
>>
>> Any idea how to fix this? is it a good idea to add PageTester to an app
>> that
>> uses a lot of services?
>>
>> Thanks,
>>
>> Angelo
>>
>> --
>> View this message in context:
>> http://www.nabble.com/T5%3A-PageTester-and-services-in-AppModule-tp22013582p22013582.html
>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>> For additional commands, e-mail: users-h...@tapestry.apache.org
>>
>>
> 
> 
> 
> -- 
> Howard M. Lewis Ship
> 
> Creator Apache Tapestry and Apache HiveMind
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/T5%3A-PageTester-and-services-in-AppModule-tp22013582p22020092.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to