简体   繁体   English

JerseyTest无法识别@WebFilter

[英]JerseyTest doesn't recognize @WebFilter

I try to create a JerseyTest on a Jersey REST Servlet with jersey-test-framework-provider-grizzly2. 我尝试使用jersey-test-framework-provider-grizzly2在Jersey REST Servlet上创建JerseyTest。

The test requests correct content from the servlet in grizzly. 该测试在灰熊时代从servlet请求正确的内容。

But when starting up the servlet productive there is an HTTPBasicAuth. 但是,当启动可生产的servlet时,会有一个HTTPBasicAuth。 The Auth is done with a @WebFilter("/*") org.apache.shiro.web.servlet.ShiroFilter. Auth是通过@WebFilter(“ / *”)org.apache.shiro.web.servlet.ShiroFilter完成的。

During JerseyTest there is no Auth requested. 在JerseyTest期间,没有请求验证。 So my conclusion is that the @WebFilter annotation is not recognized. 因此,我的结论是无法识别@WebFilter批注。 Does JerseyTest only test resources in the Application? JerseyTest是否仅测试应用程序中的资源? How to get the WebFilters recognized? 如何获得WebFilters的认可?

Thanks. 谢谢。

I think I can answer myself ;-) 我想我可以回答自己;-)

It's a JerseyTest Framework and no "FullAppWithJerseyTest" Framework. 它是JerseyTest框架,没有“ FullAppWithJerseyTest”框架。

I've now implemented something like ServletJerseyTest extending JerseyTest. 我现在已经实现了像ServletJerseyTest这样的扩展了JerseyTest的东西。 It uses the org.glassfish.jersey.test.external.ExternalTestContainerFactory.class and setUp() contains starting up a servlet container and installing the latest built WAR. 它使用org.glassfish.jersey.test.external.ExternalTestContainerFactory.class和setUp()包含启动Servlet容器并安装最新构建的WAR。

The test runs against this container. 测试针对此容器。 In tearDown() the container is stopped and installed WAR becomes deleted. 在tearDown()中,容器已停止并且已删除WAR。

Embedded Tomcat has API to look by itself for a free TCP port and TestProperties.CONTAINER_PORT is set to choosen port. 嵌入式Tomcat具有可自行查找免费TCP端口和TestProperties的API.CONTAINER_PORT设置为选择的端口。

Now the tests run as expected... 现在测试按预期运行...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM