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.api;
19  
20  import org.junit.Test;
21  
22  /**
23   * Test that all {@link RDFTermFactory} default methods throw
24   * {@link UnsupportedOperationException}.
25   */
26  @SuppressWarnings("deprecation")
27  public class DefaultRDFTermFactoryTest {
28      // All methods in RDFTermFactory has a default implementation
29      RDFTermFactory factory = new RDFTermFactory() {};
30  
31      @Test(expected=UnsupportedOperationException.class)
32      public void createBlankNode() throws Exception {
33          factory.createBlankNode();
34      }
35      @Test(expected=UnsupportedOperationException.class)
36      public void createBlankNodeName() throws Exception {
37          factory.createBlankNode("fred");
38      }
39      @Test(expected=UnsupportedOperationException.class)
40      public void createGraph() throws Exception {
41          factory.createGraph();
42      }
43      @Test(expected=UnsupportedOperationException.class)
44      public void createIRI() throws Exception {
45          factory.createIRI("http://example.com/");
46      }
47      @Test(expected=UnsupportedOperationException.class)
48      public void createLiteral() throws Exception {
49          factory.createLiteral("Alice");
50      }
51      @Test(expected=UnsupportedOperationException.class)
52      public void createLiteralLang() throws Exception {
53          factory.createLiteral("Alice", "en");
54      }
55      @Test(expected=UnsupportedOperationException.class)
56      public void createLiteralTyped() throws Exception {
57          factory.createLiteral("Alice", new DummyIRI(0));
58      }
59      @Test(expected=UnsupportedOperationException.class)
60      public void createTriple() throws Exception {
61          factory.createTriple(new DummyIRI(1), new DummyIRI(2), new DummyIRI(3));
62      }
63  }