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 2019/08/07 22:26:33 UTC
[lucenenet] 36/42: Lucene.Net.TestFramework.Util.LuceneTestCase:
Added try catch blocks to write stack traces to the console if exceptions
occur during OneTimeSetUp or OneTimeTearDown
This is an automated email from the ASF dual-hosted git repository.
nightowl888 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucenenet.git
commit ab138b130862ea3c697fb9666284f62dec793b43
Author: Shad Storhaug <sh...@shadstorhaug.com>
AuthorDate: Tue Aug 6 08:33:05 2019 +0700
Lucene.Net.TestFramework.Util.LuceneTestCase: Added try catch blocks to write stack traces to the console if exceptions occur during OneTimeSetUp or OneTimeTearDown
---
.../Util/LuceneTestCase.cs | 35 +++++++++++++++++-----
1 file changed, 28 insertions(+), 7 deletions(-)
diff --git a/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs b/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
index ad36742..8db12de 100644
--- a/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
+++ b/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
@@ -630,19 +630,40 @@ namespace Lucene.Net.Util
[OneTimeSetUp]
public virtual void BeforeClass()
{
- // Setup the factories
- Codec.SetCodecFactory(TEST_CODEC_FACTORY);
- DocValuesFormat.SetDocValuesFormatFactory(TEST_DOCVALUES_FORMAT_FACTORY);
- PostingsFormat.SetPostingsFormatFactory(TEST_POSTINGS_FORMAT_FACTORY);
+
+ try
+ {
+ // Setup the factories
+ Codec.SetCodecFactory(TEST_CODEC_FACTORY);
+ DocValuesFormat.SetDocValuesFormatFactory(TEST_DOCVALUES_FORMAT_FACTORY);
+ PostingsFormat.SetPostingsFormatFactory(TEST_POSTINGS_FORMAT_FACTORY);
- ClassEnvRule.Before(this);
+ ClassEnvRule.Before(this);
+ }
+ catch (Exception ex)
+ {
+ // Print the stack trace so we have something to go on if an error occurs here.
+ Console.Write("An exception occurred during BeforeClass: ");
+ Console.WriteLine(ex.ToString());
+ throw;
+ }
}
[OneTimeTearDown]
public virtual void AfterClass()
{
- ClassEnvRule.After(this);
- CleanupTemporaryFiles();
+ try
+ {
+ ClassEnvRule.After(this);
+ CleanupTemporaryFiles();
+ }
+ catch (Exception ex)
+ {
+ // Print the stack trace so we have something to go on if an error occurs here.
+ Console.Write("An exception occurred during AfterClass: ");
+ Console.WriteLine(ex.ToString());
+ throw;
+ }
}
// -----------------------------------------------------------------