Format format = Format.JSON; PrintStream out = System.out; RDBDocumentSerializer ser = new RDBDocumentSerializer(new MemoryDocumentStore()); String columns = null;
@NotNull protected <T extends Document> T convertFromDBObject(@NotNull Collection<T> collection, @NotNull RDBRow row) { // this method is present here in order to facilitate unit testing for OAK-3566 return ser.fromRow(collection, row); }
@NotNull private static StringBuilder dumpRow(RDBDocumentSerializer ser, String id, RDBRow row) { NodeDocument doc = ser.fromRow(Collection.NODES, row); String docjson = ser.asString(doc, EXCLUDE_COLUMNS); StringBuilder fulljson = new StringBuilder(); fulljson.append("{\"_id\":\""); JsopBuilder.escape(id, fulljson); fulljson.append("\","); fulljson.append(docjson.substring(1)); return fulljson; }
String s = fromBlobData(bdata); json = new JsopTokenizer(s); json.read('{'); readDocumentFromJson(json, doc); json.read(JsopReader.END); blobInUse = true; throw new DocumentStoreException("expected literal \"blob\" but found: " + row.getData()); readDocumentFromJson(json, doc); } else if (next == JsopReader.STRING) { if (!blobInUse) { applyUpdate(doc, update, op); checkSdType(doc);
String data = this.ser.asString(document, tmd.getColumnOnlyProperties()); Number hasBinary = (Number) document.get(NodeDocument.HAS_BINARY_FLAG); Boolean deletedOnce = (Boolean) document.get(NodeDocument.DELETED_ONCE);
String s = fromBlobData(bdata); json = new JsopTokenizer(s); json.read('{'); readDocumentFromJson(json, doc); json.read(JsopReader.END); blobInUse = true; throw new DocumentStoreException("expected literal \"blob\" but found: " + row.getData()); readDocumentFromJson(json, doc); } else if (next == JsopReader.STRING) { if (!blobInUse) { applyUpdate(doc, update, op); checkSdType(doc);
String data = ser.asString(d, tmd.getColumnOnlyProperties()); byte bytes[] = asBytes(data); if (bytes.length > longest) {
@NotNull protected <T extends Document> T convertFromDBObject(@NotNull Collection<T> collection, @NotNull RDBRow row) { // this method is present here in order to facilitate unit testing for OAK-3566 return ser.fromRow(collection, row); }
@NotNull private static StringBuilder dumpRow(RDBDocumentSerializer ser, String id, RDBRow row) { NodeDocument doc = ser.fromRow(Collection.NODES, row); String docjson = ser.asString(doc, EXCLUDE_COLUMNS); StringBuilder fulljson = new StringBuilder(); fulljson.append("{\"_id\":\""); JsopBuilder.escape(id, fulljson); fulljson.append("\","); fulljson.append(docjson.substring(1)); return fulljson; }
Format format = Format.JSON; PrintStream out = System.out; RDBDocumentSerializer ser = new RDBDocumentSerializer(new MemoryDocumentStore()); String columns = null;
String data = ser.asString(d, tmd.getColumnOnlyProperties()); byte bytes[] = asBytes(data); if (bytes.length > longest) {
@Test public void testSimpleBoth() throws UnsupportedEncodingException { try { RDBRow row = new RDBRow("_foo", 1L, false, 1l, 2l, 3l, 0L, 0L, 0L, "{}", "{}".getBytes("UTF-8")); this.ser.fromRow(Collection.NODES, row); fail("should fail"); } catch (DocumentStoreException expected) { } }
@Before public void setUp() throws Exception { store = fixture.createDocumentStore(); ser = new RDBDocumentSerializer(store); }
String data = this.ser.asString(document, tmd.getColumnOnlyProperties()); Number hasBinary = (Number) document.get(NodeDocument.HAS_BINARY_FLAG); Boolean deletedOnce = (Boolean) document.get(NodeDocument.DELETED_ONCE);
@Test public void testBlobAndDiffBorked() throws UnsupportedEncodingException { try { RDBRow row = new RDBRow("_foo", 1L, false, 1l, 2l, 3l, 0L, 0L, 0L, "[[\"\", \"\", \"\"]]", "{}".getBytes("UTF-8")); this.ser.fromRow(Collection.NODES, row); fail("should fail"); } catch (DocumentStoreException expected) { } }
public RDBDocumentStoreJDBCTest(DocumentStoreFixture dsf) { super(dsf); assumeTrue(super.rdbDataSource != null); dbInfo = RDBDocumentStoreDB.getValue(((RDBDocumentStore) super.ds).getMetadata().get("db")); RDBDocumentSerializer ser = new RDBDocumentSerializer(super.ds); jdbc = new RDBDocumentStoreJDBC(dbInfo, ser, 100, 10000); }
try { for (T document : sortedDocs) { String data = this.ser.asString(document, tmd.getColumnOnlyProperties()); String id = document.getId(); Number hasBinary = (Number) document.get(NodeDocument.HAS_BINARY_FLAG);
@Test public void testSimpleBlobGzipped() throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); GZIPOutputStream gos = new GZIPOutputStream(bos); gos.write("{}".getBytes("UTF-8")); gos.close(); RDBRow row = new RDBRow("_foo", 0L, false, 1l, 2l, 3l, 0L, 0L, 0L, "\"blob\"", bos.toByteArray()); NodeDocument doc = this.ser.fromRow(Collection.NODES, row); assertEquals("_foo", doc.getId()); assertEquals(false, doc.hasBinary()); assertEquals(2L, doc.getModCount().longValue()); }
try { for (T document : sortedDocs) { String data = this.ser.asString(document, tmd.getColumnOnlyProperties()); String id = document.getId(); Number hasBinary = (Number) document.get(NodeDocument.HAS_BINARY_FLAG);
@Test public void testInvalidGzip() { try { byte[] bytes = { 31, -117, 1, 2, 3, 4 }; RDBRow row = new RDBRow("_foo", 0L, false, 1l, 2l, 3l, 0L, 0L, 0L, "\"blob\"", bytes); this.ser.fromRow(Collection.NODES, row); fail("should fail"); } catch (DocumentStoreException expected) { } } }