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.schema;
17:
18: import java.util.Collection;
19:
20: import org.apache.solr.core.SolrCore;
21: import org.apache.solr.schema.SchemaField;
22: import org.apache.solr.util.AbstractSolrTestCase;
23:
24: /**
25: * This is a simple test to make sure the unique key is not required
26: * when it is specified as 'false'
27: *
28: * It needs its own file so it can load a special schema file
29: */
30: public class NotRequiredUniqueKeyTest extends AbstractSolrTestCase {
31:
32: @Override
33: public String getSchemaFile() {
34: return "schema-not-required-unique-key.xml";
35: }
36:
37: @Override
38: public String getSolrConfigFile() {
39: return "solrconfig.xml";
40: }
41:
42: @Override
43: public void setUp() throws Exception {
44: super .setUp();
45: }
46:
47: @Override
48: public void tearDown() throws Exception {
49: super .tearDown();
50: }
51:
52: public void testSchemaLoading() {
53: SolrCore core = SolrCore.getSolrCore();
54: IndexSchema schema = core.getSchema();
55: SchemaField uniqueKey = schema.getUniqueKeyField();
56:
57: assertFalse(uniqueKey.isRequired());
58:
59: assertFalse(schema.getRequiredFields().contains(uniqueKey));
60: }
61: }
|