// for issue 278 @Test public void test_clob() throws IOException, SQLException { dao.create(BinObject.class, true); BinObject bin = new BinObject(); File f = File.createTempFile("clob", "data"); Files.write(f, "中文"); bin.setMyClob(new SimpleClob(f)); dao.insert(bin); bin = dao.fetch(BinObject.class); String str = Lang.readAll(bin.getMyClob().getCharacterStream()); assertEquals("中文", str); }
@Test public void test_blob() throws IOException { // For mysql only if (dao.meta().isMySql()) { dao.create(BinObject.class, true); BinObject obj = new BinObject(); obj.setXblob(new ByteArrayInputStream("中文".getBytes())); obj.setXclob(new StringReader("不是英文")); dao.insert(obj); BinObject db_obj = dao.fetch(BinObject.class); assertTrue(Streams.equals(new ByteArrayInputStream("中文".getBytes()), db_obj.getXblob())); assertEquals("不是英文", Lang.readAll(db_obj.getXclob())); } }