01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */package org.apache.solr.core;
17:
18: import org.apache.solr.request.SolrRequestHandler;
19: import org.apache.solr.request.StandardRequestHandler;
20: import org.apache.solr.util.AbstractSolrTestCase;
21:
22: public class RequestHandlersTest extends AbstractSolrTestCase {
23:
24: public String getSchemaFile() {
25: return "schema.xml";
26: }
27:
28: public String getSolrConfigFile() {
29: return "solrconfig.xml";
30: }
31:
32: public void testLazyLoading() {
33: SolrCore core = SolrCore.getSolrCore();
34: SolrRequestHandler handler = core.getRequestHandler("lazy");
35: assertFalse(handler instanceof StandardRequestHandler);
36:
37: // But it should behave just like the 'defaults' request handler above
38: assertU(adoc("id", "42", "name", "Zapp Brannigan"));
39: assertU(adoc("id", "43", "title", "Democratic Order of Planets"));
40: assertU(adoc("id", "44", "name", "The Zapper"));
41: assertU(adoc("id", "45", "title", "25 star General"));
42: assertU(adoc("id", "46", "subject",
43: "Defeated the pacifists of the Gandhi nebula"));
44: assertU(adoc(
45: "id",
46: "47",
47: "text",
48: "line up and fly directly at the enemy death cannons, clogging them with wreckage!"));
49: assertU(commit());
50:
51: assertQ("lazy request handler returns all matches",
52: req("id:[42 TO 47]"), "*[count(//doc)=6]");
53:
54: assertQ("lazy handler returns fewer matches", req("q",
55: "id:[42 TO 47]", "qt", "defaults"), "*[count(//doc)=4]");
56:
57: assertQ("lazy handler includes highlighting", req("q",
58: "name:Zapp OR title:General", "qt", "defaults"),
59: "//lst[@name='highlighting']");
60: }
61:
62: public void testPathNormalization() {
63: SolrCore core = SolrCore.getSolrCore();
64: SolrRequestHandler h1 = core.getRequestHandler("/update/csv");
65: assertNotNull(h1);
66:
67: SolrRequestHandler h2 = core.getRequestHandler("/update/csv/");
68: assertNotNull(h2);
69:
70: assertEquals(h1, h2); // the same object
71:
72: assertNull(core.getRequestHandler("/update/csv/asdgadsgas")); // prefix
73: }
74: }
|