Ejemplo n.º 1
0
        public void ServerProxy_FallbackOnConnect()
        {
            //------------Setup for test--------------------------
            var           serverProxy = new ServerProxy(new Uri("http://bob"));
            var           serverGuid  = Guid.NewGuid();
            PrivateObject p           = new PrivateObject(serverProxy);
            var           wrapped     = new Mock <IEnvironmentConnection>();

            wrapped.Setup(a => a.DisplayName).Returns("moo");
            wrapped.Setup(a => a.Connect(It.IsAny <Guid>())).Throws(new FallbackException());
            wrapped.Setup(a => a.WebServerUri).Returns(new Uri("http://bob"));
            p.SetField("_wrappedConnection", wrapped.Object);

            try
            {
                serverProxy.Connect(serverGuid);
            }
            // ReSharper disable EmptyGeneralCatchClause
            catch (Exception err)
            {
                Assert.IsNotNull(err);
            }
            var con = p.GetField("_wrappedConnection") as IEnvironmentConnection;

            Assert.IsNotNull(con);
            Assert.AreNotEqual(con, wrapped.Object);
            Assert.AreEqual("moo", con.DisplayName);
        }
Ejemplo n.º 2
0
        public static string ExecuteServiceOnLocalhostUsingProxy(string serviceName, Dictionary <string, string> payloadArguments)
        {
            CommunicationControllerFactory fact = new CommunicationControllerFactory();
            var comm = fact.CreateController(serviceName);
            var prx  = new ServerProxy("http://localhost:3142", CredentialCache.DefaultNetworkCredentials, AsyncWorkerTests.CreateSynchronousAsyncWorker().Object);

            prx.Connect(Guid.NewGuid());
            foreach (var payloadArgument in payloadArguments)
            {
                comm.AddPayloadArgument(payloadArgument.Key, payloadArgument.Value);
            }
            if (comm != null)
            {
                var messageToExecute = comm.ExecuteCommand <ExecuteMessage>(prx, Guid.Empty);
                if (messageToExecute != null)
                {
                    var responseMessage = messageToExecute.Message;
                    if (responseMessage != null)
                    {
                        var actual = responseMessage.ToString();
                        return(actual);
                    }
                    return("Error: response message empty!");
                }
                return("Error: message to send to localhost server could not be generated.");
            }
            return("Error: localhost server controller could not be created.");
        }
Ejemplo n.º 3
0
        public void ServerProxy_NoFallbackOnConnectIfNormalException()
        {
            //------------Setup for test--------------------------
            var           serverProxy = new ServerProxy(new Uri("http://bob"));
            var           serverGuid  = Guid.NewGuid();
            PrivateObject p           = new PrivateObject(serverProxy);
            var           wrapped     = new Mock <IEnvironmentConnection>();
            var           fallback    = new Mock <IEnvironmentConnection>();

            wrapped.Setup(a => a.Connect(It.IsAny <Guid>())).Throws(new Exception());
            p.SetField("_wrappedConnection", wrapped.Object);

            try
            {
                serverProxy.Connect(serverGuid);
            }
            // ReSharper disable EmptyGeneralCatchClause
            catch
            // ReSharper restore EmptyGeneralCatchClause
            {
            }
            var con = p.GetField("_wrappedConnection");

            Assert.IsNotNull(con);
        }
Ejemplo n.º 4
0
            public int Run()
            {
                if (_options.ShowConsole)
                {
                    _ = new ConsoleWindow();
                }
                var serverEndpoint        = _options.ServerEndpoint;
                var environmentConnection = new ServerProxy(serverEndpoint);

                Console.Write("connecting to server: " + serverEndpoint + "...");
                environmentConnection.Connect(Guid.Empty);
                Console.WriteLine("done.");
                var resourceCatalogProxy = new ResourceCatalogProxy(environmentConnection);

                var config = new WorkerContext(_options, resourceCatalogProxy, TriggersCatalog.Instance);

                using (var watcher = new FileSystemWatcherWrapper())
                {
                    config.WatchTriggerResource(watcher);
                    watcher.Created += (o, t) => Environment.Exit(1);
                    watcher.Changed += (o, t) => Environment.Exit(0);
                    watcher.Deleted += (o, t) => Environment.Exit(0);
                    watcher.Renamed += (o, t) => Environment.Exit(0);

                    new QueueWorkerImplementation(config).Run();
                }

                return(0);
            }
Ejemplo n.º 5
0
        public void ServerProxy_HandleItemAdded()
        {
            //------------Setup for test--------------------------
            var serverProxy = new ServerProxy(new Uri("http://bob"));
            var serverGuid  = Guid.NewGuid();
            var ItemGuid    = Guid.Empty;

            try
            {
                serverProxy.Connect(serverGuid);
            }
            // ReSharper disable EmptyGeneralCatchClause
            catch
            // ReSharper restore EmptyGeneralCatchClause
            {
            }
            //------------Execute Test---------------------------
            ServerExplorerItem item = new ServerExplorerItem("bob", Guid.Empty, ResourceType.DbService, null, Permissions.Administrator, "bob");

            serverProxy.ItemAddedMessageAction += explorerItem => { ItemGuid = explorerItem.ServerId; };
            Dev2JsonSerializer dev = new Dev2JsonSerializer();
            var           output   = dev.SerializeToBuilder(item);
            PrivateObject p        = new PrivateObject(serverProxy);

            p.Invoke("OnItemAddedMessageReceived", new object[] { output.ToString() });
            Assert.AreEqual(ItemGuid, serverGuid);
            //------------Assert Results-------------------------
            var subscription = serverProxy.EsbProxy.Subscribe("SendDebugState");

            Assert.IsNotNull(subscription);
        }
Ejemplo n.º 6
0
        public void DeleteWorkflowSuccessCantCallDeletedWorkflow()
        {
            //---------Setup-------------------------------
            IEnvironmentConnection connection = new ServerProxy(new Uri(_webserverUri));

            connection.Connect(Guid.Empty);
            const string ServiceName  = "DeleteWorkflowTest3";
            const string ResourceType = "WorkflowService";
            //----------Execute-----------------------------

            var coms = new CommunicationController {
                ServiceName = "DeleteResourceService"
            };

            coms.AddPayloadArgument("ResourceName", ServiceName);
            coms.AddPayloadArgument("ResourceType", ResourceType);

            var result = coms.ExecuteCommand <ExecuteMessage>(connection, Guid.Empty);

            //---------Call Workflow Failure-------
// ReSharper disable InconsistentNaming
            const string serviceName = "DeleteWorkflowTest3";
// ReSharper restore InconsistentNaming
            var servicecall = String.Format("{0}{1}", ServerSettings.WebserverURI, serviceName);
            var result2     = TestHelper.PostDataToWebserver(servicecall);

            Assert.IsTrue(result2.Contains("Service [ DeleteWorkflowTest3 ] not found."), "Got [ " + result + " ]");
        }
Ejemplo n.º 7
0
        public void DeleteWorkflowSuccessCantDeleteDeletedWorkflow()
        {
            //---------Setup-------------------------------
            IEnvironmentConnection connection = new ServerProxy(new Uri(_webserverUri));

            connection.Connect(Guid.Empty);
            const string ServiceName  = "DeleteWorkflowTest2";
            const string ResourceType = "WorkflowService";
            //----------Execute-----------------------------

            var coms = new CommunicationController {
                ServiceName = "DeleteResourceService"
            };

            coms.AddPayloadArgument("ResourceName", ServiceName);
            coms.AddPayloadArgument("ResourceType", ResourceType);
            coms.AddPayloadArgument("ResourceID", "f2b78836-91dd-44f0-a43f-b3ecf4c53cd5");

            // Execute
            var result = coms.ExecuteCommand <ExecuteMessage>(connection, Guid.Empty);

            // Assert
            Assert.IsTrue(result.Message.Contains("Success"), "Got [ " + result.Message + " ]");

            result = coms.ExecuteCommand <ExecuteMessage>(connection, Guid.Empty);
            StringAssert.Contains(result.Message.ToString(), "WorkflowService 'f2b78836-91dd-44f0-a43f-b3ecf4c53cd5' was not found.");
        }
        public void ServerProxy_NoFallbackOnConnectIfNormalException()
        {
            //------------Setup for test--------------------------
            var serverProxy = new ServerProxy(new Uri("http://bob"));
            var serverGuid  = Guid.NewGuid();
            var p           = new Warewolf.Testing.PrivateObject(serverProxy);
            var wrapped     = new Mock <IEnvironmentConnection>();
            var fallback    = new Mock <IEnvironmentConnection>();

            wrapped.Setup(a => a.Connect(It.IsAny <Guid>())).Throws(new Exception());
            p.SetField("_wrappedConnection", wrapped.Object);

            try
            {
                serverProxy.Connect(serverGuid);
            }

            catch

            {
                // ignored
            }

            var con = p.GetField("_wrappedConnection");

            Assert.IsNotNull(con);
        }
Ejemplo n.º 9
0
        private static void Main(string[] args)
        {
            string        uri                   = "http://*****:*****@"C:\temp\networkSpeedTo{0}.csv", uri.Replace(':', '-').Replace('/', '_'));

            // header
            timings.Add(string.Format("URI:, '{0}'", uri));
            timings.Add(string.Format("Max message size:, {0}, Initial block size:, {1}, Incrementing factor:, {2}, Rounds per packet size:, {3}", maxMessageSize, numberOfGuidsPerChunk, incrementingFactor, roundsPerPacketStep));

            using (var serverProxy = new ServerProxy(new Uri(uri)))
            {
                serverProxy.Connect(Guid.NewGuid());
                CommunicationControllerFactory cf = new CommunicationControllerFactory();
                while (sb.Length < maxMessageSize)
                {
                    timingsPerRound.Clear();
                    for (int i = 0; i < roundsPerPacketStep; i++)
                    {
                        var controller = cf.CreateController("TestNetworkService");
                        controller.AddPayloadArgument("payload", sb);
                        DateTime start = DateTime.Now;
                        // send very large message
                        var svc = controller.ExecuteCommand <ExecuteMessage>(serverProxy, Guid.NewGuid());

                        TimeSpan elapsed = DateTime.Now - start;
                        timingsPerRound.Add(elapsed.TotalMilliseconds);

                        // give the server time to clear it's queue
                        Thread.Sleep((int)Math.Round(elapsed.TotalMilliseconds) * 2);
                    }
                    string toAdd = string.Format("{0}, {1}", sb.Length, timingsPerRound.Sum() / roundsPerPacketStep);
                    Console.WriteLine(toAdd);
                    timings.Add(toAdd);
                    // build new packet that is incrementingFactor bigger than previous
                    StringBuilder tmpSb = new StringBuilder();
                    tmpSb.Append(sb);
                    Enumerable.Range(1, (int)Math.Ceiling(incrementingFactor)).ToList().ForEach(x =>
                                                                                                tmpSb.Append(tmpSb.ToString()));
                    sb.Append(tmpSb.ToString().Substring(0,
                                                         (int)((tmpSb.Length - sb.Length) * (incrementingFactor - 1))));
                }
            }
            File.WriteAllLines(outFileName, timings.ToArray());
            //Console.ReadKey();
        }
Ejemplo n.º 10
0
        protected override void Configure()
        {
            CustomContainer.Register <IWindowManager>(new WindowManager());
            CustomContainer.Register <IPopupController>(new PopupController());
            _mainViewModel = new ShellViewModel();
            CustomContainer.Register <IShellViewModel>(_mainViewModel);
            CustomContainer.Register <IShellViewModel>(_mainViewModel);
            CustomContainer.Register <IWindowsServiceManager>(new WindowsServiceManager());
            var conn = new ServerProxy("http://localHost:3142", CredentialCache.DefaultNetworkCredentials, new AsyncWorker());

            conn.Connect(Guid.NewGuid());
            CustomContainer.Register <Microsoft.Practices.Prism.PubSubEvents.IEventAggregator>(new Microsoft.Practices.Prism.PubSubEvents.EventAggregator());

            ClassRoutedEventHandlers.RegisterEvents();
        }
Ejemplo n.º 11
0
        private void btnConnect_Click(object sender, EventArgs e)
        {
            try
            {
                // Connect to the game server
                if (rconServerProxy.Connect(serverConnectionInfo))
                {
                    EnableLoginControls(true);
                    GetServerInformation();
                    ListPlayers();
                }

                LoadContextMenuItems();
            } catch (Exception ex)
            {
                MessageBox.Show("Unexpected error occurred trying to connect! Exception: " + ex.Message +
                                "\r\nPlease report this error to the adminstrator.");
            }
        }
Ejemplo n.º 12
0
        public void DeleteWorkflowExpectsSuccessResponse()
        {
            //---------Setup-------------------------------
            IEnvironmentConnection connection = new ServerProxy(new Uri(_webserverUri));

            connection.Connect(Guid.Empty);
            const string ServiceName  = "DeleteWorkflowTest";
            const string ResourceType = "WorkflowService";
            //----------Execute-----------------------------

            var coms = new CommunicationController {
                ServiceName = "DeleteResourceService"
            };

            coms.AddPayloadArgument("ResourceName", ServiceName);
            coms.AddPayloadArgument("ResourceType", ResourceType);
            coms.AddPayloadArgument("ResourceID", "c25610b9-b28a-49f0-9074-d743ea729c6a");
            var result = coms.ExecuteCommand <ExecuteMessage>(connection, Guid.Empty);

            Assert.IsTrue(result.Message.Contains("Success"), "Got [ " + result.Message + " ]");
        }