You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sa...@apache.org on 2013/03/29 17:18:22 UTC

svn commit: r1462522 - /lucene/dev/trunk/solr/core/src/test/org/apache/solr/schema/BadCopyFieldTest.java

Author: sarowe
Date: Fri Mar 29 16:18:22 2013
New Revision: 1462522

URL: http://svn.apache.org/r1462522
Log:
SOLR-4650: make BadCopyFieldTest extend AbstractBadConfigTestBase, which handles exceptions properly and deletes the core init'd to test config

Modified:
    lucene/dev/trunk/solr/core/src/test/org/apache/solr/schema/BadCopyFieldTest.java

Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/schema/BadCopyFieldTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/schema/BadCopyFieldTest.java?rev=1462522&r1=1462521&r2=1462522&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/schema/BadCopyFieldTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/schema/BadCopyFieldTest.java Fri Mar 29 16:18:22 2013
@@ -17,69 +17,42 @@
 
 package org.apache.solr.schema;
 
-import org.apache.solr.SolrTestCaseJ4;
-import org.junit.Test;
+import org.apache.solr.core.AbstractBadConfigTestBase;
 
 /**
  * SOLR-4650: copyField source with no asterisk should trigger an error if it doesn't match an explicit or dynamic field 
  */
-public class BadCopyFieldTest extends SolrTestCaseJ4 {
- 
-  @Test
-  public void testNonGlobCopyFieldSourceMatchingNothingShouldFail() {
-    try {
-      initCore("solrconfig.xml","bad-schema-non-glob-copyfield-source-matching-nothing-should-fail-test.xml");
-    } catch (Exception e) {
-      assertEquals
-          ("copyField source :'matches_nothing' is not a glob and doesn't match any explicit field or dynamicField.", 
-           e.getMessage());
-    }
-  }
-
-  @Test
-  public void testMultipleAsteriskCopyFieldSourceShouldFail() {
-    try {
-      initCore("solrconfig.xml","bad-schema-multiple-asterisk-copyfield-source-should-fail-test.xml");
-    } catch (Exception e) {
-      assertEquals
-          ("copyField source :'*too_many_asterisks*' is an invalid glob: either it contains more than one asterisk,"
-          +" or the asterisk occurs neither at the start nor at the end.",
-           e.getMessage());
-    }
-  }
-
-  @Test
-  public void testMisplacedAsteriskCopyFieldSourceShouldFail() {
-    try {
-      initCore("solrconfig.xml","bad-schema-misplaced-asterisk-copyfield-source-should-fail-test.xml");
-    } catch (Exception e) {
-      assertEquals
-          ("copyField source :'misplaced_*_asterisk' is an invalid glob: either it contains more than one asterisk,"
-          +" or the asterisk occurs neither at the start nor at the end.",
-           e.getMessage());
-    }
-  }
-
-  public void testMultipleAsteriskCopyFieldDestShouldFail() {
-    try {
-      initCore("solrconfig.xml","bad-schema-multiple-asterisk-copyfield-dest-should-fail-test.xml");
-    } catch (Exception e) {
-      assertEquals
-          ("copyField dest :'*too_many_asterisks*' is an invalid glob: either it contains more than one asterisk,"
-          +" or the asterisk occurs neither at the start nor at the end.",
-           e.getMessage());
-    }
-  }
-
-  @Test
-  public void testMisplacedAsteriskCopyFieldDestShouldFail() {
-    try {
-      initCore("solrconfig.xml","bad-schema-misplaced-asterisk-copyfield-dest-should-fail-test.xml");
-    } catch (Exception e) {
-      assertEquals
-          ("copyField dest :'misplaced_*_asterisk' is an invalid glob: either it contains more than one asterisk,"
-          +" or the asterisk occurs neither at the start nor at the end.",
-           e.getMessage());
-    }
+public class BadCopyFieldTest extends AbstractBadConfigTestBase {
+
+  private void doTest(final String schema, final String errString) throws Exception {
+    assertConfigs("solrconfig-basic.xml", schema, errString);
+  }
+
+  public void testNonGlobCopyFieldSourceMatchingNothingShouldFail() throws Exception {
+    doTest("bad-schema-non-glob-copyfield-source-matching-nothing-should-fail-test.xml",
+           "copyField source :'matches_nothing' is not a glob and doesn't match any explicit field or dynamicField."); 
+  }
+
+  private static final String INVALID_GLOB_MESSAGE = " is an invalid glob: either it contains more than one asterisk,"
+                                                   + " or the asterisk occurs neither at the start nor at the end.";
+  
+  public void testMultipleAsteriskCopyFieldSourceShouldFail() throws Exception {
+    doTest("bad-schema-multiple-asterisk-copyfield-source-should-fail-test.xml",
+           "copyField source :'*too_many_asterisks*'" + INVALID_GLOB_MESSAGE);
+  }
+
+  public void testMisplacedAsteriskCopyFieldSourceShouldFail() throws Exception {
+    doTest("bad-schema-misplaced-asterisk-copyfield-source-should-fail-test.xml",
+           "copyField source :'misplaced_*_asterisk'" + INVALID_GLOB_MESSAGE);
+  }
+
+  public void testMultipleAsteriskCopyFieldDestShouldFail() throws Exception {
+    doTest("bad-schema-multiple-asterisk-copyfield-dest-should-fail-test.xml",
+           "copyField dest :'*too_many_asterisks*'" + INVALID_GLOB_MESSAGE);
+  }
+
+  public void testMisplacedAsteriskCopyFieldDestShouldFail() throws Exception {
+    doTest("bad-schema-misplaced-asterisk-copyfield-dest-should-fail-test.xml",
+           "copyField dest :'misplaced_*_asterisk'" + INVALID_GLOB_MESSAGE);
   }
 }