001: /*
002: (c) Copyright 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
003: All rights reserved - see end of file.
004: $Id: TestLiteralLabels.java,v 1.7 2008/01/02 12:05:32 andy_seaborne Exp $
005: */
006:
007: package com.hp.hpl.jena.graph.test;
008:
009: import com.hp.hpl.jena.graph.impl.LiteralLabel;
010:
011: import junit.framework.*;
012:
013: /**
014: Tests submitted By: Wolfgang Groiss (littlelui) via SF bugtracker, incorporated
015: into new test class by kers.
016:
017: @author kers
018: */
019: public class TestLiteralLabels extends GraphTestBase {
020: public TestLiteralLabels(String name) {
021: super (name);
022: }
023:
024: public static Test suite() {
025: return new TestSuite(TestLiteralLabels.class);
026: }
027:
028: public void testHashCode() {
029: LiteralLabel ll = new LiteralLabel("test", "", null);
030: ll.hashCode();
031: }
032:
033: public void testHashCode2() {
034: LiteralLabel ll = new LiteralLabel((Object) "test", "", null);
035: ll.hashCode();
036: }
037:
038: public void testHashCodesForBase64Binary() {
039: LiteralLabel A = node(
040: "'0123'http://www.w3.org/2001/XMLSchema#base64Binary")
041: .getLiteral();
042: LiteralLabel B = node(
043: "'0123'http://www.w3.org/2001/XMLSchema#base64Binary")
044: .getLiteral();
045: assertEquals(A.hashCode(), B.hashCode());
046: }
047:
048: public void testHashCodesForHexBinary() {
049: LiteralLabel A = node(
050: "'0123'http://www.w3.org/2001/XMLSchema#hexBinary")
051: .getLiteral();
052: LiteralLabel B = node(
053: "'0123'http://www.w3.org/2001/XMLSchema#hexBinary")
054: .getLiteral();
055: assertEquals(A.hashCode(), B.hashCode());
056: }
057:
058: // AFS
059: public void testEquality1() {
060: LiteralLabel A = new LiteralLabel("xyz");
061: LiteralLabel B = new LiteralLabel("xyz");
062: assertTrue(A.equals(B));
063: assertTrue(A.sameValueAs(B));
064: assertEquals(A.hashCode(), B.hashCode());
065: }
066:
067: public void testEquality2() {
068: LiteralLabel A = new LiteralLabel("xyz");
069: LiteralLabel B = new LiteralLabel("XYZ");
070: assertFalse(A.equals(B));
071: assertFalse(A.sameValueAs(B));
072: }
073:
074: public void testEquality3() {
075: LiteralLabel A = new LiteralLabel("xyz", "en-us");
076: LiteralLabel B = new LiteralLabel("xyz", "en-uk");
077: assertFalse(A.equals(B));
078: assertFalse(A.sameValueAs(B));
079: }
080:
081: public void testEquality4() {
082: LiteralLabel A = new LiteralLabel("xyz", "en-UK");
083: LiteralLabel B = new LiteralLabel("xyz", "en-uk");
084: assertFalse(A.equals(B));
085: assertTrue(A.sameValueAs(B));
086: }
087:
088: }
089:
090: /*
091: * (c) Copyright 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
092: * All rights reserved.
093: *
094: * Redistribution and use in source and binary forms, with or without
095: * modification, are permitted provided that the following conditions
096: * are met:
097: * 1. Redistributions of source code must retain the above copyright
098: * notice, this list of conditions and the following disclaimer.
099: * 2. Redistributions in binary form must reproduce the above copyright
100: * notice, this list of conditions and the following disclaimer in the
101: * documentation and/or other materials provided with the distribution.
102: * 3. The name of the author may not be used to endorse or promote products
103: * derived from this software without specific prior written permission.
104: *
105: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
106: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
107: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
108: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
109: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
110: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
111: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
112: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
113: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
114: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
115: */
|