lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sar...@apache.org
Subject [2/2] lucene-solr:branch_7x: SOLR-11631: fix another test
Date Tue, 09 Jan 2018 22:52:18 GMT
SOLR-11631: fix another test


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

Branch: refs/heads/branch_7x
Commit: 4f81bb3cfc9f6bcc1f4dedea90064ba66999e3aa
Parents: 5aa6048
Author: Steve Rowe <sarowe@apache.org>
Authored: Tue Jan 9 17:51:42 2018 -0500
Committer: Steve Rowe <sarowe@apache.org>
Committed: Tue Jan 9 17:52:04 2018 -0500

----------------------------------------------------------------------
 .../TestEmbeddedSolrServerSchemaAPI.java        | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/4f81bb3c/solr/core/src/test/org/apache/solr/client/solrj/embedded/TestEmbeddedSolrServerSchemaAPI.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/client/solrj/embedded/TestEmbeddedSolrServerSchemaAPI.java
b/solr/core/src/test/org/apache/solr/client/solrj/embedded/TestEmbeddedSolrServerSchemaAPI.java
index f253831..0539c70 100644
--- a/solr/core/src/test/org/apache/solr/client/solrj/embedded/TestEmbeddedSolrServerSchemaAPI.java
+++ b/solr/core/src/test/org/apache/solr/client/solrj/embedded/TestEmbeddedSolrServerSchemaAPI.java
@@ -20,14 +20,19 @@ import java.io.IOException;
 import java.nio.file.Path;
 import java.util.Collections;
 import java.util.LinkedHashMap;
+import java.util.List;
 import java.util.Map;
 
 import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.api.ApiBag;
 import org.apache.solr.client.solrj.SolrServerException;
+import org.apache.solr.client.solrj.impl.HttpSolrClient;
 import org.apache.solr.client.solrj.request.schema.SchemaRequest;
 import org.apache.solr.client.solrj.response.schema.SchemaResponse;
 import org.apache.solr.client.solrj.response.schema.SchemaResponse.FieldResponse;
 import org.apache.solr.common.SolrException;
+import org.apache.solr.common.util.NamedList;
+import org.apache.solr.common.util.SimpleOrderedMap;
 import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.BeforeClass;
@@ -98,14 +103,17 @@ public class TestEmbeddedSolrServerSchemaAPI extends SolrTestCaseJ4 {
   }
 
   @Test 
-  public void testSchemaAddFieldAndFailOnImmutable() throws Exception {
+  public void testSchemaAddFieldAndFailOnImmutable() {
     assumeFalse("it needs a readonly schema", Boolean.getBoolean("managed.schema.mutable"));
 
-      SchemaRequest.AddField addFieldUpdateSchemaRequest = new SchemaRequest.AddField(fieldAttributes);
-      SchemaResponse.UpdateResponse addFieldResponse = addFieldUpdateSchemaRequest.process(server);
-      // wt hell???? assertFalse(addFieldResponse.toString(), addFieldResponse.getStatus()==0);
-      assertTrue((""+addFieldResponse).contains("schema is not editable"));
-
+    SchemaRequest.AddField addFieldUpdateSchemaRequest = new SchemaRequest.AddField(fieldAttributes);
+    assertFailedSchemaResponse(() -> addFieldUpdateSchemaRequest.process(server),
+        "schema is not editable");
   }
 
+  private static void assertFailedSchemaResponse(ThrowingRunnable runnable, String expectedErrorMessage)
{
+    ApiBag.ExceptionWithErrObject e = expectThrows(ApiBag.ExceptionWithErrObject.class, runnable);
+    String msg = e.getErrs().get(0).get("errorMessages").toString();
+    assertTrue(msg.contains(expectedErrorMessage));
+  }
 }


Mime
View raw message