lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [15/50] [abbrv] lucenenet git commit: Lucene.Net.Support.TestOldPatches: Commented Test_Store_RAMDirectory() test because binary serialization is no longer considered a good practice
Date Sat, 09 Sep 2017 00:31:33 GMT
Lucene.Net.Support.TestOldPatches: Commented Test_Store_RAMDirectory() test because binary
serialization is no longer considered a good practice


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/dc993d0f
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/dc993d0f
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/dc993d0f

Branch: refs/heads/master
Commit: dc993d0fd8c3013bf931686c02369b3812061c74
Parents: 65a2ee2
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Sat Sep 2 05:21:39 2017 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Sat Sep 2 05:21:39 2017 +0700

----------------------------------------------------------------------
 src/Lucene.Net.Tests/Support/TestOldPatches.cs | 109 ++++++++++----------
 1 file changed, 57 insertions(+), 52 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/dc993d0f/src/Lucene.Net.Tests/Support/TestOldPatches.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/Support/TestOldPatches.cs b/src/Lucene.Net.Tests/Support/TestOldPatches.cs
index ccf7062..b6df6dd 100644
--- a/src/Lucene.Net.Tests/Support/TestOldPatches.cs
+++ b/src/Lucene.Net.Tests/Support/TestOldPatches.cs
@@ -83,58 +83,63 @@ namespace Lucene.Net.Support
         }
 #endif
 
-        //-------------------------------------------
-#if FEATURE_SERIALIZABLE
-        [Test]
-        [Description("LUCENENET-174")]
-        public void Test_Store_RAMDirectory()
-        {
-            Lucene.Net.Store.RAMDirectory ramDIR = new Lucene.Net.Store.RAMDirectory();
-
-            //Index 1 Doc
-            Lucene.Net.Analysis.Analyzer analyzer = new Lucene.Net.Analysis.Core.WhitespaceAnalyzer(Version.LUCENE_CURRENT);
-            var conf = new IndexWriterConfig(Version.LUCENE_CURRENT, analyzer);
-            Lucene.Net.Index.IndexWriter wr = new Lucene.Net.Index.IndexWriter(ramDIR, conf
/*new Lucene.Net.Analysis.WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.UNLIMITED*/);
-            Lucene.Net.Documents.Document doc = new Lucene.Net.Documents.Document();
-            doc.Add(new Lucene.Net.Documents.Field("field1", "value1 value11", Lucene.Net.Documents.Field.Store.YES,
Lucene.Net.Documents.Field.Index.ANALYZED));
-            wr.AddDocument(doc);
-            wr.Dispose();
-
-            //now serialize it 
-            System.Runtime.Serialization.Formatters.Binary.BinaryFormatter serializer = new
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
-            System.IO.MemoryStream memoryStream = new System.IO.MemoryStream();
-            serializer.Serialize(memoryStream, ramDIR);
-
-            //Close DIR
-            ramDIR.Dispose();
-            ramDIR = null;
-
-            //now deserialize 
-            memoryStream.Seek(0, System.IO.SeekOrigin.Begin);
-            Lucene.Net.Store.RAMDirectory ramDIR2 = (Lucene.Net.Store.RAMDirectory)serializer.Deserialize(memoryStream);
-
-            //Add 1 more doc
-            Lucene.Net.Analysis.Analyzer analyzer2 = new Lucene.Net.Analysis.Core.WhitespaceAnalyzer(Version.LUCENE_CURRENT);
-            var conf2 = new IndexWriterConfig(Version.LUCENE_CURRENT, analyzer);
-            wr = new Lucene.Net.Index.IndexWriter(ramDIR2, conf2 /*new Lucene.Net.Analysis.WhitespaceAnalyzer(),
false, IndexWriter.MaxFieldLength.UNLIMITED*/);
-            doc = new Lucene.Net.Documents.Document();
-            doc.Add(new Lucene.Net.Documents.Field("field1", "value1 value11", Lucene.Net.Documents.Field.Store.YES,
Lucene.Net.Documents.Field.Index.ANALYZED));
-            wr.AddDocument(doc);
-            wr.Dispose();
-
-            Lucene.Net.Search.TopDocs topDocs;
-            //Search
-            using (var reader = DirectoryReader.Open(ramDIR2))
-            {
-                Lucene.Net.Search.IndexSearcher s = new Lucene.Net.Search.IndexSearcher(reader);
-                Lucene.Net.QueryParsers.Classic.QueryParser qp = new Lucene.Net.QueryParsers.Classic.QueryParser(Version.LUCENE_CURRENT,
"field1", new Lucene.Net.Analysis.Standard.StandardAnalyzer(Version.LUCENE_CURRENT));
-                Lucene.Net.Search.Query q = qp.Parse("value1");
-                topDocs = s.Search(q, 100);
-            }
-
-            Assert.AreEqual(topDocs.TotalHits, 2, "See the issue: LUCENENET-174");
-        }
-#endif
+        // LUCENENENET: Microsoft no longer considers it good practice to use binary serialization
+        // in new applications. Therefore, we are no longer marking RAMDirectory serializable
+        // (It isn't serializable in Lucene 4.8.0 anymore anyway).
+        // See: https://github.com/dotnet/corefx/issues/23584
+
+//        //-------------------------------------------
+//#if FEATURE_SERIALIZABLE
+//        [Test]
+//        [Description("LUCENENET-174")]
+//        public void Test_Store_RAMDirectory()
+//        {
+//            Lucene.Net.Store.RAMDirectory ramDIR = new Lucene.Net.Store.RAMDirectory();
+
+//            //Index 1 Doc
+//            Lucene.Net.Analysis.Analyzer analyzer = new Lucene.Net.Analysis.Core.WhitespaceAnalyzer(Version.LUCENE_CURRENT);
+//            var conf = new IndexWriterConfig(Version.LUCENE_CURRENT, analyzer);
+//            Lucene.Net.Index.IndexWriter wr = new Lucene.Net.Index.IndexWriter(ramDIR,
conf /*new Lucene.Net.Analysis.WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.UNLIMITED*/);
+//            Lucene.Net.Documents.Document doc = new Lucene.Net.Documents.Document();
+//            doc.Add(new Lucene.Net.Documents.Field("field1", "value1 value11", Lucene.Net.Documents.Field.Store.YES,
Lucene.Net.Documents.Field.Index.ANALYZED));
+//            wr.AddDocument(doc);
+//            wr.Dispose();
+
+//            //now serialize it 
+//            System.Runtime.Serialization.Formatters.Binary.BinaryFormatter serializer =
new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
+//            System.IO.MemoryStream memoryStream = new System.IO.MemoryStream();
+//            serializer.Serialize(memoryStream, ramDIR);
+
+//            //Close DIR
+//            ramDIR.Dispose();
+//            ramDIR = null;
+
+//            //now deserialize 
+//            memoryStream.Seek(0, System.IO.SeekOrigin.Begin);
+//            Lucene.Net.Store.RAMDirectory ramDIR2 = (Lucene.Net.Store.RAMDirectory)serializer.Deserialize(memoryStream);
+
+//            //Add 1 more doc
+//            Lucene.Net.Analysis.Analyzer analyzer2 = new Lucene.Net.Analysis.Core.WhitespaceAnalyzer(Version.LUCENE_CURRENT);
+//            var conf2 = new IndexWriterConfig(Version.LUCENE_CURRENT, analyzer);
+//            wr = new Lucene.Net.Index.IndexWriter(ramDIR2, conf2 /*new Lucene.Net.Analysis.WhitespaceAnalyzer(),
false, IndexWriter.MaxFieldLength.UNLIMITED*/);
+//            doc = new Lucene.Net.Documents.Document();
+//            doc.Add(new Lucene.Net.Documents.Field("field1", "value1 value11", Lucene.Net.Documents.Field.Store.YES,
Lucene.Net.Documents.Field.Index.ANALYZED));
+//            wr.AddDocument(doc);
+//            wr.Dispose();
+
+//            Lucene.Net.Search.TopDocs topDocs;
+//            //Search
+//            using (var reader = DirectoryReader.Open(ramDIR2))
+//            {
+//                Lucene.Net.Search.IndexSearcher s = new Lucene.Net.Search.IndexSearcher(reader);
+//                Lucene.Net.QueryParsers.Classic.QueryParser qp = new Lucene.Net.QueryParsers.Classic.QueryParser(Version.LUCENE_CURRENT,
"field1", new Lucene.Net.Analysis.Standard.StandardAnalyzer(Version.LUCENE_CURRENT));
+//                Lucene.Net.Search.Query q = qp.Parse("value1");
+//                topDocs = s.Search(q, 100);
+//            }
+
+//            Assert.AreEqual(topDocs.TotalHits, 2, "See the issue: LUCENENET-174");
+//        }
+//#endif
 
 
         //-------------------------------------------


Mime
View raw message