You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Stephan Schwab <sn...@caimito.net> on 2008/12/04 07:28:09 UTC

IoC registry survives between JUnit tests?

Hi!

I have several JUnit tests that instantiate
org.apache.tapestry5.ioc.Registry via the RegistryBuilder before tests run.
Now I'm observing that services registered in one test are still available
in other tests although I did call registry.shutdown(). My test runner does
not fork a new JVM.

Calling registry.shutdown() should cause everything to vanish. Is there
anything that causes one-registry-per-JVM?

Stephan



-----
--
http://www.caimito.net - Caimito One Team - Agile Collaboration and Planning
tool
http://www.stephan-schwab.com - Personal blog
http://code.google.com/p/tapestry-sesame - Authentication extension for
Tapestry 5

-- 
View this message in context: http://www.nabble.com/IoC-registry-survives-between-JUnit-tests--tp20828078p20828078.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: IoC registry survives between JUnit tests?

Posted by Christian Edward Gruber <ch...@gmail.com>.
Ah.  Got it.

Christian.

On 4-Dec-08, at 21:41 , Howard Lewis Ship wrote:

> My point was that it was possible the IoC was being re-initialized on
> each test and it wasn't noticeable because its very fast.
>
> On Thu, Dec 4, 2008 at 12:39 PM, Christian Edward Gruber
> <ch...@gmail.com> wrote:
>> Oh, not a critique of startup or shutdown performance on T5-ioc,  
>> but more of
>> a general principle of unit testing components that participate in  
>> any IoC
>> container.  To test the component, you shouldn't need to use the  
>> container,
>> because it's a "unit" test.  But he said he was testing the wiring  
>> between
>> components anyway, rather than the functionality of the units, so  
>> my comment
>> isn't as relevant.
>>
>> Christian.
>>
>> On 4-Dec-08, at 15:23 , Howard Lewis Ship wrote:
>>
>>> I use a mix of techniques, using a lot of mocks for true unit tests,
>>> but also a lot of integration tests.
>>>
>>> I'm not sure what CEG has actually seen here; Registry.shutdown() is
>>> very dramatic, it tears apart the registry (releasing almost
>>> everything to the GC) and informs all of the proxies to shutdown as
>>> well.  Could he just be missing the re-creation of the services in
>>> later tests ... Registry startup is very, very fast once all the
>>> underlying classes are instantiated.
>>>
>>> On Thu, Dec 4, 2008 at 12:04 PM, Christian Edward Gruber
>>> <ch...@gmail.com> wrote:
>>>>
>>>> FYI, in general, you shouldn't be using the container in your  
>>>> tests,
>>>> unless
>>>> you're testing the wiring itself.  You should be creating the
>>>> component/service under test, and constructing it with fakes.   
>>>> This isn't
>>>> absolute but there is a lot more effort/configuration/overhead if  
>>>> you
>>>> want
>>>> to use the container infrastructure in your unit test, and you  
>>>> start to
>>>> have
>>>> subtle interactions that might potentially make it more of an  
>>>> integration
>>>> test.  You risk testing more than one thing at a time.
>>>>
>>>> Christian
>>>>
>>>> On 4-Dec-08, at 01:28 , Stephan Schwab wrote:
>>>>
>>>>>
>>>>> Hi!
>>>>>
>>>>> I have several JUnit tests that instantiate
>>>>> org.apache.tapestry5.ioc.Registry via the RegistryBuilder before  
>>>>> tests
>>>>> run.
>>>>> Now I'm observing that services registered in one test are still
>>>>> available
>>>>> in other tests although I did call registry.shutdown(). My test  
>>>>> runner
>>>>> does
>>>>> not fork a new JVM.
>>>>>
>>>>> Calling registry.shutdown() should cause everything to vanish.  
>>>>> Is there
>>>>> anything that causes one-registry-per-JVM?
>>>>>
>>>>> Stephan
>>>>>
>>>>>
>>>>>
>>>>> -----
>>>>> --
>>>>> http://www.caimito.net - Caimito One Team - Agile Collaboration  
>>>>> and
>>>>> Planning
>>>>> tool
>>>>> http://www.stephan-schwab.com - Personal blog
>>>>> http://code.google.com/p/tapestry-sesame - Authentication  
>>>>> extension for
>>>>> Tapestry 5
>>>>>
>>>>> --
>>>>> View this message in context:
>>>>>
>>>>> http://www.nabble.com/IoC-registry-survives-between-JUnit-tests--tp20828078p20828078.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
>>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> 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
>>>
>>
>>
>> ---------------------------------------------------------------------
>> 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
>


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


Re: IoC registry survives between JUnit tests?

Posted by Howard Lewis Ship <hl...@gmail.com>.
My point was that it was possible the IoC was being re-initialized on
each test and it wasn't noticeable because its very fast.

On Thu, Dec 4, 2008 at 12:39 PM, Christian Edward Gruber
<ch...@gmail.com> wrote:
> Oh, not a critique of startup or shutdown performance on T5-ioc, but more of
> a general principle of unit testing components that participate in any IoC
> container.  To test the component, you shouldn't need to use the container,
> because it's a "unit" test.  But he said he was testing the wiring between
> components anyway, rather than the functionality of the units, so my comment
> isn't as relevant.
>
> Christian.
>
> On 4-Dec-08, at 15:23 , Howard Lewis Ship wrote:
>
>> I use a mix of techniques, using a lot of mocks for true unit tests,
>> but also a lot of integration tests.
>>
>> I'm not sure what CEG has actually seen here; Registry.shutdown() is
>> very dramatic, it tears apart the registry (releasing almost
>> everything to the GC) and informs all of the proxies to shutdown as
>> well.  Could he just be missing the re-creation of the services in
>> later tests ... Registry startup is very, very fast once all the
>> underlying classes are instantiated.
>>
>> On Thu, Dec 4, 2008 at 12:04 PM, Christian Edward Gruber
>> <ch...@gmail.com> wrote:
>>>
>>> FYI, in general, you shouldn't be using the container in your tests,
>>> unless
>>> you're testing the wiring itself.  You should be creating the
>>> component/service under test, and constructing it with fakes.  This isn't
>>> absolute but there is a lot more effort/configuration/overhead if you
>>> want
>>> to use the container infrastructure in your unit test, and you start to
>>> have
>>> subtle interactions that might potentially make it more of an integration
>>> test.  You risk testing more than one thing at a time.
>>>
>>> Christian
>>>
>>> On 4-Dec-08, at 01:28 , Stephan Schwab wrote:
>>>
>>>>
>>>> Hi!
>>>>
>>>> I have several JUnit tests that instantiate
>>>> org.apache.tapestry5.ioc.Registry via the RegistryBuilder before tests
>>>> run.
>>>> Now I'm observing that services registered in one test are still
>>>> available
>>>> in other tests although I did call registry.shutdown(). My test runner
>>>> does
>>>> not fork a new JVM.
>>>>
>>>> Calling registry.shutdown() should cause everything to vanish. Is there
>>>> anything that causes one-registry-per-JVM?
>>>>
>>>> Stephan
>>>>
>>>>
>>>>
>>>> -----
>>>> --
>>>> http://www.caimito.net - Caimito One Team - Agile Collaboration and
>>>> Planning
>>>> tool
>>>> http://www.stephan-schwab.com - Personal blog
>>>> http://code.google.com/p/tapestry-sesame - Authentication extension for
>>>> Tapestry 5
>>>>
>>>> --
>>>> View this message in context:
>>>>
>>>> http://www.nabble.com/IoC-registry-survives-between-JUnit-tests--tp20828078p20828078.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
>>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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
>>
>
>
> ---------------------------------------------------------------------
> 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: IoC registry survives between JUnit tests?

Posted by Christian Edward Gruber <ch...@gmail.com>.
Oh, not a critique of startup or shutdown performance on T5-ioc, but  
more of a general principle of unit testing components that  
participate in any IoC container.  To test the component, you  
shouldn't need to use the container, because it's a "unit" test.  But  
he said he was testing the wiring between components anyway, rather  
than the functionality of the units, so my comment isn't as relevant.

Christian.

On 4-Dec-08, at 15:23 , Howard Lewis Ship wrote:

> I use a mix of techniques, using a lot of mocks for true unit tests,
> but also a lot of integration tests.
>
> I'm not sure what CEG has actually seen here; Registry.shutdown() is
> very dramatic, it tears apart the registry (releasing almost
> everything to the GC) and informs all of the proxies to shutdown as
> well.  Could he just be missing the re-creation of the services in
> later tests ... Registry startup is very, very fast once all the
> underlying classes are instantiated.
>
> On Thu, Dec 4, 2008 at 12:04 PM, Christian Edward Gruber
> <ch...@gmail.com> wrote:
>> FYI, in general, you shouldn't be using the container in your  
>> tests, unless
>> you're testing the wiring itself.  You should be creating the
>> component/service under test, and constructing it with fakes.  This  
>> isn't
>> absolute but there is a lot more effort/configuration/overhead if  
>> you want
>> to use the container infrastructure in your unit test, and you  
>> start to have
>> subtle interactions that might potentially make it more of an  
>> integration
>> test.  You risk testing more than one thing at a time.
>>
>> Christian
>>
>> On 4-Dec-08, at 01:28 , Stephan Schwab wrote:
>>
>>>
>>> Hi!
>>>
>>> I have several JUnit tests that instantiate
>>> org.apache.tapestry5.ioc.Registry via the RegistryBuilder before  
>>> tests
>>> run.
>>> Now I'm observing that services registered in one test are still  
>>> available
>>> in other tests although I did call registry.shutdown(). My test  
>>> runner
>>> does
>>> not fork a new JVM.
>>>
>>> Calling registry.shutdown() should cause everything to vanish. Is  
>>> there
>>> anything that causes one-registry-per-JVM?
>>>
>>> Stephan
>>>
>>>
>>>
>>> -----
>>> --
>>> http://www.caimito.net - Caimito One Team - Agile Collaboration and
>>> Planning
>>> tool
>>> http://www.stephan-schwab.com - Personal blog
>>> http://code.google.com/p/tapestry-sesame - Authentication  
>>> extension for
>>> Tapestry 5
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/IoC-registry-survives-between-JUnit-tests--tp20828078p20828078.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
>>>
>>
>>
>> ---------------------------------------------------------------------
>> 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
>


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


Re: IoC registry survives between JUnit tests?

Posted by Howard Lewis Ship <hl...@gmail.com>.
I use a mix of techniques, using a lot of mocks for true unit tests,
but also a lot of integration tests.

I'm not sure what CEG has actually seen here; Registry.shutdown() is
very dramatic, it tears apart the registry (releasing almost
everything to the GC) and informs all of the proxies to shutdown as
well.  Could he just be missing the re-creation of the services in
later tests ... Registry startup is very, very fast once all the
underlying classes are instantiated.

On Thu, Dec 4, 2008 at 12:04 PM, Christian Edward Gruber
<ch...@gmail.com> wrote:
> FYI, in general, you shouldn't be using the container in your tests, unless
> you're testing the wiring itself.  You should be creating the
> component/service under test, and constructing it with fakes.  This isn't
> absolute but there is a lot more effort/configuration/overhead if you want
> to use the container infrastructure in your unit test, and you start to have
> subtle interactions that might potentially make it more of an integration
> test.  You risk testing more than one thing at a time.
>
> Christian
>
> On 4-Dec-08, at 01:28 , Stephan Schwab wrote:
>
>>
>> Hi!
>>
>> I have several JUnit tests that instantiate
>> org.apache.tapestry5.ioc.Registry via the RegistryBuilder before tests
>> run.
>> Now I'm observing that services registered in one test are still available
>> in other tests although I did call registry.shutdown(). My test runner
>> does
>> not fork a new JVM.
>>
>> Calling registry.shutdown() should cause everything to vanish. Is there
>> anything that causes one-registry-per-JVM?
>>
>> Stephan
>>
>>
>>
>> -----
>> --
>> http://www.caimito.net - Caimito One Team - Agile Collaboration and
>> Planning
>> tool
>> http://www.stephan-schwab.com - Personal blog
>> http://code.google.com/p/tapestry-sesame - Authentication extension for
>> Tapestry 5
>>
>> --
>> View this message in context:
>> http://www.nabble.com/IoC-registry-survives-between-JUnit-tests--tp20828078p20828078.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
>>
>
>
> ---------------------------------------------------------------------
> 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: IoC registry survives between JUnit tests?

Posted by Stephan Schwab <sn...@caimito.net>.

Christian Edward Gruber-2 wrote:
> 
> FYI, in general, you shouldn't be using the container in your tests,  
> unless you're testing the wiring itself.  You should be creating the  
> component/service under test, and constructing it with fakes.  This  
> isn't absolute but there is a lot more effort/configuration/overhead  
> if you want to use the container infrastructure in your unit test, and  
> you start to have subtle interactions that might potentially make it  
> more of an integration test.  You risk testing more than one thing at  
> a time.
> 

It was about the wiring what I wanted to achieve. Not really a *unit* test.
The approach is a bit similar as to what the PageTester does. As background
info: I'm using Tapestry IoC outside of a Tapestry web application.

-----
--
http://www.caimito.net - Caimito One Team - Agile Collaboration and Planning
tool
http://www.stephan-schwab.com - Personal blog
http://code.google.com/p/tapestry-sesame - Authentication extension for
Tapestry 5

-- 
View this message in context: http://www.nabble.com/IoC-registry-survives-between-JUnit-tests--tp20828078p20841474.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: IoC registry survives between JUnit tests?

Posted by Christian Edward Gruber <ch...@gmail.com>.
FYI, in general, you shouldn't be using the container in your tests,  
unless you're testing the wiring itself.  You should be creating the  
component/service under test, and constructing it with fakes.  This  
isn't absolute but there is a lot more effort/configuration/overhead  
if you want to use the container infrastructure in your unit test, and  
you start to have subtle interactions that might potentially make it  
more of an integration test.  You risk testing more than one thing at  
a time.

Christian

On 4-Dec-08, at 01:28 , Stephan Schwab wrote:

>
> Hi!
>
> I have several JUnit tests that instantiate
> org.apache.tapestry5.ioc.Registry via the RegistryBuilder before  
> tests run.
> Now I'm observing that services registered in one test are still  
> available
> in other tests although I did call registry.shutdown(). My test  
> runner does
> not fork a new JVM.
>
> Calling registry.shutdown() should cause everything to vanish. Is  
> there
> anything that causes one-registry-per-JVM?
>
> Stephan
>
>
>
> -----
> --
> http://www.caimito.net - Caimito One Team - Agile Collaboration and  
> Planning
> tool
> http://www.stephan-schwab.com - Personal blog
> http://code.google.com/p/tapestry-sesame - Authentication extension  
> for
> Tapestry 5
>
> -- 
> View this message in context: http://www.nabble.com/IoC-registry-survives-between-JUnit-tests--tp20828078p20828078.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
>


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


Re: IoC registry survives between JUnit tests?

Posted by Stephan Schwab <sn...@caimito.net>.
Never mind. Apparently it's too late and I don't see my own mistakes. Sorry
for wasting bandwidth.

-----
--
http://www.caimito.net - Caimito One Team - Agile Collaboration and Planning
tool
http://www.stephan-schwab.com - Personal blog
http://code.google.com/p/tapestry-sesame - Authentication extension for
Tapestry 5

-- 
View this message in context: http://www.nabble.com/IoC-registry-survives-between-JUnit-tests--tp20828078p20828173.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