-
1. Re: Arquillian integration with Spring @Autowired (Tomcat 7.0 Managed)
jmnarloch Jun 5, 2012 5:12 PM (in response to billm)Hi Bill,
This is what for the Spring Extension has been made - currently in Alpha 1 ver.: https://github.com/arquillian/arquillian-extension-spring
You need to add the extension into your POM:
<dependency>
<groupId>org.jboss.arquillian.extension</groupId>
<artifactId>arquillian-service-deployer-spring-3</artifactId>
<version>1.0.0.Alpha1</version>
<scope>test</scope>
</dependency>Then you make a standard arquillian test, with one difference - annotate it with @SpringConfiguration with location pointing to yours applicationContext.xml.
Remeber to include the configuration file with the deployment, otherwise the extension won't be able to instantiate the ApplicationContext:
{code}
archive.addAsResource("applicationContext.xml")
{code}
The extension should allow to test JAR and WAR archives.
After setting everything up you should be able to autowire you controller in the test case e.g.:
{code}
@RunWith(Arquillian.class)
@SpringConfiguration("applicationContext.xml")
public class SearchControllerTest {
@Autowired
private SearchController searchService;
@Test
public void testSearchDocument {
// test code
}
}
{code}
Note that you may have to add additional Spring dependencies into the ShrinkWrap deployment.
-
2. Re: Arquillian integration with Spring @Autowired (Tomcat 7.0 Managed)
billm Jun 6, 2012 1:16 PM (in response to jmnarloch)thanks for the help Jakub and good luck on your efforts this summer.