How to turn on tracing in a unit test using a ResourceTestRule?

I'm using dropwizard with jersey. I'm having a problem with the path in a resource and would like to debug it. How do you configure the jersey environment variable for this? The following does not work.

@ClassRule
public static final ResourceTestRule resources = ResourceTestRule.builder()
    .addResource(UserResource.class)
    .addProperty("jersey.config.server.tracing.type", "ON")
    .build();

The following call in ResourceTestRule sets up the default logging with WARN level:

static {
    BootstrapLogging.bootstrap();
}

To override, I call BootstrapLogging again and indicate the required logging level in my test class after the ResourceTestRule creation, eg:

import ch.qos.logback.classic.Level;
import io.dropwizard.logging.BootstrapLogging;
...

@ClassRule
public static final ResourceTestRule resources = ResourceTestRule.builder()
    .addResource(UserResource.class)
    .build();

static {
    BootstrapLogging.bootstrap(Level.DEBUG);
}

Then I can see my logging output in the console.

链接地址: http://www.djcxy.com/p/87096.html

上一篇: Docker备份和恢复postgres

下一篇: 如何使用ResourceTestRule在单元测试中打开跟踪?