关于 Arquillian 远程测试的基本问题
我最近开始学习 Arquillian。遵循入门教程,了解了“容器品种”,其中涉及远程、嵌入式和托管容器。我对 Arqillian 如何处理这些不同的品种有点困惑。
我的问题是:入门教程第一个示例(具有 TemparatureConverter)使用 JBoss AS 6 作为远程容器。我的理解是,包含TemparatureConverter bean的主应用程序存档将部署在JBoss AS 6(在其自己的VM中运行)中,而我的测试类将在单独的VM中运行。
我向 TemparatureConverter.java 即 Bean 类添加了一些日志消息:
public double convertToCelsius(double f) {
System.out.println("@@@@@@@@@@Inside container: convertToCelsius");
return ((f - 32) * 5 / 9);
}
public double convertToFarenheit(double c) {
System.out.println("@@@@@@@@@@Inside container: convertToFarenheit");
return ((c * 9 / 5) + 32);
}
我还向我的测试类添加了一些日志消息:
@Test
public void testConvertToCelsius() {
System.out.println("@@@@@@@@@Inside Junit client");
Assert.assertEquals(converter.convertToCelsius(32d), 0d);
Assert.assertEquals(converter.convertToCelsius(212d), 100d);
}
现在我启动 JBoss AS 并通过键入以下内容通过命令行运行测试用例: mvn test -Pjbossas-remote- 6
我认为我在 Bean 类中添加的日志消息将打印在 JBoss 控制台上,而我在 Test 类中添加的日志消息将打印在 Maven 控制台窗口上,因为这两件事是在单独的虚拟机中运行。
然而这并没有发生,我看到所有日志消息都打印在 JBoss AS 控制台上。
这意味着,我的测试用例与 Bean 类一起在 JBoss AS 容器内运行。
如果这是真的,那么这里的偏远在哪里呢?我的意思是,测试用例和 bean 都在同一个 JVM 中运行。这类似于“嵌入式容器”行为,不是吗?
我指的是这个解释:
a remote container resides in a separate JVM from the test runner; Arquillian binds to the container to deploy and undeploy the test archive and invokes tests via a remote protocol (typically HTTP)
但在这种情况下,Arquillian 似乎将我的测试用例与 Bean 类一起放置在同一个 JVM 中。
如果我的问题不清楚,请告诉我?
I've recently started learning about Arquillian. Was following the Geting started tutorial, learned about "Container Varieties" that talks about Remote, Embedded and Managed containers.I'm bit confused about how Arqillian treats these different varieties.
My question is: The Getting started tutorial first example (that has TemparatureConverter) uses JBoss AS 6 as Remote container. What i understood is that my main application archive that contains the TemparatureConverter bean will be deployed in JBoss AS 6 (that is running in its own VM) and my Test class will run in a separate VM.
I added some log messages to TemparatureConverter.java i.e. Bean class:
public double convertToCelsius(double f) {
System.out.println("@@@@@@@@@@Inside container: convertToCelsius");
return ((f - 32) * 5 / 9);
}
public double convertToFarenheit(double c) {
System.out.println("@@@@@@@@@@Inside container: convertToFarenheit");
return ((c * 9 / 5) + 32);
}
I also added some log messages to my Test class:
@Test
public void testConvertToCelsius() {
System.out.println("@@@@@@@@@Inside Junit client");
Assert.assertEquals(converter.convertToCelsius(32d), 0d);
Assert.assertEquals(converter.convertToCelsius(212d), 100d);
}
Now I started JBoss AS and run the test cases through command line by typing: mvn test -Pjbossas-remote-6
I was thinking that log messages that I added in Bean class will be printed on JBoss console, and the log messages that I added in my Test class will be printed on Maven console window, because these two things are running in separate VM.
However that did not happen, and I saw all the log messages are getting printed on JBoss AS console.
That means, my Test cases are running inside JBoss AS container along with the Bean class.
If this is true, then where is remoteness here? I mean, both the test case and bean are running inside same JVM. This is similar to "embedded container" behaviour, isn't?
I'm referring this explanation:
a remote container resides in a separate JVM from the test runner; Arquillian binds to the container to deploy and undeploy the test archive and invokes tests via a remote protocol (typically HTTP)
But in this case, it appears Arquillian is placing my Test cases along with Bean class in same JVM.
Let me know, if my question is not clear?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,Arquillian 正在部署您的测试用例类以及目标容器中正在测试的代码。
引用文档:
因此,就“远程性”而言,Arquillian 提供的是一种“远程”启动测试并将结果呈现给开发人员的方法,就像“本地”运行一样。销售宣传是您不必关心部署,并且可以在自己的开发环境中运行测试。
远程容器和嵌入式容器的区别就变成了容器的运行方式。远程意味着在运行测试之前,您有一个容器与您的开发环境一起运行。嵌入式增加了在测试开始时仅运行容器的价值。
Yes, Arquillian is deploying your test case classes along with the code that is being tested in your target container.
To quote the docs:
So in terms of "remoteness", what Arquillian provides is a way to initiate the test "remotely" and have the result presented to the developer as if it was run "locally". The sales pitch being that you should not have to care about deployment and you're able to run test in your own development environment.
The difference in remote and embedded containers then becomes the way the container is run. Remote means that you have a container running alongside your development environment before the test is run. And embedded adds the value of only having a container running when the test is started.