Examples of TDHSResponse


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

    @Test
    public void testTenThousand() throws TDHSException {
        TableInfo tableInfo = new TableInfo(db, table, null, fields);
        Get get = new Get(tableInfo, new String[][]{{"-1"}},
                FindFlag.TDHS_GE, 0, 10000);
        TDHSResponse r = client.get(get);
        Assert.assertEquals(ClientStatus.OK, r.getStatus());
        Assert.assertEquals(10000, r.getFieldData().size());
    }
View Full Code Here

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

    public void testHundredThousand() throws TDHSException {
        TableInfo tableInfo = new TableInfo(db, table, null,
                new String[]{fields[0]});
        Get get = new Get(tableInfo, new String[][]{{"-1"}},
                FindFlag.TDHS_GE, 0, 100000);
        TDHSResponse r = client.get(get);
        Assert.assertEquals(ClientStatus.OK, r.getStatus());
        Assert.assertEquals(100000, r.getFieldData().size());
    }
View Full Code Here

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

   * 此处自动把非数字字符串转换0,具体需要在数据库中my.ini中配置
   * sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
   */
  @Test
  public void testIllegalValue() throws TDHSException {
    TDHSResponse r = client.insert().use(db).from(table)
        .value(fields[0], "asd").value(fields[1], "31")
        .value(fields[2], "mmm").insert();
    Assert.assertEquals(ClientStatus.OK, r.getStatus());

    r = client.delete(db, table, null, new String[][] { { "0" } },
        FindFlag.TDHS_EQ, 0, 100, null);
    Assert.assertEquals(ClientStatus.OK, r.getStatus());
  }
View Full Code Here

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

   * 此处自动把非数字字符串转换0,具体需要在数据库中my.ini中配置
   * sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
   */
  @Test
  public void testMissField() throws TDHSException {
    TDHSResponse r = client.insert().use(db).from(table)
        .value(fields[0], "1").value(fields[2], "10").insert();
    Assert.assertEquals(ClientStatus.OK, r.getStatus());

    r = client.delete(db, table, null, new String[][] { { "1" } },
        FindFlag.TDHS_EQ, 0, 100, null);
    Assert.assertEquals(ClientStatus.OK, r.getStatus());
  }
View Full Code Here

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

    Assert.assertEquals(ClientStatus.OK, r.getStatus());
  }

  @Test
  public void testNullValue() throws TDHSException {
    TDHSResponse r = client.insert().use(db).from(table)
        .value(fields[0], (String) null).insert();
    Assert.assertEquals(ClientStatus.OK, r.getStatus());

    r = client.delete(db, table, null, new String[][] { { "0" } },
        FindFlag.TDHS_EQ, 0, 100, null);
    Assert.assertEquals(ClientStatus.OK, r.getStatus());

    r = client.insert().use(db).from(table).value(fields[0], "").insert();
    Assert.assertEquals(ClientStatus.OK, r.getStatus());

    r = client.delete(db, table, null, new String[][] { { "0" } },
        FindFlag.TDHS_EQ, 0, 100, null);
    Assert.assertEquals(ClientStatus.OK, r.getStatus());
  }
View Full Code Here

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

    Assert.assertEquals(ClientStatus.OK, r.getStatus());
  }

  @Test
  public void testNullField() throws TDHSException {
    TDHSResponse r = client.insert().use(db).from(table).value(null, "abc")
        .insert();
    Assert.assertEquals(ClientStatus.NOT_FOUND, r.getStatus());

    client.insert().use(db).from(table).value("", "abc").insert();
    Assert.assertEquals(ClientStatus.NOT_FOUND, r.getStatus());
  }
View Full Code Here

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

    Assert.assertEquals(ClientStatus.NOT_FOUND, r.getStatus());
  }

  @Test
  public void testSpecialChar() throws TDHSException {
    TDHSResponse r = client
        .insert()
        .use(db)
        .from(table)
        .value("~!@#$%^&*()_+-={}[]<>?,./:;\\\"'",
            "~!@#$%^&*()_+-={}[]<>?,./:;\\\"'").insert();
    Assert.assertEquals(ClientStatus.NOT_FOUND, r.getStatus());
  }
View Full Code Here

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

    @Test
    public void testBetween() throws TDHSException {
        TDHSClient client = new TDHSClientImpl(new InetSocketAddress("t-wentong-u.local", 9999), 1);

        TDHSResponse r = client.query().use("test").select("id", "v", "i").from("test").where().fields("i")
                .between(new String[]{"2"},
                        new String[]{"5"}).and().field("i").not("2").and().field("i").not("5").get();

        List<List<String>> fieldData = r.getFieldData();
        for (List<String> fd : fieldData) {
            for (String v : fd) {
                System.out.print(v + " ");
            }
            System.out.print("\n");
View Full Code Here

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

  @Test
  public void testDifferentCharset() throws TDHSException {
    try {
      client.setCharsetName("gbk");

      TDHSResponse r = client.insert(db, table, fields, new String[] {
          "999", "中文", "999" });

      Assert.assertEquals(ClientStatus.OK, r.getStatus());

      r = client.get(db, table, null, fields,
          new String[][] { { "999" } });

      Assert.assertEquals(ClientStatus.OK, r.getStatus());
      Assert.assertEquals("", r.getFieldData().get(0).get(1));

      client.setCharsetName("utf8");

    } finally {
      TDHSResponse r = client.delete(db, table, null,
          new String[][] { { "999" } }, FindFlag.TDHS_EQ, 0, 1, null);
      Assert.assertEquals(ClientStatus.OK, r.getStatus());
      Assert.assertEquals("1", r.getFieldData().get(0).get(0));
    }
  }
View Full Code Here

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

                } else {
                    if (TDHSResponseEnum.ClientStatus.ACCEPT.equals(ret.getClientStatus())) {
                        retData.write(ret.getData());
                    } else if (TDHSResponseEnum.ClientStatus.OK.equals(ret.getClientStatus())) {
                        retData.write(ret.getData());
                        return new TDHSResponse(ret.getClientStatus(), metaData, retData.toByteArray(),
                                charsetName);
                    } else if (ret.getClientStatus() != null && ret.getClientStatus().getStatus() >= 400 &&
                            ret.getClientStatus().getStatus() < 600) {
                        return new TDHSResponse(ret.getClientStatus(), metaData, ret.getData(), charsetName);
                    } else {
                        throw new TDHSException("unknown response code! [" + (ret.getClientStatus() != null ?
                                String.valueOf(ret.getClientStatus().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.