lucene-lucene-net-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aro...@apache.org
Subject svn commit: r683791 - in /incubator/lucene.net/trunk/C#/src/Test/Search: TestRemoteCachingWrapperFilter.cs TestRemoteSearchable.cs TestSort.cs
Date Fri, 08 Aug 2008 01:39:03 GMT
Author: aroush
Date: Thu Aug  7 18:39:02 2008
New Revision: 683791

URL: http://svn.apache.org/viewvc?rev=683791&view=rev
Log:
LUCENENET-139 "Bugs in test codes (remote searching) stemming from opening the same port twice
or registering an already registered http channel"

Modified:
    incubator/lucene.net/trunk/C#/src/Test/Search/TestRemoteCachingWrapperFilter.cs
    incubator/lucene.net/trunk/C#/src/Test/Search/TestRemoteSearchable.cs
    incubator/lucene.net/trunk/C#/src/Test/Search/TestSort.cs

Modified: incubator/lucene.net/trunk/C#/src/Test/Search/TestRemoteCachingWrapperFilter.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Search/TestRemoteCachingWrapperFilter.cs?rev=683791&r1=683790&r2=683791&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Search/TestRemoteCachingWrapperFilter.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Search/TestRemoteCachingWrapperFilter.cs Thu Aug
 7 18:39:02 2008
@@ -46,31 +46,31 @@
 		public override void SetUp()
 		{
 			base.SetUp();
-			Random rnd = new Random();
-			port = rnd.Next(1099, 9999);
+			Random rnd = new Random((int) (DateTime.Now.Ticks & 0x7fffffff));
+			port = rnd.Next(System.Net.IPEndPoint.MinPort, System.Net.IPEndPoint.MaxPort);
 			httpChannel = new System.Runtime.Remoting.Channels.Http.HttpChannel(port);
+			if (!serverStarted)
+				StartServer();
 		}
 
 		[TearDown]
 		public override void TearDown()
 		{
+			try
+			{
+				System.Runtime.Remoting.Channels.ChannelServices.UnregisterChannel(httpChannel);
+			}
+			catch
+			{
+			}
+            
 			httpChannel = null;
 			base.TearDown();
 		}
 
 		private static Lucene.Net.Search.Searchable GetRemote()
 		{
-			try
-			{
-				if (!serverStarted)
-					StartServer();
-				return LookupRemote();
-			}
-			catch (System.Exception)
-			{
-				StartServer();
-				return LookupRemote();
-			}
+			return LookupRemote();
 		}
 
 		private static Lucene.Net.Search.Searchable LookupRemote()
@@ -80,6 +80,11 @@
 
 		private static void StartServer()
 		{
+			if (serverStarted)
+			{
+				return;
+			}
+
 			// construct an index
 			RAMDirectory indexStore = new RAMDirectory();
 			IndexWriter writer = new IndexWriter(indexStore, new SimpleAnalyzer(), true);

Modified: incubator/lucene.net/trunk/C#/src/Test/Search/TestRemoteSearchable.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Search/TestRemoteSearchable.cs?rev=683791&r1=683790&r2=683791&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Search/TestRemoteSearchable.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Search/TestRemoteSearchable.cs Thu Aug  7 18:39:02
2008
@@ -42,40 +42,45 @@
 		public override void SetUp()
 		{
 			base.SetUp();
-			Random rnd = new Random();
-			port = rnd.Next(1099, 9999);
+			Random rnd = new Random((int)(DateTime.Now.Ticks & 0x7fffffff));
+			port = rnd.Next(System.Net.IPEndPoint.MinPort, System.Net.IPEndPoint.MaxPort);
 			httpChannel = new System.Runtime.Remoting.Channels.Http.HttpChannel(port);
+			if (!serverStarted)
+				StartServer();
 		}
 
 		[TearDown]
 		public override void TearDown()
 		{
-			httpChannel = null;
+            try
+            {
+                System.Runtime.Remoting.Channels.ChannelServices.UnregisterChannel(httpChannel);
+            }
+            catch
+            {
+            }
+
+            httpChannel = null;
 			base.TearDown();
 		}
 
 		private static Lucene.Net.Search.Searchable GetRemote()
 		{
-			try
-			{
-				if (!serverStarted)
-					StartServer();
-				return LookupRemote();
-			}
-			catch (System.Exception)
-			{
-				StartServer();
-				return LookupRemote();
-			}
+			return LookupRemote();
 		}
 
 		private static Lucene.Net.Search.Searchable LookupRemote()
 		{
-			return (Lucene.Net.Search.Searchable)Activator.GetObject(typeof(Lucene.Net.Search.Searchable),
string.Format("http://localhost:{0}/Searchable", port));
+			return (Lucene.Net.Search.Searchable)Activator.GetObject(typeof(Lucene.Net.Search.Searchable),
string.Format("http://localhost:{0}/RemoteSearchable", port));
 		}
 
 		public static void StartServer()
 		{
+			if (serverStarted)
+			{
+				return;
+			}
+
 			try
 			{
 				System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(httpChannel, false);
@@ -102,7 +107,7 @@
 			// publish it
 			Lucene.Net.Search.Searchable local = new IndexSearcher(indexStore);
 			RemoteSearchable impl = new RemoteSearchable(local);
-			System.Runtime.Remoting.RemotingServices.Marshal(impl, "Searchable");
+			System.Runtime.Remoting.RemotingServices.Marshal(impl, "RemoteSearchable");
 			serverStarted = true;
 		}
 		

Modified: incubator/lucene.net/trunk/C#/src/Test/Search/TestSort.cs
URL: http://svn.apache.org/viewvc/incubator/lucene.net/trunk/C%23/src/Test/Search/TestSort.cs?rev=683791&r1=683790&r2=683791&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Search/TestSort.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Search/TestSort.cs Thu Aug  7 18:39:02 2008
@@ -789,8 +789,8 @@
 
 		private System.Runtime.Remoting.Channels.Http.HttpChannel GetHttpChannel()
 		{
-			Random rnd = new Random();
-			port = rnd.Next(1099, 9999);
+			Random rnd = new Random((int) (DateTime.Now.Ticks & 0x7fffffff));
+			port = rnd.Next(System.Net.IPEndPoint.MinPort, System.Net.IPEndPoint.MaxPort);
 			System.Runtime.Remoting.Channels.Http.HttpChannel ch = new System.Runtime.Remoting.Channels.Http.HttpChannel(port);
 			return ch;
 		}



Mime
View raw message