Package com.hp.hpl.jena.ontology

Examples of com.hp.hpl.jena.ontology.OntModel


    protected OntModel ontModel()
        { return ontModel( "" ); }

    protected OntModel ontModel( String facts )
        {
        OntModel result =  ModelFactory.createOntologyModel();
        result.setNsPrefixes( PrefixMapping.Extended );
        setRequiredPrefixes( result );
        new Parser( facts ).parseInto( result );
        return result;
        }
View Full Code Here


        testNoJenaPrefixReported( "j", "eh:/prefix/" );
        }
   
    private void testNoJenaPrefixReported( String prefix, String namespace )
        {
        OntModel m = ontModelWithPrefix( prefix, namespace );
        Report r = new Report();
        new PrefixInspector().inspectModel( r, m );
        assertIsoModels( model(), r.model() );
        }
View Full Code Here

        assertIsoModels( model(), r.model() );
        }
   
    private void testJenaPrefixReported( String prefix, String namespace )
        {
        OntModel m = ontModelWithPrefix( prefix, namespace );
        Report r = new Report();
        String modelString =
            "[eye:mainProperty eye:jenaPrefixFound & eye:jenaPrefixFound '<a>' & eye:forNamespace '<b>']"
            .replaceAll( "<a>", prefix )
            .replaceAll( "<b>", namespace )
View Full Code Here

        assertIsoModels( wanted, r.model() );
        }

    private OntModel ontModelWithPrefix( String prefix, String namespace )
        {
        OntModel m = ModelFactory.createOntologyModel();
        m.setNsPrefix( prefix, namespace );
        return m;
        }
View Full Code Here

        }

    @Test public void testReportsUnterminatedNamespace()
        {
        Report r = new Report();
        OntModel m = ontModelWithPrefix( "any", "http://domain.com/atom" );
        new PrefixInspector().inspectModel( r, m );
        String modelString =
            "[eye:mainProperty eye:badNamespaceURI & eye:onPrefix 'any'"
            + " & eye:badNamespaceURI 'http://domain.com/atom'"
            + " & eye:forReason eye:namespaceEndsWithNameCharacter]";
View Full Code Here

        assertIsoModels( itemModel( modelString ), r.model() );
        }
   
    @Test public void testReportsRepeatedNamespaces()
        {
        OntModel m = ontModel();
        Report r = new Report();
        String someURI = "http://some.domain.com/directory#";
        m.setNsPrefix( "a", someURI ).setNsPrefix( "b", someURI );
        new PrefixInspector().inspectModel( r, m );
        String modelString =
            "[eye:mainProperty eye:multiplePrefixesForNamespace"
            + " & eye:multiplePrefixesForNamespace 'http://some.domain.com/directory#'"
            + " & eye:onPrefix 'a' & eye:onPrefix 'b']";
View Full Code Here

        assertIsoModels( itemModel( modelString ), r.model() );
        }
   
    @Test public void testReportsMultipleRepeatedNamespaces()
        {
        OntModel m = ontModel();
        Report r = new Report();
        String someURI = "http://some.domain.com/directory#";
        String otherURI = "urn:xyz:preamble/";
        m.setNsPrefix( "a", someURI ).setNsPrefix( "b", someURI );
        m.setNsPrefix( "c", otherURI ).setNsPrefix( "d", otherURI );
        new PrefixInspector().inspectModel( r, m );
        String modelString =
            "[eye:mainProperty eye:multiplePrefixesForNamespace"
            + " & eye:multiplePrefixesForNamespace 'http://some.domain.com/directory#'"
            + " & eye:onPrefix 'a' & eye:onPrefix 'b']"
View Full Code Here

        testKnownPrefixCorrect( "eg", "http://bad/eg#" );
        }

    public void testKnownPrefixCorrect( String prefix, String uri )
        {
        OntModel m = ontModelWithPrefix( prefix, uri );
        Model wanted = ModelFactory.createDefaultModel()
            .createResource()
            .addProperty( EYE.forReason, "non-standard namespace for prefix" )
            .addProperty( EYE.onPrefix, prefix )
            .addProperty( EYE.badNamespaceURI, uri )
View Full Code Here

    @Test public void testAssumeTypeProvidesKnownProperty()
        { testAssumeContentDeclaresPropertyP( "p rdf:type rdf:Property" ); }

    private void testAssumeContentDeclaresPropertyP( String content )
        {
        OntModel assume = ontModel( content );
        ins.begin( new Report(), assume );
        assertTrue( "(" + content + ") should declare 'p' as a property", ins.knownProperty( property( "p" ) ) );
        }
View Full Code Here

        assertTrue( "(" + content + ") should declare 'p' as a property", ins.knownProperty( property( "p" ) ) );
        }

    @Test public void testImportsUpdateKnownProperties()
        {
        OntModel model = ontModel( "" );
        model.addSubModel( model( "X rdf:type rdf:Property" ) );
        model.addSubModel( model( "Y rdf:type rdf:Property" ) );
        ins.inspectModel( new Report(), model );
        assertTrue( ins.knownProperty( property( "X" ) ) );
        assertTrue( ins.knownProperty( property( "Y" ) ) );
        }
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.ontology.OntModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.