Examples of KiWiAnonResource


Examples of org.apache.marmotta.kiwi.model.rdf.KiWiAnonResource

    @Test
    public void testClusteredCacheBNode() throws InterruptedException, RepositoryException {

        log.info("testing cache synchronization ...");

        KiWiAnonResource u = (KiWiAnonResource) repositorySync1.getValueFactory().createBNode();


        // give the cluster some time to performance asynchronous balancing
        Thread.sleep(100);


        log.debug("test if resource is in cache where it was created ...");
        KiWiAnonResource u1 = cacheManagerSync1.getBNodeCache().get(u.getID());

        Assert.assertNotNull(u1);
        Assert.assertEquals(u,u1);
        Assert.assertEquals(u.getId(), u1.getId());

        log.debug("test if resource has been synced to other cache in cluster ...");
        KiWiAnonResource u2 = cacheManagerSync2.getBNodeCache().get(u.getID());

        Assert.assertNotNull(u2);
        Assert.assertEquals(u, u2);
        Assert.assertEquals(u.getId(), u2.getId());
    }
View Full Code Here

Examples of org.apache.marmotta.kiwi.model.rdf.KiWiAnonResource

    @Test
    public void testStoreBNode() throws SQLException {
        KiWiConnection connection = persistence.getConnection();
        try {
            // add a new URI to the triple store and check if it exists afterwards, before and after commit
            KiWiAnonResource bnode = new KiWiAnonResource(RandomStringUtils.randomAlphanumeric(8));
            connection.storeNode(bnode, false);

            // check if it then has a database ID
            Assert.assertNotNull(bnode.getId());

            KiWiNode testBNode1 = connection.loadNodeById(bnode.getId());

            // needs to be equal, and should also be the identical object!
            Assert.assertEquals(bnode,testBNode1);
            Assert.assertTrue(bnode == testBNode1);

            connection.commit();

            KiWiNode testBNode2 = connection.loadNodeById(bnode.getId());

            // needs to be equal, and should also be the identical object!
            Assert.assertEquals(bnode,testBNode2);
            Assert.assertTrue(bnode == testBNode2);


            KiWiNode testBNode3 = connection.loadAnonResource(bnode.stringValue());

            // needs to be equal, and should also be the identical object!
            Assert.assertEquals(bnode,testBNode3);
            Assert.assertTrue(bnode == testBNode3);


            connection.commit();

            Assert.assertEquals(1,Iterations.asList(connection.listResources()).size());

            // clear cache and test again
            persistence.clearCache();
            KiWiNode testBNode4 = connection.loadNodeById(bnode.getId());

            // needs to be equal, but now it should not be the same object!
            Assert.assertEquals(bnode,testBNode4);
            Assert.assertTrue(bnode != testBNode4);

            KiWiNode testBNode5 = connection.loadAnonResource(bnode.stringValue());

            // needs to be equal, but now it should not be the same object!
            Assert.assertEquals(bnode,testBNode5);
            Assert.assertTrue(bnode != testBNode5);

            connection.commit();

            // finally do a test on the nodes table, it should contain exactly one entry
            PreparedStatement checkNodeStmt = connection.getJDBCConnection().prepareStatement("SELECT * FROM nodes");
            ResultSet result = checkNodeStmt.executeQuery();

            Assert.assertTrue(result.next());
            Assert.assertEquals((long)bnode.getId(),result.getLong("id"));
            Assert.assertEquals(bnode.stringValue(),result.getString("svalue"));
            Assert.assertEquals("bnode",result.getString("ntype"));

            result.close();
            connection.commit();
        } finally {
View Full Code Here

Examples of org.apache.marmotta.kiwi.model.rdf.KiWiAnonResource

        for(KiWiNode n : nodeBacklog) {
            if(n instanceof KiWiUriResource) {
                KiWiUriResource u = (KiWiUriResource)n;
                createNodeList(rowArray, u.getId(), u.getClass(), u.stringValue(), null, null, null, null, null, null, u.getCreated());
            } else if(n instanceof KiWiAnonResource) {
                KiWiAnonResource a = (KiWiAnonResource)n;
                createNodeList(rowArray, a.getId(), a.getClass(), a.stringValue(), null, null, null, null, null, null, a.getCreated());
            } else if(n instanceof KiWiIntLiteral) {
                KiWiIntLiteral l = (KiWiIntLiteral)n;
                createNodeList(rowArray, l.getId(), l.getClass(), l.getContent(), l.getDoubleContent(), l.getIntContent(), null, null, l.getDatatype(), l.getLocale(), l.getCreated());
            } else if(n instanceof KiWiDoubleLiteral) {
                KiWiDoubleLiteral l = (KiWiDoubleLiteral)n;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.