1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 package org.apache.any23;
19
20 import org.junit.Test;
21 import org.eclipse.rdf4j.model.BNode;
22 import org.eclipse.rdf4j.model.impl.SimpleValueFactory;
23
24 import static org.junit.Assert.assertEquals;
25 import static org.junit.Assert.assertNull;
26 import static org.junit.Assert.fail;
27
28 /**
29 * Tests how Sesame's ValueFactory behaves with null arguments.
30 *
31 * @author Richard Cyganiak (richard@cyganiak.de)
32 */
33 public class SesameTest {
34
35 @Test
36 public void testCreateIRIWithNullArgumentThrowsNPE() {
37 try {
38 SimpleValueFactory.getInstance().createIRI(null);
39 fail("should have thrown NPE or assertion error.");
40 } catch (AssertionError ae) {
41 // espected when assertions are enabled.
42 } catch (NullPointerException ex) {
43 // expected without assertions.
44 } catch (IllegalArgumentException ex) {
45 // expected without assertions.
46 }
47 }
48
49 @Test
50 public void testCreateBNodeWithNullArgumentWorks() {
51 BNode b = SimpleValueFactory.getInstance().createBNode(null);
52 assertNull(b.stringValue());
53 assertEquals(b, b);
54 }
55
56 }