Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions mcs/class/System.Runtime.Remoting/Test/RemotingServicesTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,61 @@ public void ExecuteMessage ()
}
}

[Test]
public void Reregister ()
{
var port = NetworkHelpers.FindFreePort ();
IDictionary props = new Hashtable ();
props ["port"] = port;
props ["bindTo"] = "127.0.0.1";
TcpChannel chn = new TcpChannel (props, null, null);
ChannelServices.RegisterChannel (chn);
try {
MarshalObject objMarshal = NewMarshalObject ();

RemotingConfiguration.RegisterWellKnownServiceType (typeof (MarshalObject), objMarshal.Uri, WellKnownObjectMode.SingleCall);
bool found = false;
foreach (WellKnownServiceTypeEntry entry in RemotingConfiguration.GetRegisteredWellKnownServiceTypes ())
{
if (entry.ObjectUri == objMarshal.Uri)
{
Assert.AreEqual (WellKnownObjectMode.SingleCall, entry.Mode, "found 1");
Assert.IsFalse (found, "found 1");
found = true;
}
}
Assert.IsTrue (found, "found 1");

RemotingConfiguration.RegisterWellKnownServiceType (typeof (MarshalObject), objMarshal.Uri, WellKnownObjectMode.SingleCall);
found = false;
foreach (WellKnownServiceTypeEntry entry in RemotingConfiguration.GetRegisteredWellKnownServiceTypes ())
{
if (entry.ObjectUri == objMarshal.Uri)
{
Assert.AreEqual (WellKnownObjectMode.SingleCall, entry.Mode, "found 2");
Assert.IsFalse (found, "found 2");
found = true;
}
}
Assert.IsTrue (found, "found 2");

RemotingConfiguration.RegisterWellKnownServiceType (typeof (MarshalObject), objMarshal.Uri, WellKnownObjectMode.Singleton);
found = false;
foreach (WellKnownServiceTypeEntry entry in RemotingConfiguration.GetRegisteredWellKnownServiceTypes ())
{
if (entry.ObjectUri == objMarshal.Uri)
{
Assert.AreEqual (WellKnownObjectMode.Singleton, entry.Mode, "found 3");
Assert.IsFalse (found, "found 3");
found = true;
}
}
Assert.IsTrue (found, "found 3");
} finally {
ChannelServices.UnregisterChannel (chn);
}
}

// Tests the IsOneWay method
[Test]
public void IsOneWay ()
Expand Down
3 changes: 0 additions & 3 deletions mcs/class/corlib/System.Runtime.Remoting/RemotingServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -737,9 +737,6 @@ private static void RegisterServerIdentity(ServerIdentity identity)
{
lock (uri_hash)
{
if (uri_hash.ContainsKey (identity.ObjectUri))
throw new RemotingException ("Uri already in use: " + identity.ObjectUri + ".");

uri_hash[identity.ObjectUri] = identity;
}
}
Expand Down