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;
17:
18: import org.apache.solr.util.AbstractSolrTestCase;
19:
20: /** Test SOLR-59, echo of query parameters */
21:
22: public class EchoParamsTest extends AbstractSolrTestCase {
23:
24: public String getSchemaFile() {
25: return "solr/crazy-path-to-schema.xml";
26: }
27:
28: public String getSolrConfigFile() {
29: return "solr/crazy-path-to-config.xml";
30: }
31:
32: private static final String HEADER_XPATH = "/response/lst[@name='responseHeader']";
33:
34: public void testDefaultEchoParams() {
35: lrf.args.put("wt", "xml");
36: lrf.args.put("version", "2.2");
37: assertQ(req("foo"), HEADER_XPATH + "/int[@name='status']");
38: assertQ(req("foo"), "not(//lst[@name='params'])");
39: }
40:
41: public void testDefaultEchoParamsDefaultVersion() {
42: lrf.args.put("wt", "xml");
43: lrf.args.remove("version");
44: assertQ(req("foo"), HEADER_XPATH + "/int[@name='status']");
45: assertQ(req("foo"), "not(//lst[@name='params'])");
46: }
47:
48: public void testExplicitEchoParams() {
49: lrf.args.put("wt", "xml");
50: lrf.args.put("version", "2.2");
51: lrf.args.put("echoParams", "explicit");
52: assertQ(req("foo"), HEADER_XPATH + "/int[@name='status']");
53: assertQ(req("foo"), HEADER_XPATH + "/lst[@name='params']");
54: assertQ(req("foo"), HEADER_XPATH
55: + "/lst[@name='params']/str[@name='wt'][.='xml']");
56: }
57:
58: public void testAllEchoParams() {
59: lrf = h.getRequestFactory("crazy_custom_qt", 0, 20, "version",
60: "2.2", "wt", "xml", "echoParams", "all", "echoHandler",
61: "true");
62:
63: assertQ(req("foo"), HEADER_XPATH
64: + "/lst[@name='params']/str[@name='fl'][.='implicit']");
65: assertQ(
66: req("foo"),
67: HEADER_XPATH
68: + "/str[@name='handler'][.='org.apache.solr.request.StandardRequestHandler']");
69: }
70:
71: }
|