From 7193b6469b0cf5424e91eefc39fd56d4634e7295 Mon Sep 17 00:00:00 2001 From: Roman Chyla Date: Mon, 16 Jun 2014 20:04:03 -0400 Subject: [PATCH] aaaaargh, the solr upgrade is hard --- .classpath | 30 ++++++++-- .project | 17 ++++++ build.xml | 7 +++ .../synonym/NewSynonymFilterFactory.java | 2 +- ...qpAdsabsFieldNodePreAnalysisProcessor.java | 11 +++- .../ASCIIDuplicatingFilterFactory.java | 2 +- .../AuthorShortNameUpgradeFilterFactory.java | 4 +- .../solr/util/MontySolrQueryTestCase.java | 2 +- .../analysis/TestASCIIDuplicatingFilter.java | 5 +- .../analysis/TestAdsabsTypeDateString.java | 30 +++++----- .../analysis/TestDateNormalizerFilter.java | 4 +- .../author/TestAdsabsTypeAuthorParsing.java | 46 ++++++++------- .../author/TestAuthorSynonymFilter.java | 6 +- .../TestAuthorTransliterationFilter.java | 4 +- .../author/TestAuthorVariationFilter.java | 4 +- .../TestPythonicAuthorNormalizeFilter.java | 5 +- .../analysis/author/TestSolrAuthorFilter.java | 57 ------------------- .../search/BenchmarkBitSetQParserPlugin.java | 25 ++++---- .../StandardLuceneGrammarSyntaxParser.java | 2 +- .../test/examples/BlackAbstractTestCase.java | 25 ++++---- .../solr/util/MontySolrAbstractTestCase.java | 14 ++--- 21 files changed, 161 insertions(+), 141 deletions(-) create mode 100644 .project delete mode 100644 contrib/adsabs/src/test/org/apache/solr/analysis/author/TestSolrAuthorFilter.java diff --git a/.classpath b/.classpath index 3ea7857ba..a92ad7234 100644 --- a/.classpath +++ b/.classpath @@ -1,5 +1,7 @@ + + @@ -15,7 +17,6 @@ - @@ -65,7 +66,6 @@ - @@ -73,15 +73,14 @@ - - + + - @@ -92,6 +91,25 @@ - + + + + + + + + + + + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 000000000..71f82a600 --- /dev/null +++ b/.project @@ -0,0 +1,17 @@ + + + montysolr-next + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/build.xml b/build.xml index e92109a23..a4d432eb4 100644 --- a/build.xml +++ b/build.xml @@ -414,6 +414,13 @@ montysolr.version=${montysolr.version} + + + + + + + diff --git a/contrib/adsabs/src/java/org/apache/lucene/analysis/synonym/NewSynonymFilterFactory.java b/contrib/adsabs/src/java/org/apache/lucene/analysis/synonym/NewSynonymFilterFactory.java index fa54a9cd1..da9ec05db 100644 --- a/contrib/adsabs/src/java/org/apache/lucene/analysis/synonym/NewSynonymFilterFactory.java +++ b/contrib/adsabs/src/java/org/apache/lucene/analysis/synonym/NewSynonymFilterFactory.java @@ -66,7 +66,7 @@ public class NewSynonymFilterFactory extends TokenFilterFactory implements ResourceLoaderAware { protected Map args; - protected NewSynonymFilterFactory(Map args) { + public NewSynonymFilterFactory(Map args) { super(args); this.args = args; } diff --git a/contrib/adsabs/src/java/org/apache/lucene/queryparser/flexible/aqp/processors/AqpAdsabsFieldNodePreAnalysisProcessor.java b/contrib/adsabs/src/java/org/apache/lucene/queryparser/flexible/aqp/processors/AqpAdsabsFieldNodePreAnalysisProcessor.java index 1908ed9ab..3cd07cb88 100644 --- a/contrib/adsabs/src/java/org/apache/lucene/queryparser/flexible/aqp/processors/AqpAdsabsFieldNodePreAnalysisProcessor.java +++ b/contrib/adsabs/src/java/org/apache/lucene/queryparser/flexible/aqp/processors/AqpAdsabsFieldNodePreAnalysisProcessor.java @@ -66,7 +66,7 @@ protected QueryNode postProcessNode(QueryNode node) // first parse the date with the appropriate analyzer String value = fieldNode.getTextAsString(); Analyzer analyzer = getQueryConfigHandler().get(ConfigurationKeys.ANALYZER); - TokenStream source; + TokenStream source = null; try { source = analyzer.tokenStream(field, new StringReader(value)); source.reset(); @@ -74,6 +74,15 @@ protected QueryNode postProcessNode(QueryNode node) } catch (IOException e1) { throw new RuntimeException(e1); } + finally { + if (source != null) { + try { + source.close(); + } catch (IOException e) { + // ignore + } + } + } Date date = null; String normalizedDate=null; diff --git a/contrib/adsabs/src/java/org/apache/solr/analysis/ASCIIDuplicatingFilterFactory.java b/contrib/adsabs/src/java/org/apache/solr/analysis/ASCIIDuplicatingFilterFactory.java index c1ca9c2da..1dc645a10 100644 --- a/contrib/adsabs/src/java/org/apache/solr/analysis/ASCIIDuplicatingFilterFactory.java +++ b/contrib/adsabs/src/java/org/apache/solr/analysis/ASCIIDuplicatingFilterFactory.java @@ -34,7 +34,7 @@ * */ public class ASCIIDuplicatingFilterFactory extends TokenFilterFactory implements MultiTermAwareComponent { - protected ASCIIDuplicatingFilterFactory(Map args) { + public ASCIIDuplicatingFilterFactory(Map args) { super(args); if (!args.isEmpty()) { throw new IllegalArgumentException("Unknown parameter(s): " + args); diff --git a/contrib/adsabs/src/java/org/apache/solr/analysis/author/AuthorShortNameUpgradeFilterFactory.java b/contrib/adsabs/src/java/org/apache/solr/analysis/author/AuthorShortNameUpgradeFilterFactory.java index d41daf31b..3f9680110 100644 --- a/contrib/adsabs/src/java/org/apache/solr/analysis/author/AuthorShortNameUpgradeFilterFactory.java +++ b/contrib/adsabs/src/java/org/apache/solr/analysis/author/AuthorShortNameUpgradeFilterFactory.java @@ -97,7 +97,7 @@ public static class MakeAllShortNames extends NewSynonymFilterFactory.SynonymBui - protected MakeAllShortNames(Map args) { + public MakeAllShortNames(Map args) { super(args); } @@ -292,7 +292,7 @@ private int containsLongForm(String[] names) { */ public static class MakeShortNames extends NewSynonymFilterFactory.SynonymBuilderFactory { - protected MakeShortNames(Map args) { + public MakeShortNames(Map args) { super(args); } diff --git a/contrib/adsabs/src/test/monty/solr/util/MontySolrQueryTestCase.java b/contrib/adsabs/src/test/monty/solr/util/MontySolrQueryTestCase.java index 50a8bfd96..16a8d2576 100644 --- a/contrib/adsabs/src/test/monty/solr/util/MontySolrQueryTestCase.java +++ b/contrib/adsabs/src/test/monty/solr/util/MontySolrQueryTestCase.java @@ -270,7 +270,7 @@ public int incrementId() { } - public String[] formatSynonyms(String[] strings) { + public static String[] formatSynonyms(String[] strings) { String[] newLines = new String[strings.length]; int nl = 0; for (String line : strings) { diff --git a/contrib/adsabs/src/test/org/apache/solr/analysis/TestASCIIDuplicatingFilter.java b/contrib/adsabs/src/test/org/apache/solr/analysis/TestASCIIDuplicatingFilter.java index 97a9b390c..a75022c6e 100644 --- a/contrib/adsabs/src/test/org/apache/solr/analysis/TestASCIIDuplicatingFilter.java +++ b/contrib/adsabs/src/test/org/apache/solr/analysis/TestASCIIDuplicatingFilter.java @@ -1,6 +1,9 @@ package org.apache.solr.analysis; import java.io.StringReader; +import java.util.HashMap; +import java.util.Map; + import org.apache.lucene.analysis.MockTokenizer; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.BaseTokenStreamTestCase; @@ -9,7 +12,7 @@ public class TestASCIIDuplicatingFilter extends BaseTokenStreamTestCase { public void test() throws Exception { - ASCIIDuplicatingFilterFactory factory = new ASCIIDuplicatingFilterFactory(); + ASCIIDuplicatingFilterFactory factory = new ASCIIDuplicatingFilterFactory(new HashMap()); TokenStream stream = factory.create(new MockTokenizer(new StringReader("čtyřista čtyřicet čtyři"), MockTokenizer.WHITESPACE, false)); diff --git a/contrib/adsabs/src/test/org/apache/solr/analysis/TestAdsabsTypeDateString.java b/contrib/adsabs/src/test/org/apache/solr/analysis/TestAdsabsTypeDateString.java index 3dcad8313..6f277ccec 100644 --- a/contrib/adsabs/src/test/org/apache/solr/analysis/TestAdsabsTypeDateString.java +++ b/contrib/adsabs/src/test/org/apache/solr/analysis/TestAdsabsTypeDateString.java @@ -23,6 +23,7 @@ import org.apache.lucene.search.NumericRangeQuery; import org.adsabs.solr.AdsConfig.F; +import org.junit.BeforeClass; /** * Test for the date_string type @@ -30,22 +31,25 @@ */ public class TestAdsabsTypeDateString extends MontySolrQueryTestCase { + @BeforeClass + public static void beforeClass() throws Exception { - @Override - public String getSchemaFile() { - makeResourcesVisible(this.solrConfig.getResourceLoader(), - new String[] {MontySolrSetup.getMontySolrHome() + "/contrib/examples/adsabs/solr/collection1/conf", - MontySolrSetup.getSolrHome() + "/example/solr/collection1/conf" - }); - return MontySolrSetup.getMontySolrHome() - + "/contrib/examples/adsabs/solr/collection1/conf/schema.xml"; + makeResourcesVisible(Thread.currentThread().getContextClassLoader(), new String[] { + MontySolrSetup.getMontySolrHome() + "/contrib/examples/adsabs/solr/collection1/conf", + MontySolrSetup.getSolrHome() + "/example/solr/collection1/conf" + }); - } + System.setProperty("solr.allow.unsafe.resourceloading", "true"); + schemaString = MontySolrSetup.getMontySolrHome() + + "/contrib/examples/adsabs/solr/collection1/conf/schema.xml"; - public String getSolrConfigFile() { - return MontySolrSetup.getMontySolrHome() - + "/contrib/examples/adsabs/solr/collection1/conf/solrconfig.xml"; - } + configString = MontySolrSetup.getMontySolrHome() + + "/contrib/examples/adsabs/solr/collection1/conf/solrconfig.xml"; + + initCore(configString, schemaString, MontySolrSetup.getSolrHome() + + "/example/solr"); + } + public void test() throws Exception { diff --git a/contrib/adsabs/src/test/org/apache/solr/analysis/TestDateNormalizerFilter.java b/contrib/adsabs/src/test/org/apache/solr/analysis/TestDateNormalizerFilter.java index d35c6dce0..98ea30620 100644 --- a/contrib/adsabs/src/test/org/apache/solr/analysis/TestDateNormalizerFilter.java +++ b/contrib/adsabs/src/test/org/apache/solr/analysis/TestDateNormalizerFilter.java @@ -1,6 +1,8 @@ package org.apache.solr.analysis; import java.io.StringReader; +import java.util.HashMap; + import org.apache.lucene.analysis.MockTokenizer; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.BaseTokenStreamTestCase; @@ -9,7 +11,7 @@ public class TestDateNormalizerFilter extends BaseTokenStreamTestCase { public void test() throws Exception { - ASCIIDuplicatingFilterFactory factory = new ASCIIDuplicatingFilterFactory(); + ASCIIDuplicatingFilterFactory factory = new ASCIIDuplicatingFilterFactory(new HashMap()); TokenStream stream = factory.create(new MockTokenizer(new StringReader("čtyřista čtyřicet čtyři"), MockTokenizer.WHITESPACE, false)); diff --git a/contrib/adsabs/src/test/org/apache/solr/analysis/author/TestAdsabsTypeAuthorParsing.java b/contrib/adsabs/src/test/org/apache/solr/analysis/author/TestAdsabsTypeAuthorParsing.java index 173dad4a7..23eb64225 100644 --- a/contrib/adsabs/src/test/org/apache/solr/analysis/author/TestAdsabsTypeAuthorParsing.java +++ b/contrib/adsabs/src/test/org/apache/solr/analysis/author/TestAdsabsTypeAuthorParsing.java @@ -80,13 +80,27 @@ public class TestAdsabsTypeAuthorParsing extends MontySolrQueryTestCase { private String author_field = "author"; - @Override - public String getSchemaFile() { - makeResourcesVisible(this.solrConfig.getResourceLoader(), - new String[] {MontySolrSetup.getMontySolrHome() + "/contrib/examples/adsabs/solr/collection1/conf", - MontySolrSetup.getSolrHome() + "/example/solr/collection1/conf" - }); - + @BeforeClass + public static void beforeClass() throws Exception { + + makeResourcesVisible(Thread.currentThread().getContextClassLoader(), + new String[] {MontySolrSetup.getMontySolrHome() + "/contrib/examples/adsabs/solr/collection1/conf", + MontySolrSetup.getSolrHome() + "/example/solr/collection1/conf" + }); + + System.setProperty("solr.allow.unsafe.resourceloading", "true"); + schemaString = getSchemaFile(); + + + configString = MontySolrSetup.getMontySolrHome() + + "/contrib/examples/adsabs/solr/collection1/conf/solrconfig.xml"; + + initCore(configString, schemaString, MontySolrSetup.getSolrHome() + + "/example/solr"); + } + + public static String getSchemaFile() { + /* * Make a copy of the schema.xml, and create our own synonym translation rules */ @@ -294,27 +308,15 @@ public void setUp() throws Exception { TokenStream iAuthor = iAnalyzer.tokenStream("author", new StringReader("")); TokenStream qAuthor = qAnalyzer.tokenStream("author", new StringReader("")); - iAuthor.reset(); - iAuthor.reset(); - iAuthor.reset(); - - qAuthor.reset(); - qAuthor.reset(); - qAuthor.reset(); + iAuthor.close(); + qAuthor.close(); + // TODO: force reload of the synonym map //h.getCoreContainer().reload("collection1"); } - @Override - public String getSolrConfigFile() { - - return MontySolrSetup.getMontySolrHome() - + "/contrib/examples/adsabs/solr/collection1/conf/solrconfig.xml"; - - } - public void testAuthorParsingUseCases() throws Exception { diff --git a/contrib/adsabs/src/test/org/apache/solr/analysis/author/TestAuthorSynonymFilter.java b/contrib/adsabs/src/test/org/apache/solr/analysis/author/TestAuthorSynonymFilter.java index acaf50bd9..2f35640cb 100644 --- a/contrib/adsabs/src/test/org/apache/solr/analysis/author/TestAuthorSynonymFilter.java +++ b/contrib/adsabs/src/test/org/apache/solr/analysis/author/TestAuthorSynonymFilter.java @@ -19,7 +19,7 @@ public class TestAuthorSynonymFilter extends BaseTokenStreamTestCase { public void testAuthorSynonyms1() throws Exception { - AuthorSynonymFilterFactory factory = new AuthorSynonymFilterFactory(); + AuthorSynonymFilterFactory factory = new AuthorSynonymFilterFactory(new HashMap()); WriteableSynonymMap map = new WriteableExplicitSynonymMap(); List rules = new ArrayList(); rules.add("MILLER, WILLIAM=>MILLER, B;MILLER, BILL;MILLER,;MILLER, BILL\\b.*"); @@ -54,7 +54,7 @@ public void testAuthorSynonyms1() throws Exception { } public void testAuthorSynonyms2() throws Exception { - AuthorSynonymFilterFactory factory = new AuthorSynonymFilterFactory(); + AuthorSynonymFilterFactory factory = new AuthorSynonymFilterFactory(new HashMap()); WriteableSynonymMap map = new WriteableExplicitSynonymMap(); List rules = new ArrayList(); @@ -106,7 +106,7 @@ public void testAuthorSynonyms2() throws Exception { public void testAuthorEquivSynonymMap() throws Exception { - AuthorSynonymFilterFactory factory = new AuthorSynonymFilterFactory(); + AuthorSynonymFilterFactory factory = new AuthorSynonymFilterFactory(new HashMap()); WriteableSynonymMap map = new WriteableEquivalentSynonymMap(); List rules = new ArrayList(){{ add("ADAMČUK\\,\\ K,ADAMCUK\\,\\ K,ADAMCHUK\\,\\ K,"); diff --git a/contrib/adsabs/src/test/org/apache/solr/analysis/author/TestAuthorTransliterationFilter.java b/contrib/adsabs/src/test/org/apache/solr/analysis/author/TestAuthorTransliterationFilter.java index 0287426b7..f157cc1dd 100644 --- a/contrib/adsabs/src/test/org/apache/solr/analysis/author/TestAuthorTransliterationFilter.java +++ b/contrib/adsabs/src/test/org/apache/solr/analysis/author/TestAuthorTransliterationFilter.java @@ -3,6 +3,8 @@ import java.io.IOException; import java.io.Reader; import java.io.StringReader; +import java.util.HashMap; + import org.apache.lucene.analysis.core.KeywordTokenizer; import org.apache.lucene.analysis.tokenattributes.TypeAttribute; import org.apache.lucene.analysis.TokenFilter; @@ -30,7 +32,7 @@ public void testAuthorSynonyms() throws Exception { Tokenizer tokenizer = new KeywordTokenizer(reader); - AuthorTransliterationFactory factory = new AuthorTransliterationFactory(); + AuthorTransliterationFactory factory = new AuthorTransliterationFactory(new HashMap()); TokenStream stream = factory.create(new TestFilter(tokenizer)); diff --git a/contrib/adsabs/src/test/org/apache/solr/analysis/author/TestAuthorVariationFilter.java b/contrib/adsabs/src/test/org/apache/solr/analysis/author/TestAuthorVariationFilter.java index 896bcb3e6..5617126f4 100644 --- a/contrib/adsabs/src/test/org/apache/solr/analysis/author/TestAuthorVariationFilter.java +++ b/contrib/adsabs/src/test/org/apache/solr/analysis/author/TestAuthorVariationFilter.java @@ -2,6 +2,8 @@ import java.io.Reader; import java.io.StringReader; +import java.util.HashMap; + import org.apache.lucene.analysis.core.KeywordTokenizer; import org.apache.lucene.analysis.Tokenizer; import org.apache.lucene.analysis.TokenStream; @@ -12,7 +14,7 @@ public class TestAuthorVariationFilter extends BaseTokenStreamTestCase { public void testAuthorVariations() throws Exception { Reader reader = new StringReader("GOMEZ, HECTOR"); Tokenizer tokenizer = new KeywordTokenizer(reader); - AuthorQueryVariationsFilterFactory factory = new AuthorQueryVariationsFilterFactory(); + AuthorQueryVariationsFilterFactory factory = new AuthorQueryVariationsFilterFactory(new HashMap()); TokenStream stream = factory.create(tokenizer); String[] expected = { "GOMEZ, HECTOR", "GOMEZ, H", "GOMEZ,", "GOMEZ, HECTOR\\b.*", "GOMEZ, H\\b.*", }; assertTokenStreamContents(stream, expected); diff --git a/contrib/adsabs/src/test/org/apache/solr/analysis/author/TestPythonicAuthorNormalizeFilter.java b/contrib/adsabs/src/test/org/apache/solr/analysis/author/TestPythonicAuthorNormalizeFilter.java index 70e3e474a..5a2d2b913 100644 --- a/contrib/adsabs/src/test/org/apache/solr/analysis/author/TestPythonicAuthorNormalizeFilter.java +++ b/contrib/adsabs/src/test/org/apache/solr/analysis/author/TestPythonicAuthorNormalizeFilter.java @@ -3,7 +3,10 @@ import java.io.Reader; import java.io.StringReader; import java.util.ArrayList; +import java.util.HashMap; + import monty.solr.util.MontySolrAbstractLuceneTestCase; + import org.apache.lucene.analysis.core.KeywordTokenizer; import org.apache.lucene.analysis.tokenattributes.CharTermAttribute; import org.apache.lucene.analysis.Tokenizer; @@ -55,7 +58,7 @@ public void test() throws Exception { public void compare(String input, String... expected) throws Exception { Reader reader = new StringReader(input); Tokenizer tokenizer = new KeywordTokenizer(reader); - PythonicAuthorNormalizeFilterFactory factory = new PythonicAuthorNormalizeFilterFactory(); + PythonicAuthorNormalizeFilterFactory factory = new PythonicAuthorNormalizeFilterFactory(new HashMap()); TokenStream stream = factory.create(tokenizer); stream.reset(); CharTermAttribute termAtt = stream.getAttribute(CharTermAttribute.class); diff --git a/contrib/adsabs/src/test/org/apache/solr/analysis/author/TestSolrAuthorFilter.java b/contrib/adsabs/src/test/org/apache/solr/analysis/author/TestSolrAuthorFilter.java deleted file mode 100644 index 4da7c027b..000000000 --- a/contrib/adsabs/src/test/org/apache/solr/analysis/author/TestSolrAuthorFilter.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.apache.solr.analysis.author; - -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import monty.solr.util.MontySolrAbstractTestCase; -import monty.solr.util.MontySolrSetup; - -import org.apache.solr.schema.IndexSchema; - - - -public class TestSolrAuthorFilter extends MontySolrAbstractTestCase { - - String AUTHOR_FIELD = "author"; - - public String getSchemaFile() { - - makeResourcesVisible(this.solrConfig.getResourceLoader(), - new String[] {MontySolrSetup.getMontySolrHome() + "/contrib/examples/adsabs/solr/collection1/conf", - MontySolrSetup.getSolrHome() + "/example/solr/collection1/conf" - }); - - return MontySolrSetup.getMontySolrHome() - + "/contrib/examples/adsabs/solr/collection1/conf/schema.xml"; - } - - public String getSolrConfigFile() { - return MontySolrSetup.getMontySolrHome() - + "/contrib/examples/adsabs/solr/collection1/conf/solrconfig.xml"; - } - - public void testAuthorParsing() throws Exception { - adoc("recid", "1", AUTHOR_FIELD, "Jim Jay Clavell"); - adoc("recid", "2", AUTHOR_FIELD, "Jim Jay Clavell"); - adoc("recid", "3", AUTHOR_FIELD, "Jim Jay Clavell"); - - IndexSchema schema = h.getCore().getSchema(); - schema.getField(AUTHOR_FIELD); - } -} - - diff --git a/contrib/adsabs/src/test/org/apache/solr/search/BenchmarkBitSetQParserPlugin.java b/contrib/adsabs/src/test/org/apache/solr/search/BenchmarkBitSetQParserPlugin.java index 8ec173250..2abc18a7d 100644 --- a/contrib/adsabs/src/test/org/apache/solr/search/BenchmarkBitSetQParserPlugin.java +++ b/contrib/adsabs/src/test/org/apache/solr/search/BenchmarkBitSetQParserPlugin.java @@ -6,6 +6,7 @@ import java.util.Random; import org.apache.solr.common.util.NamedList; +import org.junit.BeforeClass; import org.junit.Test; import monty.solr.util.MontySolrAbstractTestCase; @@ -16,19 +17,21 @@ public class BenchmarkBitSetQParserPlugin extends MontySolrAbstractTestCase { private int indexSize = 10000000; private long maxTime = 60*1000; // max time benchmark is allowed to run private ArrayList> timerStack = new ArrayList>(); - - public String getSchemaFile() { - makeResourcesVisible(this.solrConfig.getResourceLoader(), - new String[] {MontySolrSetup.getMontySolrHome() + "/contrib/adsabs/src/test-files/solr/collection1/conf", - MontySolrSetup.getSolrHome() + "/example/solr/collection1/conf" - }); - return "schema.xml"; + + @BeforeClass + public static void beforeClass() throws Exception { + + System.setProperty("solr.allow.unsafe.resourceloading", "true"); + schemaString = MontySolrSetup.getMontySolrHome() + + "/contrib/adsabs/src/test-files/solr/collection1/conf/" + + "schema-minimal.xml"; + + configString = MontySolrSetup.getMontySolrHome() + + "/contrib/adsabs/src/test-files/solr/collection1/conf/" + + "bitset-solrconfig.xml"; + initCore(configString, schemaString, MontySolrSetup.getMontySolrHome() + "/contrib/adsabs/src/test-files/solr/collection1"); } - public String getSolrConfigFile() { - return MontySolrSetup.getMontySolrHome() + "/contrib/adsabs/src/test-files/solr/collection1/conf/" + - "bitset-solrconfig.xml"; - } @Override public void setUp() throws Exception { diff --git a/contrib/antlrqueryparser/src/java/org/apache/lucene/queryparser/flexible/aqp/parser/StandardLuceneGrammarSyntaxParser.java b/contrib/antlrqueryparser/src/java/org/apache/lucene/queryparser/flexible/aqp/parser/StandardLuceneGrammarSyntaxParser.java index f09201a70..2a2e5af2c 100644 --- a/contrib/antlrqueryparser/src/java/org/apache/lucene/queryparser/flexible/aqp/parser/StandardLuceneGrammarSyntaxParser.java +++ b/contrib/antlrqueryparser/src/java/org/apache/lucene/queryparser/flexible/aqp/parser/StandardLuceneGrammarSyntaxParser.java @@ -5,7 +5,7 @@ /** * Automatically generated SyntaxParser wrapper built by ant - * from the grammar source: /dvt/workspace/montysolr/contrib/antlrqueryparser/src/java/org/apache/lucene/queryparser/flexible/aqp/parser/StandardLuceneGrammar.g + * from the grammar source: /dvt/workspace/montysolr-next/contrib/antlrqueryparser/src/java/org/apache/lucene/queryparser/flexible/aqp/parser/StandardLuceneGrammar.g * * YOUR CHANGES WILL BE OVERWRITTEN AUTOMATICALLY! */ diff --git a/contrib/examples/src/test/examples/BlackAbstractTestCase.java b/contrib/examples/src/test/examples/BlackAbstractTestCase.java index ff975ea80..53dc18227 100644 --- a/contrib/examples/src/test/examples/BlackAbstractTestCase.java +++ b/contrib/examples/src/test/examples/BlackAbstractTestCase.java @@ -1,6 +1,7 @@ package examples; import java.io.File; + import javax.xml.xpath.XPathExpressionException; import monty.solr.util.MontySolrAbstractTestCase; @@ -9,6 +10,7 @@ import org.apache.commons.io.FileUtils; import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer; import org.apache.solr.servlet.DirectSolrConnection; +import org.junit.BeforeClass; public abstract class BlackAbstractTestCase extends MontySolrAbstractTestCase { @@ -20,6 +22,19 @@ public abstract class BlackAbstractTestCase extends MontySolrAbstractTestCase { private File persistDir = null; private String factoryPropShadow; + @BeforeClass + public static void beforeClass() throws Exception { + + /*makeResourcesVisible(Thread.currentThread().getContextClassLoader(), + new String[] {MontySolrSetup.getMontySolrHome() + "/contrib/adsabs/src/test-files/solr/collection1/conf", + MontySolrSetup.getSolrHome() + "/example/solr/collection1/conf" + });*/ + System.setProperty("solr.allow.unsafe.resourceloading", "true"); + schemaString = getConf("solr/collection1/conf/schema.xml"); + + configString = getConf("solr/collection1/conf/solrconfig.xml"); + initCore(configString, schemaString, getConf("solr/collection1")); + } public String getSolrHome() { @@ -113,16 +128,6 @@ public static void setEName(String name) { base = path + ename; } - @Override - public String getSchemaFile() { - return getConf("solr/collection1/conf/schema.xml"); - } - - - @Override - public String getSolrConfigFile() { - return getConf("solr/collection1/conf/solrconfig.xml"); - } public void assertQDirect(String query, String body, String expected) { try { diff --git a/src/test/monty/solr/util/MontySolrAbstractTestCase.java b/src/test/monty/solr/util/MontySolrAbstractTestCase.java index df94ab5d4..8bf9cb2a3 100644 --- a/src/test/monty/solr/util/MontySolrAbstractTestCase.java +++ b/src/test/monty/solr/util/MontySolrAbstractTestCase.java @@ -89,9 +89,9 @@ public static File getFile(String name) { * * @param loader */ - public static void makeResourcesVisible(SolrResourceLoader loader, String...paths) { + public static void makeResourcesVisible(ClassLoader loader, String...paths) { try { - URLClassLoader innerLoader = (URLClassLoader) loader.getClassLoader(); + URLClassLoader innerLoader = (URLClassLoader) loader; Class classLoader = URLClassLoader.class; Class[] params = new Class[]{ URL.class }; Method method = classLoader.getDeclaredMethod( "addURL", params); @@ -117,7 +117,7 @@ public DirectSolrConnection getDirectServer() { return new DirectSolrConnection(h.getCore()); } - public File createTempFile(String...lines) throws IOException { + public static File createTempFile(String...lines) throws IOException { File tmpFile = File.createTempFile("montySolr-unittest", null); if (lines.length > 0) { //FileOutputStream fi = FileUtils.openOutputStream(tmpFile); @@ -130,17 +130,17 @@ public File createTempFile(String...lines) throws IOException { return tmpFile; } - public File duplicateFile(File origFile) throws IOException { + public static File duplicateFile(File origFile) throws IOException { File tmpFile = createTempFile(); FileUtils.copyFile(origFile, tmpFile); return tmpFile; } - public int replaceInFile(File target, String toFind, String replacement) throws IOException { + public static int replaceInFile(File target, String toFind, String replacement) throws IOException { return replaceInFile(target, Pattern.compile(toFind), replacement); } - public int replaceInFile(File target, Pattern toFind, String replacement) throws IOException { + public static int replaceInFile(File target, Pattern toFind, String replacement) throws IOException { int matches = 0; String contents = FileUtils.readFileToString(target); Matcher matcher = toFind.matcher(contents); @@ -153,7 +153,7 @@ public int replaceInFile(File target, Pattern toFind, String replacement) throws return matches; } - public File duplicateModify(File sourceFile, String...searchReplace) { + public static File duplicateModify(File sourceFile, String...searchReplace) { assert searchReplace.length%2==0; File newFile; try {