You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by Justin Edelson <ju...@helemus.com> on 2010/04/12 23:08:48 UTC

"flushing" the event queue

Is there any good way to flush the event queue in Jackrabbit 2? I'm
trying to do this in the context of an integration test. I can get the
effect I want using SynchronousEventListener, but this creates a
Jackrabbit dependency in a place where their shouldn't be one.

Thanks,
Justin

Re: "flushing" the event queue

Posted by Bertrand Delacretaz <bd...@apache.org>.
On Tue, Apr 13, 2010 at 3:11 PM, Justin Edelson <ju...@gmail.com> wrote:
> On 4/13/10 4:27 AM, Bertrand Delacretaz wrote:
>> Hi Justin,
>>
>> On Mon, Apr 12, 2010 at 11:08 PM, Justin Edelson <ju...@helemus.com> wrote:
>>> Is there any good way to flush the event queue in Jackrabbit 2? I'm
>>> trying to do this in the context of an integration test...
>>
>> The EventHelper class [1] in Sling's jcrinstall test suite allows you
>> to wait until all events have been delivered, by creating a node and
>> waiting for the corresponding events to arrive.
>>
> Thanks Bertrand. This should work.
>
> Any objections to me moving this to commons.testing?

Feel free, sounds like the right thing to do.
-Bertrand

Re: "flushing" the event queue

Posted by Justin Edelson <ju...@gmail.com>.
On 4/13/10 4:27 AM, Bertrand Delacretaz wrote:
> Hi Justin,
> 
> On Mon, Apr 12, 2010 at 11:08 PM, Justin Edelson <ju...@helemus.com> wrote:
>> Is there any good way to flush the event queue in Jackrabbit 2? I'm
>> trying to do this in the context of an integration test...
> 
> The EventHelper class [1] in Sling's jcrinstall test suite allows you
> to wait until all events have been delivered, by creating a node and
> waiting for the corresponding events to arrive.
>
Thanks Bertrand. This should work.

Any objections to me moving this to commons.testing?

Justin


> It assumes that events are delivered in the order they were generated,
> which works so far with Jackrabbit - dunno if the JCR spec mandates
> that.
> 
> -Bertrand
> 
> [1] http://svn.apache.org/repos/asf/sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/EventHelper.java


Re: "flushing" the event queue

Posted by Justin Edelson <ju...@gmail.com>.
On 4/13/10 4:27 AM, Bertrand Delacretaz wrote:
> Hi Justin,
> 
> On Mon, Apr 12, 2010 at 11:08 PM, Justin Edelson <ju...@helemus.com> wrote:
>> Is there any good way to flush the event queue in Jackrabbit 2? I'm
>> trying to do this in the context of an integration test...
> 
> The EventHelper class [1] in Sling's jcrinstall test suite allows you
> to wait until all events have been delivered, by creating a node and
> waiting for the corresponding events to arrive.
> 
> It assumes that events are delivered in the order they were generated,
> which works so far with Jackrabbit - dunno if the JCR spec mandates
> that.
Hmmm. I'm seeing this fail some of the time, i.e. events that have
occurred BEFORE EventHelper.waitForEvents() is called haven't been
processed when that method returns.

It fails about 1/5 of the time.

According to the JCR 2 spec (12.4.1), event order isn't guaranteed.
Perhaps in JR 1.6 (the version against which JCRcInstall is tested), it
was implemented this way, but in JR 2 (the version against which I'm
testing), it isn't.

Bertrand - if you can take a look, I should be checking this code in to
Sling later today.

Thanks,
Justin

> 
> -Bertrand
> 
> [1] http://svn.apache.org/repos/asf/sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/EventHelper.java


Re: "flushing" the event queue

Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi Justin,

On Mon, Apr 12, 2010 at 11:08 PM, Justin Edelson <ju...@helemus.com> wrote:
> Is there any good way to flush the event queue in Jackrabbit 2? I'm
> trying to do this in the context of an integration test...

The EventHelper class [1] in Sling's jcrinstall test suite allows you
to wait until all events have been delivered, by creating a node and
waiting for the corresponding events to arrive.

It assumes that events are delivered in the order they were generated,
which works so far with Jackrabbit - dunno if the JCR spec mandates
that.

-Bertrand

[1] http://svn.apache.org/repos/asf/sling/trunk/installer/jcr/jcrinstall/src/test/java/org/apache/sling/jcr/jcrinstall/impl/EventHelper.java