<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, May 14, 2013 at 12:38 PM, Pedro Ruivo <span dir="ltr"><<a href="mailto:pedro@infinispan.org" target="_blank">pedro@infinispan.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="im"><br>
<br>
On 05/14/2013 10:31 AM, Dan Berindei wrote:<br>
><br>
><br>
><br>
> On Tue, May 14, 2013 at 11:51 AM, Pedro Ruivo <<a href="mailto:pedro@infinispan.org">pedro@infinispan.org</a><br>
</div><div class="im">> <mailto:<a href="mailto:pedro@infinispan.org">pedro@infinispan.org</a>>> wrote:<br>
><br>
><br>
><br>
> On 05/14/2013 09:44 AM, Dan Berindei wrote:<br>
> ><br>
> ><br>
> ><br>
> > On Tue, May 14, 2013 at 11:37 AM, Manik Surtani<br>
> <<a href="mailto:msurtani@redhat.com">msurtani@redhat.com</a> <mailto:<a href="mailto:msurtani@redhat.com">msurtani@redhat.com</a>><br>
</div><div class="im">> > <mailto:<a href="mailto:msurtani@redhat.com">msurtani@redhat.com</a> <mailto:<a href="mailto:msurtani@redhat.com">msurtani@redhat.com</a>>>> wrote:<br>
> ><br>
> ><br>
> > On 14 May 2013, at 08:33, Dan Berindei<br>
> <<a href="mailto:dan.berindei@gmail.com">dan.berindei@gmail.com</a> <mailto:<a href="mailto:dan.berindei@gmail.com">dan.berindei@gmail.com</a>><br>
</div>> > <mailto:<a href="mailto:dan.berindei@gmail.com">dan.berindei@gmail.com</a><br>
<div><div class="h5">> <mailto:<a href="mailto:dan.berindei@gmail.com">dan.berindei@gmail.com</a>>>> wrote:<br>
> ><br>
> >> If we want to keep it hidden, then I think it would be best to<br>
> >> leave the getTimeService() method only in<br>
> >> ComponentRegistry/GlobalComponentRegistry and remove it from the<br>
> >> AdvancedCache interface.<br>
> ><br>
> > +1.<br>
><br>
> first I have two situations here:<br>
><br>
> in production: it's indifferent for me have it in the AdvancedCache or<br>
> in the ComponentRegistry, in the cache loader/store and in the Extended<br>
> Stats I have access to the cache and I can pick from everywhere.<br>
><br>
> in the test suite: I first try to have it only in the ComponentRegistry<br>
> and I was not be able to mock it because the class is final (I believe<br>
> that is final for some reason). In addition, all the cache store tests<br>
> mocks the Cache interface. That's why I put it in the AdvancedCache.<br>
><br>
><br>
> Yeah, being able to inject the TimeService directly in the cache store<br>
> would have been nice :)<br>
> I think we can remove the final modifier from the ComponentRegistry<br>
> class, though.<br>
><br>
> ><br>
> >> We might want to remove it from the configuration, too.<br>
> ><br>
> > It is definitely *not* configurable and *not* a part of the<br>
> > configuration. See an earlier thread on this subject:<br>
> > <a href="http://bit.ly/102aQ9R" target="_blank">http://bit.ly/102aQ9R</a><br>
><br>
> This is another issue I have. I need to have the TimeService in the<br>
> Extended Stats and this are a CustomInterceptor. My first try was to<br>
> replace and rewire the GlobalComponent but this does not work because I<br>
> don't have any @Inject method in the CustomInterceptor where I can<br>
> replace for TimeService implementation in the test suite. That's why it<br>
> is in the GlobalConfiguration.<br>
><br>
><br>
> cache.getAdvancedCache().getComponentRegistry().getTimeService() should<br>
> work in a custom interceptor.<br>
> You just have to mock the cache and the component registry...<br>
<br>
</div></div>I cannot mock the cache in the test suite otherwise I'm not able to test<br>
the statistics. Even if I register and rewire the ComponentRegistry,<br>
does not work because I'm setting the TimeService when the start() is<br>
invoked.<br>
<div class=""><div class="h5"><br></div></div></blockquote><div><br></div><div>Ok, I think I understand the problem now, and the simplest solution would be to use TestingUtil.replaceField to replace the TimeService in your interceptor with a mock.<br>
</div><div><br></div><div><br></div></div><br></div></div>