예제 #1
0
파일: TestMisc.java 프로젝트: evren/Empire
  @Test
  public void testEmpireUtil() throws Exception {
    SupportsRdfId aId = new SupportsRdfIdImpl();

    assertTrue(EmpireUtil.asResource(aId) == null);

    Resource aRes =
        EmpireUtil.asResource(new SupportsRdfIdImpl(new SupportsRdfId.BNodeKey("asdf")));
    assertTrue(aRes instanceof BNode);
    assertEquals(((BNode) aRes).getID(), "asdf");

    aId = EmpireUtil.asSupportsRdfId(java.net.URI.create("urn:foo"));
    assertTrue(aId.getRdfId() instanceof SupportsRdfId.URIKey);
    assertEquals(aId.getRdfId().value(), java.net.URI.create("urn:foo"));

    assertTrue(EmpireUtil.getNamedGraph("") == null);

    SupportsRdfId.RdfKey aKey = EmpireUtil.asPrimaryKey(new URL("http://example.org"));
    assertTrue(aKey instanceof SupportsRdfId.URIKey);
    assertEquals(aKey.value(), new URL("http://example.org").toURI());

    BNode aAnon = ValueFactoryImpl.getInstance().createBNode("foobar");
    aKey = EmpireUtil.asPrimaryKey(aAnon);
    assertTrue(aKey instanceof SupportsRdfId.BNodeKey);
    assertEquals(aKey.value(), "foobar");
  }
예제 #2
0
파일: TestMisc.java 프로젝트: evren/Empire
  @Test
  public void testTimesTwo() throws InvalidRdfException {
    TestDoubleImpl obj = new TestDoubleImpl();

    Graph g = RdfGenerator.asRdf(obj);

    assertEquals(
        1,
        new ExtGraph(g)
            .getValues(
                EmpireUtil.asResource(obj),
                ValueFactoryImpl.getInstance().createURI(PrefixMapping.GLOBAL.uri("test:foo")))
            .size());
  }