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.LinkedList;
19: import java.util.List;
20:
21: import org.apache.solr.core.SolrConfig;
22: import org.apache.solr.core.SolrCore;
23: import org.apache.solr.util.AbstractSolrTestCase;
24:
25: /**
26: * @author ryan
27: */
28: public class BadIndexSchemaTest extends AbstractSolrTestCase {
29:
30: @Override
31: public String getSchemaFile() {
32: return "bad-schema.xml";
33: }
34:
35: @Override
36: public String getSolrConfigFile() {
37: return "solrconfig.xml";
38: }
39:
40: @Override
41: public void setUp() throws Exception {
42: super .setUp();
43: }
44:
45: @Override
46: public void tearDown() throws Exception {
47: super .tearDown();
48: }
49:
50: private Throwable findErrorWithSubstring(List<Throwable> err,
51: String v) {
52: for (Throwable t : err) {
53: if (t.getMessage().indexOf(v) > 0) {
54: return t;
55: }
56: }
57: return null;
58: }
59:
60: public void testSevereErrorsForDuplicateNames() {
61: SolrCore core = SolrCore.getSolrCore();
62: IndexSchema schema = core.getSchema();
63:
64: for (Throwable t : SolrConfig.severeErrors) {
65: System.out.println("ERROR:" + t.getMessage());
66: }
67:
68: assertEquals(3, SolrConfig.severeErrors.size());
69:
70: List<Throwable> err = new LinkedList<Throwable>();
71: err.addAll(SolrConfig.severeErrors);
72:
73: Throwable t = findErrorWithSubstring(err, "*_twice");
74: assertNotNull(t);
75: err.remove(t);
76:
77: t = findErrorWithSubstring(err, "ftAgain");
78: assertNotNull(t);
79: err.remove(t);
80:
81: t = findErrorWithSubstring(err, "fAgain");
82: assertNotNull(t);
83: err.remove(t);
84:
85: // make sure thats all of them
86: assertTrue(err.isEmpty());
87: }
88: }
|