You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by os...@apache.org on 2016/05/16 09:00:12 UTC

jena git commit: reorganize jena-text unit tests: separate AbstractTestDatasetWithAnalyzer from TestDatasetWithKeywordAnalyzer

Repository: jena
Updated Branches:
  refs/heads/master f223f3324 -> 8a20f238f


reorganize jena-text unit tests: separate AbstractTestDatasetWithAnalyzer from TestDatasetWithKeywordAnalyzer


Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/8a20f238
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/8a20f238
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/8a20f238

Branch: refs/heads/master
Commit: 8a20f238ffc5aed23648b038132fe74cbca2c85c
Parents: f223f33
Author: Osma Suominen <os...@apache.org>
Authored: Mon May 16 11:59:15 2016 +0300
Committer: Osma Suominen <os...@apache.org>
Committed: Mon May 16 11:59:15 2016 +0300

----------------------------------------------------------------------
 .../text/AbstractTestDatasetWithAnalyzer.java   | 111 +++++++++++++++++++
 .../text/TestDatasetWithKeywordAnalyzer.java    |  81 +-------------
 2 files changed, 112 insertions(+), 80 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/8a20f238/jena-text/src/test/java/org/apache/jena/query/text/AbstractTestDatasetWithAnalyzer.java
----------------------------------------------------------------------
diff --git a/jena-text/src/test/java/org/apache/jena/query/text/AbstractTestDatasetWithAnalyzer.java b/jena-text/src/test/java/org/apache/jena/query/text/AbstractTestDatasetWithAnalyzer.java
new file mode 100644
index 0000000..458d8c0
--- /dev/null
+++ b/jena-text/src/test/java/org/apache/jena/query/text/AbstractTestDatasetWithAnalyzer.java
@@ -0,0 +1,111 @@
+/**
+ * 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.jena.query.text;
+
+import java.io.Reader ;
+import java.io.StringReader ;
+
+import org.apache.jena.assembler.Assembler ;
+import org.apache.jena.atlas.lib.StrUtils ;
+import org.apache.jena.query.Dataset ;
+import org.apache.jena.query.text.assembler.TextAssembler ;
+import org.apache.jena.rdf.model.Model ;
+import org.apache.jena.rdf.model.ModelFactory ;
+import org.apache.jena.rdf.model.Resource ;
+import org.junit.After ;
+import org.junit.Before ;
+
+/**
+ * This abstract class defines a setup configuration for a dataset that uses a specific analyzer with a Lucene index.
+ */
+public abstract class AbstractTestDatasetWithAnalyzer extends AbstractTestDatasetWithTextIndexBase {
+
+    private static final String SPEC_BASE = "http://example.org/spec#";
+    private static final String SPEC_ROOT_LOCAL = "lucene_text_dataset";
+    private static final String SPEC_ROOT_URI = SPEC_BASE + SPEC_ROOT_LOCAL;
+
+    private static String makeSpec(String analyzer, String parser) {
+        return StrUtils.strjoinNL(
+                    "prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> ",
+                    "prefix ja:   <http://jena.hpl.hp.com/2005/11/Assembler#> ",
+                    "prefix tdb:  <http://jena.hpl.hp.com/2008/tdb#>",
+                    "prefix text: <http://jena.apache.org/text#>",
+                    "prefix :     <" + SPEC_BASE + ">",
+                    "",
+                    "[] ja:loadClass    \"org.apache.jena.query.text.TextQuery\" .",
+                    "text:TextDataset      rdfs:subClassOf   ja:RDFDataset .",
+                    "text:TextIndexLucene  rdfs:subClassOf   text:TextIndex .",
+                    
+                    ":" + SPEC_ROOT_LOCAL,
+                    "    a              text:TextDataset ;",
+                    "    text:dataset   :dataset ;",
+                    "    text:index     :indexLucene ;",
+                    "    .",
+                    "",
+                    ":dataset",
+                    "    a               ja:RDFDataset ;",
+                    "    ja:defaultGraph :graph ;",
+                    ".",
+                    ":graph",
+                    "    a               ja:MemoryModel ;",
+                    ".",
+                    "",
+                    ":indexLucene",
+                    "    a text:TextIndexLucene ;",
+                    "    text:directory \"mem\" ;",
+                    "    text:queryParser " + parser + ";",
+                    "    text:entityMap :entMap ;",
+                    "    .",
+                    "",
+                    ":entMap",
+                    "    a text:EntityMap ;",
+                    "    text:entityField      \"uri\" ;",
+                    "    text:defaultField     \"label\" ;",
+                    "    text:map (",
+                    "         [ text:field \"label\" ; ",
+                    "           text:predicate rdfs:label ;",
+                    "           text:analyzer [ a " + analyzer + " ]",
+                    "         ]",
+                    "         [ text:field \"comment\" ; text:predicate rdfs:comment ]",
+                    "         ) ."
+                    );
+    }      
+    
+    public void init(String analyzer, String parser) {
+        Reader reader = new StringReader(makeSpec(analyzer, parser));
+        Model specModel = ModelFactory.createDefaultModel();
+        specModel.read(reader, "", "TURTLE");
+        TextAssembler.init();            
+        Resource root = specModel.getResource(SPEC_ROOT_URI);
+        dataset = (Dataset) Assembler.general.open(root);
+    }
+    
+    public void init(String analyzer) {
+        init(analyzer, "text:QueryParser");
+    }   
+    
+    @Before
+    abstract public void before();
+    
+    @After
+    public void after() {
+        dataset.close();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/8a20f238/jena-text/src/test/java/org/apache/jena/query/text/TestDatasetWithKeywordAnalyzer.java
----------------------------------------------------------------------
diff --git a/jena-text/src/test/java/org/apache/jena/query/text/TestDatasetWithKeywordAnalyzer.java b/jena-text/src/test/java/org/apache/jena/query/text/TestDatasetWithKeywordAnalyzer.java
index 375c7e0..3d90df2 100644
--- a/jena-text/src/test/java/org/apache/jena/query/text/TestDatasetWithKeywordAnalyzer.java
+++ b/jena-text/src/test/java/org/apache/jena/query/text/TestDatasetWithKeywordAnalyzer.java
@@ -18,102 +18,23 @@
 
 package org.apache.jena.query.text;
 
-import java.io.Reader ;
-import java.io.StringReader ;
 import java.util.Arrays ;
 import java.util.HashSet ;
 import java.util.Set ;
 
-import org.apache.jena.assembler.Assembler ;
 import org.apache.jena.atlas.lib.StrUtils ;
-import org.apache.jena.query.Dataset ;
-import org.apache.jena.query.text.assembler.TextAssembler ;
-import org.apache.jena.rdf.model.Model ;
-import org.apache.jena.rdf.model.ModelFactory ;
-import org.apache.jena.rdf.model.Resource ;
-import org.junit.After ;
 import org.junit.Before ;
 import org.junit.Test ;
 
 /**
  * This class defines a setup configuration for a dataset that uses a keyword analyzer with a Lucene index.
  */
-public class TestDatasetWithKeywordAnalyzer extends AbstractTestDatasetWithTextIndexBase {
-    
-    private static final String SPEC_BASE = "http://example.org/spec#";
-    private static final String SPEC_ROOT_LOCAL = "lucene_text_dataset";
-    private static final String SPEC_ROOT_URI = SPEC_BASE + SPEC_ROOT_LOCAL;
-
-    private static String makeSpec(String analyzer, String parser) {
-        return StrUtils.strjoinNL(
-                    "prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> ",
-                    "prefix ja:   <http://jena.hpl.hp.com/2005/11/Assembler#> ",
-                    "prefix tdb:  <http://jena.hpl.hp.com/2008/tdb#>",
-                    "prefix text: <http://jena.apache.org/text#>",
-                    "prefix :     <" + SPEC_BASE + ">",
-                    "",
-                    "[] ja:loadClass    \"org.apache.jena.query.text.TextQuery\" .",
-                    "text:TextDataset      rdfs:subClassOf   ja:RDFDataset .",
-                    "text:TextIndexLucene  rdfs:subClassOf   text:TextIndex .",
-                    
-                    ":" + SPEC_ROOT_LOCAL,
-                    "    a              text:TextDataset ;",
-                    "    text:dataset   :dataset ;",
-                    "    text:index     :indexLucene ;",
-                    "    .",
-                    "",
-                    ":dataset",
-                    "    a               ja:RDFDataset ;",
-                    "    ja:defaultGraph :graph ;",
-                    ".",
-                    ":graph",
-                    "    a               ja:MemoryModel ;",
-                    ".",
-                    "",
-                    ":indexLucene",
-                    "    a text:TextIndexLucene ;",
-                    "    text:directory \"mem\" ;",
-                    "    text:queryParser " + parser + ";",
-                    "    text:entityMap :entMap ;",
-                    "    .",
-                    "",
-                    ":entMap",
-                    "    a text:EntityMap ;",
-                    "    text:entityField      \"uri\" ;",
-                    "    text:defaultField     \"label\" ;",
-                    "    text:map (",
-                    "         [ text:field \"label\" ; ",
-                    "           text:predicate rdfs:label ;",
-                    "           text:analyzer [ a " + analyzer + " ]",
-                    "         ]",
-                    "         [ text:field \"comment\" ; text:predicate rdfs:comment ]",
-                    "         ) ."
-                    );
-    }      
-    
-    public void init(String analyzer, String parser) {
-        Reader reader = new StringReader(makeSpec(analyzer, parser));
-        Model specModel = ModelFactory.createDefaultModel();
-        specModel.read(reader, "", "TURTLE");
-        TextAssembler.init();            
-        Resource root = specModel.getResource(SPEC_ROOT_URI);
-        dataset = (Dataset) Assembler.general.open(root);
-    }
-    
-    public void init(String analyzer) {
-        init(analyzer, "text:QueryParser");
-    }   
-    
+public class TestDatasetWithKeywordAnalyzer extends AbstractTestDatasetWithAnalyzer {
     @Before
     public void before() {
         init("text:KeywordAnalyzer");
     }
     
-    @After
-    public void after() {
-        dataset.close();
-    }
-    
     @Test
     public void testKeywordAnalyzerDoesNotSplitTokensAtSpace() {
         final String testName = "testKeywordAnalyzerDoesNotSplitTokensAtSpace";