lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aro...@apache.org
Subject svn commit: r569954 - /incubator/lucene.net/trunk/C#/src/Test/Search/TestRemoteSearchable.cs
Date Mon, 27 Aug 2007 01:47:54 GMT
Author: aroush
Date: Sun Aug 26 18:47:54 2007
New Revision: 569954

URL: http://svn.apache.org/viewvc?rev=569954&view=rev
Log:
Fix: LUCENENET-93 "NUnite test for Search.TestRemoteSearchable"

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

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=569954&r1=569953&r2=569954&view=diff
==============================================================================
--- incubator/lucene.net/trunk/C#/src/Test/Search/TestRemoteSearchable.cs (original)
+++ incubator/lucene.net/trunk/C#/src/Test/Search/TestRemoteSearchable.cs Sun Aug 26 18:47:54
2007
@@ -35,26 +35,30 @@
     public class TestRemoteSearchable
 	{
 		
-		private static Lucene.Net.Search.Searchable GetRemote()
+		private Lucene.Net.Search.Searchable GetRemote()
 		{
-			try
-			{
-				return LookupRemote();
-			}
-			catch (System.Exception e)
-			{
-				StartServer();
-				return LookupRemote();
-			}
+            return LookupRemote();
 		}
 		
-		private static Lucene.Net.Search.Searchable LookupRemote()
+		private  Lucene.Net.Search.Searchable LookupRemote()
 		{
-			return (Lucene.Net.Search.Searchable) Activator.GetObject(typeof(Lucene.Net.Search.Searchable),
"http://localhost/Searchable");
+            return (Lucene.Net.Search.Searchable) Activator.GetObject(typeof(Lucene.Net.Search.Searchable),
@"http://localhost:1099/Searchable");
 		}
 		
-		private static void  StartServer()
+		[SetUp]
+        public void StartServer()
 		{
+            try
+            {
+                System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(new System.Runtime.Remoting.Channels.Http.HttpChannel(1099));
+            }
+            catch (System.Net.Sockets.SocketException ex)
+            {
+                if (ex.ErrorCode == 10048)
+                    return;     // EADDRINUSE?
+                throw ex;
+            }
+
 			// construct an index
 			RAMDirectory indexStore = new RAMDirectory();
 			IndexWriter writer = new IndexWriter(indexStore, new SimpleAnalyzer(), true);
@@ -65,13 +69,12 @@
 			writer.Close();
 			
 			// publish it
-			// LocateRegistry.createRegistry(1099); // {{Aroush-1.9}}
 			Lucene.Net.Search.Searchable local = new IndexSearcher(indexStore);
 			RemoteSearchable impl = new RemoteSearchable(local);
-			System.Runtime.Remoting.RemotingServices.Marshal(impl, "http://localhost/Searchable");
+			System.Runtime.Remoting.RemotingServices.Marshal(impl, "Searchable");
 		}
 		
-		private static void  Search(Query query)
+		private void  Search(Query query)
 		{
 			// try to search the published index
 			Lucene.Net.Search.Searchable[] searchables = new Lucene.Net.Search.Searchable[]{GetRemote()};



Mime
View raw message