lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jokin Cuadrado" <joki...@gmail.com>
Subject Unit test and remoting.
Date Tue, 11 Dec 2007 09:55:24 GMT
when running all the test for Lucene.Net.Search from NUnit  (2.4.3) I get:

Lucene.Net.Search.TestSort.TestNormalizedScores :
System.Runtime.Remoting.RemotingException : requested service not
found.

the problem is with TestRemoteSearchable, that starts a new
RemoteSearchable, and don't free the resources, so when
TestNormalizedScores.StartServer try to open a new channel it fails
because the channel is already registered and don't start the server.
Running both test alone works without any problem.

I have fixed it checking for ChannelServices.RegisteredChannels before
tried to register a channel, and making a "singleton" with startserver
to start the server only the first time it is calle, but don't know if
this is the better solution, or would be better start and stop the
server in every test.

Has somebody get the same problem?



the modified startserver() function:

static System.Runtime.Remoting.ObjRef RemoteSearchable;
public void  StartServer()
	{
            if (RemoteSearchable == null)
            {
               if
(System.Runtime.Remoting.Channels.ChannelServices.RegisteredChannels.Length
== 0)
                {

System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(new
System.Runtime.Remoting.Channels.Http.HttpChannel(1099), false);
                }
                // construct an index
                Searcher local = GetFullIndex();
                // publish it
                RemoteSearchable impl = new RemoteSearchable(local);
                RemoteSearchable =
System.Runtime.Remoting.RemotingServices.Marshal(impl,
"SortedSearchable");
            }

        }

Mime
View raw message