Arquillian - 如何调试托管的 Wildfly 容器
Arquillian - How to debug managed Wildfly container
我正在使用 Arquillian 为我的 RESTful 应用程序编写黑盒测试。我实际上能够调试测试 类,但无法调试我的应用程序 类。我想知道具体怎么做。
我的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">
<container qualifier="jbossas-managed" default="true">
<configuration>
<property name="jbossHome">D:\desenv\arquivos\servidores\wildfly-9.0.1.Final-test</property>
<property name="allowConnectingToRunningServer">true</property>
<property name="javaVmArguments">-Dorg.apache.deltaspike.ProjectStage=IntegrationTest</property>
</configuration>
</container>
我的一个测试类:
@RunAsClient
@RunWith(Arquillian.class)
public class AuthenticationBlackBoxTest extends AbstractBlackBoxTest {
@Test
public void testInvalidCredentials(@ArquillianResource URL baseURI) {
Client client = ClientBuilder.newClient();
WebTarget target = client.target(baseURI.toString()).path("api/v1/auth");
Response response = target.request(MediaType.APPLICATION_JSON)
.post(Entity.entity(new Credentials("invalid", "invalid"), MediaType.APPLICATION_JSON));
Assert.assertEquals(401, response.getStatus());
response.close();
client.close();
}
@Test
public void testValidCredentials(@ArquillianResource URL baseURI) {
Client client = ClientBuilder.newClient();
WebTarget target = client.target(baseURI.toString()).path("api/v1/auth");
Entity<Credentials> credentialsEntity = Entity.entity(new Credentials("adm@adm.com", "123"), MediaType.APPLICATION_JSON);
Response response = target.request(MediaType.APPLICATION_JSON)
.post(credentialsEntity);
Assert.assertEquals(200, response.getStatus());
response.close();
client.close();
}
}
在 arquillian.xml 内为 javaVmArguments 元素添加 -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y
.
然后在您最喜欢的 IDE 中,您必须定义一个新的远程调试配置,在其中指定主机 (localhost)、端口 (8787)。放置断点,然后 运行 测试,最后开始远程调试。官方文档 here.
我正在使用 Arquillian 为我的 RESTful 应用程序编写黑盒测试。我实际上能够调试测试 类,但无法调试我的应用程序 类。我想知道具体怎么做。
我的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">
<container qualifier="jbossas-managed" default="true">
<configuration>
<property name="jbossHome">D:\desenv\arquivos\servidores\wildfly-9.0.1.Final-test</property>
<property name="allowConnectingToRunningServer">true</property>
<property name="javaVmArguments">-Dorg.apache.deltaspike.ProjectStage=IntegrationTest</property>
</configuration>
</container>
我的一个测试类:
@RunAsClient
@RunWith(Arquillian.class)
public class AuthenticationBlackBoxTest extends AbstractBlackBoxTest {
@Test
public void testInvalidCredentials(@ArquillianResource URL baseURI) {
Client client = ClientBuilder.newClient();
WebTarget target = client.target(baseURI.toString()).path("api/v1/auth");
Response response = target.request(MediaType.APPLICATION_JSON)
.post(Entity.entity(new Credentials("invalid", "invalid"), MediaType.APPLICATION_JSON));
Assert.assertEquals(401, response.getStatus());
response.close();
client.close();
}
@Test
public void testValidCredentials(@ArquillianResource URL baseURI) {
Client client = ClientBuilder.newClient();
WebTarget target = client.target(baseURI.toString()).path("api/v1/auth");
Entity<Credentials> credentialsEntity = Entity.entity(new Credentials("adm@adm.com", "123"), MediaType.APPLICATION_JSON);
Response response = target.request(MediaType.APPLICATION_JSON)
.post(credentialsEntity);
Assert.assertEquals(200, response.getStatus());
response.close();
client.close();
}
}
在 arquillian.xml 内为 javaVmArguments 元素添加 -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y
.
然后在您最喜欢的 IDE 中,您必须定义一个新的远程调试配置,在其中指定主机 (localhost)、端口 (8787)。放置断点,然后 运行 测试,最后开始远程调试。官方文档 here.