You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Angelo Chen <an...@yahoo.com.hk> on 2009/02/14 16:12:38 UTC

T5: PageTester and services in AppModule

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-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5: PageTester and services in AppModule

Posted by manuel aldana <al...@gmx.de>.
5.1 is not released yet. In maven terminology often SNAPSHOTS are used.

You have to pass:

<tapestry-release-version>5.1.0.0-SNAPSHOT</tapestry-release-version>



Angelo Chen schrieb:
> Hi Howard,
>
> Sounds good, is 5.1 as stable as 5.0.18? I did:
>
>  <tapestry-release-version>5.1</tapestry-release-version>
>
> but it did not pull down the 5.1, any idea? thanks.
>
>
> 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 <an...@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-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>>       
>>
>> -- 
>> Howard M. Lewis Ship
>>
>> Creator Apache Tapestry and Apache HiveMind
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>>
>>     
>
>   


-- 
 manuel aldana
 aldana@gmx.de
 software-engineering blog: http://www.aldana-online.de


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


Re: T5: PageTester and services in AppModule

Posted by Howard Lewis Ship <hl...@gmail.com>.
5.1.0.0-SNAPSHOT

On Sat, Feb 14, 2009 at 4:19 PM, Angelo Chen <an...@yahoo.com.hk> wrote:
>
> Hi Howard,
>
> Sounds good, is 5.1 as stable as 5.0.18? I did:
>
>  <tapestry-release-version>5.1</tapestry-release-version>
>
> but it did not pull down the 5.1, any idea? thanks.
>
>
> 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 <an...@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-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>
>>
>>
>> --
>> Howard M. Lewis Ship
>>
>> Creator Apache Tapestry and Apache HiveMind
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/T5%3A-PageTester-and-services-in-AppModule-tp22013582p22018650.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
Howard M. Lewis Ship

Creator Apache Tapestry and Apache HiveMind

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


Re: T5: PageTester and services in AppModule

Posted by Angelo Chen <an...@yahoo.com.hk>.
Hi Howard,

Sounds good, is 5.1 as stable as 5.0.18? I did:

 <tapestry-release-version>5.1</tapestry-release-version>

but it did not pull down the 5.1, any idea? thanks.


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 <an...@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-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
> 
> 
> 
> -- 
> Howard M. Lewis Ship
> 
> Creator Apache Tapestry and Apache HiveMind
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

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


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


Re: T5: PageTester and services in AppModule

Posted by Angelo Chen <an...@yahoo.com.hk>.
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 <an...@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-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
> 
> 
> 
> -- 
> Howard M. Lewis Ship
> 
> Creator Apache Tapestry and Apache HiveMind
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@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-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5: PageTester and services in AppModule

Posted by Howard Lewis Ship <hl...@gmail.com>.
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 <an...@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-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
Howard M. Lewis Ship

Creator Apache Tapestry and Apache HiveMind

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