本文整理汇总了Java中com.googlecode.jsonrpc4j.ErrorResolver类的典型用法代码示例。如果您正苦于以下问题:Java ErrorResolver类的具体用法?Java ErrorResolver怎么用?Java ErrorResolver使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ErrorResolver类属于com.googlecode.jsonrpc4j包,在下文中一共展示了ErrorResolver类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGetMethod_badRequest_corruptParams
import com.googlecode.jsonrpc4j.ErrorResolver; //导入依赖的package包/类
@Test
public void testGetMethod_badRequest_corruptParams() throws Exception {
EasyMock.expect(mockService.testMethod("Whirinaki")).andReturn("Forest");
EasyMock.replay(mockService);
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/test-get");
MockHttpServletResponse response = new MockHttpServletResponse();
request.addParameter("id", Integer.toString(123));
request.addParameter("method", "testMethod");
request.addParameter("params", "{BROKEN}");
jsonRpcServer.handle(request, response);
assertTrue(MockHttpServletResponse.SC_BAD_REQUEST == response.getStatus());
JsonNode errorNode = error(toByteArrayOutputStream(response.getContentAsByteArray()));
assertNotNull(errorNode);
assertEquals(errorCode(errorNode).asLong(), (long) ErrorResolver.JsonError.PARSE_ERROR.code);
}
示例2: testGetMethod_badRequest_noMethod
import com.googlecode.jsonrpc4j.ErrorResolver; //导入依赖的package包/类
@Test
public void testGetMethod_badRequest_noMethod() throws Exception {
EasyMock.expect(mockService.testMethod("Whirinaki")).andReturn("Forest");
EasyMock.replay(mockService);
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/test-get");
MockHttpServletResponse response = new MockHttpServletResponse();
request.addParameter("id", Integer.toString(123));
// no method!
request.addParameter("params", net.iharder.Base64.encodeBytes("[\"Whirinaki\"]".getBytes(StandardCharsets.UTF_8)));
jsonRpcServer.handle(request, response);
assertTrue(MockHttpServletResponse.SC_NOT_FOUND == response.getStatus());
JsonNode errorNode = error(toByteArrayOutputStream(response.getContentAsByteArray()));
assertNotNull(errorNode);
assertEquals(errorCode(errorNode).asLong(), (long) ErrorResolver.JsonError.METHOD_NOT_FOUND.code);
}
示例3: handleJsonNodeRequest
import com.googlecode.jsonrpc4j.ErrorResolver; //导入依赖的package包/类
@Override
protected ErrorResolver.JsonError handleJsonNodeRequest(JsonNode node, OutputStream output) throws IOException {
if (node.hasNonNull(JSON_RPC_METHOD_FIELD_NAME)) {
checkMethod(node.at(JSON_RPC_METHOD_FIELD_NAME).asText());
}
return super.handleJsonNodeRequest(node, output);
}
示例4: exceptionWithoutAnnotatedServiceInterface
import com.googlecode.jsonrpc4j.ErrorResolver; //导入依赖的package包/类
@Test
public void exceptionWithoutAnnotatedServiceInterface() throws Exception {
JsonRpcBasicServer jsonRpcServer = new JsonRpcBasicServer(mapper, new Service(), ServiceInterfaceWithoutAnnotation.class);
jsonRpcServer.handleRequest(messageWithListParamsStream(1, "testMethod"), byteArrayOutputStream);
JsonNode error = error(byteArrayOutputStream);
assertNotNull(error);
assertEquals(ErrorResolver.JsonError.ERROR_NOT_HANDLED.code, errorCode(error).intValue());
}
示例5: setErrorResolver
import com.googlecode.jsonrpc4j.ErrorResolver; //导入依赖的package包/类
/**
* @param errorResolver the errorResolver to set
*/
public void setErrorResolver(ErrorResolver errorResolver) {
this.errorResolver = errorResolver;
}