Examples of TDHSResponse


Examples of com.taobao.tdhs.client.response.TDHSResponse

  @Test
  public void testGet36() throws TDHSException {
    try {
      Filter f = new Filter(fields[2], FilterFlag.TDHS_NOT, level);
      TDHSResponse r = client.get(db, table, index, new String[] {
          fields[0], fields[2] }, new String[][] { { name } },
          FindFlag.TDHS_IN, 0, 100, new Filter[] { f });
      Assert.assertEquals(ClientStatus.OK, r.getStatus());
      Assert.assertEquals(0, r.getFieldData().size());
    } catch (TDHSException e) {
      throw new TDHSException("Get1 exception", e);
    }
  }
View Full Code Here

Examples of com.taobao.tdhs.client.response.TDHSResponse

      // 此get方法调用get(String db, String table, String index, String
      // fields[], String keys[][],TDHSCommon.FindFlag findFlag, int
      // start, int limit, Filter filters[])
      // 其中start设置为0, limit设置为1
      // 所以下面判断getFieldData().size()为1(从数据库中看应该为5,特此说明)
      TDHSResponse r = client.get(db, table, index, new String[] {
          fields[0], fields[2] }, new String[][] { { name } });
      Assert.assertEquals(ClientStatus.OK, r.getStatus());
      Assert.assertEquals(1, r.getFieldData().size());
    } catch (TDHSException e) {
      throw new TDHSException("Get2 exception:" + e.getMessage());
    }
  }
View Full Code Here

Examples of com.taobao.tdhs.client.response.TDHSResponse

    }
  }

  @Test
  public void testNullIndex() throws TDHSException {
    TDHSResponse r = client.query().use(db).from(table).select(fields)
        .where().index("").equal("a").and().field("level")
        .greaterEqual("9").get();
    Assert.assertEquals(ClientStatus.NOT_FOUND, r.getStatus());

    // 为null时使用主键索引
    r = client.query().use(db).from(table).select(fields).where()
        .index(null).equal("a").and().field("level").greaterEqual("9")
        .get();
    Assert.assertEquals(ClientStatus.OK, r.getStatus());

    r = client.query().use(db).from(table).select(fields).where()
        .index("NoThisIndex").equal("a").and().field("level")
        .equal("9").get();
    Assert.assertEquals(ClientStatus.NOT_FOUND, r.getStatus());

    r = client.query().use(db).from(table).select(fields).where()
        .index(index).equal("a").and().field("level").equal("9")
        .limit(-1, -1).get();
    Assert.assertEquals(ClientStatus.OK, r.getStatus());
  }
View Full Code Here

Examples of com.taobao.tdhs.client.response.TDHSResponse

    }
  }

  @Test
  public void testNullNot() throws TDHSException {
    TDHSResponse r = client.query().use(db).from(table).where().equal("a")
        .and().field("name").not("").get();
    Assert.assertEquals(ClientStatus.BAD_REQUEST, r.getStatus());

    r = client.query().use(db).from(table).where().equal("a").and()
        .field("name").not(null).get();
    Assert.assertEquals(ClientStatus.BAD_REQUEST, r.getStatus());
  }
View Full Code Here

Examples of com.taobao.tdhs.client.response.TDHSResponse

  }

  @Test
  public void testSepcialChar() {
    try {
      TDHSResponse r = client.query()
          .use("~!@#$%^&*(\\\")_+-=[]{}<>?,./")
          .from("~!@#$%^&*(\\\")_+-=[]{}<>?,./")
          .select("~!@#$%^&*(\\\")_+-=[]{}<>?,./").where()
          .equal("~!@#$%^&*(\\\")_+-=[]{}<>?,./").and()
          .field("~!@#$%^&*(\\\")_+-=[]{}<>?,./")
          .greaterEqual("~!@#$%^&*(\\\")_+-=[]{}<>?,./").get();
      Assert.assertEquals(ClientStatus.NOT_FOUND, r.getStatus());
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
View Full Code Here

Examples of com.taobao.tdhs.client.response.TDHSResponse

    } catch (Exception e) {
      Assert.assertEquals("field's size not match updateEntries's size",
          e.getMessage());
    }

    TDHSResponse r = client.update("a", "b", "c", new String[] { "d" },
        new ValueEntry[1], new String[][] { { "e" } },
        FindFlag.TDHS_EQ, 0, 100, null);
    Assert.assertEquals(ClientStatus.BAD_REQUEST, r.getStatus());
  }
View Full Code Here

Examples of com.taobao.tdhs.client.response.TDHSResponse

    try {
      id = rand.nextInt() + "";
      name = UUID.randomUUID().toString().substring(0, 12);
      level = rand.nextInt() + "";

      TDHSResponse response = client.insert().use(db).from(table)
          .value(fields[0], id).value(fields[1], name)
          .value(fields[2], level).insert();

      Assert.assertEquals(ClientStatus.OK, response.getStatus());
    } catch (TDHSException e) {
      Assert.fail("Insert exception:" + e.getMessage());
    }
  }
View Full Code Here

Examples of com.taobao.tdhs.client.response.TDHSResponse

  }

  @After
  public void clean() {
    try {
      TDHSResponse response = client.query().use(db).from(table).where()
          .equal(id).delete();

      Assert.assertEquals(ClientStatus.OK, response.getStatus());
    } catch (TDHSException e) {
      Assert.fail("Delete exception:" + e.getMessage());
    }
  }
View Full Code Here

Examples of com.taobao.tdhs.client.response.TDHSResponse

    }
  }

  @Test
  public void testDuplicateInsert() throws TDHSException {
    TDHSResponse response = client.insert().use(db).from(table)
        .value(fields[0], id).value(fields[1], name)
        .value(fields[2], level).insert();

    Assert.assertEquals(ClientStatus.DB_ERROR, response.getStatus());
  }
View Full Code Here

Examples of com.taobao.tdhs.client.response.TDHSResponse

   * update unit_test set name='my_name_updated' where id=9999
   */
  @Test
  public void test02Update() throws TDHSException {
    name = UUID.randomUUID().toString().substring(0, 12);
    TDHSResponse response = client.query().use(db).from(table).set()
        .field(fields[1]).set(name).where().equal(id).update();

    Assert.assertEquals("1", response.getFieldData().get(0).get(0));
    Assert.assertEquals(ClientStatus.OK, response.getStatus());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.