Я создаю свой первый тест EJB с Arquillian, и я столкнулся с чем-то, что кажется очень распространенным, учитывая количество сообщений с той же проблемой. Но, перепробовав все предложения, я не смог найти решение. Я запускаю его над мухой14.
Мой тестовый класс
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.*;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.inject.*;
@RunWith(Arquillian.class)
public class LicenseManagerTest {
@Deployment
public static WebArchive createDeployment() {
WebArchive war = ShrinkWrap.create(WebArchive.class)
.addClasses(LicenseManager.class)
.addPackages(true, "package1", "package2");
return war;
}
@Inject
private LicenseManager licenseManager;
@Test
public void getAboutTest() {
Assert.assertNotNull(licenseManager.getAbout().getText());
}
}
Менеджер EJB
import javax.ejb.Remote;
@Remote
public interface LicenseManager {
AboutDTO getAbout();
}
Класс БИН
@Stateless(name = "LicenseManagerEJB3")
@Remote(LicenseManager.class)
public class LicenseManagerBean implements LicenseManager{
@Override
public AboutDTO getAbout(){
*My code goes here*
}
}
Arquillian.xml
<?xml version="1.0"?>
<arquillian xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://jboss.org/schema/arquillian"
xsi:schemaLocation="http://jboss.org/schema/arquillian
http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
<defaultProtocol type="Servlet 3.0"/>
<container qualifier="widlfly-managed" default="true">
<configuration>
<property name="jbossHome">target/wildFly-14.0.1.Final</property>
<!--<property name="managementAddress">127.0.0.1</property>-->
<!-- Port offset allows running the tests while a WildFly server is already running -->
<property name="javaVmArguments">-Djboss.socket.binding.port-offset=10000 -Xms512m -Xmx1024m -XX:MaxPermSize=512m --add-modules java.se</property>
<property name="managementPort">19990</property>
<property name="username">admin</property>
<property name="password">admin</property>
</configuration>
</container>
POM file
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>artifactName</artifactId>
<parent>
<groupId>package1</groupId>
<artifactId>artifactName</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../name1/pom.xml</relativePath>
</parent>
<properties>
<version.arquillian>1.4.1.Final</version.arquillian>
<version.wildfly>14.0.1.Final</version.wildfly>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<archive>
<manifest>
<addClasspath>false</addClasspath>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<!-- Project dependencies -->
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>${version.arquillian}</version>
<scope>test</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<version>${version.arquillian}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.core</groupId>
<artifactId>arquillian-core-api</artifactId>
<version>${version.arquillian}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.protocol</groupId>
<artifactId>arquillian-protocol-servlet</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-arquillian-container-managed</artifactId>
<version>8.2.1.Final</version>
<exclusions>
<exclusion>
<groupId>sun.jdk</groupId>
<artifactId>jconsole</artifactId>
</exclusion>
</exclusions>
<scope>test</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<id>wildFlyManaged</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<testResources>
<testResource>
<directory>src/test/resources</directory>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack</id>
<phase>process-test-classes</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-dist</artifactId>
<version>${version.wildfly}</version>
<type>zip</type>
<overWrite>false</overWrite>
<outputDirectory>target</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
During the test configuration, several EJB's that have mixed dependencies with mine, are started without problem, but LicenseManagerEJB3 is not, and when the test code is executed I get the following error:
Причина: org.jboss.weld.exceptions.IllegalArgumentException: WELD-001408: Неудовлетворенные зависимости для типа LicenseManager с квалификаторами @Default в точке внедрения [BackedAnnotatedField] @Inject private package1.LicenseManagerTest.licenseManager в package1.LicenseManagerTest.licenseManager(LicenseManagerTest.java :0) по адресу [email protected]//org.jboss.weld.manager.InjectionTargetFactoryImpl.createInjectionTarget(InjectionTargetFactoryImpl.java:83) по адресу [email protected]. Final//org.jboss.weld.manager.InjectionTargetFactoryImpl.createInjectionTarget(InjectionTargetFactoryImpl.java:70) по адресу [email protected]//org.jboss.weld.manager.BeanManagerImpl.createInjectionTarget(BeanManagerImpl .java:1025) по адресу [email protected]//org.jboss.weld.util.ForwardingBeanManager.createInjectionTarget(ForwardingBeanManager.java:204) по адресу deployment.0d8da7a8-dc23-4657-ac07- 40964685a2c1.war//org.jboss.arquillian.testenricher.cdi. CDIInjectionEnricher.injectNonContextualInstance(CDIInjectionEnricher.java:143) at deployment.0d8da7a8-dc23-4657-ac07-40964685a2c1.war//org.jboss.arquillian.testenricher.cdi.CDIInjectionEnricher.injectClass(CDIInjectionEnricher.java:125) ... 125 больше Причина: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Неудовлетворенные зависимости для типа LicenseManager с квалификаторами @Default в точке внедрения [BackedAnnotatedField] @Inject private package1.LicenseManagerTest.licenseManager в package1.LicenseManagerTest.licenseManager(LicenseManagerTest. java:0) по адресу [email protected]//org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:378) по адресу [email protected] .Final//org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:290) по адресу [email protected]//org.jboss.weld.bootstrap.Validator.validateProducer( Validator.java:425) по адресу [email protected]. 5.Final//org.jboss.weld.injection.producer.InjectionTargetService.validateProducer(InjectionTargetService.java:36) по адресу [email protected]//org.jboss.weld.manager.InjectionTargetFactoryImpl .validate(InjectionTargetFactoryImpl.java:153) по адресу [email protected]//org.jboss.weld.manager.InjectionTargetFactoryImpl.createInjectionTarget(InjectionTargetFactoryImpl.java:81) ... еще 147
Вы знаете, что я делаю неправильно? Спасибо