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.util.AbstractSolrTestCase;
19: import org.w3c.dom.Node;
20: import org.w3c.dom.NodeList;
21:
22: import javax.xml.xpath.XPathConstants;
23:
24: public class TestConfig 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 testJavaProperty() {
35: // property values defined in build.xml
36:
37: String s = SolrConfig.config.get("propTest");
38: assertEquals("prefix-proptwo-suffix", s);
39:
40: s = SolrConfig.config.get("propTest/@attr1", "default");
41: assertEquals("propone-${literal}", s);
42:
43: s = SolrConfig.config.get("propTest/@attr2", "default");
44: assertEquals("default-from-config", s);
45:
46: s = SolrConfig.config.get(
47: "propTest[@attr2='default-from-config']", "default");
48: assertEquals("prefix-proptwo-suffix", s);
49:
50: NodeList nl = (NodeList) SolrConfig.config.evaluate("propTest",
51: XPathConstants.NODESET);
52: assertEquals(1, nl.getLength());
53: assertEquals("prefix-proptwo-suffix", nl.item(0)
54: .getTextContent());
55:
56: Node node = SolrConfig.config.getNode("propTest", true);
57: assertEquals("prefix-proptwo-suffix", node.getTextContent());
58: }
59: }
|