You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by wi...@apache.org on 2013/09/10 14:44:38 UTC

[1/3] git commit: MARMOTTA-155: added unit test to reproduce the issue

Updated Branches:
  refs/heads/develop 1a3a45ccc -> 09f96df99


MARMOTTA-155: added unit test to reproduce the issue


Project: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/commit/be890b69
Tree: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/tree/be890b69
Diff: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/diff/be890b69

Branch: refs/heads/develop
Commit: be890b698d8fa063b1c0ca7b06581a8e5564b233
Parents: 69cc8f3
Author: Sergio Fernández <wi...@apache.org>
Authored: Tue Sep 10 14:42:32 2013 +0200
Committer: Sergio Fernández <wi...@apache.org>
Committed: Tue Sep 10 14:42:32 2013 +0200

----------------------------------------------------------------------
 .../kiwi/test/sesame/KiWiLocaleTest.java        | 101 +++++++++++++++++++
 1 file changed, 101 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/be890b69/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/sesame/KiWiLocaleTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/sesame/KiWiLocaleTest.java b/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/sesame/KiWiLocaleTest.java
new file mode 100644
index 0000000..5c97e59
--- /dev/null
+++ b/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/sesame/KiWiLocaleTest.java
@@ -0,0 +1,101 @@
+/*
+ * 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.marmotta.kiwi.test.sesame;
+
+import org.apache.marmotta.kiwi.config.KiWiConfiguration;
+import org.apache.marmotta.kiwi.sail.KiWiStore;
+import org.apache.marmotta.kiwi.sail.KiWiValueFactory;
+import org.apache.marmotta.kiwi.test.junit.KiWiDatabaseRunner;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.openrdf.model.Literal;
+import org.openrdf.sail.SailConnection;
+import org.openrdf.sail.SailException;
+
+/**
+ * Tests for testing locales against the KiWi Triple store 
+ * (and its implementation of the ValueFactory)
+ * 
+ * @author Sergio Fernández <wi...@apache.org>
+ */
+@RunWith(KiWiDatabaseRunner.class)
+public class KiWiLocaleTest  {
+
+    private final KiWiConfiguration kiwiConfig;
+    private KiWiStore store;
+    private KiWiValueFactory vf;
+    
+    public KiWiLocaleTest(KiWiConfiguration kiwiConfig) {
+        this.kiwiConfig = kiwiConfig;
+    }
+    
+    @Before
+    public void initialize() throws SailException {
+    	store = new KiWiStore(kiwiConfig);
+    	store.initialize();
+    	vf = new KiWiValueFactory(store, "http://example.org");
+    }
+    
+    @After
+    public void shutdown() throws SailException {
+    	store.shutDown();
+    	store = null;
+    	vf = null;
+    }
+    
+    /** 
+     * Tests creating BCP47 literals (see MARMOTTA-115 for further details)
+     */
+    @Test
+    public void createBCP47LiteralsTests() {
+    	Literal enLiteral = vf.createLiteral("Hungary", "en");
+    	Assert.assertEquals("Hungary", enLiteral.getLabel());
+    	Assert.assertEquals("en", enLiteral.getLanguage());
+    	Literal warLiteral = vf.createLiteral("Hungary", "war");
+    	Assert.assertEquals("Hungary", warLiteral.getLabel());
+    	Assert.assertEquals("war", warLiteral.getLanguage());
+    }
+
+//    /** 
+//     * Tests adding BCP47 literals (see MARMOTTA-115 for further details)
+//     */
+//    @Test
+//    public void addBCP47LiteralsTests() throws SailException {
+//    	SailConnection conn = store.getConnection();
+//        try {
+//        	conn.begin();
+//            conn.commit();
+//        } finally {
+//            conn.close();
+//        }
+//    	
+//    }
+//    
+//    /** 
+//     * Tests importing BCP47 literals (see MARMOTTA-115 for further details)
+//     */
+//    @Test
+//    public void importBCP47LiteralsTests() throws SailException {
+//    	SailConnection connection = store.getConnection();
+//    	
+//    }
+
+}


[3/3] git commit: Merge branch 'develop' of https://git-wip-us.apache.org/repos/asf/incubator-marmotta into develop

Posted by wi...@apache.org.
Merge branch 'develop' of https://git-wip-us.apache.org/repos/asf/incubator-marmotta into develop


Project: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/commit/09f96df9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/tree/09f96df9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/diff/09f96df9

Branch: refs/heads/develop
Commit: 09f96df997dad836a36b986297a7fbdcd7b50469
Parents: d467cec 1a3a45c
Author: Sergio Fernández <wi...@apache.org>
Authored: Tue Sep 10 14:44:25 2013 +0200
Committer: Sergio Fernández <wi...@apache.org>
Committed: Tue Sep 10 14:44:25 2013 +0200

----------------------------------------------------------------------
 .../sesame/repository/ResourceUtils.java        | 28 ++++---
 .../sesame/facading/impl/FacadingImpl.java      | 12 ++-
 .../concurrent/ConcurrentFacadingTest.java      |  5 +-
 .../kiwi/persistence/KiWiConnection.java        |  4 +-
 .../ldpath/api/functions/NodeFunction.java      |  2 +-
 .../marmotta/ldpath/api/tests/NodeTest.java     |  1 +
 .../api/transformers/NodeTransformer.java       |  5 +-
 .../ldpath/backend/file/ParserTest.java         |  6 +-
 .../java/org/apache/marmotta/ldpath/LDPath.java | 12 +--
 .../ldpath/model/fields/FieldMapping.java       | 23 ++++--
 .../model/functions/ConcatenateFunction.java    |  3 +-
 .../ldpath/model/functions/CountFunction.java   |  3 +-
 .../ldpath/model/functions/FirstFunction.java   |  5 +-
 .../ldpath/model/functions/LastFunction.java    |  5 +-
 .../ldpath/model/functions/SortFunction.java    |  3 +-
 .../marmotta/ldpath/model/programs/Program.java | 53 +++++++++-----
 .../ldpath/model/tests/LiteralTypeTest.java     | 15 +++-
 .../tests/functions/BinaryNumericTest.java      |  1 +
 .../marmotta/ldpath/util/Collections.java       |  3 +
 .../at/newmedialab/ldpath/parser/rdfpath.jj     | 77 +++++++++++---------
 .../BinaryNumericTestFunctionsTest.java         |  4 +-
 .../ldpath/model/functions/FunctionsTest.java   | 16 ++--
 .../marmotta/ldpath/parser/ParserTest.java      | 10 +--
 .../marmotta/ldpath/parser/ProgramTest.java     | 61 ++++++++++++++++
 .../marmotta/ldpath/parser/SelectorsTest.java   |  2 +-
 .../marmotta/ldpath/parser/TestsTest.java       |  2 +-
 .../marmotta/ldpath/test/AbstractTestBase.java  | 14 ++--
 .../ldpath-core/src/test/resources/logback.xml  |  2 +
 .../src/test/resources/parse/program.ldpath     | 20 +++--
 .../model/functions/date/DateFunctionsTest.java |  6 +-
 .../model/functions/html/HtmlFunctionsTest.java |  8 +-
 .../model/functions/math/MathFunctionTest.java  | 30 ++++----
 .../tests/functions/text/StringTestTest.java    |  4 +-
 .../xml/RemoveXmlTagsFunctionTest.java          |  4 +-
 .../model/functions/xml/XPathFunctionTest.java  |  4 +-
 .../resource/InspectionWebService.java          |  2 +-
 .../resources/web/public/html/reasoning.html    |  2 +-
 37 files changed, 295 insertions(+), 162 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/09f96df9/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiConnection.java
----------------------------------------------------------------------


[2/3] git commit: MARMOTTA-155: fixed issue with 3-char locales (LocaleUtils.toLocale() does not handle them properly)

Posted by wi...@apache.org.
MARMOTTA-155: fixed issue with 3-char locales (LocaleUtils.toLocale() does not handle them properly)


Project: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/commit/d467cec7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/tree/d467cec7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/diff/d467cec7

Branch: refs/heads/develop
Commit: d467cec7e5dbabf37a9f4f9f3b2f71979e1b4726
Parents: be890b6
Author: Sergio Fernández <wi...@apache.org>
Authored: Tue Sep 10 14:44:16 2013 +0200
Committer: Sergio Fernández <wi...@apache.org>
Committed: Tue Sep 10 14:44:16 2013 +0200

----------------------------------------------------------------------
 .../apache/marmotta/kiwi/model/rdf/KiWiLiteral.java  | 15 ++++++---------
 .../marmotta/kiwi/persistence/KiWiConnection.java    |  9 ++++++---
 .../apache/marmotta/kiwi/sail/KiWiValueFactory.java  | 10 +++++-----
 3 files changed, 17 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/d467cec7/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/model/rdf/KiWiLiteral.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/model/rdf/KiWiLiteral.java b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/model/rdf/KiWiLiteral.java
index 9526081..e96220e 100644
--- a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/model/rdf/KiWiLiteral.java
+++ b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/model/rdf/KiWiLiteral.java
@@ -17,20 +17,17 @@
  */
 package org.apache.marmotta.kiwi.model.rdf;
 
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Locale;
+
+import javax.xml.datatype.XMLGregorianCalendar;
+
 import org.apache.marmotta.commons.sesame.model.Namespaces;
-import com.google.common.hash.HashCode;
-import com.google.common.hash.HashFunction;
-import com.google.common.hash.Hasher;
-import com.google.common.hash.Hashing;
 import org.openrdf.model.Literal;
 import org.openrdf.model.URI;
 import org.openrdf.model.datatypes.XMLDatatypeUtil;
 
-import javax.xml.datatype.XMLGregorianCalendar;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.util.Locale;
-
 /**
  * KiWiLiterals store literal information from the knowledge base. They directly
  * correspond to an RDF literal stored in Sesame. KiWiLiterals are

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/d467cec7/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiConnection.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiConnection.java b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiConnection.java
index 3467525..cbba4e2 100644
--- a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiConnection.java
+++ b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiConnection.java
@@ -18,12 +18,16 @@
 package org.apache.marmotta.kiwi.persistence;
 
 import info.aduna.iteration.*;
+
 import org.apache.marmotta.commons.sesame.model.LiteralCommons;
 import org.apache.marmotta.commons.sesame.model.Namespaces;
 import org.apache.marmotta.commons.util.DateUtils;
+
 import com.google.common.base.Preconditions;
+
 import net.sf.ehcache.Cache;
 import net.sf.ehcache.Element;
+
 import org.apache.commons.lang3.LocaleUtils;
 import org.apache.marmotta.kiwi.caching.KiWiCacheManager;
 import org.apache.marmotta.kiwi.config.KiWiConfiguration;
@@ -1707,9 +1711,8 @@ public class KiWiConnection {
     protected static Locale getLocale(String language) {
         Locale locale = localeMap.get(language);
         if(locale == null && language != null) {
-            locale = LocaleUtils.toLocale(language.replace("-","_"));
-            localeMap.put(language,locale);
-
+            locale = Locale.forLanguageTag(language);
+            localeMap.put(language, locale);
         }
         return locale;
     }

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/d467cec7/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/sail/KiWiValueFactory.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/sail/KiWiValueFactory.java b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/sail/KiWiValueFactory.java
index 0074ede..78f630e 100644
--- a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/sail/KiWiValueFactory.java
+++ b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/sail/KiWiValueFactory.java
@@ -49,7 +49,6 @@ public class KiWiValueFactory implements ValueFactory {
 
     private Random anonIdGenerator;
 
-
     /**
      * This is a hash map for storing references to resources that have not yet been persisted. It is used e.g. when
      * one or more transactions are currently active and request the creation of same resource several times
@@ -393,14 +392,15 @@ public class KiWiValueFactory implements ValueFactory {
         Locale locale;
         if(lang != null) {
             try {
-                locale = LocaleUtils.toLocale(lang.replace("-","_"));
+                locale = Locale.forLanguageTag(lang);
             } catch (IllegalArgumentException ex) {
                 log.warn("malformed language literal (language: {})", lang);
                 locale = null;
-                lang   = null;
+                lang = null;
             }
-        } else
-            locale  = null;
+        } else {
+            locale = null;
+        }
 
         if (lang != null) {
             // FIXME: MARMOTTA-39 (no rdf:langString)