1 19 20 package com.hp.hpl.jena.ontology.impl.test; 23 24 25 import java.util.*; 28 29 import com.hp.hpl.jena.ontology.*; 30 import com.hp.hpl.jena.rdf.model.*; 31 import com.hp.hpl.jena.reasoner.test.TestUtil; 32 33 import junit.framework.*; 34 35 36 45 public abstract class OntTestBase 46 extends TestSuite 47 { 48 51 public static final String BASE = "http://jena.hpl.hp.com/testing/ontology"; 52 public static final String NS = BASE + "#"; 53 54 55 58 61 62 65 public OntTestBase( String name ) { 66 super( name ); 67 TestCase[] tc = getTests(); 68 69 for (int i = 0; i < tc.length; i++) { 70 addTest( tc[i] ); 71 } 72 } 73 74 77 78 81 82 protected OntTestCase[] getTests() { 83 return null; 84 } 85 86 87 91 protected abstract class OntTestCase 92 extends TestCase 93 { 94 protected boolean m_inOWL; 95 protected boolean m_inOWLLite; 96 protected boolean m_inDAML; 97 protected boolean m_inRDFS; 98 protected String m_langElement; 99 protected boolean m_owlLang = true; 100 protected boolean m_owlLiteLang = false; 101 protected boolean m_rdfsLang = false; 102 protected boolean m_damlLang = false; 103 104 public OntTestCase( String langElement, boolean inOWL, boolean inOWLLite, boolean inDAML, boolean inRDFS ) { 105 super( "Ontology API test " + langElement ); 106 m_langElement = langElement; 107 m_inOWL = inOWL; 108 m_inOWLLite = inOWLLite; 109 m_inDAML = inDAML; 110 m_inRDFS = inRDFS; 111 } 112 113 public void runTest() 114 throws Exception 115 { 116 runTest( ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM, null ), m_inOWL ); 118 119 m_owlLiteLang = true; 120 121 runTest( ModelFactory.createOntologyModel( OntModelSpec.OWL_LITE_MEM, null ), m_inOWLLite ); 122 123 m_owlLang = false; 125 m_owlLiteLang = false; 126 m_damlLang = true; 127 128 runTest( ModelFactory.createOntologyModel( OntModelSpec.DAML_MEM, null ), m_inDAML ); 129 130 132 m_rdfsLang = true; 133 m_damlLang = false; 134 runTest( ModelFactory.createOntologyModel( OntModelSpec.RDFS_MEM, null ), m_inRDFS); 135 } 136 137 protected void runTest( OntModel m, boolean inModel ) 138 throws Exception 139 { 140 boolean profileEx = false; 141 142 try { 143 ontTest( m ); 144 } 145 catch (ProfileException e) { 146 profileEx = true; 147 } 148 149 assertEquals( "language element " + m_langElement + " was " + (inModel ? "" : "not") + " expected in model " + m.getProfile().getLabel(), inModel, !profileEx ); 150 } 151 152 153 protected abstract void ontTest( OntModel m ) throws Exception ; 154 155 156 protected void iteratorTest( Iterator i, Object [] expected ) { 157 TestUtil.assertIteratorValues( this, i, expected ); 158 } 159 160 public void setUp() { 161 OntDocumentManager.getInstance().reset( true ); 163 } 164 165 protected boolean owlFull() { 166 return m_owlLang && !m_owlLiteLang; 167 } 168 169 } 170 } 171 172 173 202 203 | Popular Tags |