Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 64538200B35 for ; Mon, 20 Jun 2016 10:58:01 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 633FE160A65; Mon, 20 Jun 2016 08:58:01 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id AFA39160A66 for ; Mon, 20 Jun 2016 10:58:00 +0200 (CEST) Received: (qmail 56200 invoked by uid 500); 20 Jun 2016 08:58:00 -0000 Mailing-List: contact commits-help@commonsrdf.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commonsrdf.incubator.apache.org Delivered-To: mailing list commits@commonsrdf.incubator.apache.org Received: (qmail 56191 invoked by uid 99); 20 Jun 2016 08:57:59 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 20 Jun 2016 08:57:59 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 856251805A8 for ; Mon, 20 Jun 2016 08:57:59 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -4.646 X-Spam-Level: X-Spam-Status: No, score=-4.646 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-1.426] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id XLQF1MG0VprB for ; Mon, 20 Jun 2016 08:57:57 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with SMTP id BD7E95F46F for ; Mon, 20 Jun 2016 08:57:56 +0000 (UTC) Received: (qmail 55641 invoked by uid 99); 20 Jun 2016 08:57:55 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 20 Jun 2016 08:57:55 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 9C8F2ED310; Mon, 20 Jun 2016 08:57:55 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: stain@apache.org To: commits@commonsrdf.incubator.apache.org Date: Mon, 20 Jun 2016 08:57:58 -0000 Message-Id: <1e263a2cbfd5405fba8e37d63eeaafa9@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [04/50] incubator-commonsrdf git commit: Create our own BlankNode for testing archived-at: Mon, 20 Jun 2016 08:58:01 -0000 Create our own BlankNode for testing The test was improved to make the g1 and g2 with its own BlankNode instances - each graph then having _:b1 and _:b2 - but with different uniqueReference(). This would also test that multiple graph.add(s,p,o) works with foreign BlankNode instances, but without taking a stance on COMMONSRDF-15 - we don't care how it does the mapping (if any) - and don't even require that they have the same uniqueReference() after adding. Iterating g1 and g2 to add to g3 should not assume those BlankNodes are the same based on their triplesString() - but differ by their uniqueReference() Project: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/commit/a06f6219 Tree: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/tree/a06f6219 Diff: http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/diff/a06f6219 Branch: refs/heads/parser-with-quads Commit: a06f6219a4458f5dda70cda3097b975b005db308 Parents: 6fa2b48 Author: Stian Soiland-Reyes Authored: Mon Apr 11 15:58:20 2016 +0100 Committer: Stian Soiland-Reyes Committed: Mon Apr 11 15:58:20 2016 +0100 ---------------------------------------------------------------------- .../commons/rdf/api/AbstractGraphTest.java | 50 ++++++++++++++++++-- 1 file changed, 45 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/a06f6219/api/src/test/java/org/apache/commons/rdf/api/AbstractGraphTest.java ---------------------------------------------------------------------- diff --git a/api/src/test/java/org/apache/commons/rdf/api/AbstractGraphTest.java b/api/src/test/java/org/apache/commons/rdf/api/AbstractGraphTest.java index a6c4397..326e2ff 100644 --- a/api/src/test/java/org/apache/commons/rdf/api/AbstractGraphTest.java +++ b/api/src/test/java/org/apache/commons/rdf/api/AbstractGraphTest.java @@ -28,6 +28,8 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.Set; +import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; import org.junit.Assume; @@ -362,15 +364,19 @@ public abstract class AbstractGraphTest { source.getTriples().unordered().sequential().forEach(t -> target.add(t)); } + /** + * Make a new graph with two BlankNodes - each with a different uniqueReference + */ private Graph createGraph1() { RDFTermFactory factory1 = createFactory(); IRI name = factory1.createIRI("http://xmlns.com/foaf/0.1/name"); Graph g1 = factory1.createGraph(); - BlankNode b1 = factory1.createBlankNode(); + BlankNode b1 = createOwnBlankNode("b1"); g1.add(b1, name, factory1.createLiteral("Alice")); - - BlankNode b2 = factory1.createBlankNode(); + + + BlankNode b2 = createOwnBlankNode("b2"); g1.add(b2, name, factory1.createLiteral("Bob")); IRI hasChild = factory1.createIRI("http://example.com/hasChild"); @@ -379,16 +385,50 @@ public abstract class AbstractGraphTest { return g1; } + /** + * Create a different implementation of BlankNode to be tested with + * graph.add(a,b,c); + * (the implementation may or may not then choose to translate such to + * its own instances) + * + * @param name + * @return + */ + private BlankNode createOwnBlankNode(String name) { + return new BlankNode() { + @Override + public String ntriplesString() { + return "_: " + name; + } + @Override + public String uniqueReference() { + return "urn:uuid:" + UUID.randomUUID().toString(); + } + @Override + public int hashCode() { + return uniqueReference().hashCode(); + } + @Override + public boolean equals(Object obj) { + if (!( obj instanceof BlankNode)) { + return false; + } + BlankNode other = (BlankNode)obj; + return uniqueReference().equals(other.uniqueReference()); + } + }; + } + private Graph createGraph2() { RDFTermFactory factory2 = createFactory(); IRI name = factory2.createIRI("http://xmlns.com/foaf/0.1/name"); Graph g2 = factory2.createGraph(); - BlankNode b1 = factory2.createBlankNode(); + BlankNode b1 = createOwnBlankNode("b1"); g2.add(b1, name, factory2.createLiteral("Charlie")); - BlankNode b2 = factory2.createBlankNode(); + BlankNode b2 = createOwnBlankNode("b2"); g2.add(b2, name, factory2.createLiteral("Dave")); IRI hasChild = factory2.createIRI("http://example.com/hasChild");