Arquillian autowire is not working
rm0han Aug 14, 2015 3:24 AMI have this artemis queue configuration which I am loading using 'ShrinkWrap'. But the template is not getting autowired.
Test code uses this 'Service'.
@Service
public class SpringProducer {
@Autowired
private JmsTemplate myJmsTemplate;
Artemis configuration file (spring-beans-embedded.xml) is this.
<!-- JMS ConnectionFactory to use, configuring the embedded broker using XML -->
<amq:connectionFactory id="jmsFactory" brokerURL="vm://localhost"/>
<!-- Spring JMS Template -->
<bean id="myJmsTemplate" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory">
<!-- lets wrap in a pool to avoid creating a connection per send -->
<bean class="org.springframework.jms.connection.SingleConnectionFactory">
<property name="targetConnectionFactory">
<ref local="jmsFactory" />
</property>
</bean>
</property>
</bean>
Arquillian test is this.
File[] files = Maven.resolver().loadPomFromFile("pom.xml")
.importRuntimeDependencies().resolve().withTransitivity().asFile();
EnterpriseArchive ear = ShrinkWrap.create( ZipImporter.class,
"test.ear")
.importFrom(new File("test.ear"))
.as(EnterpriseArchive.class) ;
ear.addAsApplicationResource("jbossas-ds.xml")
.addAsLibraries(files)
.addAsLibrary(new File("D:/arquillian/ibm-mq/com.ibm.mq.jmqi-7.0.1.4.jar"))
.addAsLibrary(new File("D:/arquillian/ibm-mq/com.ibm.mq.jms-7.0.1.4.jar"));
WebArchive war = ear.getAsType(WebArchive.class, "/test.war");
war.addAsWebInfResource("applicationContext-Business.xml");
war.addAsWebInfResource("applicationContext-listener.xml");
war.addAsWebInfResource("applicationContext.xml");
war.addAsWebInfResource("artemis-roles.properties");
war.addAsWebInfResource("artemis-users.properties");
war.addAsWebInfResource("broker.xml");
war.addAsWebInfResource("spring-jms-beans.xml");
war.addAsWebInfResource("spring-beans-embedded.xml");
war.delete("/WEB-INF/applicationContext-sender.xml");
war.addPackage("test");
Wildfly starts properly but the JUnit test fails.
@Test
public void useArtemisQueueHostedInJBossAS() throws Exception {
SpringProducer sp = new SpringProducer();
assertNotNull( sp.getWiredTemplate() );
}
I don't understand the entire lifecycle here and I have been trying various options to even reach this level. It is sometimes hard to locate specific examples for common cases like this. I may be missing some documentation.
Thanks,
Mohan