当前位置: 首页>>代码示例>>Java>>正文


Java ErrorResolver类代码示例

本文整理汇总了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);
}
 
开发者ID:briandilley,项目名称:jsonrpc4j,代码行数:22,代码来源:JsonRpcServerTest.java

示例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);
}
 
开发者ID:briandilley,项目名称:jsonrpc4j,代码行数:22,代码来源:JsonRpcServerTest.java

示例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);
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:8,代码来源:JsonRpcFilterServer.java

示例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());
}
 
开发者ID:briandilley,项目名称:jsonrpc4j,代码行数:9,代码来源:JsonRpcErrorsTest.java

示例5: setErrorResolver

import com.googlecode.jsonrpc4j.ErrorResolver; //导入依赖的package包/类
/**
 * @param errorResolver the errorResolver to set
 */
public void setErrorResolver(ErrorResolver errorResolver) {
	this.errorResolver = errorResolver;
}
 
开发者ID:briandilley,项目名称:jsonrpc4j,代码行数:7,代码来源:AutoJsonRpcServiceExporter.java


注:本文中的com.googlecode.jsonrpc4j.ErrorResolver类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。