/** * PODD is an OWL ontology database used for scientific project management * * Copyright (C) 2009-2013 The University Of Queensland * * This program is free software: you can redistribute it and/or modify it under the terms of the * GNU Affero General Public License as published by the Free Software Foundation, either version 3 * of the License, or (at your option) any later version. * * This program 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 * Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License along with this program. * If not, see <http://www.gnu.org/licenses/>. */ package com.github.podd.impl.test; import java.io.File; import java.util.Collection; import org.junit.Assert; import org.openrdf.model.Model; import org.openrdf.model.Resource; import org.openrdf.model.util.GraphUtil; import org.openrdf.repository.Repository; import org.openrdf.repository.config.RepositoryConfigSchema; import org.openrdf.repository.config.RepositoryImplConfig; import org.openrdf.repository.config.RepositoryImplConfigBase; import org.openrdf.repository.manager.LocalRepositoryManager; import org.openrdf.repository.sail.SailRepository; import org.openrdf.rio.RDFFormat; import org.openrdf.rio.Rio; import org.openrdf.sail.memory.MemoryStore; import org.semanticweb.owlapi.model.OWLOntologyManagerFactory; import org.semanticweb.owlapi.model.OWLOntologyManagerFactoryRegistry; import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; import org.semanticweb.owlapi.reasoner.OWLReasonerFactoryRegistry; import com.github.ansell.propertyutil.PropertyUtil; import com.github.podd.api.PoddOWLManager; import com.github.podd.api.PoddRepositoryManager; import com.github.podd.api.PoddSchemaManager; import com.github.podd.api.PoddSesameManager; import com.github.podd.api.test.AbstractPoddSchemaManagerTest; import com.github.podd.impl.PoddOWLManagerImpl; import com.github.podd.impl.PoddRepositoryManagerImpl; import com.github.podd.impl.PoddSchemaManagerImpl; import com.github.podd.impl.PoddSesameManagerImpl; import com.github.podd.utils.PoddWebConstants; /** * @author Peter Ansell p_ansell@yahoo.com * */ public class PoddSchemaManagerImplTest extends AbstractPoddSchemaManagerTest { @Override protected OWLOntologyManagerFactory getNewOWLOntologyManagerFactory() { final Collection<OWLOntologyManagerFactory> ontologyManagers = OWLOntologyManagerFactoryRegistry.getInstance().get(PoddWebConstants.DEFAULT_OWLAPI_MANAGER); if(ontologyManagers == null || ontologyManagers.isEmpty()) { this.log.error("OWLOntologyManagerFactory was not found"); } return ontologyManagers.iterator().next(); } @Override protected PoddOWLManager getNewPoddOwlManagerInstance(final OWLOntologyManagerFactory manager, final OWLReasonerFactory reasonerFactory) { return new PoddOWLManagerImpl(manager, reasonerFactory); } @Override protected PoddRepositoryManager getNewPoddRepositoryManagerInstance() throws Exception { final File repositoryManagerDirectory = this.tempDir.newFolder("repositorymanager"); final File managementRepositoryDirectory = this.tempDir.newFolder("managementrepository"); final Repository managementRepository = new SailRepository(new MemoryStore(managementRepositoryDirectory)); managementRepository.initialize(); final Model graph = Rio.parse(this.getClass().getResourceAsStream("/memorystoreconfig.ttl"), "", RDFFormat.TURTLE); final Resource repositoryNode = GraphUtil.getUniqueSubject(graph, RepositoryConfigSchema.REPOSITORYTYPE, null); final RepositoryImplConfig repositoryImplConfig = RepositoryImplConfigBase.create(graph, repositoryNode); Assert.assertNotNull(repositoryImplConfig); Assert.assertNotNull(repositoryImplConfig.getType()); final LocalRepositoryManager repositoryManager = new LocalRepositoryManager(repositoryManagerDirectory); repositoryManager.initialize(); return new PoddRepositoryManagerImpl(managementRepository, repositoryImplConfig, "", repositoryManagerDirectory.toPath(), new PropertyUtil("podd")); } @Override protected PoddSchemaManager getNewPoddSchemaManagerInstance() { return new PoddSchemaManagerImpl(); } @Override protected PoddSesameManager getNewPoddSesameManagerInstance() { return new PoddSesameManagerImpl(); } @Override protected OWLReasonerFactory getNewReasonerFactory() { return OWLReasonerFactoryRegistry.getInstance().getReasonerFactory("Pellet"); } }