1

使用JerseyTest框架,如何设置ContainerRequestContext要在测试会话期间使用的属性

我尝试ResourceConfig在测试运行之前添加

ResourceConfig rc = new ResourceConfig();
rc.property("hello", "world");

在请求中

        Client client = ClientBuilder.newClient();
        WebTarget target = target().path("test/custom_header");
        Response response = client.target(target.getUri())
                .request(MediaType.APPLICATION_JSON)
                .property("hello", "world")

但始终在我的 ContainerRequestContext 过滤器中,该属性为空

context.getProperty("hello")//always null

知道如何在测试期间设置属性吗?

问候

4

0 回答 0