You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by ni...@apache.org on 2017/07/11 07:42:33 UTC
[08/22] lucenenet git commit: lucene-ci: Added additional tests and
fixed bugs
lucene-ci: Added additional tests and fixed bugs
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/ea6ec0fa
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/ea6ec0fa
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/ea6ec0fa
Branch: refs/heads/master
Commit: ea6ec0fa629d8b6899819e395da66a813ed8a6e0
Parents: 3d11d5d
Author: Shad Storhaug <sh...@shadstorhaug.com>
Authored: Sat Jul 8 12:47:37 2017 +0700
Committer: Shad Storhaug <sh...@shadstorhaug.com>
Committed: Sat Jul 8 12:47:37 2017 +0700
----------------------------------------------------------------------
.../Commands/Analysis/AnalysisCommandTest.cs | 2 +-
.../AnalysisStempelCompileStemsCommandTest.cs | 3 +-
.../AnalysisStempelPatchStemsCommandTest.cs | 3 +-
.../Commands/CommandTestCase.cs | 81 ++++++++++----------
.../Demo/DemoAssociationsFacetsCommandTest.cs | 40 ++++++++++
.../Commands/Demo/DemoCommandTest.cs | 2 +-
.../Demo/DemoDistanceFacetsCommandTest.cs | 41 ++++++++++
...emoExpressionAggregationFacetsCommandTest.cs | 42 ++++++++++
.../Commands/Demo/DemoIndexFilesCommandTest.cs | 61 +++++++++++++++
.../DemoMultiCategoryListsFacetsCommandTest.cs | 40 ++++++++++
.../Commands/Demo/DemoRangeFacetsCommandTest.cs | 40 ++++++++++
.../Commands/Demo/DemoSearchFilesCommandTest.cs | 64 ++++++++++++++++
.../Demo/DemoSimpleFacetsCommandTest.cs | 40 ++++++++++
.../DemoSimpleSortedSetFacetsCommandTest.cs | 40 ++++++++++
.../Commands/Index/IndexCheckCommandTest.cs | 47 +-----------
.../Commands/Index/IndexCommandTest.cs | 4 +-
.../Commands/Index/IndexCopySegmentsTest.cs | 3 +-
.../Index/IndexDeleteSegmentsCommandTest.cs | 3 +-
.../Index/IndexExtractCfsCommandTest.cs | 3 +-
.../Commands/Index/IndexFixCommandTest.cs | 46 ++++++++---
.../Commands/Index/IndexListCfsCommandTest.cs | 13 +---
.../Index/IndexListHighFreqTermsCommandTest.cs | 4 +-
.../Index/IndexListSegmentsCommandTest.cs | 4 +-
.../Index/IndexListTaxonomyStatsCommandTest.cs | 4 +-
.../Index/IndexListTermInfoCommandTest.cs | 5 +-
.../Commands/Index/IndexMergeCommandTest.cs | 3 +-
.../Commands/Index/IndexSplitCommandTest.cs | 3 +-
.../Commands/Index/IndexUpgradeCommandTest.cs | 4 +-
.../Commands/Lock/LockCommandTest.cs | 4 +-
.../Commands/Lock/LockStressTestCommandTest.cs | 5 +-
.../Lock/LockVerifyServerCommandTest.cs | 5 +-
.../Commands/RootCommandTest.cs | 8 +-
.../EnumerableExtensions.cs | 36 ++++++++-
.../Lucene.Net.Tests.Cli/EnvironmentTest.cs | 20 +++++
.../Lucene.Net.Tests.Cli/StringExtensions.cs | 36 ---------
src/tools/lucene-cli/Properties/AssemblyInfo.cs | 2 +-
.../lucene-cli/Resources/Strings.Designer.cs | 36 ++++++---
src/tools/lucene-cli/Resources/Strings.resx | 20 +++--
.../AnalysisStempelPatchStemsCommand.cs | 5 +-
.../demo-search-files/DemoSearchFilesCommand.cs | 3 +-
.../index-extract-cfs/IndexExtractCfsCommand.cs | 2 +-
.../commands/index/index-fix/IndexFixCommand.cs | 27 +++++--
.../IndexListTaxonomyStatsCommand.cs | 2 +-
43 files changed, 646 insertions(+), 210 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ea6ec0fa/src/tools/Lucene.Net.Tests.Cli/Commands/Analysis/AnalysisCommandTest.cs
----------------------------------------------------------------------
diff --git a/src/tools/Lucene.Net.Tests.Cli/Commands/Analysis/AnalysisCommandTest.cs b/src/tools/Lucene.Net.Tests.Cli/Commands/Analysis/AnalysisCommandTest.cs
index d05131b..b0082e5 100644
--- a/src/tools/Lucene.Net.Tests.Cli/Commands/Analysis/AnalysisCommandTest.cs
+++ b/src/tools/Lucene.Net.Tests.Cli/Commands/Analysis/AnalysisCommandTest.cs
@@ -40,7 +40,7 @@ namespace Lucene.Net.Cli.Commands
}
[Test]
- public void TestTooManyArguments()
+ public virtual void TestTooManyArguments()
{
Assert.Throws<CommandParsingException>(() => AssertConsoleOutput("one", ""));
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ea6ec0fa/src/tools/Lucene.Net.Tests.Cli/Commands/Analysis/AnalysisStempelCompileStemsCommandTest.cs
----------------------------------------------------------------------
diff --git a/src/tools/Lucene.Net.Tests.Cli/Commands/Analysis/AnalysisStempelCompileStemsCommandTest.cs b/src/tools/Lucene.Net.Tests.Cli/Commands/Analysis/AnalysisStempelCompileStemsCommandTest.cs
index 951644f..fdcae26 100644
--- a/src/tools/Lucene.Net.Tests.Cli/Commands/Analysis/AnalysisStempelCompileStemsCommandTest.cs
+++ b/src/tools/Lucene.Net.Tests.Cli/Commands/Analysis/AnalysisStempelCompileStemsCommandTest.cs
@@ -49,9 +49,8 @@ namespace Lucene.Net.Cli.Commands
}
[Test]
- public void TestNotEnoughArguments()
+ public virtual void TestNotEnoughArguments()
{
- Assert.NotNull(FromResource("NotEnoughArguments"));
AssertConsoleOutput("one", FromResource("NotEnoughArguments", 2));
}
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ea6ec0fa/src/tools/Lucene.Net.Tests.Cli/Commands/Analysis/AnalysisStempelPatchStemsCommandTest.cs
----------------------------------------------------------------------
diff --git a/src/tools/Lucene.Net.Tests.Cli/Commands/Analysis/AnalysisStempelPatchStemsCommandTest.cs b/src/tools/Lucene.Net.Tests.Cli/Commands/Analysis/AnalysisStempelPatchStemsCommandTest.cs
index 0a21a1f..41d6637 100644
--- a/src/tools/Lucene.Net.Tests.Cli/Commands/Analysis/AnalysisStempelPatchStemsCommandTest.cs
+++ b/src/tools/Lucene.Net.Tests.Cli/Commands/Analysis/AnalysisStempelPatchStemsCommandTest.cs
@@ -48,9 +48,8 @@ namespace Lucene.Net.Cli.Commands.Analysis
}
[Test]
- public void TestNotEnoughArguments()
+ public virtual void TestNotEnoughArguments()
{
- Assert.NotNull(FromResource("NotEnoughArguments"));
AssertConsoleOutput("", FromResource("NotEnoughArguments", 1));
}
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ea6ec0fa/src/tools/Lucene.Net.Tests.Cli/Commands/CommandTestCase.cs
----------------------------------------------------------------------
diff --git a/src/tools/Lucene.Net.Tests.Cli/Commands/CommandTestCase.cs b/src/tools/Lucene.Net.Tests.Cli/Commands/CommandTestCase.cs
index 0b1917d..7d933d7 100644
--- a/src/tools/Lucene.Net.Tests.Cli/Commands/CommandTestCase.cs
+++ b/src/tools/Lucene.Net.Tests.Cli/Commands/CommandTestCase.cs
@@ -46,6 +46,9 @@ namespace Lucene.Net.Cli.Commands
var cmd = CreateConfiguration(output);
cmd.Execute(command.ToArgs());
+ Assert.False(output.CallCount < 1, "Main() method not called");
+ Assert.False(output.CallCount > 1, "Main() method called more than once");
+
Assert.AreEqual(expectedResult.Length, output.Args.Length);
for (int i = 0; i < output.Args.Length; i++)
{
@@ -66,12 +69,12 @@ namespace Lucene.Net.Cli.Commands
Assert.True(consoleText.Contains(expectedConsoleText), "Expected output was {0}, actual console output was {1}", expectedConsoleText, consoleText);
}
- protected virtual string FromResource(string resourceName)
+ public static string FromResource(string resourceName)
{
return Resources.Strings.ResourceManager.GetString(resourceName);
}
- protected virtual string FromResource(string resourceName, params object[] args)
+ public static string FromResource(string resourceName, params object[] args)
{
return string.Format(Resources.Strings.ResourceManager.GetString(resourceName), args);
}
@@ -106,14 +109,49 @@ namespace Lucene.Net.Cli.Commands
AssertConsoleOutput("?", "Version");
}
+ [Test]
+ public virtual void TestCommandHasDescription()
+ {
+ var output = new MockConsoleApp();
+ var cmd = CreateConfiguration(output);
+ Assert.IsNotNull(cmd.Description);
+ Assert.IsNotEmpty(cmd.Description);
+ }
+
+ [Test]
+ public virtual void TestAllArgumentsHaveDescription()
+ {
+ var output = new MockConsoleApp();
+ var cmd = CreateConfiguration(output);
+ foreach (var arg in cmd.Arguments)
+ {
+ Assert.IsNotNull(arg.Description);
+ Assert.IsNotEmpty(arg.Description);
+ }
+ }
+
+ [Test]
+ public virtual void TestAllOptionsHaveDescription()
+ {
+ var output = new MockConsoleApp();
+ var cmd = CreateConfiguration(output);
+ foreach (var option in cmd.Options)
+ {
+ Assert.IsNotNull(option.Description);
+ Assert.IsNotEmpty(option.Description);
+ }
+ }
+
public class MockConsoleApp
{
public void Main(string[] args)
{
this.Args = args;
+ this.CallCount++;
}
public string[] Args { get; private set; }
+ public int CallCount { get; private set; }
}
public class Arg
@@ -128,43 +166,4 @@ namespace Lucene.Net.Cli.Commands
public string[] Output { get; private set; }
}
}
-
- public static class ListExtensions
- {
- // Breaks out any options based on logical OR | symbol
- public static IList<CommandTestCase.Arg[]> ExpandArgs(this IList<CommandTestCase.Arg[]> args)
- {
- var result = new List<CommandTestCase.Arg[]>();
- foreach (var arg in args)
- {
- result.Add(ExpandArgs(arg));
- }
-
- return result;
- }
-
- public static CommandTestCase.Arg[] ExpandArgs(this CommandTestCase.Arg[] args)
- {
- var result = new List<CommandTestCase.Arg>();
- if (args != null)
- {
- foreach (var arg in args)
- {
- if (arg.InputPattern.Contains("|"))
- {
- var options = arg.InputPattern.Split('|');
- foreach (var option in options)
- {
- result.Add(new CommandTestCase.Arg(option, (string[])arg.Output.Clone()));
- }
- }
- else
- {
- result.Add(arg);
- }
- }
- }
- return result.ToArray();
- }
- }
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ea6ec0fa/src/tools/Lucene.Net.Tests.Cli/Commands/Demo/DemoAssociationsFacetsCommandTest.cs
----------------------------------------------------------------------
diff --git a/src/tools/Lucene.Net.Tests.Cli/Commands/Demo/DemoAssociationsFacetsCommandTest.cs b/src/tools/Lucene.Net.Tests.Cli/Commands/Demo/DemoAssociationsFacetsCommandTest.cs
new file mode 100644
index 0000000..8bb7c94
--- /dev/null
+++ b/src/tools/Lucene.Net.Tests.Cli/Commands/Demo/DemoAssociationsFacetsCommandTest.cs
@@ -0,0 +1,40 @@
+using System.Collections.Generic;
+
+namespace Lucene.Net.Cli.Commands.Demo
+{
+ /*
+ * 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 DemoAssociationsFacetsCommandTest : CommandTestCase
+ {
+ protected override ConfigurationBase CreateConfiguration(MockConsoleApp app)
+ {
+ return new DemoAssociationsFacetsCommand.Configuration(new CommandLineOptions()) { Main = (args) => app.Main(args) };
+ }
+
+ protected override IList<Arg[]> GetOptionalArgs()
+ {
+ return new List<Arg[]>();
+ }
+
+ protected override IList<Arg[]> GetRequiredArgs()
+ {
+ // NOTE: We must order this in the sequence of the expected output.
+ return new List<Arg[]>();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ea6ec0fa/src/tools/Lucene.Net.Tests.Cli/Commands/Demo/DemoCommandTest.cs
----------------------------------------------------------------------
diff --git a/src/tools/Lucene.Net.Tests.Cli/Commands/Demo/DemoCommandTest.cs b/src/tools/Lucene.Net.Tests.Cli/Commands/Demo/DemoCommandTest.cs
index 4c57bbb..3f448fa 100644
--- a/src/tools/Lucene.Net.Tests.Cli/Commands/Demo/DemoCommandTest.cs
+++ b/src/tools/Lucene.Net.Tests.Cli/Commands/Demo/DemoCommandTest.cs
@@ -40,7 +40,7 @@ namespace Lucene.Net.Cli.Commands
}
[Test]
- public void TestTooManyArguments()
+ public virtual void TestTooManyArguments()
{
Assert.Throws<CommandParsingException>(() => AssertConsoleOutput("one", ""));
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ea6ec0fa/src/tools/Lucene.Net.Tests.Cli/Commands/Demo/DemoDistanceFacetsCommandTest.cs
----------------------------------------------------------------------
diff --git a/src/tools/Lucene.Net.Tests.Cli/Commands/Demo/DemoDistanceFacetsCommandTest.cs b/src/tools/Lucene.Net.Tests.Cli/Commands/Demo/DemoDistanceFacetsCommandTest.cs
new file mode 100644
index 0000000..b454ce7
--- /dev/null
+++ b/src/tools/Lucene.Net.Tests.Cli/Commands/Demo/DemoDistanceFacetsCommandTest.cs
@@ -0,0 +1,41 @@
+using System.Collections.Generic;
+
+namespace Lucene.Net.Cli.Commands.Demo
+{
+ /*
+ * 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 DemoDistanceFacetsCommandTest : CommandTestCase
+ {
+ protected override ConfigurationBase CreateConfiguration(MockConsoleApp app)
+ {
+ return new DemoDistanceFacetsCommand.Configuration(new CommandLineOptions()) { Main = (args) => app.Main(args) };
+ }
+
+ protected override IList<Arg[]> GetOptionalArgs()
+ {
+ return new List<Arg[]>();
+ }
+
+ protected override IList<Arg[]> GetRequiredArgs()
+ {
+ // NOTE: We must order this in the sequence of the expected output.
+ return new List<Arg[]>();
+ }
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ea6ec0fa/src/tools/Lucene.Net.Tests.Cli/Commands/Demo/DemoExpressionAggregationFacetsCommandTest.cs
----------------------------------------------------------------------
diff --git a/src/tools/Lucene.Net.Tests.Cli/Commands/Demo/DemoExpressionAggregationFacetsCommandTest.cs b/src/tools/Lucene.Net.Tests.Cli/Commands/Demo/DemoExpressionAggregationFacetsCommandTest.cs
new file mode 100644
index 0000000..12576ea
--- /dev/null
+++ b/src/tools/Lucene.Net.Tests.Cli/Commands/Demo/DemoExpressionAggregationFacetsCommandTest.cs
@@ -0,0 +1,42 @@
+using System.Collections.Generic;
+
+namespace Lucene.Net.Cli.Commands.Demo
+{
+ /*
+ * 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 DemoExpressionAggregationFacetsCommandTest : CommandTestCase
+ {
+ protected override ConfigurationBase CreateConfiguration(MockConsoleApp app)
+ {
+ return new DemoExpressionAggregationFacetsCommand.Configuration(new CommandLineOptions()) { Main = (args) => app.Main(args) };
+ }
+
+ protected override IList<Arg[]> GetOptionalArgs()
+ {
+ return new List<Arg[]>();
+ }
+
+ protected override IList<Arg[]> GetRequiredArgs()
+ {
+ // NOTE: We must order this in the sequence of the expected output.
+ return new List<Arg[]>();
+ }
+ }
+}
+
+
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ea6ec0fa/src/tools/Lucene.Net.Tests.Cli/Commands/Demo/DemoIndexFilesCommandTest.cs
----------------------------------------------------------------------
diff --git a/src/tools/Lucene.Net.Tests.Cli/Commands/Demo/DemoIndexFilesCommandTest.cs b/src/tools/Lucene.Net.Tests.Cli/Commands/Demo/DemoIndexFilesCommandTest.cs
new file mode 100644
index 0000000..e892eb1
--- /dev/null
+++ b/src/tools/Lucene.Net.Tests.Cli/Commands/Demo/DemoIndexFilesCommandTest.cs
@@ -0,0 +1,61 @@
+using Lucene.Net.Cli.CommandLine;
+using NUnit.Framework;
+using System.Collections.Generic;
+
+namespace Lucene.Net.Cli.Commands.Demo
+{
+ /*
+ * 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 DemoIndexFilesCommandTest : CommandTestCase
+ {
+ protected override ConfigurationBase CreateConfiguration(MockConsoleApp app)
+ {
+ return new DemoIndexFilesCommand.Configuration(new CommandLineOptions()) { Main = (args) => app.Main(args) };
+ }
+
+ protected override IList<Arg[]> GetOptionalArgs()
+ {
+ return new List<Arg[]>()
+ {
+ new Arg[] { new Arg(inputPattern: "-u|--update", output: new string[] { "--update" }) },
+ };
+ }
+
+ protected override IList<Arg[]> GetRequiredArgs()
+ {
+ // NOTE: We must order this in the sequence of the expected output.
+ return new List<Arg[]>()
+ {
+ new Arg[] { new Arg(inputPattern: @"C:\lucene-temp", output: new string[] { @"C:\lucene-temp" }) },
+ new Arg[] { new Arg(inputPattern: @"C:\lucene-temp2", output: new string[] { @"C:\lucene-temp2" }) },
+ };
+ }
+
+ [Test]
+ public virtual void TestNotEnoughArguments()
+ {
+ AssertConsoleOutput("one", FromResource("NotEnoughArguments", 2));
+ }
+
+ [Test]
+ public virtual void TestTooManyArguments()
+ {
+ Assert.Throws<CommandParsingException>(() => AssertConsoleOutput("one two three", ""));
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ea6ec0fa/src/tools/Lucene.Net.Tests.Cli/Commands/Demo/DemoMultiCategoryListsFacetsCommandTest.cs
----------------------------------------------------------------------
diff --git a/src/tools/Lucene.Net.Tests.Cli/Commands/Demo/DemoMultiCategoryListsFacetsCommandTest.cs b/src/tools/Lucene.Net.Tests.Cli/Commands/Demo/DemoMultiCategoryListsFacetsCommandTest.cs
new file mode 100644
index 0000000..dca20cc
--- /dev/null
+++ b/src/tools/Lucene.Net.Tests.Cli/Commands/Demo/DemoMultiCategoryListsFacetsCommandTest.cs
@@ -0,0 +1,40 @@
+using System.Collections.Generic;
+
+namespace Lucene.Net.Cli.Commands.Demo
+{
+ /*
+ * 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 DemoMultiCategoryListsFacetsCommandTest : CommandTestCase
+ {
+ protected override ConfigurationBase CreateConfiguration(MockConsoleApp app)
+ {
+ return new DemoMultiCategoryListsFacetsCommand.Configuration(new CommandLineOptions()) { Main = (args) => app.Main(args) };
+ }
+
+ protected override IList<Arg[]> GetOptionalArgs()
+ {
+ return new List<Arg[]>();
+ }
+
+ protected override IList<Arg[]> GetRequiredArgs()
+ {
+ // NOTE: We must order this in the sequence of the expected output.
+ return new List<Arg[]>();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ea6ec0fa/src/tools/Lucene.Net.Tests.Cli/Commands/Demo/DemoRangeFacetsCommandTest.cs
----------------------------------------------------------------------
diff --git a/src/tools/Lucene.Net.Tests.Cli/Commands/Demo/DemoRangeFacetsCommandTest.cs b/src/tools/Lucene.Net.Tests.Cli/Commands/Demo/DemoRangeFacetsCommandTest.cs
new file mode 100644
index 0000000..d97c47c
--- /dev/null
+++ b/src/tools/Lucene.Net.Tests.Cli/Commands/Demo/DemoRangeFacetsCommandTest.cs
@@ -0,0 +1,40 @@
+using System.Collections.Generic;
+
+namespace Lucene.Net.Cli.Commands.Demo
+{
+ /*
+ * 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 DemoRangeFacetsCommandTest : CommandTestCase
+ {
+ protected override ConfigurationBase CreateConfiguration(MockConsoleApp app)
+ {
+ return new DemoRangeFacetsCommand.Configuration(new CommandLineOptions()) { Main = (args) => app.Main(args) };
+ }
+
+ protected override IList<Arg[]> GetOptionalArgs()
+ {
+ return new List<Arg[]>();
+ }
+
+ protected override IList<Arg[]> GetRequiredArgs()
+ {
+ // NOTE: We must order this in the sequence of the expected output.
+ return new List<Arg[]>();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ea6ec0fa/src/tools/Lucene.Net.Tests.Cli/Commands/Demo/DemoSearchFilesCommandTest.cs
----------------------------------------------------------------------
diff --git a/src/tools/Lucene.Net.Tests.Cli/Commands/Demo/DemoSearchFilesCommandTest.cs b/src/tools/Lucene.Net.Tests.Cli/Commands/Demo/DemoSearchFilesCommandTest.cs
new file mode 100644
index 0000000..3ae64be
--- /dev/null
+++ b/src/tools/Lucene.Net.Tests.Cli/Commands/Demo/DemoSearchFilesCommandTest.cs
@@ -0,0 +1,64 @@
+using Lucene.Net.Cli.CommandLine;
+using NUnit.Framework;
+using System.Collections.Generic;
+
+namespace Lucene.Net.Cli.Commands.Demo
+{
+ /*
+ * 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 DemoSearchFilesCommandTest : CommandTestCase
+ {
+ protected override ConfigurationBase CreateConfiguration(MockConsoleApp app)
+ {
+ return new DemoSearchFilesCommand.Configuration(new CommandLineOptions()) { Main = (args) => app.Main(args) };
+ }
+
+ protected override IList<Arg[]> GetOptionalArgs()
+ {
+ return new List<Arg[]>()
+ {
+ new Arg[] { new Arg(inputPattern: "-f fieldName|--field fieldName", output: new string[] { "--field", "fieldName" }) },
+ new Arg[] { new Arg(inputPattern: "-r 10|--repeat 10", output: new string[] { "--repeat", "10" }) },
+ new Arg[] { new Arg(inputPattern: @"-qf C:\lucene-temp2\queries.txt|--queries-file C:\lucene-temp2\queries.txt", output: new string[] { "--queries-file", @"C:\lucene-temp2\queries.txt" }) },
+ new Arg[] { new Arg(inputPattern: "--raw", output: new string[] { "--raw" }) },
+ new Arg[] { new Arg(inputPattern: "-p 15|--page-size 15", output: new string[] { "--page-size", "15" }) },
+ };
+ }
+
+ protected override IList<Arg[]> GetRequiredArgs()
+ {
+ // NOTE: We must order this in the sequence of the expected output.
+ return new List<Arg[]>()
+ {
+ new Arg[] { new Arg(inputPattern: @"C:\lucene-temp", output: new string[] { @"C:\lucene-temp" }) },
+ };
+ }
+
+ [Test]
+ public virtual void TestNotEnoughArguments()
+ {
+ AssertConsoleOutput("", FromResource("NotEnoughArguments", 1));
+ }
+
+ [Test]
+ public virtual void TestTooManyArguments()
+ {
+ Assert.Throws<CommandParsingException>(() => AssertConsoleOutput("one two", ""));
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ea6ec0fa/src/tools/Lucene.Net.Tests.Cli/Commands/Demo/DemoSimpleFacetsCommandTest.cs
----------------------------------------------------------------------
diff --git a/src/tools/Lucene.Net.Tests.Cli/Commands/Demo/DemoSimpleFacetsCommandTest.cs b/src/tools/Lucene.Net.Tests.Cli/Commands/Demo/DemoSimpleFacetsCommandTest.cs
new file mode 100644
index 0000000..8db37e2
--- /dev/null
+++ b/src/tools/Lucene.Net.Tests.Cli/Commands/Demo/DemoSimpleFacetsCommandTest.cs
@@ -0,0 +1,40 @@
+using System.Collections.Generic;
+
+namespace Lucene.Net.Cli.Commands.Demo
+{
+ /*
+ * 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 DemoSimpleFacetsCommandTest : CommandTestCase
+ {
+ protected override ConfigurationBase CreateConfiguration(MockConsoleApp app)
+ {
+ return new DemoSimpleFacetsCommand.Configuration(new CommandLineOptions()) { Main = (args) => app.Main(args) };
+ }
+
+ protected override IList<Arg[]> GetOptionalArgs()
+ {
+ return new List<Arg[]>();
+ }
+
+ protected override IList<Arg[]> GetRequiredArgs()
+ {
+ // NOTE: We must order this in the sequence of the expected output.
+ return new List<Arg[]>();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ea6ec0fa/src/tools/Lucene.Net.Tests.Cli/Commands/Demo/DemoSimpleSortedSetFacetsCommandTest.cs
----------------------------------------------------------------------
diff --git a/src/tools/Lucene.Net.Tests.Cli/Commands/Demo/DemoSimpleSortedSetFacetsCommandTest.cs b/src/tools/Lucene.Net.Tests.Cli/Commands/Demo/DemoSimpleSortedSetFacetsCommandTest.cs
new file mode 100644
index 0000000..a7bcfc3
--- /dev/null
+++ b/src/tools/Lucene.Net.Tests.Cli/Commands/Demo/DemoSimpleSortedSetFacetsCommandTest.cs
@@ -0,0 +1,40 @@
+using System.Collections.Generic;
+
+namespace Lucene.Net.Cli.Commands.Demo
+{
+ /*
+ * 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 DemoSimpleSortedSetFacetsCommandTest : CommandTestCase
+ {
+ protected override ConfigurationBase CreateConfiguration(MockConsoleApp app)
+ {
+ return new DemoSimpleSortedSetFacetsCommand.Configuration(new CommandLineOptions()) { Main = (args) => app.Main(args) };
+ }
+
+ protected override IList<Arg[]> GetOptionalArgs()
+ {
+ return new List<Arg[]>();
+ }
+
+ protected override IList<Arg[]> GetRequiredArgs()
+ {
+ // NOTE: We must order this in the sequence of the expected output.
+ return new List<Arg[]>();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ea6ec0fa/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexCheckCommandTest.cs
----------------------------------------------------------------------
diff --git a/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexCheckCommandTest.cs b/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexCheckCommandTest.cs
index 0ec00ef..5521124 100644
--- a/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexCheckCommandTest.cs
+++ b/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexCheckCommandTest.cs
@@ -35,7 +35,7 @@ namespace Lucene.Net.Cli.Commands
return new List<Arg[]>()
{
new Arg[] { new Arg(inputPattern: "-c|--cross-check-term-vectors", output: new string[] { "-crossCheckTermVectors" }) },
- new Arg[] { new Arg(inputPattern: "--verbose", output: new string[] { "-verbose" }) },
+ new Arg[] { new Arg(inputPattern: "-v|--verbose", output: new string[] { "-verbose" }) },
new Arg[] {
new Arg(inputPattern: "-s _seg1|--segment _seg1", output: new string[] { "-segment", "_seg1" }),
new Arg(inputPattern: "-s _seg1 -s _seg2|--segment _seg1 --segment _seg2", output: new string[] { "-segment", "_seg1", "-segment", "_seg2" }),
@@ -53,57 +53,14 @@ namespace Lucene.Net.Cli.Commands
};
}
-
-
-
-
- //[Test]
- //public void TestAllOptionsShort()
- //{
- // AssertCommandTranslation(
- // @"C:\lucene-temp -v -c -dir SimpleFSDirectory -s _seg1 -s _seg2 -s _seg3",
- // new string[] {
- // @"C:\lucene-temp", "-crossCheckTermVectors", "-verbose",
- // "-segment", "_seg1", "-segment", "_seg2", "-segment", "_seg3",
- // "-dir-impl", "SimpleFSDirectory"
- // });
-
- // //var output = new MockConsoleApp();
- // //var cmd = new IndexCheckCommand.Configuration(new CommandLineOptions()) { Main = (args) => output.Main(args) };
-
- // //string input = @"C:\lucene-temp -v -c -dir SimpleFSDirectory -s _seg1 -s _seg2 -s _seg3";
- // //cmd.Execute(input.ToArgs());
-
- // //Assert.AreEqual(@"C:\lucene-temp", output.Args[0]);
- // //Assert.True(output.Args.Contains("-crossCheckTermVectors"));
- // //Assert.True(output.Args.Contains("-verbose"));
- // //Assert.AreEqual("SimpleFSDirectory", output.Args.OptionValue("-dir-impl"));
- // //Assert.True(new HashSet<string>(output.Args.OptionValues("-segment")).SetEquals(new HashSet<string>(new string[] { "_seg1", "_seg2", "_seg3" })));
- // //Assert.False(output.Args.Contains("-fix"));
- //}
-
- //[Test]
- //public void TestAllOptionsLong()
- //{
- // AssertCommandTranslation(
- // @"C:\lucene-temp --verbose --cross-check-term-vectors --directory-type SimpleFSDirectory --segment _seg1 --segment _seg2 --segment _seg3",
- // new string[] {
- // @"C:\lucene-temp", "-crossCheckTermVectors", "-verbose",
- // "-segment", "_seg1", "-segment", "_seg2", "-segment", "_seg3",
- // "-dir-impl", "SimpleFSDirectory"
- // });
- //}
-
/// <summary>
/// Ensures the current working directory is used when index directory is not supplied.
/// </summary>
[Test]
- public void TestNoArguments()
+ public virtual void TestNoArguments()
{
System.IO.Directory.SetCurrentDirectory(@"C:\");
AssertCommandTranslation("", new string[] { @"C:\" });
}
-
-
}
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ea6ec0fa/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexCommandTest.cs
----------------------------------------------------------------------
diff --git a/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexCommandTest.cs b/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexCommandTest.cs
index e110667..5ec554b 100644
--- a/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexCommandTest.cs
+++ b/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexCommandTest.cs
@@ -42,13 +42,13 @@ namespace Lucene.Net.Cli.Commands
/// Ensures the current working directory is used when index directory is not supplied.
/// </summary>
[Test]
- public void TestNoArguments()
+ public virtual void TestNoArguments()
{
AssertConsoleOutput("", "Lucene.Net Command Line Utility, Version");
}
[Test]
- public void TestTooManyArguments()
+ public virtual void TestTooManyArguments()
{
Assert.Throws<CommandParsingException>(() => AssertConsoleOutput("one", ""));
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ea6ec0fa/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexCopySegmentsTest.cs
----------------------------------------------------------------------
diff --git a/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexCopySegmentsTest.cs b/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexCopySegmentsTest.cs
index 68b86c0..3c14af5 100644
--- a/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexCopySegmentsTest.cs
+++ b/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexCopySegmentsTest.cs
@@ -49,9 +49,8 @@ namespace Lucene.Net.Cli.Commands
}
[Test]
- public void TestNotEnoughArguments()
+ public virtual void TestNotEnoughArguments()
{
- Assert.NotNull(FromResource("NotEnoughArguments"));
AssertConsoleOutput("one two", FromResource("NotEnoughArguments", 3));
}
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ea6ec0fa/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexDeleteSegmentsCommandTest.cs
----------------------------------------------------------------------
diff --git a/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexDeleteSegmentsCommandTest.cs b/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexDeleteSegmentsCommandTest.cs
index 42a2632..bc72375 100644
--- a/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexDeleteSegmentsCommandTest.cs
+++ b/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexDeleteSegmentsCommandTest.cs
@@ -49,9 +49,8 @@ namespace Lucene.Net.Cli.Commands
}
[Test]
- public void TestNotEnoughArguments()
+ public virtual void TestNotEnoughArguments()
{
- Assert.NotNull(FromResource("NotEnoughArguments"));
AssertConsoleOutput("one", FromResource("NotEnoughArguments", 2));
}
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ea6ec0fa/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexExtractCfsCommandTest.cs
----------------------------------------------------------------------
diff --git a/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexExtractCfsCommandTest.cs b/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexExtractCfsCommandTest.cs
index a8ecd92..2325d0d 100644
--- a/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexExtractCfsCommandTest.cs
+++ b/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexExtractCfsCommandTest.cs
@@ -47,9 +47,8 @@ namespace Lucene.Net.Cli.Commands
}
[Test]
- public void TestNotEnoughArguments()
+ public virtual void TestNotEnoughArguments()
{
- Assert.NotNull(FromResource("NotEnoughArguments"));
AssertConsoleOutput("", FromResource("NotEnoughArguments", 1));
}
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ea6ec0fa/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexFixCommandTest.cs
----------------------------------------------------------------------
diff --git a/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexFixCommandTest.cs b/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexFixCommandTest.cs
index 105606d..29a2b4c 100644
--- a/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexFixCommandTest.cs
+++ b/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexFixCommandTest.cs
@@ -1,6 +1,7 @@
using Lucene.Net.Cli.CommandLine;
using NUnit.Framework;
using System.Collections.Generic;
+using System.Linq;
namespace Lucene.Net.Cli.Commands
{
@@ -33,13 +34,12 @@ namespace Lucene.Net.Cli.Commands
// NOTE: We must order this in the sequence of the expected output.
return new List<Arg[]>()
{
- new Arg[] { new Arg(inputPattern: "-c|--cross-check-term-vectors", output: new string[] { "-crossCheckTermVectors" }) },
- new Arg[] { new Arg(inputPattern: "--verbose", output: new string[] { "-verbose" }) },
new Arg[] {
- new Arg(inputPattern: "-s _seg1|--segment _seg1", output: new string[] { "-segment", "_seg1" }),
- new Arg(inputPattern: "-s _seg1 -s _seg2|--segment _seg1 --segment _seg2", output: new string[] { "-segment", "_seg1", "-segment", "_seg2" }),
- new Arg(inputPattern: "-s _seg1 -s _seg2 -s _seg3|--segment _seg1 --segment _seg2 --segment _seg3", output: new string[] { "-segment", "_seg1", "-segment", "_seg2", "-segment", "_seg3" })
+ new Arg(inputPattern: "", output: new string[] { "-fix" }),
+ new Arg(inputPattern: "--dry-run", output: new string[0]),
},
+ new Arg[] { new Arg(inputPattern: "-c|--cross-check-term-vectors", output: new string[] { "-crossCheckTermVectors" }) },
+ new Arg[] { new Arg(inputPattern: "-v|--verbose", output: new string[] { "-verbose" }) },
new Arg[] { new Arg(inputPattern: "-dir SimpleFSDirectory|--directory-type SimpleFSDirectory", output: new string[] { "-dir-impl", "SimpleFSDirectory" }) },
};
}
@@ -49,20 +49,48 @@ namespace Lucene.Net.Cli.Commands
// NOTE: We must order this in the sequence of the expected output.
return new List<Arg[]>()
{
- new Arg[] { new Arg(inputPattern: @"C:\lucene-temp", output: new string[] { @"C:\lucene-temp" }) },
- new Arg[] { new Arg(inputPattern: "", output: new string[] { "-fix" }) },
+ new Arg[] { new Arg(inputPattern: @"C:\lucene-temp", output: new string[] { @"C:\lucene-temp" }) }
};
}
[Test]
- public void TestNoArguments()
+ public override void TestAllValidCombinations()
+ {
+ var requiredArgs = GetRequiredArgs().ExpandArgs().RequiredParameters();
+ var optionalArgs = GetOptionalArgs().ExpandArgs().OptionalParameters();
+
+ foreach (var requiredArg in requiredArgs)
+ {
+ AssertCommandTranslation(
+ string.Join(" ", requiredArg.Select(x => x.InputPattern).ToArray()),
+ requiredArg.SelectMany(x => x.Output)
+ // Special case - the -fix option must be specified when --dry-run is not
+ .Concat(new string[] { "-fix" }).ToArray());
+ }
+
+ foreach (var requiredArg in requiredArgs)
+ {
+ foreach (var optionalArg in optionalArgs)
+ {
+ string command = string.Join(" ", requiredArg.Select(x => x.InputPattern).Union(optionalArg.Select(x => x.InputPattern).ToArray()));
+ string[] expected = requiredArg.SelectMany(x => x.Output)
+ // Special case - the -fix option must be specified when --dry-run is not
+ .Concat(command.Contains("--dry-run") ? new string[0] : new string[] { "-fix" })
+ .Union(optionalArg.SelectMany(x => x.Output)).ToArray();
+ AssertCommandTranslation(command, expected);
+ }
+ }
+ }
+
+ [Test]
+ public virtual void TestNoArguments()
{
System.IO.Directory.SetCurrentDirectory(@"C:\");
AssertCommandTranslation("", new string[] { @"C:\", "-fix" });
}
[Test]
- public void TestTooManyArguments()
+ public virtual void TestTooManyArguments()
{
Assert.Throws<CommandParsingException>(() => AssertConsoleOutput("one two", ""));
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ea6ec0fa/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexListCfsCommandTest.cs
----------------------------------------------------------------------
diff --git a/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexListCfsCommandTest.cs b/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexListCfsCommandTest.cs
index 46b014c..244e2fc 100644
--- a/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexListCfsCommandTest.cs
+++ b/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexListCfsCommandTest.cs
@@ -23,7 +23,7 @@ namespace Lucene.Net.Cli.Commands
public class IndexListCfsCommandTest : CommandTestCase
{
-
+
protected override ConfigurationBase CreateConfiguration(MockConsoleApp app)
{
return new IndexListCfsCommand.Configuration(new CommandLineOptions()) { Main = (args) => app.Main(args) };
@@ -48,22 +48,15 @@ namespace Lucene.Net.Cli.Commands
}
[Test]
- public void TestNotEnoughArguments()
+ public virtual void TestNotEnoughArguments()
{
- Assert.NotNull(FromResource("NotEnoughArguments"));
AssertConsoleOutput("", FromResource("NotEnoughArguments", 1));
}
[Test]
- public void TestTooManyArguments()
+ public virtual void TestTooManyArguments()
{
Assert.Throws<CommandParsingException>(() => AssertConsoleOutput("one two", ""));
}
-
- [Test]
- public override void TestHelp()
- {
- base.TestHelp();
- }
}
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ea6ec0fa/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexListHighFreqTermsCommandTest.cs
----------------------------------------------------------------------
diff --git a/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexListHighFreqTermsCommandTest.cs b/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexListHighFreqTermsCommandTest.cs
index fc937ad..e12aeea 100644
--- a/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexListHighFreqTermsCommandTest.cs
+++ b/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexListHighFreqTermsCommandTest.cs
@@ -52,14 +52,14 @@ namespace Lucene.Net.Cli.Commands
/// Ensures the current working directory is used when index directory is not supplied.
/// </summary>
[Test]
- public void TestNoArguments()
+ public virtual void TestNoArguments()
{
System.IO.Directory.SetCurrentDirectory(@"C:\");
AssertCommandTranslation("", new string[] { @"C:\" });
}
[Test]
- public void TestTooManyArguments()
+ public virtual void TestTooManyArguments()
{
Assert.Throws<CommandParsingException>(() => AssertConsoleOutput("one two", ""));
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ea6ec0fa/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexListSegmentsCommandTest.cs
----------------------------------------------------------------------
diff --git a/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexListSegmentsCommandTest.cs b/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexListSegmentsCommandTest.cs
index c4297c7..a8e4837 100644
--- a/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexListSegmentsCommandTest.cs
+++ b/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexListSegmentsCommandTest.cs
@@ -48,14 +48,14 @@ namespace Lucene.Net.Cli.Commands
/// Ensures the current working directory is used when index directory is not supplied.
/// </summary>
[Test]
- public void TestNoArguments()
+ public virtual void TestNoArguments()
{
System.IO.Directory.SetCurrentDirectory(@"C:\");
AssertCommandTranslation("", new string[] { @"C:\", "-l" });
}
[Test]
- public void TestTooManyArguments()
+ public virtual void TestTooManyArguments()
{
Assert.Throws<CommandParsingException>(() => AssertConsoleOutput("one two", ""));
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ea6ec0fa/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexListTaxonomyStatsCommandTest.cs
----------------------------------------------------------------------
diff --git a/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexListTaxonomyStatsCommandTest.cs b/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexListTaxonomyStatsCommandTest.cs
index 8539200..4b35516 100644
--- a/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexListTaxonomyStatsCommandTest.cs
+++ b/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexListTaxonomyStatsCommandTest.cs
@@ -50,14 +50,14 @@ namespace Lucene.Net.Cli.Commands
/// Ensures the current working directory is used when index directory is not supplied.
/// </summary>
[Test]
- public void TestNoArguments()
+ public virtual void TestNoArguments()
{
System.IO.Directory.SetCurrentDirectory(@"C:\");
AssertCommandTranslation("", new string[] { @"C:\" });
}
[Test]
- public void TestTooManyArguments()
+ public virtual void TestTooManyArguments()
{
Assert.Throws<CommandParsingException>(() => AssertConsoleOutput("one two", ""));
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ea6ec0fa/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexListTermInfoCommandTest.cs
----------------------------------------------------------------------
diff --git a/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexListTermInfoCommandTest.cs b/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexListTermInfoCommandTest.cs
index 09a536a..1b97cf2 100644
--- a/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexListTermInfoCommandTest.cs
+++ b/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexListTermInfoCommandTest.cs
@@ -46,14 +46,13 @@ namespace Lucene.Net.Cli.Commands
}
[Test]
- public void TestNotEnoughArguments()
+ public virtual void TestNotEnoughArguments()
{
- Assert.NotNull(FromResource("NotEnoughArguments"));
AssertConsoleOutput("", FromResource("NotEnoughArguments", 3));
}
[Test]
- public void TestTooManyArguments()
+ public virtual void TestTooManyArguments()
{
Assert.Throws<CommandParsingException>(() => AssertConsoleOutput("one two three four", ""));
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ea6ec0fa/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexMergeCommandTest.cs
----------------------------------------------------------------------
diff --git a/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexMergeCommandTest.cs b/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexMergeCommandTest.cs
index f425eab..7dba980 100644
--- a/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexMergeCommandTest.cs
+++ b/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexMergeCommandTest.cs
@@ -48,9 +48,8 @@ namespace Lucene.Net.Cli.Commands
}
[Test]
- public void TestNotEnoughArguments()
+ public virtual void TestNotEnoughArguments()
{
- Assert.NotNull(FromResource("NotEnoughArguments"));
AssertConsoleOutput("", FromResource("NotEnoughArguments", 3));
}
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ea6ec0fa/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexSplitCommandTest.cs
----------------------------------------------------------------------
diff --git a/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexSplitCommandTest.cs b/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexSplitCommandTest.cs
index bf0ef31..c5a9017 100644
--- a/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexSplitCommandTest.cs
+++ b/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexSplitCommandTest.cs
@@ -53,9 +53,8 @@ namespace Lucene.Net.Cli.Commands
}
[Test]
- public void TestNotEnoughArguments()
+ public virtual void TestNotEnoughArguments()
{
- Assert.NotNull(FromResource("NotEnoughArguments"));
AssertConsoleOutput("", FromResource("NotEnoughArguments", 2));
}
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ea6ec0fa/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexUpgradeCommandTest.cs
----------------------------------------------------------------------
diff --git a/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexUpgradeCommandTest.cs b/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexUpgradeCommandTest.cs
index 9b52235..776c3d4 100644
--- a/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexUpgradeCommandTest.cs
+++ b/src/tools/Lucene.Net.Tests.Cli/Commands/Index/IndexUpgradeCommandTest.cs
@@ -52,14 +52,14 @@ namespace Lucene.Net.Cli.Commands
/// Ensures the current working directory is used when index directory is not supplied.
/// </summary>
[Test]
- public void TestNoArguments()
+ public virtual void TestNoArguments()
{
System.IO.Directory.SetCurrentDirectory(@"C:\");
AssertCommandTranslation("", new string[] { @"C:\" });
}
[Test]
- public void TestTooManyArguments()
+ public virtual void TestTooManyArguments()
{
Assert.Throws<CommandParsingException>(() => AssertConsoleOutput("one two", ""));
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ea6ec0fa/src/tools/Lucene.Net.Tests.Cli/Commands/Lock/LockCommandTest.cs
----------------------------------------------------------------------
diff --git a/src/tools/Lucene.Net.Tests.Cli/Commands/Lock/LockCommandTest.cs b/src/tools/Lucene.Net.Tests.Cli/Commands/Lock/LockCommandTest.cs
index d5c1f64..9ac8c04 100644
--- a/src/tools/Lucene.Net.Tests.Cli/Commands/Lock/LockCommandTest.cs
+++ b/src/tools/Lucene.Net.Tests.Cli/Commands/Lock/LockCommandTest.cs
@@ -42,13 +42,13 @@ namespace Lucene.Net.Cli.Commands
/// Ensures the current working directory is used when index directory is not supplied.
/// </summary>
[Test]
- public void TestNoArguments()
+ public virtual void TestNoArguments()
{
AssertConsoleOutput("", "Lucene.Net Command Line Utility, Version");
}
[Test]
- public void TestTooManyArguments()
+ public virtual void TestTooManyArguments()
{
Assert.Throws<CommandParsingException>(() => AssertConsoleOutput("one", ""));
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ea6ec0fa/src/tools/Lucene.Net.Tests.Cli/Commands/Lock/LockStressTestCommandTest.cs
----------------------------------------------------------------------
diff --git a/src/tools/Lucene.Net.Tests.Cli/Commands/Lock/LockStressTestCommandTest.cs b/src/tools/Lucene.Net.Tests.Cli/Commands/Lock/LockStressTestCommandTest.cs
index 462ebb2..948104a 100644
--- a/src/tools/Lucene.Net.Tests.Cli/Commands/Lock/LockStressTestCommandTest.cs
+++ b/src/tools/Lucene.Net.Tests.Cli/Commands/Lock/LockStressTestCommandTest.cs
@@ -49,14 +49,13 @@ namespace Lucene.Net.Cli.Commands
}
[Test]
- public void TestNotEnoughArguments()
+ public virtual void TestNotEnoughArguments()
{
- Assert.NotNull(FromResource("NotEnoughArguments"));
AssertConsoleOutput("one two three four five six", FromResource("NotEnoughArguments", 7));
}
[Test]
- public void TestTooManyArguments()
+ public virtual void TestTooManyArguments()
{
Assert.Throws<CommandParsingException>(() => AssertConsoleOutput("one two three four five six seven eight", ""));
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ea6ec0fa/src/tools/Lucene.Net.Tests.Cli/Commands/Lock/LockVerifyServerCommandTest.cs
----------------------------------------------------------------------
diff --git a/src/tools/Lucene.Net.Tests.Cli/Commands/Lock/LockVerifyServerCommandTest.cs b/src/tools/Lucene.Net.Tests.Cli/Commands/Lock/LockVerifyServerCommandTest.cs
index a76a99c..485482e 100644
--- a/src/tools/Lucene.Net.Tests.Cli/Commands/Lock/LockVerifyServerCommandTest.cs
+++ b/src/tools/Lucene.Net.Tests.Cli/Commands/Lock/LockVerifyServerCommandTest.cs
@@ -44,14 +44,13 @@ namespace Lucene.Net.Cli.Commands
}
[Test]
- public void TestNotEnoughArguments()
+ public virtual void TestNotEnoughArguments()
{
- Assert.NotNull(FromResource("NotEnoughArguments"));
AssertConsoleOutput("one", FromResource("NotEnoughArguments", 2));
}
[Test]
- public void TestTooManyArguments()
+ public virtual void TestTooManyArguments()
{
Assert.Throws<CommandParsingException>(() => AssertConsoleOutput("one two three", ""));
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ea6ec0fa/src/tools/Lucene.Net.Tests.Cli/Commands/RootCommandTest.cs
----------------------------------------------------------------------
diff --git a/src/tools/Lucene.Net.Tests.Cli/Commands/RootCommandTest.cs b/src/tools/Lucene.Net.Tests.Cli/Commands/RootCommandTest.cs
index 543cf24..b49b697 100644
--- a/src/tools/Lucene.Net.Tests.Cli/Commands/RootCommandTest.cs
+++ b/src/tools/Lucene.Net.Tests.Cli/Commands/RootCommandTest.cs
@@ -40,9 +40,15 @@ namespace Lucene.Net.Cli.Commands
}
[Test]
- public void TestTooManyArguments()
+ public virtual void TestTooManyArguments()
{
Assert.Throws<CommandParsingException>(() => AssertConsoleOutput("one", ""));
}
+
+ [Test]
+ public override void TestCommandHasDescription()
+ {
+ // No need to do this, it is not displayed anyway
+ }
}
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ea6ec0fa/src/tools/Lucene.Net.Tests.Cli/EnumerableExtensions.cs
----------------------------------------------------------------------
diff --git a/src/tools/Lucene.Net.Tests.Cli/EnumerableExtensions.cs b/src/tools/Lucene.Net.Tests.Cli/EnumerableExtensions.cs
index 95ad494..ac5bb01 100644
--- a/src/tools/Lucene.Net.Tests.Cli/EnumerableExtensions.cs
+++ b/src/tools/Lucene.Net.Tests.Cli/EnumerableExtensions.cs
@@ -1,4 +1,5 @@
-using System.Collections.Generic;
+using Lucene.Net.Cli.Commands;
+using System.Collections.Generic;
using System.Linq;
namespace Lucene.Net.Cli
@@ -20,7 +21,7 @@ namespace Lucene.Net.Cli
* limitations under the License.
*/
- public static class Extensions
+ public static class EnumerableExtensions
{
public static IEnumerable<IEnumerable<T>> OptionalParameters<T>(this IEnumerable<IEnumerable<T>> input)
{
@@ -56,5 +57,36 @@ namespace Lucene.Net.Cli
}
}
}
+
+ // Breaks out any options based on logical OR | symbol
+ public static IEnumerable<IEnumerable<CommandTestCase.Arg>> ExpandArgs(this IEnumerable<IEnumerable<CommandTestCase.Arg>> args)
+ {
+ foreach (var arg in args)
+ {
+ yield return ExpandArgs(arg);
+ }
+ }
+
+ public static IEnumerable<CommandTestCase.Arg> ExpandArgs(this IEnumerable<CommandTestCase.Arg> args)
+ {
+ if (args != null)
+ {
+ foreach (var arg in args)
+ {
+ if (arg.InputPattern.Contains("|"))
+ {
+ var options = arg.InputPattern.Split('|');
+ foreach (var option in options)
+ {
+ yield return new CommandTestCase.Arg(option, (string[])arg.Output.Clone());
+ }
+ }
+ else
+ {
+ yield return arg;
+ }
+ }
+ }
+ }
}
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ea6ec0fa/src/tools/Lucene.Net.Tests.Cli/EnvironmentTest.cs
----------------------------------------------------------------------
diff --git a/src/tools/Lucene.Net.Tests.Cli/EnvironmentTest.cs b/src/tools/Lucene.Net.Tests.Cli/EnvironmentTest.cs
new file mode 100644
index 0000000..29d53c0
--- /dev/null
+++ b/src/tools/Lucene.Net.Tests.Cli/EnvironmentTest.cs
@@ -0,0 +1,20 @@
+using Lucene.Net.Cli.Commands;
+using NUnit.Framework;
+
+namespace Lucene.Net.Cli
+{
+ public class EnvironmentTest
+ {
+ [Test]
+ public virtual void TestNotEnoughArgumentsResourceNotNull()
+ {
+ Assert.NotNull(CommandTestCase.FromResource("NotEnoughArguments"));
+ }
+
+ [Test]
+ public virtual void TestNotEnoughArgumentsResourceNotEmpty()
+ {
+ Assert.IsNotEmpty(CommandTestCase.FromResource("NotEnoughArguments"));
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ea6ec0fa/src/tools/Lucene.Net.Tests.Cli/StringExtensions.cs
----------------------------------------------------------------------
diff --git a/src/tools/Lucene.Net.Tests.Cli/StringExtensions.cs b/src/tools/Lucene.Net.Tests.Cli/StringExtensions.cs
index eeb4e80..196c9b1 100644
--- a/src/tools/Lucene.Net.Tests.Cli/StringExtensions.cs
+++ b/src/tools/Lucene.Net.Tests.Cli/StringExtensions.cs
@@ -28,41 +28,5 @@ namespace Lucene.Net.Cli
{
return Regex.Replace(input.Trim(), @"\s+", " ").Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToArray();
}
-
- public static string OptionValue(this IEnumerable<string> args, string option)
- {
- return args.SkipWhile(a => a != option).Skip(1).FirstOrDefault();
- }
-
- public static IList<string> OptionValues(this IEnumerable<string> args, string option)
- {
- var argsList = new List<string>(args);
- var result = new List<string>();
- for (int i = 0; i < argsList.Count; i++)
- {
- string current = argsList[i];
- if (current == option)
- {
- if (i == argsList.Count - 1)
- {
- result.Add(null);
- }
- else
- {
- current = argsList[i + 1];
- if (current != option)
- {
- result.Add(current);
- i++;
- }
- else
- {
- result.Add(null);
- }
- }
- }
- }
- return result;
- }
}
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ea6ec0fa/src/tools/lucene-cli/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/src/tools/lucene-cli/Properties/AssemblyInfo.cs b/src/tools/lucene-cli/Properties/AssemblyInfo.cs
index 07a71d6..d1118b7 100644
--- a/src/tools/lucene-cli/Properties/AssemblyInfo.cs
+++ b/src/tools/lucene-cli/Properties/AssemblyInfo.cs
@@ -24,7 +24,7 @@ using System.Runtime.InteropServices;
// associated with an assembly.
[assembly: AssemblyTitle("lucene-cli")]
[assembly: AssemblyDescription(
- "Lucene.Net maintenance utilities and demos.")]
+ "Lucene.Net maintenance utilities and demos. Run 'dotnet lucene-cli.dll' to see usage information.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyDefaultAlias("Lucene.Net.Cli")]
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ea6ec0fa/src/tools/lucene-cli/Resources/Strings.Designer.cs
----------------------------------------------------------------------
diff --git a/src/tools/lucene-cli/Resources/Strings.Designer.cs b/src/tools/lucene-cli/Resources/Strings.Designer.cs
index 0db885c..cb790ae 100644
--- a/src/tools/lucene-cli/Resources/Strings.Designer.cs
+++ b/src/tools/lucene-cli/Resources/Strings.Designer.cs
@@ -240,7 +240,7 @@ namespace Lucene.Net.Cli.Resources {
}
/// <summary>
- /// Looks up a localized string similar to Run the index-files demo first to create an index to run this command against. You can either use a file containing many queries, a single query on the command line, or omit both options to run queries interactively..
+ /// Looks up a localized string similar to Run the index-files demo first to create an index to run this command against. You can either use a file containing many queries (each on a single line), a single query on the command line, or omit both options to run queries interactively..
/// </summary>
public static string DemoSearchFilesCommandExtendedHelpText {
get {
@@ -249,7 +249,7 @@ namespace Lucene.Net.Cli.Resources {
}
/// <summary>
- /// Looks up a localized string similar to The index field to use in the search..
+ /// Looks up a localized string similar to The index field to use in the search. If not supplied, defaults to "contents"..
/// </summary>
public static string DemoSearchFilesCommandFieldDescription {
get {
@@ -483,7 +483,7 @@ namespace Lucene.Net.Cli.Resources {
}
/// <summary>
- /// Looks up a localized string similar to The .cfs file containing words to parse..
+ /// Looks up a localized string similar to The .cfs compound file containing words to parse..
/// </summary>
public static string IndexExtractCfsCommandCFSFileNameDescription {
get {
@@ -510,7 +510,7 @@ namespace Lucene.Net.Cli.Resources {
}
/// <summary>
- /// Looks up a localized string similar to Fixes an index with problematic segments..
+ /// Looks up a localized string similar to Fixes an index by removing problematic segments..
/// </summary>
public static string IndexFixCommandDescription {
get {
@@ -519,7 +519,25 @@ namespace Lucene.Net.Cli.Resources {
}
/// <summary>
- /// Looks up a localized string similar to The .cfs file containing words to parse..
+ /// Looks up a localized string similar to Doesn't change the index, but reports any actions that would be taken if this option were not supplied..
+ /// </summary>
+ public static string IndexFixCommandDryRunDescription {
+ get {
+ return ResourceManager.GetString("IndexFixCommandDryRunDescription", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to WARNING: This command should only be used on an emergency basis as it will cause documents (perhaps many) to be permanently removed from the index. Always make a backup copy of your index before running this! Do not run this tool on an index that is actively being written to. You have been warned!.
+ /// </summary>
+ public static string IndexFixCommandExtendedHelpText {
+ get {
+ return ResourceManager.GetString("IndexFixCommandExtendedHelpText", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to The .cfs compound file containing words to parse..
/// </summary>
public static string IndexListCfsCommandCFSFileNameDescription {
get {
@@ -602,18 +620,18 @@ namespace Lucene.Net.Cli.Resources {
/// <summary>
/// Looks up a localized string similar to Displays the taxonomy statistical information for a taxonomy index..
/// </summary>
- public static string IndexListTaxonomyStatsDescription {
+ public static string IndexListTaxonomyStatsCommandDescription {
get {
- return ResourceManager.GetString("IndexListTaxonomyStatsDescription", resourceCulture);
+ return ResourceManager.GetString("IndexListTaxonomyStatsCommandDescription", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Recursively lists all descendent nodes..
/// </summary>
- public static string IndexListTaxonomyStatsShowTreeDescription {
+ public static string IndexListTaxonomyStatsCommandShowTreeDescription {
get {
- return ResourceManager.GetString("IndexListTaxonomyStatsShowTreeDescription", resourceCulture);
+ return ResourceManager.GetString("IndexListTaxonomyStatsCommandShowTreeDescription", resourceCulture);
}
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ea6ec0fa/src/tools/lucene-cli/Resources/Strings.resx
----------------------------------------------------------------------
diff --git a/src/tools/lucene-cli/Resources/Strings.resx b/src/tools/lucene-cli/Resources/Strings.resx
index 3634369..2e4ce2a 100644
--- a/src/tools/lucene-cli/Resources/Strings.resx
+++ b/src/tools/lucene-cli/Resources/Strings.resx
@@ -178,10 +178,10 @@
<value>Simple command-line based search demo. Run index-files demo first.</value>
</data>
<data name="DemoSearchFilesCommandExtendedHelpText" xml:space="preserve">
- <value>Run the index-files demo first to create an index to run this command against. You can either use a file containing many queries, a single query on the command line, or omit both options to run queries interactively.</value>
+ <value>Run the index-files demo first to create an index to run this command against. You can either use a file containing many queries (each on a single line), a single query on the command line, or omit both options to run queries interactively.</value>
</data>
<data name="DemoSearchFilesCommandFieldDescription" xml:space="preserve">
- <value>The index field to use in the search.</value>
+ <value>The index field to use in the search. If not supplied, defaults to "contents".</value>
</data>
<data name="DemoSearchFilesCommandPageSizeDescription" xml:space="preserve">
<value>Hits per page to display.</value>
@@ -259,7 +259,7 @@
<value>If omitted, it defaults to the current working directory.</value>
</data>
<data name="IndexExtractCfsCommandCFSFileNameDescription" xml:space="preserve">
- <value>The .cfs file containing words to parse.</value>
+ <value>The .cfs compound file containing words to parse.</value>
</data>
<data name="IndexExtractCfsCommandDescription" xml:space="preserve">
<value>Lists sub-files from a .cfs compound file.</value>
@@ -268,10 +268,16 @@
<value>The .cfs compound file format is created using the CompoundFileDirectory from Lucene.Net.Misc.</value>
</data>
<data name="IndexFixCommandDescription" xml:space="preserve">
- <value>Fixes an index with problematic segments.</value>
+ <value>Fixes an index by removing problematic segments.</value>
+ </data>
+ <data name="IndexFixCommandDryRunDescription" xml:space="preserve">
+ <value>Doesn't change the index, but reports any actions that would be taken if this option were not supplied.</value>
+ </data>
+ <data name="IndexFixCommandExtendedHelpText" xml:space="preserve">
+ <value>WARNING: This command should only be used on an emergency basis as it will cause documents (perhaps many) to be permanently removed from the index. Always make a backup copy of your index before running this! Do not run this tool on an index that is actively being written to. You have been warned!</value>
</data>
<data name="IndexListCfsCommandCFSFileNameDescription" xml:space="preserve">
- <value>The .cfs file containing words to parse.</value>
+ <value>The .cfs compound file containing words to parse.</value>
</data>
<data name="IndexListCfsCommandDescription" xml:space="preserve">
<value>Extracts sub-files out of a .cfs compound file.</value>
@@ -297,10 +303,10 @@
<data name="IndexListSegmentsCommandDescription" xml:space="preserve">
<value>Lists segments in an index.</value>
</data>
- <data name="IndexListTaxonomyStatsDescription" xml:space="preserve">
+ <data name="IndexListTaxonomyStatsCommandDescription" xml:space="preserve">
<value>Displays the taxonomy statistical information for a taxonomy index.</value>
</data>
- <data name="IndexListTaxonomyStatsShowTreeDescription" xml:space="preserve">
+ <data name="IndexListTaxonomyStatsCommandShowTreeDescription" xml:space="preserve">
<value>Recursively lists all descendent nodes.</value>
</data>
<data name="IndexListTermInfoCommandDescription" xml:space="preserve">
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ea6ec0fa/src/tools/lucene-cli/commands/analysis/analysis-stempel-patch-stems/AnalysisStempelPatchStemsCommand.cs
----------------------------------------------------------------------
diff --git a/src/tools/lucene-cli/commands/analysis/analysis-stempel-patch-stems/AnalysisStempelPatchStemsCommand.cs b/src/tools/lucene-cli/commands/analysis/analysis-stempel-patch-stems/AnalysisStempelPatchStemsCommand.cs
index 4e24118..6670990 100644
--- a/src/tools/lucene-cli/commands/analysis/analysis-stempel-patch-stems/AnalysisStempelPatchStemsCommand.cs
+++ b/src/tools/lucene-cli/commands/analysis/analysis-stempel-patch-stems/AnalysisStempelPatchStemsCommand.cs
@@ -41,7 +41,7 @@ namespace Lucene.Net.Cli
FromResource("StemmerTableFilesEncodingDescription"),
CommandOptionType.SingleValue);
- this.OnExecute(() => new IndexListHighFreqTermsCommand().Run(this));
+ this.OnExecute(() => new AnalysisStempelPatchStemsCommand().Run(this));
}
public virtual CommandArgument StemmerTableFiles { get; private set; }
@@ -60,7 +60,8 @@ namespace Lucene.Net.Cli
if (input.StemmerTableFilesEncoding.HasValue())
{
- args.AddRange(input.StemmerTableFilesEncoding.Values);
+ args.Add("--encoding");
+ args.Add(input.StemmerTableFilesEncoding.Value());
}
cmd.Main(args.ToArray());
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ea6ec0fa/src/tools/lucene-cli/commands/demo/demo-search-files/DemoSearchFilesCommand.cs
----------------------------------------------------------------------
diff --git a/src/tools/lucene-cli/commands/demo/demo-search-files/DemoSearchFilesCommand.cs b/src/tools/lucene-cli/commands/demo/demo-search-files/DemoSearchFilesCommand.cs
index b40e9c8..a7f6bd6 100644
--- a/src/tools/lucene-cli/commands/demo/demo-search-files/DemoSearchFilesCommand.cs
+++ b/src/tools/lucene-cli/commands/demo/demo-search-files/DemoSearchFilesCommand.cs
@@ -58,7 +58,7 @@ namespace Lucene.Net.Cli
this.PageSizeOption = this.Option(
"-p|--page-size <NUMBER>",
FromResource("PageSizeDescription"),
- CommandOptionType.NoValue);
+ CommandOptionType.SingleValue);
this.OnExecute(() => new DemoSearchFilesCommand().Run(this));
@@ -118,7 +118,6 @@ namespace Lucene.Net.Cli
if (input.RawOption.HasValue())
{
args.Add("--raw");
- args.Add(input.RawOption.Value());
}
if (input.PageSizeOption.HasValue())
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ea6ec0fa/src/tools/lucene-cli/commands/index/index-extract-cfs/IndexExtractCfsCommand.cs
----------------------------------------------------------------------
diff --git a/src/tools/lucene-cli/commands/index/index-extract-cfs/IndexExtractCfsCommand.cs b/src/tools/lucene-cli/commands/index/index-extract-cfs/IndexExtractCfsCommand.cs
index c3bce19..874f6a6 100644
--- a/src/tools/lucene-cli/commands/index/index-extract-cfs/IndexExtractCfsCommand.cs
+++ b/src/tools/lucene-cli/commands/index/index-extract-cfs/IndexExtractCfsCommand.cs
@@ -31,7 +31,7 @@ namespace Lucene.Net.Cli
this.Name = "extract-cfs";
this.Description = FromResource("Description");
- this.Argument("<CFS_FILE_NAME>", FromResource("CompoundFileNameDescription"));
+ this.Argument("<CFS_FILE_NAME>", FromResource("CFSFileNameDescription"));
this.Options.Add(new DirectoryTypeOption());
this.OnExecute(() => new IndexListCfsCommand(extract: true).Run(this));
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ea6ec0fa/src/tools/lucene-cli/commands/index/index-fix/IndexFixCommand.cs
----------------------------------------------------------------------
diff --git a/src/tools/lucene-cli/commands/index/index-fix/IndexFixCommand.cs b/src/tools/lucene-cli/commands/index/index-fix/IndexFixCommand.cs
index 0418d49..356c46f 100644
--- a/src/tools/lucene-cli/commands/index/index-fix/IndexFixCommand.cs
+++ b/src/tools/lucene-cli/commands/index/index-fix/IndexFixCommand.cs
@@ -1,5 +1,5 @@
-using Lucene.Net.Index;
-using System;
+using Lucene.Net.Cli.CommandLine;
+using Lucene.Net.Index;
namespace Lucene.Net.Cli
{
@@ -30,21 +30,36 @@ namespace Lucene.Net.Cli
this.Name = "fix";
this.Description = FromResource("Description");
+ this.ExtendedHelpText = FromResource("ExtendedHelpText");
this.Arguments.Add(new IndexDirectoryArgument());
this.Options.Add(new VerboseOption());
this.Options.Add(new CrossCheckTermVectorsOption());
this.Options.Add(new DirectoryTypeOption());
- this.Options.Add(new SegmentOption(allowMultiple: true) { Description = FromResource("SegmentsDescpription") });
+ // LUCENENET NOTE: This is effectively the same thing as running
+ // the check command, but using fix doesn't allow the option of
+ // specifying individual segments, so it is better to have an option here.
+ DryRunOption = this.Option("--dry-run",
+ FromResource("DryRunDescription"),
+ CommandOptionType.NoValue);
- this.OnExecute(() => new IndexCheckCommand(fix: true).Run(this));
+ this.OnExecute(() => new IndexFixCommand().Run(this));
}
+
+ public CommandOption DryRunOption { get; private set; }
}
public int Run(ConfigurationBase cmd)
{
- // We call IndexCheckCommand - nothing to do here.
- throw new NotSupportedException();
+ var input = cmd as Configuration;
+
+ bool fix = true;
+ if (input.DryRunOption.HasValue())
+ {
+ fix = false;
+ }
+
+ return new IndexCheckCommand(fix).Run(cmd);
}
}
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ea6ec0fa/src/tools/lucene-cli/commands/index/index-list-taxonomy-stats/IndexListTaxonomyStatsCommand.cs
----------------------------------------------------------------------
diff --git a/src/tools/lucene-cli/commands/index/index-list-taxonomy-stats/IndexListTaxonomyStatsCommand.cs b/src/tools/lucene-cli/commands/index/index-list-taxonomy-stats/IndexListTaxonomyStatsCommand.cs
index a0336a6..ad985d8 100644
--- a/src/tools/lucene-cli/commands/index/index-list-taxonomy-stats/IndexListTaxonomyStatsCommand.cs
+++ b/src/tools/lucene-cli/commands/index/index-list-taxonomy-stats/IndexListTaxonomyStatsCommand.cs
@@ -33,7 +33,7 @@ namespace Lucene.Net.Cli
this.Description = FromResource("Description");
this.Arguments.Add(new IndexDirectoryArgument());
- this.ShowTreeOption = this.Option("-tree|--show-tree", FromResource("ShowTreeOption"), CommandOptionType.NoValue);
+ this.ShowTreeOption = this.Option("-tree|--show-tree", FromResource("ShowTreeDescription"), CommandOptionType.NoValue);
this.OnExecute(() => new IndexListTaxonomyStatsCommand().Run(this));
}