You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucenenet.apache.org by Jokin Cuadrado <jo...@gmail.com> on 2007/12/11 10:55:24 UTC

Unit test and remoting.

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");
            }

        }