You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by re...@apache.org on 2017/02/22 14:39:03 UTC
svn commit: r1784023 - in /jackrabbit/oak/trunk/oak-core/src:
main/java/org/apache/jackrabbit/oak/plugins/document/rdb/
test/java/org/apache/jackrabbit/oak/plugins/document/
test/java/org/apache/jackrabbit/oak/plugins/document/rdb/
Author: reschke
Date: Wed Feb 22 14:39:03 2017
New Revision: 1784023
URL: http://svn.apache.org/viewvc?rev=1784023&view=rev
Log:
OAK-5751: RDBDocumentStore: properly handle null values for system properties
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentSerializer.java
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStore.java
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStoreJDBC.java
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBExport.java
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBRow.java
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/BasicDocumentStoreTest.java
jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentSerializerTest.java
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentSerializer.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentSerializer.java?rev=1784023&r1=1784022&r2=1784023&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentSerializer.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentSerializer.java Wed Feb 22 14:39:03 2017
@@ -160,11 +160,11 @@ public class RDBDocumentSerializer {
if (RDBDocumentStore.USECMODCOUNT && row.getCollisionsModcount() != RDBRow.LONG_UNSET) {
doc.put(CMODCOUNT, row.getCollisionsModcount());
}
- if (row.hasBinaryProperties()) {
- doc.put(HASBINARY, NodeDocument.HAS_BINARY_VAL);
+ if (row.hasBinaryProperties() != null) {
+ doc.put(HASBINARY, row.hasBinaryProperties().longValue());
}
- if (row.deletedOnce()) {
- doc.put(DELETEDONCE, Boolean.TRUE);
+ if (row.deletedOnce() != null) {
+ doc.put(DELETEDONCE, row.deletedOnce().booleanValue());
}
byte[] bdata = row.getBdata();
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStore.java?rev=1784023&r1=1784022&r2=1784023&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStore.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStore.java Wed Feb 22 14:39:03 2017
@@ -1622,10 +1622,8 @@ public class RDBDocumentStore implements
String data = null;
try {
connection = this.ch.getRWConnection();
- Number flagB = (Number) document.get(NodeDocument.HAS_BINARY_FLAG);
- Boolean hasBinary = flagB != null && flagB.intValue() == NodeDocument.HAS_BINARY_VAL;
- Boolean flagD = (Boolean) document.get(NodeDocument.DELETED_ONCE);
- Boolean deletedOnce = flagD != null && flagD.booleanValue();
+ Number hasBinary = (Number) document.get(NodeDocument.HAS_BINARY_FLAG);
+ Boolean deletedOnce = (Boolean) document.get(NodeDocument.DELETED_ONCE);
Long modcount = (Long) document.get(MODCOUNT);
Long cmodcount = (Long) document.get(COLLISIONSMODCOUNT);
boolean success = false;
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStoreJDBC.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStoreJDBC.java?rev=1784023&r1=1784022&r2=1784023&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStoreJDBC.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStoreJDBC.java Wed Feb 22 14:39:03 2017
@@ -84,7 +84,7 @@ public class RDBDocumentStoreJDBC {
}
public boolean appendingUpdate(Connection connection, RDBTableMetaData tmd, String id, Long modified,
- boolean setModifiedConditionally, Boolean hasBinary, Boolean deletedOnce, Long modcount, Long cmodcount,
+ boolean setModifiedConditionally, Number hasBinary, Boolean deletedOnce, Long modcount, Long cmodcount,
Long oldmodcount, String appendData) throws SQLException {
String appendDataWithComma = "," + appendData;
PreparedStatementComponent stringAppend = this.dbInfo.getConcatQuery(appendDataWithComma, tmd.getDataLimitInOctets());
@@ -104,8 +104,8 @@ public class RDBDocumentStoreJDBC {
if (setModifiedConditionally) {
stmt.setObject(si++, modified, Types.BIGINT);
}
- stmt.setObject(si++, hasBinary ? 1 : 0, Types.SMALLINT);
- stmt.setObject(si++, deletedOnce ? 1 : 0, Types.SMALLINT);
+ stmt.setObject(si++, hasBinaryAsNullOrInteger(hasBinary), Types.SMALLINT);
+ stmt.setObject(si++, deletedOnceAsNullOrInteger(deletedOnce), Types.SMALLINT);
stmt.setObject(si++, modcount, Types.BIGINT);
stmt.setObject(si++, cmodcount == null ? Long.valueOf(0) : cmodcount, Types.BIGINT);
stmt.setObject(si++, appendDataWithComma.length(), Types.BIGINT);
@@ -304,9 +304,8 @@ public class RDBDocumentStoreJDBC {
int si = 1;
setIdInStatement(tmd, stmt, si++, id);
stmt.setObject(si++, document.get(MODIFIED), Types.BIGINT);
- stmt.setObject(si++, (hasBinary != null && hasBinary.intValue() == NodeDocument.HAS_BINARY_VAL) ? 1 : 0,
- Types.SMALLINT);
- stmt.setObject(si++, (deletedOnce != null && deletedOnce) ? 1 : 0, Types.SMALLINT);
+ stmt.setObject(si++, hasBinaryAsNullOrInteger(hasBinary), Types.SMALLINT);
+ stmt.setObject(si++, deletedOnceAsNullOrInteger(deletedOnce), Types.SMALLINT);
stmt.setObject(si++, document.get(MODCOUNT), Types.BIGINT);
stmt.setObject(si++, cmodcount == null ? Long.valueOf(0) : cmodcount, Types.BIGINT);
stmt.setObject(si++, data.length(), Types.BIGINT);
@@ -383,9 +382,8 @@ public class RDBDocumentStoreJDBC {
int si = 1;
stmt.setObject(si++, document.get(MODIFIED), Types.BIGINT);
- stmt.setObject(si++, (hasBinary != null && hasBinary.intValue() == NodeDocument.HAS_BINARY_VAL) ? 1 : 0,
- Types.SMALLINT);
- stmt.setObject(si++, (deletedOnce != null && deletedOnce) ? 1 : 0, Types.SMALLINT);
+ stmt.setObject(si++, hasBinaryAsNullOrInteger(hasBinary), Types.SMALLINT);
+ stmt.setObject(si++, deletedOnceAsNullOrInteger(deletedOnce), Types.SMALLINT);
stmt.setObject(si++, modcount, Types.BIGINT);
stmt.setObject(si++, cmodcount == null ? Long.valueOf(0) : cmodcount, Types.BIGINT);
stmt.setObject(si++, data.length(), Types.BIGINT);
@@ -512,11 +510,11 @@ public class RDBDocumentStoreJDBC {
long modified = readLongFromResultSet(rs, 2);
long modcount = readLongFromResultSet(rs, 3);
long cmodcount = readLongFromResultSet(rs, 4);
- long hasBinary = rs.getLong(5);
- long deletedOnce = rs.getLong(6);
+ Long hasBinary = readLongOrNullFromResultSet(rs, 5);
+ Boolean deletedOnce = readBooleanOrNullFromResultSet(rs, 6);
String data = rs.getString(7);
byte[] bdata = rs.getBytes(8);
- result.add(new RDBRow(id, hasBinary == 1, deletedOnce == 1, modified, modcount, cmodcount, data, bdata));
+ result.add(new RDBRow(id, hasBinary, deletedOnce, modified, modcount, cmodcount, data, bdata));
dataTotal += data.length();
bdataTotal += bdata == null ? 0 : bdata.length;
}
@@ -584,11 +582,11 @@ public class RDBDocumentStoreJDBC {
long modified = readLongFromResultSet(rs, col++);
long modcount = readLongFromResultSet(rs, col++);
long cmodcount = readLongFromResultSet(rs, col++);
- long hasBinary = rs.getLong(col++);
- long deletedOnce = rs.getLong(col++);
+ Long hasBinary = readLongOrNullFromResultSet(rs, col++);
+ Boolean deletedOnce = readBooleanOrNullFromResultSet(rs, col++);
String data = rs.getString(col++);
byte[] bdata = rs.getBytes(col++);
- RDBRow row = new RDBRow(id, hasBinary == 1, deletedOnce == 1, modified, modcount, cmodcount, data, bdata);
+ RDBRow row = new RDBRow(id, hasBinary, deletedOnce, modified, modcount, cmodcount, data, bdata);
rows.add(row);
}
} catch (SQLException ex) {
@@ -648,11 +646,11 @@ public class RDBDocumentStoreJDBC {
long modified = readLongFromResultSet(rs, 1);
long modcount = readLongFromResultSet(rs, 2);
long cmodcount = readLongFromResultSet(rs, 3);
- long hasBinary = rs.getLong(4);
- long deletedOnce = rs.getLong(5);
+ Long hasBinary = readLongOrNullFromResultSet(rs, 4);
+ Boolean deletedOnce = readBooleanOrNullFromResultSet(rs, 5);
String data = rs.getString(6);
byte[] bdata = rs.getBytes(7);
- return new RDBRow(id, hasBinary == 1, deletedOnce == 1, modified, modcount, cmodcount, data, bdata);
+ return new RDBRow(id, hasBinary, deletedOnce, modified, modcount, cmodcount, data, bdata);
} else {
return null;
}
@@ -676,7 +674,7 @@ public class RDBDocumentStoreJDBC {
}
}
- public boolean update(Connection connection, RDBTableMetaData tmd, String id, Long modified, Boolean hasBinary,
+ public boolean update(Connection connection, RDBTableMetaData tmd, String id, Long modified, Number hasBinary,
Boolean deletedOnce, Long modcount, Long cmodcount, Long oldmodcount, String data) throws SQLException {
StringBuilder t = new StringBuilder();
@@ -690,8 +688,8 @@ public class RDBDocumentStoreJDBC {
try {
int si = 1;
stmt.setObject(si++, modified, Types.BIGINT);
- stmt.setObject(si++, hasBinary ? 1 : 0, Types.SMALLINT);
- stmt.setObject(si++, deletedOnce ? 1 : 0, Types.SMALLINT);
+ stmt.setObject(si++, hasBinaryAsNullOrInteger(hasBinary), Types.SMALLINT);
+ stmt.setObject(si++, deletedOnceAsNullOrInteger(deletedOnce), Types.SMALLINT);
stmt.setObject(si++, modcount, Types.BIGINT);
stmt.setObject(si++, cmodcount == null ? Long.valueOf(0) : cmodcount, Types.BIGINT);
stmt.setObject(si++, data.length(), Types.BIGINT);
@@ -810,6 +808,31 @@ public class RDBDocumentStoreJDBC {
return res.wasNull() ? RDBRow.LONG_UNSET : v;
}
+ @CheckForNull
+ private static Boolean readBooleanOrNullFromResultSet(ResultSet res, int index) throws SQLException {
+ long v = res.getLong(index);
+ return res.wasNull() ? null : Boolean.valueOf(v != 0);
+ }
+
+ @CheckForNull
+ private static Long readLongOrNullFromResultSet(ResultSet res, int index) throws SQLException {
+ long v = res.getLong(index);
+ return res.wasNull() ? null : Long.valueOf(v);
+ }
+
+ private static final Integer INT_FALSE = 0;
+ private static final Integer INT_TRUE = 1;
+
+ @CheckForNull
+ private static Integer deletedOnceAsNullOrInteger(Boolean b) {
+ return b == null ? null : (b.booleanValue() ? INT_TRUE : INT_FALSE);
+ }
+
+ @CheckForNull
+ private static Integer hasBinaryAsNullOrInteger(Number n) {
+ return n == null ? null : (n.longValue() == 1 ? INT_TRUE : INT_FALSE);
+ }
+
private static <T extends Document> List<T> sortDocuments(Collection<T> documents) {
List<T> result = new ArrayList<T>(documents);
Collections.sort(result, new Comparator<T>() {
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBExport.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBExport.java?rev=1784023&r1=1784022&r2=1784023&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBExport.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBExport.java Wed Feb 22 14:39:03 2017
@@ -42,6 +42,7 @@ import java.util.Locale;
import java.util.Map;
import java.util.Set;
+import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import org.apache.commons.io.IOUtils;
@@ -215,7 +216,7 @@ public class RDBExport {
IOUtils.closeQuietly(is);
}
try {
- RDBRow row = new RDBRow(id, "1".equals(shasbinary), "1".equals(sdeletedonce),
+ RDBRow row = new RDBRow(id, "1".equals(shasbinary) ? 1L : 0L, "1".equals(sdeletedonce),
smodified.length() == 0 ? 0 : Long.parseLong(smodified), Long.parseLong(smodcount),
Long.parseLong(scmodcount), sdata, bytes);
StringBuilder fulljson = dumpRow(ser, id, row);
@@ -314,12 +315,12 @@ public class RDBExport {
long modified = rs.getLong("MODIFIED");
long modcount = rs.getLong("MODCOUNT");
long cmodcount = rs.getLong("CMODCOUNT");
- long hasBinary = rs.getLong("HASBINARY");
- long deletedOnce = rs.getLong("DELETEDONCE");
+ Long hasBinary = readLongOrNullFromResultSet(rs, "HASBINARY");
+ Boolean deletedOnce = readBooleanOrNullFromResultSet(rs, "DELETEDONCE");
String data = rs.getString("DATA");
byte[] bdata = rs.getBytes("BDATA");
- RDBRow row = new RDBRow(id, hasBinary == 1, deletedOnce == 1, modified, modcount, cmodcount, data, bdata);
+ RDBRow row = new RDBRow(id, hasBinary, deletedOnce, modified, modcount, cmodcount, data, bdata);
StringBuilder fulljson = dumpRow(ser, id, row);
if (format == Format.CSV) {
out.println(asCSV(fieldNames, fulljson));
@@ -341,6 +342,18 @@ public class RDBExport {
c.close();
}
+ @CheckForNull
+ private static Boolean readBooleanOrNullFromResultSet(ResultSet res, String field) throws SQLException {
+ long v = res.getLong(field);
+ return res.wasNull() ? null : Boolean.valueOf(v != 0);
+ }
+
+ @CheckForNull
+ private static Long readLongOrNullFromResultSet(ResultSet res, String field) throws SQLException {
+ long v = res.getLong(field);
+ return res.wasNull() ? null : Long.valueOf(v);
+ }
+
@Nonnull
private static StringBuilder dumpRow(RDBDocumentSerializer ser, String id, RDBRow row) {
NodeDocument doc = ser.fromRow(Collection.NODES, row);
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBRow.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBRow.java?rev=1784023&r1=1784022&r2=1784023&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBRow.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBRow.java Wed Feb 22 14:39:03 2017
@@ -31,12 +31,13 @@ public class RDBRow {
public static final long LONG_UNSET = Long.MIN_VALUE;
private final String id;
- private final boolean hasBinaryProperties, deletedOnce;
+ private final Long hasBinaryProperties;
+ private final Boolean deletedOnce;
private final long modified, modcount, cmodcount;
private final String data;
private final byte[] bdata;
- public RDBRow(String id, boolean hasBinaryProperties, boolean deletedOnce, Long modified, Long modcount, Long cmodcount, String data, byte[] bdata) {
+ public RDBRow(String id, Long hasBinaryProperties, Boolean deletedOnce, Long modified, Long modcount, Long cmodcount, String data, byte[] bdata) {
this.id = id;
this.hasBinaryProperties = hasBinaryProperties;
this.deletedOnce = deletedOnce;
@@ -52,11 +53,13 @@ public class RDBRow {
return id;
}
- public boolean hasBinaryProperties() {
+ @CheckForNull
+ public Long hasBinaryProperties() {
return hasBinaryProperties;
}
- public boolean deletedOnce() {
+ @CheckForNull
+ public Boolean deletedOnce() {
return deletedOnce;
}
Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/BasicDocumentStoreTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/BasicDocumentStoreTest.java?rev=1784023&r1=1784022&r2=1784023&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/BasicDocumentStoreTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/BasicDocumentStoreTest.java Wed Feb 22 14:39:03 2017
@@ -91,6 +91,52 @@ public class BasicDocumentStoreTest exte
}
@Test
+ public void testValuesForSystemProps() {
+ String id = this.getClass().getName() + ".testValuesForSystemProps";
+
+ // remove if present
+ NodeDocument nd = super.ds.find(Collection.NODES, id);
+ if (nd != null) {
+ super.ds.remove(Collection.NODES, id);
+ }
+ removeMe.add(id);
+
+ // add
+ UpdateOp up = new UpdateOp(id, true);
+ assertTrue(super.ds.create(Collection.NODES, Collections.singletonList(up)));
+
+ super.ds.invalidateCache();
+ nd = super.ds.find(Collection.NODES, id, 0);
+ assertNull(nd.get(NodeDocument.DELETED_ONCE));
+ assertNull(nd.get(NodeDocument.HAS_BINARY_FLAG));
+ assertFalse(nd.wasDeletedOnce());
+ assertFalse(nd.hasBinary());
+
+ up = new UpdateOp(id, false);
+ up.set(NodeDocument.DELETED_ONCE, true);
+ super.ds.findAndUpdate(Collection.NODES, up);
+
+ super.ds.invalidateCache();
+ nd = super.ds.find(Collection.NODES, id, 0);
+ assertEquals(true, nd.get(NodeDocument.DELETED_ONCE));
+ assertNull(nd.get(NodeDocument.HAS_BINARY_FLAG));
+ assertTrue(nd.wasDeletedOnce());
+ assertFalse(nd.hasBinary());
+
+ up = new UpdateOp(id, false);
+ up.set(NodeDocument.DELETED_ONCE, false);
+ up.set(NodeDocument.HAS_BINARY_FLAG, NodeDocument.HAS_BINARY_VAL);
+ super.ds.findAndUpdate(Collection.NODES, up);
+
+ super.ds.invalidateCache();
+ nd = super.ds.find(Collection.NODES, id, 0);
+ assertEquals(false, nd.get(NodeDocument.DELETED_ONCE));
+ assertEquals(NodeDocument.HAS_BINARY_VAL, nd.get(NodeDocument.HAS_BINARY_FLAG));
+ assertFalse(nd.wasDeletedOnce());
+ assertTrue(nd.hasBinary());
+ }
+
+ @Test
public void testSetId() {
String id = this.getClass().getName() + ".testSetId";
Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentSerializerTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentSerializerTest.java?rev=1784023&r1=1784022&r2=1784023&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentSerializerTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentSerializerTest.java Wed Feb 22 14:39:03 2017
@@ -56,7 +56,7 @@ public class RDBDocumentSerializerTest {
@Test
public void testSimpleString() {
- RDBRow row = new RDBRow("_foo", true, true, 1l, 2l, 3l, "{}", null);
+ RDBRow row = new RDBRow("_foo", 1L, true, 1l, 2l, 3l, "{}", null);
NodeDocument doc = this.ser.fromRow(Collection.NODES, row);
assertEquals("_foo", doc.getId());
assertEquals(true, doc.hasBinary());
@@ -65,8 +65,20 @@ public class RDBDocumentSerializerTest {
}
@Test
+ public void testNoSysprops() {
+ RDBRow row = new RDBRow("_foo", null, null, 1l, 2l, 3l, "{}", null);
+ NodeDocument doc = this.ser.fromRow(Collection.NODES, row);
+ assertEquals("_foo", doc.getId());
+ assertEquals(false, doc.hasBinary());
+ assertNull(null, doc.get(NodeDocument.HAS_BINARY_FLAG));
+ assertEquals(false, doc.wasDeletedOnce());
+ assertNull(null, doc.get(NodeDocument.DELETED_ONCE));
+ assertEquals(2L, doc.getModCount().longValue());
+ }
+
+ @Test
public void testSimpleBlob() throws UnsupportedEncodingException {
- RDBRow row = new RDBRow("_foo", false, false, 1l, 2l, 3l, "\"blob\"", "{}".getBytes("UTF-8"));
+ RDBRow row = new RDBRow("_foo", 0L, false, 1l, 2l, 3l, "\"blob\"", "{}".getBytes("UTF-8"));
NodeDocument doc = this.ser.fromRow(Collection.NODES, row);
assertEquals("_foo", doc.getId());
assertEquals(false, doc.hasBinary());
@@ -75,7 +87,7 @@ public class RDBDocumentSerializerTest {
@Test
public void testSimpleBlob2() throws UnsupportedEncodingException {
- RDBRow row = new RDBRow("_foo", false, false, 1l, 2l, 3l, "\"blob\"",
+ RDBRow row = new RDBRow("_foo", 0L, false, 1l, 2l, 3l, "\"blob\"",
"{\"s\":\"string\", \"b\":true, \"i\":1}".getBytes("UTF-8"));
NodeDocument doc = this.ser.fromRow(Collection.NODES, row);
assertEquals("_foo", doc.getId());
@@ -89,7 +101,7 @@ public class RDBDocumentSerializerTest {
@Test
public void testSimpleBoth() throws UnsupportedEncodingException {
try {
- RDBRow row = new RDBRow("_foo", true, false, 1l, 2l, 3l, "{}", "{}".getBytes("UTF-8"));
+ RDBRow row = new RDBRow("_foo", 1L, false, 1l, 2l, 3l, "{}", "{}".getBytes("UTF-8"));
this.ser.fromRow(Collection.NODES, row);
fail("should fail");
} catch (DocumentStoreException expected) {
@@ -98,7 +110,7 @@ public class RDBDocumentSerializerTest {
@Test
public void testBlobAndDiff() throws UnsupportedEncodingException {
- RDBRow row = new RDBRow("_foo", true, false, 1l, 2l, 3l,
+ RDBRow row = new RDBRow("_foo", 1L, false, 1l, 2l, 3l,
"\"blob\", [[\"=\", \"foo\", \"bar\"],[\"M\", \"m1\", 1],[\"M\", \"m2\", 3]]",
"{\"m1\":2, \"m2\":2}".getBytes("UTF-8"));
NodeDocument doc = this.ser.fromRow(Collection.NODES, row);
@@ -110,7 +122,7 @@ public class RDBDocumentSerializerTest {
@Test
public void testBlobAndDiffBorked() throws UnsupportedEncodingException {
try {
- RDBRow row = new RDBRow("_foo", true, false, 1l, 2l, 3l, "[[\"\", \"\", \"\"]]", "{}".getBytes("UTF-8"));
+ RDBRow row = new RDBRow("_foo", 1L, false, 1l, 2l, 3l, "[[\"\", \"\", \"\"]]", "{}".getBytes("UTF-8"));
this.ser.fromRow(Collection.NODES, row);
fail("should fail");
} catch (DocumentStoreException expected) {
@@ -119,7 +131,7 @@ public class RDBDocumentSerializerTest {
@Test
public void testNullModified() throws UnsupportedEncodingException {
- RDBRow row = new RDBRow("_foo", true, true, null, 2l, 3l, "{}", null);
+ RDBRow row = new RDBRow("_foo", 1L, true, null, 2l, 3l, "{}", null);
NodeDocument doc = this.ser.fromRow(Collection.NODES, row);
assertNull(doc.getModified());
}
@@ -127,7 +139,7 @@ public class RDBDocumentSerializerTest {
@Test
public void testBrokenJSONTrailingComma() throws UnsupportedEncodingException {
try {
- RDBRow row = new RDBRow("_foo", true, false, 1l, 2l, 3l, "{ \"x\" : 1, }", null);
+ RDBRow row = new RDBRow("_foo", 1L, false, 1l, 2l, 3l, "{ \"x\" : 1, }", null);
this.ser.fromRow(Collection.NODES, row);
fail("should fail");
} catch (DocumentStoreException expected) {
@@ -137,7 +149,7 @@ public class RDBDocumentSerializerTest {
@Test
public void testBrokenJSONUnquotedIdentifier() throws UnsupportedEncodingException {
try {
- RDBRow row = new RDBRow("_foo", true, false, 1l, 2l, 3l, "{ x : 1, }", null);
+ RDBRow row = new RDBRow("_foo", 1L, false, 1l, 2l, 3l, "{ x : 1, }", null);
this.ser.fromRow(Collection.NODES, row);
fail("should fail");
} catch (DocumentStoreException expected) {
@@ -146,7 +158,7 @@ public class RDBDocumentSerializerTest {
@Test
public void testSimpleStringNonAscii() {
- RDBRow row = new RDBRow("_foo", true, false, 1l, 2l, 3l, "{\"x\":\"\u20ac\uD834\uDD1E\"}", null);
+ RDBRow row = new RDBRow("_foo", 1L, false, 1l, 2l, 3l, "{\"x\":\"\u20ac\uD834\uDD1E\"}", null);
NodeDocument doc = this.ser.fromRow(Collection.NODES, row);
assertEquals("_foo", doc.getId());
assertEquals("\u20ac\uD834\uDD1E", doc.get("x"));