|
2 | 2 |
|
3 | 3 | import java.util.List; |
4 | 4 |
|
| 5 | +import org.json.JSONArray; |
5 | 6 | import org.json.JSONObject; |
6 | 7 |
|
7 | 8 | import com.peersafe.base.client.pubsub.Publisher.Callback; |
@@ -64,7 +65,8 @@ private static void testChainSql() { |
64 | 65 | // test.insertAfterGrant(); |
65 | 66 |
|
66 | 67 | //根据sql语句查询,有签名检测 |
67 | | -// test.testGetBySqlUser(); |
| 68 | + |
| 69 | + test.testGetBySqlUser(); |
68 | 70 |
|
69 | 71 | //根据sql语句查询,admin权限,无签名检测 |
70 | 72 | // test.testGetBySqlAdmin(); |
@@ -188,9 +190,25 @@ public void testts() { |
188 | 190 | public void testCreateTable() { |
189 | 191 | List<String> args = Util.array("{'field':'id','type':'int','length':11,'PK':1,'NN':1,'UQ':1}", |
190 | 192 | "{'field':'name','type':'varchar','length':50,'default':null}", "{'field':'age','type':'int'}"); |
| 193 | + |
| 194 | +// List<String> args = Util.array("{'field':'id','type':'decimal','length':1}"); |
191 | 195 | JSONObject obj; |
192 | 196 | obj = c.createTable(sTableName,args,false).submit(SyncCond.db_success); |
193 | 197 | System.out.println("create result:" + obj); |
| 198 | +// int number = 3; |
| 199 | +// while(true) { |
| 200 | +// List<String> args = Util.array("{'field':'id','type':'int','length':11,'PK':1,'NN':1,'UQ':1}", |
| 201 | +// "{'field':'name','type':'varchar','length':50,'default':null}", "{'field':'age','type':'int'}"); |
| 202 | +// JSONObject obj; |
| 203 | +// obj = c.createTable(sTableName + number++,args,false).submit(); |
| 204 | +// System.out.println("create result:" + obj); |
| 205 | +// try { |
| 206 | +// Thread.sleep(1000); |
| 207 | +// } catch (InterruptedException e) { |
| 208 | +// // TODO Auto-generated catch block |
| 209 | +// e.printStackTrace(); |
| 210 | +// } |
| 211 | +// } |
194 | 212 | } |
195 | 213 |
|
196 | 214 | public void testinsert() { |
@@ -247,7 +265,7 @@ public void testget() { |
247 | 265 |
|
248 | 266 | // //查询单条数据 |
249 | 267 | // JSONObject obj = c.table(sTableName).get(Util.array("{id:1}")).withFields("[]").submit(); |
250 | | - |
| 268 | + c.use(rootAddress); |
251 | 269 | //查询所有数据 |
252 | 270 | JSONObject obj = c.table(sTableName).get(Util.array("{name:hello}")).submit(); |
253 | 271 | System.out.println("get result:" + obj); |
@@ -298,26 +316,6 @@ public void testGetBySqlUser() { |
298 | 316 | // JSONObject obj = c.getBySqlUser("insert into t_" + ret.getString("nameInDB") + " values()"); |
299 | 317 | System.out.println("get_sql_user sync result:" + obj); |
300 | 318 | } |
301 | | - |
302 | | -// c.getTableNameInDB(rootAddress, sTableName, new Callback<JSONObject>(){ |
303 | | -// |
304 | | -// @Override |
305 | | -// public void called(JSONObject args) { |
306 | | -// if(ret.has("nameInDB")) { |
307 | | -// String sql = "select * from t_" + ret.getString("nameInDB"); |
308 | | -// c.getBySqlUser(sql,new Callback<JSONObject>() { |
309 | | -// |
310 | | -// @Override |
311 | | -// public void called(JSONObject args) { |
312 | | -// System.out.println("get_sql_user async result:" + args); |
313 | | -// } |
314 | | -// |
315 | | -// }); |
316 | | -// |
317 | | -// } |
318 | | -// } |
319 | | -// |
320 | | -// }); |
321 | 319 | } |
322 | 320 |
|
323 | 321 | public void grant() { |
|
0 commit comments