1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.any23.rdf;
19
20 import org.junit.Assert;
21 import org.junit.Test;
22 import org.eclipse.rdf4j.rio.RDFFormat;
23
24 import javax.xml.datatype.DatatypeConfigurationException;
25 import java.io.ByteArrayOutputStream;
26 import java.io.OutputStreamWriter;
27 import java.io.UnsupportedEncodingException;
28 import java.net.URISyntaxException;
29 import java.nio.charset.StandardCharsets;
30 import java.text.ParseException;
31
32
33
34
35
36
37
38 public class RDFUtilsTest {
39
40 @Test
41 public void testFixAbsoluteIRI() throws UnsupportedEncodingException, URISyntaxException {
42 Assert.assertEquals("Error: passed IRIs are not the same.", "http://example.com/resource/the%20godfather",
43 RDFUtils.fixAbsoluteIRI("http://example.com/resource/the godfather"));
44
45 Assert.assertEquals("Error: passed IRIs are not the same.", "http://dbpedia.org/",
46 RDFUtils.fixAbsoluteIRI("http://dbpedia.org"));
47 }
48
49 @Test
50 public void testGetXSDDate() throws DatatypeConfigurationException, ParseException {
51 Assert.assertEquals("1997-09-01T13:00:00.000Z", RDFUtils.getXSDDate("19970901T1300Z", "yyyyMMdd'T'HHmm'Z'"));
52 }
53
54
55
56
57 @Test
58 public void testGetRDFFormatByExtension() {
59 Assert.assertEquals(RDFFormat.NTRIPLES, RDFUtils.getFormatByExtension("nt").get());
60 Assert.assertEquals(RDFFormat.TURTLE, RDFUtils.getFormatByExtension("ttl").get());
61 Assert.assertEquals(RDFFormat.NQUADS, RDFUtils.getFormatByExtension("nq").get());
62 Assert.assertEquals(RDFFormat.NQUADS, RDFUtils.getFormatByExtension(".nq").get());
63 }
64
65
66
67
68 @Test
69 public void testGetNQuadsFormat() {
70 RDFUtils.getFormats().contains(RDFFormat.NQUADS);
71 }
72
73
74
75
76 @Test
77 public void testGetNQuadsParser() {
78 Assert.assertNotNull(RDFUtils.getParser(RDFFormat.NQUADS));
79 }
80
81
82
83
84 @Test
85 public void testGetNQuadsWriter() {
86 Assert.assertNotNull(RDFUtils.getWriter(RDFFormat.NQUADS,
87 new OutputStreamWriter(new ByteArrayOutputStream(), StandardCharsets.UTF_8)));
88 }
89
90 }