public static void Main(string[] args)
    {
        Console.WriteLine("GoBang 0.001");
        string host;
        int port;
        if (args.Length < 2)
        {
            host = "localhost";
            port = 7777;

        }
        else
        {
            host = args[0];
            port = int.Parse(args[1]);
        }
        Player one = new NewAiPlayer();
        //Player two = new NewAiPlayer();
        Player two = new Communicator(host, port);

        string color = two.AskColor();
        int size = two.AskSize();

        if (color == "white")
        {
            one.SetColor("white");
            two.SetColor("black");
        }
        else
        {
            Player tmp = one;
            one = two;
            two = tmp;
            one.SetColor("white");
            two.SetColor("black");
        }
        one.SetSize(size);
        two.SetSize(size);

        int[,] board = new int[size, size];
        Coordinate move;
        while (true) {
            move = one.GetMove();
            Console.WriteLine("Got move from player 1: {0}", move);
            if (!valid(board,move))
                throw new Exception("Invalid move " + move);
            board[move.X, move.Y] = 1;
            printBoard(board);
            if (winning(board, 1)) throw new Exception("white has won");
            two.RegOppMove(move);
            move = two.GetMove();
            Console.WriteLine("Got move from player 2: {0}", move);
            if (!valid(board,move))
                throw new Exception("Invalid move " + move);
            board[move.X, move.Y] = -1;
            printBoard(board);
            if (winning(board, -1)) throw new Exception("black has won");
            one.RegOppMove(move);
        }
    }
Beispiel #2
0
        public Operations(Communicator communicator)
        {
            this.communicator = communicator;

            databaseConnectionSessionID = this.communicator.CurrentSessionID;
            databaseConnectionCallback = this.communicator.ClientList[databaseConnectionSessionID];
        }
 // Receive in a seperate thread
 public MessageHandler(MainGrid active_grid)
 {
     c = Communicator.GetInstance(active_grid);
     ThreadStart ts = new ThreadStart(c.ReceiveData);
     Thread t = new Thread(ts,50000000);
     t.Start();
 }
        internal IceMessageSender(Uri serviceUri)
        {
            var address = string.Format("OrderService:tcp -p {1} -h {0}", serviceUri.Host, serviceUri.Port);

            communicator = Util.initialize();
            proxy = IMessageServicePrxHelper.checkedCast(communicator.stringToProxy(address));
        }
        public TempCommunicator(string configFileClasspath)
        {
            log("Constructor called");
            try
            {
                InitializationData initData = new InitializationData();
                initData.properties = Util.createProperties();
                initData.properties.load(configFileClasspath);
                communicator = Util.initialize(initData);
                log("Properties Loaded!");
            }
            catch (Exception e)
            {
                log(e.ToString());
                throw e;
            }
            string proxy1 = "'::TeRK::TeRKUser':tcp -h 127.0.0.1 -p 10101";
            log("Calling stringToProxy on " + proxy1);
            communicator.stringToProxy(proxy1);
            log("Complete!");

            string proxy2 = "'::TeRK::TeRKUser':tcp -h 192.168.0.16 -p 10101";
            log("Calling stringToProxy on " + proxy2);
            communicator.stringToProxy(proxy2);
            log("Complete!");

            log("Constructor terminated");
            writeLog("C:\\tempCommLog.txt");
        }
        static void Main()
        {
            try
            {
                _log.InfoFormat("User: {0}", Environment.UserName);

                while (CommunicatorNotRunning())
                {
                    _log.Info("Communicator is not running. Will try again in 5 seconds");
                    System.Threading.Thread.Sleep(5000);
                }

                var communicator = new Communicator(GetRecordHistoryInterval());
                communicator.ConversationEnded += (s, e) => new SaveConversationToFile(_historyFile).Save(e.EventData);

                var notifyIcon = MakeNotifyIcon();
                notifyIcon.Visible = true;
                Application.Run();
                notifyIcon.Visible = false;
                communicator.Dispose();
            }
            catch (Exception e)
            {
                _log.Error("Exception caught", e);
            }
        }
Beispiel #7
0
 public PluginManagerI(Communicator communicator)
 {
     _communicator = communicator;
     _plugins = new Hashtable();
     _initOrder = new ArrayList();
     _initialized = false;
 }
 public MainWindow()
     : base(Gtk.WindowType.Toplevel)
 {
     Build ();
     this._com = new Communicator (new TcpClient ("192.168.0.10", 8888));
     this._vm = new ValueManager (555);
 }
 protected override void Dispose(bool disposing)
 {
     if (disposing && communicator != null)
     {
         communicator.destroy();
         communicator = null;
     }
 }
Beispiel #10
0
        public MainForm()
        {
            InitializeComponent();            

            _communicator = Communicator.getInstance();

            _activeTalks = new List<Talk>();            
        }
Beispiel #11
0
 private void client_ConnexionRemoved(Communicator c, IConnexion conn)
 {
     /* if (!IsDisposed && client.Connexions.Count == 0)
     {
         MessageBox.Show(this, "Disconnected from server", Text);
         Close();
     } */
 }
 private void Dispose(bool disposing)
 {
     if (disposing && communicator!= null)
     {
         communicator.destroy();
         communicator = null;
     }
 }
Beispiel #13
0
 static void Main(string[] args)
 {
     Console.WriteLine("Server started.");
     var settings = LoadSettings("Settings.txt");
     GameStateServer gameState = new GameStateServer(settings.Map);
     Communicator communicator = new Communicator(settings.ServerPort, settings.ServerConnectionPort, gameState);
     Console.ReadKey();
     System.Threading.Thread.Sleep(5000);
 }
Beispiel #14
0
    public static Communicator getInstance()
    {
        if (instance == null)
        {
            instance = new Communicator();
        }

        return instance;
    }
Beispiel #15
0
 public void GetGameConfiguration(Action<Response<GameConfiguration>> callback)
 {
     var payload = new Dictionary<string, object>(0);
      var communicator = new Communicator(this);
      communicator.SendPayload<GameConfiguration>(Communicator.POST, "conf", payload, r =>
      {
     if (r.Success) { r.Data = JsonConvert.DeserializeObject<GameConfiguration>(r.Raw); }
     callback(r);
      });
 }
Beispiel #16
0
        public PingTimesForm(Communicator comm)
        {
            InitializeComponent();
            _pingTimes.ClearData(ClearDataFlag.Values);
            _pingTimes.AxisX.Min = 0;

            Text += ": " + comm;
            _observed = comm;
            _statsObserver = CommunicationStatisticsObserver<Communicator>.On(comm);
        }
Beispiel #17
0
 public void GetAssets(Action<Response<IList<Asset>>> callback)
 {
     var payload = new Dictionary<string, object> {{"key", Key}};
      var communicator = new Communicator(this);
      communicator.SendPayload<IList<Asset>>(Communicator.Get, "assets", payload, r =>
      {
     if (r.Success) { r.Data = JsonConvert.DeserializeObject<IList<Asset>> (r.Raw); }
     if (callback != null) { callback(r); }
      });
 }
Beispiel #18
0
 public void AchievementEarned(string achievementId, string userName, string uniqueIdentifier, Action<Response<Achievement>> callback)
 {
     var payload = new Dictionary<string, object> { { "aid", achievementId }, { "username", userName }, { "userkey", uniqueIdentifier } };
      var communicator = new Communicator(this);
      communicator.SendPayload<Achievement>(Communicator.Post, "achievements", payload, r =>
      {
     if (r.Success) { r.Data = JsonConvert.DeserializeObject<Achievement>(r.Raw); }
     if (callback != null) { callback(r); }
      });
 }
 public MainWindow()
 {
     InitializeComponent();
     comm = Communicator.Instance;
     this.Background = ThemeParser.GetColor(ThemeParser.Colors.Background);
     comm.ConnectionStatusChanged += new EventHandler<ConnectionStatusChangedEventArgs>(comm_ConnectionStatusChanged);
     comm.DataRecieved += new EventHandler<DataReceivedEventArgs>(comm_DataRecieved);
     mHandler.NewIncomingMessage += new EventHandler<NewIncomingMessageEventArgs>(mHandler_NewIncomingMessage);
     this.Closing += new System.ComponentModel.CancelEventHandler(MainWindow_Closing);
     this.Loaded += new RoutedEventHandler(MainWindow_Loaded);
 }
Beispiel #20
0
 public void LogAsync(string message, Action<LogResponse> callback)
 {
     var communicator = new Communicator(this);
     var callbackWrapper = callback == null ? (Action<Response>) null : r =>
     {
     if (r.Success)
     {
         callback(JsonConvert.DeserializeObject<LogResponse>(r.Raw));
     }
     };
     communicator.SendPayload(Communicator.POST, string.Concat("inputs/", _inputKey), message, callbackWrapper);
 }
Beispiel #21
0
     ThreadHookPlugin(Communicator communicator, ThreadNotification threadHook)
     {
         if(communicator == null)
         {
             PluginInitializationException ex = new PluginInitializationException();
             ex.reason = "Communicator cannot be null";
             throw ex;
         }
 
         IceInternal.Instance instance = IceInternal.Util.getInstance(communicator);
         instance.setThreadHook(threadHook);
     }
Beispiel #22
0
 public void GetGameVersion(Action<Response<int>> callback)
 {
     var payload = new Dictionary<string, object>(0);
      var communicator = new Communicator(this);
      communicator.SendPayload<int>(Communicator.POST, "conf/version", payload, r =>
      {
     if (r.Success)
     {
        var container = ((JContainer) JsonConvert.DeserializeObject(r.Raw))["version"];
        r.Data = container == null ? 0 : container.Value<int>();
     }
     callback(r);
      });
 }
Beispiel #23
0
 public void TestWrite()
 {
     using (MemoryStream stream = new MemoryStream())
     {
         Communicator communicator = new Communicator(
             new StreamSimpleCommunicator<object>(stream, null));
         foreach (object message in
             new object[] { new A { UIntValue = 1 }, new A { UIntValue = 2 } })
         {
             communicator.Send(message);
         }
         AssertExtensions.AreEqual(
             new byte[] { 0x02, 0x08, 0x01, 0x02, 0x08, 0x02 },
             stream.ToArray());
     }
 }
 public RelayCommunicator(string applicationName, string configFileClasspath)
 {
     try
        {
        InitializationData initData = new InitializationData();
        initData.properties = Util.createProperties();
        Trace.TraceInformation("About to load properties...");
        initData.properties.load(configFileClasspath);
        Trace.TraceInformation("Done loading properties!  About to call Util.initialize()...");
        communicator = Util.initialize(initData);
        Trace.TraceInformation("Done calling Util.initialize()!");
        }
        catch (Exception e)
        {
        throw e;
        }
 }
        /// <summary>
        /// Constructor
        /// </summary>
        public ArbiterCore()
        {
            // begin the log
            ArbiterOutput.BeginLog();

            // constructor
            this.communicator = new Communicator(this);

            // set intelligence core
            this.intelligenceCore = new CoreIntelligence.Core();

            #region Handle Events

            this.OnRoadNetworkChanged += new RoadNetworkChangedDelegate(ArbiterCore_OnRoadNetworkChanged);
            this.OnMissionDescriptionChanged += new MissionDescriptionChangedDelegate(ArbiterCore_OnMissionDescriptionChanged);

            #endregion
        }
Beispiel #26
0
 public void Log(string message, bool json, Action<LogResponse> callback)
 {
     var communicator = new Communicator(this);
      var callbackWrapper = callback == null ? (Action<Response>) null : r =>
      {
     if (r.Success)
     {
        var res = JsonConvert.DeserializeObject<LogResponse>(r.Raw);
        res.Success = true;
        callback(res);
     }
     else
     {
        var res = new LogResponse{ Success = false };
        callback(res);
     }
      };
      communicator.SendPayload(Communicator.POST, string.Concat("inputs/", _inputKey), message, json, callbackWrapper);
 }
Beispiel #27
0
        public void LogAsync(string message, Action<LogResponse> callback)
        {
            var communicator = new Communicator(this);
            var callbackWrapper = callback == null ? (Action<Response>)null : r =>
            {
                if (r.Success)
                {
                    var js = new JavaScriptSerializer();
                    callback(js.Deserialize<LogResponse>(r.Raw));
                }
            };

            try{
                communicator.SendPayload(Communicator.POST, string.Format(Routes.Log, _inputKey), message, callbackWrapper);
            }catch(Exception ex)
            {
                // yes I know it's bad)
            }
        }
Beispiel #28
0
     LoggerPlugin(Communicator communicator, Logger logger)
     {
         if(communicator == null)
         {
             PluginInitializationException ex = new PluginInitializationException();
             ex.reason = "Communicator cannot be null";
             throw ex;
         }
 
         if(logger == null)
         {
             PluginInitializationException ex = new PluginInitializationException();
             ex.reason = "Logger cannot be null";
             throw ex;
         }
 
         IceInternal.Instance instance = IceInternal.Util.getInstance(communicator);
         instance.setLogger(logger);
     }
Beispiel #29
0
        public DHTNodeI(string nodeName, bool isMaster, Communicator communicator)
        {
            IsDisconnecting = false;
            _communicator = communicator;
            _nodeName = nodeName;

            if (isMaster)
            {
                subtreeRange = new range(int.MinValue, int.MaxValue);
                _parent = null;
                ranges.Add(new range(int.MinValue, int.MaxValue));
                Console.WriteLine(describe());
                return;
            }

            while (true)
            {
                ObjectPrx oprx = communicator.stringToProxy(Constants.SERVICE_NAME);
                DHTNodePrx nprx =  DHTNodePrxHelper.checkedCast(oprx);
                if (nprx != null)
                {
                    try
                    {
                        nodeConf my_node = nprx.newConnected(nodeName);
                        subtreeRange = new range(my_node.min, my_node.max);
                        ranges.Add(new range(my_node.min, my_node.max));
                        _parent = my_node.parentNode;
                        Console.WriteLine(describe());
                        return;
                    }
                    catch (Ice.Exception e)
                    {
                        Console.WriteLine(e.StackTrace);
                    }
                }
                else
                {
                    Console.WriteLine("Wait for master");
                    Thread.Sleep(500);
                }
            }
        }
Beispiel #30
0
        public void connect(String ipAddr, String port)
        {
            lock (this)
            {
                if (!IsConnected)
                {
                    communicator = new Communicator();
                    if (communicator.Connect(ipAddr, port, TestController.robossClientName) < 0)
                    {
                        string msg = "Unable to connect RoboSS controller " + ipAddr + ":" + port;
                        LOG.Debug(msg);
                        communicator = null;
                        throw new CommunicatorException(msg);
                    }
                    LOG.Info("Connected to RoboSS controller " + ipAddr + ":" + port);
                    IsConnected = true;

                }
            }
        }
        /// <summary>
        /// Deletes the room link information.
        /// </summary>
        /// <param name="roomId">The chat room id.</param>
        /// <returns>The response data.</returns>
        public ResponseData <DataType> DeleteRoomLink(long roomId)
        {
            var path = string.Format(CultureInfo.InvariantCulture, Path.RoomLink, roomId);

            return(Communicator.Delete <DataType>(path));
        }
Beispiel #32
0
 /// <summary>
 /// Cancel a server upgrade
 /// </summary>
 /// <param name="resourceGroupName">The resource group the server is in</param>
 /// <param name="serverName">The name of the server to cancel upgrade</param>
 public void Cancel(string resourceGroupName, string serverName)
 {
     Communicator.Cancel(resourceGroupName, serverName);
 }
 /// <summary>
 /// Update index recommendation state.
 /// </summary>
 /// <param name="resourceGroupName">Resource group name</param>
 /// <param name="serverName">Server name</param>
 /// <param name="indexRecommendation">Index recommendation</param>
 public void UpdateRecommendationState(string resourceGroupName, string serverName, IndexRecommendation indexRecommendation)
 {
     Communicator.UpdateRecommendedIndexState(resourceGroupName, serverName, indexRecommendation.DatabaseName, indexRecommendation.Schema, indexRecommendation.Table, indexRecommendation.Name, indexRecommendation.State, Util.GenerateTracingId());
 }
Beispiel #34
0
 /// <summary>
 /// Get's the list of all chats on owner's account.
 /// </summary>
 /// <returns>The response data.</returns>
 public ResponseData <DataType> GetRooms()
 {
     return(Communicator.Get <DataType>(Path.Rooms));
 }
        /// <summary>
        /// Gets a Transparent Data Encryption in a server
        /// </summary>
        /// <param name="resourceGroupName">The name of the resource group</param>
        /// <param name="serverName">The name of the server</param>
        /// <param name="databaseName">The name of the database</param>
        /// <returns>The Transparent Data Encryption</returns>
        public AzureSqlDatabaseTransparentDataEncryptionModel GetTransparentDataEncryption(string resourceGroupName, string serverName, string databaseName)
        {
            var resp = Communicator.Get(resourceGroupName, serverName, databaseName, Util.GenerateTracingId());

            return(CreateTransparentDataEncryptionModelFromResponse(resourceGroupName, serverName, databaseName, resp));
        }
Beispiel #36
0
        public static void TestFacets(Communicator com, bool builtInFacets, bool filtered)
        {
            if (builtInFacets && !filtered)
            {
                TestHelper.Assert(com.FindAdminFacet("Properties") != null);
                TestHelper.Assert(com.FindAdminFacet("Process") != null);
                TestHelper.Assert(com.FindAdminFacet("Logger") != null);
                TestHelper.Assert(com.FindAdminFacet("Metrics") != null);
            }

            var f1 = new TestFacet();
            var f2 = new TestFacet();
            var f3 = new TestFacet();

            if (!filtered)
            {
                com.AddAdminFacet("Facet1", f1);
                com.AddAdminFacet("Facet2", f2);
                com.AddAdminFacet("Facet3", f3);
            }
            else
            {
                try
                {
                    com.AddAdminFacet("Facet1", f1);
                    TestHelper.Assert(false);
                }
                catch (ArgumentException)
                {
                }

                try
                {
                    com.AddAdminFacet("Facet2", f2);
                    TestHelper.Assert(false);
                }
                catch (ArgumentException)
                {
                }

                try
                {
                    com.AddAdminFacet("Facet3", f3);
                    TestHelper.Assert(false);
                }
                catch (ArgumentException)
                {
                }
            }

            if (!filtered)
            {
                TestHelper.Assert(com.FindAdminFacet("Facet1") == f1);
                TestHelper.Assert(com.FindAdminFacet("Facet2") == f2);
                TestHelper.Assert(com.FindAdminFacet("Facet3") == f3);
            }
            else
            {
                TestHelper.Assert(com.FindAdminFacet("Facet1") == null);
                TestHelper.Assert(com.FindAdminFacet("Facet2") == null);
                TestHelper.Assert(com.FindAdminFacet("Facet3") == null);
            }
            TestHelper.Assert(com.FindAdminFacet("Bogus") == null);

            IReadOnlyDictionary <string, IObject> facetMap = com.FindAllAdminFacets();

            if (builtInFacets)
            {
                TestHelper.Assert(facetMap.Count == 7);
                TestHelper.Assert(facetMap.ContainsKey("Properties"));
                TestHelper.Assert(facetMap.ContainsKey("Process"));
                TestHelper.Assert(facetMap.ContainsKey("Logger"));
                TestHelper.Assert(facetMap.ContainsKey("Metrics"));
            }
            else if (filtered)
            {
                TestHelper.Assert(facetMap.Count >= 1);
                TestHelper.Assert(facetMap.ContainsKey("Properties"));
            }

            if (!filtered)
            {
                TestHelper.Assert(facetMap.ContainsKey("Facet1"));
                TestHelper.Assert(facetMap.ContainsKey("Facet2"));
                TestHelper.Assert(facetMap.ContainsKey("Facet3"));

                try
                {
                    com.AddAdminFacet("Facet1", f1);
                    TestHelper.Assert(false);
                }
                catch (ArgumentException)
                {
                    // Expected
                }
            }

            IObject?facet = com.RemoveAdminFacet("Bogus");

            TestHelper.Assert(facet == null);

            if (!filtered)
            {
                facet = com.RemoveAdminFacet("Facet1");
                TestHelper.Assert(facet == f1);
                com.RemoveAdminFacet("Facet2");
                com.RemoveAdminFacet("Facet3");
                facet = com.RemoveAdminFacet("Facet1");
                TestHelper.Assert(facet == null);
            }
        }
Beispiel #37
0
 /// <summary>
 /// Get's the list of all chats on owner's account asynchronously.
 /// </summary>
 /// <param name="callback">The callback action.</param>
 public async void GetRoomsAsync(Action <ResponseData <DataType> > callback)
 {
     await Communicator.CreateGetTask(callback, Path.Rooms)
     .ConfigureAwait(false);
 }
Beispiel #38
0
        /// <summary>
        /// Changes the specified task's status.
        /// </summary>
        /// <param name="roomId">The chat room id.</param>
        /// <param name="taskId">The task id.</param>
        /// <param name="parameters">The updating task parameters.</param>
        /// <returns>The response data.</returns>
        public ResponseData <DataType> PutRoomTaskStatus(long roomId, long taskId, ParametersType parameters)
        {
            var path = string.Format(CultureInfo.InvariantCulture, Path.RoomTaskStatus, roomId, taskId);

            return(Communicator.Put <DataType, ParametersType>(path, parameters));
        }
 public ArrayMember(int length, Communicator <GameObject> .Types baseType)
 {
     Length   = length;
     BaseType = baseType;
 }
Beispiel #40
0
        public void SetDatabaseAuditingPolicy(AuditingPolicy policy, String clientId)
        {
            DatabaseSecurityPolicyUpdateParameters parameters = UnwrapPolicy(policy);

            Communicator.SetDatabaseSecurityPolicy(policy.ResourceGroupName, policy.ServerName, policy.DatabaseName, clientId, parameters);
        }
Beispiel #41
0
 /// <summary>
 /// Changes the specified task's status asynchronously.
 /// </summary>
 /// <param name="callback">The callback action.</param>
 /// <param name="roomId">The chat room id.</param>
 /// <param name="taskId">The task id.</param>
 /// <param name="parameters">the updating task parameters.</param>
 public async void PutRoomTaskStatusAsync(Action <ResponseData <DataType> > callback, long roomId, long taskId, ParametersType parameters)
 {
     var path = string.Format(CultureInfo.InvariantCulture, Path.RoomTaskStatus, roomId, taskId);
     await Communicator.CreatePutTask(callback, path, parameters)
     .ConfigureAwait(false);
 }
Beispiel #42
0
        public static void allTests(global::Test.TestHelper helper)
        {
            Communicator communicator = helper.communicator();

            communicator.SetProperty("ReplyAdapter.Endpoints", "udp");
            ObjectAdapter adapter = communicator.CreateObjectAdapter("ReplyAdapter");
            PingReplyI    replyI  = new PingReplyI();
            IPingReplyPrx reply   = adapter.AddWithUUID(replyI, IPingReplyPrx.Factory)
                                    .Clone(invocationMode: InvocationMode.Datagram);

            adapter.Activate();

            Console.Out.Write("testing udp... ");
            Console.Out.Flush();
            var obj = ITestIntfPrx.Parse("test:" + helper.getTestEndpoint(0, "udp"),
                                         communicator).Clone(invocationMode: InvocationMode.Datagram);

            int  nRetry = 5;
            bool ret    = false;

            while (nRetry-- > 0)
            {
                replyI.reset();
                obj.ping(reply);
                obj.ping(reply);
                obj.ping(reply);
                ret = replyI.waitReply(3, 2000);
                if (ret)
                {
                    break; // Success
                }

                // If the 3 datagrams were not received within the 2 seconds, we try again to
                // receive 3 new datagrams using a new object. We give up after 5 retries.
                replyI = new PingReplyI();
                reply  = adapter.AddWithUUID(
                    replyI, IPingReplyPrx.Factory).Clone(invocationMode: InvocationMode.Datagram);
            }
            test(ret == true);

            if ((communicator.GetPropertyAsInt("Ice.Override.Compress") ?? 0) == 0)
            {
                //
                // Only run this test if compression is disabled, the test expect fixed message size
                // to be sent over the wire.
                //
                byte[] seq = new byte[1024];;
                try
                {
                    while (true)
                    {
                        seq = new byte[seq.Length * 2 + 10];
                        replyI.reset();
                        obj.sendByteSeq(seq, reply);
                        replyI.waitReply(1, 10000);
                    }
                }
                catch (DatagramLimitException)
                {
                    //
                    // The server's Ice.UDP.RcvSize property is set to 16384, which means that DatagramLimitException
                    // will be throw when try to send a packet bigger than that.
                    //
                    test(seq.Length > 16384);
                }
                obj.GetConnection().Close(Ice.ConnectionClose.GracefullyWithWait);
                communicator.SetProperty("Ice.UDP.SndSize", "64000");
                seq = new byte[50000];
                try
                {
                    replyI.reset();
                    obj.sendByteSeq(seq, reply);

                    bool b = replyI.waitReply(1, 500);
                    //
                    // The server's Ice.UDP.RcvSize property is set to 16384, which means this packet
                    // should not be delivered.
                    //
                    test(!b);
                }
                catch (DatagramLimitException)
                {
                }
                catch (LocalException ex)
                {
                    Console.Out.WriteLine(ex);
                    test(false);
                }
            }

            Console.Out.WriteLine("ok");

            Console.Out.Write("testing udp multicast... ");
            Console.Out.Flush();
            StringBuilder endpoint = new StringBuilder();

            //
            // Use loopback to prevent other machines to answer.
            //
            if (communicator.GetProperty("Ice.IPv6") == "1")
            {
                endpoint.Append("udp -h \"ff15::1:1\"");
                if (IceInternal.AssemblyUtil.IsWindows || IceInternal.AssemblyUtil.IsMacOS)
                {
                    endpoint.Append(" --interface \"::1\"");
                }
            }
            else
            {
                endpoint.Append("udp -h 239.255.1.1");
                if (IceInternal.AssemblyUtil.IsWindows || IceInternal.AssemblyUtil.IsMacOS)
                {
                    endpoint.Append(" --interface 127.0.0.1");
                }
            }
            endpoint.Append(" -p ");
            endpoint.Append(helper.getTestPort(10));
            var objMcast = ITestIntfPrx.Parse($"test -d:{endpoint}", communicator);

            nRetry = 5;
            while (nRetry-- > 0)
            {
                replyI.reset();
                objMcast.ping(reply);
                ret = replyI.waitReply(5, 5000);
                if (ret)
                {
                    break;
                }
                replyI = new PingReplyI();
                reply  = adapter.AddWithUUID(
                    replyI, IPingReplyPrx.Factory).Clone(invocationMode: InvocationMode.Datagram);
            }
            if (!ret)
            {
                Console.Out.WriteLine("failed(is a firewall enabled?)");
            }
            else
            {
                Console.Out.WriteLine("ok");
            }

            Console.Out.Write("testing udp bi-dir connection... ");
            Console.Out.Flush();
            obj.GetConnection().SetAdapter(adapter);
            objMcast.GetConnection().SetAdapter(adapter);
            nRetry = 5;
            while (nRetry-- > 0)
            {
                replyI.reset();
                obj.pingBiDir(reply.Identity);
                obj.pingBiDir(reply.Identity);
                obj.pingBiDir(reply.Identity);
                ret = replyI.waitReply(3, 2000);
                if (ret)
                {
                    break; // Success
                }
                replyI = new PingReplyI();
                reply  = adapter.AddWithUUID(
                    replyI, IPingReplyPrx.Factory).Clone(invocationMode: InvocationMode.Datagram);
            }
            test(ret);
            Console.Out.WriteLine("ok");

            //
            // Sending the replies back on the multicast UDP connection doesn't work for most
            // platform(it works for macOS Leopard but not Snow Leopard, doesn't work on SLES,
            // Windows...). For Windows, see UdpTransceiver constructor for the details. So
            // we don't run this test.
            //
            //         Console.Out.Write("testing udp bi-dir connection... ");
            //         nRetry = 5;
            //         while(nRetry-- > 0)
            //         {
            //             replyI.reset();
            //             objMcast.pingBiDir(reply.Identity);
            //             ret = replyI.waitReply(5, 2000);
            //             if(ret)
            //             {
            //                 break; // Success
            //             }
            //             replyI = new PingReplyI();
            //             reply =(PingReplyPrx)PingReplyPrxHelper.uncheckedCast(adapter.addWithUUID(replyI)).ice_datagram();
            //         }

            //         if(!ret)
            //         {
            //             Console.Out.WriteLine("failed(is a firewall enabled?)");
            //         }
            //         else
            //         {
            //             Console.Out.WriteLine("ok");
            //         }
        }
        /// <summary>
        /// Gets an Azure Sql Database by name with additional information.
        /// </summary>
        /// <param name="resourceGroupName">The name of the resource group</param>
        /// <param name="serverName">The name of the Azure Sql Database Server</param>
        /// <param name="databaseName">The name of the Azure Sql Database</param>
        /// <returns>The Azure Sql Database object</returns>
        internal AzureSqlDatabaseModelExpanded GetDatabaseExpanded(string resourceGroupName, string serverName, string databaseName)
        {
            var resp = Communicator.GetExpanded(resourceGroupName, serverName, databaseName);

            return(CreateExpandedDatabaseModelFromResponse(resourceGroupName, serverName, resp));
        }
 /// <summary>
 /// Deletes a database
 /// </summary>
 /// <param name="resourceGroupName">The resource group the server is in</param>
 /// <param name="serverName">The name of the Azure Sql Database Server</param>
 /// <param name="databaseName">The name of the Azure Sql Database to delete</param>
 public void RemoveDatabase(string resourceGroupName, string serverName, string databaseName)
 {
     Communicator.Remove(resourceGroupName, serverName, databaseName);
 }
Beispiel #45
0
            public void startServer(Ice.Current current)
            {
                foreach (Ice.Communicator c in _communicators)
                {
                    c.waitForShutdown();
                    c.destroy();
                }
                _communicators.Clear();

                //
                // Simulate a server: create a new communicator and object
                // adapter. The object adapter is started on a system allocated
                // port. The configuration used here contains the Ice.Locator
                // configuration variable. The new object adapter will register
                // its endpoints with the locator and create references containing
                // the adapter id instead of the endpoints.
                //
                var properties = _helper.communicator().GetProperties();

                properties["TestAdapter.AdapterId"]      = "TestAdapter";
                properties["TestAdapter.ReplicaGroupId"] = "ReplicatedAdapter";
                properties["TestAdapter2.AdapterId"]     = "TestAdapter2";

                Communicator serverCommunicator = _helper.initialize(properties);

                _communicators.Add(serverCommunicator);

                //
                // Use fixed port to ensure that OA re-activation doesn't re-use previous port from
                // another OA(e.g.: TestAdapter2 is re-activated using port of TestAdapter).
                //
                int nRetry = 10;

                while (--nRetry > 0)
                {
                    ObjectAdapter?adapter  = null;
                    ObjectAdapter?adapter2 = null;
                    try
                    {
                        serverCommunicator.SetProperty("TestAdapter.Endpoints",
                                                       _helper.getTestEndpoint(_nextPort++));
                        serverCommunicator.SetProperty("TestAdapter2.Endpoints",
                                                       _helper.getTestEndpoint(_nextPort++));

                        adapter  = serverCommunicator.createObjectAdapter("TestAdapter");
                        adapter2 = serverCommunicator.createObjectAdapter("TestAdapter2");

                        var locator = LocatorPrx.Parse($"locator:{_helper.getTestEndpoint(0)}", serverCommunicator);
                        adapter.SetLocator(locator);
                        adapter2.SetLocator(locator);

                        var testI = new TestI(adapter, adapter2, _registry);
                        _registry.addObject(adapter.Add(testI, "test"));
                        _registry.addObject(adapter.Add(testI, "test2"));
                        adapter.Add(testI, "test3");

                        adapter.Activate();
                        adapter2.Activate();
                        break;
                    }
                    catch (Ice.SocketException ex)
                    {
                        if (nRetry == 0)
                        {
                            throw ex;
                        }

                        // Retry, if OA creation fails with EADDRINUSE(this can occur when running with JS web
                        // browser clients if the driver uses ports in the same range as this test, ICE-8148)
                        if (adapter != null)
                        {
                            adapter.Destroy();
                        }
                        if (adapter2 != null)
                        {
                            adapter2.Destroy();
                        }
                    }
                }
            }
Beispiel #46
0
 internal SSLServer(Communicator communicator) => _communicator = communicator;
Beispiel #47
0
 public BasePlugin(Communicator communicator) => Communicator = communicator;
Beispiel #48
0
 public G(Communicator communicator) => _communicator = communicator;
Beispiel #49
0
        public static void Run(TestHelper helper)
        {
            Communicator?communicator = helper.Communicator;

            TestHelper.Assert(communicator != null);
            TextWriter output = helper.Output;
            bool       ice1   = helper.Protocol == Protocol.Ice1;

            output.Write("testing communicator operations... ");
            output.Flush();
            {
                // Test: Exercise AddAdminFacet, FindAdminFacet, RemoveAdminFacet with a typical configuration.
                var properties = new Dictionary <string, string>
                {
                    ["Ice.Admin.Endpoints"]    = ice1 ? "tcp -h 127.0.0.1" : "ice+tcp://127.0.0.1:0",
                    ["Ice.Admin.InstanceName"] = "Test"
                };
                using var com = new Communicator(properties);
                TestFacets(com, true, false);
            }
            {
                // Test: Verify that the operations work correctly in the presence of facet filters.
                var properties = new Dictionary <string, string>
                {
                    ["Ice.Admin.Endpoints"]    = ice1 ? "tcp -h 127.0.0.1" : "ice+tcp://127.0.0.1:0",
                    ["Ice.Admin.InstanceName"] = "Test",
                    ["Ice.Admin.Facets"]       = "Properties"
                };
                using var com = new Communicator(properties);
                TestFacets(com, false, true);
            }
            {
                // Test: Verify that the operations work correctly with the Admin object disabled.
                using var com = new Communicator();
                TestFacets(com, false, false);
            }
            {
                // Test: Verify that the operations work correctly with Ice.Admin.Enabled=1
                var properties = new Dictionary <string, string>()
                {
                    { "Ice.Admin.Enabled", "1" }
                };
                using var com = new Communicator(properties);
                TestHelper.Assert(com.GetAdmin() == null);
                var id = Identity.Parse("test-admin");
                try
                {
                    com.CreateAdmin(null, id);
                    TestHelper.Assert(false);
                }
                catch (InvalidConfigurationException)
                {
                }

                ObjectAdapter adapter = com.CreateObjectAdapter();
                TestHelper.Assert(com.CreateAdmin(adapter, id) != null);
                TestHelper.Assert(com.GetAdmin() != null);

                TestFacets(com, true, false);
            }
            {
                // Test: Verify that the operations work correctly when creation of the Admin object is delayed.
                var properties = new Dictionary <string, string>()
                {
                    { "Ice.Admin.Endpoints", ice1 ? "tcp -h 127.0.0.1" : "ice+tcp://127.0.0.1:0" },
                    { "Ice.Admin.InstanceName", "Test" },
                    { "Ice.Admin.DelayCreation", "1" }
                };

                using var com = new Communicator(properties);
                TestFacets(com, true, false);
                com.GetAdmin();
                TestFacets(com, true, false);
            }
            output.WriteLine("ok");

            var factory = IRemoteCommunicatorFactoryPrx.Parse(helper.GetTestProxy("factory", 0), communicator);

            output.Write("testing process facet... ");
            output.Flush();
            {
                // Test: Verify that Process.Shutdown() operation shuts down the communicator.
                var props = new Dictionary <string, string>
                {
                    { "Ice.Admin.Endpoints", ice1 ? "tcp -h 127.0.0.1" : "ice+tcp://127.0.0.1:0" },
                    { "Ice.Admin.InstanceName", "Test" }
                };
                IRemoteCommunicatorPrx?com = factory.CreateCommunicator(props);
                TestHelper.Assert(com != null);
                IObjectPrx?obj = com.GetAdmin();
                TestHelper.Assert(obj != null);
                IProcessPrx proc = obj.Clone(IProcessPrx.Factory, facet: "Process");
                proc.Shutdown();
                com.WaitForShutdown();
                com.Destroy();
            }
            output.WriteLine("ok");

            output.Write("testing properties facet... ");
            output.Flush();
            {
                var props = new Dictionary <string, string>
                {
                    { "Ice.Admin.Endpoints", ice1 ? "tcp -h 127.0.0.1" : "ice+tcp://127.0.0.1:0" },
                    { "Ice.Admin.InstanceName", "Test" },
                    { "Prop1", "1" },
                    { "Prop2", "2" },
                    { "Prop3", "3" }
                };
                IRemoteCommunicatorPrx?com = factory.CreateCommunicator(props);
                TestHelper.Assert(com != null);
                IObjectPrx?obj = com.GetAdmin();
                TestHelper.Assert(obj != null);
                IPropertiesAdminPrx pa = obj.Clone(IPropertiesAdminPrx.Factory, facet: "Properties");

                // Test: PropertiesAdmin.GetProperty()
                TestHelper.Assert(pa.GetProperty("Prop2") == "2");
                TestHelper.Assert(pa.GetProperty("Bogus").Length == 0);

                // Test: PropertiesAdmin.GetProperties()
                Dictionary <string, string> pd = pa.GetPropertiesForPrefix("");
                TestHelper.Assert(pd.Count == 7);
                TestHelper.Assert(pd["Ice.ProgramName"] == "server");
                TestHelper.Assert(pd["Ice.Admin.Endpoints"] == (ice1 ? "tcp -h 127.0.0.1" : "ice+tcp://127.0.0.1:0"));
                TestHelper.Assert(pd["Ice.Admin.InstanceName"] == "Test");
                TestHelper.Assert(pd["Prop1"] == "1");
                TestHelper.Assert(pd["Prop2"] == "2");
                TestHelper.Assert(pd["Prop3"] == "3");
                TestHelper.Assert(pd["Test.Protocol"] == helper.Protocol.GetName());

                Dictionary <string, string> changes;

                // Test: PropertiesAdmin.SetProperties()
                var setProps = new Dictionary <string, string>
                {
                    { "Prop1", "10" }, // Changed
                    { "Prop2", "20" }, // Changed
                    { "Prop3", "" },   // Removed
                    { "Prop4", "4" },  // Added
                    { "Prop5", "5" } // Added
                };
                pa.SetProperties(setProps);
                TestHelper.Assert(pa.GetProperty("Prop1").Equals("10"));
                TestHelper.Assert(pa.GetProperty("Prop2").Equals("20"));
                TestHelper.Assert(pa.GetProperty("Prop3").Length == 0);
                TestHelper.Assert(pa.GetProperty("Prop4").Equals("4"));
                TestHelper.Assert(pa.GetProperty("Prop5").Equals("5"));
                changes = com.GetChanges();
                TestHelper.Assert(changes.Count == 5);
                TestHelper.Assert(changes["Prop1"].Equals("10"));
                TestHelper.Assert(changes["Prop2"].Equals("20"));
                TestHelper.Assert(changes["Prop3"].Length == 0);
                TestHelper.Assert(changes["Prop4"].Equals("4"));
                TestHelper.Assert(changes["Prop5"].Equals("5"));
                pa.SetProperties(setProps);
                changes = com.GetChanges();
                TestHelper.Assert(changes.Count == 0);

                com.Destroy();
            }
            output.WriteLine("ok");

            output.Write("testing logger facet... ");
            output.Flush();
            {
                var props = new Dictionary <string, string>
                {
                    { "Ice.Admin.Endpoints", ice1 ? "tcp -h 127.0.0.1" : "ice+tcp://127.0.0.1:0" },
                    { "Ice.Admin.InstanceName", "Test" },
                    { "NullLogger", "1" }
                };
                IRemoteCommunicatorPrx?com = factory.CreateCommunicator(props);
                TestHelper.Assert(com != null);
                com.Trace("testCat", "trace");
                com.Warning("warning");
                com.Error("error");
                com.Print("print");

                IObjectPrx?obj = com.GetAdmin();
                TestHelper.Assert(obj != null);
                ILoggerAdminPrx logger = obj.Clone(ILoggerAdminPrx.Factory, facet: "Logger");

                // Get all
                (LogMessage[] logMessages, string prefix) =
                    logger.GetLog(Array.Empty <LogMessageType>(), Array.Empty <string>(), -1);

                TestHelper.Assert(logMessages.Length == 4);
                TestHelper.Assert(prefix.Equals("NullLogger"));
                TestHelper.Assert(logMessages[0].TraceCategory.Equals("testCat") && logMessages[0].Message.Equals("trace"));
                TestHelper.Assert(logMessages[1].Message.Equals("warning"));
                TestHelper.Assert(logMessages[2].Message.Equals("error"));
                TestHelper.Assert(logMessages[3].Message.Equals("print"));

                // Get only errors and warnings
                com.Error("error2");
                com.Print("print2");
                com.Trace("testCat", "trace2");
                com.Warning("warning2");

                LogMessageType[] messageTypes = { LogMessageType.ErrorMessage, LogMessageType.WarningMessage };

                (logMessages, prefix) = logger.GetLog(messageTypes, Array.Empty <string>(), -1);

                TestHelper.Assert(logMessages.Length == 4);
                TestHelper.Assert(prefix.Equals("NullLogger"));

                foreach (LogMessage msg in logMessages)
                {
                    TestHelper.Assert(msg.Type == LogMessageType.ErrorMessage || msg.Type == LogMessageType.WarningMessage);
                }

                // Get only errors and traces with Cat = "testCat"
                com.Trace("testCat2", "A");
                com.Trace("testCat", "trace3");
                com.Trace("testCat2", "B");

                messageTypes = new LogMessageType[] { LogMessageType.ErrorMessage, LogMessageType.TraceMessage };
                string[] categories = { "testCat" };
                (logMessages, prefix) = logger.GetLog(messageTypes, categories, -1);
                TestHelper.Assert(logMessages.Length == 5);
                TestHelper.Assert(prefix.Equals("NullLogger"));

                foreach (LogMessage msg in logMessages)
                {
                    TestHelper.Assert(msg.Type == LogMessageType.ErrorMessage ||
                                      (msg.Type == LogMessageType.TraceMessage && msg.TraceCategory.Equals("testCat")));
                }

                // Same, but limited to last 2 messages(trace3 + error3)
                com.Error("error3");

                (logMessages, prefix) = logger.GetLog(messageTypes, categories, 2);
                TestHelper.Assert(logMessages.Length == 2);
                TestHelper.Assert(prefix.Equals("NullLogger"));

                TestHelper.Assert(logMessages[0].Message.Equals("trace3"));
                TestHelper.Assert(logMessages[1].Message.Equals("error3"));

                // Now, test RemoteLogger
                ObjectAdapter adapter = communicator.CreateObjectAdapterWithEndpoints("RemoteLoggerAdapter",
                                                                                      ice1 ? "tcp -h localhost" : "ice+tcp://localhost:0", serializeDispatch: true);

                var remoteLogger = new RemoteLogger();

                IRemoteLoggerPrx myProxy = adapter.AddWithUUID(remoteLogger, IRemoteLoggerPrx.Factory);

                adapter.Activate();

                // No filtering
                (logMessages, prefix) = logger.GetLog(Array.Empty <LogMessageType>(), Array.Empty <string>(), -1);

                logger.AttachRemoteLogger(myProxy, Array.Empty <LogMessageType>(), Array.Empty <string>(), -1);
                remoteLogger.Wait(1);

                foreach (LogMessage m in logMessages)
                {
                    remoteLogger.CheckNextInit(prefix, m.Type, m.Message, m.TraceCategory);
                }

                com.Trace("testCat", "rtrace");
                com.Warning("rwarning");
                com.Error("rerror");
                com.Print("rprint");

                remoteLogger.Wait(4);

                remoteLogger.CheckNextLog(LogMessageType.TraceMessage, "rtrace", "testCat");
                remoteLogger.CheckNextLog(LogMessageType.WarningMessage, "rwarning", "");
                remoteLogger.CheckNextLog(LogMessageType.ErrorMessage, "rerror", "");
                remoteLogger.CheckNextLog(LogMessageType.PrintMessage, "rprint", "");

                TestHelper.Assert(logger.DetachRemoteLogger(myProxy));
                TestHelper.Assert(!logger.DetachRemoteLogger(myProxy));

                // Use Error + Trace with "traceCat" filter with 4 limit
                (logMessages, prefix) = logger.GetLog(messageTypes, categories, 4);
                TestHelper.Assert(logMessages.Length == 4);

                logger.AttachRemoteLogger(myProxy, messageTypes, categories, 4);
                remoteLogger.Wait(1);

                foreach (LogMessage m in logMessages)
                {
                    remoteLogger.CheckNextInit(prefix, m.Type, m.Message, m.TraceCategory);
                }

                com.Warning("rwarning2");
                com.Trace("testCat", "rtrace2");
                com.Warning("rwarning3");
                com.Error("rerror2");
                com.Print("rprint2");

                remoteLogger.Wait(2);

                remoteLogger.CheckNextLog(LogMessageType.TraceMessage, "rtrace2", "testCat");
                remoteLogger.CheckNextLog(LogMessageType.ErrorMessage, "rerror2", "");

                // Attempt reconnection with slightly different proxy
                try
                {
                    logger.AttachRemoteLogger(myProxy.Clone(oneway: true), messageTypes, categories, 4);
                    TestHelper.Assert(false);
                }
                catch (RemoteLoggerAlreadyAttachedException)
                {
                    // expected
                }

                com.Destroy();
            }
            output.WriteLine("ok");

            output.Write("testing custom facet... ");
            output.Flush();
            {
                // Test: Verify that the custom facet is present.
                var props = new Dictionary <string, string>
                {
                    { "Ice.Admin.Endpoints", ice1 ? "tcp -h 127.0.0.1" : "ice+tcp://127.0.0.1:0" },
                    { "Ice.Admin.InstanceName", "Test" }
                };
                IRemoteCommunicatorPrx?com = factory.CreateCommunicator(props);
                TestHelper.Assert(com != null);
                IObjectPrx?obj = com.GetAdmin();
                TestHelper.Assert(obj != null);
                ITestFacetPrx tf = obj.Clone(ITestFacetPrx.Factory, facet: "TestFacet");
                tf.Op();
                com.Destroy();
            }
            output.WriteLine("ok");

            output.Write("testing facet filtering... ");
            output.Flush();
            {
                // Test: Set Ice.Admin.Facets to expose only the Properties facet, meaning no other facet is available.
                var props = new Dictionary <string, string>
                {
                    { "Ice.Admin.Endpoints", ice1 ? "tcp -h 127.0.0.1" : "ice+tcp://127.0.0.1:0" },
                    { "Ice.Admin.InstanceName", "Test" },
                    { "Ice.Admin.Facets", "Properties" }
                };
                IRemoteCommunicatorPrx?com = factory.CreateCommunicator(props);
                TestHelper.Assert(com != null);
                IObjectPrx?obj = com.GetAdmin();
                TestHelper.Assert(obj != null);
                try
                {
                    obj.Clone(IProcessPrx.Factory, facet: "Process").IcePing();
                    TestHelper.Assert(false);
                }
                catch (ObjectNotExistException)
                {
                }

                try
                {
                    obj.Clone(ITestFacetPrx.Factory, facet: "TestFacet").IcePing();
                    TestHelper.Assert(false);
                }
                catch (ObjectNotExistException)
                {
                }
                com.Destroy();
            }
            {
                // Test: Set Ice.Admin.Facets to expose only the Process facet, meaning no other facet is available.
                var props = new Dictionary <string, string>
                {
                    { "Ice.Admin.Endpoints", ice1 ? "tcp -h 127.0.0.1" : "ice+tcp://127.0.0.1:0" },
                    { "Ice.Admin.InstanceName", "Test" },
                    { "Ice.Admin.Facets", "Process" }
                };
                IRemoteCommunicatorPrx?com = factory.CreateCommunicator(props);
                TestHelper.Assert(com != null);
                IObjectPrx?obj = com.GetAdmin();
                TestHelper.Assert(obj != null);
                try
                {
                    obj.Clone(IPropertiesAdminPrx.Factory, facet: "Properties").IcePing();
                    TestHelper.Assert(false);
                }
                catch (ObjectNotExistException)
                {
                }

                try
                {
                    obj.Clone(ITestFacetPrx.Factory, facet: "TestFacet").IcePing();
                    TestHelper.Assert(false);
                }
                catch (ObjectNotExistException)
                {
                }
                com.Destroy();
            }
            {
                // Test: Set Ice.Admin.Facets to expose only the TestFacet facet, meaning no other facet is available.
                var props = new Dictionary <string, string>
                {
                    { "Ice.Admin.Endpoints", ice1 ? "tcp -h 127.0.0.1" : "ice+tcp://127.0.0.1:0" },
                    { "Ice.Admin.InstanceName", "Test" },
                    { "Ice.Admin.Facets", "TestFacet" }
                };
                IRemoteCommunicatorPrx?com = factory.CreateCommunicator(props);
                TestHelper.Assert(com != null);
                IObjectPrx?obj = com.GetAdmin();
                TestHelper.Assert(obj != null);
                try
                {
                    obj.Clone(IPropertiesAdminPrx.Factory, facet: "Properties").IcePing();
                    TestHelper.Assert(false);
                }
                catch (ObjectNotExistException)
                {
                }

                try
                {
                    obj.Clone(IProcessPrx.Factory, facet: "Process").IcePing();
                    TestHelper.Assert(false);
                }
                catch (ObjectNotExistException)
                {
                }
                com.Destroy();
            }
            {
                // Test: Set Ice.Admin.Facets to expose two facets. Use whitespace to separate the facet names.
                var props = new Dictionary <string, string>
                {
                    { "Ice.Admin.Endpoints", ice1 ? "tcp -h 127.0.0.1" : "ice+tcp://127.0.0.1:0" },
                    { "Ice.Admin.InstanceName", "Test" },
                    { "Ice.Admin.Facets", "Properties TestFacet" }
                };
                IRemoteCommunicatorPrx?com = factory.CreateCommunicator(props);
                TestHelper.Assert(com != null);
                IObjectPrx?obj = com.GetAdmin();
                TestHelper.Assert(obj != null);
                IPropertiesAdminPrx pa = obj.Clone(IPropertiesAdminPrx.Factory, facet: "Properties");
                TestHelper.Assert(pa.GetProperty("Ice.Admin.InstanceName").Equals("Test"));
                ITestFacetPrx?tf =
                    obj.Clone(IObjectPrx.Factory, facet: "TestFacet").CheckedCast(ITestFacetPrx.Factory);
                tf !.Op();
                try
                {
                    obj.Clone(IProcessPrx.Factory, facet: "Process").IcePing();
                    TestHelper.Assert(false);
                }
                catch (ObjectNotExistException)
                {
                }
                com.Destroy();
            }
            {
                // Test: Set Ice.Admin.Facets to expose two facets. Use a comma to separate the facet names.
                var props = new Dictionary <string, string>
                {
                    { "Ice.Admin.Endpoints", ice1 ? "tcp -h 127.0.0.1" : "ice+tcp://127.0.0.1:0" },
                    { "Ice.Admin.InstanceName", "Test" },
                    { "Ice.Admin.Facets", "TestFacet, Process" }
                };
                IRemoteCommunicatorPrx?com = factory.CreateCommunicator(props);
                TestHelper.Assert(com != null);
                IObjectPrx?obj = com.GetAdmin();
                TestHelper.Assert(obj != null);
                try
                {
                    obj.Clone(IPropertiesAdminPrx.Factory, facet: "Properties").IcePing();
                    TestHelper.Assert(false);
                }
                catch (ObjectNotExistException)
                {
                }
                ITestFacetPrx?tf =
                    obj.Clone(IObjectPrx.Factory, facet: "TestFacet").CheckedCast(ITestFacetPrx.Factory);
                TestHelper.Assert(tf != null);
                tf.Op();
                IProcessPrx?proc =
                    obj.Clone(IObjectPrx.Factory, facet: "Process").CheckedCast(IProcessPrx.Factory);
                TestHelper.Assert(proc != null);
                proc.Shutdown();
                com.WaitForShutdown();
                com.Destroy();
            }
            output.WriteLine("ok");

            factory.Shutdown();
        }
Beispiel #50
0
            public static void allTests(global::Test.TestHelper helper)
            {
                Communicator communicator = helper.communicator();
                var          manager      = Test.ServerManagerPrxHelper.checkedCast(
                    communicator.stringToProxy("ServerManager :" + helper.getTestEndpoint(0)));

                test(manager != null);
                var locator = Test.TestLocatorPrxHelper.uncheckedCast(communicator.getDefaultLocator());

                test(locator != null);
                var registry = Test.TestLocatorRegistryPrxHelper.checkedCast(locator.getRegistry());

                test(registry != null);

                var output = helper.getWriter();

                output.Write("testing stringToProxy... ");
                output.Flush();
                ObjectPrx @base = communicator.stringToProxy("test @ TestAdapter");
                ObjectPrx base2 = communicator.stringToProxy("test @ TestAdapter");
                ObjectPrx base3 = communicator.stringToProxy("test");
                ObjectPrx base4 = communicator.stringToProxy("ServerManager");
                ObjectPrx base5 = communicator.stringToProxy("test2");
                ObjectPrx base6 = communicator.stringToProxy("test @ ReplicatedAdapter");

                output.WriteLine("ok");

                output.Write("testing ice_locator and ice_getLocator... ");
                test(Util.proxyIdentityCompare(@base.ice_getLocator(), communicator.getDefaultLocator()) == 0);
                LocatorPrx anotherLocator =
                    LocatorPrxHelper.uncheckedCast(communicator.stringToProxy("anotherLocator"));

                @base = @base.ice_locator(anotherLocator);
                test(Util.proxyIdentityCompare(@base.ice_getLocator(), anotherLocator) == 0);
                communicator.setDefaultLocator(null);
                @base = communicator.stringToProxy("test @ TestAdapter");
                test(@base.ice_getLocator() == null);
                @base = @base.ice_locator(anotherLocator);
                test(Util.proxyIdentityCompare(@base.ice_getLocator(), anotherLocator) == 0);
                communicator.setDefaultLocator(locator);
                @base = communicator.stringToProxy("test @ TestAdapter");
                test(Util.proxyIdentityCompare(@base.ice_getLocator(), communicator.getDefaultLocator()) == 0);

                //
                // We also test ice_router/ice_getRouter(perhaps we should add a
                // test/Ice/router test?)
                //
                test(@base.ice_getRouter() == null);
                RouterPrx anotherRouter =
                    RouterPrxHelper.uncheckedCast(communicator.stringToProxy("anotherRouter"));

                @base = @base.ice_router(anotherRouter);
                test(Util.proxyIdentityCompare(@base.ice_getRouter(), anotherRouter) == 0);
                RouterPrx router = RouterPrxHelper.uncheckedCast(communicator.stringToProxy("dummyrouter"));

                communicator.setDefaultRouter(router);
                @base = communicator.stringToProxy("test @ TestAdapter");
                test(Util.proxyIdentityCompare(@base.ice_getRouter(), communicator.getDefaultRouter()) == 0);
                communicator.setDefaultRouter(null);
                @base = communicator.stringToProxy("test @ TestAdapter");
                test(@base.ice_getRouter() == null);
                output.WriteLine("ok");

                output.Write("starting server... ");
                output.Flush();
                manager.startServer();
                output.WriteLine("ok");

                output.Write("testing checked cast... ");
                output.Flush();
                var obj = Test.TestIntfPrxHelper.checkedCast(@base);

                test(obj != null);
                var obj2 = Test.TestIntfPrxHelper.checkedCast(base2);

                test(obj2 != null);
                var obj3 = Test.TestIntfPrxHelper.checkedCast(base3);

                test(obj3 != null);
                var obj4 = Test.ServerManagerPrxHelper.checkedCast(base4);

                test(obj4 != null);
                var obj5 = Test.TestIntfPrxHelper.checkedCast(base5);

                test(obj5 != null);
                var obj6 = Test.TestIntfPrxHelper.checkedCast(base6);

                test(obj6 != null);
                output.WriteLine("ok");

                output.Write("testing id@AdapterId indirect proxy... ");
                output.Flush();
                obj.shutdown();
                manager.startServer();
                try
                {
                    obj2.ice_ping();
                }
                catch (LocalException)
                {
                    test(false);
                }
                output.WriteLine("ok");

                output.Write("testing id@ReplicaGroupId indirect proxy... ");
                output.Flush();
                obj.shutdown();
                manager.startServer();
                try
                {
                    obj6.ice_ping();
                }
                catch (LocalException)
                {
                    test(false);
                }
                output.WriteLine("ok");

                output.Write("testing identity indirect proxy... ");
                output.Flush();
                obj.shutdown();
                manager.startServer();
                try
                {
                    obj3.ice_ping();
                }
                catch (LocalException)
                {
                    test(false);
                }
                try
                {
                    obj2.ice_ping();
                }
                catch (LocalException)
                {
                    test(false);
                }
                obj.shutdown();
                manager.startServer();
                try
                {
                    obj2.ice_ping();
                }
                catch (LocalException)
                {
                    test(false);
                }
                try
                {
                    obj3.ice_ping();
                }
                catch (LocalException)
                {
                    test(false);
                }
                obj.shutdown();
                manager.startServer();
                try
                {
                    obj2.ice_ping();
                }
                catch (LocalException)
                {
                    test(false);
                }
                obj.shutdown();
                manager.startServer();
                try
                {
                    obj3.ice_ping();
                }
                catch (LocalException)
                {
                    test(false);
                }
                obj.shutdown();
                manager.startServer();
                try
                {
                    obj5 = Test.TestIntfPrxHelper.checkedCast(base5);
                    obj5.ice_ping();
                }
                catch (LocalException)
                {
                    test(false);
                }
                output.WriteLine("ok");

                output.Write("testing proxy with unknown identity... ");
                output.Flush();
                try
                {
                    @base = communicator.stringToProxy("unknown/unknown");
                    @base.ice_ping();
                    test(false);
                }
                catch (NotRegisteredException ex)
                {
                    test(ex.kindOfObject.Equals("object"));
                    test(ex.id.Equals("unknown/unknown"));
                }
                output.WriteLine("ok");

                output.Write("testing proxy with unknown adapter... ");
                output.Flush();
                try
                {
                    @base = communicator.stringToProxy("test @ TestAdapterUnknown");
                    @base.ice_ping();
                    test(false);
                }
                catch (NotRegisteredException ex)
                {
                    test(ex.kindOfObject.Equals("object adapter"));
                    test(ex.id.Equals("TestAdapterUnknown"));
                }
                output.WriteLine("ok");

                output.Write("testing locator cache timeout... ");
                output.Flush();

                ObjectPrx basencc = communicator.stringToProxy("test@TestAdapter").ice_connectionCached(false);
                int       count   = locator.getRequestCount();

                basencc.ice_locatorCacheTimeout(0).ice_ping(); // No locator cache.
                test(++count == locator.getRequestCount());
                basencc.ice_locatorCacheTimeout(0).ice_ping(); // No locator cache.
                test(++count == locator.getRequestCount());
                basencc.ice_locatorCacheTimeout(2).ice_ping(); // 2s timeout.
                test(count == locator.getRequestCount());
                System.Threading.Thread.Sleep(1300);           // 1300ms
                basencc.ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout.
                test(++count == locator.getRequestCount());

                communicator.stringToProxy("test").ice_locatorCacheTimeout(0).ice_ping(); // No locator cache.
                count += 2;
                test(count == locator.getRequestCount());
                communicator.stringToProxy("test").ice_locatorCacheTimeout(2).ice_ping(); // 2s timeout
                test(count == locator.getRequestCount());
                System.Threading.Thread.Sleep(1300);                                      // 1300ms
                communicator.stringToProxy("test").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout
                count += 2;
                test(count == locator.getRequestCount());

                communicator.stringToProxy("test@TestAdapter").ice_locatorCacheTimeout(-1).ice_ping();
                test(count == locator.getRequestCount());
                communicator.stringToProxy("test").ice_locatorCacheTimeout(-1).ice_ping();
                test(count == locator.getRequestCount());
                communicator.stringToProxy("test@TestAdapter").ice_ping();
                test(count == locator.getRequestCount());
                communicator.stringToProxy("test").ice_ping();
                test(count == locator.getRequestCount());

                test(communicator.stringToProxy("test").ice_locatorCacheTimeout(99).ice_getLocatorCacheTimeout() == 99);

                output.WriteLine("ok");

                output.Write("testing proxy from server... ");
                output.Flush();
                obj = Test.TestIntfPrxHelper.checkedCast(communicator.stringToProxy("test@TestAdapter"));
                var hello = obj.getHello();

                test(hello.ice_getAdapterId().Equals("TestAdapter"));
                hello.sayHello();
                hello = obj.getReplicatedHello();
                test(hello.ice_getAdapterId().Equals("ReplicatedAdapter"));
                hello.sayHello();
                output.WriteLine("ok");

                output.Write("testing locator request queuing... ");
                output.Flush();
                hello = (Test.HelloPrx)obj.getReplicatedHello().ice_locatorCacheTimeout(0).ice_connectionCached(false);
                count = locator.getRequestCount();
                hello.ice_ping();
                test(++count == locator.getRequestCount());
                List <Task> results = new List <Task>();

                for (int i = 0; i < 1000; i++)
                {
                    results.Add(hello.sayHelloAsync());
                }
                Task.WaitAll(results.ToArray());
                results.Clear();
                test(locator.getRequestCount() > count && locator.getRequestCount() < count + 999);
                if (locator.getRequestCount() > count + 800)
                {
                    output.Write("queuing = " + (locator.getRequestCount() - count));
                }
                count = locator.getRequestCount();
                hello = (Test.HelloPrx)hello.ice_adapterId("unknown");
                for (int i = 0; i < 1000; i++)
                {
                    results.Add(hello.sayHelloAsync().ContinueWith((Task t) => {
                        try
                        {
                            t.Wait();
                        }
                        catch (AggregateException ex) when(ex.InnerException is Ice.NotRegisteredException)
                        {
                        }
                    }));
                }
                Task.WaitAll(results.ToArray());
                results.Clear();
                // XXX:
                // Take into account the retries.
                test(locator.getRequestCount() > count && locator.getRequestCount() < count + 1999);
                if (locator.getRequestCount() > count + 800)
                {
                    output.Write("queuing = " + (locator.getRequestCount() - count));
                }
                output.WriteLine("ok");

                output.Write("testing adapter locator cache... ");
                output.Flush();
                try
                {
                    communicator.stringToProxy("test@TestAdapter3").ice_ping();
                    test(false);
                }
                catch (NotRegisteredException ex)
                {
                    test(ex.kindOfObject == "object adapter");
                    test(ex.id.Equals("TestAdapter3"));
                }
                registry.setAdapterDirectProxy("TestAdapter3", locator.findAdapterById("TestAdapter"));
                try
                {
                    communicator.stringToProxy("test@TestAdapter3").ice_ping();
                    registry.setAdapterDirectProxy("TestAdapter3",
                                                   communicator.stringToProxy("dummy:" + helper.getTestEndpoint(99)));
                    communicator.stringToProxy("test@TestAdapter3").ice_ping();
                }
                catch (LocalException)
                {
                    test(false);
                }

                try
                {
                    communicator.stringToProxy("test@TestAdapter3").ice_locatorCacheTimeout(0).ice_ping();
                    test(false);
                }
                catch (LocalException)
                {
                }
                try
                {
                    communicator.stringToProxy("test@TestAdapter3").ice_ping();
                    test(false);
                }
                catch (LocalException)
                {
                }
                registry.setAdapterDirectProxy("TestAdapter3", locator.findAdapterById("TestAdapter"));
                try
                {
                    communicator.stringToProxy("test@TestAdapter3").ice_ping();
                }
                catch (LocalException)
                {
                    test(false);
                }
                output.WriteLine("ok");

                output.Write("testing well-known object locator cache... ");
                output.Flush();
                registry.addObject(communicator.stringToProxy("test3@TestUnknown"));
                try
                {
                    communicator.stringToProxy("test3").ice_ping();
                    test(false);
                }
                catch (NotRegisteredException ex)
                {
                    test(ex.kindOfObject == "object adapter");
                    test(ex.id.Equals("TestUnknown"));
                }
                registry.addObject(communicator.stringToProxy("test3@TestAdapter4")); // Update
                registry.setAdapterDirectProxy("TestAdapter4",
                                               communicator.stringToProxy("dummy:" + helper.getTestEndpoint(99)));
                try
                {
                    communicator.stringToProxy("test3").ice_ping();
                    test(false);
                }
                catch (LocalException)
                {
                }
                registry.setAdapterDirectProxy("TestAdapter4", locator.findAdapterById("TestAdapter"));
                try
                {
                    communicator.stringToProxy("test3").ice_ping();
                }
                catch (LocalException)
                {
                    test(false);
                }

                registry.setAdapterDirectProxy("TestAdapter4",
                                               communicator.stringToProxy("dummy:" + helper.getTestEndpoint(99)));
                try
                {
                    communicator.stringToProxy("test3").ice_ping();
                }
                catch (LocalException)
                {
                    test(false);
                }

                try
                {
                    communicator.stringToProxy("test@TestAdapter4").ice_locatorCacheTimeout(0).ice_ping();
                    test(false);
                }
                catch (LocalException)
                {
                }
                try
                {
                    communicator.stringToProxy("test@TestAdapter4").ice_ping();
                    test(false);
                }
                catch (LocalException)
                {
                }
                try
                {
                    communicator.stringToProxy("test3").ice_ping();
                    test(false);
                }
                catch (LocalException)
                {
                }
                registry.addObject(communicator.stringToProxy("test3@TestAdapter"));
                try
                {
                    communicator.stringToProxy("test3").ice_ping();
                }
                catch (LocalException)
                {
                    test(false);
                }

                registry.addObject(communicator.stringToProxy("test4"));
                try
                {
                    communicator.stringToProxy("test4").ice_ping();
                    test(false);
                }
                catch (NoEndpointException)
                {
                }
                output.WriteLine("ok");

                output.Write("testing locator cache background updates... ");
                output.Flush();
                {
                    InitializationData initData = new InitializationData();
                    initData.properties = communicator.getProperties().ice_clone_();
                    initData.properties.setProperty("Ice.BackgroundLocatorCacheUpdates", "1");
                    Communicator ic = helper.initialize(initData);

                    registry.setAdapterDirectProxy("TestAdapter5", locator.findAdapterById("TestAdapter"));
                    registry.addObject(communicator.stringToProxy("test3@TestAdapter"));

                    count = locator.getRequestCount();
                    ic.stringToProxy("test@TestAdapter5").ice_locatorCacheTimeout(0).ice_ping(); // No locator cache.
                    ic.stringToProxy("test3").ice_locatorCacheTimeout(0).ice_ping();             // No locator cache.
                    count += 3;
                    test(count == locator.getRequestCount());
                    registry.setAdapterDirectProxy("TestAdapter5", null);
                    registry.addObject(communicator.stringToProxy("test3:" + helper.getTestEndpoint(99)));
                    ic.stringToProxy("test@TestAdapter5").ice_locatorCacheTimeout(10).ice_ping(); // 10s timeout.
                    ic.stringToProxy("test3").ice_locatorCacheTimeout(10).ice_ping();             // 10s timeout.
                    test(count == locator.getRequestCount());
                    System.Threading.Thread.Sleep(1200);

                    // The following request should trigger the background
                    // updates but still use the cached endpoints and
                    // therefore succeed.
                    ic.stringToProxy("test@TestAdapter5").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout.
                    ic.stringToProxy("test3").ice_locatorCacheTimeout(1).ice_ping();             // 1s timeout.

                    try
                    {
                        while (true)
                        {
                            ic.stringToProxy("test@TestAdapter5").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout.
                            System.Threading.Thread.Sleep(10);
                        }
                    }
                    catch (LocalException)
                    {
                        // Expected to fail once they endpoints have been updated in the background.
                    }
                    try
                    {
                        while (true)
                        {
                            ic.stringToProxy("test3").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout.
                            System.Threading.Thread.Sleep(10);
                        }
                    }
                    catch (LocalException)
                    {
                        // Expected to fail once they endpoints have been updated in the background.
                    }
                    ic.destroy();
                }
                output.WriteLine("ok");

                output.Write("testing proxy from server after shutdown... ");
                output.Flush();
                hello = obj.getReplicatedHello();
                obj.shutdown();
                manager.startServer();
                hello.sayHello();
                output.WriteLine("ok");

                output.Write("testing object migration... ");
                output.Flush();
                hello = Test.HelloPrxHelper.checkedCast(communicator.stringToProxy("hello"));
                obj.migrateHello();
                hello.ice_getConnection().close(ConnectionClose.GracefullyWithWait);
                hello.sayHello();
                obj.migrateHello();
                hello.sayHello();
                obj.migrateHello();
                hello.sayHello();
                output.WriteLine("ok");

                output.Write("testing locator encoding resolution... ");
                output.Flush();
                hello = Test.HelloPrxHelper.checkedCast(communicator.stringToProxy("hello"));
                count = locator.getRequestCount();
                communicator.stringToProxy("test@TestAdapter").ice_encodingVersion(Util.Encoding_1_1).ice_ping();
                test(count == locator.getRequestCount());
                communicator.stringToProxy("test@TestAdapter10").ice_encodingVersion(Util.Encoding_1_0).ice_ping();
                test(++count == locator.getRequestCount());
                communicator.stringToProxy("test -e 1.0@TestAdapter10-2").ice_ping();
                test(++count == locator.getRequestCount());
                output.WriteLine("ok");

                output.Write("shutdown server... ");
                output.Flush();
                obj.shutdown();
                output.WriteLine("ok");

                output.Write("testing whether server is gone... ");
                output.Flush();
                try
                {
                    obj2.ice_ping();
                    test(false);
                }
                catch (LocalException)
                {
                }
                try
                {
                    obj3.ice_ping();
                    test(false);
                }
                catch (LocalException)
                {
                }
                try
                {
                    obj5.ice_ping();
                    test(false);
                }
                catch (LocalException)
                {
                }
                output.WriteLine("ok");

                output.Write("testing indirect proxies to collocated objects... ");
                output.Flush();

                communicator.getProperties().setProperty("Hello.AdapterId", Guid.NewGuid().ToString());
                ObjectAdapter adapter = communicator.createObjectAdapterWithEndpoints("Hello", "default");

                Identity id = new Identity();

                id.name = Guid.NewGuid().ToString();
                adapter.add(new HelloI(), id);
                adapter.activate();

                // Ensure that calls on the well-known proxy is collocated.
                var helloPrx = Test.HelloPrxHelper.checkedCast(
                    communicator.stringToProxy("\"" + communicator.identityToString(id) + "\""));

                test(helloPrx.ice_getConnection() == null);

                // Ensure that calls on the indirect proxy (with adapter ID) is collocated
                helloPrx = Test.HelloPrxHelper.checkedCast(adapter.createIndirectProxy(id));
                test(helloPrx.ice_getConnection() == null);

                // Ensure that calls on the direct proxy is collocated
                helloPrx = Test.HelloPrxHelper.checkedCast(adapter.createDirectProxy(id));
                test(helloPrx.ice_getConnection() == null);

                output.WriteLine("ok");

                output.Write("shutdown server manager... ");
                output.Flush();
                manager.shutdown();
                output.WriteLine("ok");
            }
Beispiel #51
0
 /// <summary>
 /// Get's the list of all chats on owner's account asynchronously.
 /// </summary>
 /// <returns>The response data.</returns>
 public async Task <ResponseData <DataType> > GetRoomsAsync()
 {
     return(await Communicator.CreateGetTask <DataType>(Path.Rooms)
            .ConfigureAwait(false));
 }
Beispiel #52
0
        public static IMyClassPrx allTests(TestHelper helper)
        {
            Communicator?communicator = helper.Communicator();

            TestHelper.Assert(communicator != null);
            System.IO.TextWriter output = helper.GetWriter();
            output.Write("testing proxy parsing (URI)... ");
            output.Flush();

            string[] uriStringArray =
            {
                "ice+tcp://host.zeroc.com/identity#facet",
                "ice+tcp://host.zeroc.com:1000/category/name",
                "ice+tcp://host.zeroc.com/category/name%20with%20space",
                "ice+ws://host.zeroc.com//identity",
                "ice+ws://host.zeroc.com//identity?alt-endpoint=host2.zeroc.com",
                "ice+ws://host.zeroc.com//identity?alt-endpoint=host2.zeroc.com:10000",
                "ice+ws://host.zeroc.com//identity?protocol=ice1&source-address=[::2]&compress=true",
                "ice+ws://host.zeroc.com//identity?protocol=ice1&alt-endpoint=host2.zeroc.com?" +
                "source-address=10.1.2.4$compress=true",
                "ice+tcp://[::1]:10000/identity?alt-endpoint=host1:10000,host2,host3,host4",
                "ice+ssl://[::1]:10000/identity?alt-endpoint=host1:10000&alt-endpoint=host2,host3&alt-endpoint=[::2]",
                "ice:location//identity#facet",
                "ice+tcp://host.zeroc.com//identity",
                "ice+tcp://host.zeroc.com:/identity", // another syntax for empty port
                "ice+universal://com.zeroc.ice/identity?transport=iaps&option=a,b%2Cb,c&option=d",
                "ice+universal://host.zeroc.com/identity?transport=100",
                "ice+universal://[::ab:cd:ef:00]/identity?transport=bt",                  // leading :: to make the address IPv6-like
                "ice+udp://[::1]/test?source-address=::1&interface=0:0:0:0:0:0:0:1%25lo", // unescaped as ..:1%lo
                "ice+ws://host.zeroc.com/identity?resource=/foo%2Fbar?/xyz",
                "ice+universal://host.zeroc.com:10000/identity?transport=tcp",
                "ice+universal://host.zeroc.com/identity?transport=ws&option=/foo%2520/bar",
            };

            foreach (string uriString in uriStringArray)
            {
                _ = IObjectPrx.Parse(uriString, communicator);
                // output.WriteLine($"{uriString} = {prx}");
            }

            string[] badUriStringArray =
            {
                "ice+tcp://host.zeroc.com:foo",                               // missing host
                "ice+tcp:identity?protocol=invalid",                          // invalid protocol
                "ice+universal://host.zeroc.com",                             // missing transport
                "ice+universal://host.zeroc.com?transport=100&protocol=ice1", // invalid protocol
                "ice://*****:*****@test\"", communicator);
            TestHelper.Assert(b1.Identity.Name.Equals("test -f facet@test") && b1.Identity.Category.Length == 0 &&
                              b1.Facet.Length == 0);
            b1 = IObjectPrx.Parse("\"test -f facet@test @test\"", communicator);
            TestHelper.Assert(b1.Identity.Name.Equals("test -f facet@test @test") && b1.Identity.Category.Length == 0 &&
                              b1.Facet.Length == 0);
            try
            {
                b1 = IObjectPrx.Parse("test test", communicator);
                TestHelper.Assert(false);
            }
            catch (FormatException)
            {
            }
            b1 = IObjectPrx.Parse("test\\040test", communicator);
            TestHelper.Assert(b1.Identity.Name.Equals("test test") && b1.Identity.Category.Length == 0);
            try
            {
                b1 = IObjectPrx.Parse("test\\777", communicator);
                TestHelper.Assert(false);
            }
            catch (FormatException)
            {
            }
            b1 = IObjectPrx.Parse("test\\40test", communicator);
            TestHelper.Assert(b1.Identity.Name.Equals("test test"));

            // Test some octal and hex corner cases.
            b1 = IObjectPrx.Parse("test\\4test", communicator);
            TestHelper.Assert(b1.Identity.Name.Equals("test\u0004test"));
            b1 = IObjectPrx.Parse("test\\04test", communicator);
            TestHelper.Assert(b1.Identity.Name.Equals("test\u0004test"));
            b1 = IObjectPrx.Parse("test\\004test", communicator);
            TestHelper.Assert(b1.Identity.Name.Equals("test\u0004test"));
            b1 = IObjectPrx.Parse("test\\1114test", communicator);
            TestHelper.Assert(b1.Identity.Name.Equals("test\u00494test"));

            b1 = IObjectPrx.Parse("test\\b\\f\\n\\r\\t\\'\\\"\\\\test", communicator);
            TestHelper.Assert(b1.Identity.Name.Equals("test\b\f\n\r\t\'\"\\test") && b1.Identity.Category.Length == 0);

            b1 = IObjectPrx.Parse("category/test", communicator);
            TestHelper.Assert(b1.Identity.Name.Equals("test") && b1.Identity.Category.Equals("category") &&
                              b1.AdapterId.Length == 0);

            b1 = IObjectPrx.Parse("test:tcp --sourceAddress \"::1\"", communicator);
            TestHelper.Assert(b1.Equals(IObjectPrx.Parse(b1.ToString() !, communicator)));

            b1 = IObjectPrx.Parse("test:udp --sourceAddress \"::1\" --interface \"0:0:0:0:0:0:0:1%lo\"", communicator);
            TestHelper.Assert(b1.Equals(IObjectPrx.Parse(b1.ToString() !, communicator)));

            try
            {
                b1 = IObjectPrx.Parse("", communicator);
                TestHelper.Assert(false);
            }
            catch (FormatException)
            {
            }

            try
            {
                b1 = IObjectPrx.Parse("\"\"", communicator);
                TestHelper.Assert(false);
            }
            catch (FormatException)
            {
            }

            try
            {
                b1 = IObjectPrx.Parse("\"\" test", communicator); // Invalid trailing characters.
                TestHelper.Assert(false);
            }
            catch (FormatException)
            {
            }

            try
            {
                b1 = IObjectPrx.Parse("test:", communicator); // Missing endpoint.
                TestHelper.Assert(false);
            }
            catch (FormatException)
            {
            }

            b1 = IObjectPrx.Parse("test@adapter", communicator);
            TestHelper.Assert(b1.Identity.Name.Equals("test") && b1.Identity.Category.Length == 0 &&
                              b1.AdapterId.Equals("adapter"));
            try
            {
                b1 = IObjectPrx.Parse("id@adapter test", communicator);
                TestHelper.Assert(false);
            }
            catch (FormatException)
            {
            }
            b1 = IObjectPrx.Parse("category/test@adapter", communicator);
            TestHelper.Assert(b1.Identity.Name.Equals("test") && b1.Identity.Category.Equals("category") &&
                              b1.AdapterId.Equals("adapter"));
            b1 = IObjectPrx.Parse("category/test@adapter:tcp", communicator);
            TestHelper.Assert(b1.Identity.Name.Equals("test") && b1.Identity.Category.Equals("category") &&
                              b1.AdapterId.Equals("adapter:tcp"));
            b1 = IObjectPrx.Parse("'category 1/test'@adapter", communicator);
            TestHelper.Assert(b1.Identity.Name.Equals("test") && b1.Identity.Category.Equals("category 1") &&
                              b1.AdapterId.Equals("adapter"));
            b1 = IObjectPrx.Parse("'category/test 1'@adapter", communicator);
            TestHelper.Assert(b1.Identity.Name.Equals("test 1") && b1.Identity.Category.Equals("category") &&
                              b1.AdapterId.Equals("adapter"));
            b1 = IObjectPrx.Parse("'category/test'@'adapter 1'", communicator);
            TestHelper.Assert(b1.Identity.Name.Equals("test") && b1.Identity.Category.Equals("category") &&
                              b1.AdapterId.Equals("adapter 1"));
            b1 = IObjectPrx.Parse("\"category \\/test@foo/test\"@adapter", communicator);
            TestHelper.Assert(b1.Identity.Name.Equals("test") && b1.Identity.Category.Equals("category /test@foo") &&
                              b1.AdapterId.Equals("adapter"));
            b1 = IObjectPrx.Parse("\"category \\/test@foo/test\"@\"adapter:tcp\"", communicator);
            TestHelper.Assert(b1.Identity.Name.Equals("test") && b1.Identity.Category.Equals("category /test@foo") &&
                              b1.AdapterId.Equals("adapter:tcp"));

            b1 = IObjectPrx.Parse("id -f facet", communicator);
            TestHelper.Assert(b1.Identity.Name.Equals("id") && b1.Identity.Category.Length == 0 &&
                              b1.Facet.Equals("facet"));
            b1 = IObjectPrx.Parse("id -f 'facet x'", communicator);
            TestHelper.Assert(b1.Identity.Name.Equals("id") && b1.Identity.Category.Length == 0 &&
                              b1.Facet.Equals("facet x"));
            b1 = IObjectPrx.Parse("id -f \"facet x\"", communicator);
            TestHelper.Assert(b1.Identity.Name.Equals("id") && b1.Identity.Category.Length == 0 &&
                              b1.Facet.Equals("facet x"));
            try
            {
                b1 = IObjectPrx.Parse("id -f \"facet x", communicator);
                TestHelper.Assert(false);
            }
            catch (FormatException)
            {
            }
            try
            {
                b1 = IObjectPrx.Parse("id -f \'facet x", communicator);
                TestHelper.Assert(false);
            }
            catch (FormatException)
            {
            }
            b1 = IObjectPrx.Parse("test -f facet:tcp", communicator);
            TestHelper.Assert(b1.Identity.Name.Equals("test") && b1.Identity.Category.Length == 0 &&
                              b1.Facet.Equals("facet") && b1.AdapterId.Length == 0);
            b1 = IObjectPrx.Parse("test -f \"facet:tcp\"", communicator);
            TestHelper.Assert(b1.Identity.Name.Equals("test") && b1.Identity.Category.Length == 0 &&
                              b1.Facet.Equals("facet:tcp") && b1.AdapterId.Length == 0);
            b1 = IObjectPrx.Parse("test -f facet@test", communicator);
            TestHelper.Assert(b1.Identity.Name.Equals("test") && b1.Identity.Category.Length == 0 &&
                              b1.Facet.Equals("facet") && b1.AdapterId.Equals("test"));
            b1 = IObjectPrx.Parse("test -f 'facet@test'", communicator);
            TestHelper.Assert(b1.Identity.Name.Equals("test") && b1.Identity.Category.Length == 0 &&
                              b1.Facet.Equals("facet@test") && b1.AdapterId.Length == 0);
            b1 = IObjectPrx.Parse("test -f 'facet@test'@test", communicator);
            TestHelper.Assert(b1.Identity.Name.Equals("test") && b1.Identity.Category.Length == 0 &&
                              b1.Facet.Equals("facet@test") && b1.AdapterId.Equals("test"));
            try
            {
                b1 = IObjectPrx.Parse("test -f facet@test @test", communicator);
                TestHelper.Assert(false);
            }
            catch (FormatException)
            {
            }
            b1 = IObjectPrx.Parse("test", communicator);
            TestHelper.Assert(!b1.IsOneway);
            b1 = IObjectPrx.Parse("test -t", communicator);
            TestHelper.Assert(!b1.IsOneway);
            b1 = IObjectPrx.Parse("test -o", communicator);
            TestHelper.Assert(b1.IsOneway);
            b1 = IObjectPrx.Parse("test -O", communicator);
            TestHelper.Assert(b1.InvocationMode == InvocationMode.BatchOneway);
            b1 = IObjectPrx.Parse("test -d", communicator);
            TestHelper.Assert(b1.InvocationMode == InvocationMode.Datagram);
            b1 = IObjectPrx.Parse("test -D", communicator);
            TestHelper.Assert(b1.InvocationMode == InvocationMode.BatchDatagram);
            b1 = IObjectPrx.Parse("test", communicator);

            TestHelper.Assert(b1.Encoding.Equals(communicator.DefaultEncoding));

            b1 = IObjectPrx.Parse("test -e 1.0", communicator);
            TestHelper.Assert(b1.Encoding.Major == 1 && b1.Encoding.Minor == 0);

            b1 = IObjectPrx.Parse("test -e 6.5", communicator);
            TestHelper.Assert(b1.Encoding.Major == 6 && b1.Encoding.Minor == 5);

            b1 = IObjectPrx.Parse("test -p ice1 -e 1.0", communicator);
            TestHelper.Assert(b1.ToString() !.Equals("test -t -p ice1 -e 1.0"));

            b1 = IObjectPrx.Parse("test -p ice1 -e 1.0", communicator);
            TestHelper.Assert(b1.ToString() !.Equals("test -t -p ice1 -e 1.0"));

            b1 = IObjectPrx.Parse("test -p ice2 -e 1.0", communicator);
            TestHelper.Assert(b1.ToString() !.Equals("test -t -p ice2 -e 1.0"));

            b1 = IObjectPrx.Parse("test -p 2.0 -e 1.0", communicator);
            TestHelper.Assert(b1.ToString() !.Equals("test -t -p ice2 -e 1.0"));

            b1 = IObjectPrx.Parse("test -p 6 -e 1.0", communicator);
            TestHelper.Assert(b1.ToString() !.Equals("test -t -p 6 -e 1.0"));

            b1 = IObjectPrx.Parse("test -p 6.0 -e 1.0", communicator);
            TestHelper.Assert(b1.ToString() !.Equals("test -t -p 6 -e 1.0"));

            try
            {
                IObjectPrx.Parse("test:tcp@adapterId", communicator);
                TestHelper.Assert(false);
            }
            catch (FormatException)
            {
            }
            // This is an unknown endpoint warning, not a parse exception.
            //
            //try
            //{
            //   b1 = communicator.stringToProxy("test -f the:facet:tcp");
            //   TestHelper.Assert(false);
            //}
            //catch(EndpointParseException)
            //{
            //}
            try
            {
                IObjectPrx.Parse("test: :tcp", communicator);
                TestHelper.Assert(false);
            }
            catch (FormatException)
            {
            }

            //
            // Test invalid endpoint syntax
            //
            try
            {
                communicator.CreateObjectAdapterWithEndpoints("BadAdapter", " : ");
                TestHelper.Assert(false);
            }
            catch (FormatException)
            {
            }

            try
            {
                communicator.CreateObjectAdapterWithEndpoints("BadAdapter", "tcp: ");
                TestHelper.Assert(false);
            }
            catch (FormatException)
            {
            }

            try
            {
                communicator.CreateObjectAdapterWithEndpoints("BadAdapter", ":tcp");
                TestHelper.Assert(false);
            }
            catch (FormatException)
            {
            }

            //
            // Test for bug ICE-5543: escaped escapes in stringToIdentity
            //
            var id  = new Identity("test", ",X2QNUAzSBcJ_e$AV;E\\");
            var id2 = Identity.Parse(id.ToString(communicator.ToStringMode));

            TestHelper.Assert(id.Equals(id2));

            id  = new Identity("test", ",X2QNUAz\\SB\\/cJ_e$AV;E\\\\");
            id2 = Identity.Parse(id.ToString(communicator.ToStringMode));
            TestHelper.Assert(id.Equals(id2));

            id = new Identity("/test", "cat/");
            string idStr = id.ToString(communicator.ToStringMode);

            TestHelper.Assert(idStr == "cat\\//\\/test");
            id2 = Identity.Parse(idStr);
            TestHelper.Assert(id.Equals(id2));

            // Input string with various pitfalls
            id = Identity.Parse("\\342\\x82\\254\\60\\x9\\60\\");
            TestHelper.Assert(id.Name == "€0\t0\\" && id.Category.Length == 0);

            try
            {
                // Illegal character < 32
                id = Identity.Parse("xx\01FooBar");
                TestHelper.Assert(false);
            }
            catch (FormatException)
            {
            }

            try
            {
                // Illegal surrogate
                id = Identity.Parse("xx\\ud911");
                TestHelper.Assert(false);
            }
            catch (FormatException)
            {
            }

            // Testing bytes 127(\x7F, \177) and €
            id = new Identity("test", "\x7f€");

            idStr = id.ToString(ToStringMode.Unicode);
            TestHelper.Assert(idStr == "\\u007f€/test");
            id2 = Identity.Parse(idStr);
            TestHelper.Assert(id.Equals(id2));
            TestHelper.Assert(id.ToString() == idStr);

            idStr = id.ToString(ToStringMode.ASCII);
            TestHelper.Assert(idStr == "\\u007f\\u20ac/test");
            id2 = Identity.Parse(idStr);
            TestHelper.Assert(id.Equals(id2));

            idStr = id.ToString(ToStringMode.Compat);
            TestHelper.Assert(idStr == "\\177\\342\\202\\254/test");
            id2 = Identity.Parse(idStr);
            TestHelper.Assert(id.Equals(id2));

            id2 = Identity.Parse(id.ToString(communicator.ToStringMode));
            TestHelper.Assert(id.Equals(id2));

            // More unicode character
            id = new Identity("banana \x0E-\ud83c\udf4c\u20ac\u00a2\u0024", "greek \ud800\udd6a");

            idStr = id.ToString(ToStringMode.Unicode);
            TestHelper.Assert(idStr == "greek \ud800\udd6a/banana \\u000e-\ud83c\udf4c\u20ac\u00a2$");
            id2 = Identity.Parse(idStr);
            TestHelper.Assert(id.Equals(id2));

            idStr = id.ToString(ToStringMode.ASCII);
            TestHelper.Assert(idStr == "greek \\U0001016a/banana \\u000e-\\U0001f34c\\u20ac\\u00a2$");
            id2 = Identity.Parse(idStr);
            TestHelper.Assert(id.Equals(id2));

            idStr = id.ToString(ToStringMode.Compat);
            id2   = Identity.Parse(idStr);
            TestHelper.Assert(idStr == "greek \\360\\220\\205\\252/banana \\016-\\360\\237\\215\\214\\342\\202\\254\\302\\242$");
            TestHelper.Assert(id.Equals(id2));

            output.WriteLine("ok");

            output.Write("testing proxyToString... ");
            output.Flush();
            b1 = IObjectPrx.Parse(rf, communicator);
            var b2 = IObjectPrx.Parse(b1.ToString() !, communicator);

            TestHelper.Assert(b1.Equals(b2));

            if (b1.GetConnection() is Connection connection) // not coloc-optimized target
            {
                b2 = connection.CreateProxy(Identity.Parse("fixed"), IObjectPrx.Factory);
                TestHelper.Assert(b2.ToString() == b2.ToString());
            }
            output.WriteLine("ok");

            output.Write("testing propertyToProxy... ");
            output.Flush();

            string propertyPrefix = "Foo.Proxy";

            communicator.SetProperty(propertyPrefix, "test:" + helper.GetTestEndpoint(0));
            b1 = communicator.GetPropertyAsProxy(propertyPrefix, IObjectPrx.Factory);
            TestHelper.Assert(b1 != null &&
                              b1.Identity.Name.Equals("test") && b1.Identity.Category.Length == 0 &&
                              b1.AdapterId.Length == 0 && b1.Facet.Length == 0);

            string property;

            property = propertyPrefix + ".Locator";
            TestHelper.Assert(b1.Locator == null);
            communicator.SetProperty(property, "locator:default -p 10000");
            b1 = communicator.GetPropertyAsProxy(propertyPrefix, IObjectPrx.Factory);
            TestHelper.Assert(b1 != null && b1.Locator != null && b1.Locator.Identity.Name.Equals("locator"));
            communicator.SetProperty(property, "");
            property = propertyPrefix + ".LocatorCacheTimeout";
            TestHelper.Assert(b1.LocatorCacheTimeout == Timeout.InfiniteTimeSpan);
            communicator.SetProperty(property, "1s");
            b1 = communicator.GetPropertyAsProxy(propertyPrefix, IObjectPrx.Factory);
            TestHelper.Assert(b1 != null && b1.LocatorCacheTimeout == TimeSpan.FromSeconds(1));
            communicator.SetProperty(property, "");

            // Now retest with an indirect proxy.
            communicator.SetProperty(propertyPrefix, "test");
            property = propertyPrefix + ".Locator";
            communicator.SetProperty(property, "locator:default -p 10000");
            b1 = communicator.GetPropertyAsProxy(propertyPrefix, IObjectPrx.Factory);
            TestHelper.Assert(b1 != null && b1.Locator != null && b1.Locator.Identity.Name.Equals("locator"));
            communicator.SetProperty(property, "");

            property = propertyPrefix + ".LocatorCacheTimeout";
            TestHelper.Assert(b1.LocatorCacheTimeout == Timeout.InfiniteTimeSpan);
            communicator.SetProperty(property, "1s");
            b1 = communicator.GetPropertyAsProxy(propertyPrefix, IObjectPrx.Factory);
            TestHelper.Assert(b1 != null && b1.LocatorCacheTimeout == TimeSpan.FromSeconds(1));
            communicator.SetProperty(property, "");

            // This cannot be tested so easily because the property is cached
            // on communicator initialization.
            //
            //communicator.SetProperty("Default.LocatorCacheTimeout", "60");
            //b1 = communicator.propertyToProxy(propertyPrefix);
            //TestHelper.Assert(b1.LocatorCacheTimeout == 60);
            //communicator.SetProperty("Default.LocatorCacheTimeout", "");

            communicator.SetProperty(propertyPrefix, "test:" + helper.GetTestEndpoint(0));

            property = propertyPrefix + ".Router";
            TestHelper.Assert(b1.Router == null);
            communicator.SetProperty(property, "router:default -p 10000");
            b1 = communicator.GetPropertyAsProxy(propertyPrefix, IObjectPrx.Factory);
            TestHelper.Assert(b1 != null && b1.Router != null && b1.Router.Identity.Name.Equals("router"));
            communicator.RemoveProperty(property);

            property = propertyPrefix + ".PreferNonSecure";
            TestHelper.Assert(b1.PreferNonSecure);
            communicator.SetProperty(property, "0");
            b1 = communicator.GetPropertyAsProxy(propertyPrefix, IObjectPrx.Factory);
            TestHelper.Assert(b1 != null && !b1.PreferNonSecure);
            communicator.RemoveProperty(property);

            property = propertyPrefix + ".ConnectionCached";
            TestHelper.Assert(b1.IsConnectionCached);
            communicator.SetProperty(property, "0");
            b1 = communicator.GetPropertyAsProxy(propertyPrefix, IObjectPrx.Factory);
            TestHelper.Assert(b1 != null && !b1.IsConnectionCached);
            communicator.RemoveProperty(property);

            property = propertyPrefix + ".InvocationTimeout";
            TestHelper.Assert(b1.InvocationTimeout == -1);
            communicator.SetProperty(property, "1000");
            b1 = communicator.GetPropertyAsProxy(propertyPrefix, IObjectPrx.Factory);
            TestHelper.Assert(b1 != null && b1.InvocationTimeout == 1000);
            communicator.RemoveProperty(property);

            property = propertyPrefix + ".EndpointSelection";
            TestHelper.Assert(b1.EndpointSelection == EndpointSelectionType.Random);
            communicator.SetProperty(property, "Random");
            b1 = communicator.GetPropertyAsProxy(propertyPrefix, IObjectPrx.Factory);
            TestHelper.Assert(b1 != null && b1.EndpointSelection == EndpointSelectionType.Random);
            communicator.SetProperty(property, "Ordered");
            b1 = communicator.GetPropertyAsProxy(propertyPrefix, IObjectPrx.Factory);
            TestHelper.Assert(b1 != null && b1.EndpointSelection == EndpointSelectionType.Ordered);
            communicator.RemoveProperty(property);

            property = propertyPrefix + ".Context.c1";
            TestHelper.Assert(!b1.Context.ContainsKey("c1"));
            communicator.SetProperty(property, "TEST");
            b1 = communicator.GetPropertyAsProxy(propertyPrefix, IObjectPrx.Factory);
            TestHelper.Assert(b1 != null && b1.Context["c1"].Equals("TEST"));

            property = propertyPrefix + ".Context.c2";
            TestHelper.Assert(!b1.Context.ContainsKey("c2"));
            communicator.SetProperty(property, "TEST");
            b1 = communicator.GetPropertyAsProxy(propertyPrefix, IObjectPrx.Factory);
            TestHelper.Assert(b1 != null && b1.Context["c2"].Equals("TEST"));

            communicator.SetProperty(propertyPrefix + ".Context.c1", "");
            communicator.SetProperty(propertyPrefix + ".Context.c2", "");

            output.WriteLine("ok");

            output.Write("testing proxyToProperty... ");
            output.Flush();

            var router = IRouterPrx.Parse("router", communicator).Clone(
                cacheConnection: true,
                preferNonSecure: true,
                endpointSelection: EndpointSelectionType.Random,
                locatorCacheTimeout: TimeSpan.FromSeconds(200),
                invocationTimeout: 1500);

            var locator = ILocatorPrx.Parse("locator", communicator).Clone(
                cacheConnection: false,
                preferNonSecure: true,
                endpointSelection: EndpointSelectionType.Random,
                locatorCacheTimeout: TimeSpan.FromSeconds(300),
                invocationTimeout: 1500,
                router: router);

            b1 = IObjectPrx.Parse("test", communicator).Clone(
                cacheConnection: true,
                preferNonSecure: false,
                endpointSelection: EndpointSelectionType.Ordered,
                locatorCacheTimeout: TimeSpan.FromSeconds(100),
                invocationTimeout: 1234,
                encoding: Encoding.V2_0,
                locator: locator);

            Dictionary <string, string> proxyProps = b1.ToProperty("Test");

            TestHelper.Assert(proxyProps.Count == 18);

            string defaultProtocolName = communicator.DefaultProtocol.GetName();

            TestHelper.Assert(proxyProps["Test"] == $"test -t -p {defaultProtocolName} -e 2.0");
            TestHelper.Assert(proxyProps["Test.ConnectionCached"] == "1");
            TestHelper.Assert(proxyProps["Test.PreferNonSecure"] == "0");
            TestHelper.Assert(proxyProps["Test.EndpointSelection"] == "Ordered");
            TestHelper.Assert(proxyProps["Test.LocatorCacheTimeout"] == "100s");
            TestHelper.Assert(proxyProps["Test.InvocationTimeout"] == "1234");

            TestHelper.Assert(proxyProps["Test.Locator"] == $"locator -t -p {defaultProtocolName} -e {Encoding.V2_0}");
            TestHelper.Assert(proxyProps["Test.Locator.ConnectionCached"] == "0");
            TestHelper.Assert(proxyProps["Test.Locator.PreferNonSecure"] == "1");
            TestHelper.Assert(proxyProps["Test.Locator.EndpointSelection"] == "Random");
            TestHelper.Assert(proxyProps["Test.Locator.LocatorCacheTimeout"] == "5m");
            TestHelper.Assert(proxyProps["Test.Locator.InvocationTimeout"] == "1500");

            TestHelper.Assert(proxyProps["Test.Locator.Router"] ==
                              $"router -t -p {defaultProtocolName} -e {communicator.DefaultEncoding}");
            TestHelper.Assert(proxyProps["Test.Locator.Router.ConnectionCached"] == "1");
            TestHelper.Assert(proxyProps["Test.Locator.Router.PreferNonSecure"] == "1");
            TestHelper.Assert(proxyProps["Test.Locator.Router.EndpointSelection"] == "Random");
            TestHelper.Assert(proxyProps["Test.Locator.Router.LocatorCacheTimeout"] == "200s");
            TestHelper.Assert(proxyProps["Test.Locator.Router.InvocationTimeout"] == "1500");

            output.WriteLine("ok");

            output.Write("testing ice_getCommunicator... ");
            output.Flush();
            TestHelper.Assert(baseProxy.Communicator == communicator);
            output.WriteLine("ok");

            output.Write("testing proxy methods... ");

            TestHelper.Assert(baseProxy.Clone(facet: "facet", IObjectPrx.Factory).Facet.Equals("facet"));
            TestHelper.Assert(baseProxy.Clone(adapterId: "id").AdapterId.Equals("id"));
            TestHelper.Assert(!baseProxy.Clone(invocationMode: InvocationMode.Twoway).IsOneway);
            TestHelper.Assert(baseProxy.Clone(invocationMode: InvocationMode.Oneway).IsOneway);
            TestHelper.Assert(baseProxy.Clone(invocationMode: InvocationMode.Datagram).IsOneway);
            TestHelper.Assert(baseProxy.Clone(invocationMode: InvocationMode.BatchOneway).InvocationMode ==
                              InvocationMode.BatchOneway);
            TestHelper.Assert(baseProxy.Clone(invocationMode: InvocationMode.Datagram).InvocationMode ==
                              InvocationMode.Datagram);
            TestHelper.Assert(baseProxy.Clone(invocationMode: InvocationMode.BatchDatagram).InvocationMode ==
                              InvocationMode.BatchDatagram);
            TestHelper.Assert(baseProxy.Clone(preferNonSecure: true).PreferNonSecure);
            TestHelper.Assert(!baseProxy.Clone(preferNonSecure: false).PreferNonSecure);

            try
            {
                baseProxy.Clone(invocationTimeout: 0);
                TestHelper.Assert(false);
            }
            catch (ArgumentException)
            {
            }

            try
            {
                baseProxy.Clone(invocationTimeout: -1);
            }
            catch (ArgumentException)
            {
                TestHelper.Assert(false);
            }

            try
            {
                baseProxy.Clone(invocationTimeout: -2);
                TestHelper.Assert(false);
            }
            catch (ArgumentException)
            {
            }

            try
            {
                baseProxy.Clone(locatorCacheTimeout: TimeSpan.Zero);
            }
            catch (ArgumentException)
            {
                TestHelper.Assert(false);
            }

            try
            {
                baseProxy.Clone(locatorCacheTimeout: Timeout.InfiniteTimeSpan);
            }
            catch (ArgumentException)
            {
                TestHelper.Assert(false);
            }

            try
            {
                baseProxy.Clone(locatorCacheTimeout: TimeSpan.FromSeconds(-2));
                TestHelper.Assert(false);
            }
            catch (ArgumentException)
            {
            }

            output.WriteLine("ok");

            output.Write("testing proxy comparison... ");
            output.Flush();

            TestHelper.Assert(Equals(IObjectPrx.Parse("foo", communicator), IObjectPrx.Parse("foo", communicator)));
            TestHelper.Assert(!IObjectPrx.Parse("foo", communicator).Equals(IObjectPrx.Parse("foo2", communicator)));

            var compObj = IObjectPrx.Parse("foo", communicator);

            TestHelper.Assert(compObj.Clone(facet: "facet", IObjectPrx.Factory).Equals(
                                  compObj.Clone(facet: "facet", IObjectPrx.Factory)));
            TestHelper.Assert(!compObj.Clone(facet: "facet", IObjectPrx.Factory).Equals(
                                  compObj.Clone(facet: "facet1", IObjectPrx.Factory)));

            TestHelper.Assert(compObj.Clone(invocationMode: InvocationMode.Oneway).Equals(
                                  compObj.Clone(invocationMode: InvocationMode.Oneway)));
            TestHelper.Assert(!compObj.Clone(invocationMode: InvocationMode.Oneway).Equals(
                                  compObj.Clone(invocationMode: InvocationMode.Twoway)));

            TestHelper.Assert(compObj.Clone(cacheConnection: true).Equals(compObj.Clone(cacheConnection: true)));
            TestHelper.Assert(!compObj.Clone(cacheConnection: false).Equals(compObj.Clone(cacheConnection: true)));

            TestHelper.Assert(compObj.Clone(endpointSelection: EndpointSelectionType.Random).Equals(
                                  compObj.Clone(endpointSelection: EndpointSelectionType.Random)));
            TestHelper.Assert(!compObj.Clone(endpointSelection: EndpointSelectionType.Random).Equals(
                                  compObj.Clone(endpointSelection: EndpointSelectionType.Ordered)));

            TestHelper.Assert(compObj.Clone(connectionId: "id2").Equals(compObj.Clone(connectionId: "id2")));
            TestHelper.Assert(!compObj.Clone(connectionId: "id1").Equals(compObj.Clone(connectionId: "id2")));
            TestHelper.Assert(compObj.Clone(connectionId: "id1").ConnectionId.Equals("id1"));
            TestHelper.Assert(compObj.Clone(connectionId: "id2").ConnectionId.Equals("id2"));

            var loc1 = ILocatorPrx.Parse("loc1:default -p 10000", communicator);
            var loc2 = ILocatorPrx.Parse("loc2:default -p 10000", communicator);

            TestHelper.Assert(compObj.Clone(clearLocator: true).Equals(compObj.Clone(clearLocator: true)));
            TestHelper.Assert(compObj.Clone(locator: loc1).Equals(compObj.Clone(locator: loc1)));
            TestHelper.Assert(!compObj.Clone(locator: loc1).Equals(compObj.Clone(clearLocator: true)));
            TestHelper.Assert(!compObj.Clone(clearLocator: true).Equals(compObj.Clone(locator: loc2)));
            TestHelper.Assert(!compObj.Clone(locator: loc1).Equals(compObj.Clone(locator: loc2)));

            var rtr1 = IRouterPrx.Parse("rtr1:default -p 10000", communicator);
            var rtr2 = IRouterPrx.Parse("rtr2:default -p 10000", communicator);

            TestHelper.Assert(compObj.Clone(clearRouter: true).Equals(compObj.Clone(clearRouter: true)));
            TestHelper.Assert(compObj.Clone(router: rtr1).Equals(compObj.Clone(router: rtr1)));
            TestHelper.Assert(!compObj.Clone(router: rtr1).Equals(compObj.Clone(clearRouter: true)));
            TestHelper.Assert(!compObj.Clone(clearRouter: true).Equals(compObj.Clone(router: rtr2)));
            TestHelper.Assert(!compObj.Clone(router: rtr1).Equals(compObj.Clone(router: rtr2)));

            Dictionary <string, string> ctx1 = new Dictionary <string, string>();

            ctx1["ctx1"] = "v1";
            Dictionary <string, string> ctx2 = new Dictionary <string, string>();

            ctx2["ctx2"] = "v2";
            TestHelper.Assert(compObj.Clone(context: new Dictionary <string, string>()).Equals(
                                  compObj.Clone(context: new Dictionary <string, string>())));
            TestHelper.Assert(compObj.Clone(context: ctx1).Equals(compObj.Clone(context: ctx1)));
            TestHelper.Assert(!compObj.Clone(context: ctx1).Equals(
                                  compObj.Clone(context: new Dictionary <string, string>())));
            TestHelper.Assert(!compObj.Clone(context: new Dictionary <string, string>()).Equals(
                                  compObj.Clone(context: ctx2)));
            TestHelper.Assert(!compObj.Clone(context: ctx1).Equals(compObj.Clone(context: ctx2)));

            TestHelper.Assert(compObj.Clone(preferNonSecure: true).Equals(compObj.Clone(preferNonSecure: true)));
            TestHelper.Assert(!compObj.Clone(preferNonSecure: true).Equals(compObj.Clone(preferNonSecure: false)));

            var compObj1 = IObjectPrx.Parse("foo:tcp -h 127.0.0.1 -p 10000", communicator);
            var compObj2 = IObjectPrx.Parse("foo:tcp -h 127.0.0.1 -p 10001", communicator);

            TestHelper.Assert(!compObj1.Equals(compObj2));

            compObj1 = IObjectPrx.Parse("foo@MyAdapter1", communicator);
            compObj2 = IObjectPrx.Parse("foo@MyAdapter2", communicator);
            TestHelper.Assert(!compObj1.Equals(compObj2));

            TestHelper.Assert(compObj1.Clone(locatorCacheTimeout: TimeSpan.FromSeconds(20))
                              .Equals(compObj1.Clone(locatorCacheTimeout: TimeSpan.FromSeconds(20))));
            TestHelper.Assert(!compObj1.Clone(locatorCacheTimeout: TimeSpan.FromSeconds(10))
                              .Equals(compObj1.Clone(locatorCacheTimeout: TimeSpan.FromSeconds(20))));

            TestHelper.Assert(compObj1.Clone(invocationTimeout: 20).Equals(compObj1.Clone(invocationTimeout: 20)));
            TestHelper.Assert(!compObj1.Clone(invocationTimeout: 10).Equals(compObj1.Clone(invocationTimeout: 20)));

            compObj1 = IObjectPrx.Parse("foo:tcp -h 127.0.0.1 -p 1000", communicator);
            compObj2 = IObjectPrx.Parse("foo@MyAdapter1", communicator);
            TestHelper.Assert(!compObj1.Equals(compObj2));

            var endpts1 = IObjectPrx.Parse("foo:tcp -h 127.0.0.1 -p 10000", communicator).Endpoints;
            var endpts2 = IObjectPrx.Parse("foo:tcp -h 127.0.0.1 -p 10001", communicator).Endpoints;

            TestHelper.Assert(!endpts1[0].Equals(endpts2[0]));
            TestHelper.Assert(endpts1[0].Equals(IObjectPrx.Parse("foo:tcp -h 127.0.0.1 -p 10000", communicator).Endpoints[0]));

            if (baseProxy.GetConnection() is Connection baseConnection)
            {
                Connection baseConnection2 = baseProxy.Clone(connectionId: "base2").GetConnection() !;
                compObj1 = compObj1.Clone(fixedConnection: baseConnection);
                compObj2 = compObj2.Clone(fixedConnection: baseConnection2);
                TestHelper.Assert(!compObj1.Equals(compObj2));
            }
            output.WriteLine("ok");

            output.Write("testing checked cast... ");
            output.Flush();
            var cl = IMyClassPrx.CheckedCast(baseProxy);

            TestHelper.Assert(cl != null);
            var derived = IMyDerivedClassPrx.CheckedCast(cl);

            TestHelper.Assert(derived != null);
            TestHelper.Assert(cl.Equals(baseProxy));
            TestHelper.Assert(derived.Equals(baseProxy));
            TestHelper.Assert(cl.Equals(derived));
            try
            {
                IMyDerivedClassPrx.CheckedCast(cl.Clone(facet: "facet", IObjectPrx.Factory));
                TestHelper.Assert(false);
            }
            catch (ObjectNotExistException)
            {
            }
            output.WriteLine("ok");

            output.Write("testing checked cast with context... ");
            output.Flush();

            Dictionary <string, string> c = cl.getContext();

            TestHelper.Assert(c == null || c.Count == 0);

            c        = new Dictionary <string, string>();
            c["one"] = "hello";
            c["two"] = "world";
            cl       = IMyClassPrx.CheckedCast(baseProxy, c);
            Dictionary <string, string> c2 = cl !.getContext();

            TestHelper.Assert(c.DictionaryEqual(c2));
            output.WriteLine("ok");

            output.Write("testing ice_fixed... ");
            output.Flush();
            {
                if (cl.GetConnection() is Connection connection2)
                {
                    TestHelper.Assert(!cl.IsFixed);
                    IMyClassPrx prx = cl.Clone(fixedConnection: connection2);
                    TestHelper.Assert(prx.IsFixed);
                    prx.IcePing();
                    TestHelper.Assert(cl.Clone("facet", IObjectPrx.Factory, fixedConnection: connection2).Facet.Equals("facet"));
                    TestHelper.Assert(cl.Clone(invocationMode: InvocationMode.Oneway, fixedConnection: connection2).IsOneway);
                    Dictionary <string, string> ctx = new Dictionary <string, string>();
                    ctx["one"] = "hello";
                    ctx["two"] = "world";
                    TestHelper.Assert(cl.Clone(fixedConnection: connection2).Context.Count == 0);
                    TestHelper.Assert(cl.Clone(context: ctx, fixedConnection: connection2).Context.Count == 2);
                    TestHelper.Assert(cl.Clone(fixedConnection: connection2).InvocationTimeout == -1);
                    TestHelper.Assert(cl.Clone(invocationTimeout: 10, fixedConnection: connection2).InvocationTimeout == 10);
                    TestHelper.Assert(cl.Clone(fixedConnection: connection2).GetConnection() == connection2);
                    TestHelper.Assert(cl.Clone(fixedConnection: connection2).Clone(fixedConnection: connection2).GetConnection() == connection2);
                    Connection?fixedConnection = cl.Clone(connectionId: "ice_fixed").GetConnection();
                    TestHelper.Assert(cl.Clone(fixedConnection: connection2).Clone(fixedConnection: fixedConnection).GetConnection() == fixedConnection);
                    try
                    {
                        cl.Clone(invocationMode: InvocationMode.Datagram, fixedConnection: connection2);
                        TestHelper.Assert(false);
                    }
                    catch (ArgumentException)
                    {
                    }
                }
            }
            output.WriteLine("ok");

            output.Write("testing encoding versioning... ");
            string ref13 = "test -e 1.3:" + helper.GetTestEndpoint(0);
            var    cl13  = IMyClassPrx.Parse(ref13, communicator);

            try
            {
                cl13.IcePing();
                TestHelper.Assert(false);
            }
            catch (NotSupportedException)
            {
                // expected
            }
            output.WriteLine("ok");

            output.Write("testing protocol versioning... ");
            output.Flush();
            string ref3 = "test -p 3:" + helper.GetTestEndpoint(0);
            var    cl3  = IMyClassPrx.Parse(ref3, communicator);

            try
            {
                cl3.IcePing();
                TestHelper.Assert(false);
            }
            catch (NotSupportedException)
            {
                // expected
            }
            output.WriteLine("ok");

            output.Write("testing opaque endpoints... ");
            output.Flush();

            try
            {
                // Invalid -x option
                IObjectPrx.Parse("id:opaque -t 99 -v abcd -x abc", communicator);
                TestHelper.Assert(false);
            }
            catch (FormatException)
            {
            }

            try
            {
                // Missing -t and -v
                IObjectPrx.Parse("id:opaque", communicator);
                TestHelper.Assert(false);
            }
            catch (FormatException)
            {
            }

            try
            {
                // Repeated -t
                IObjectPrx.Parse("id:opaque -t 1 -t 1 -v abcd", communicator);
                TestHelper.Assert(false);
            }
            catch (FormatException)
            {
            }

            try
            {
                // Repeated -v
                IObjectPrx.Parse("id:opaque -t 1 -v abcd -v abcd", communicator);
                TestHelper.Assert(false);
            }
            catch (FormatException)
            {
            }

            try
            {
                // Missing -t
                IObjectPrx.Parse("id:opaque -v abcd", communicator);
                TestHelper.Assert(false);
            }
            catch (FormatException)
            {
            }

            try
            {
                // Missing -v
                IObjectPrx.Parse("id:opaque -t 1", communicator);
                TestHelper.Assert(false);
            }
            catch (FormatException)
            {
            }

            try
            {
                // Missing arg for -t
                IObjectPrx.Parse("id:opaque -t -v abcd", communicator);
                TestHelper.Assert(false);
            }
            catch (FormatException)
            {
            }

            try
            {
                // Missing arg for -v
                IObjectPrx.Parse("id:opaque -t 1 -v", communicator);
                TestHelper.Assert(false);
            }
            catch (FormatException)
            {
            }

            try
            {
                // Not a number for -t
                IObjectPrx.Parse("id:opaque -t x -v abcd", communicator);
                TestHelper.Assert(false);
            }
            catch (FormatException)
            {
            }

            try
            {
                // < 0 for -t
                IObjectPrx.Parse("id:opaque -t -1 -v abcd", communicator);
                TestHelper.Assert(false);
            }
            catch (FormatException)
            {
            }

            try
            {
                // Invalid char for -v
                IObjectPrx.Parse("id:opaque -t 99 -v x?c", communicator);
                TestHelper.Assert(false);
            }
            catch (FormatException)
            {
            }

            try
            {
                // Invalid lenght for base64 input
                IObjectPrx.Parse("id:opaque -t 99 -v xc", communicator);
                TestHelper.Assert(false);
            }
            catch (FormatException)
            {
            }

            // Legal TCP endpoint expressed as opaque endpoint
            // Opaque endpoint encoded with 1.1 encoding.
            var p1 = IObjectPrx.Parse("test -e 1.1 -p ice1:opaque -e 1.1 -t 1 -v CTEyNy4wLjAuMeouAAAQJwAAAA==",
                                      communicator);

            TestHelper.Assert(p1.ToString() !.Equals("test -t -p ice1 -e 1.1:tcp -h 127.0.0.1 -p 12010 -t 10000"));

            if (!(communicator.GetPropertyAsBool("Ice.IPv6") ?? false))
            {
                // Two legal TCP endpoints expressed as opaque endpoints
                p1 = IObjectPrx.Parse("test -e 1.1 -p ice1:" + "" +
                                      "opaque -e 1.1 -t 1 -v CTEyNy4wLjAuMeouAAAQJwAAAA==:" +
                                      "opaque -e 1.1 -t 1 -v CTEyNy4wLjAuMusuAAAQJwAAAA==", communicator);
                TestHelper.Assert(p1.ToString() ==
                                  "test -t -p ice1 -e 1.1:tcp -h 127.0.0.1 -p 12010 -t 10000:tcp -h 127.0.0.2 -p 12011 -t 10000");

                // Test that an SSL endpoint and a nonsense endpoint get written back out as an opaque endpoint.
                p1 = IObjectPrx.Parse("test -e 1.1 -p ice1:opaque -e 1.1 -t 2 -v CTEyNy4wLjAuMREnAAD/////AA==:opaque -e 1.1 -t 99 -v abch",
                                      communicator);
                TestHelper.Assert(p1.ToString() ==
                                  "test -t -p ice1 -e 1.1:ssl -h 127.0.0.1 -p 10001 -t infinite:opaque -t 99 -e 1.1 -v abch");
            }

            output.WriteLine("ok");

            output.Write("testing communicator shutdown/destroy... ");
            output.Flush();
            {
                Communicator com = new Communicator();
                com.ShutdownAsync();
                com.WaitForShutdownAsync();
                com.Dispose();
                com.ShutdownAsync();
                com.WaitForShutdownAsync();
                com.Dispose();
            }
            output.WriteLine("ok");

            return(cl);
        }
        /// <summary>
        /// Gets the encryption protector for the server
        /// </summary>
        /// <param name="resourceGroupName">The name of the resource group</param>
        /// <param name="serverName">The name of the server</param>
        /// <returns>The encryption protector model</returns>
        public AzureSqlServerTransparentDataEncryptionProtectorModel GetEncryptionProtector(string resourceGroupName, string serverName)
        {
            var resp = Communicator.GetEncryptionProtector(resourceGroupName, serverName, Util.GenerateTracingId());

            return(CreateEncryptionProtectorModelFromResponse(resourceGroupName, serverName, resp));
        }
Beispiel #54
0
 public RemoteCommunicator(Communicator communicator) => _communicator = communicator;
Beispiel #55
0
        internal static void Run(Communicator communicator, IMyClassPrx p)
        {
            {
                byte[] i = Enumerable.Range(0, Length).Select(x => (byte)x).ToArray();
                (byte[] ReturnValue, byte[] o) = p.OpAByteSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = Enumerable.Range(0, Length).Select(x => (byte)x).ToList();
                (List <byte> ReturnValue, List <byte> o) = p.OpLByteSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = new LinkedList <byte>(Enumerable.Range(0, Length).Select(x => (byte)x).ToArray());
                (LinkedList <byte> ReturnValue, LinkedList <byte> o) = p.OpKByteSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = new Queue <byte>(Enumerable.Range(0, Length).Select(x => (byte)x).ToArray());
                (Queue <byte> ReturnValue, Queue <byte> o) = p.OpQByteSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = new Stack <byte>(Enumerable.Range(0, Length).Select(x => (byte)x).ToArray());
                (Stack <byte> ReturnValue, Stack <byte> o) = p.OpSByteSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = new Custom <byte>(Enumerable.Range(0, Length).Select(x => (byte)x).ToArray());
                (Custom <byte> ReturnValue, Custom <byte> o) = p.OpCByteSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                bool[] i = Enumerable.Range(0, Length).Select(x => x % 2 == 1).ToArray();
                (bool[] ReturnValue, bool[] o) = p.OpABoolSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = Enumerable.Range(0, Length).Select(x => x % 2 == 1).ToList();
                (List <bool> ReturnValue, List <bool> o) = p.OpLBoolSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = new LinkedList <bool>(Enumerable.Range(0, Length).Select(x => x % 2 == 1).ToArray());
                (LinkedList <bool> ReturnValue, LinkedList <bool> o) = p.OpKBoolSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = new Queue <bool>(Enumerable.Range(0, Length).Select(x => x % 2 == 1).ToArray());
                (Queue <bool> ReturnValue, Queue <bool> o) = p.OpQBoolSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = new Stack <bool>(Enumerable.Range(0, Length).Select(x => x % 2 == 1).ToArray());
                (Stack <bool> ReturnValue, Stack <bool> o) = p.OpSBoolSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = new Custom <bool>(Enumerable.Range(0, Length).Select(x => x % 2 == 1).ToArray());
                (Custom <bool> ReturnValue, Custom <bool> o) = p.OpCBoolSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                short[]? i = Enumerable.Range(0, Length).Select(x => (short)x).ToArray();
                (short[] ReturnValue, short[] o) = p.OpAShortSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = Enumerable.Range(0, Length).Select(x => (short)x).ToList();
                (List <short> ReturnValue, List <short> o) = p.OpLShortSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = new LinkedList <short>(Enumerable.Range(0, Length).Select(x => (short)x).ToArray());
                (LinkedList <short> ReturnValue, LinkedList <short> o) = p.OpKShortSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = new Queue <short>(Enumerable.Range(0, Length).Select(x => (short)x).ToArray());
                (Queue <short> ReturnValue, Queue <short> o) = p.OpQShortSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = new Stack <short>(Enumerable.Range(0, Length).Select(x => (short)x).ToArray());
                (Stack <short> ReturnValue, Stack <short> o) = p.OpSShortSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = new Custom <short>(Enumerable.Range(0, Length).Select(x => (short)x).ToArray());
                (Custom <short> ReturnValue, Custom <short> o) = p.OpCShortSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                int[] i = Enumerable.Range(0, Length).ToArray();
                (int[] ReturnValue, int[] o) = p.OpAIntSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = Enumerable.Range(0, Length).ToList();
                (List <int> ReturnValue, List <int> o) = p.OpLIntSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = new LinkedList <int>(Enumerable.Range(0, Length).ToArray());
                (LinkedList <int> ReturnValue, LinkedList <int> o) = p.OpKIntSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = new Queue <int>(Enumerable.Range(0, Length).ToArray());
                (Queue <int> ReturnValue, Queue <int> o) = p.OpQIntSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = new Stack <int>(Enumerable.Range(0, Length).ToArray());
                (Stack <int> ReturnValue, Stack <int> o) = p.OpSIntSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = new Custom <int>(Enumerable.Range(0, Length).ToArray());
                (Custom <int> ReturnValue, Custom <int> o) = p.OpCIntSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                long[]? i = Enumerable.Range(0, Length).Select(x => (long)x).ToArray();
                (long[] ReturnValue, long[] o) = p.OpALongSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = Enumerable.Range(0, Length).Select(x => (long)x).ToList();
                (List <long> ReturnValue, List <long> o) = p.OpLLongSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = new LinkedList <long>(Enumerable.Range(0, Length).Select(x => (long)x).ToArray());
                (LinkedList <long> ReturnValue, LinkedList <long> o) = p.OpKLongSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = new Queue <long>(Enumerable.Range(0, Length).Select(x => (long)x).ToArray());
                (Queue <long> ReturnValue, Queue <long> o) = p.OpQLongSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = new Stack <long>(Enumerable.Range(0, Length).Select(x => (long)x).ToArray());
                (Stack <long> ReturnValue, Stack <long> o) = p.OpSLongSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = new Custom <long>(Enumerable.Range(0, Length).Select(x => (long)x).ToArray());
                (Custom <long> ReturnValue, Custom <long> o) = p.OpCLongSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                float[] i = Enumerable.Range(0, Length).Select(x => (float)x).ToArray();
                (float[] ReturnValue, float[] o) = p.OpAFloatSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = Enumerable.Range(0, Length).Select(x => (float)x).ToList();
                (List <float> ReturnValue, List <float> o) = p.OpLFloatSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = new LinkedList <float>(Enumerable.Range(0, Length).Select(x => (float)x).ToArray());
                (LinkedList <float> ReturnValue, LinkedList <float> o) = p.OpKFloatSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = new Queue <float>(Enumerable.Range(0, Length).Select(x => (float)x).ToArray());
                (Queue <float> ReturnValue, Queue <float> o) = p.OpQFloatSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = new Stack <float>(Enumerable.Range(0, Length).Select(x => (float)x).ToArray());
                (Stack <float> ReturnValue, Stack <float> o) = p.OpSFloatSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = new Custom <float>(Enumerable.Range(0, Length).Select(x => (float)x).ToArray());
                (Custom <float> ReturnValue, Custom <float> o) = p.OpCFloatSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                double[] i = Enumerable.Range(0, Length).Select(x => (double)x).ToArray();
                (double[] ReturnValue, double[] o) = p.OpADoubleSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = Enumerable.Range(0, Length).Select(x => (double)x).ToList();
                (List <double> ReturnValue, List <double> o) = p.OpLDoubleSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = new LinkedList <double>(Enumerable.Range(0, Length).Select(x => (double)x).ToArray());
                (LinkedList <double> ReturnValue, LinkedList <double> o) = p.OpKDoubleSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = new Queue <double>(Enumerable.Range(0, Length).Select(x => (double)x).ToArray());
                (Queue <double> ReturnValue, Queue <double> o) = p.OpQDoubleSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = new Stack <double>(Enumerable.Range(0, Length).Select(x => (double)x).ToArray());
                (Stack <double> ReturnValue, Stack <double> o) = p.OpSDoubleSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = new Custom <double>(Enumerable.Range(0, Length).Select(x => (double)x).ToArray());
                (Custom <double> ReturnValue, Custom <double> o) = p.OpCDoubleSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                string[] i = Enumerable.Range(0, Length).Select(x => x.ToString()).ToArray();
                (string[] ReturnValue, string[] o) = p.OpAStringSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = Enumerable.Range(0, Length).Select(x => x.ToString()).ToList();
                (List <string> ReturnValue, List <string> o) = p.OpLStringSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = new LinkedList <string>(Enumerable.Range(0, Length).Select(x => x.ToString()).ToArray());
                (LinkedList <string> ReturnValue, LinkedList <string> o) = p.OpKStringSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = new Queue <string>(Enumerable.Range(0, Length).Select(x => x.ToString()).ToArray());
                (Queue <string> ReturnValue, Queue <string> o) = p.OpQStringSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = new Stack <string>(Enumerable.Range(0, Length).Select(x => x.ToString()).ToArray());
                (Stack <string> ReturnValue, Stack <string> o) = p.OpSStringSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = new Custom <string>(Enumerable.Range(0, Length).Select(x => x.ToString()).ToArray());
                (Custom <string> ReturnValue, Custom <string> o) = p.OpCStringSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                AnyClass[] i = Enumerable.Range(0, Length).Select(x => new CV(x) as AnyClass).ToArray();
                (AnyClass?[] ReturnValue, AnyClass?[] o) = p.OpAObjectSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i, new CVComparer()));
                TestHelper.Assert(ReturnValue.SequenceEqual(i, new CVComparer()));
            }

            {
                var i = Enumerable.Range(0, Length).Select(x => new CV(x) as AnyClass).ToList <AnyClass?>();
                (List <AnyClass?> ReturnValue, List <AnyClass?> o) = p.OpLObjectSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i, new CVComparer()));
                TestHelper.Assert(ReturnValue.SequenceEqual(i, new CVComparer()));
            }

            {
                var i = new Custom <AnyClass>(Enumerable.Range(0, Length).Select(
                                                  x => new CV(x) as AnyClass).ToArray());
                (Custom <AnyClass?> ReturnValue, Custom <AnyClass?> o) = p.OpCObjectSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i, new CVComparer()));
                TestHelper.Assert(ReturnValue.SequenceEqual(i, new CVComparer()));
            }

            {
                IObjectPrx[]? i = Enumerable.Range(0, Length).Select(
                    x => IObjectPrx.Parse(x.ToString(), communicator)).ToArray();
                (IObjectPrx?[] ReturnValue, IObjectPrx?[] o) = p.OpAObjectPrxSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = Enumerable.Range(0, Length).Select(
                    x => IObjectPrx.Parse(x.ToString(), communicator)).ToList <IObjectPrx?>();
                (List <IObjectPrx?> ReturnValue, List <IObjectPrx?> o) = p.OpLObjectPrxSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = new LinkedList <IObjectPrx?>(Enumerable.Range(0, Length).Select(
                                                         x => IObjectPrx.Parse(x.ToString(), communicator)).ToArray());
                (LinkedList <IObjectPrx?> ReturnValue, LinkedList <IObjectPrx?> o) = p.OpKObjectPrxSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = new Queue <IObjectPrx?>(Enumerable.Range(0, Length).Select(
                                                    x => IObjectPrx.Parse(x.ToString(), communicator)).ToArray());
                (Queue <IObjectPrx?> ReturnValue, Queue <IObjectPrx?> o) = p.OpQObjectPrxSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = new Stack <IObjectPrx?>(Enumerable.Range(0, Length).Select(
                                                    x => IObjectPrx.Parse(x.ToString(), communicator)).ToArray());
                (Stack <IObjectPrx?> ReturnValue, Stack <IObjectPrx?> o) = p.OpSObjectPrxSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = new Custom <IObjectPrx?>(Enumerable.Range(0, Length).Select(
                                                     x => IObjectPrx.Parse(x.ToString(), communicator)).ToArray());
                (Custom <IObjectPrx?> ReturnValue, Custom <IObjectPrx?> o) = p.OpCObjectPrxSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                S[]? i = Enumerable.Range(0, Length).Select(x => new S(x)).ToArray();
                (S[] ReturnValue, S[] o) = p.OpAStructSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = Enumerable.Range(0, Length).Select(x => new S(x)).ToList();
                (List <S> ReturnValue, List <S> o) = p.OpLStructSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = new LinkedList <S>(Enumerable.Range(0, Length).Select(x => new S(x)).ToArray());
                (LinkedList <S> ReturnValue, LinkedList <S> o) = p.OpKStructSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = new Queue <S>(Enumerable.Range(0, Length).Select(x => new S(x)).ToArray());
                (Queue <S> ReturnValue, Queue <S> o) = p.OpQStructSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = new Stack <S>(Enumerable.Range(0, Length).Select(x => new S(x)).ToArray());
                (Stack <S> ReturnValue, Stack <S> o) = p.OpSStructSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = new Custom <S>(Enumerable.Range(0, Length).Select(x => new S(x)).ToArray());
                (Custom <S> ReturnValue, Custom <S> o) = p.OpCStructSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                CV[] i = Enumerable.Range(0, Length).Select(x => new CV(x)).ToArray();
                (CV?[] ReturnValue, CV?[] o) = p.OpACVSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i, new CVComparer()));
                TestHelper.Assert(ReturnValue.SequenceEqual(i, new CVComparer()));
            }

            {
                var i = Enumerable.Range(0, Length).Select(x => new CV(x)).ToList <CV?>();
                (List <CV?> ReturnValue, List <CV?> o) = p.OpLCVSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i, new CVComparer()));
                TestHelper.Assert(ReturnValue.SequenceEqual(i, new CVComparer()));
            }

            {
                IIPrx[] i = Enumerable.Range(0, Length).Select(
                    x => IIPrx.Parse(x.ToString(), communicator)).ToArray();
                (IIPrx?[] ReturnValue, IIPrx?[] o) = p.OpAIPrxSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = Enumerable.Range(0, Length).Select(
                    x => IIPrx.Parse(x.ToString(), communicator)).ToList <IIPrx?>();
                (List <IIPrx?> ReturnValue, List <IIPrx?> o) = p.OpLIPrxSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = new LinkedList <IIPrx?>(Enumerable.Range(0, Length).Select(
                                                    x => IIPrx.Parse(x.ToString(), communicator)).ToArray());
                (LinkedList <IIPrx?> ReturnValue, LinkedList <IIPrx?> o) = p.OpKIPrxSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = new Queue <IIPrx?>(Enumerable.Range(0, Length).Select(
                                               x => IIPrx.Parse(x.ToString(), communicator)).ToArray());
                (Queue <IIPrx?> ReturnValue, Queue <IIPrx?> o) = p.OpQIPrxSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = new Stack <IIPrx?>(Enumerable.Range(0, Length).Select(
                                               x => IIPrx.Parse(x.ToString(), communicator)).ToArray());
                (Stack <IIPrx?> ReturnValue, Stack <IIPrx?> o) = p.OpSIPrxSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = new Custom <IIPrx?>(Enumerable.Range(0, Length).Select(
                                                x => IIPrx.Parse(x.ToString(), communicator)).ToArray());
                (Custom <IIPrx?> ReturnValue, Custom <IIPrx?> o) = p.OpCIPrxSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                CR[]? i = Enumerable.Range(0, Length).Select(x => new CR(new CV(x))).ToArray();
                (CR?[] ReturnValue, CR?[] o) = p.OpACRSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i, new CRComparer()));
                TestHelper.Assert(ReturnValue.SequenceEqual(i, new CRComparer()));
            }

            {
                var i = Enumerable.Range(0, Length).Select(x => new CR(new CV(x))).ToList <CR?>();
                (List <CR?> ReturnValue, List <CR?> o) = p.OpLCRSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i, new CRComparer()));
                TestHelper.Assert(ReturnValue.SequenceEqual(i, new CRComparer()));
            }

            {
                var i = new Custom <CR>(Enumerable.Range(0, Length).Select(
                                            x => new CR(new CV(x))).ToArray());
                (List <CR?> ReturnValue, List <CR?> o) = p.OpLCRSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i, new CRComparer()));
                TestHelper.Assert(ReturnValue.SequenceEqual(i, new CRComparer()));
            }

            {
                En[] i = Enumerable.Range(0, Length).Select(x => (En)(x % 3)).ToArray();
                (En[] ReturnValue, En[] o) = p.OpAEnSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = Enumerable.Range(0, Length).Select(x => (En)(x % 3)).ToList();
                (List <En> ReturnValue, List <En> o) = p.OpLEnSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = new LinkedList <En>(Enumerable.Range(0, Length).Select(
                                                x => (En)(x % 3)).ToArray());
                (LinkedList <En> ReturnValue, LinkedList <En> o) = p.OpKEnSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = new Queue <En>(Enumerable.Range(0, Length).Select(x => (En)(x % 3)).ToArray());
                (Queue <En> ReturnValue, Queue <En> o) = p.OpQEnSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = new Stack <En>(Enumerable.Range(0, Length).Select(x => (En)(x % 3)).ToArray());
                (Stack <En> ReturnValue, Stack <En> o) = p.OpSEnSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = new Custom <En>(Enumerable.Range(0, Length).Select(x => (En)(x % 3)).ToArray());
                (Custom <En> ReturnValue, Custom <En> o) = p.OpCEnSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = new Custom <int>(Enumerable.Range(0, Length).ToList());
                (Custom <int> ReturnValue, Custom <int> o) = p.OpCustomIntSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = new Custom <CV?>(
                    Enumerable.Range(0, Length).Select(x => new CV(x)).ToList <CV?>());
                (Custom <CV?> ReturnValue, Custom <CV?> o) = p.OpCustomCVSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i, new CVComparer()));
                TestHelper.Assert(ReturnValue.SequenceEqual(i, new CVComparer()));
            }

            {
                var i = new Custom <Custom <int> >();
                for (int c = 0; c < Length; ++c)
                {
                    i.Add(new Custom <int>(Enumerable.Range(0, Length).ToList()));
                }
                (Custom <Custom <int> > ReturnValue, Custom <Custom <int> > o) = p.OpCustomIntSSAsync(i).Result;
                TestHelper.Assert(o.SequenceEqual(i));
                TestHelper.Assert(ReturnValue.SequenceEqual(i));
            }

            {
                var i = new Custom <Custom <CV?> >();
                for (int c = 0; c < Length; ++c)
                {
                    i.Add(new Custom <CV?>(Enumerable.Range(0, Length).Select(
                                               x => new CV(x)).ToList <CV?>()));
                }
                (Custom <Custom <CV?> > ReturnValue, Custom <Custom <CV?> > o) = p.OpCustomCVSSAsync(i).Result;
                for (int c = 0; c < Length; ++c)
                {
                    TestHelper.Assert(o[c].SequenceEqual(i[c], new CVComparer()));
                    TestHelper.Assert(ReturnValue[c].SequenceEqual(i[c], new CVComparer()));
                }
            }

            {
                var i = new Serialize.Small();
                i.i = 99;

                (Serialize.Small ReturnValue, Serialize.Small o) = p.OpSerialSmallCSharpAsync(i).Result;
                TestHelper.Assert(o.i == 99);
                TestHelper.Assert(ReturnValue.i == 99);
            }

            {
                var i = new Serialize.Large();
                i.d1  = 1.0;
                i.d2  = 2.0;
                i.d3  = 3.0;
                i.d4  = 4.0;
                i.d5  = 5.0;
                i.d6  = 6.0;
                i.d7  = 7.0;
                i.d8  = 8.0;
                i.d9  = 9.0;
                i.d10 = 10.0;
                i.d11 = 11.0;
                i.s1  = Serialize.Large.LargeString;

                (Serialize.Large ReturnValue, Serialize.Large o) = p.OpSerialLargeCSharpAsync(i).Result;
                TestHelper.Assert(o.d1 == 1.0);
                TestHelper.Assert(o.d2 == 2.0);
                TestHelper.Assert(o.d3 == 3.0);
                TestHelper.Assert(o.d4 == 4.0);
                TestHelper.Assert(o.d5 == 5.0);
                TestHelper.Assert(o.d6 == 6.0);
                TestHelper.Assert(o.d7 == 7.0);
                TestHelper.Assert(o.d8 == 8.0);
                TestHelper.Assert(o.d9 == 9.0);
                TestHelper.Assert(o.d10 == 10.0);
                TestHelper.Assert(o.d11 == 11.0);
                TestHelper.Assert(o.s1 == Serialize.Large.LargeString);

                TestHelper.Assert(ReturnValue.d1 == 1.0);
                TestHelper.Assert(ReturnValue.d2 == 2.0);
                TestHelper.Assert(ReturnValue.d3 == 3.0);
                TestHelper.Assert(ReturnValue.d4 == 4.0);
                TestHelper.Assert(ReturnValue.d5 == 5.0);
                TestHelper.Assert(ReturnValue.d6 == 6.0);
                TestHelper.Assert(ReturnValue.d7 == 7.0);
                TestHelper.Assert(ReturnValue.d8 == 8.0);
                TestHelper.Assert(ReturnValue.d9 == 9.0);
                TestHelper.Assert(ReturnValue.d10 == 10.0);
                TestHelper.Assert(ReturnValue.d11 == 11.0);
                TestHelper.Assert(ReturnValue.s1 == Serialize.Large.LargeString);
            }

            {
                var i = new Serialize.Struct();
                i.o  = null;
                i.o2 = i;
                i.s  = null;
                i.s2 = "Hello";

                (Serialize.Struct ReturnValue, Serialize.Struct o) = p.OpSerialStructCSharpAsync(i).Result;
                TestHelper.Assert(o.o == null);
                TestHelper.Assert(o.o2 == o);
                TestHelper.Assert(o.s == null);
                TestHelper.Assert(o.s2 == "Hello");

                TestHelper.Assert(ReturnValue.o == null);
                TestHelper.Assert(ReturnValue.o2 == ReturnValue);
                TestHelper.Assert(ReturnValue.s == null);
                TestHelper.Assert(ReturnValue.s2 == "Hello");
            }
        }
Beispiel #56
0
        public override async Task RunAsync(string[] args)
        {
            var properties = CreateTestProperties(ref args);

            properties["Ice.Warn.Connections"] = "0";
            properties["Ice.UDP.RcvSize"]      = "16K";

            string?value;
            int    ipv6;

            if (AssemblyUtil.IsMacOS &&
                properties.TryGetValue("Ice.IPv6", out value) &&
                int.TryParse(value, out ipv6) && ipv6 > 0)
            {
                // Disable dual mode sockets on macOS, see https://github.com/dotnet/corefx/issues/31182
                properties["Ice.IPv4"] = "0";
            }

            await using Communicator communicator = Initialize(properties);
            int num = 0;

            try
            {
                num = args.Length == 1 ? int.Parse(args[0]) : 0;
            }
            catch (FormatException)
            {
            }

            communicator.SetProperty("ControlAdapter.Endpoints", GetTestEndpoint(num, "tcp"));
            ObjectAdapter adapter = communicator.CreateObjectAdapter("ControlAdapter");

            adapter.Add("control", new TestIntf());
            await adapter.ActivateAsync();

            ServerReady();
            if (num == 0)
            {
                communicator.SetProperty("TestAdapter.Endpoints", GetTestEndpoint(num, "udp"));
                ObjectAdapter adapter2 = communicator.CreateObjectAdapter("TestAdapter");
                adapter2.Add("test", new TestIntf());
                await adapter2.ActivateAsync();
            }

            StringBuilder endpoint = new StringBuilder();

            //
            // Use loopback to prevent other machines to answer.
            //
            if (communicator.GetProperty("Ice.IPv6") == "1")
            {
                endpoint.Append("udp -h \"ff15::1:1\"");
                if (AssemblyUtil.IsWindows || AssemblyUtil.IsMacOS)
                {
                    endpoint.Append(" --interface \"::1\"");
                }
            }
            else
            {
                endpoint.Append("udp -h 239.255.1.1");
                if (AssemblyUtil.IsWindows || AssemblyUtil.IsMacOS)
                {
                    endpoint.Append(" --interface 127.0.0.1");
                }
            }
            endpoint.Append(" -p ");
            endpoint.Append(GetTestPort(properties, 10));
            communicator.SetProperty("McastTestAdapter.Endpoints", endpoint.ToString());
            ObjectAdapter mcastAdapter = communicator.CreateObjectAdapter("McastTestAdapter");

            mcastAdapter.Add("test", new TestIntf());
            await mcastAdapter.ActivateAsync();

            await communicator.WaitForShutdownAsync();
        }
Beispiel #57
0
 LocatorRegistry(Communicator com) =>
Beispiel #58
0
        public void StartServer(Current current)
        {
            foreach (Communicator?c in _communicators)
            {
                c.WaitForShutdownAsync();
                c.Dispose();
            }
            _communicators.Clear();

            //
            // Simulate a server: create a new communicator and object
            // adapter. The object adapter is started on a system allocated
            // port. The configuration used here contains the Ice.Locator
            // configuration variable. The new object adapter will register
            // its endpoints with the locator and create references containing
            // the adapter id instead of the endpoints.
            //
            Dictionary <string, string> properties = _helper.Communicator() !.GetProperties();

            properties["TestAdapter.AdapterId"]      = "TestAdapter";
            properties["TestAdapter.ReplicaGroupId"] = "ReplicatedAdapter";
            properties["TestAdapter2.AdapterId"]     = "TestAdapter2";

            Communicator serverCommunicator = _helper.Initialize(properties);

            _communicators.Add(serverCommunicator);

            //
            // Use fixed port to ensure that OA re-activation doesn't re-use previous port from
            // another OA(e.g.: TestAdapter2 is re-activated using port of TestAdapter).
            //
            int nRetry = 10;

            while (--nRetry > 0)
            {
                ObjectAdapter?adapter  = null;
                ObjectAdapter?adapter2 = null;
                try
                {
                    serverCommunicator.SetProperty("TestAdapter.Endpoints", _helper.GetTestEndpoint(_nextPort++));
                    serverCommunicator.SetProperty("TestAdapter2.Endpoints", _helper.GetTestEndpoint(_nextPort++));

                    adapter  = serverCommunicator.CreateObjectAdapter("TestAdapter");
                    adapter2 = serverCommunicator.CreateObjectAdapter("TestAdapter2");

                    var locator = ILocatorPrx.Parse(_helper.GetTestProxy("locator", 0), serverCommunicator);
                    adapter.Locator  = locator;
                    adapter2.Locator = locator;

                    var testI = new TestIntf(adapter, adapter2, _registry);
                    _registry.AddObject(adapter.Add("test", testI, IObjectPrx.Factory));
                    _registry.AddObject(adapter.Add("test2", testI, IObjectPrx.Factory));
                    adapter.Add("test3", testI);

                    adapter.Activate();
                    adapter2.Activate();
                    break;
                }
                catch (TransportException)
                {
                    if (nRetry == 0)
                    {
                        throw;
                    }

                    // Retry, if OA creation fails with EADDRINUSE(this can occur when running with JS web
                    // browser clients if the driver uses ports in the same range as this test, ICE-8148)
                    if (adapter != null)
                    {
                        adapter.Dispose();
                    }
                    if (adapter2 != null)
                    {
                        adapter2.Dispose();
                    }
                }
            }
        }
 /// <summary>
 /// Deletes the room link information asynchronously.
 /// </summary>
 /// <param name="callback">The callback action.</param>
 /// <param name="roomId">The chat room id.</param>
 public async void DeleteRoomLinkAsync(Action <ResponseData <DataType> > callback, long roomId)
 {
     var path = string.Format(CultureInfo.InvariantCulture, Path.RoomLink, roomId);
     await Communicator.CreateDeleteTask(callback, path)
     .ConfigureAwait(false);
 }
Beispiel #60
0
 public Controller(Communicator communicator)
 {
     _adapter = communicator.CreateObjectAdapter("TestAdapter", serializeDispatch: true);
     _adapter.Add("timeout", new Timeout());
     _adapter.Activate();
 }