You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by Dennis Byrne <de...@dbyrne.net> on 2006/08/21 06:00:30 UTC

Re: How to configure the default renderers and component within a Shale-Test based unit test

I would be suprised if you found a quick and easy way to do this. MyFaces core uses digester to unmarshal the config files.  It then calls the API you mention. I would start digging around in org.apache.myfaces.config .

Dennis Byrne

>-----Original Message-----
>From: Paul Spencer [mailto:paulsp@apache.org]
>Sent: Sunday, August 20, 2006 11:42 PM
>To: 'MyFaces Development'
>Subject: How to configure the default renderers and component within a Shale-Test based unit test
>
>I am writing a unit test based on the Shale Test Framework for a Tomahawk
>component.  My current problem is the I need to add the default MyFaces and
>Tomahawk components and renderers to the FacesContext. To date I have been
>using facesContext.getApplication().addComponent(...) and
>facesContext.getRenderKit().addRenderer(...).  This is becoming very
>cumbersome.  I know the defaults are out their in various configuration files,
>but I do not know how to tell Shale's test framework how to use them.
>
>Suggestions?
>
>Paul Spencer
>
>



Re: How to configure the default renderers and component within a Shale-Test based unit test

Posted by Craig McClanahan <cr...@apache.org>.
On 8/20/06, Dennis Byrne <de...@dbyrne.net> wrote:
>
> I would be suprised if you found a quick and easy way to do this. MyFaces
> core uses digester to unmarshal the config files.  It then calls the API you
> mention. I would start digging around in org.apache.myfaces.config .


One aggressive approach you might consider is to set up a directory
structure that looks like a webapp, and then fire off the real MyFaces
context listener that initializes things.  It would tie you using the
MyFaces implementation for your tests, but it would pre-initialize all that
stuff.  (I haven't tried this myself, so it might also run into cases where
the mock objects need some extended behavior ... but i'd certainly be open
to improving the test library so that it enables this use case.)

A more conservative approach would be to build an abstract base test case
that did the manual configuration operations (as you are doing them), for
the combination of components that you want to test, in its setUp() method.
At least that way, you'd only have to write them once.

Dennis Byrne


Craig

>-----Original Message-----
> >From: Paul Spencer [mailto:paulsp@apache.org]
> >Sent: Sunday, August 20, 2006 11:42 PM
> >To: 'MyFaces Development'
> >Subject: How to configure the default renderers and component within a
> Shale-Test based unit test
> >
> >I am writing a unit test based on the Shale Test Framework for a Tomahawk
> >component.  My current problem is the I need to add the default MyFaces
> and
> >Tomahawk components and renderers to the FacesContext. To date I have
> been
> >using facesContext.getApplication().addComponent(...) and
> >facesContext.getRenderKit().addRenderer(...).  This is becoming very
> >cumbersome.  I know the defaults are out their in various configuration
> files,
> >but I do not know how to tell Shale's test framework how to use them.
> >
> >Suggestions?
> >
> >Paul Spencer
> >
> >
>
>
>

Re: Re: How to configure the default renderers and component within a Shale-Test based unit test

Posted by Adam Winer <aw...@gmail.com>.
One might also have a look at the Trinidad RenderKit test framework,
which does a lot of work to make writing unit tests for renderers
oh so trivial, including parsing faces-config.xmls on the classpath.

http://wiki.apache.org/myfaces/Trinidad_RenderKit_test_framework

-- Adam


On 8/20/06, Dennis Byrne <de...@dbyrne.net> wrote:
> I would be suprised if you found a quick and easy way to do this. MyFaces core uses digester to unmarshal the config files.  It then calls the API you mention. I would start digging around in org.apache.myfaces.config .
>
> Dennis Byrne
>
> >-----Original Message-----
> >From: Paul Spencer [mailto:paulsp@apache.org]
> >Sent: Sunday, August 20, 2006 11:42 PM
> >To: 'MyFaces Development'
> >Subject: How to configure the default renderers and component within a Shale-Test based unit test
> >
> >I am writing a unit test based on the Shale Test Framework for a Tomahawk
> >component.  My current problem is the I need to add the default MyFaces and
> >Tomahawk components and renderers to the FacesContext. To date I have been
> >using facesContext.getApplication().addComponent(...) and
> >facesContext.getRenderKit().addRenderer(...).  This is becoming very
> >cumbersome.  I know the defaults are out their in various configuration files,
> >but I do not know how to tell Shale's test framework how to use them.
> >
> >Suggestions?
> >
> >Paul Spencer
> >
> >
>
>
>