mirror of https://github.com/apache/lucene.git
SOLR-13812: Add javadocs, uneven rejection and basic test coverage for the SolrTestCaseJ4.params method.
(Diego Ceccarelli, Christine Poerschke, Munendra S N)
This commit is contained in:
parent
824f0eca6b
commit
b51013a10b
|
@ -298,6 +298,9 @@ Other Changes
|
|||
|
||||
* SOLR-13791: Remove remaining Commons BeanUtils references. (Andras Salamon, Christine Poerschke)
|
||||
|
||||
* SOLR-13812: Add javadocs, uneven rejection and basic test coverage for the SolrTestCaseJ4.params method.
|
||||
(Diego Ceccarelli, Christine Poerschke, Munendra S N)
|
||||
|
||||
================== 8.2.0 ==================
|
||||
|
||||
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.solr;
|
|||
import java.io.File;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.solr.common.params.ModifiableSolrParams;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
@ -61,4 +62,25 @@ public class SolrTestCaseJ4Test extends SolrTestCaseJ4 {
|
|||
public void testCorrectCore() throws Exception {
|
||||
assertEquals("should be core1", "core1", h.getCore().getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParams() throws Exception {
|
||||
final ModifiableSolrParams params = new ModifiableSolrParams();
|
||||
assertEquals(params.toString(), params().toString());
|
||||
|
||||
params.add("q", "*:*");
|
||||
assertEquals(params.toString(), params("q", "*:*").toString());
|
||||
|
||||
params.add("rows", "42");
|
||||
assertEquals(params.toString(), params("q", "*:*", "rows", "42").toString());
|
||||
|
||||
expectThrows(RuntimeException.class, () -> {
|
||||
params("parameterWithoutValue");
|
||||
});
|
||||
|
||||
expectThrows(RuntimeException.class, () -> {
|
||||
params("q", "*:*", "rows", "42", "parameterWithoutValue");
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1270,7 +1270,16 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase {
|
|||
return d;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the correct SolrParams from an even list of strings.
|
||||
* A string in an even position will represent the name of a parameter, while the following string
|
||||
* at position (i+1) will be the assigned value.
|
||||
*
|
||||
* @param params an even list of strings
|
||||
* @return the ModifiableSolrParams generated from the given list of strings.
|
||||
*/
|
||||
public static ModifiableSolrParams params(String... params) {
|
||||
if (params.length % 2 != 0) throw new RuntimeException("Params length should be even");
|
||||
ModifiableSolrParams msp = new ModifiableSolrParams();
|
||||
for (int i=0; i<params.length; i+=2) {
|
||||
msp.add(params[i], params[i+1]);
|
||||
|
|
Loading…
Reference in New Issue