lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cpoersc...@apache.org
Subject lucene-solr:branch_6x: SOLR-10077: merge TestFeatureStore and TestFeatureLtrScoringModel into TestManagedFeatureStore.
Date Mon, 06 Feb 2017 16:55:33 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/branch_6x be87c9b89 -> a22681c85


SOLR-10077: merge TestFeatureStore and TestFeatureLtrScoringModel into TestManagedFeatureStore.


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/a22681c8
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/a22681c8
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/a22681c8

Branch: refs/heads/branch_6x
Commit: a22681c8594cd9b97bc6d013acb0bdf61835d2a0
Parents: be87c9b
Author: Christine Poerschke <cpoerschke@apache.org>
Authored: Mon Feb 6 17:26:56 2017 +0100
Committer: Christine Poerschke <cpoerschke@apache.org>
Committed: Mon Feb 6 17:42:29 2017 +0100

----------------------------------------------------------------------
 .../ltr/feature/TestFeatureLtrScoringModel.java |  71 -----------
 .../solr/ltr/feature/TestFeatureStore.java      | 106 -----------------
 .../ltr/store/rest/TestManagedFeatureStore.java | 119 ++++++++++++++++++-
 3 files changed, 116 insertions(+), 180 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/a22681c8/solr/contrib/ltr/src/test/org/apache/solr/ltr/feature/TestFeatureLtrScoringModel.java
----------------------------------------------------------------------
diff --git a/solr/contrib/ltr/src/test/org/apache/solr/ltr/feature/TestFeatureLtrScoringModel.java
b/solr/contrib/ltr/src/test/org/apache/solr/ltr/feature/TestFeatureLtrScoringModel.java
deleted file mode 100644
index a50e75e..0000000
--- a/solr/contrib/ltr/src/test/org/apache/solr/ltr/feature/TestFeatureLtrScoringModel.java
+++ /dev/null
@@ -1,71 +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.solr.ltr.feature;
-
-import org.apache.solr.ltr.TestRerankBase;
-import org.apache.solr.ltr.store.rest.ManagedFeatureStore;
-import org.apache.solr.ltr.store.rest.TestManagedFeatureStore;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class TestFeatureLtrScoringModel extends TestRerankBase {
-
-  static ManagedFeatureStore store = null;
-
-  @BeforeClass
-  public static void setup() throws Exception {
-    setuptest(true);
-    store = getManagedFeatureStore();
-  }
-
-  @AfterClass
-  public static void after() throws Exception {
-    aftertest();
-  }
-
-  @Test
-  public void getInstanceTest() throws FeatureException
-  {
-    store.addFeature(TestManagedFeatureStore.createMap("test",
-        OriginalScoreFeature.class.getCanonicalName(), null),
-        "testFstore");
-    final Feature feature = store.getFeatureStore("testFstore").get("test");
-    assertNotNull(feature);
-    assertEquals("test", feature.getName());
-    assertEquals(OriginalScoreFeature.class.getCanonicalName(), feature
-        .getClass().getCanonicalName());
-  }
-
-  @Test
-  public void getInvalidInstanceTest()
-  {
-    final String nonExistingClassName = "org.apache.solr.ltr.feature.LOLFeature";
-    final ClassNotFoundException expectedException =
-        new ClassNotFoundException(nonExistingClassName);
-    try {
-      store.addFeature(TestManagedFeatureStore.createMap("test",
-          nonExistingClassName, null),
-          "testFstore2");
-      fail("getInvalidInstanceTest failed to throw exception: "+expectedException);
-    } catch (Exception actualException) {
-      Throwable rootError = getRootCause(actualException);
-      assertEquals(expectedException.toString(), rootError.toString());
-    }
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/a22681c8/solr/contrib/ltr/src/test/org/apache/solr/ltr/feature/TestFeatureStore.java
----------------------------------------------------------------------
diff --git a/solr/contrib/ltr/src/test/org/apache/solr/ltr/feature/TestFeatureStore.java b/solr/contrib/ltr/src/test/org/apache/solr/ltr/feature/TestFeatureStore.java
deleted file mode 100644
index ca58b7b..0000000
--- a/solr/contrib/ltr/src/test/org/apache/solr/ltr/feature/TestFeatureStore.java
+++ /dev/null
@@ -1,106 +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.solr.ltr.feature;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.solr.ltr.TestRerankBase;
-import org.apache.solr.ltr.store.FeatureStore;
-import org.apache.solr.ltr.store.rest.ManagedFeatureStore;
-import org.apache.solr.ltr.store.rest.TestManagedFeatureStore;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class TestFeatureStore extends TestRerankBase {
-
-  static ManagedFeatureStore fstore = null;
-
-  @BeforeClass
-  public static void setup() throws Exception {
-    setuptest(true);
-    fstore = getManagedFeatureStore();
-  }
-
-  @Test
-  public void testDefaultFeatureStoreName()
-  {
-    assertEquals("_DEFAULT_", FeatureStore.DEFAULT_FEATURE_STORE_NAME);
-    final FeatureStore expectedFeatureStore = fstore.getFeatureStore(FeatureStore.DEFAULT_FEATURE_STORE_NAME);
-    final FeatureStore actualFeatureStore = fstore.getFeatureStore(null);
-    assertEquals("getFeatureStore(null) should return the default feature store", expectedFeatureStore,
actualFeatureStore);
-  }
-
-  @Test
-  public void testFeatureStoreAdd() throws FeatureException
-  {
-    final FeatureStore fs = fstore.getFeatureStore("fstore-testFeature");
-    for (int i = 0; i < 5; i++) {
-      final String name = "c" + i;
-
-      fstore.addFeature(TestManagedFeatureStore.createMap(name,
-          OriginalScoreFeature.class.getCanonicalName(), null),
-          "fstore-testFeature");
-
-      final Feature f = fs.get(name);
-      assertNotNull(f);
-
-    }
-    assertEquals(5, fs.getFeatures().size());
-
-  }
-
-  @Test
-  public void testFeatureStoreGet() throws FeatureException
-  {
-    final FeatureStore fs = fstore.getFeatureStore("fstore-testFeature2");
-    for (int i = 0; i < 5; i++) {
-      Map<String,Object> params = new HashMap<String,Object>();
-      params.put("value", i);
-      final String name = "c" + i;
-
-      fstore.addFeature(TestManagedFeatureStore.createMap(name,
-          ValueFeature.class.getCanonicalName(), params),
-          "fstore-testFeature2");
-
-    }
-
-    for (int i = 0; i < 5; i++) {
-      final Feature f = fs.get("c" + i);
-      assertEquals("c" + i, f.getName());
-      assertTrue(f instanceof ValueFeature);
-      final ValueFeature vf = (ValueFeature)f;
-      assertEquals(i, vf.getValue());
-    }
-  }
-
-  @Test
-  public void testMissingFeatureReturnsNull() {
-    final FeatureStore fs = fstore.getFeatureStore("fstore-testFeature3");
-    for (int i = 0; i < 5; i++) {
-      Map<String,Object> params = new HashMap<String,Object>();
-      params.put("value", i);
-      final String name = "testc" + (float) i;
-      fstore.addFeature(TestManagedFeatureStore.createMap(name,
-          ValueFeature.class.getCanonicalName(), params),
-          "fstore-testFeature3");
-
-    }
-    assertNull(fs.get("missing_feature_name"));
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/a22681c8/solr/contrib/ltr/src/test/org/apache/solr/ltr/store/rest/TestManagedFeatureStore.java
----------------------------------------------------------------------
diff --git a/solr/contrib/ltr/src/test/org/apache/solr/ltr/store/rest/TestManagedFeatureStore.java
b/solr/contrib/ltr/src/test/org/apache/solr/ltr/store/rest/TestManagedFeatureStore.java
index 14373fb..c229ddd 100644
--- a/solr/contrib/ltr/src/test/org/apache/solr/ltr/store/rest/TestManagedFeatureStore.java
+++ b/solr/contrib/ltr/src/test/org/apache/solr/ltr/store/rest/TestManagedFeatureStore.java
@@ -19,11 +19,27 @@ package org.apache.solr.ltr.store.rest;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.lucene.util.LuceneTestCase;
+import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.ltr.feature.Feature;
+import org.apache.solr.ltr.feature.FeatureException;
+import org.apache.solr.ltr.feature.OriginalScoreFeature;
+import org.apache.solr.ltr.feature.ValueFeature;
+import org.apache.solr.ltr.store.FeatureStore;
+import org.apache.solr.ltr.store.rest.ManagedFeatureStore;
+import org.junit.BeforeClass;
+import org.junit.Test;
 
-public class TestManagedFeatureStore extends LuceneTestCase {
+public class TestManagedFeatureStore extends SolrTestCaseJ4 {
 
-  public static Map<String,Object> createMap(String name, String className, Map<String,Object>
params) {
+  private static ManagedFeatureStore fstore = null;
+
+  @BeforeClass
+  public static void setup() throws Exception {
+    initCore("solrconfig-ltr.xml", "schema.xml");
+    fstore = ManagedFeatureStore.getManagedFeatureStore(h.getCore());
+  }
+
+  private static Map<String,Object> createMap(String name, String className, Map<String,Object>
params) {
     final Map<String,Object> map = new HashMap<String,Object>();
     map.put(ManagedFeatureStore.NAME_KEY, name);
     map.put(ManagedFeatureStore.CLASS_KEY, className);
@@ -33,4 +49,101 @@ public class TestManagedFeatureStore extends LuceneTestCase {
     return map;
   }
 
+  @Test
+  public void testDefaultFeatureStoreName()
+  {
+    assertEquals("_DEFAULT_", FeatureStore.DEFAULT_FEATURE_STORE_NAME);
+    final FeatureStore expectedFeatureStore = fstore.getFeatureStore(FeatureStore.DEFAULT_FEATURE_STORE_NAME);
+    final FeatureStore actualFeatureStore = fstore.getFeatureStore(null);
+    assertEquals("getFeatureStore(null) should return the default feature store", expectedFeatureStore,
actualFeatureStore);
+  }
+
+  @Test
+  public void testFeatureStoreAdd() throws FeatureException
+  {
+    final FeatureStore fs = fstore.getFeatureStore("fstore-testFeature");
+    for (int i = 0; i < 5; i++) {
+      final String name = "c" + i;
+
+      fstore.addFeature(createMap(name,
+          OriginalScoreFeature.class.getCanonicalName(), null),
+          "fstore-testFeature");
+
+      final Feature f = fs.get(name);
+      assertNotNull(f);
+
+    }
+    assertEquals(5, fs.getFeatures().size());
+
+  }
+
+  @Test
+  public void testFeatureStoreGet() throws FeatureException
+  {
+    final FeatureStore fs = fstore.getFeatureStore("fstore-testFeature2");
+    for (int i = 0; i < 5; i++) {
+      Map<String,Object> params = new HashMap<String,Object>();
+      params.put("value", i);
+      final String name = "c" + i;
+
+      fstore.addFeature(createMap(name,
+          ValueFeature.class.getCanonicalName(), params),
+          "fstore-testFeature2");
+
+    }
+
+    for (int i = 0; i < 5; i++) {
+      final Feature f = fs.get("c" + i);
+      assertEquals("c" + i, f.getName());
+      assertTrue(f instanceof ValueFeature);
+      final ValueFeature vf = (ValueFeature)f;
+      assertEquals(i, vf.getValue());
+    }
+  }
+
+  @Test
+  public void testMissingFeatureReturnsNull() {
+    final FeatureStore fs = fstore.getFeatureStore("fstore-testFeature3");
+    for (int i = 0; i < 5; i++) {
+      Map<String,Object> params = new HashMap<String,Object>();
+      params.put("value", i);
+      final String name = "testc" + (float) i;
+      fstore.addFeature(createMap(name,
+          ValueFeature.class.getCanonicalName(), params),
+          "fstore-testFeature3");
+
+    }
+    assertNull(fs.get("missing_feature_name"));
+  }
+
+  @Test
+  public void getInstanceTest() throws FeatureException
+  {
+    fstore.addFeature(createMap("test",
+        OriginalScoreFeature.class.getCanonicalName(), null),
+        "testFstore");
+    final Feature feature = fstore.getFeatureStore("testFstore").get("test");
+    assertNotNull(feature);
+    assertEquals("test", feature.getName());
+    assertEquals(OriginalScoreFeature.class.getCanonicalName(), feature
+        .getClass().getCanonicalName());
+  }
+
+  @Test
+  public void getInvalidInstanceTest()
+  {
+    final String nonExistingClassName = "org.apache.solr.ltr.feature.LOLFeature";
+    final ClassNotFoundException expectedException =
+        new ClassNotFoundException(nonExistingClassName);
+    try {
+      fstore.addFeature(createMap("test",
+          nonExistingClassName, null),
+          "testFstore2");
+      fail("getInvalidInstanceTest failed to throw exception: "+expectedException);
+    } catch (Exception actualException) {
+      Throwable rootError = getRootCause(actualException);
+      assertEquals(expectedException.toString(), rootError.toString());
+    }
+  }
+
 }


Mime
View raw message