protected void testNode(Node n) { NodeTable nt = createEmptyNodeTable() ; NodeId nodeId = nt.getAllocateNodeId(n) ; assertNotNull(nodeId) ; assertNotEquals(NodeId.NodeDoesNotExist, nodeId) ; assertNotEquals(NodeId.NodeIdAny, nodeId) ; Node n2 = nt.getNodeForNodeId(nodeId) ; assertEquals(n, n2) ; NodeId nodeId2 = nt.getNodeIdForNode(n) ; assertEquals(nodeId, nodeId2) ; }
static void forceSync(DatasetGraphTDB dsg) { // Force sync - we have been bypassing DSG tables. // THIS DOES NOT WORK IF modules check for SYNC necessity. dsg.getTripleTable().getNodeTupleTable().getNodeTable().sync(); dsg.getQuadTable().getNodeTupleTable().getNodeTable().sync(); dsg.getQuadTable().getNodeTupleTable().getNodeTable().sync(); dsg.getPrefixes().getNodeTupleTable().getNodeTable().sync(); // This is not enough -- modules check whether sync needed. dsg.sync() ; } }
private void test(Node n) { int maxSize = nodec.maxSize(n) ; ByteBuffer bb = ByteBuffer.allocate(maxSize) ; int x = nodec.encode(n, bb, null) ; int bbLen = bb.limit()-bb.position(); assertEquals(bbLen, x) ; assertEquals(0, bb.position()) ; ByteBuffer bb2 = ByteBufferLib.duplicate(bb) ; Node n2 = nodec.decode(bb2, null) ; assertEquals(n, n2) ; } }
private void test(String sseString) { Node n = NodeFactory.parseNode(sseString) ; test(n) ; }
protected void testNode(String str) { testNode(NodeFactory.parseNode(str)) ; }
@Test public void nodec_lit_01() { test ("''") ; } @Test public void nodec_lit_02() { test ("'a'") ; }
@Test public void nodetable_05() { testNode("'x'@en") ; } @Test public void nodetable_06() { testNode("'x'^^<http://example/dt>") ; }
@Test public void nodec_lit_10() { test ("'"+latinBase+"'") ; } @Test public void nodec_lit_11() { test ("'"+latinExtraBase+"'") ; }
@Test public void nodetable_06() { testNode("'x'^^<http://example/dt>") ; } }
@Test public void nodec_lit_09() { test ("'\\n'@EN-uk") ; }
@Test public void nodetable_04() { testNode("'x'") ; } @Test public void nodetable_05() { testNode("'x'@en") ; }
@Test public void nodec_lit_02() { test ("'a'") ; } @Test public void nodec_lit_03() { test ("'ab'") ; }
@Test public void nodetable_03() { testNode("_:x") ; } @Test public void nodetable_04() { testNode("'x'") ; }
@Test public void nodec_lit_04() { test ("'abc'") ; } @Test public void nodec_lit_05() { test ("'abcd'") ; }
@Test public void nodec_lit_13() { test ("'"+hewbrewBase+"'") ; } @Test public void nodec_lit_14() { test ("'"+arabicBase+"'") ; }
@Test public void nodec_lit_16() { test ("'"+chineseBase+"'") ; } @Test public void nodec_lit_17() { test ("'"+japaneseBase+"'") ; }
@Test public void nodec_lit_03() { test ("'ab'") ; } @Test public void nodec_lit_04() { test ("'abc'") ; }
@Test public void nodec_lit_06() { test ("''@e") ; } @Test public void nodec_lit_07() { test ("''@en") ; }
@Test public void nodec_lit_20() { test ("1") ; } @Test public void nodec_lit_21() { test ("12.3") ; }
@Test public void nodec_uri_01() { test ("<>") ; } @Test public void nodec_uri_02() { test ("<http://example/>") ; }