01: /*
02: * Copyright Aduna (http://www.aduna-software.com/) (c) 1997-2006.
03: *
04: * Licensed under the Aduna BSD-style license.
05: */
06: package org.openrdf.sail.memory.model;
07:
08: import org.openrdf.model.impl.URIImpl;
09: import org.openrdf.model.vocabulary.RDF;
10:
11: import junit.framework.TestCase;
12:
13: /**
14: * Unit tests for class {@link MemURI}.
15: *
16: * @author Arjohn Kampman
17: */
18: public class MemURITest extends TestCase {
19:
20: /**
21: * Verifies that MemURI's hash code is the same as the hash code of an
22: * equivalent URIImpl.
23: */
24: public void testEqualsAndHash() throws Exception {
25: compareURIs(RDF.NAMESPACE);
26: compareURIs(RDF.TYPE.toString());
27: compareURIs("foo:bar");
28: compareURIs("http://www.example.org/");
29: compareURIs("http://www.example.org/foo#bar");
30: }
31:
32: private void compareURIs(String uri) throws Exception {
33: URIImpl uriImpl = new URIImpl(uri);
34: MemURI memURI = new MemURI(this , uriImpl.getNamespace(),
35: uriImpl.getLocalName());
36:
37: assertEquals("MemURI not equal to URIImpl for: " + uri,
38: uriImpl, memURI);
39: assertEquals(
40: "MemURI has different hash code than URIImpl for: "
41: + uri, uriImpl.hashCode(), memURI.hashCode());
42: }
43: }
|