Return-Path: X-Original-To: apmail-clerezza-commits-archive@www.apache.org Delivered-To: apmail-clerezza-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B8AA017D70 for ; Thu, 19 Mar 2015 14:53:58 +0000 (UTC) Received: (qmail 51181 invoked by uid 500); 19 Mar 2015 14:53:46 -0000 Delivered-To: apmail-clerezza-commits-archive@clerezza.apache.org Received: (qmail 51153 invoked by uid 500); 19 Mar 2015 14:53:46 -0000 Mailing-List: contact commits-help@clerezza.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@clerezza.apache.org Delivered-To: mailing list commits@clerezza.apache.org Received: (qmail 51144 invoked by uid 99); 19 Mar 2015 14:53:46 -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; Thu, 19 Mar 2015 14:53:46 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id DBB76E1916; Thu, 19 Mar 2015 14:53:45 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: reto@apache.org To: commits@clerezza.apache.org Date: Thu, 19 Mar 2015 14:53:45 -0000 Message-Id: <2202a4a46a7644b69fb369cd4f2677dd@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/3] clerezza git commit: CLEREZZA-961: using rdf-commons from clerezza-rdf-core repository Repository: clerezza Updated Branches: refs/heads/rdf-commons 9ae0a1bc9 -> e5531d964 http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/util/SimpleLiteralFactory.java ---------------------------------------------------------------------- diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/util/SimpleLiteralFactory.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/util/SimpleLiteralFactory.java new file mode 100644 index 0000000..2799379 --- /dev/null +++ b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/impl/util/SimpleLiteralFactory.java @@ -0,0 +1,313 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.clerezza.rdf.core.impl.util; + +import org.apache.commons.rdf.impl.utils.TypedLiteralImpl; +import java.math.BigInteger; +import java.text.DateFormat; +import java.text.ParseException; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import org.apache.clerezza.rdf.core.InvalidLiteralTypeException; +import org.apache.clerezza.rdf.core.LiteralFactory; +import org.apache.clerezza.rdf.core.NoConvertorException; +import org.apache.commons.rdf.Iri; +import org.apache.clerezza.rdf.core.impl.util.Base64; +import org.apache.clerezza.rdf.core.impl.util.W3CDateFormat; +import org.apache.commons.rdf.Literal; + +/** + * An implementation of literal factory currently supporting only + * byte[]/base64Binary and Java.util.Date/date + * + * @author reto + */ + +public class SimpleLiteralFactory extends LiteralFactory { + + private static final String XSD = "http://www.w3.org/2001/XMLSchema#"; + final private static Iri xsdInteger = xsd("integer"); + final private static Iri xsdInt = xsd("int"); + final private static Iri xsdShort = xsd("short"); + final private static Iri xsdByte = xsd("byte"); + final private static Iri xsdLong = xsd("long"); + + + final private static Set decimalTypes = new HashSet(); + + final private static Map, TypeConverter> typeConverterMap = new HashMap, TypeConverter>(); + final static Class byteArrayType; + + static { + Collections.addAll(decimalTypes, xsdInteger, xsdInt, xsdByte, xsdShort, xsdLong ); + + byte[] byteArray = new byte[0]; + byteArrayType = byteArray.getClass(); + typeConverterMap.put(byteArrayType, new ByteArrayConverter()); + typeConverterMap.put(Date.class, new DateConverter()); + typeConverterMap.put(Boolean.class, new BooleanConverter()); + typeConverterMap.put(String.class, new StringConverter()); + typeConverterMap.put(Integer.class, new IntegerConverter()); + typeConverterMap.put(BigInteger.class, new BigIntegerConverter()); + typeConverterMap.put(Long.class, new LongConverter()); + typeConverterMap.put(Double.class, new DoubleConverter()); + typeConverterMap.put(Float.class, new FloatConverter()); + typeConverterMap.put(Iri.class, new UriRefConverter()); + } + + final private static Iri xsdDouble =xsd("double"); + final private static Iri xsdFloat =xsd("float"); + final private static Iri xsdAnyURI =xsd("anyURI"); + + final private static Iri xsd(String name) { + return new Iri(XSD+name); + } + + private static interface TypeConverter { + Literal createLiteral(T value); + T createObject(Literal literal); + } + + private static class ByteArrayConverter implements TypeConverter { + + private static final Iri base64Uri =xsd("base64Binary"); + + @Override + public Literal createLiteral(byte[] value) { + return new TypedLiteralImpl(Base64.encode((byte[]) value), base64Uri); + } + + @Override + public byte[] createObject(Literal literal) { + if (!literal.getDataType().equals(base64Uri)) { + throw new InvalidLiteralTypeException(byteArrayType, literal.getDataType()); + } + return (byte[])Base64.decode(literal.getLexicalForm()); + } + + + } + private static class DateConverter implements TypeConverter { + + private static final Iri dateTimeUri =xsd("dateTime"); + private static final DateFormat DATE_FORMAT = new W3CDateFormat(); + + @Override + public Literal createLiteral(Date value) { + return new TypedLiteralImpl(DATE_FORMAT.format(value), dateTimeUri); + } + + @Override + public Date createObject(Literal literal) { + if (!literal.getDataType().equals(dateTimeUri)) { + throw new InvalidLiteralTypeException(Date.class, literal.getDataType()); + } + try { + return DATE_FORMAT.parse(literal.getLexicalForm()); + } catch (ParseException ex) { + throw new RuntimeException("Exception parsing literal as date", ex); + } + } + + + } + + private static class BooleanConverter implements TypeConverter { + + private static final Iri booleanUri =xsd("boolean"); + public static final TypedLiteralImpl TRUE = new TypedLiteralImpl("true", booleanUri); + public static final TypedLiteralImpl FALSE = new TypedLiteralImpl("false", booleanUri); + + @Override + public Literal createLiteral(Boolean value) { + if (value) return TRUE; + else return FALSE; + } + + @Override + public Boolean createObject(Literal literal) { + if (literal == TRUE) return true; + else if (literal == FALSE) return false; + else if (!literal.getDataType().equals(booleanUri)) { + throw new InvalidLiteralTypeException(Boolean.class, literal.getDataType()); + } + return Boolean.valueOf(literal.getLexicalForm()); + } + } + + private static class StringConverter implements TypeConverter { + + private static final Iri stringUri =xsd("string"); + + @Override + public Literal createLiteral(String value) { + return new TypedLiteralImpl(value, stringUri); + } + + @Override + public String createObject(Literal literal) { + if (!literal.getDataType().equals(stringUri)) { + throw new InvalidLiteralTypeException(String.class, literal.getDataType()); + } + return literal.getLexicalForm(); + } + } + + private static class IntegerConverter implements TypeConverter { + + + @Override + public Literal createLiteral(Integer value) { + return new TypedLiteralImpl(value.toString(), xsdInt); + } + + @Override + public Integer createObject(Literal literal) { + if (!decimalTypes.contains(literal.getDataType())) { + throw new InvalidLiteralTypeException(Integer.class, literal.getDataType()); + } + return new Integer(literal.getLexicalForm()); + } + } + + private static class LongConverter implements TypeConverter { + + + + @Override + public Literal createLiteral(Long value) { + return new TypedLiteralImpl(value.toString(), xsdLong); + } + + @Override + public Long createObject(Literal literal) { + if (!decimalTypes.contains(literal.getDataType())) { + throw new InvalidLiteralTypeException(Long.class, literal.getDataType()); + } + return new Long(literal.getLexicalForm()); + } + } + + + private static class FloatConverter implements TypeConverter { + + @Override + public Literal createLiteral(Float value) { + return new TypedLiteralImpl(value.toString(), xsdFloat); + } + + @Override + public Float createObject(Literal literal) { + if (!literal.getDataType().equals(xsdFloat)) { + throw new InvalidLiteralTypeException(Float.class, literal.getDataType()); + } + return Float.valueOf(literal.getLexicalForm()); + } + } + + private static class DoubleConverter implements TypeConverter { + + + + @Override + public Literal createLiteral(Double value) { + return new TypedLiteralImpl(value.toString(), xsdDouble); + } + + @Override + public Double createObject(Literal literal) { + if (!literal.getDataType().equals(xsdDouble)) { + throw new InvalidLiteralTypeException(Double.class, literal.getDataType()); + } + return new Double(literal.getLexicalForm()); + } + } + + private static class BigIntegerConverter implements TypeConverter { + + + + @Override + public Literal createLiteral(BigInteger value) { + return new TypedLiteralImpl(value.toString(), xsdInteger); + } + + @Override + public BigInteger createObject(Literal literal) { + if (!literal.getDataType().equals(xsdInteger)) { + throw new InvalidLiteralTypeException(Double.class, literal.getDataType()); + } + return new BigInteger(literal.getLexicalForm()); + } + } + + private static class UriRefConverter implements TypeConverter { + + + + @Override + public Literal createLiteral(Iri value) { + return new TypedLiteralImpl(value.getUnicodeString(), xsdAnyURI); + } + + @Override + public Iri createObject(Literal literal) { + if (!literal.getDataType().equals(xsdAnyURI)) { + throw new InvalidLiteralTypeException(Iri.class, literal.getDataType()); + } + return new Iri(literal.getLexicalForm()); + } + } + + + @SuppressWarnings("unchecked") + @Override + public Literal createTypedLiteral(Object value) throws NoConvertorException { + TypeConverter converter = getConverterFor(value.getClass()); + return converter.createLiteral(value); + } + + + + @Override + public T createObject(Class type, Literal literal) + throws NoConvertorException, InvalidLiteralTypeException { + final TypeConverter converter = getConverterFor(type); + return converter.createObject(literal); + + } + + @SuppressWarnings("unchecked") + private TypeConverter getConverterFor(Class type) throws NoConvertorException { + TypeConverter convertor = (TypeConverter) typeConverterMap.get(type); + if (convertor != null) { + return convertor; + } + for (Map.Entry, TypeConverter> converterEntry : typeConverterMap.entrySet()) { + if (type.isAssignableFrom(converterEntry.getKey())) { + return (TypeConverter) converterEntry.getValue(); + } + } + throw new NoConvertorException(type); + } +} http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/main/java/org/apache/clerezza/rdf/core/serializedform/Parser.java ---------------------------------------------------------------------- diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/serializedform/Parser.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/serializedform/Parser.java index d7ef8a8..944fd5d 100644 --- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/serializedform/Parser.java +++ b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/serializedform/Parser.java @@ -35,7 +35,7 @@ import java.util.logging.Level; import org.apache.commons.rdf.ImmutableGraph; import org.apache.commons.rdf.Graph; import org.apache.commons.rdf.Iri; -import org.apache.clerezza.rdf.core.impl.SimpleMGraph; +import org.apache.commons.rdf.impl.utils.simple.SimpleMGraph; import org.osgi.service.cm.ConfigurationAdmin; import org.osgi.service.component.ComponentContext; import org.osgi.service.component.annotations.Activate; http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/main/javacc/org/apache/clerezza/rdf/core/sparql/JavaCCGeneratedQueryParser.jj ---------------------------------------------------------------------- diff --git a/rdf.core/src/main/javacc/org/apache/clerezza/rdf/core/sparql/JavaCCGeneratedQueryParser.jj b/rdf.core/src/main/javacc/org/apache/clerezza/rdf/core/sparql/JavaCCGeneratedQueryParser.jj index c56f87c..db5ad01 100644 --- a/rdf.core/src/main/javacc/org/apache/clerezza/rdf/core/sparql/JavaCCGeneratedQueryParser.jj +++ b/rdf.core/src/main/javacc/org/apache/clerezza/rdf/core/sparql/JavaCCGeneratedQueryParser.jj @@ -45,8 +45,8 @@ import org.apache.commons.rdf.Literal; import org.apache.commons.rdf.RdfTerm; import org.apache.commons.rdf.Iri; import org.apache.clerezza.rdf.core.LiteralFactory; -import org.apache.clerezza.rdf.core.impl.PlainLiteralImpl; -import org.apache.clerezza.rdf.core.impl.TypedLiteralImpl; +import org.apache.commons.rdf.impl.utils.PlainLiteralImpl; +import org.apache.commons.rdf.impl.utils.TypedLiteralImpl; import org.apache.clerezza.rdf.core.sparql.query.GroupGraphPattern; import org.apache.clerezza.rdf.core.sparql.query.BinaryOperation; import org.apache.clerezza.rdf.core.sparql.query.Variable; http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/main/javacc/org/apache/clerezza/rdf/core/sparql/JavaCCGeneratedSparqlPreParser.jj ---------------------------------------------------------------------- diff --git a/rdf.core/src/main/javacc/org/apache/clerezza/rdf/core/sparql/JavaCCGeneratedSparqlPreParser.jj b/rdf.core/src/main/javacc/org/apache/clerezza/rdf/core/sparql/JavaCCGeneratedSparqlPreParser.jj index e881782..1064cb8 100644 --- a/rdf.core/src/main/javacc/org/apache/clerezza/rdf/core/sparql/JavaCCGeneratedSparqlPreParser.jj +++ b/rdf.core/src/main/javacc/org/apache/clerezza/rdf/core/sparql/JavaCCGeneratedSparqlPreParser.jj @@ -44,8 +44,8 @@ import org.apache.commons.rdf.Literal; import org.apache.commons.rdf.RdfTerm; import org.apache.commons.rdf.Iri; import org.apache.clerezza.rdf.core.LiteralFactory; -import org.apache.clerezza.rdf.core.impl.PlainLiteralImpl; -import org.apache.clerezza.rdf.core.impl.TypedLiteralImpl; +import org.apache.commons.rdf.impl.utils.PlainLiteralImpl; +import org.apache.commons.rdf.impl.utils.TypedLiteralImpl; import org.apache.clerezza.rdf.core.sparql.query.AlternativeGraphPattern; import org.apache.clerezza.rdf.core.sparql.query.BinaryOperation; import org.apache.clerezza.rdf.core.sparql.query.BinaryPropertyPathOperation; http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/test/java/org/apache/clerezza/rdf/core/access/SecurityTest.java ---------------------------------------------------------------------- diff --git a/rdf.core/src/test/java/org/apache/clerezza/rdf/core/access/SecurityTest.java b/rdf.core/src/test/java/org/apache/clerezza/rdf/core/access/SecurityTest.java index 42c297c..deb0baf 100644 --- a/rdf.core/src/test/java/org/apache/clerezza/rdf/core/access/SecurityTest.java +++ b/rdf.core/src/test/java/org/apache/clerezza/rdf/core/access/SecurityTest.java @@ -40,8 +40,8 @@ import org.apache.commons.rdf.Iri; import org.apache.clerezza.rdf.core.access.providers.WeightedA; import org.apache.clerezza.rdf.core.access.providers.WeightedDummy; import org.apache.clerezza.rdf.core.access.security.TcPermission; -import org.apache.clerezza.rdf.core.impl.PlainLiteralImpl; -import org.apache.clerezza.rdf.core.impl.TripleImpl; +import org.apache.commons.rdf.impl.utils.PlainLiteralImpl; +import org.apache.commons.rdf.impl.utils.TripleImpl; /** * http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/test/java/org/apache/clerezza/rdf/core/access/TcManagerTest.java ---------------------------------------------------------------------- diff --git a/rdf.core/src/test/java/org/apache/clerezza/rdf/core/access/TcManagerTest.java b/rdf.core/src/test/java/org/apache/clerezza/rdf/core/access/TcManagerTest.java index a4ae80a..59ce257 100644 --- a/rdf.core/src/test/java/org/apache/clerezza/rdf/core/access/TcManagerTest.java +++ b/rdf.core/src/test/java/org/apache/clerezza/rdf/core/access/TcManagerTest.java @@ -32,8 +32,8 @@ import org.apache.clerezza.rdf.core.access.providers.WeightedA; import org.apache.clerezza.rdf.core.access.providers.WeightedA1; import org.apache.clerezza.rdf.core.access.providers.WeightedAHeavy; import org.apache.clerezza.rdf.core.access.providers.WeightedBlight; -import org.apache.clerezza.rdf.core.impl.SimpleMGraph; -import org.apache.clerezza.rdf.core.impl.TripleImpl; +import org.apache.commons.rdf.impl.utils.simple.SimpleMGraph; +import org.apache.commons.rdf.impl.utils.TripleImpl; import org.apache.clerezza.rdf.core.sparql.NoQueryEngineException; import org.apache.clerezza.rdf.core.sparql.QueryEngine; import org.apache.clerezza.rdf.core.sparql.query.AskQuery; http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/test/java/org/apache/clerezza/rdf/core/access/providers/WeightedA.java ---------------------------------------------------------------------- diff --git a/rdf.core/src/test/java/org/apache/clerezza/rdf/core/access/providers/WeightedA.java b/rdf.core/src/test/java/org/apache/clerezza/rdf/core/access/providers/WeightedA.java index 2e804fb..f61bd44 100644 --- a/rdf.core/src/test/java/org/apache/clerezza/rdf/core/access/providers/WeightedA.java +++ b/rdf.core/src/test/java/org/apache/clerezza/rdf/core/access/providers/WeightedA.java @@ -29,8 +29,8 @@ import org.apache.clerezza.rdf.core.access.EntityUndeletableException; import org.apache.clerezza.rdf.core.access.NoSuchEntityException; import org.apache.clerezza.rdf.core.access.WeightedTcProvider; import org.apache.clerezza.rdf.core.access.TcManagerTest; -import org.apache.clerezza.rdf.core.impl.SimpleMGraph; -import org.apache.clerezza.rdf.core.impl.TripleImpl; +import org.apache.commons.rdf.impl.utils.simple.SimpleMGraph; +import org.apache.commons.rdf.impl.utils.TripleImpl; /** * @@ -57,7 +57,7 @@ public class WeightedA implements WeightedTcProvider { @Override public Graph getMGraph(Iri name) throws NoSuchEntityException { - throw new UnsupportedOperationException("Not supported yet."); + throw new NoSuchEntityException(name); } @Override http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/test/java/org/apache/clerezza/rdf/core/access/providers/WeightedA1.java ---------------------------------------------------------------------- diff --git a/rdf.core/src/test/java/org/apache/clerezza/rdf/core/access/providers/WeightedA1.java b/rdf.core/src/test/java/org/apache/clerezza/rdf/core/access/providers/WeightedA1.java index f280178..4a9bcf2 100644 --- a/rdf.core/src/test/java/org/apache/clerezza/rdf/core/access/providers/WeightedA1.java +++ b/rdf.core/src/test/java/org/apache/clerezza/rdf/core/access/providers/WeightedA1.java @@ -29,8 +29,8 @@ import org.apache.clerezza.rdf.core.access.EntityUndeletableException; import org.apache.clerezza.rdf.core.access.NoSuchEntityException; import org.apache.clerezza.rdf.core.access.WeightedTcProvider; import org.apache.clerezza.rdf.core.access.TcManagerTest; -import org.apache.clerezza.rdf.core.impl.SimpleMGraph; -import org.apache.clerezza.rdf.core.impl.TripleImpl; +import org.apache.commons.rdf.impl.utils.simple.SimpleMGraph; +import org.apache.commons.rdf.impl.utils.TripleImpl; /** * Same weight as WeightedA, but later in string-ordering @@ -58,7 +58,7 @@ public class WeightedA1 implements WeightedTcProvider { @Override public Graph getMGraph(Iri name) throws NoSuchEntityException { - throw new UnsupportedOperationException("Not supported yet."); + throw new NoSuchEntityException(name); } @Override http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/test/java/org/apache/clerezza/rdf/core/access/providers/WeightedAHeavy.java ---------------------------------------------------------------------- diff --git a/rdf.core/src/test/java/org/apache/clerezza/rdf/core/access/providers/WeightedAHeavy.java b/rdf.core/src/test/java/org/apache/clerezza/rdf/core/access/providers/WeightedAHeavy.java index d5f0ae5..82307ad 100644 --- a/rdf.core/src/test/java/org/apache/clerezza/rdf/core/access/providers/WeightedAHeavy.java +++ b/rdf.core/src/test/java/org/apache/clerezza/rdf/core/access/providers/WeightedAHeavy.java @@ -30,8 +30,9 @@ import org.apache.clerezza.rdf.core.access.EntityUndeletableException; import org.apache.clerezza.rdf.core.access.NoSuchEntityException; import org.apache.clerezza.rdf.core.access.WeightedTcProvider; import org.apache.clerezza.rdf.core.access.TcManagerTest; -import org.apache.clerezza.rdf.core.impl.SimpleMGraph; -import org.apache.clerezza.rdf.core.impl.TripleImpl; +import org.apache.commons.rdf.impl.utils.simple.SimpleMGraph; +import org.apache.commons.rdf.impl.utils.TripleImpl; +import org.apache.commons.rdf.impl.utils.simple.SimpleGraph; /** * @@ -47,7 +48,7 @@ public class WeightedAHeavy implements WeightedTcProvider { @Override public ImmutableGraph getGraph(Iri name) throws NoSuchEntityException { if (name.equals(TcManagerTest.uriRefA)) { - Graph mResult = new SimpleMGraph(); + Graph mResult = new SimpleGraph(); mResult.add(new TripleImpl(TcManagerTest.uriRefAHeavy, TcManagerTest.uriRefAHeavy, TcManagerTest.uriRefAHeavy)); return mResult.getImmutableGraph(); @@ -57,7 +58,7 @@ public class WeightedAHeavy implements WeightedTcProvider { @Override public Graph getMGraph(Iri name) throws NoSuchEntityException { - throw new UnsupportedOperationException("Not supported yet."); + throw new NoSuchEntityException(name); } @Override http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/test/java/org/apache/clerezza/rdf/core/access/providers/WeightedBlight.java ---------------------------------------------------------------------- diff --git a/rdf.core/src/test/java/org/apache/clerezza/rdf/core/access/providers/WeightedBlight.java b/rdf.core/src/test/java/org/apache/clerezza/rdf/core/access/providers/WeightedBlight.java index b0e3192..c5023d8 100644 --- a/rdf.core/src/test/java/org/apache/clerezza/rdf/core/access/providers/WeightedBlight.java +++ b/rdf.core/src/test/java/org/apache/clerezza/rdf/core/access/providers/WeightedBlight.java @@ -29,8 +29,8 @@ import org.apache.clerezza.rdf.core.access.EntityUndeletableException; import org.apache.clerezza.rdf.core.access.NoSuchEntityException; import org.apache.clerezza.rdf.core.access.WeightedTcProvider; import org.apache.clerezza.rdf.core.access.TcManagerTest; -import org.apache.clerezza.rdf.core.impl.SimpleMGraph; -import org.apache.clerezza.rdf.core.impl.TripleImpl; +import org.apache.commons.rdf.impl.utils.simple.SimpleMGraph; +import org.apache.commons.rdf.impl.utils.TripleImpl; /** * @@ -60,7 +60,7 @@ public class WeightedBlight implements WeightedTcProvider { @Override public Graph getMGraph(Iri name) throws NoSuchEntityException { - throw new UnsupportedOperationException("Not supported yet."); + throw new NoSuchEntityException(name); } @Override http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/test/java/org/apache/clerezza/rdf/core/access/providers/WeightedDummy.java ---------------------------------------------------------------------- diff --git a/rdf.core/src/test/java/org/apache/clerezza/rdf/core/access/providers/WeightedDummy.java b/rdf.core/src/test/java/org/apache/clerezza/rdf/core/access/providers/WeightedDummy.java index cc9bd88..183d1f7 100644 --- a/rdf.core/src/test/java/org/apache/clerezza/rdf/core/access/providers/WeightedDummy.java +++ b/rdf.core/src/test/java/org/apache/clerezza/rdf/core/access/providers/WeightedDummy.java @@ -31,8 +31,8 @@ import org.apache.clerezza.rdf.core.access.EntityAlreadyExistsException; import org.apache.clerezza.rdf.core.access.EntityUndeletableException; import org.apache.clerezza.rdf.core.access.NoSuchEntityException; import org.apache.clerezza.rdf.core.access.WeightedTcProvider; -import org.apache.clerezza.rdf.core.impl.SimpleImmutableGraph; -import org.apache.clerezza.rdf.core.impl.SimpleMGraph; +import org.apache.commons.rdf.impl.utils.simple.SimpleImmutableGraph; +import org.apache.commons.rdf.impl.utils.simple.SimpleMGraph; /** * http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/test/java/org/apache/clerezza/rdf/core/events/NotificationTest.java ---------------------------------------------------------------------- diff --git a/rdf.core/src/test/java/org/apache/clerezza/rdf/core/events/NotificationTest.java b/rdf.core/src/test/java/org/apache/clerezza/rdf/core/events/NotificationTest.java deleted file mode 100644 index 09a25e8..0000000 --- a/rdf.core/src/test/java/org/apache/clerezza/rdf/core/events/NotificationTest.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.clerezza.rdf.core.events; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import org.junit.Assert; -import org.junit.Test; -import org.apache.commons.rdf.Triple; -import org.apache.commons.rdf.Graph; -import org.apache.commons.rdf.Iri; -import org.apache.commons.rdf.event.FilterTriple; -import org.apache.commons.rdf.event.GraphEvent; -import org.apache.commons.rdf.event.GraphListener; -import org.apache.clerezza.rdf.core.impl.SimpleMGraph; -import org.apache.clerezza.rdf.core.impl.TripleImpl; - -/** - * - * @author reto - */ -public class NotificationTest { - @Test public void getEventsTogether() throws Exception { - final Graph tc = new SimpleMGraph(); - final List> eventChunks = new ArrayList>(); - GraphListener myGraphListener = new GraphListener() { - @Override - public void graphChanged(List events) { - eventChunks.add(events); - //the following causes an event to be added to events - //(the List we already got)! This is because it doesn't wait - //on a synhronized(this) as we are already in an evnet dispatch - //thread - //tc.add(generateTriple()); - } - }; - tc.addGraphListener(myGraphListener, new FilterTriple(null, null, null), - 500); - for (int i = 0; i < 100; i++) { - tc.add(generateTriple()); - } - Thread.sleep(600); - Assert.assertEquals(1, eventChunks.size()); - Assert.assertEquals(100, eventChunks.get(0).size()); - tc.add(generateTriple()); - Thread.sleep(600); - Assert.assertEquals(2, eventChunks.size()); - Assert.assertEquals(1, eventChunks.get(1).size()); - } - - - @Test public void synchroneousEvents() throws Exception { - final Graph tc = new SimpleMGraph(); - final List> eventChunks = new ArrayList>(); - GraphListener myGraphListener = new GraphListener() { - @Override - public void graphChanged(List events) { - eventChunks.add(events); - } - }; - tc.addGraphListener(myGraphListener, new FilterTriple(null, null, null), - 0); - for (int i = 0; i < 100; i++) { - tc.add(generateTriple()); - } - Assert.assertEquals(100, eventChunks.size()); - Assert.assertEquals(1, eventChunks.get(97).size()); - tc.add(generateTriple()); - Assert.assertEquals(101, eventChunks.size()); - Assert.assertEquals(1, eventChunks.get(100).size()); - } - - private static Triple generateTriple() { - return new TripleImpl(generateRandomUriRef(), generateRandomUriRef(), - generateRandomUriRef()); - } - - private static Iri generateRandomUriRef() { - return new Iri("http://example.org/"+Math.random()); - } -} http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/test/java/org/apache/clerezza/rdf/core/impl/PlainLiteralImplTest.java ---------------------------------------------------------------------- diff --git a/rdf.core/src/test/java/org/apache/clerezza/rdf/core/impl/PlainLiteralImplTest.java b/rdf.core/src/test/java/org/apache/clerezza/rdf/core/impl/PlainLiteralImplTest.java deleted file mode 100644 index 381503b..0000000 --- a/rdf.core/src/test/java/org/apache/clerezza/rdf/core/impl/PlainLiteralImplTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.clerezza.rdf.core.impl; - -import org.junit.Test; -import junit.framework.Assert; - -import org.apache.commons.rdf.Language; -import org.apache.commons.rdf.Literal; -/** - * - * @author reto - * - */ - -public class PlainLiteralImplTest { - - - @Test public void plainLiteralEquality() { - String stringValue = "some text"; - Literal literal1 = new PlainLiteralImpl(stringValue); - Literal literal2 = new PlainLiteralImpl(stringValue); - Assert.assertEquals(literal1, literal2); - Assert.assertEquals(literal1.hashCode(), literal2.hashCode()); - Literal literal3 = new PlainLiteralImpl("something else"); - Assert.assertFalse(literal1.equals(literal3)); - } - - @Test public void languageLiteralEquality() { - String stringValue = "some text"; - Language lang = new Language("en-ca"); - Literal literal1 = new PlainLiteralImpl(stringValue, lang); - Literal literal2 = new PlainLiteralImpl(stringValue, lang); - Assert.assertEquals(literal1, literal2); - Assert.assertEquals(literal1.hashCode(), literal2.hashCode()); - Language lang2 = new Language("de"); - Literal literal3 = new PlainLiteralImpl(stringValue, lang2); - Assert.assertFalse(literal1.equals(literal3)); - Literal literal4 = new PlainLiteralImpl(stringValue, null); - Assert.assertFalse(literal3.equals(literal4)); - Assert.assertFalse(literal4.equals(literal3)); - } - - /** - * hashCode of the lexical form plus the hashCode of the locale - */ - @Test public void checkHashCode() { - String stringValue = "some text"; - Language language = new Language("en"); - Literal literal = new PlainLiteralImpl(stringValue, language); - Assert.assertEquals(stringValue.hashCode() + language.hashCode(), literal.hashCode()); - } - -} http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/test/java/org/apache/clerezza/rdf/core/impl/SimpleGraphTest.java ---------------------------------------------------------------------- diff --git a/rdf.core/src/test/java/org/apache/clerezza/rdf/core/impl/SimpleGraphTest.java b/rdf.core/src/test/java/org/apache/clerezza/rdf/core/impl/SimpleGraphTest.java deleted file mode 100644 index b4f5aa4..0000000 --- a/rdf.core/src/test/java/org/apache/clerezza/rdf/core/impl/SimpleGraphTest.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.clerezza.rdf.core.impl; - -import java.util.ConcurrentModificationException; -import java.util.Iterator; -import org.junit.Assert; -import org.junit.Test; -import org.apache.commons.rdf.Triple; -import org.apache.commons.rdf.Iri; - -/** - * - * @author mir - */ -public class SimpleGraphTest { - - private Iri uriRef1 = new Iri("http://example.org/foo"); - private Iri uriRef2 = new Iri("http://example.org/bar"); - private Iri uriRef3 = new Iri("http://example.org/test"); - private Triple triple1 = new TripleImpl(uriRef1, uriRef2, uriRef3); - private Triple triple2 = new TripleImpl(uriRef2, uriRef2, uriRef1); - private Triple triple3 = new TripleImpl(uriRef3, uriRef1, uriRef3); - private Triple triple4 = new TripleImpl(uriRef1, uriRef3, uriRef2); - private Triple triple5 = new TripleImpl(uriRef2, uriRef3, uriRef2); - - @Test - public void iteratorRemove() { - SimpleGraph stc = new SimpleGraph(); - stc.add(triple1); - stc.add(triple2); - stc.add(triple3); - stc.add(triple4); - stc.add(triple5); - Iterator iter = stc.iterator(); - while (iter.hasNext()) { - Triple triple = iter.next(); - iter.remove(); - } - Assert.assertEquals(0, stc.size()); - } - - @Test - public void removeAll() { - SimpleGraph stc = new SimpleGraph(); - stc.add(triple1); - stc.add(triple2); - stc.add(triple3); - stc.add(triple4); - stc.add(triple5); - SimpleGraph stc2 = new SimpleGraph(); - stc2.add(triple1); - stc2.add(triple3); - stc2.add(triple5); - stc.removeAll(stc2); - Assert.assertEquals(2, stc.size()); - } - - @Test - public void filterIteratorRemove() { - SimpleGraph stc = new SimpleGraph(); - stc.add(triple1); - stc.add(triple2); - stc.add(triple3); - stc.add(triple4); - stc.add(triple5); - Iterator iter = stc.filter(uriRef1, null, null); - while (iter.hasNext()) { - Triple triple = iter.next(); - iter.remove(); - } - Assert.assertEquals(3, stc.size()); - } - - @Test(expected=ConcurrentModificationException.class) - public void remove() { - SimpleGraph stc = new SimpleGraph(); - stc.setCheckConcurrency(true); - stc.add(triple1); - stc.add(triple2); - stc.add(triple3); - stc.add(triple4); - stc.add(triple5); - Iterator iter = stc.filter(uriRef1, null, null); - while (iter.hasNext()) { - Triple triple = iter.next(); - stc.remove(triple); - } - Assert.assertEquals(3, stc.size()); - } -} http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/test/java/org/apache/clerezza/rdf/core/impl/SimpleLiteralFactoryTest.java ---------------------------------------------------------------------- diff --git a/rdf.core/src/test/java/org/apache/clerezza/rdf/core/impl/SimpleLiteralFactoryTest.java b/rdf.core/src/test/java/org/apache/clerezza/rdf/core/impl/SimpleLiteralFactoryTest.java deleted file mode 100644 index 17e25ed..0000000 --- a/rdf.core/src/test/java/org/apache/clerezza/rdf/core/impl/SimpleLiteralFactoryTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.clerezza.rdf.core.impl; - -import junit.framework.Assert; -import org.apache.commons.rdf.Literal; -import org.apache.commons.rdf.Iri; -import org.junit.Test; - -/** - * - * @author reto - */ -public class SimpleLiteralFactoryTest { - - final private static Iri xsdInteger = - new Iri("http://www.w3.org/2001/XMLSchema#integer"); - final private static Iri xsdInt = - new Iri("http://www.w3.org/2001/XMLSchema#int"); - final private static Iri xsdLong = - new Iri("http://www.w3.org/2001/XMLSchema#long"); - - SimpleLiteralFactory simpleLiteralFactory = new SimpleLiteralFactory(); - - @Test - public void longToXsdIntegerAndBackToMany() { - long value = 14l; - Literal tl = simpleLiteralFactory.createTypedLiteral(value); - Assert.assertEquals(xsdLong, tl.getDataType()); - long longValue = simpleLiteralFactory.createObject(Long.class, tl); - Assert.assertEquals(value, longValue); - int intValue = simpleLiteralFactory.createObject(Integer.class, tl); - Assert.assertEquals(value, intValue); - } - - @Test - public void intToXsdIntAndBackToMany() { - int value = 14; - Literal tl = simpleLiteralFactory.createTypedLiteral(value); - Assert.assertEquals(xsdInt, tl.getDataType()); - long longValue = simpleLiteralFactory.createObject(Long.class, tl); - Assert.assertEquals(value, longValue); - int intValue = simpleLiteralFactory.createObject(Integer.class, tl); - Assert.assertEquals(value, intValue); - } -} http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/test/java/org/apache/clerezza/rdf/core/impl/TripleImplTest.java ---------------------------------------------------------------------- diff --git a/rdf.core/src/test/java/org/apache/clerezza/rdf/core/impl/TripleImplTest.java b/rdf.core/src/test/java/org/apache/clerezza/rdf/core/impl/TripleImplTest.java deleted file mode 100644 index b127702..0000000 --- a/rdf.core/src/test/java/org/apache/clerezza/rdf/core/impl/TripleImplTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ - -package org.apache.clerezza.rdf.core.impl; -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ - - -import org.junit.Test; -import junit.framework.Assert; - -import org.apache.commons.rdf.BlankNodeOrIri; -import org.apache.commons.rdf.RdfTerm; -import org.apache.commons.rdf.Triple; -import org.apache.commons.rdf.Iri; -import org.apache.clerezza.rdf.core.impl.PlainLiteralImpl; -import org.apache.clerezza.rdf.core.impl.TripleImpl; -/** - * - * @author reto - * - */ - -public class TripleImplTest { - - - @Test public void tripleEquality() { - BlankNodeOrIri subject = new Iri("http://example.org/"); - Iri predicate = new Iri("http://example.org/property"); - RdfTerm object = new PlainLiteralImpl("property value"); - Triple triple1 = new TripleImpl(subject, predicate, object); - Triple triple2 = new TripleImpl(subject, predicate, object); - Assert.assertEquals(triple1.hashCode(), triple2.hashCode()); - Assert.assertEquals(triple1, triple2); - } - -} http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/test/java/org/apache/clerezza/rdf/core/impl/TypedLiteralImplTest.java ---------------------------------------------------------------------- diff --git a/rdf.core/src/test/java/org/apache/clerezza/rdf/core/impl/TypedLiteralImplTest.java b/rdf.core/src/test/java/org/apache/clerezza/rdf/core/impl/TypedLiteralImplTest.java deleted file mode 100644 index 9a3dbed..0000000 --- a/rdf.core/src/test/java/org/apache/clerezza/rdf/core/impl/TypedLiteralImplTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.clerezza.rdf.core.impl; - -import org.junit.Test; -import junit.framework.Assert; - -import org.apache.commons.rdf.Iri; -import org.apache.commons.rdf.Literal; -/** - * - * @author reto/** - * - * @author reto/** - * - * @author reto/** - * - * @author reto - * - */ - -public class TypedLiteralImplTest { - - - @Test public void typedLiteralEquality() { - String stringValue = "some text"; - Iri uriRef = new Iri("http://example.org/datatypes/magic"); - Literal literal1 = new TypedLiteralImpl(stringValue, uriRef); - Literal literal2 = new TypedLiteralImpl(stringValue, uriRef); - Assert.assertEquals(literal1, literal2); - Assert.assertEquals(literal1.hashCode(), literal2.hashCode()); - Literal literal3 = new TypedLiteralImpl("something else", uriRef); - Assert.assertFalse(literal1.equals(literal3)); - Iri uriRef2 = new Iri("http://example.org/datatypes/other"); - Literal literal4 = new TypedLiteralImpl(stringValue, uriRef2); - Assert.assertFalse(literal1.equals(literal4)); - } - - - /** - * The hascode is equals to the hascode of the lexical form plus the hashcode of the dataTyp - */ - @Test public void checkHashCode() { - String stringValue = "some text"; - Iri uriRef = new Iri("http://example.org/datatypes/magic"); - Literal literal = new TypedLiteralImpl(stringValue, uriRef); - Assert.assertEquals(stringValue.hashCode() + uriRef.hashCode(), literal.hashCode()); - } - -} http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/test/java/org/apache/clerezza/rdf/core/impl/graphmatching/GraphMatcherTest.java ---------------------------------------------------------------------- diff --git a/rdf.core/src/test/java/org/apache/clerezza/rdf/core/impl/graphmatching/GraphMatcherTest.java b/rdf.core/src/test/java/org/apache/clerezza/rdf/core/impl/graphmatching/GraphMatcherTest.java deleted file mode 100644 index 5c7248d..0000000 --- a/rdf.core/src/test/java/org/apache/clerezza/rdf/core/impl/graphmatching/GraphMatcherTest.java +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.clerezza.rdf.core.impl.graphmatching; - -import java.util.Map; -import org.apache.commons.rdf.BlankNode; -import org.apache.commons.rdf.Graph; -import org.apache.commons.rdf.BlankNodeOrIri; -import org.apache.commons.rdf.RdfTerm; -import org.apache.commons.rdf.Triple; -import org.apache.commons.rdf.Graph; -import org.apache.commons.rdf.Iri; -import org.apache.clerezza.rdf.core.impl.SimpleMGraph; -import org.apache.clerezza.rdf.core.impl.TripleImpl; -import org.junit.Assert; -import org.junit.Test; - -/** - * - * @author reto - */ -public class GraphMatcherTest { - - final static Iri u1 = new Iri("http://example.org/u1"); - - @Test - public void testEmpty() { - Graph tc1 = new SimpleMGraph(); - Graph tc2 = new SimpleMGraph(); - final Map mapping = GraphMatcher.getValidMapping(tc1, tc2); - Assert.assertNotNull(mapping); - Assert.assertEquals(0, mapping.size()); - } - - @Test - public void test2() { - Graph tc1 = new SimpleMGraph(); - tc1.add(new TripleImpl(u1, u1, u1)); - Graph tc2 = new SimpleMGraph(); - final Map mapping = GraphMatcher.getValidMapping(tc1, tc2); - Assert.assertNull(mapping); - } - - @Test - public void test3() { - Graph tc1 = new SimpleMGraph(); - tc1.add(new TripleImpl(u1, u1, u1)); - Graph tc2 = new SimpleMGraph(); - tc2.add(new TripleImpl(u1, u1, u1)); - final Map mapping = GraphMatcher.getValidMapping(tc1, tc2); - Assert.assertNotNull(mapping); - Assert.assertEquals(0, mapping.size()); - } - - @Test - public void test4() { - Graph tc1 = new SimpleMGraph(); - tc1.add(new TripleImpl(u1, u1, new BlankNode())); - Graph tc2 = new SimpleMGraph(); - tc2.add(new TripleImpl(u1, u1, new BlankNode())); - final Map mapping = GraphMatcher.getValidMapping(tc1, tc2); - Assert.assertNotNull(mapping); - Assert.assertEquals(1, mapping.size()); - } - - @Test - public void test5() { - Graph tc1 = new SimpleMGraph(); - tc1.add(new TripleImpl(new BlankNode(), u1, new BlankNode())); - Graph tc2 = new SimpleMGraph(); - tc2.add(new TripleImpl(new BlankNode(), u1, new BlankNode())); - final Map mapping = GraphMatcher.getValidMapping(tc1, tc2); - Assert.assertNotNull(mapping); - Assert.assertEquals(2, mapping.size()); - } - - @Test - public void test6() { - Graph tc1 = new SimpleMGraph(); - final BlankNode b11 = new BlankNode(); - tc1.add(new TripleImpl(new BlankNode(), u1,b11)); - tc1.add(new TripleImpl(new BlankNode(), u1,b11)); - Graph tc2 = new SimpleMGraph(); - tc2.add(new TripleImpl(new BlankNode(), u1, new BlankNode())); - final Map mapping = GraphMatcher.getValidMapping(tc1, tc2); - Assert.assertNull(mapping); - } - - private Graph generateCircle(int size) { - return generateCircle(size, new BlankNode()); - } - - private Graph generateCircle(int size, final BlankNodeOrIri firstNode) { - if (size < 1) { - throw new IllegalArgumentException(); - } - Graph result = new SimpleMGraph(); - BlankNodeOrIri lastNode = firstNode; - for (int i = 0; i < (size-1); i++) { - final BlankNode newNode = new BlankNode(); - result.add(new TripleImpl(lastNode, u1, newNode)); - lastNode = newNode; - } - result.add(new TripleImpl(lastNode, u1, firstNode)); - return result; - } - - @Test - public void test7() { - Graph tc1 = generateCircle(2); - Graph tc2 = generateCircle(2); - final Map mapping = GraphMatcher.getValidMapping(tc1, tc2); - Assert.assertNotNull(mapping); - Assert.assertEquals(2, mapping.size()); - } - - @Test - public void test8() { - Graph tc1 = generateCircle(5); - Graph tc2 = generateCircle(5); - final Map mapping = GraphMatcher.getValidMapping(tc1, tc2); - Assert.assertNotNull(mapping); - Assert.assertEquals(5, mapping.size()); - } - - @Test - public void test9() { - BlankNodeOrIri crossing = new Iri("http://example.org/"); - Graph tc1 = generateCircle(2,crossing); - tc1.addAll(generateCircle(3,crossing)); - Graph tc2 = generateCircle(2,crossing); - tc2.addAll(generateCircle(3,crossing)); - Assert.assertEquals(5, tc1.size()); - final Map mapping = GraphMatcher.getValidMapping(tc1, tc2); - Assert.assertNotNull(mapping); - //a circle of 2 with 1 bnode and one of 2 bnodes - Assert.assertEquals(3, mapping.size()); - } - - @Test - public void test10() { - BlankNodeOrIri crossing1 = new BlankNode(); - Graph tc1 = generateCircle(2,crossing1); - tc1.addAll(generateCircle(3,crossing1)); - BlankNodeOrIri crossing2 = new BlankNode(); - Graph tc2 = generateCircle(2,crossing2); - tc2.addAll(generateCircle(3,crossing2)); - Assert.assertEquals(5, tc1.size()); - final Map mapping = GraphMatcher.getValidMapping(tc1, tc2); - Assert.assertNotNull(mapping); - //a circle of 2 and one of 3 with one common node - Assert.assertEquals(4, mapping.size()); - } - - @Test - public void test11() { - BlankNodeOrIri crossing1 = new BlankNode(); - Graph tc1 = generateCircle(2,crossing1); - tc1.addAll(generateCircle(4,crossing1)); - BlankNodeOrIri crossing2 = new BlankNode(); - Graph tc2 = generateCircle(3,crossing2); - tc2.addAll(generateCircle(3,crossing2)); - Assert.assertEquals(6, tc1.size()); - final Map mapping = GraphMatcher.getValidMapping(tc1, tc2); - Assert.assertNull(mapping); - } - - @Test - public void test12() { - BlankNodeOrIri start1 = new BlankNode(); - Graph tc1 = Utils4Testing.generateLine(4,start1); - tc1.addAll(Utils4Testing.generateLine(5,start1)); - BlankNodeOrIri start2 = new BlankNode(); - Graph tc2 = Utils4Testing.generateLine(5,start2); - tc2.addAll(Utils4Testing.generateLine(4,start2)); - Assert.assertEquals(9, tc1.size()); - final Map mapping = GraphMatcher.getValidMapping(tc1, tc2); - Assert.assertNotNull(mapping); - Assert.assertEquals(10, mapping.size()); - } - - @Test - public void test13() { - BlankNodeOrIri start1 = new BlankNode(); - Graph tc1 = Utils4Testing.generateLine(4,start1); - tc1.addAll(Utils4Testing.generateLine(5,start1)); - BlankNodeOrIri start2 = new BlankNode(); - Graph tc2 = Utils4Testing.generateLine(3,start2); - tc2.addAll(Utils4Testing.generateLine(3,start2)); - Assert.assertEquals(9, tc1.size()); - final Map mapping = GraphMatcher.getValidMapping(tc1, tc2); - Assert.assertNull(mapping); - } -} http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/test/java/org/apache/clerezza/rdf/core/impl/graphmatching/HashMatchingTest.java ---------------------------------------------------------------------- diff --git a/rdf.core/src/test/java/org/apache/clerezza/rdf/core/impl/graphmatching/HashMatchingTest.java b/rdf.core/src/test/java/org/apache/clerezza/rdf/core/impl/graphmatching/HashMatchingTest.java deleted file mode 100644 index 075d38b..0000000 --- a/rdf.core/src/test/java/org/apache/clerezza/rdf/core/impl/graphmatching/HashMatchingTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.clerezza.rdf.core.impl.graphmatching; - -import java.util.Map; - -import org.apache.commons.rdf.BlankNode; -import org.apache.commons.rdf.Graph; -import org.apache.commons.rdf.BlankNodeOrIri; -import org.junit.Assert; -import org.junit.Test; - -/** - * - * @author reto - */ -public class HashMatchingTest { - - @Test - public void twoLine() throws GraphNotIsomorphicException { - BlankNodeOrIri start1 = new BlankNode(); - Graph tc1 = Utils4Testing.generateLine(4,start1); - tc1.addAll(Utils4Testing.generateLine(5,start1)); - BlankNodeOrIri start2 = new BlankNode(); - Graph tc2 = Utils4Testing.generateLine(5,start2); - tc2.addAll(Utils4Testing.generateLine(4,start2)); - Assert.assertEquals(9, tc1.size()); - final Map mapping = new HashMatching(tc1, tc2).getMatchings(); - Assert.assertNotNull(mapping); - Assert.assertEquals(10, mapping.size()); - } - -} http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/test/java/org/apache/clerezza/rdf/core/impl/graphmatching/PermutationIteratorTest.java ---------------------------------------------------------------------- diff --git a/rdf.core/src/test/java/org/apache/clerezza/rdf/core/impl/graphmatching/PermutationIteratorTest.java b/rdf.core/src/test/java/org/apache/clerezza/rdf/core/impl/graphmatching/PermutationIteratorTest.java deleted file mode 100644 index db6cf71..0000000 --- a/rdf.core/src/test/java/org/apache/clerezza/rdf/core/impl/graphmatching/PermutationIteratorTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.clerezza.rdf.core.impl.graphmatching; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import org.junit.Assert; -import org.junit.Test; - -/** - * - * @author reto - */ -public class PermutationIteratorTest { - - @Test - public void simple() { - List list = new ArrayList(); - PermutationIterator pi = new PermutationIterator(list); - Assert.assertFalse(pi.hasNext()); - } - - @Test - public void lessSimple() { - List list = new ArrayList(); - list.add("Hasan"); - PermutationIterator pi = new PermutationIterator(list); - Assert.assertTrue(pi.hasNext()); - } - - @Test - public void regular() { - List list = new ArrayList(); - list.add("Hasan"); - list.add("Tsuy"); - PermutationIterator pi = new PermutationIterator(list); - Set> permutations = new HashSet>(); - while (pi.hasNext()) { - permutations.add(pi.next()); - } - Assert.assertEquals(2, permutations.size()); - } - - @Test - public void extended() { - List list = new ArrayList(); - list.add("Hasan"); - list.add("Tsuy"); - list.add("Llena"); - PermutationIterator pi = new PermutationIterator(list); - Set> permutations = new HashSet>(); - while (pi.hasNext()) { - permutations.add(pi.next()); - } - Assert.assertEquals(6, permutations.size()); - } - -} http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/test/java/org/apache/clerezza/rdf/core/impl/graphmatching/Utils4Testing.java ---------------------------------------------------------------------- diff --git a/rdf.core/src/test/java/org/apache/clerezza/rdf/core/impl/graphmatching/Utils4Testing.java b/rdf.core/src/test/java/org/apache/clerezza/rdf/core/impl/graphmatching/Utils4Testing.java deleted file mode 100644 index d5ef512..0000000 --- a/rdf.core/src/test/java/org/apache/clerezza/rdf/core/impl/graphmatching/Utils4Testing.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.clerezza.rdf.core.impl.graphmatching; - -import org.apache.commons.rdf.BlankNode; -import org.apache.commons.rdf.Graph; -import org.apache.commons.rdf.BlankNodeOrIri; -import org.apache.commons.rdf.Iri; -import org.apache.clerezza.rdf.core.impl.SimpleMGraph; -import org.apache.clerezza.rdf.core.impl.TripleImpl; - -/** - * - * @author reto - */ -public class Utils4Testing { - - static Graph generateLine(int size, final BlankNodeOrIri firstNode) { - if (size < 1) { - throw new IllegalArgumentException(); - } - Graph result = new SimpleMGraph(); - BlankNodeOrIri lastNode = firstNode; - for (int i = 0; i < size; i++) { - final BlankNode newNode = new BlankNode(); - result.add(new TripleImpl(lastNode, u1, newNode)); - lastNode = newNode; - } - return result; - } - - final static Iri u1 = new Iri("http://example.org/u1"); - -} http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/test/java/org/apache/clerezza/rdf/core/impl/util/SimpleLiteralFactoryTest.java ---------------------------------------------------------------------- diff --git a/rdf.core/src/test/java/org/apache/clerezza/rdf/core/impl/util/SimpleLiteralFactoryTest.java b/rdf.core/src/test/java/org/apache/clerezza/rdf/core/impl/util/SimpleLiteralFactoryTest.java new file mode 100644 index 0000000..886648b --- /dev/null +++ b/rdf.core/src/test/java/org/apache/clerezza/rdf/core/impl/util/SimpleLiteralFactoryTest.java @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.clerezza.rdf.core.impl.util; + +import junit.framework.Assert; +import org.apache.clerezza.rdf.core.impl.util.SimpleLiteralFactory; +import org.apache.commons.rdf.Literal; +import org.apache.commons.rdf.Iri; +import org.junit.Test; + +/** + * + * @author reto + */ +public class SimpleLiteralFactoryTest { + + final private static Iri xsdInteger = + new Iri("http://www.w3.org/2001/XMLSchema#integer"); + final private static Iri xsdInt = + new Iri("http://www.w3.org/2001/XMLSchema#int"); + final private static Iri xsdLong = + new Iri("http://www.w3.org/2001/XMLSchema#long"); + + SimpleLiteralFactory simpleLiteralFactory = new SimpleLiteralFactory(); + + @Test + public void longToXsdIntegerAndBackToMany() { + long value = 14l; + Literal tl = simpleLiteralFactory.createTypedLiteral(value); + Assert.assertEquals(xsdLong, tl.getDataType()); + long longValue = simpleLiteralFactory.createObject(Long.class, tl); + Assert.assertEquals(value, longValue); + int intValue = simpleLiteralFactory.createObject(Integer.class, tl); + Assert.assertEquals(value, intValue); + } + + @Test + public void intToXsdIntAndBackToMany() { + int value = 14; + Literal tl = simpleLiteralFactory.createTypedLiteral(value); + Assert.assertEquals(xsdInt, tl.getDataType()); + long longValue = simpleLiteralFactory.createObject(Long.class, tl); + Assert.assertEquals(value, longValue); + int intValue = simpleLiteralFactory.createObject(Integer.class, tl); + Assert.assertEquals(value, intValue); + } +} http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/test/java/org/apache/clerezza/rdf/core/sparql/QueryParserTest.java ---------------------------------------------------------------------- diff --git a/rdf.core/src/test/java/org/apache/clerezza/rdf/core/sparql/QueryParserTest.java b/rdf.core/src/test/java/org/apache/clerezza/rdf/core/sparql/QueryParserTest.java index 0c30926..a923f8a 100644 --- a/rdf.core/src/test/java/org/apache/clerezza/rdf/core/sparql/QueryParserTest.java +++ b/rdf.core/src/test/java/org/apache/clerezza/rdf/core/sparql/QueryParserTest.java @@ -25,7 +25,7 @@ import org.junit.Assert; import org.junit.Test; import org.apache.commons.rdf.Language; import org.apache.commons.rdf.Iri; -import org.apache.clerezza.rdf.core.impl.PlainLiteralImpl; +import org.apache.commons.rdf.impl.utils.PlainLiteralImpl; import org.apache.clerezza.rdf.core.sparql.query.AskQuery; import org.apache.clerezza.rdf.core.sparql.query.BasicGraphPattern; import org.apache.clerezza.rdf.core.sparql.query.BuiltInCall; http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/test/java/org/apache/clerezza/rdf/core/sparql/QuerySerializerTest.java ---------------------------------------------------------------------- diff --git a/rdf.core/src/test/java/org/apache/clerezza/rdf/core/sparql/QuerySerializerTest.java b/rdf.core/src/test/java/org/apache/clerezza/rdf/core/sparql/QuerySerializerTest.java index e536493..d088dc1 100644 --- a/rdf.core/src/test/java/org/apache/clerezza/rdf/core/sparql/QuerySerializerTest.java +++ b/rdf.core/src/test/java/org/apache/clerezza/rdf/core/sparql/QuerySerializerTest.java @@ -43,6 +43,7 @@ import org.apache.clerezza.rdf.core.sparql.query.impl.SimpleOrderCondition; import org.apache.clerezza.rdf.core.sparql.query.impl.SimpleSelectQuery; import org.apache.clerezza.rdf.core.sparql.query.impl.SimpleTriplePattern; import org.junit.Assert; +import org.junit.Ignore; import org.junit.Test; /** @@ -149,6 +150,11 @@ public class QuerySerializerTest { .replaceAll("( |\n)+", " ").trim().equals(queryString)); } + /** + * Ignoring: given that triplePatterns is a Set I don't see what is supposed + * to guarantee the expected ordering. + */ + @Ignore @Test public void testFilter() { http://git-wip-us.apache.org/repos/asf/clerezza/blob/e5531d96/rdf.core/src/test/java/org/apache/clerezza/rdf/core/sparql/SparqlPreParserTest.java ---------------------------------------------------------------------- diff --git a/rdf.core/src/test/java/org/apache/clerezza/rdf/core/sparql/SparqlPreParserTest.java b/rdf.core/src/test/java/org/apache/clerezza/rdf/core/sparql/SparqlPreParserTest.java index c03c2d0..490d296 100644 --- a/rdf.core/src/test/java/org/apache/clerezza/rdf/core/sparql/SparqlPreParserTest.java +++ b/rdf.core/src/test/java/org/apache/clerezza/rdf/core/sparql/SparqlPreParserTest.java @@ -31,9 +31,9 @@ import org.junit.Test; */ public class SparqlPreParserTest { - private final static Iri DEFAULT_GRAPH = new Iri("http://example.org/default.ImmutableGraph"); - private final static Iri NAMED_GRAPH = new Iri("http://example.org/dummy.ImmutableGraph"); - private final static Iri TEST_GRAPH = new Iri("http://example.org/test.ImmutableGraph"); + private final static Iri DEFAULT_GRAPH = new Iri("http://example.org/default.graph"); + private final static Iri NAMED_GRAPH = new Iri("http://example.org/dummy.graph"); + private final static Iri TEST_GRAPH = new Iri("http://example.org/test.graph"); class MyTcManager extends TcManager { @Override @@ -65,7 +65,7 @@ public class SparqlPreParserTest { public void testAllGraphReferenceInSelectQuery() throws ParseException { StringBuilder queryStrBuilder = new StringBuilder(); - queryStrBuilder.append("SELECT DISTINCT ?g { ImmutableGraph ?g { ?s ?p ?o } }\n"); + queryStrBuilder.append("SELECT DISTINCT ?g { GRAPH ?g { ?s ?p ?o } }\n"); SparqlPreParser parser; parser = new SparqlPreParser(TcManager.getInstance()); @@ -116,7 +116,7 @@ public class SparqlPreParserTest { @Test public void testLoadingToGraph() throws ParseException { - String queryStr = "LOAD SILENT INTO ImmutableGraph " + TEST_GRAPH.toString(); + String queryStr = "LOAD SILENT INTO GRAPH " + TEST_GRAPH.toString(); SparqlPreParser parser; parser = new SparqlPreParser(TcManager.getInstance()); @@ -149,7 +149,7 @@ public class SparqlPreParserTest { @Test public void testClearingGraph() throws ParseException { - String queryStr = "CLEAR SILENT ImmutableGraph " + TEST_GRAPH.toString(); + String queryStr = "CLEAR SILENT GRAPH " + TEST_GRAPH.toString(); SparqlPreParser parser; parser = new SparqlPreParser(TcManager.getInstance()); @@ -182,7 +182,7 @@ public class SparqlPreParserTest { @Test public void testDroppingGraph() throws ParseException { - String queryStr = "DROP SILENT ImmutableGraph " + TEST_GRAPH.toString(); + String queryStr = "DROP SILENT GRAPH " + TEST_GRAPH.toString(); SparqlPreParser parser; parser = new SparqlPreParser(TcManager.getInstance()); @@ -193,7 +193,7 @@ public class SparqlPreParserTest { @Test public void testCreatingGraph() throws ParseException { - String queryStr = "CREATE SILENT ImmutableGraph " + TEST_GRAPH.toString(); + String queryStr = "CREATE SILENT GRAPH " + TEST_GRAPH.toString(); SparqlPreParser parser; parser = new SparqlPreParser(TcManager.getInstance()); @@ -204,7 +204,7 @@ public class SparqlPreParserTest { @Test public void testAddingTriplesFromDefaultGraphToNamedGraph() throws ParseException { - String queryStr = "ADD SILENT DEFAULT TO ImmutableGraph " + TEST_GRAPH.toString(); + String queryStr = "ADD SILENT DEFAULT TO GRAPH " + TEST_GRAPH.toString(); SparqlPreParser parser; parser = new SparqlPreParser(TcManager.getInstance()); @@ -218,7 +218,7 @@ public class SparqlPreParserTest { @Test public void testAddingTriplesFromNamedGraphToDefaultGraph() throws ParseException { - String queryStr = "ADD SILENT ImmutableGraph " + TEST_GRAPH.toString() + " TO DEFAULT"; + String queryStr = "ADD SILENT GRAPH " + TEST_GRAPH.toString() + " TO DEFAULT"; SparqlPreParser parser; parser = new SparqlPreParser(TcManager.getInstance()); @@ -232,7 +232,7 @@ public class SparqlPreParserTest { @Test public void testMovingTriplesFromDefaultGraphToNamedGraph() throws ParseException { - String queryStr = "MOVE SILENT DEFAULT TO ImmutableGraph " + TEST_GRAPH.toString(); + String queryStr = "MOVE SILENT DEFAULT TO GRAPH " + TEST_GRAPH.toString(); SparqlPreParser parser; parser = new SparqlPreParser(TcManager.getInstance()); @@ -246,7 +246,7 @@ public class SparqlPreParserTest { @Test public void testMovingTriplesFromNamedGraphToDefaultGraph() throws ParseException { - String queryStr = "MOVE SILENT ImmutableGraph " + TEST_GRAPH.toString() + " TO DEFAULT"; + String queryStr = "MOVE SILENT GRAPH " + TEST_GRAPH.toString() + " TO DEFAULT"; SparqlPreParser parser; parser = new SparqlPreParser(TcManager.getInstance()); @@ -260,7 +260,7 @@ public class SparqlPreParserTest { @Test public void testCopyingTriplesFromDefaultGraphToNamedGraph() throws ParseException { - String queryStr = "COPY SILENT DEFAULT TO ImmutableGraph " + TEST_GRAPH.toString(); + String queryStr = "COPY SILENT DEFAULT TO GRAPH " + TEST_GRAPH.toString(); SparqlPreParser parser; parser = new SparqlPreParser(TcManager.getInstance()); @@ -274,7 +274,7 @@ public class SparqlPreParserTest { @Test public void testCopyingTriplesFromNamedGraphToDefaultGraph() throws ParseException { - String queryStr = "COPY SILENT ImmutableGraph " + TEST_GRAPH.toString() + " TO DEFAULT"; + String queryStr = "COPY SILENT GRAPH " + TEST_GRAPH.toString() + " TO DEFAULT"; SparqlPreParser parser; parser = new SparqlPreParser(TcManager.getInstance()); @@ -301,7 +301,7 @@ public class SparqlPreParserTest { public void testInsertDataToNamedGraph() throws ParseException { String queryStr = "PREFIX ns: \n" + - "INSERT DATA { ImmutableGraph " + TEST_GRAPH.toString() + " { ns:price 42 } }"; + "INSERT DATA { GRAPH " + TEST_GRAPH.toString() + " { ns:price 42 } }"; SparqlPreParser parser; parser = new SparqlPreParser(TcManager.getInstance()); Set referredGraphs = parser.getReferredGraphs(queryStr, DEFAULT_GRAPH); @@ -324,7 +324,7 @@ public class SparqlPreParserTest { public void testDeleteDataInNamedGraph() throws ParseException { String queryStr = "PREFIX ns: \n" + - "DELETE DATA { ImmutableGraph " + TEST_GRAPH.toString() + " { ns:price 42 } }"; + "DELETE DATA { GRAPH " + TEST_GRAPH.toString() + " { ns:price 42 } }"; SparqlPreParser parser; parser = new SparqlPreParser(TcManager.getInstance()); Set referredGraphs = parser.getReferredGraphs(queryStr, DEFAULT_GRAPH); @@ -336,7 +336,7 @@ public class SparqlPreParserTest { String queryStr = "PREFIX ns: " + "INSERT DATA { ns:price 42 }; " + - "DELETE DATA { ImmutableGraph " + TEST_GRAPH.toString() + " { ns:price 42 } }"; + "DELETE DATA { GRAPH " + TEST_GRAPH.toString() + " { ns:price 42 } }"; SparqlPreParser parser; parser = new SparqlPreParser(TcManager.getInstance()); Set referredGraphs = parser.getReferredGraphs(queryStr, DEFAULT_GRAPH); @@ -364,8 +364,8 @@ public class SparqlPreParserTest { public void testDeleteWhereInNamedGraphs() throws ParseException { String queryStr = "PREFIX foaf: DELETE WHERE " + - "{ ImmutableGraph { ?person foaf:givenName 'Fred' ; ?property1 ?value1 } " + - " ImmutableGraph { ?person ?property2 ?value2 } }"; + "{ GRAPH { ?person foaf:givenName 'Fred' ; ?property1 ?value1 } " + + " GRAPH { ?person ?property2 ?value2 } }"; SparqlPreParser parser; parser = new SparqlPreParser(TcManager.getInstance()); @@ -404,8 +404,8 @@ public class SparqlPreParserTest { @Test public void testInsertOperationToNamedGraph() throws ParseException { String queryStr = "PREFIX dc: PREFIX xsd: " + - "INSERT { ImmutableGraph { ?book ?p ?v } } " + - "WHERE { ImmutableGraph { ?book dc:date ?date . " + + "INSERT { GRAPH { ?book ?p ?v } } " + + "WHERE { GRAPH { ?book dc:date ?date . " + "FILTER ( ?date > \"1970-01-01T00:00:00-02:00\"^^xsd:dateTime ) ?book ?p ?v } }"; SparqlPreParser parser; @@ -424,9 +424,9 @@ public class SparqlPreParserTest { "PREFIX dcmitype: \n" + "PREFIX xsd: \n\n" + "INSERT\n" + - " { ImmutableGraph { ?book ?p ?v } }\n" + + " { GRAPH { ?book ?p ?v } }\n" + "WHERE\n" + - " { ImmutableGraph \n" + + " { GRAPH \n" + " { ?book dc:date ?date . \n" + " FILTER ( ?date < \"2000-01-01T00:00:00-02:00\"^^xsd:dateTime )\n" + " ?book ?p ?v\n" +