@Test public void decodeException_nullContentPassed_InternalServerErrorShouldBeReturned() throws RpcCallException { byte[] content = null; RpcCallException exception = decoder.decodeException(response(content)); assertThat(exception.getCategory()).isEqualTo(InternalServerError); assertThat(exception.getMessage()).isEqualTo("Empty response received"); }
public RESPONSE callSynchronous(Message request, OrangeContext orangeContext) throws RpcCallException { HttpClientWrapper clientWrapper = loadBalancer.getHttpClientWrapper(); HttpRequestWrapper balancedPost = clientWrapper.createHttpPost(this); //set custom headers if (orangeContext != null) { orangeContext.getProperties().forEach(balancedPost::setHeader); } balancedPost.setHeader("Content-type", TYPE_OCTET); //TODO: fix: Temporary workaround below until go services are more http compliant balancedPost.setHeader("Connection", "close"); ProtobufRpcRequest pbRequest = new ProtobufRpcRequest(methodName, request); byte[] protobufData = pbRequest.getProtobufData(); balancedPost.setContentProvider(new BytesContentProvider(protobufData)); logger.debug("Sending request of size {}", protobufData.length); ContentResponse rpcResponse = clientWrapper.execute(balancedPost, new ProtobufRpcCallExceptionDecoder(), orangeContext); byte[] data = rpcResponse.getContent(); logger.debug("Received a proto response of size: {}", data.length); return ProtobufUtil.byteArrayToProtobuf( new ProtobufRpcResponse(data).getPayloadData(), responseClass); }
@Test public void decodeException_zeroLengthContentPassed_InternalServerErrorShouldBeReturned() throws RpcCallException { byte[] content = new byte[0]; RpcCallException exception = decoder.decodeException(response(content)); assertThat(exception.getCategory()).isEqualTo(InternalServerError); assertThat(exception.getMessage()).isEqualTo("Empty response received"); }