use of org.apache.solr.response.SolrQueryResponse in project lucene-solr by apache.
the class CoreAdminCreateDiscoverTest method testCreateSavesRegProps.
@Test
public void testCreateSavesRegProps() throws Exception {
setupCore(coreNormal, true);
// create a new core (using CoreAdminHandler) w/ properties
// Just to be sure it's NOT written to the core.properties file
File workDir = new File(solrHomeDirectory, coreNormal);
File data = new File(workDir, "data");
SolrQueryResponse resp = new SolrQueryResponse();
admin.handleRequestBody(req(CoreAdminParams.ACTION, CoreAdminParams.CoreAdminAction.CREATE.toString(), CoreAdminParams.NAME, coreNormal, CoreAdminParams.INSTANCE_DIR, workDir.getAbsolutePath(), CoreAdminParams.CONFIG, "solrconfig_ren.xml", CoreAdminParams.SCHEMA, "schema_ren.xml", CoreAdminParams.DATA_DIR, data.getAbsolutePath()), resp);
assertNull("Exception on create", resp.getException());
// verify props are in persisted file
Properties props = new Properties();
File propFile = new File(solrHomeDirectory, coreNormal + "/" + CorePropertiesLocator.PROPERTIES_FILENAME);
FileInputStream is = new FileInputStream(propFile);
try {
props.load(new InputStreamReader(is, StandardCharsets.UTF_8));
} finally {
org.apache.commons.io.IOUtils.closeQuietly(is);
}
assertEquals("Unexpected value preserved in properties file " + propFile.getAbsolutePath(), props.getProperty(CoreAdminParams.NAME), coreNormal);
assertEquals("Unexpected value preserved in properties file " + propFile.getAbsolutePath(), props.getProperty(CoreAdminParams.CONFIG), "solrconfig_ren.xml");
assertEquals("Unexpected value preserved in properties file " + propFile.getAbsolutePath(), props.getProperty(CoreAdminParams.SCHEMA), "schema_ren.xml");
assertEquals("Unexpected value preserved in properties file " + propFile.getAbsolutePath(), props.getProperty(CoreAdminParams.DATA_DIR), data.getAbsolutePath());
assertEquals(props.size(), 4);
//checkOnlyKnown(propFile);
// For the other 3 vars, we couldn't get past creating the core if dereferencing didn't work correctly.
// Should have segments in the directory pointed to by the ${DATA_TEST}.
File test = new File(data, "index");
assertTrue("Should have found index dir at " + test.getAbsolutePath(), test.exists());
}
use of org.apache.solr.response.SolrQueryResponse in project lucene-solr by apache.
the class TestScoreJoinQPNoScore method testJoinQueryType.
public void testJoinQueryType() throws SyntaxError, IOException {
SolrQueryRequest req = null;
try {
final String score = whateverScore();
req = req("{!join from=dept_id_s to=dept_ss" + score + "}text_t:develop");
SolrQueryResponse rsp = new SolrQueryResponse();
SolrRequestInfo.setRequestInfo(new SolrRequestInfo(req, rsp));
{
final Query query = QParser.getParser(req.getParams().get("q"), req).getQuery();
final Query rewrittenQuery = query.rewrite(req.getSearcher().getIndexReader());
assertEquals(rewrittenQuery + " is expected to be from Solr", ScoreJoinQParserPlugin.class.getPackage().getName(), rewrittenQuery.getClass().getPackage().getName());
}
{
final Query query = QParser.getParser("{!join from=dept_id_s to=dept_ss}text_t:develop", req).getQuery();
final Query rewrittenQuery = query.rewrite(req.getSearcher().getIndexReader());
assertEquals(rewrittenQuery + " is expected to be from Solr", JoinQParserPlugin.class.getPackage().getName(), rewrittenQuery.getClass().getPackage().getName());
}
} finally {
if (req != null) {
req.close();
}
SolrRequestInfo.clearRequestInfo();
}
}
use of org.apache.solr.response.SolrQueryResponse in project lucene-solr by apache.
the class UpdateParamsTest method testUpdateProcessorParamDeprecationRemoved.
/**
* Tests that only update.chain and not update.processor works (SOLR-2105)
*/
public void testUpdateProcessorParamDeprecationRemoved() throws Exception {
SolrCore core = h.getCore();
UpdateRequestHandler handler = new UpdateRequestHandler();
handler.init(null);
MapSolrParams params = new MapSolrParams(new HashMap<String, String>());
params.getMap().put("update.processor", "nonexistant");
// Add a single document
SolrQueryResponse rsp = new SolrQueryResponse();
SolrQueryRequestBase req = new SolrQueryRequestBase(core, params) {
};
// First check that the old param behaves as it should
try {
handler.handleRequestBody(req, rsp);
assertTrue("Old param update.processor should not have any effect anymore", true);
} catch (Exception e) {
assertFalse("Got wrong exception while testing update.chain", e.getMessage().equals("unknown UpdateRequestProcessorChain: nonexistant"));
}
// Then check that the new param behaves correctly
params.getMap().remove("update.processor");
params.getMap().put(UpdateParams.UPDATE_CHAIN, "nonexistant");
req.setParams(params);
try {
handler.handleRequestBody(req, rsp);
assertFalse("Faulty update.chain parameter not causing an error - i.e. it is not detected", true);
} catch (Exception e) {
assertEquals("Got wrong exception while testing update.chain", e.getMessage(), "unknown UpdateRequestProcessorChain: nonexistant");
}
}
use of org.apache.solr.response.SolrQueryResponse in project lucene-solr by apache.
the class ClassificationUpdateProcessorFactoryTest method init_unsupportedFilterQuery_shouldThrowExceptionWithDetailedMessage.
@Test
public void init_unsupportedFilterQuery_shouldThrowExceptionWithDetailedMessage() {
UpdateRequestProcessor mockProcessor = mock(UpdateRequestProcessor.class);
SolrQueryRequest mockRequest = mock(SolrQueryRequest.class);
SolrQueryResponse mockResponse = mock(SolrQueryResponse.class);
args.add("knn.filterQuery", "not supported query");
try {
cFactoryToTest.init(args);
/* parsing failure happens because of the mocks, fine enough to check a proper exception propagation */
cFactoryToTest.getInstance(mockRequest, mockResponse, mockProcessor);
} catch (SolrException e) {
assertEquals("Classification UpdateProcessor Training Filter Query: 'not supported query' is not supported", e.getMessage());
}
}
use of org.apache.solr.response.SolrQueryResponse in project lucene-solr by apache.
the class CSVRequestHandlerTest method testCommitWithin.
@Test
public void testCommitWithin() throws Exception {
String csvString = "id;name\n123;hello";
SolrQueryRequest req = req("separator", ";", "commitWithin", "200");
SolrQueryResponse rsp = new SolrQueryResponse();
BufferingRequestProcessor p = new BufferingRequestProcessor(null);
CSVLoader loader = new CSVLoader();
loader.load(req, rsp, new ContentStreamBase.StringStream.StringStream(csvString), p);
AddUpdateCommand add = p.addCommands.get(0);
assertEquals(200, add.commitWithin);
req.close();
}
Aggregations