()
| 316 | } |
| 317 | |
| 318 | public void testSelect() { |
| 319 | byte[] k = new byte[5]; |
| 320 | byte[] r = new byte[5]; |
| 321 | Database db; |
| 322 | Environment env = new Environment(); |
| 323 | try { |
| 324 | env.create("jtest.db"); |
| 325 | db = env.createDatabase((short)1); |
| 326 | for (int i = 0; i < 100; i++) { |
| 327 | k[0] = (byte)i; |
| 328 | r[0] = (byte)i; |
| 329 | db.insert(k, r); |
| 330 | } |
| 331 | |
| 332 | Result result = env.select("COUNT($key) FROM DATABASE 1"); |
| 333 | assertEquals(result.getRowCount(), 1); |
| 334 | assertEquals(result.getKeyType(), Const.UPS_TYPE_BINARY); |
| 335 | |
| 336 | byte[] r1 = result.getRecordData(); |
| 337 | ByteBuffer b1 = ByteBuffer.wrap(r1); |
| 338 | b1.order(ByteOrder.LITTLE_ENDIAN); |
| 339 | assertEquals(b1.getInt(), 100); |
| 340 | |
| 341 | byte[] r2 = result.getRecord(0); |
| 342 | ByteBuffer b2 = ByteBuffer.wrap(r2); |
| 343 | b2.order(ByteOrder.LITTLE_ENDIAN); |
| 344 | assertEquals(b2.getInt(), 100); |
| 345 | |
| 346 | db.close(); |
| 347 | } |
| 348 | catch (DatabaseException err) { |
| 349 | fail("Exception "+err); |
| 350 | } |
| 351 | env.close(); |
| 352 | } |
| 353 | |
| 354 | public void testSelectRange() { |
| 355 | byte[] k = new byte[5]; |
nothing calls this directly
no test coverage detected