Package com.youtube.vitess.gorpc.codecs.bson

Examples of com.youtube.vitess.gorpc.codecs.bson.BsonClientCodecFactory


   * Test unsigned longs are encoded and decoded correctly
   */
  @Test
  public void testUnsignedLongs() throws Exception {
    UnsignedLong a = UnsignedLong.valueOf("9767889778372766922");
    Client client = Client.dialHttp(Util.HOST, Util.PORT, Util.PATH, new BsonClientCodecFactory());
    BSONObject mArgs = new BasicBSONObject();
    mArgs.put("Num", a);
    Response response = client.call("Arith.Increment", mArgs);
    Assert.assertEquals(a.add(UnsignedLong.ONE), (UnsignedLong) response.getReply());
    client.close();
View Full Code Here


    Util.stopFakeGoServer();
  }

  @Test
  public void testValidCase() throws IOException, GoRpcException, ApplicationException {
    Client client = Client.dialHttp(Util.HOST, Util.PORT, Util.PATH, new BsonClientCodecFactory());
    BSONObject mArgs = new BasicBSONObject();
    mArgs.put("A", 5L);
    mArgs.put("B", 7L);
    Response response = client.call("Arith.Multiply", mArgs);
    Assert.assertNull(response.getError());
View Full Code Here

  @Test
  public void testInValidHandshake() throws IOException, GoRpcException {
    try {
      Client client =
          Client.dialHttp(Util.HOST, Util.PORT, "/_somerpc_", new BsonClientCodecFactory());
      client.close();
      Assert.fail("did not raise exception");
    } catch (GoRpcException e) {
      Assert.assertTrue("unexpected response for handshake HTTP/1.0 404 Not Found".equals(e
          .getMessage()));
View Full Code Here

    }
  }

  @Test
  public void testInValidMethodName() throws IOException, GoRpcException {
    Client client = Client.dialHttp(Util.HOST, Util.PORT, Util.PATH, new BsonClientCodecFactory());
    try {
      client.call("Arith.SomeMethod", new BasicBSONObject());
      client.close();
      Assert.fail("did not raise exception");
    } catch (ApplicationException e) {
View Full Code Here

    client.close();
  }

  @Test
  public void testMissingMethodArgs() throws IOException, GoRpcException, ApplicationException {
    Client client = Client.dialHttp(Util.HOST, Util.PORT, Util.PATH, new BsonClientCodecFactory());
    BSONObject mArgs = new BasicBSONObject();
    mArgs.put("A", 5L);
    // incomplete args defaults to zero values
    Response response = client.call("Arith.Multiply", mArgs);
    Assert.assertEquals(0L, response.getReply());
View Full Code Here

    client.close();
  }

  @Test
  public void testValidMultipleCalls() throws IOException, GoRpcException, ApplicationException {
    Client client = Client.dialHttp(Util.HOST, Util.PORT, Util.PATH, new BsonClientCodecFactory());

    BSONObject mArgs = new BasicBSONObject();
    mArgs.put("A", 5L);
    mArgs.put("B", 7L);
    Response response = client.call("Arith.Multiply", mArgs);
View Full Code Here

    client.close();
  }

  @Test
  public void testCallOnClosedClient() throws IOException, GoRpcException, ApplicationException {
    Client client = Client.dialHttp(Util.HOST, Util.PORT, Util.PATH, new BsonClientCodecFactory());

    BSONObject mArgs = new BasicBSONObject();
    mArgs.put("A", 5L);
    mArgs.put("B", 7L);
    Response response = client.call("Arith.Multiply", mArgs);
View Full Code Here

TOP

Related Classes of com.youtube.vitess.gorpc.codecs.bson.BsonClientCodecFactory

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.