View Javadoc
1   /**
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  package org.apache.commons.rdf.jena;
19  
20  import static org.junit.Assert.assertEquals;
21  
22  import org.apache.commons.rdf.api.AbstractDatasetTest;
23  import org.apache.commons.rdf.api.IRI;
24  import org.apache.commons.rdf.api.Literal;
25  import org.apache.commons.rdf.api.RDF;
26  import org.apache.commons.rdf.simple.Types;
27  import org.junit.Test;
28  
29  public class DatasetJenaTest extends AbstractDatasetTest {
30  
31      @Override
32      public RDF createFactory() {
33          return new JenaRDF();
34      }
35  
36      @Test
37      public void datasetImplToStringTest() {
38          RDF rdf = createFactory();
39          JenaDataset jena = (JenaDataset) rdf.createDataset();
40          final IRI graph = rdf.createIRI("http://example.com/");
41          final IRI s = rdf.createIRI("http://example.com/s");
42          final IRI p = rdf.createIRI("http://example.com/p");
43          final Literal literal123 = rdf.createLiteral("123", Types.XSD_INTEGER);
44          jena.add(graph, s, p, literal123);
45          String out = jena.toString();
46          assertEquals("<http://example.com/s> <http://example.com/p> \"123\"^^<http://www"
47                  + ".w3.org/2001/XMLSchema#integer> <http://example.com/> .\n", out);
48          assertEquals(10L, dataset.size());
49      }
50  }