⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 exotictest.java

📁 这是外国一个开源推理机
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*  Sesame - Storage and Querying architecture for RDF and RDF Schema *  Copyright (C) 2001-2005 Aduna * *  Contact:  *  	Aduna *  	Prinses Julianaplein 14 b *  	3817 CS Amersfoort *  	The Netherlands *  	tel. +33 (0)33 465 99 87 *  	fax. +33 (0)33 465 99 87 * *  	http://aduna.biz/ *  	http://www.openrdf.org/ *   *  This library is free software; you can redistribute it and/or *  modify it under the terms of the GNU Lesser General Public *  License as published by the Free Software Foundation; either *  version 2.1 of the License, or (at your option) any later version. * *  This library is distributed in the hope that it will be useful, *  but WITHOUT ANY WARRANTY; without even the implied warranty of *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU *  Lesser General Public License for more details. * *  You should have received a copy of the GNU Lesser General Public *  License along with this library; if not, write to the Free Software *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */package org.openrdf.sesame.sail;import java.io.IOException;import java.io.InputStream;import junit.framework.TestCase;import junit.framework.TestSuite;import org.openrdf.model.Resource;import org.openrdf.model.URI;import org.openrdf.model.impl.URIImpl;import org.openrdf.sesame.admin.RdfAdmin;import org.openrdf.sesame.admin.StdOutAdminListener;import org.openrdf.sesame.admin.UpdateException;import org.openrdf.sesame.constants.RDFFormat;/** * A JUnit test suite for testing the methods of RdfSchemaRepository * using 'exotic' test data. * * @author Arjohn Kampman */public class ExoticTest extends TestSuite {/*-------------------------------+| Constants                      |+-------------------------------*/	private static String EXOTIC_FILE = "/files/exotic/exotic.rdf";	private static String EXOTIC_URL = "http://example.org/";	private static URI CLASSA = new URIImpl(EXOTIC_URL, "ClassA");	private static URI CLASSB = new URIImpl(EXOTIC_URL, "ClassB");	private static URI CLASSC = new URIImpl(EXOTIC_URL, "ClassC");	private static URI CLASSD = new URIImpl(EXOTIC_URL, "ClassD");	private static URI PROPA = new URIImpl(EXOTIC_URL, "propA");	private static URI PROPB = new URIImpl(EXOTIC_URL, "propB");	private static URI PROPC = new URIImpl(EXOTIC_URL, "propC");	private static URI PROPD = new URIImpl(EXOTIC_URL, "propD");	private static URI PROPCLASS = new URIImpl(EXOTIC_URL, "PropClass");	private static URI OBJECTA = new URIImpl(EXOTIC_URL, "objectA");	private static URI OBJECTB = new URIImpl(EXOTIC_URL, "objectB");	private static URI OBJECTC = new URIImpl(EXOTIC_URL, "objectC");	private static URI OBJECTD = new URIImpl(EXOTIC_URL, "objectD");	private static URI OBJECTE = new URIImpl(EXOTIC_URL, "objectE");/*-------------------------------+| Variables                      |+-------------------------------*/	protected RdfSchemaRepository _repository;/*-------------------------------+| Constructors                   |+-------------------------------*/	public ExoticTest(String name, RdfSchemaRepository repository)		throws IOException, UpdateException	{		super(name);		_repository = repository;		_upload(repository, EXOTIC_FILE, EXOTIC_URL);		_addTests();	}/*-------------------------------+| Methods                        |+-------------------------------*/	protected void _upload(RdfRepository repository, String fileName, String baseURL)		throws IOException, UpdateException	{		RdfAdmin admin = new RdfAdmin(repository);		InputStream rdfStream = this.getClass().getResourceAsStream(fileName);		admin.addRdfModel(rdfStream, baseURL, new StdOutAdminListener(), RDFFormat.RDFXML, false);		rdfStream.close();	}	protected void _addTests() {		addTest(new IsClassTest(CLASSA, true));		addTest(new IsClassTest(CLASSB, true));		addTest(new IsClassTest(CLASSC, true));		addTest(new IsClassTest(CLASSD, true));		addTest(new IsClassTest(PROPCLASS, true));		addTest(new IsClassTest(PROPB, false));		addTest(new IsClassTest(OBJECTB, false));		addTest(new IsPropertyTest(PROPA, true));		addTest(new IsPropertyTest(PROPB, true));		addTest(new IsPropertyTest(PROPC, true));		addTest(new IsPropertyTest(PROPD, true));		addTest(new IsPropertyTest(PROPCLASS, true));		addTest(new IsPropertyTest(CLASSB, false));		addTest(new IsPropertyTest(OBJECTB, false));		addTest(new IsSubClassOfTest(CLASSA, CLASSA, true));		addTest(new IsSubClassOfTest(CLASSB, CLASSA, true));		addTest(new IsSubClassOfTest(CLASSC, CLASSA, true));		addTest(new IsSubClassOfTest(CLASSD, CLASSA, true));		addTest(new IsSubClassOfTest(CLASSB, CLASSC, true));		addTest(new IsSubClassOfTest(CLASSC, CLASSB, true));		addTest(new IsSubClassOfTest(PROPCLASS, CLASSA, true));		addTest(new IsSubClassOfTest(CLASSA, CLASSB, false));		addTest(new IsSubClassOfTest(CLASSC, CLASSD, false));		addTest(new IsSubClassOfTest(OBJECTB, CLASSB, false));		addTest(new IsSubClassOfTest(PROPCLASS, PROPA, false));		addTest(new IsDirectSubClassOfTest(CLASSB, CLASSA, true));		addTest(new IsDirectSubClassOfTest(CLASSC, CLASSA, true));		addTest(new IsDirectSubClassOfTest(CLASSD, CLASSB, true));		addTest(new IsDirectSubClassOfTest(CLASSD, CLASSC, true));		addTest(new IsDirectSubClassOfTest(PROPCLASS, CLASSA, true));		addTest(new IsDirectSubClassOfTest(CLASSA, CLASSA, false));		addTest(new IsDirectSubClassOfTest(CLASSD, CLASSA, false));		addTest(new IsDirectSubClassOfTest(CLASSB, CLASSC, false));		addTest(new IsDirectSubClassOfTest(CLASSC, CLASSB, false));		addTest(new IsDirectSubClassOfTest(CLASSA, CLASSB, false));		addTest(new IsDirectSubClassOfTest(OBJECTB, CLASSB, false));		addTest(new IsDirectSubClassOfTest(PROPCLASS, PROPA, false));		addTest(new IsSubPropertyOfTest(PROPA, PROPA, true));		addTest(new IsSubPropertyOfTest(PROPB, PROPA, true));		addTest(new IsSubPropertyOfTest(PROPC, PROPA, true));		addTest(new IsSubPropertyOfTest(PROPD, PROPA, true));		addTest(new IsSubPropertyOfTest(PROPB, PROPC, true));		addTest(new IsSubPropertyOfTest(PROPC, PROPB, true));		addTest(new IsSubPropertyOfTest(PROPCLASS, PROPA, true));		addTest(new IsSubPropertyOfTest(PROPA, PROPB, false));		addTest(new IsSubPropertyOfTest(PROPC, PROPD, false));		addTest(new IsSubPropertyOfTest(OBJECTB, PROPB, false));		addTest(new IsSubPropertyOfTest(PROPCLASS, CLASSA, false));		addTest(new IsDirectSubPropertyOfTest(PROPB, PROPA, true));		addTest(new IsDirectSubPropertyOfTest(PROPC, PROPA, true));		addTest(new IsDirectSubPropertyOfTest(PROPD, PROPB, true));		addTest(new IsDirectSubPropertyOfTest(PROPD, PROPC, true));		addTest(new IsDirectSubPropertyOfTest(PROPCLASS, PROPA, true));		addTest(new IsDirectSubPropertyOfTest(CLASSA, CLASSA, false));		addTest(new IsDirectSubPropertyOfTest(CLASSD, CLASSA, false));		addTest(new IsDirectSubPropertyOfTest(PROPB, PROPC, false));		addTest(new IsDirectSubPropertyOfTest(PROPC, PROPB, false));		addTest(new IsDirectSubPropertyOfTest(CLASSA, CLASSB, false));		addTest(new IsDirectSubPropertyOfTest(OBJECTB, CLASSB, false));		addTest(new IsDirectSubPropertyOfTest(PROPCLASS, CLASSA, false));		addTest(new IsTypeTest(OBJECTA, CLASSA, true));		addTest(new IsTypeTest(OBJECTB, CLASSB, true));		addTest(new IsTypeTest(OBJECTC, CLASSC, true));		addTest(new IsTypeTest(OBJECTD, CLASSD, true));		addTest(new IsTypeTest(OBJECTE, PROPCLASS, true));		addTest(new IsTypeTest(CLASSA, CLASSA, true));		addTest(new IsTypeTest(OBJECTB, CLASSA, true));		addTest(new IsTypeTest(OBJECTB, CLASSC, true));		addTest(new IsTypeTest(OBJECTC, CLASSB, true));		addTest(new IsTypeTest(OBJECTD, CLASSA, true));		addTest(new IsTypeTest(OBJECTD, CLASSB, true));		addTest(new IsTypeTest(OBJECTD, CLASSC, true));		addTest(new IsTypeTest(OBJECTE, OBJECTA, false));		addTest(new IsTypeTest(CLASSA, OBJECTA, false));		addTest(new IsTypeTest(CLASSB, CLASSB, false));		addTest(new IsTypeTest(PROPCLASS, CLASSA, false));		addTest(new IsDirectTypeTest(OBJECTA, CLASSA, true));		addTest(new IsDirectTypeTest(OBJECTB, CLASSB, true));		addTest(new IsDirectTypeTest(OBJECTC, CLASSC, true));		addTest(new IsDirectTypeTest(OBJECTD, CLASSD, true));		addTest(new IsDirectTypeTest(OBJECTE, PROPCLASS, true));		addTest(new IsDirectTypeTest(CLASSA, CLASSA, true));		addTest(new IsDirectTypeTest(OBJECTB, CLASSC, true));		addTest(new IsDirectTypeTest(OBJECTC, CLASSB, true));		addTest(new IsDirectTypeTest(OBJECTB, CLASSA, false));		addTest(new IsDirectTypeTest(OBJECTD, CLASSA, false));		addTest(new IsDirectTypeTest(OBJECTD, CLASSB, false));		addTest(new IsDirectTypeTest(OBJECTD, CLASSC, false));		addTest(new IsDirectTypeTest(OBJECTE, OBJECTA, false));		addTest(new IsDirectTypeTest(CLASSA, OBJECTA, false));		addTest(new IsDirectTypeTest(CLASSB, CLASSB, false));		addTest(new IsDirectTypeTest(PROPCLASS, CLASSA, false));	}/*	public void testGetSubClassOf() {		StatementIterator statIter = _repository.getSubClassOf(null, ARTIST);		assertNotNull(statIter);		assertTrue("there should be subclasses of Artist", statIter.hasNext());		Set subClasses = new HashSet();		while (statIter.hasNext()) {			// no double elements allowed			Resource subClass = statIter.next().getSubject();			assertTrue(					"the list of subclasses of Artist should not contain duplicates",					subClasses.add(subClass));		}		statIter.close();		assertTrue(				"Artist should be returned as a subclass of Artist",				subClasses.contains(ARTIST));		assertTrue(				"Painter should be returned as a subclass of Artist",				subClasses.contains(PAINTER));		assertTrue(				"Cubist should be returned as a subclass of Artist",				subClasses.contains(CUBIST));	}*//*	public void testAddStatement() {		URI newCubist = new URIImpl("http://www.foo.com/someCubist");		try {			_repository.startTransaction();			_repository.addStatement(newCubist, URIImpl.RDF_TYPE, CUBIST);			_repository.commitTransaction();		}		catch (SailUpdateException e) {			fail("Unable to add statement: " + e.getMessage());		}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -