Package com.googlecode.protobuf.socketrpc.TestProtos

Examples of com.googlecode.protobuf.socketrpc.TestProtos.Request


  public void testGoodRpc() throws IOException {
    // Create data
    String reqdata = "Request Data";
    String resdata = "Response Data";
    Request request = Request.newBuilder().setStrData(reqdata).build();
    Response response = Response.newBuilder().setStrData(resdata).build();
    socket.withResponseProto(response);

    // Call non-blocking method
    FakeCallback callback = callRpc(request, null);
View Full Code Here


   * Rpc called with incomplete request proto
   */
  public void testIncompleteRequest() throws IOException {
    // Create data
    String resdata = "Response Data";
    Request request = Request.newBuilder().buildPartial(); // required missing
    Response response = Response.newBuilder().setStrData(resdata).build();
    socket.withResponseProto(response);

    // Call non-blocking method
    callRpc(request, ErrorReason.INVALID_REQUEST_PROTO);
View Full Code Here

   * RPC doesn't invoke callback.
   */
  public void testNoCallBack() throws IOException {
    // Create data
    String reqdata = "Request Data";
    Request request = Request.newBuilder().setStrData(reqdata).build();
    socket.withNoResponse(false /* callback */);

    // Call non-blocking method
    FakeCallback callback = callRpc(request, null);
    verifyRequestToSocket(request);
View Full Code Here

   * RPC invokes callback with null.
   */
  public void testNullCallBack() throws IOException {
    // Create data
    String reqdata = "Request Data";
    Request request = Request.newBuilder().setStrData(reqdata).build();
    socket.withNoResponse(true /* callback */);

    // Call non-blocking method
    FakeCallback callback = callRpc(request, null);
    verifyRequestToSocket(request);
View Full Code Here

   * Server responds with bad data
   */
  public void testBadResponse() throws IOException {
    // Create data
    String reqdata = "Request Data";
    Request request = Request.newBuilder().setStrData(reqdata).build();
    socket.withInputBytes("bad response".getBytes());

    // Call non-blocking method
    callRpc(request, ErrorReason.IO_ERROR);
    verifyRequestToSocket(request);
View Full Code Here

   * RPC responds with bad response proto
   */
  public void testBadResponseProto() throws IOException {
    // Create data
    String reqdata = "Request Data";
    Request request = Request.newBuilder().setStrData(reqdata).build();
    socket.withResponseProto(ByteString.copyFrom("bad response".getBytes()));

    callRpc(request, ErrorReason.BAD_RESPONSE_PROTO);
    verifyRequestToSocket(request);

View Full Code Here

   * RPC responds with incomplete response.
   */
  public void testIncompleteResponse() throws IOException {
    // Create data
    String reqdata = "Request Data";
    Request request = Request.newBuilder().setStrData(reqdata).build();
    // incomplete response
    Response response = Response.newBuilder().setIntData(5).buildPartial();
    socket.withResponseProto(response);

    callRpc(request, ErrorReason.BAD_RESPONSE_PROTO);
View Full Code Here

  }

  private void checkResponseWithError(ErrorReason reason) throws IOException {
    // Create data
    String reqdata = "Request Data";
    Request request = Request.newBuilder().setStrData(reqdata).build();
    String error = "Error String";
    socket.withErrorResponseProto(error, reason);

    callRpc(request, reason);
    verifyRequestToSocket(request);
View Full Code Here

  public void testGoodRpc() throws IOException {
    // Create data
    String reqdata = "Request Data";
    String resdata = "Response Data";
    Request request = Request.newBuilder().setStrData(reqdata).build();
    Response response = Response.newBuilder().setStrData(resdata).build();

    // Create channel
    FakeSocket socket = new FakeSocket(false).withResponseProto(response);
    SocketRpcChannel rpcChannel = new SocketRpcChannel("host", -1,
View Full Code Here

   * Error while creating socket
   */
  public void testUnknownHost() {
    // Create data
    String reqdata = "Request Data";
    Request request = Request.newBuilder().setStrData(reqdata).build();

    // Create channel
    SocketRpcChannel rpcChannel = new SocketRpcChannel("host", -1,
        new FakeSocketFactory().throwsException(new UnknownHostException()));

View Full Code Here

TOP

Related Classes of com.googlecode.protobuf.socketrpc.TestProtos.Request

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.