[webbeans-dev] TCK Tests - Dependent Context Activation

David Allen drallendc at gmail.com
Mon Mar 2 09:20:11 EST 2009


On Mon, 2009-03-02 at 03:27 -0800, Gurkan Erdogdu wrote:
> Hi;
> 
> org/jboss/jsr299/tck/tests/context/dependent/DependentContextTest.java, 
> 
> @Test(groups = { "contexts", "observerMethod" })
>    @SpecAssertion(section = "8.3", id = "g")
>    public void testContextIsActiveWhenInvokingObserverMethod()
>    {
>       getCurrentManager().fireEvent(new HorseInStableEvent());
>       assert HorseStable.isDependentContextActive();
>    }
> 

This test was testing the same thing as the one below, so it has been
changed and renamed to
testContextIsActiveWhenCreatingObserverMethodInstance.  Now it properly
tests the condition from the specification that states:

The @Dependent scope is inactive except:
•  when an instance of a bean with scope @Dependent is created by the
container to receive a producer method, producer
   field, disposal method or observer method invocation, or

> @Test(groups = { "contexts", "observerMethod" })
>    @SpecAssertion(section = "8.3", id = "i")
>    public void testContextIsActiveWhenInvokingObserver()
>    {
>       getCurrentManager().fireEvent(new HorseInStableEvent());
>       assert ApplicationHorseStable.isDependentContextActive();
>    }

This test is correct and verifies that the dependent context is active
while the observer method is called, not after fireEvent().  The
isDependentContextActive() method is not checking at that moment, but
checking whether it was active when the event was fired.


> I think that after the Observer#notify method [calling the HorseStable
> or ApplicationHorseStable observer methods], Dependent context will be
> destroyed.

Yes, this is correct, but does not actually have anything to do with
these tests since the dependentContextActive member was set while the
observer method was executed, not while it is queried.

> 
> Gurkan
> 
> 
> 
> ______________________________________________________________________
> From: David Allen <drallendc at gmail.com>
> To: Gurkan Erdogdu <gurkanerdogdu at yahoo.com>
> Cc: Gavin King <gavin at hibernate.org>;
> openwebbeans-dev at incubator.apache.org; webbeans-dev at lists.jboss.org
> Sent: Monday, March 2, 2009 12:36:35 PM
> Subject: Re: [webbeans-dev] TCK Tests - Dependent Context Activation
> 
> On Sun, 2009-03-01 at 23:02 -0800, Gurkan Erdogdu wrote:
> > Thanks for answering Gavin. 
> > Then, we can not pass the TCK test if we use Observer#notify :)
> > 
> Which test in the TCK are you referring to?
> 
> > 
> > 
> >
> ______________________________________________________________________
> > From: Gavin King <gavin at hibernate.org>
> > To: Gurkan Erdogdu <gurkanerdogdu at yahoo.com>
> > Cc: webbeans-dev at lists.jboss.org
> > Sent: Sunday, March 1, 2009 11:25:06 PM
> > Subject: Re: [webbeans-dev] TCK Tests - Dependent Context Activation
> > 
> > Well, the spec says "observer method". It doesn't say anything about
> > other observers. So It would be perfectly fine to do it in the
> > notify() method, but not wrong to do it form fireEvent().
> > 
> > On Sat, Feb 28, 2009 at 4:01 PM, Gurkan Erdogdu
> > <gurkanerdogdu at yahoo.com> wrote:
> > > Hi;
> > >
> > > Specification states that  depending context is active --> "while
> an
> > > observer method is invoked", but it does not state that where is
> the
> > > starting point for the activation. In the TCK tests, it is
> activated
> > on the
> > > Manager#fireEvent.
> > >
> > > But currently in the OpenWebBeans project, we activate the
> Dependent
> > Context
> > > at the start of the Observer#notify method.
> > >
> > > Which one is correct?
> > >
> > > Thanks;
> > >
> > > /Gurkan
> > >
> > >
> > > _______________________________________________
> > > webbeans-dev mailing list
> > > webbeans-dev at lists.jboss.org
> > > https://lists.jboss.org/mailman/listinfo/webbeans-dev
> > >
> > >
> > 
> > 
> > 
> > -- 
> > Gavin King
> > gavin.king at gmail.com
> > http://in.relation.to/Bloggers/Gavin
> > http://hibernate.org
> > http://seamframework.org
> > 
> > 
> > _______________________________________________
> > webbeans-dev mailing list
> > webbeans-dev at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/webbeans-dev
> 
> 
> 




More information about the weld-dev mailing list