Literal implements Node { @Override public String toString() { return _data; } Literal(String data);  Literal(String data, boolean isNTriples);  Literal(String data, String lang);  Literal(String data, Resource dt);  Literal(String data, String lang, Resource dt); private  Literal(String data, String lang, Resource dt, boolean isNTriples); @Override String getLabel(); String getLanguageTag(); Resource getDatatype(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); @Override int compareTo(Node n);  }
@Test public void testQuotesInString() { String s = "he said \"wow\""; Literal l = new Literal(s); assertEquals("\"he said \\\"wow\\\"\"", l.toString()); }
@Test public void testQuotesInString2() { String s = "he said \"Shakespeare said 'to be or not to be'\""; Literal l = new Literal(s); assertEquals( "\"he said \\\"Shakespeare said 'to be or not to be'\\\"\"", l.toString()); }
@Test public void testCanonicalNtriplesLiteral() { StringBuffer sb = new StringBuffer(); sb.append((char) 0x22); sb.append((char) 0x5c); sb.append((char) 0x0a); sb.append((char) 0x0d); sb.append((char) 0x08); sb.append((char) 0x09); sb.append("ä"); sb.append("'"); sb.append((char) 0x0e07); sb.append((char) 0x1ce1); char[] pair = Character.toChars(0x100002); sb.append(pair[0]); sb.append(pair[1]); Literal l = new Literal(sb.toString()); assertEquals("\"\\\"\\\\\\n\\r\u0008\tä'\u0e07\u1ce1\udbc0\udc02\"", l.toString()); }
@Test public void testEmptyStringInConstructor() { String data = ""; Literal l = new Literal(data); assertEquals(l.toString(), "\"\""); }
@Test public void testProperLiteralSupplied() { String data = "\"Test\"^^<http: Literal l = new Literal(data); assertNotEquals(data, l.toString()); }
@Test public void testMultilineString() { String s = "a\nb\nc"; Literal l = new Literal(s); assertEquals("\"a\\nb\\nc\"", l.toString()); }
@Test public void testTabString() { String s = "a\tb\tc"; Literal l = new Literal(s); assertEquals("\"a\tb\tc\"", l.toString()); }