<div>Hi,</div><div><br></div><div>I&#39;ve written a Junit Runner for Webbeans support in TestCases. The following features are supported:</div><div> - TestCase class field injection</div><div> - TestMethod arg injection</div>
<div> - Producers / Observers in the TestCase seems to work without any extras..</div><div> - &#39;Should&#39; run in any EE/Servlet/SE enviroment (Only SE tested at the moment) </div><div> </div><div><br></div><div>The Runner tries to locate the appropriate BeanManager based on the following rules in order:</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>- Lookup &quot;java:comp/BeanManager&quot; via JNDI -&gt; EE enviroment</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>- If success use that BeanManager. </div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>- Call CurrentManager.rootManager() -&gt; Servlet enviroment / Previously initiated SE enviroment</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>- If success use that BeanManager. </div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>- Load class &quot;org.jboss.webbeans.environment.se.StartMain&quot; -&gt; SE enviroment</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>- If success, initialize the enviroment using StartMain.main(new String[0]) and use CurrentManager.rootManager().</div>
<div><span class="Apple-tab-span" style="white-space:pre">                        </span></div><div><br></div><div>Overrides the default Junit TestMethod validation with a new set of rules:</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>- validatePublicVoid (default validatePublicVoidNoArgs)</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>- validateBindingTypeParameters (only arguments annotated with a BindingType allowed)</div><div><br></div><div>Overrides the createTest method to inject TestCase fields:</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>pesudo: for each Field &quot;annotated with a BindingType&quot; set getInstanceByType</div><div><span class="Apple-tab-span" style="white-space:pre">        </span></div>
<div>Overrides methodInvoker to inject TestMethod args:</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>pesudo: for each Arg getInstanceByType</div><div><br></div><div><br></div><div>Annotate the TestCase with @RunWith(Webbeans.class) and one should be good to go..</div>
<div><br></div><div>If interested, the code with TestCase example can be found at: </div><div><a href="http://pastebin.com/m66ad1894">http://pastebin.com/m66ad1894</a></div><div><br></div><br>-- <br>--<br>Aslak Knutsen; +47 952 38 791; fax +47 22 33 60 24<br>
Kongens gate 14; Boks 805 Sentrum, 0104 Oslo;<br><a href="http://www.conduct.no">http://www.conduct.no</a>; mailto:<a href="mailto:aslak@conduct.no">aslak@conduct.no</a><br><br>Conduct AS - Professional Open Source Services<br>
- Red Hat/JBoss Premier System Integrator<br>- Pentaho Preferred Integration Partner<br>- Atlassian Technology Partner<br>