Package org.bson

Examples of org.bson.BasicBSONObject


  @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) {
      Assert.assertTrue(e.getMessage().contains("rpc: can't find method"));
    }
View Full Code Here


  }

  @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());
    Assert.assertNull(response.getError());
    client.close();
View Full Code Here

  @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);
    Assert.assertEquals(35L, response.getReply());

    mArgs = new BasicBSONObject();
    mArgs.put("A", 2L);
    mArgs.put("B", 3L);
    response = client.call("Arith.Multiply", mArgs);
    Assert.assertEquals(6L, response.getReply());

    client.close();
  }
View Full Code Here

  @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);
    Assert.assertEquals(35L, response.getReply());
    client.close();

    try {
View Full Code Here

    this.client = client;
  }

  @Override
  public Object begin() throws ConnectionException {
    Response response = call("VTGate.Begin", new BasicBSONObject());
    return response.getReply();
  }
View Full Code Here

      throw new IllegalArgumentException("Can not parse message " + message.getClass());
    }
  }

  protected BSONObject create(Query query) {
    BSONObject bsonMessage = new BasicBSONObject();
    bsonMessage.put("TransactionId", query.getSession().getTransactionId());
    bsonMessage.put("SessionId", query.getSession().getSessionId());
    bsonMessage.put("BindVariables", bindVariablesToMap(query.getBindVariablesList()));
    bsonMessage.put("Sql", query.getSql().toByteArray());
    return bsonMessage;
  }
View Full Code Here

    bsonMessage.put("Sql", query.getSql().toByteArray());
    return bsonMessage;
  }

  protected BSONObject bindVariablesToMap(List<BindVariable> bindVariableList) {
    BSONObject bsonBindVariables = new BasicBSONObject();
    for (BindVariable bindVariable : bindVariableList) {
      addTypeField(bsonBindVariables, bindVariable);
    }
    return bsonBindVariables;
  }
View Full Code Here

        break;
    }
  }

  protected BSONObject create(SessionParams sessionParams) {
    BSONObject bsonMessage = new BasicBSONObject();
    bsonMessage.put("Keyspace", sessionParams.getKeyspace());
    bsonMessage.put("Shard", sessionParams.getShard());
    return bsonMessage;
  }
View Full Code Here

    bsonMessage.put("Shard", sessionParams.getShard());
    return bsonMessage;
  }

  protected BSONObject create(QueryList queryList) {
    BSONObject bsonQueryList = new BasicBSONObject();
    bsonQueryList.put("TransactionId", queryList.getSession().getTransactionId());
    bsonQueryList.put("SessionId", queryList.getSession().getSessionId());

    BasicBSONList bsonQueries = new BasicBSONList();
    for (int i = 0; i < queryList.getQueriesCount(); i++) {
      BoundQuery boundQuery = queryList.getQueries(i);
      BSONObject bsonQuery = new BasicBSONObject();
      bsonQuery.put("BindVariables", bindVariablesToMap(boundQuery.getBindVariablesList()));
      bsonQuery.put("Sql", boundQuery.getSql().toStringUtf8());
      bsonQueries.put(i, bsonQuery);
    }

    bsonQueryList.put("Queries", bsonQueries);
    return bsonQueryList;
View Full Code Here

    return bsonQueryList;

  }

  protected BSONObject create(Session session) {
    BSONObject bsonMessage = new BasicBSONObject();
    bsonMessage.put("TransactionId", session.getTransactionId());
    bsonMessage.put("SessionId", session.getSessionId());
    return bsonMessage;
  }
View Full Code Here

TOP

Related Classes of org.bson.BasicBSONObject

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.