Ich schreibe Wildfly Java EE App, aber ich habe Probleme mit Bean-Injektion in Testfällen. Es funktioniert nicht in eigenständigen Tests und auch in ShrinkWrap.Arquillian Bean und dao @Injection nicht funktionieren
Einfacher Test, aber beide injizierten Objekte sind null. Ich habe versucht, Injektion von org.jboss.arquillian.core.api.annotation.Inject Paket aber den gleichen Effekt.
Können Sie mir helfen? Ich habe keine Ahnung, was ich damit machen soll.
src/test/resources/arquillian.xml
<?xml version="1.0" encoding="UTF-8"?>
<arquillian xmlns="http://www.jboss.org/arquillian-1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.jboss.org/arquillian-1.0
http://www.jboss.org/schema/arquillian/arquillian-1.0.xsd">
<defaultProtocol type="Servlet 3.0" />
<extension qualifier="webdriver">
<property name="browser">chrome</property>
</extension>
<container qualifier="widlfly-remote" default="true">
<configuration>
<property name="managementAddress">host</property>
<property name="managementPort">9990</property>
<property name="username">user</property>
<property name="password">password</property>
</configuration>
</container>
</arquillian>
Ausführungslog
kwi 14, 2016 8:25:02 AM org.jboss.arquillian.drone.webdriver.factory.remote.reusable.ReusedSessionPermanentFileStorage readStore
INFO: Reused session store is not available at C:\Users\......\.drone-webdriver-session-store, a new one will be created.
kwi 14, 2016 8:25:02 AM org.jboss.arquillian.container.test.impl.RunModeUtils isRunAsClient
WARNING: The test method "InjectionTestCase groupSetter" will run on the client side - there is no running deployment yet. Please use the annotation @RunAsClient
kwi 14, 2016 8:25:02 AM org.jboss.arquillian.container.test.impl.RunModeUtils isRunAsClient
WARNING: The test method "InjectionTestCase groupSetter" will run on the client side - there is no running deployment yet. Please use the annotation @RunAsClient
kwi 14, 2016 8:25:02 AM org.jboss.arquillian.container.test.impl.RunModeUtils isRunAsClient
WARNING: The test method "InjectionTestCase groupSetter" will run on the client side - there is no running deployment yet. Please use the annotation @RunAsClient
kwi 14, 2016 8:25:02 AM org.jboss.arquillian.container.test.impl.RunModeUtils isRunAsClient
WARNING: The test method "InjectionTestCase groupSetter" will run on the client side - there is no running deployment yet. Please use the annotation @RunAsClient
kwi 14, 2016 8:25:02 AM org.jboss.arquillian.container.test.impl.RunModeUtils isRunAsClient
WARNING: The test method "InjectionTestCase groupSetter" will run on the client side - there is no running deployment yet. Please use the annotation @RunAsClient
kwi 14, 2016 8:25:02 AM org.jboss.arquillian.container.test.impl.RunModeUtils isRunAsClient
WARNING: The test method "InjectionTestCase groupSetter" will run on the client side - there is no running deployment yet. Please use the annotation @RunAsClient
Neue Protokolle. Mit ShrinkWrap:
public static WebArchive createDeployment() {
File[] files = Maven.resolver().loadPomFromFile("pom.xml")
.importRuntimeDependencies().resolve().withTransitivity().asFile();
WebArchive war = ShrinkWrap.create(WebArchive.class, "test.war")
// add classes
.addPackages(true, "my.package")
// add configuration
.addAsResource("META-INF/persistence.xml", "META-INF/persistence.xml")
.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
.addAsWebInfResource(new File("src/test/webapp/WEB-INF/jboss-web.xml"))
// add pages
.addAsWebResource(new File("src/main/webapp/403.xhtml"))
.addAsWebResource(new File("src/main/webapp/404.xhtml"))
.addAsWebResource(new File("src/main/webapp/error.xhtml"))
.addAsWebResource(new File("src/main/webapp/login.xhtml"))
/** OTHER PAGES ADDED **/
// add libraries
.addAsLibraries(files)
.setWebXML(new File("src/test/webapp/WEB-INF/web.xml"));
System.err.println(war.toString(true));
return war;
}
@Deployment
public static Archive<?> createDeployment() {
return createDeployment();
}
Ich habe ein Problem gefunden. Tests versuchen, mit 0.0.0.0 statt meiner extrnal Wildfly Server "host"
Caused by: java.lang.IllegalStateException: Error launching request at http://0.0.0.0:8080/test/ArquillianServletRunner?outputMode=serializedObject&className=my.package.InjectionTestCase&methodName=groupSetter. No result returned
On-Server verbinden ich sehe, dass die Anwendung
2016-04-15 11:20:55,986 INFO [org.jboss.as.server.deployment] (MSC service thread 1-14) JBAS015876: Starting deployment of "test.war" (runtime-name: "test.war")
......
2016-04-15 11:21:00,884 INFO [org.jboss.as.server] (management-handler-thread - 1) JBAS018559: Deployed "test.war" (runtime-name : "test.war")
Ich habe ShrinkWrap hinzugefügt, aber es ist ein neues Problem aufgetreten. Protokolle und Code zum ersten Beitrag hinzugefügt. – skoczo
Es sieht aus wie es funktioniert. Die jetzt injizierte Entität ist kein Nullwert. Danke @ Jan_Piel. Jetzt habe ich "Unerwartete Callable in Drone Context vorhanden, sollte in diesem Moment bereits instanziiert werden". Ich versuche eine Lösung dafür zu finden. Danke für die Hilfe. Es hat mich für ein paar Tage blockiert. Könnte ein Problem mit "Drone Context" sein, weil ich einen Remote-Server ohne grafisches env habe? – skoczo
Tut mir leid, ich habe keine Erfahrung mit der Arquillian Drone Extension –