ClientBuilder无法产生新的客户端

问题描述

我是Junit测试和jmockit的新手。在我的项目中,我们必须测试一个get呼叫请求。以下是我的测试 公共类RestConnectorTest {

@Injectable
private String authenticationUsername;

@Injectable
private String authenticationPassword;

@Injectable
private Response response;

@Injectable
private Invocation.Builder builder;

@Injectable
private SecurityContext securityContext;

@Tested
@Injectable
RestConnector<String> restConnector;

@Injectable
private LoggerSupport loggerSupport;

@Injectable
private Logger logger;

@Test
public void testGetEmptyResponse()
{
    new Expectations()
    {
        {
            response.getStatus();
            result = 200;
        }
        {
            restConnector.callGet((Invocation.Builder) any);
            result = response;
        }
    };

    final String result = restConnector.get("test",String.class);

    assertNull(result);
}

} 但是当我在以下步骤调试代码时 客户端= ClientBuilder.newBuilder()。property(“ connect.timeout”,NUMBER_OF_MILLISECONDS) .register(JsonProvider.class) 。建立(); 我会有以下例外 java.lang.RuntimeException:java.lang.RuntimeException:RESTEASY003940:无法实例化MessageBodyReader

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)