You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by rw...@apache.org on 2012/12/01 12:46:35 UTC

svn commit: r1415982 [2/2] - in /stanbol/trunk/commons/namespaceprefix: ./ service/ service/src/ service/src/main/ service/src/main/java/ service/src/main/java/org/ service/src/main/java/org/apache/ service/src/main/java/org/apache/stanbol/ service/src...

Added: stanbol/trunk/commons/namespaceprefix/stanbolprovider/src/test/java/org/apache/stanbol/commons/namespaceprefix/provider/stanbol/DefaultProviderTest.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/namespaceprefix/stanbolprovider/src/test/java/org/apache/stanbol/commons/namespaceprefix/provider/stanbol/DefaultProviderTest.java?rev=1415982&view=auto
==============================================================================
--- stanbol/trunk/commons/namespaceprefix/stanbolprovider/src/test/java/org/apache/stanbol/commons/namespaceprefix/provider/stanbol/DefaultProviderTest.java (added)
+++ stanbol/trunk/commons/namespaceprefix/stanbolprovider/src/test/java/org/apache/stanbol/commons/namespaceprefix/provider/stanbol/DefaultProviderTest.java Sat Dec  1 11:46:32 2012
@@ -0,0 +1,49 @@
+package org.apache.stanbol.commons.namespaceprefix.provider.stanbol;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+import org.apache.stanbol.commons.namespaceprefix.NamespacePrefixService;
+import org.apache.stanbol.commons.namespaceprefix.mappings.DefaultNamespaceMappingsEnum;
+import org.apache.stanbol.commons.namespaceprefix.service.StanbolNamespacePrefixService;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class DefaultProviderTest {
+
+    private static NamespacePrefixService service;
+
+    @BeforeClass
+    public static void init() throws IOException {
+        //this test for now does not use predefined mappings
+        URL mappingURL = DefaultProviderTest.class.getClassLoader()
+                .getResource("testnamespaceprefix.mappings");
+        //Assert.assertNotNull(mappingURL);
+        File mappingFile;
+        if(mappingURL != null){
+            try {
+              mappingFile = new File(mappingURL.toURI());
+            } catch(URISyntaxException e) {
+              mappingFile = new File(mappingURL.getPath());
+            }
+            //Assert.assertTrue(mappingFile.isFile());
+        } else {
+            mappingFile = new File("testnamespaceprefix.mappings");
+        }
+        service = new StanbolNamespacePrefixService(mappingFile);
+    }
+
+    @Test
+    public void testDefaultMappings(){
+        //this tests both the implementation of the getNamespace and getPrefix mappings
+        //and that the defaultNamespaceMappingProvider is correctly loaded by the ServiceLoader 
+        for(DefaultNamespaceMappingsEnum defaultMapping : DefaultNamespaceMappingsEnum.values()){
+            Assert.assertEquals(defaultMapping.getNamespace(), 
+                service.getNamespace(defaultMapping.getPrefix()));
+            Assert.assertTrue(service.getPrefixes(defaultMapping.getNamespace()).contains(defaultMapping.getPrefix()));
+        }
+    }
+}

Added: stanbol/trunk/commons/namespaceprefix/stanbolprovider/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/namespaceprefix/stanbolprovider/src/test/resources/log4j.properties?rev=1415982&view=auto
==============================================================================
--- stanbol/trunk/commons/namespaceprefix/stanbolprovider/src/test/resources/log4j.properties (added)
+++ stanbol/trunk/commons/namespaceprefix/stanbolprovider/src/test/resources/log4j.properties Sat Dec  1 11:46:32 2012
@@ -0,0 +1,24 @@
+# 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.
+
+# Root logger option
+log4j.rootLogger=INFO, stdout
+ 
+# Direct log messages to stdout
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
+log4j.logger.org.apache.stanbol.enhancer.engines.keywordextraction=DEBUG
\ No newline at end of file