11 Replies Latest reply on Feb 28, 2018 2:22 AM by Martin Kouba

    Help Bootstrapping StrutsTestCase in Junit

    Glenn Buckholtz Newbie

      I have struts2 running with it's CDI-plugin and Weld is the CDI container of choice on my glassfish server. 

       

      For unit testing struts Actions, Struts has a StrutsTestCase http://struts.apache.org/maven/struts2-plugins/struts2-junit-plugin/apidocs/org/apache/struts2/StrutsTestCase.html

       

      The catch with struts is that it uses a JNDI lookup to find the weld context to override its internal injection framework (Which is a distant ancestor or Weld!).  I am trying to mock an InitialContextFactory so when struts tries to look up java:app/BeanManager  the mock will provide a BeanManager instance.  My problem is getting a BeanManager out of the Junit4 WeldInitiator. 

       

      tl;dr How do you get a BeanManager instance in Junit4?