Package org.apache.marmotta.ldclient.model

Examples of org.apache.marmotta.ldclient.model.ClientResponse


        ldclient.shutdown();
    }

    @Test
    public void testDummyProvider() throws Exception {
        ClientResponse resp1 = ldclient.retrieveResource("http://remote/resource1");
        RepositoryConnection con1 = resp1.getTriples().getConnection();
        try {
            con1.begin();
            Assert.assertEquals(3, con1.size());
            con1.commit();
        } finally {
            con1.close();
        }

        ClientResponse resp2 = ldclient.retrieveResource("http://remote/resource2");
        RepositoryConnection con2 = resp2.getTriples().getConnection();
        try {
            con2.begin();
            Assert.assertEquals(2, con2.size());
            con2.commit();
        } finally {
            con2.close();
        }

        ClientResponse resp3 = ldclient.retrieveResource("http://remote/resource3");
        RepositoryConnection con3 = resp3.getTriples().getConnection();
        try {
            con3.begin();
            Assert.assertEquals(2, con3.size());
            con3.commit();
        } finally {
View Full Code Here


            // 4.
            log.debug("refreshing resource {}",resource);
            this.lock.readLock().lock();
            try {
                ClientResponse response = ldclient.retrieveResource(resource.stringValue());

                if(response != null) {
                    log.info("refreshed resource {}",resource);

                    // obtain a new cache connection, since we closed the original connection above
                    LDCachingConnection cacheConnection1 = backend.getCacheConnection(resource.stringValue());
                    cacheConnection1.begin();
                    try {
                        URI subject = cacheConnection1.getValueFactory().createURI(resource.stringValue());

                        RepositoryConnection respConnection = response.getTriples().getConnection();

                        cacheConnection1.remove(subject, null, null);

                        int count = 0;
                        RepositoryResult<Statement> triples = respConnection.getStatements(null,null,null,true);
                        while(triples.hasNext()) {
                            Statement triple = triples.next();
                            try {
                                cacheConnection1.add(triple);
                            } catch (RuntimeException ex) {
                                log.warn("not adding triple {}: an exception occurred ({})",triple,ex.getMessage());
                            }
                            count++;
                        }
                        triples.close();
                        respConnection.close();

                        CacheEntry newEntry = new CacheEntry();
                        newEntry.setResource(subject);
                        newEntry.setExpiryDate(response.getExpires());
                        newEntry.setLastRetrieved(new Date());
                        if(entry != null) {
                            newEntry.setUpdateCount(entry.getUpdateCount()+1);
                        } else {
                            newEntry.setUpdateCount(1);
View Full Code Here

        ldclient.shutdown();
    }

    @Test
    public void testDummyProvider() throws Exception {
        ClientResponse resp1 = ldclient.retrieveResource("http://localhost/resource1");
        RepositoryConnection con1 = resp1.getTriples().getConnection();
        try {
            con1.begin();
            Assert.assertEquals(3, con1.size());
            con1.commit();
        } finally {
            con1.close();
        }

        ClientResponse resp2 = ldclient.retrieveResource("http://localhost/resource2");
        RepositoryConnection con2 = resp2.getTriples().getConnection();
        try {
            con2.begin();
            Assert.assertEquals(2, con2.size());
            con2.commit();
        } finally {
            con2.close();
        }

        ClientResponse resp3 = ldclient.retrieveResource("http://localhost/resource3");
        RepositoryConnection con3 = resp3.getTriples().getConnection();
        try {
            con3.begin();
            Assert.assertEquals(2, con3.size());
            con3.commit();
        } finally {
View Full Code Here

        String uriLMFVideo = "http://youtu.be/_3BmNcHW4Ew";

        Assume.assumeTrue(ldclient.ping(uriLMFVideo));

        ClientResponse respLMFVideo = ldclient.retrieveResource(uriLMFVideo);

        RepositoryConnection conLMFVideo = respLMFVideo.getTriples().getConnection();
        conLMFVideo.begin();
        Assert.assertTrue(conLMFVideo.size() > 0);

        // run a SPARQL test to see if the returned data is correct
        InputStream sparql = this.getClass().getResourceAsStream("youtube-lmf-video.sparql");
View Full Code Here

        String uriLMFVideo = "http://www.youtube.com/watch?v=_3BmNcHW4Ew";

        Assume.assumeTrue(ldclient.ping(uriLMFVideo));

        ClientResponse respLMFVideo = ldclient.retrieveResource(uriLMFVideo);

        RepositoryConnection conLMFVideo = respLMFVideo.getTriples().getConnection();
        conLMFVideo.begin();
        Assert.assertTrue(conLMFVideo.size() > 0);

        // run a SPARQL test to see if the returned data is correct
        InputStream sparql = this.getClass().getResourceAsStream("youtube-lmf-video-page.sparql");
View Full Code Here

        String uriChannel = "http://www.youtube.com/user/dieSpringer";

        Assume.assumeTrue(ldclient.ping("http://gdata.youtube.com/feeds/api/users/dieSpringer/uploads"));

        ClientResponse respChannel = ldclient.retrieveResource(uriChannel);

        RepositoryConnection conChannel = respChannel.getTriples().getConnection();
        conChannel.begin();
        Assert.assertTrue(conChannel.size() > 0);

        // run a SPARQL test to see if the returned data is correct
        InputStream sparql = this.getClass().getResourceAsStream("youtube-channel.sparql");
View Full Code Here

        String uriPlaylist = "http://www.youtube.com/playlist?list=FLsrORDOimfQf42SDGJgRY4g";

        Assume.assumeTrue(ldclient.ping("http://gdata.youtube.com/feeds/api/playlists/FLsrORDOimfQf42SDGJgRY4g"));

        ClientResponse respPlaylist = ldclient.retrieveResource(uriPlaylist);

        RepositoryConnection conPlaylist = respPlaylist.getTriples().getConnection();
        conPlaylist.begin();
        Assert.assertTrue(conPlaylist.size() > 0);

        conPlaylist.export(Rio.createWriter(RDFFormat.TURTLE, System.out));
View Full Code Here

        String uriMovie = "http://graph.facebook.com/160617097307237";

        Assume.assumeTrue(ldclient.ping(uriMovie));

        ClientResponse respMovie = ldclient.retrieveResource(uriMovie);

        RepositoryConnection con = respMovie.getTriples().getConnection();
        con.begin();
        Assert.assertTrue(con.size() > 0);

        logData(con);
View Full Code Here

    public void testInterest() throws Exception {
        String uriInterest = "http://graph.facebook.com/106515832719603";

        Assume.assumeTrue(ldclient.ping(uriInterest));

        ClientResponse respInterest = ldclient.retrieveResource(uriInterest);

        RepositoryConnection con = respInterest.getTriples().getConnection();
        con.begin();
        Assert.assertTrue(con.size() > 0);

        logData(con);
View Full Code Here

    public void testRestauraunt() throws Exception {
        String uriRestaurant = "http://graph.facebook.com/285699076901";

        Assume.assumeTrue(ldclient.ping(uriRestaurant));

        ClientResponse respInterest = ldclient.retrieveResource(uriRestaurant);

        RepositoryConnection con = respInterest.getTriples().getConnection();
        con.begin();
        Assert.assertTrue(con.size() > 0);

        logData(con);
View Full Code Here

TOP

Related Classes of org.apache.marmotta.ldclient.model.ClientResponse

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.