<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">&lt;<a href="mailto:pedro@infinispan.org" target="_blank">pedro@infinispan.org</a>&gt;</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>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; On Tue, May 14, 2013 at 11:51 AM, Pedro Ruivo &lt;<a href="mailto:pedro@infinispan.org">pedro@infinispan.org</a><br>
</div><div class="im">&gt; &lt;mailto:<a href="mailto:pedro@infinispan.org">pedro@infinispan.org</a>&gt;&gt; wrote:<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;     On 05/14/2013 09:44 AM, Dan Berindei wrote:<br>
&gt;      &gt;<br>
&gt;      &gt;<br>
&gt;      &gt;<br>
&gt;      &gt; On Tue, May 14, 2013 at 11:37 AM, Manik Surtani<br>
&gt;     &lt;<a href="mailto:msurtani@redhat.com">msurtani@redhat.com</a> &lt;mailto:<a href="mailto:msurtani@redhat.com">msurtani@redhat.com</a>&gt;<br>
</div><div class="im">&gt;      &gt; &lt;mailto:<a href="mailto:msurtani@redhat.com">msurtani@redhat.com</a> &lt;mailto:<a href="mailto:msurtani@redhat.com">msurtani@redhat.com</a>&gt;&gt;&gt; wrote:<br>
&gt;      &gt;<br>
&gt;      &gt;<br>
&gt;      &gt;     On 14 May 2013, at 08:33, Dan Berindei<br>
&gt;     &lt;<a href="mailto:dan.berindei@gmail.com">dan.berindei@gmail.com</a> &lt;mailto:<a href="mailto:dan.berindei@gmail.com">dan.berindei@gmail.com</a>&gt;<br>
</div>&gt;      &gt;     &lt;mailto:<a href="mailto:dan.berindei@gmail.com">dan.berindei@gmail.com</a><br>
<div><div class="h5">&gt;     &lt;mailto:<a href="mailto:dan.berindei@gmail.com">dan.berindei@gmail.com</a>&gt;&gt;&gt; wrote:<br>
&gt;      &gt;<br>
&gt;      &gt;&gt;     If we want to keep it hidden, then I think it would be best to<br>
&gt;      &gt;&gt;     leave the getTimeService() method only in<br>
&gt;      &gt;&gt;     ComponentRegistry/GlobalComponentRegistry and remove it from the<br>
&gt;      &gt;&gt;     AdvancedCache interface.<br>
&gt;      &gt;<br>
&gt;      &gt;     +1.<br>
&gt;<br>
&gt;     first I have two situations here:<br>
&gt;<br>
&gt;     in production: it&#39;s indifferent for me have it in the AdvancedCache or<br>
&gt;     in the ComponentRegistry, in the cache loader/store and in the Extended<br>
&gt;     Stats I have access to the cache and I can pick from everywhere.<br>
&gt;<br>
&gt;     in the test suite: I first try to have it only in the ComponentRegistry<br>
&gt;     and I was not be able to mock it because the class is final (I believe<br>
&gt;     that is final for some reason). In addition, all the cache store tests<br>
&gt;     mocks the Cache interface. That&#39;s why I put it in the AdvancedCache.<br>
&gt;<br>
&gt;<br>
&gt; Yeah, being able to inject the TimeService directly in the cache store<br>
&gt; would have been nice :)<br>
&gt; I think we can remove the final modifier from the ComponentRegistry<br>
&gt; class, though.<br>
&gt;<br>
&gt;      &gt;<br>
&gt;      &gt;&gt;     We might want to remove it from the configuration, too.<br>
&gt;      &gt;<br>
&gt;      &gt;     It is definitely *not* configurable and *not* a part of the<br>
&gt;      &gt;     configuration.  See an earlier thread on this subject:<br>
&gt;      &gt; <a href="http://bit.ly/102aQ9R" target="_blank">http://bit.ly/102aQ9R</a><br>
&gt;<br>
&gt;     This is another issue I have. I need to have the TimeService in the<br>
&gt;     Extended Stats and this are a CustomInterceptor. My first try was to<br>
&gt;     replace and rewire the GlobalComponent but this does not work because I<br>
&gt;     don&#39;t have any @Inject method in the CustomInterceptor where I can<br>
&gt;     replace for TimeService implementation in the test suite. That&#39;s why it<br>
&gt;     is in the GlobalConfiguration.<br>
&gt;<br>
&gt;<br>
&gt; cache.getAdvancedCache().getComponentRegistry().getTimeService() should<br>
&gt; work in a custom interceptor.<br>
&gt; 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&#39;m not able to test<br>
the statistics. Even if I register and rewire the ComponentRegistry,<br>
does not work because I&#39;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>