📄 testcreate.java
字号:
/*****************************************************************************
* Source code information
* -----------------------
* Original author Ian Dickinson, HP Labs Bristol
* Author email Ian.Dickinson@hp.com
* Package Jena 2
* Web http://sourceforge.net/projects/jena/
* Created 03-Apr-2003
* Filename $RCSfile: TestCreate.java,v $
* Revision $Revision: 1.15 $
* Release status $State: Exp $
*
* Last modified on $Date: 2007/01/02 11:51:55 $
* by $Author: andy_seaborne $
*
* (c) Copyright 2002, 2003, 2004, 2005, 2006, 2007 Hewlett-Packard Development Company, LP
* (see footer for full conditions)
*****************************************************************************/
// Package
///////////////
package com.hp.hpl.jena.ontology.impl.test;
// Imports
///////////////
import com.hp.hpl.jena.rdf.model.*;
import com.hp.hpl.jena.ontology.*;
import junit.framework.*;
/**
* <p>
* Unit test cases for creating values in ontology models
* </p>
*
* @author Ian Dickinson, HP Labs
* (<a href="mailto:Ian.Dickinson@hp.com" >email</a>)
* @version CVS $Id: TestCreate.java,v 1.15 2007/01/02 11:51:55 andy_seaborne Exp $
*/
public class TestCreate
extends TestCase
{
// Constants
//////////////////////////////////
public static final String BASE = "http://jena.hpl.hp.com/testing/ontology";
public static final String NS = BASE + "#";
// Static variables
//////////////////////////////////
protected static CreateTestCase[] testCases = new CreateTestCase[] {
new CreateTestCase( "OWL create ontology", ProfileRegistry.OWL_LANG, BASE ) {
public OntResource doCreate( OntModel m ) { return m.createOntology( BASE ); }
public boolean test( OntResource r ) { return r instanceof Ontology;}
},
new CreateTestCase( "DAML create ontology", ProfileRegistry.DAML_LANG, BASE ) {
public OntResource doCreate( OntModel m ) { return m.createOntology( BASE ); }
public boolean test( OntResource r ) { return r instanceof Ontology;}
},
new CreateTestCase( "OWL create class", ProfileRegistry.OWL_LANG, NS + "C" ) {
public OntResource doCreate( OntModel m ) { return m.createClass( NS + "C" ); }
public boolean test( OntResource r ) { return r instanceof OntClass;}
},
new CreateTestCase( "OWL create anon complement class", ProfileRegistry.OWL_LANG, null ) {
public OntResource doCreate( OntModel m ) { return m.createComplementClass( null, m.createClass( NS + "A" ) ); }
public boolean test( OntResource r ) { return r instanceof OntClass && r instanceof ComplementClass; }
},
new CreateTestCase( "OWL create anon enumeration class", ProfileRegistry.OWL_LANG, null ) {
public OntResource doCreate( OntModel m ) {
OntClass A = m.createClass( NS + "A" );
Individual a0 = m.createIndividual( A );
Individual a1 = m.createIndividual( A );
Individual a2 = m.createIndividual( A );
RDFList l = m.createList( new OntResource[] {a0, a1, a2} );
return m.createEnumeratedClass( null, l );
}
public boolean test( OntResource r ) { return r instanceof OntClass && r instanceof EnumeratedClass; }
},
new CreateTestCase( "OWL create anon union class", ProfileRegistry.OWL_LANG, null ) {
public OntResource doCreate( OntModel m ) {
OntClass A = m.createClass( NS + "A" );
Individual a0 = m.createIndividual( A );
Individual a1 = m.createIndividual( A );
Individual a2 = m.createIndividual( A );
RDFList l = m.createList( new OntResource[] {a0, a1, a2} );
return m.createUnionClass( null, l );
}
public boolean test( OntResource r ) { return r instanceof OntClass && r instanceof UnionClass; }
},
new CreateTestCase( "OWL create anon intersection class", ProfileRegistry.OWL_LANG, null ) {
public OntResource doCreate( OntModel m ) {
OntClass A = m.createClass( NS + "A" );
Individual a0 = m.createIndividual( A );
Individual a1 = m.createIndividual( A );
Individual a2 = m.createIndividual( A );
RDFList l = m.createList( new OntResource[] {a0, a1, a2} );
return m.createIntersectionClass( null, l );
}
public boolean test( OntResource r ) { return r instanceof OntClass && r instanceof IntersectionClass; }
},
new CreateTestCase( "OWL create class", ProfileRegistry.OWL_LANG, NS + "C" ) {
public OntResource doCreate( OntModel m ) { return m.createClass( NS + "C" ); }
public boolean test( OntResource r ) { return r instanceof OntClass;}
},
new CreateTestCase( "DAML create class", ProfileRegistry.DAML_LANG, NS + "C" ) {
public OntResource doCreate( OntModel m ) { return m.createClass( NS + "C" ); }
public boolean test( OntResource r ) { return r instanceof OntClass;}
},
new CreateTestCase( "DAML create anon class", ProfileRegistry.DAML_LANG, null ) {
public OntResource doCreate( OntModel m ) { return m.createClass(); }
public boolean test( OntResource r ) { return r instanceof OntClass;}
},
new CreateTestCase( "DAML create anon complement class", ProfileRegistry.DAML_LANG, null ) {
public OntResource doCreate( OntModel m ) { return m.createComplementClass( null, m.createClass( NS + "A" ) ); }
public boolean test( OntResource r ) { return r instanceof OntClass && r instanceof ComplementClass; }
},
new CreateTestCase( "DAML create anon enumeration class", ProfileRegistry.DAML_LANG, null ) {
public OntResource doCreate( OntModel m ) {
OntClass A = m.createClass( NS + "A" );
Individual a0 = m.createIndividual( A );
Individual a1 = m.createIndividual( A );
Individual a2 = m.createIndividual( A );
RDFList l = m.createList( new OntResource[] {a0, a1, a2} );
return m.createEnumeratedClass( null, l );
}
public boolean test( OntResource r ) { return r instanceof OntClass && r instanceof EnumeratedClass; }
},
new CreateTestCase( "DAML create anon union class", ProfileRegistry.DAML_LANG, null ) {
public OntResource doCreate( OntModel m ) {
OntClass A = m.createClass( NS + "A" );
Individual a0 = m.createIndividual( A );
Individual a1 = m.createIndividual( A );
Individual a2 = m.createIndividual( A );
RDFList l = m.createList( new OntResource[] {a0, a1, a2} );
return m.createUnionClass( null, l );
}
public boolean test( OntResource r ) { return r instanceof OntClass && r instanceof UnionClass; }
},
new CreateTestCase( "DAML create anon intersection class", ProfileRegistry.DAML_LANG, null ) {
public OntResource doCreate( OntModel m ) {
OntClass A = m.createClass( NS + "A" );
Individual a0 = m.createIndividual( A );
Individual a1 = m.createIndividual( A );
Individual a2 = m.createIndividual( A );
RDFList l = m.createList( new OntResource[] {a0, a1, a2} );
return m.createIntersectionClass( null, l );
}
public boolean test( OntResource r ) { return r instanceof OntClass && r instanceof IntersectionClass; }
},
new CreateTestCase( "OWL create individual", ProfileRegistry.OWL_LANG, NS + "a" ) {
public OntResource doCreate( OntModel m ) {
OntClass c = m.createClass( NS + "C" );
return m.createIndividual( NS + "a", c );
}
public boolean test( OntResource r ) { return r instanceof Individual;}
},
new CreateTestCase( "OWL create anon individual", ProfileRegistry.OWL_LANG, null ) {
public OntResource doCreate( OntModel m ) {
OntClass c = m.createClass( NS + "C" );
return m.createIndividual( c );
}
public boolean test( OntResource r ) { return r instanceof Individual;}
},
new CreateTestCase( "DAML create individual", ProfileRegistry.DAML_LANG, NS + "a" ) {
public OntResource doCreate( OntModel m ) {
OntClass c = m.createClass( NS + "C" );
return m.createIndividual( NS + "a", c );
}
public boolean test( OntResource r ) { return r instanceof Individual;}
},
new CreateTestCase( "DAML create anon individual", ProfileRegistry.DAML_LANG, null ) {
public OntResource doCreate( OntModel m ) {
OntClass c = m.createClass( NS + "C" );
return m.createIndividual( c );
}
public boolean test( OntResource r ) { return r instanceof Individual;}
},
// OWL property types
new CreateTestCase( "OWL create object property", ProfileRegistry.OWL_LANG, NS + "p" ) {
public OntResource doCreate( OntModel m ) { return m.createObjectProperty( NS + "p" ); }
public boolean test( OntResource r ) { return r instanceof ObjectProperty;}
},
new CreateTestCase( "OWL create object property non-F", ProfileRegistry.OWL_LANG, NS + "p" ) {
public OntResource doCreate( OntModel m ) { return m.createObjectProperty( NS + "p", false ); }
public boolean test( OntResource r ) { return r instanceof ObjectProperty && !r.canAs( FunctionalProperty.class );}
},
new CreateTestCase( "OWL create object property F", ProfileRegistry.OWL_LANG, NS + "p" ) {
public OntResource doCreate( OntModel m ) { return m.createObjectProperty( NS + "p", true ); }
public boolean test( OntResource r ) { return r instanceof ObjectProperty && r.canAs( FunctionalProperty.class );}
},
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -