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

📄 testbugreports.java

📁 Jena推理机
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
        DatatypeProperty dp = m.createDatatypeProperty( NS + "dp" );
        dp.addRDFType( OWL.InverseFunctionalProperty );

        boolean ex = false;
        try {
            dp.as( InverseFunctionalProperty.class );
        }
        catch (ConversionException e) {
            ex = true;
        }
        assertTrue( "Should have been a conversion exception", ex );

        m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM );  // OWL full
        dp = m.createDatatypeProperty( NS + "dp" );
        dp.addRDFType( OWL.InverseFunctionalProperty );

        ex = false;
        try {
            dp.as( InverseFunctionalProperty.class );
        }
        catch (ConversionException e) {
            ex = true;
        }
        assertFalse( "Should not have been a conversion exception", ex );
    }

    /** Test case for SF bug 969475 - the return value for getInverse() on an ObjectProperty should be an object property */
    public void test_sf_969475() {
        String SOURCE=
            "<?xml version='1.0'?>" +
            "<!DOCTYPE owl [" +
            "      <!ENTITY rdf  'http://www.w3.org/1999/02/22-rdf-syntax-ns#' >" +
            "      <!ENTITY rdfs 'http://www.w3.org/2000/01/rdf-schema#' >" +
            "      <!ENTITY xsd  'http://www.w3.org/2001/XMLSchema#' >" +
            "      <!ENTITY owl  'http://www.w3.org/2002/07/owl#' >" +
            "      <!ENTITY dc   'http://purl.org/dc/elements/1.1/' >" +
            "      <!ENTITY base  'http://jena.hpl.hp.com/test' >" +
            "    ]>" +
            "<rdf:RDF xmlns:owl ='&owl;' xmlns:rdf='&rdf;' xmlns:rdfs='&rdfs;' xmlns:dc='&dc;' xmlns='&base;#' xml:base='&base;'>" +
            "  <owl:ObjectProperty rdf:ID='p0'>" +
            "    <owl:inverseOf>" +
            "      <owl:ObjectProperty rdf:ID='q0' />" +
            "    </owl:inverseOf>" +
            "  </owl:ObjectProperty>" +
            "  <owl:ObjectProperty rdf:ID='p1'>" +
            "    <owl:inverseOf>" +
            "      <owl:ObjectProperty rdf:ID='q1' />" +
            "    </owl:inverseOf>" +
            "  </owl:ObjectProperty>" +
            "</rdf:RDF>";
        OntModel m = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM );
        m.read( new StringReader( SOURCE ), null );

        ObjectProperty p0 = m.getObjectProperty( "http://jena.hpl.hp.com/test#p0");
        Object invP0 = p0.getInverseOf();

        assertEquals( m.getResource( "http://jena.hpl.hp.com/test#q0"), invP0 );
        assertTrue( "Should be an ObjectProperty facet", invP0 instanceof ObjectProperty );

        ObjectProperty q1 = m.getObjectProperty( "http://jena.hpl.hp.com/test#q1");
        Object invQ1 = q1.getInverse();

        assertEquals( m.getResource( "http://jena.hpl.hp.com/test#p1"), invQ1 );
        assertTrue( "Should be an ObjectProperty facet", invQ1 instanceof ObjectProperty );
    }

    /** Test case for SF bug 978259 - missing supports() checks in OWL DL and Lite profiles */
    public void test_sf_978259() {
        OntModel md = ModelFactory.createOntologyModel( OntModelSpec.OWL_DL_MEM );
        OntModel ml = ModelFactory.createOntologyModel( OntModelSpec.OWL_LITE_MEM );

        DataRange drd = md.createDataRange( md.createList( new Resource[] {OWL.Thing}) );
        assertNotNull( drd );
        HasValueRestriction hvrd = md.createHasValueRestriction( null, RDFS.seeAlso, OWL.Thing );
        assertNotNull( hvrd );

        boolean ex = false;
        try {
            drd = ml.createDataRange( md.createList( new Resource[] {OWL.Thing}) );
        }
        catch (ProfileException e) {
            ex = true;
        }
        assertTrue( ex );

        ex = false;
        try {
            hvrd = ml.createHasValueRestriction( null, RDFS.seeAlso, OWL.Thing );
        }
        catch (ProfileException e) {
            ex = true;
        }
        assertTrue( ex );
    }

    /**
     * Bug report by Jessica Brown jessicabrown153@yahoo.com: listIndividuals() fails
     * on a composite model in Jena 2.5
     */
    public void test_jb_01() {
        Model schema = ModelFactory.createDefaultModel();
        Model data = ModelFactory.createDefaultModel();
        Resource c = schema.createResource( "http://example.com/foo#AClass" );
        Resource i = data.createResource( "http://example.com/foo#anInd" );
        schema.add( c, RDF.type, OWL.Class );
        data.add( i, RDF.type, c );

        OntModel composite = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM, schema );
        composite.addSubModel( data );

        Set s = composite.listIndividuals().toSet();
        assertEquals( "should be one individual", 1, s.size() );
        assertTrue( s.contains( i ));
    }

    /**
     * Bug report by James Tizard - failure in listIndividuals with DIGexception causes
     * blocked thread
     */
    public void test_jt_01() {
        // set up a configuration resource to connect to the reasoner
        // on port 2004 on the local system
        Model cModel = ModelFactory.createDefaultModel();
        Resource conf = cModel.createResource();
        conf.addProperty( ReasonerVocabulary.EXT_REASONER_URL, cModel.createResource( "http://localhost:2004" ) );

        // create the reasoner factory and the reasoner
        DIGReasonerFactory drf = (DIGReasonerFactory) ReasonerRegistry.theRegistry()
                .getFactory( DIGReasonerFactory.URI );
        DIGReasoner r = (DIGReasoner) drf.create( conf );

        // now make a model
        OntModelSpec spec = new OntModelSpec( OntModelSpec.OWL_DL_MEM );
        spec.setReasoner( r );
        OntModel m = ModelFactory.createOntologyModel( spec, null );

        boolean ex = false;
        try {
            Iterator i = m.listIndividuals(); // if this throws a DIG exception
            System.out.println( i.hasNext() ); // then this doesn't return
        }
        catch (DIGWrappedException e) {
            ex = true;
        }
        assertTrue( "Should have seen a dig wrapped exception for connection fail", ex );
    }


    /**
     * Bug report by David Bigwood - listDeclaredProps(false) fails when props
     * are defined in an imported model
     */
    public void test_dab_01() {
        OntModel m0 = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM );

        // in model M0, p0 has class c0 in the domain
        OntClass c0 = m0.createClass( NS + "c0" );
        ObjectProperty p0 = m0.createObjectProperty( NS + "p0" );
        p0.setDomain( c0 );

        // in model M1, class c1 is a subClass of c0
        OntModel m1 = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM );
        OntClass c1 = m1.createClass( NS + "c1" );
        c1.addSuperClass( c0 );

        // simulate imports
        m1.addSubModel( m0 );

        // get a c0 reference from m1
        OntClass cc0 = m1.getOntClass( NS + "c0" );
        assertNotNull( cc0 );

        TestUtil.assertIteratorValues( this, c1.listDeclaredProperties(), new Object[] {p0} );
        TestUtil.assertIteratorValues( this, c0.listDeclaredProperties(false), new Object[] {p0} );

        // this is the one that fails per David's bug report
        TestUtil.assertIteratorValues( this, cc0.listDeclaredProperties(false), new Object[] {p0} );
    }

    /**
     * Bug report by David Bigwood - listUnionClasses causes conversion exception
     */
    public void test_dab_02a() {
        String SOURCEA=
            "<rdf:RDF" +
            "    xmlns:rdf          ='http://www.w3.org/1999/02/22-rdf-syntax-ns#'" +
            "    xmlns:owl          ='http://www.w3.org/2002/07/owl#'" +
            "    xml:base           ='http://example.com/a#'" +
            ">" +
            "<rdf:Description>" +
            "  <owl:unionOf " +
            "  rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/> " +
            "</rdf:Description>" +
            "</rdf:RDF>";

        OntModel a0 = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM );
        a0.read( new StringReader( SOURCEA ), null );

        // throws conversion exception ...
        for( Iterator i = a0.listUnionClasses(); i.hasNext(); ) {
            i.next();
        }

        OntModel a1 = ModelFactory.createOntologyModel( OntModelSpec.OWL_DL_MEM );
        a1.read( new StringReader( SOURCEA ), null );

        // throws conversion exception ...
        for( Iterator i = a1.listUnionClasses(); i.hasNext(); ) {
            i.next();
        }
    }

    public void test_dab_02b() {
        String SOURCEA=
            "<rdf:RDF" +
            "    xmlns:rdf          ='http://www.w3.org/1999/02/22-rdf-syntax-ns#'" +
            "    xmlns:owl          ='http://www.w3.org/2002/07/owl#'" +
            "    xml:base           ='http://example.com/a#'" +
            ">" +
            "<rdf:Description>" +
            "  <owl:intersectionOf " +
            "  rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/> " +
            "</rdf:Description>" +
            "</rdf:RDF>";

        OntModel a0 = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM );
        a0.read( new StringReader( SOURCEA ), null );

        // throws conversion exception ...
        for( Iterator i = a0.listIntersectionClasses(); i.hasNext(); ) {
            i.next();
        }

        OntModel a1 = ModelFactory.createOntologyModel( OntModelSpec.OWL_DL_MEM );
        a1.read( new StringReader( SOURCEA ), null );

        // throws conversion exception ...
        for( Iterator i = a1.listIntersectionClasses(); i.hasNext(); ) {
            i.next();
        }

        OntModel a2 = ModelFactory.createOntologyModel( OntModelSpec.OWL_LITE_MEM );
        a2.read( new StringReader( SOURCEA ), null );

        // throws conversion exception ...
        for( Iterator i = a2.listIntersectionClasses(); i.hasNext(); ) {
            i.next();
        }
    }

    public void test_dab_02c() {
        String SOURCEA=
            "<rdf:RDF" +
            "    xmlns:rdf          ='http://www.w3.org/1999/02/22-rdf-syntax-ns#'" +
            "    xmlns:owl          ='http://www.w3.org/2002/07/owl#'" +
            "    xml:base           ='http://example.com/a#'" +
            ">" +
            "<rdf:Description>" +
            "  <owl:complementOf " +
            "  rdf:resource='http://www.w3.org/2002/07/owl#Nothing'/> " +
            "</rdf:Description>" +
            "</rdf:RDF>";

        OntModel a0 = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM );
        a0.read( new StringReader( SOURCEA ), null );

        // throws conversion exception ...
        for( Iterator i = a0.listComplementClasses(); i.hasNext(); ) {
            i.next();
        }

        OntModel a1 = ModelFactory.createOntologyModel( OntModelSpec.OWL_DL_MEM );
        a1.read( new StringReader( SOURCEA ), null );

        // throws conversion exception ...
        for( Iterator i = a1.listComplementClasses(); i.hasNext(); ) {
            i.next();
        }
    }

    /**
     * Bug report by Othmane Nadjemi - DAML individual whose only type is daml:Thing
     * returns false to isIndividual()
     */
    public void test_on_01() {
        OntModel m = ModelFactory.createOntologyModel( OntModelSpec.DAML_MEM );
        Individual i = m.createIndividual( DAML_OIL.Thing );
        assertTrue( i.isIndividual() );
    }


    /**
     * Bug report by kers - maximal lower elements calculation not correct in models
     * with no reasoner. Manifests as direct sub-class bug.
     */
    public void test_kers_01() {
        OntModel m = ModelFactory.createOntologyModel( OntModelSpec.RDFS_MEM );
        OntClass r = m.createClass( NS + "r" );
        OntClass a = m.createClass( NS + "a" );
        OntClass b = m.createClass( NS + "b" );
        OntClass c = m.createClass( NS + "c" );
        OntClass d = m.createClass( NS + "d" );
        OntClass e = m.createClass( NS + "e" );
        OntClass f = m.createClass( NS + "f" );
        OntCla

⌨️ 快捷键说明

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