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.handler.RequestHandlerBase;
19: import org.apache.solr.request.SolrQueryRequest;
20: import org.apache.solr.request.SolrQueryResponse;
21: import org.apache.solr.request.SolrRequestHandler;
22: import org.apache.solr.util.AbstractSolrTestCase;
23:
24: public class SolrCoreTest extends AbstractSolrTestCase {
25:
26: public String getSchemaFile() {
27: return "schema.xml";
28: }
29:
30: public String getSolrConfigFile() {
31: return "solrconfig.xml";
32: }
33:
34: public void testRequestHandlerRegistry() {
35: // property values defined in build.xml
36: SolrCore core = SolrCore.getSolrCore();
37:
38: EmptyRequestHandler handler1 = new EmptyRequestHandler();
39: EmptyRequestHandler handler2 = new EmptyRequestHandler();
40:
41: String path = "/this/is A path /that won't be registered!";
42: SolrRequestHandler old = core.registerRequestHandler(path,
43: handler1);
44: assertNull(old); // should not be anything...
45: assertEquals(core.getRequestHandlers().get(path), handler1);
46: old = core.registerRequestHandler(path, handler2);
47: assertEquals(old, handler1); // should pop out the old one
48: assertEquals(core.getRequestHandlers().get(path), handler2);
49: }
50: }
51:
52: /**
53: * An empty handler for testing
54: */
55: class EmptyRequestHandler extends RequestHandlerBase {
56: @Override
57: public void handleRequestBody(SolrQueryRequest req,
58: SolrQueryResponse rsp) throws Exception {
59: // nothing!
60: }
61:
62: @Override
63: public String getDescription() {
64: return null;
65: }
66:
67: @Override
68: public String getSource() {
69: return null;
70: }
71:
72: @Override
73: public String getSourceId() {
74: return null;
75: }
76:
77: @Override
78: public String getVersion() {
79: return null;
80: }
81: }
|