Package org.openrdf.model

Examples of org.openrdf.model.Model


        InputStream response = getClass().getResourceAsStream("volcanoes.json");
        TestUtil.setResponseStream(method, response);
        return HTTP_OK;
      }
    });
    Model model = primalClient.getResult("topic", "contentSource", 0.6f, 20, 100);
    assertEquals(10, model.filter(null, RDF.TYPE, PRIMAL.CONTENT_ITEM).subjects().size());
    Set<String> refs = new HashSet<String>();
    for(Resource item : model.filter(null, RDF.TYPE, PRIMAL.CONTENT_ITEM).subjects()) {
      final Literal directReference = model.filter(item, DC.RELATION, null).objectLiteral();
      Literal name = model.filter(item, DC.TITLE, null).objectLiteral();
      assertNotNull(directReference);
      assertTrue(refs.add(directReference.stringValue()));
      assertNotNull(name);
      logger.debug(name.stringValue());
    }
View Full Code Here


  @Test
  public void testHangingGet() throws Exception {
    client.addConcept(testTopic, true);

    long start = System.currentTimeMillis();
    Model model = client.getResult(testTopic, 0, 0, 30);
    long end = System.currentTimeMillis();

    double durationSeconds = (end - start) / 1000.0;
    logger.debug("took " + durationSeconds + " seconds");

    // add 5 seconds for latency.
    assertTrue("took " + durationSeconds + " seconds", durationSeconds <= 35.0);

    assertNotNull(model);

    Model responseInfo = model.filter(null, null, null, PRIMAL.RESPONSE_INFO);

    assertTrue(responseInfo.contains(null, PRIMAL.STATUS, null));
    assertTrue(responseInfo.contains(null, PRIMAL.CONCEPT_COUNT, null));
    assertTrue(responseInfo.contains(null, PRIMAL.CONTENT_COUNT, null));
    assertTrue(responseInfo.contains(null, PRIMAL.MIN_SEMANTIC_COVERAGE, null));
    assertTrue(responseInfo.contains(null, PRIMAL.TERM_COVERAGE, null));

    // writeModel(model, RDFFormat.TRIG, new FileOutputStream(new
    // File("/Users/jeen/test-primal.trig")));

    client.deleteConcept(testTopic);
View Full Code Here

            fail();
        } catch (ParseException e) {
            e.printStackTrace();
            fail();
        }
        Model result = sth.createModelFromFile(resultFilePath, testCase.input);
        Model expected = sth.createModelFromFile(testCase.result, testCase.input);
        boolean equals = ModelUtil.equals(result, expected);
        if (!equals) {
            assertEquals(sth.diff(result, expected), sth.diff(expected, result), testCase.descr);
        }
//        assertEquals(ra, ea, String.format("%s (%s) failed", testCase.name, testCase.descr));
View Full Code Here

        result = result.substring(0, result.lastIndexOf('.')) + "-out." + ext;
        return result;
    }

    public Model createModelFromFile(String filename, String baseUri) throws IOException {
        Model model = new LinkedHashModel();
        if (filename != null) {
            try {
                RDFParser parser = Rio.createParser(SesameTestHelper.detectFileFormat(filename));
                parser.setRDFHandler(new ContextStatementCollector(model, ValueFactoryImpl.getInstance()));
View Full Code Here

        }
    }

    public boolean areModelsEqual(String producedModelPath, String expectedModelPath, String baseUri) {
        try {
            Model inputModel = createModelFromFile(producedModelPath, baseUri);
            Model expected = createModelFromFile(expectedModelPath, baseUri);
            return ModelUtil.equals(inputModel, expected);
        } catch (IOException e) {
            return false;
        }
    }
View Full Code Here

        }
    }

    public String diff(Model model1, Model model2) {
        StringBuilder result = new StringBuilder();
        Model delta = new LinkedHashModel(model1);
        delta.removeAll(model2);
        String[] lines = new String[delta.size()];
        int i = 0;
        for (Statement s : delta) {
            lines[i++] = s.toString();
        }
        Arrays.sort(lines);
View Full Code Here

        final ParserConfig config = new ParserConfig();
        config.set(BasicParserSettings.FAIL_ON_UNKNOWN_DATATYPES, true);
        config.set(BasicParserSettings.FAIL_ON_UNKNOWN_LANGUAGES, true);
        rdfParser.setParserConfig(config);
        rdfParser.setValueFactory(vf);
        final Model model = new LinkedHashModel();
        rdfParser.setRDFHandler(new StatementCollector(model));

        rdfParser.parse(in, "foo:bar");

        assertEquals("Unexpected number of statements", 6, model.size());
        final Model bnodeModel = model.filter(null, uri1,
                vf.createLiteral(plainLit.getLabel(), XMLSchema.STRING));
        assertEquals("Blank node was not round-tripped", 1, bnodeModel.size());
        assertTrue("Blank node was not round-tripped as a blank node", bnodeModel.subjects()
                .iterator().next() instanceof BNode);
        if (rdfParser.getRDFFormat().supportsContexts()) {
            assertTrue(model.contains(st2));
        } else {
            assertTrue(model.contains(vf.createStatement(uri1, uri2, langLit)));
View Full Code Here

TOP

Related Classes of org.openrdf.model.Model

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.