Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 54FB5200C59 for ; Mon, 17 Apr 2017 15:55:29 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 5366A160B9C; Mon, 17 Apr 2017 13:55:29 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id A5819160BB0 for ; Mon, 17 Apr 2017 15:55:27 +0200 (CEST) Received: (qmail 19555 invoked by uid 500); 17 Apr 2017 13:55:26 -0000 Mailing-List: contact commits-help@lucenenet.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: lucene-net-dev@lucenenet.apache.org Delivered-To: mailing list commits@lucenenet.apache.org Received: (qmail 19468 invoked by uid 99); 17 Apr 2017 13:55:26 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Apr 2017 13:55:26 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 25836DFC70; Mon, 17 Apr 2017 13:55:26 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: nightowl888@apache.org To: commits@lucenenet.apache.org Date: Mon, 17 Apr 2017 13:55:28 -0000 Message-Id: <5ff30cfdcb23483897fbab5736f8885e@git.apache.org> In-Reply-To: <23543cc858a54b0d8dba6feb5b7464a1@git.apache.org> References: <23543cc858a54b0d8dba6feb5b7464a1@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [3/7] lucenenet git commit: SWEEP: Moved BreakIterator-dependent functionality to a common Lucene.Net.Icu library so we can manage the icu.net dependency from one place and not make the majority of the users deal with it when they don't need to archived-at: Mon, 17 Apr 2017 13:55:29 -0000 http://git-wip-us.apache.org/repos/asf/lucenenet/blob/b1fdcca3/src/Lucene.Net.Tests.Icu/Support/TestApiConsistency.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Tests.Icu/Support/TestApiConsistency.cs b/src/Lucene.Net.Tests.Icu/Support/TestApiConsistency.cs new file mode 100644 index 0000000..1a143eb --- /dev/null +++ b/src/Lucene.Net.Tests.Icu/Support/TestApiConsistency.cs @@ -0,0 +1,126 @@ +using Lucene.Net.Attributes; +using NUnit.Framework; +using System; + +namespace Lucene.Net.Support +{ + /// + /// LUCENENET specific tests for ensuring API conventions are followed + /// + public class TestApiConsistency : ApiScanTestBase + { + [Test, LuceneNetSpecific] + [TestCase(typeof(Lucene.Net.Search.Highlight.DefaultEncoder))] + public override void TestProtectedFieldNames(Type typeFromTargetAssembly) + { + base.TestProtectedFieldNames(typeFromTargetAssembly); + } + + [Test, LuceneNetSpecific] + [TestCase(typeof(Lucene.Net.Search.Highlight.DefaultEncoder))] + public override void TestPrivateFieldNames(Type typeFromTargetAssembly) + { + base.TestPrivateFieldNames(typeFromTargetAssembly); + } + + [Test, LuceneNetSpecific] + [TestCase(typeof(Lucene.Net.Search.Highlight.DefaultEncoder))] + public override void TestPublicFields(Type typeFromTargetAssembly) + { + base.TestPublicFields(typeFromTargetAssembly); + } + + [Test, LuceneNetSpecific] + [TestCase(typeof(Lucene.Net.Search.Highlight.DefaultEncoder))] + public override void TestMethodParameterNames(Type typeFromTargetAssembly) + { + base.TestMethodParameterNames(typeFromTargetAssembly); + } + + [Test, LuceneNetSpecific] + [TestCase(typeof(Lucene.Net.Search.Highlight.DefaultEncoder))] + public override void TestInterfaceNames(Type typeFromTargetAssembly) + { + base.TestInterfaceNames(typeFromTargetAssembly); + } + + [Test, LuceneNetSpecific] + [TestCase(typeof(Lucene.Net.Search.Highlight.DefaultEncoder))] + public override void TestClassNames(Type typeFromTargetAssembly) + { + base.TestClassNames(typeFromTargetAssembly); + } + + [Test, LuceneNetSpecific] + [TestCase(typeof(Lucene.Net.Search.Highlight.DefaultEncoder))] + public override void TestForPropertiesWithNoGetter(Type typeFromTargetAssembly) + { + base.TestForPropertiesWithNoGetter(typeFromTargetAssembly); + } + + [Test, LuceneNetSpecific] + [TestCase(typeof(Lucene.Net.Search.Highlight.DefaultEncoder))] + public override void TestForPropertiesThatReturnArray(Type typeFromTargetAssembly) + { + base.TestForPropertiesThatReturnArray(typeFromTargetAssembly); + } + + [Test, LuceneNetSpecific] + [TestCase(typeof(Lucene.Net.Search.Highlight.DefaultEncoder))] + public override void TestForMethodsThatReturnWritableArray(Type typeFromTargetAssembly) + { + base.TestForMethodsThatReturnWritableArray(typeFromTargetAssembly); + } + + [Test, LuceneNetSpecific] + [TestCase(typeof(Lucene.Net.Search.Highlight.DefaultEncoder))] + public override void TestForPublicMembersContainingComparer(Type typeFromTargetAssembly) + { + base.TestForPublicMembersContainingComparer(typeFromTargetAssembly); + } + + [Test, LuceneNetSpecific] + [TestCase(typeof(Lucene.Net.Search.Highlight.DefaultEncoder))] + public override void TestForPublicMembersNamedSize(Type typeFromTargetAssembly) + { + base.TestForPublicMembersNamedSize(typeFromTargetAssembly); + } + + [Test, LuceneNetSpecific] + [TestCase(typeof(Lucene.Net.Search.Highlight.DefaultEncoder))] + public override void TestForPublicMembersContainingNonNetNumeric(Type typeFromTargetAssembly) + { + base.TestForPublicMembersContainingNonNetNumeric(typeFromTargetAssembly); + } + + [Test, LuceneNetSpecific] + [TestCase(typeof(Lucene.Net.Search.Highlight.DefaultEncoder))] + public override void TestForTypesContainingNonNetNumeric(Type typeFromTargetAssembly) + { + base.TestForTypesContainingNonNetNumeric(typeFromTargetAssembly); + } + + [Test, LuceneNetSpecific] + [TestCase(typeof(Lucene.Net.Search.Highlight.DefaultEncoder))] + public override void TestForPublicMembersWithNullableEnum(Type typeFromTargetAssembly) + { + base.TestForPublicMembersWithNullableEnum(typeFromTargetAssembly); + } + + // LUCENENET NOTE: This test is only for identifying members who were changed from + // ICollection, IList or ISet to IEnumerable during the port (that should be changed back) + //[Test, LuceneNetSpecific] + //[TestCase(typeof(Lucene.Net.Search.Highlight.DefaultEncoder))] + //public override void TestForMembersAcceptingOrReturningIEnumerable(Type typeFromTargetAssembly) + //{ + // base.TestForMembersAcceptingOrReturningIEnumerable(typeFromTargetAssembly); + //} + + [Test, LuceneNetSpecific] + [TestCase(typeof(Lucene.Net.Search.Highlight.DefaultEncoder))] + public override void TestForMembersAcceptingOrReturningListOrDictionary(Type typeFromTargetAssembly) + { + base.TestForMembersAcceptingOrReturningListOrDictionary(typeFromTargetAssembly); + } + } +} http://git-wip-us.apache.org/repos/asf/lucenenet/blob/b1fdcca3/src/Lucene.Net.Tests.Icu/Support/TestExceptionSerialization.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Tests.Icu/Support/TestExceptionSerialization.cs b/src/Lucene.Net.Tests.Icu/Support/TestExceptionSerialization.cs new file mode 100644 index 0000000..ad84905 --- /dev/null +++ b/src/Lucene.Net.Tests.Icu/Support/TestExceptionSerialization.cs @@ -0,0 +1,54 @@ +#if FEATURE_SERIALIZABLE +using Lucene.Net.Attributes; +using NUnit.Framework; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Lucene.Net.Support +{ + /* + * 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. + */ + + [TestFixture] + public class TestExceptionSerialization : ExceptionSerializationTestBase + { + public static IEnumerable ExceptionTestData + { + get + { + var exceptionTypes = typeof(Lucene.Net.Search.Highlight.DefaultEncoder).Assembly.GetTypes().Where(t => typeof(Exception).IsAssignableFrom(t)).Cast(); + + // If the assembly has no exceptions, just provide Exception so the test will pass + if (!exceptionTypes.Any()) + { + return new Type[] { typeof(Exception) }; + } + + return exceptionTypes; + } + } + + [Test, LuceneNetSpecific] + public void AllExceptionsInLuceneNamespaceCanSerialize([ValueSource("ExceptionTestData")]Type luceneException) + { + var instance = TryInstantiate(luceneException); + Assert.That(TypeCanSerialize(instance), string.Format("Unable to serialize {0}", luceneException.FullName)); + } + } +} +#endif \ No newline at end of file http://git-wip-us.apache.org/repos/asf/lucenenet/blob/b1fdcca3/src/Lucene.Net.Tests.Icu/Support/TestIcuBreakIterator.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Tests.Icu/Support/TestIcuBreakIterator.cs b/src/Lucene.Net.Tests.Icu/Support/TestIcuBreakIterator.cs new file mode 100644 index 0000000..2bc790c --- /dev/null +++ b/src/Lucene.Net.Tests.Icu/Support/TestIcuBreakIterator.cs @@ -0,0 +1,421 @@ +#if FEATURE_BREAKITERATOR +using Lucene.Net.Support; +using Lucene.Net.Util; +using NUnit.Framework; +using System; +using System.Globalization; + +namespace Lucene.Net.Support +{ + /* + * 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. + */ + + public class TestIcuBreakIterator : LuceneTestCase + { + static readonly String TEXT = + "Apache Lucene(TM) is a high-performance, full-featured text search engine library written entirely in Java."; + + static readonly String SENTENCE_TEXT = + "Apache Lucene(TM) is a high-performance, full-featured text search engine library written entirely in Java. " + + "It is a technology suitable for nearly any application that requires" + + "full-text search, especially cross-platform. Apache Lucene is an open source project available for free download. " + + "Lucene makes finding things easy. Lucene is powerful. Lucene is exciting. Lucene is cool. Where be Lucene now?"; + + private BreakIterator GetWordInstance(CultureInfo locale) + { + //return new WordBreakIterator(locale); + return new IcuBreakIterator(Icu.BreakIterator.UBreakIteratorType.WORD, locale) { EnableHacks = true }; + } + + private BreakIterator GetSentenceInstance(CultureInfo locale) + { + return new IcuBreakIterator(Icu.BreakIterator.UBreakIteratorType.SENTENCE, locale); + } + + [Test] + public void TestWordIteration() + { + BreakIterator bi = GetWordInstance(CultureInfo.InvariantCulture); + bi.SetText(TEXT); + + int temp; + temp = bi.Current; + Console.WriteLine(temp); + assertEquals(0, temp); + + temp = bi.Next(); + Console.WriteLine(temp); + assertEquals(6, temp); + + temp = bi.Current; + Console.WriteLine(temp); + assertEquals(6, temp); + + temp = bi.Next(); + Console.WriteLine(temp); + assertEquals(7, temp); + temp = bi.Current; + Console.WriteLine(temp); + assertEquals(7, temp); + temp = bi.Next(); + Console.WriteLine(temp); + assertEquals(13, temp); + temp = bi.Current; + Console.WriteLine(temp); + assertEquals(13, temp); + temp = bi.Next(); + Console.WriteLine(temp); + assertEquals(14, temp); + temp = bi.Next(); + Console.WriteLine(temp); + assertEquals(16, temp); + temp = bi.Next(); + Console.WriteLine(temp); + assertEquals(17, temp); + temp = bi.Current; + Console.WriteLine(temp); + assertEquals(17, temp); + + temp = bi.Previous(); + Console.WriteLine(temp); + assertEquals(16, temp); + temp = bi.Current; + Console.WriteLine(temp); + assertEquals(16, temp); + temp = bi.Next(); + Console.WriteLine(temp); + assertEquals(17, temp); + temp = bi.Current; + Console.WriteLine(temp); + assertEquals(17, temp); + temp = bi.Next(); + Console.WriteLine(temp); + assertEquals(18, temp); + + temp = bi.Last(); + Console.WriteLine(temp); + assertEquals(107, temp); + temp = bi.Current; + Console.WriteLine(temp); + assertEquals(107, temp); + temp = bi.Next(); + Console.WriteLine(temp); + assertEquals(-1, temp); + temp = bi.Current; + Console.WriteLine(temp); + assertEquals(107, temp); + temp = bi.Previous(); + Console.WriteLine(temp); + assertEquals(106, temp); + temp = bi.Current; + Console.WriteLine(temp); + assertEquals(106, temp); + temp = bi.Previous(); + Console.WriteLine(temp); + assertEquals(102, temp); + temp = bi.Current; + Console.WriteLine(temp); + assertEquals(102, temp); + temp = bi.Previous(); + Console.WriteLine(temp); + assertEquals(101, temp); + temp = bi.Current; + Console.WriteLine(temp); + assertEquals(101, temp); + } + + [Test] + public void TestWordFollowing() + { + BreakIterator bi = GetWordInstance(CultureInfo.InvariantCulture); + bi.SetText(TEXT); + + int temp; + temp = bi.Current; + Console.WriteLine(temp); + assertEquals(0, temp); + temp = bi.Next(); + Console.WriteLine(temp); + assertEquals(6, temp); + + + temp = bi.Following(70); + Console.WriteLine(temp); + assertEquals(73, temp); + temp = bi.Current; + Console.WriteLine(temp); + assertEquals(73, temp); + temp = bi.Next(); + Console.WriteLine(temp); + assertEquals(74, temp); + temp = bi.Current; + Console.WriteLine(temp); + assertEquals(74, temp); + temp = bi.Next(); + Console.WriteLine(temp); + assertEquals(81, temp); + temp = bi.Following(107); // Test the final boundary + Console.WriteLine(temp); + assertEquals(-1, temp); + temp = bi.Next(); + Console.WriteLine(temp); + assertEquals(-1, temp); + temp = bi.Current; + Console.WriteLine(temp); + assertEquals(107, temp); + + temp = bi.Following(66); // Test exactly on a boundary position + Console.WriteLine(temp); + assertEquals(67, temp); + temp = bi.Next(); + Console.WriteLine(temp); + assertEquals(73, temp); + temp = bi.Current; + Console.WriteLine(temp); + assertEquals(73, temp); + + temp = bi.Following(0); // Test the first boundary + Console.WriteLine(temp); + assertEquals(6, temp); + temp = bi.Next(); + Console.WriteLine(temp); + assertEquals(7, temp); + temp = bi.Current; + Console.WriteLine(temp); + assertEquals(7, temp); + + } + + [Test] + public void TestWordPreceding() + { + BreakIterator bi = GetWordInstance(CultureInfo.InvariantCulture); + bi.SetText(TEXT); + + int temp; + temp = bi.Current; + Console.WriteLine(temp); + assertEquals(0, temp); + temp = bi.Next(); + Console.WriteLine(temp); + assertEquals(6, temp); + + + temp = bi.Preceding(70); + Console.WriteLine(temp); + assertEquals(67, temp); + temp = bi.Current; + Console.WriteLine(temp); + assertEquals(67, temp); + temp = bi.Next(); + Console.WriteLine(temp); + assertEquals(73, temp); + temp = bi.Current; + Console.WriteLine(temp); + assertEquals(73, temp); + temp = bi.Next(); + Console.WriteLine(temp); + assertEquals(74, temp); + temp = bi.Preceding(107); // Test the final boundary + Console.WriteLine(temp); + assertEquals(106, temp); + temp = bi.Next(); + Console.WriteLine(temp); + assertEquals(107, temp); + temp = bi.Current; + Console.WriteLine(temp); + assertEquals(107, temp); + + temp = bi.Preceding(66); // Test exactly on a boundary position + Console.WriteLine(temp); + assertEquals(60, temp); + temp = bi.Previous(); + Console.WriteLine(temp); + assertEquals(59, temp); + temp = bi.Current; + Console.WriteLine(temp); + assertEquals(59, temp); + + temp = bi.Preceding(0); // Test the first boundary + Console.WriteLine(temp); + assertEquals(-1, temp); + temp = bi.Current; + Console.WriteLine(temp); + assertEquals(0, temp); + temp = bi.Next(); + Console.WriteLine(temp); + assertEquals(6, temp); + temp = bi.Current; + Console.WriteLine(temp); + assertEquals(6, temp); + + } + + [Test] + public void TestWordNextWithInt() + { + BreakIterator bi = GetWordInstance(CultureInfo.InvariantCulture); + bi.SetText(TEXT); + + int temp; + temp = bi.Current; + Console.WriteLine(temp); + assertEquals(0, temp); + temp = bi.Next(); + Console.WriteLine(temp); + assertEquals(6, temp); + + + temp = bi.Next(10); + Console.WriteLine(temp); + assertEquals(23, temp); + temp = bi.Current; + Console.WriteLine(temp); + assertEquals(23, temp); + temp = bi.Next(); + Console.WriteLine(temp); + assertEquals(39, temp); + temp = bi.Current; + Console.WriteLine(temp); + assertEquals(39, temp); + temp = bi.Next(); + Console.WriteLine(temp); + assertEquals(40, temp); + temp = bi.Next(-8); // Test going backward + Console.WriteLine(temp); + assertEquals(16, temp); // Magically, this is correct (from position 28 back 8 places) in Java, even though its start position is wrong + temp = bi.Next(); + Console.WriteLine(temp); + assertEquals(17, temp); + temp = bi.Current; + Console.WriteLine(temp); + assertEquals(17, temp); + + + temp = bi.Next(107); // Go past the last boundary + Console.WriteLine(temp); + assertEquals(-1, temp); + temp = bi.Current; + Console.WriteLine(temp); + assertEquals(107, temp); + temp = bi.Next(-107); // Go past the first boundary + Console.WriteLine(temp); + assertEquals(-1, temp); + temp = bi.Current; + Console.WriteLine(temp); + assertEquals(0, temp); + + } + + [Test] + public void TestSentenceIteration() + { + BreakIterator bi = GetSentenceInstance(CultureInfo.InvariantCulture); + bi.SetText(SENTENCE_TEXT); + + int temp; + temp = bi.Current; + Console.WriteLine(temp); + assertEquals(0, temp); + + temp = bi.Next(); + Console.WriteLine(temp); + assertEquals(108, temp); + + temp = bi.Current; + Console.WriteLine(temp); + assertEquals(108, temp); + + temp = bi.Next(); + Console.WriteLine(temp); + assertEquals(221, temp); + temp = bi.Current; + Console.WriteLine(temp); + assertEquals(221, temp); + temp = bi.Next(); + Console.WriteLine(temp); + assertEquals(290, temp); + temp = bi.Current; + Console.WriteLine(temp); + assertEquals(290, temp); + temp = bi.Next(); + Console.WriteLine(temp); + assertEquals(324, temp); + temp = bi.Next(); + Console.WriteLine(temp); + assertEquals(344, temp); + temp = bi.Next(); + Console.WriteLine(temp); + assertEquals(364, temp); + temp = bi.Current; + Console.WriteLine(temp); + assertEquals(364, temp); + + temp = bi.Previous(); + Console.WriteLine(temp); + assertEquals(344, temp); + temp = bi.Current; + Console.WriteLine(temp); + assertEquals(344, temp); + temp = bi.Next(); + Console.WriteLine(temp); + assertEquals(364, temp); + temp = bi.Current; + Console.WriteLine(temp); + assertEquals(364, temp); + temp = bi.Next(); + Console.WriteLine(temp); + assertEquals(380, temp); + + temp = bi.First(); + Console.WriteLine(temp); + assertEquals(0, temp); + + temp = bi.Last(); + Console.WriteLine(temp); + assertEquals(400, temp); + temp = bi.Current; + Console.WriteLine(temp); + assertEquals(400, temp); + temp = bi.Next(); + Console.WriteLine(temp); + assertEquals(-1, temp); + temp = bi.Current; + Console.WriteLine(temp); + assertEquals(400, temp); + temp = bi.Previous(); + Console.WriteLine(temp); + assertEquals(380, temp); + temp = bi.Current; + Console.WriteLine(temp); + assertEquals(380, temp); + temp = bi.Previous(); + Console.WriteLine(temp); + assertEquals(364, temp); + temp = bi.Current; + Console.WriteLine(temp); + assertEquals(364, temp); + temp = bi.Previous(); + Console.WriteLine(temp); + assertEquals(344, temp); + temp = bi.Current; + Console.WriteLine(temp); + assertEquals(344, temp); + } + } +} +#endif \ No newline at end of file http://git-wip-us.apache.org/repos/asf/lucenenet/blob/b1fdcca3/src/Lucene.Net.Tests.Icu/project.json ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Tests.Icu/project.json b/src/Lucene.Net.Tests.Icu/project.json new file mode 100644 index 0000000..f9b0fe3 --- /dev/null +++ b/src/Lucene.Net.Tests.Icu/project.json @@ -0,0 +1,67 @@ +{ + "version": "4.8.0", + "dependencies": { + "dotnet-test-nunit": "3.4.0-beta-3", + "Lucene.Net": "4.8.0", + "Lucene.Net.Analysis.Common": "4.8.0", + "Lucene.Net.Highlighter": "4.8.0", + "Lucene.Net.Icu": "4.8.0", + "Lucene.Net.TestFramework": "4.8.0", + "Lucene.Net.Tests.Analysis.Common": "4.8.0", + "NUnit": "3.5.0" + }, + "buildOptions": { + "debugType": "portable", + "compile": { + "includeFiles": [ + "../CommonAssemblyInfo.cs", + "../Lucene.Net.Tests.Analysis.Common/Analysis/Th/TestThaiAnalyzer.cs", + "../Lucene.Net.Tests.Analysis.Common/Analysis/Th/TestThaiTokenizerFactory.cs", + "../Lucene.Net.Tests.Analysis.Common/Analysis/Th/TestThaiWordFilterFactory.cs", + "../Lucene.Net.Tests.Analysis.Common/Analysis/Util/TestCharArrayIterator.cs", + "../Lucene.Net.Tests.Analysis.Common/Analysis/Util/TestSegmentingTokenizerBase.cs", + "../Lucene.Net.Tests.Highlighter/PostingsHighlight/TestMultiTermHighlighting.cs", + "../Lucene.Net.Tests.Highlighter/PostingsHighlight/TestPostingsHighlighter.cs", + "../Lucene.Net.Tests.Highlighter/PostingsHighlight/TestPostingsHighlighterRanking.cs", + "../Lucene.Net.Tests.Highlighter/PostingsHighlight/TestWholeBreakIterator.cs", + "../Lucene.Net.Tests.Highlighter/VectorHighlight/BreakIteratorBoundaryScannerTest.cs" + ] + }, + "embed": { + "includeFiles": [ + "Search/PostingsHighlight/CambridgeMA.utf8" + ] + } + }, + "testRunner": "nunit", + "frameworks": { + "netcoreapp1.0": { + "imports": "dnxcore50", + "buildOptions": { + "define": [ "NETSTANDARD", "FEATURE_BREAKITERATOR" ], + "compile": { + "excludeFiles": [ + "Support/TestApiConsistency.cs" + ] + } + }, + "dependencies": { + "Microsoft.NETCore.App": { + "type": "platform", + "version": "1.0.1" + }, + "System.Xml.XmlDocument": "4.0.1" + } + }, + "net451": { + "buildOptions": { + "define": [ "FEATURE_BREAKITERATOR", "FEATURE_SERIALIZABLE" ] + } + } + }, + + "runtimes": { + "win7-x86": {}, + "win7-x64": {} + } +} http://git-wip-us.apache.org/repos/asf/lucenenet/blob/b1fdcca3/src/Lucene.Net/Lucene.Net.csproj ---------------------------------------------------------------------- diff --git a/src/Lucene.Net/Lucene.Net.csproj b/src/Lucene.Net/Lucene.Net.csproj index 1e3f970..69de9ee 100644 --- a/src/Lucene.Net/Lucene.Net.csproj +++ b/src/Lucene.Net/Lucene.Net.csproj @@ -599,7 +599,6 @@ - @@ -611,7 +610,6 @@ - @@ -668,7 +666,6 @@ - http://git-wip-us.apache.org/repos/asf/lucenenet/blob/b1fdcca3/src/Lucene.Net/Properties/AssemblyInfo.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net/Properties/AssemblyInfo.cs b/src/Lucene.Net/Properties/AssemblyInfo.cs index b558f6a..2acfe37 100644 --- a/src/Lucene.Net/Properties/AssemblyInfo.cs +++ b/src/Lucene.Net/Properties/AssemblyInfo.cs @@ -55,10 +55,12 @@ using System.Runtime.CompilerServices; [assembly: InternalsVisibleTo("Lucene.Net.Tests")] [assembly: InternalsVisibleTo("Lucene.Net.TestFramework")] [assembly: InternalsVisibleTo("Lucene.Net.Highlighter")] // For Automaton +[assembly: InternalsVisibleTo("Lucene.Net.Icu")] // For Automaton [assembly: InternalsVisibleTo("Lucene.Net.Misc")] [assembly: InternalsVisibleTo("Lucene.Net.Suggest")] // For Automaton [assembly: InternalsVisibleTo("Lucene.Net.Tests.Analysis.Common")] // For Automaton [assembly: InternalsVisibleTo("Lucene.Net.Tests.Highlighter")] // For Automaton +[assembly: InternalsVisibleTo("Lucene.Net.Tests.Icu")] // For Analysis.Util.TestSegmentingTokenizerBase [assembly: InternalsVisibleTo("Lucene.Net.Tests.Misc")] [assembly: InternalsVisibleTo("Lucene.Net.Tests.QueryParser")] http://git-wip-us.apache.org/repos/asf/lucenenet/blob/b1fdcca3/src/Lucene.Net/Support/BreakIterator.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net/Support/BreakIterator.cs b/src/Lucene.Net/Support/BreakIterator.cs deleted file mode 100644 index ded1c9c..0000000 --- a/src/Lucene.Net/Support/BreakIterator.cs +++ /dev/null @@ -1,231 +0,0 @@ -#if FEATURE_BREAKITERATOR -using System; - -namespace Lucene.Net.Support -{ - /// - /// The BreakIterator class implements methods for finding - /// the location of boundaries in text. Instances of BreakIterator - /// maintain a current position and scan over text - /// returning the index of characters where boundaries occur. - /// - public abstract class BreakIterator -#if FEATURE_CLONEABLE - : ICloneable -#endif - { - /// - /// Constructor. BreakIterator is stateless and has no default behavior. - /// - protected BreakIterator() - { - } - - /// - /// Create a copy of this iterator - /// - /// A member-wise copy of this - public object Clone() - { - return MemberwiseClone(); - } - - /// - /// DONE is returned by Previous(), Next(), Next(int), Preceding(int) - /// and Following(int) when either the first or last text boundary has been - /// reached. - /// - public static readonly int DONE = -1; - - /// - /// Returns the first boundary. The iterator's current position is set - /// to the first text boundary. - /// - /// The character index of the first text boundary - public abstract int First(); - - /// - /// Returns the last boundary. The iterator's current position is set - /// to the last text boundary. - /// - /// The character index of the last text boundary. - public abstract int Last(); - - /// - /// Returns the nth boundary from the current boundary. If either - /// the first or last text boundary has been reached, it returns - /// and the current position is set to either - /// the first or last text boundary depending on which one is reached. Otherwise, - /// the iterator's current position is set to the new boundary. - /// For example, if the iterator's current position is the mth text boundary - /// and three more boundaries exist from the current boundary to the last text - /// boundary, the Next(2) call will return m + 2. The new text position is set - /// to the (m + 2)th text boundary. A Next(4) call would return - /// and the last text boundary would become the - /// new text position. - /// - /// - /// which boundary to return. A value of 0 - /// does nothing. Negative values move to previous boundaries - /// and positive values move to later boundaries. - /// - /// - /// The character index of the nth boundary from the current position - /// or if either first or last text boundary - /// has been reached. - /// - public abstract int Next(int n); - - /// - /// Returns the boundary following the current boundary. If the current boundary - /// is the last text boundary, it returns BreakIterator.DONE and - /// the iterator's current position is unchanged. Otherwise, the iterator's - /// current position is set to the boundary following the current boundary. - /// - /// - /// The character index of the next text boundary or - /// if the current boundary is the last text - /// boundary. - /// Equivalent to Next(1). - /// - /// - public abstract int Next(); - - /// - /// Returns the boundary preceding the current boundary. If the current boundary - /// is the first text boundary, it returns BreakIterator.DONE and - /// the iterator's current position is unchanged. Otherwise, the iterator's - /// current position is set to the boundary preceding the current boundary. - /// - /// - /// The character index of the previous text boundary or - /// if the current boundary is the first text - /// boundary. - /// - public abstract int Previous(); - - /// - /// Returns the first boundary following the specified character offset. If the - /// specified offset equals to the last text boundary, it returns - /// and the iterator's current position is unchanged. - /// Otherwise, the iterator's current position is set to the returned boundary. - /// The value returned is always greater than the offset or the value - /// . - /// - /// the character offset to begin scanning. - /// - /// The first boundary after the specified offset or - /// if the last text boundary is passed in - /// as the offset. - /// - /// - /// if the specified offset is less than - /// the first text boundary or greater than the last text boundary. - /// - public abstract int Following(int offset); - - /// - /// Returns the last boundary preceding the specified character offset. If the - /// specified offset equals to the first text boundary, it returns - /// and the iterator's current position is unchanged. - /// Otherwise, the iterator's current position is set to the returned boundary. - /// The value returned is always less than the offset or the value - /// . - /// - /// the character offset to begin scanning. - /// - /// The last boundary before the specified offset or - /// if the first text boundary is passed in - /// as the offset. - /// - public abstract int Preceding(int offset); - //{ - // // NOTE: This implementation is here solely because we can't add new - // // abstract methods to an existing class. There is almost ALWAYS a - // // better, faster way to do this. - // int pos = Following(offset); - // while (pos >= offset && pos != DONE) - // { - // pos = Previous(); - // } - // return pos; - //} - - /// - /// Returns true if the specified character offset is a text boundary. - /// - /// the character offset to check. - /// true if "offset" is a boundary position, false otherwise. - /// - /// if the specified offset is less than - /// the first text boundary or greater than the last text boundary. - /// - public abstract bool IsBoundary(int offset); - //{ - // // NOTE: This implementation probably is wrong for most situations - // // because it fails to take into account the possibility that a - // // CharacterIterator passed to setText() may not have a begin offset - // // of 0. But since the abstract BreakIterator doesn't have that - // // knowledge, it assumes the begin offset is 0. If you subclass - // // BreakIterator, copy the SimpleTextBoundary implementation of this - // // function into your subclass. [This should have been abstract at - // // this level, but it's too late to fix that now.] - // if (offset == 0) - // { - // return true; - // } - // int boundary = Following(offset - 1); - // if (boundary == DONE) - // { - // throw new ArgumentException(); - // } - // return boundary == offset; - //} - - /// - /// Returns character index of the text boundary that was most - /// recently returned by Next(), Next(int), Previous(), First(), Last(), - /// Following(int) or Preceding(int). If any of these methods returns - /// because either first or last text boundary - /// has been reached, it returns the first or last text boundary depending on - /// which one is reached. - /// - /// - /// The text boundary returned from the above methods, first or last - /// text boundary. - /// - /// - /// - /// - /// - /// - /// - /// - public abstract int Current { get; } - - /// - /// Get the text being scanned - /// - /// the text being scanned - //public abstract CharacterIterator GetText(); - public abstract string Text { get; } - - /// - /// Set a new text string to be scanned. The current scan - /// position is reset to First(). - /// - /// new text to scan. - public virtual void SetText(string newText) - { - SetText(new StringCharacterIterator(newText)); - } - - /// - /// Set a new text string to be scanned. The current scan - /// position is reset to First(). - /// - /// new text to scan. - public abstract void SetText(CharacterIterator newText); - } -} -#endif \ No newline at end of file http://git-wip-us.apache.org/repos/asf/lucenenet/blob/b1fdcca3/src/Lucene.Net/Support/CharacterIterator.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net/Support/CharacterIterator.cs b/src/Lucene.Net/Support/CharacterIterator.cs deleted file mode 100644 index 0c81629..0000000 --- a/src/Lucene.Net/Support/CharacterIterator.cs +++ /dev/null @@ -1,50 +0,0 @@ -#if FEATURE_BREAKITERATOR -using System; - -namespace Lucene.Net.Support -{ - /* - * 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. - */ - - public abstract class CharacterIterator - { - public static readonly char DONE = '\uFFFF'; - - public abstract char Current { get; } - - public abstract char First(); - - public abstract char Last(); - - public abstract char Next(); - - public abstract char Previous(); - - public abstract char SetIndex(int position); - - public abstract int BeginIndex { get; } - - public abstract int EndIndex { get; } - - public abstract int Index { get; } - - public abstract object Clone(); - - public abstract string GetTextAsString(); - } -} -#endif \ No newline at end of file http://git-wip-us.apache.org/repos/asf/lucenenet/blob/b1fdcca3/src/Lucene.Net/Support/StringCharacterIterator.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net/Support/StringCharacterIterator.cs b/src/Lucene.Net/Support/StringCharacterIterator.cs deleted file mode 100644 index a91e49a..0000000 --- a/src/Lucene.Net/Support/StringCharacterIterator.cs +++ /dev/null @@ -1,232 +0,0 @@ -#if FEATURE_BREAKITERATOR -/* - * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved - * (C) Copyright IBM Corp. 1996 - 1998 - All Rights Reserved - * - * The original version of this source code and documentation - * is copyrighted and owned by Taligent, Inc., a wholly-owned - * subsidiary of IBM. These materials are provided under terms - * of a License Agreement between Taligent and Sun. This technology - * is protected by multiple US and International patents. - * - * This notice and attribution to Taligent may not be removed. - * Taligent is a registered trademark of Taligent, Inc. - * - */ - -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Lucene.Net.Support -{ - /// - /// implements the - /// protocol for a . - /// The class iterates over the - /// entire . - /// - /// - public class StringCharacterIterator : CharacterIterator - { - private string text; - private int begin; - private int end; - // invariant: begin <= pos <= end - private int pos; - - - public StringCharacterIterator(string text) - : this(text, 0) - { - } - - public StringCharacterIterator(string text, int pos) - : this(text, 0, text.Length, pos) - { - } - - public StringCharacterIterator(string text, int begin, int end, int pos) - { - if (text == null) - throw new ArgumentNullException("text"); - this.text = text; - - if (begin < 0 || begin > end || end > text.Length) - throw new ArgumentException("Invalid substring range"); - - if (pos < begin || pos > end) - throw new ArgumentException("Invalid position"); - - this.begin = begin; - this.end = end; - this.pos = pos; - } - - public void SetText(string text) - { - if (text == null) - throw new ArgumentNullException("text"); - this.text = text; - this.begin = 0; - this.end = text.Length; - this.pos = 0; - } - - public override char First() - { - pos = begin; - return Current; - } - - public override char Last() - { - if (end != begin) - { - pos = end - 1; - } - else - { - pos = end; - } - return Current; - } - - public override char SetIndex(int position) - { - if (position < begin || position > end) - throw new ArgumentException("Invalid index"); - pos = position; - return Current; - } - - public override char Current - { - get - { - if (pos >= begin && pos < end) - { - return text[pos]; - } - else - { - return DONE; - } - } - } - - public override char Next() - { - if (pos < end - 1) - { - pos++; - return text[pos]; - } - else - { - pos = end; - return DONE; - } - } - - public override char Previous() - { - if (pos > begin) - { - pos--; - return text[pos]; - } - else - { - return DONE; - } - } - - - public override int BeginIndex - { - get - { - return begin; - } - } - - public override int EndIndex - { - get - { - return end; - } - } - - public override int Index - { - get - { - return pos; - } - } - - public override string GetTextAsString() - { - return text; - } - - public override bool Equals(object obj) - { - if (this == obj) - return true; - if (!(obj is StringCharacterIterator)) - return false; - - StringCharacterIterator that = (StringCharacterIterator)obj; - - if (GetHashCode() != that.GetHashCode()) - return false; - if (!text.Equals(that.text, StringComparison.Ordinal)) - return false; - if (pos != that.pos || begin != that.begin || end != that.end) - return false; - return true; - } - - public override int GetHashCode() - { - return base.GetHashCode() ^ pos ^ begin ^ end; - } - - public override object Clone() - { - return MemberwiseClone(); - } - } -} -#endif