From: Bryan T. <tho...@us...> - 2007-08-27 19:39:36
|
Update of /cvsroot/cweb/rdf-generic/src/test/org/CognitiveWeb/sesame/sailimpl/generic In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv7880/src/test/org/CognitiveWeb/sesame/sailimpl/generic Added Files: TestUnicodeClean.java Log Message: Added a test for Unicode clean literals. (The CTC store is not Unicode clean in its indices - the "YAC"s but it does store and return Unicode strings without trouble.) --- NEW FILE: TestUnicodeClean.java --- /** The Notice below must appear in each file of the Source Code of any copy you distribute of the Licensed Product. Contributors to any Modifications may add their own copyright notices to identify their own contributions. License: The contents of this file are subject to the CognitiveWeb Open Source License Version 1.1 (the License). You may not copy or use this file, in either source code or executable form, except in compliance with the License. You may obtain a copy of the License from http://www.CognitiveWeb.org/legal/license/ Software distributed under the License is distributed on an AS IS basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. Copyrights: Portions created by or assigned to CognitiveWeb are Copyright (c) 2003-2003 CognitiveWeb. All Rights Reserved. Contact information for CognitiveWeb is available at http://www.CognitiveWeb.org Portions Copyright (c) 2002-2003 Bryan Thompson. Acknowledgements: Special thanks to the developers of the Jabber Open Source License 1.0 (JOSL), from which this License was derived. This License contains terms that differ from JOSL. Special thanks to the CognitiveWeb Open Source Contributors for their suggestions and support of the Cognitive Web. Modifications: */ /* * Created on Aug 27, 2007 */ package org.CognitiveWeb.sesame.sailimpl.generic; import java.util.Properties; import java.util.UUID; import org.CognitiveWeb.sesame.sailimpl.generic.ctc.CTCGRdfRepository; import org.openrdf.model.Literal; import org.openrdf.model.Statement; import org.openrdf.model.impl.LiteralImpl; import org.openrdf.model.impl.URIImpl; import org.openrdf.sesame.sail.RdfRepository; import org.openrdf.sesame.sail.SailUpdateException; import org.openrdf.sesame.sail.StatementIterator; /** * @author <a href="mailto:tho...@us...">Bryan Thompson</a> * @version $Id$ */ public class TestUnicodeClean extends AbstractRepositoryTestCase { /** * */ public TestUnicodeClean() { super(); } /** * @param name */ public TestUnicodeClean(String name) { super(name); } /** * The URI used in the tests. It is random so that it will not collide with * existing URIs if you are running the integration test. */ final URIImpl uri1 = new URIImpl("http://www.systap.com/test/uri1/"+UUID.randomUUID()); /** * A label that is used to test for Unicode clean. The UTF-16 code points * are: * * <pre> * 0047 0127 0061 0077 0064 0065 0078 * </pre> */ final String unicode1 = "G\u0127awdex"; public Properties getProperties() { Properties properties = super.getProperties(); properties.setProperty ( "repositoryClass", CTCGRdfRepository.class.getName() // CTCGRdfSchemaRepository.class.getName() ); return properties; } public void test_unicodeClean() throws SailUpdateException { RdfRepository r = super.m_repo; r.startTransaction(); r.addStatement(uri1, URIImpl.RDFS_LABEL, new LiteralImpl("Gozo")); r.addStatement(uri1, URIImpl.RDFS_LABEL, new LiteralImpl(unicode1)); r.commitTransaction(); // verify with ASCII label. assertTrue(r.hasStatement(uri1, URIImpl.RDFS_LABEL, new LiteralImpl("Gozo"))); // verify with lower case version of label (not found). assertFalse(r.hasStatement(uri1, URIImpl.RDFS_LABEL, new LiteralImpl("gozo"))); // verify with Unicode label. assertTrue(r.hasStatement(uri1, URIImpl.RDFS_LABEL, new LiteralImpl(unicode1))); /* * Verify literals can be returned from the graph. */ StatementIterator itr = r.getStatements(null, null, null); try { int stmt1 = 0, stmt2 = 0, stmt3 = 0; while (itr.hasNext()) { Statement stmt = itr.next(); Literal lit = (Literal) stmt.getObject(); if(lit.getLabel().equals("Gozo")) stmt1++; if(lit.getLabel().equals("gozo")) stmt2++; if(lit.getLabel().equals(unicode1)) stmt3++; } // verify ASCII literal is returned. assertEquals("stmt1",1,stmt1); if(stmt2==0) { /* * The index does not differentiate between "Gozo" and "gozo" * (it is not case sensitive). */ log.warn("Index does not differentiate case of strings."); } // verify can return Unicode literal. assertEquals("stmt3",1,stmt3); } finally { itr.close(); } } } |