I am trying to use Arquillian to run tests on a remote Wildfly server. I am not sure why the Dependency Injection does not work. Here is the relevant section from POM:
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<version>1.7.0.Alpha10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.protocol</groupId>
<artifactId>arquillian-protocol-servlet</artifactId>
<version>1.6.0.Final</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<profile>
<!-- Run with: mvn clean test -Parq-remote -->
<id>arq-remote</id>
<dependencies>
<dependency>
<groupId>org.wildfly.arquillian</groupId>
<artifactId>wildfly-arquillian-container-remote</artifactId>
<version>5.0.0.Alpha3</version>
<scope>test</scope>
</dependency>
</dependencies>
</profile>
My test class:
import javax.inject.Inject;
import javax.inject.Named;
import com.avm.service.ITestService;
import com.avm.service.TestService;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Test;
import org.junit.Assert;
import org.junit.runner.RunWith;
@RunWith(Arquillian.class)
public class OrderServiceTest {
@Deployment
public static Archive<?> createTestArchive() {
return ShrinkWrap.create(WebArchive.class, "backend.war")
.addClass(ITestService.class)
.addClass(TestService.class)
//.addPackage(RepositoryManager.class.getPackage()).addAsResource("META-INF/persistence.xml")
.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
}
@Inject
@Named("testService")
TestService testService;
@Test
public void testRegister() throws Exception {
Assert.assertEquals("backend", testService.getAppName());
}
}
Service Interface:
public interface ITestService {
String getAppName();
}
Service Implementation:
@Named("testService")
public class TestService implements ITestService{
private String appName = "backend";
private String version = "1.0.0";
@Override
public String getAppName() {
return this.appName;
}
}
Finally, my arquillian.xml:
<arquillian xmlns="http://jboss.org/schema/arquillian" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jboss.org/schema/arquillian
http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
<!-- Force the use of the Servlet 3.0 protocol with all containers, as it is the most mature -->
<defaultProtocol type="Servlet 3.0" />
<!-- Uncomment to have test archives exported to the file system for inspection -->
<engine>
<property name="deploymentExportPath">target/</property>
</engine>
<!-- Example configuration for a managed WildFly / JBoss EAP instance -->
<container qualifier="managed">
<configuration>
<property name="jbossHome">/git/Servers/wildfly-26.1.1.Final</property>
</configuration>
</container>
<!-- Example configuration for a remote WildFly / JBoss EAP instance -->
<container qualifier="remote">
<!-- Arquillian will deploy to this WildFly server. -->
<configuration>
<property name="managementAddress">127.0.0.1</property>
<property name="managementPort">9990</property>
</configuration>
</container>
</arquillian>
After hunting down a solution for about two days now and having tried almost anything which I could, I feel I would really appreciate if a kind soul looked at this problem now.
Thanks for reading, appreciate your time.