Esempio n. 1
0
        void TC00136_dowork(bool request, bool response)
        {
            //Configuration c = CommonUtils.GetMappedConfig();
            Thread.Sleep(10000);
            string urlmod = MessageProcessor.ModifyURL(ConfigurationManager.AppSettings["HelloWorldASPNET2"], false);

            //c.AppSettings.Settings["HelloWorldASPNET2"].Value, true);
            try
            {
                CommonUtils.BounceIIS();
                CommonUtils.RemoveService(urlmod);
                Thread.Sleep(5000);
                CommonUtils.SetPolicy(urlmod, request, response);
                HelloWorldASPNET2.Service2 svc = new HelloWorldASPNET2.Service2();
                MessageProcessor           mp  = MessageProcessor.Instance;
                MessageProcessor.PurgeOutboundQueue();
                MessageProcessor.PurgePolicyCache();

                svc.Url = ConfigurationManager.AppSettings["HelloWorldASPNET2"];
                //c.AppSettings.Settings["HelloWorldASPNET2"].Value;
                string   s       = svc.HelloWorld("test");
                DateTime timeout = DateTime.Now.AddMinutes(2);

                Console.Out.WriteLine("message sent queue size" + MessageProcessor.GetQueueSize());
                while (MessageProcessor.GetQueueSize() > 0 && DateTime.Now < timeout)
                {
                    Thread.Sleep(1000);
                }
                Thread.Sleep(15000);
                svc.Dispose();
            }
            catch (Exception ex)
            {
                string _err = "";
                while (ex != null)
                {
                    _err += ex.Message + " " + ex.StackTrace;
                    ex    = ex.InnerException;
                }
                CommonUtils.RemoveService(urlmod);
                Assert.Fail(_err);
            }
            TransactionalWebServicePolicy tp = MessageProcessor.GetPolicyIfAvailable(urlmod, true);

            Assert.IsNotNull(tp);
            Assert.IsTrue(String.IsNullOrEmpty(MessageProcessor.LastErrorMessage));
            string s2 = CommonUtils.VerifyLastMessagePayloadsTwoAgentsOneTransaction(urlmod);

            CommonUtils.RemoveService(urlmod);
            if (!String.IsNullOrEmpty(s2))
            {
                Assert.Fail(s2);
            }
        }
Esempio n. 2
0
        /*  [Test]
         * public void TC00134_1_ChainingThinClientToWCFServiceToWCFService()
         * {
         *    TC00035_doWork("http://localhost/HelloWorldESMTester/callWithMonitor.aspx", true, true, 2);
         *    //there should be exactly two transactions recorded, since this service is monitored via web.config settings
         * }*/
        //Failed	TC00035_3_ThinClientNoPayloadsWithClientMonitorAndServiceMonitor	FGSMS.NETTestSuite

        /*  Assert.Fail failed. the transaction 05604057-bff9-4907-8527-f9c6b68fc4dc did not have a related transaction id,
         *    this means that an http header was not propagated agent org.miloss.fgsms.agent.wcf.AgentWCFClientMessageInspector.client
         * Agent Outbound queue: 0 Outbound Threads 1 Thread FGSMS DataPusher from thread 13 mem stat 324771840/4294434816
         */
        void TC00035_doWork(string url, bool recordrequest, bool recordresponse, int expectedcount)
        {
            Thread.Sleep(10000);
            string st = "";

            try
            {
                CommonUtils.RemoveService(url3mod);
                CommonUtils.SetPolicy(url3mod, recordrequest, recordresponse);

                WebClient cw = new WebClient();
                st = cw.DownloadString(url);
                Thread.Sleep(15000);
                DateTime timeout = DateTime.Now.AddMinutes(1);
                Console.Out.WriteLine("message sent queue size" + MessageProcessor.GetQueueSize());
            }
            catch (Exception ex)
            {
                CommonUtils.RemoveService(url3mod);
                string s = ""; while (ex != null)
                {
                    s += ex.Message + ex.StackTrace;
                    ex = ex.InnerException;
                }
                Assert.Fail(s);
            }
            string err = CommonUtils.VerifyLastMessagePayloads(url3mod, recordrequest, recordresponse, expectedcount);

            if (expectedcount == 2)
            {
                err += err = CommonUtils.VerifyLastMessagePayloadsTwoAgentsOneTransaction(url3mod);
            }
            if (st.Contains("ERROR"))
            {
                err += st;
            }
            CommonUtils.RemoveService(url3mod);
            if (!String.IsNullOrEmpty(err))
            {
                Assert.Fail(err);
            }
        }
Esempio n. 3
0
        void TC00140_dowork(bool request, bool response)
        {
            Thread.Sleep(10000);
            MessageProcessor mp     = MessageProcessor.Instance;
            string           urlmod = WCFtTests.url;

            try
            {
                CommonUtils.RemoveService(urlmod);
                Thread.Sleep(5000);
                CommonUtils.SetPolicy(urlmod, request, response);
                aspnet.client.towcf.FGSMSNetServiceImpl svc = new aspnet.client.towcf.FGSMSNetServiceImpl();
                svc.Url = urlmod;


                MessageProcessor.PurgeOutboundQueue();
                MessageProcessor.PurgePolicyCache();

                ServiceHost host = new ServiceHost(typeof(FGSMSNetServiceImpl));
                host.Description.Behaviors.Remove(typeof(org.miloss.fgsms.agent.wcf.AgentWCFServiceBehavior));
                host.Description.Behaviors.Add(new org.miloss.fgsms.agent.wcf.AgentWCFServiceBehavior());
                host.Open();


                svc.Url = urlmod;
                aspnet.client.towcf.SomeComplexRequestObject x = new aspnet.client.towcf.SomeComplexRequestObject();
                x.stderr = "hi";
                x.stdout = "hi";
                svc.getData(x);
                DateTime timeout = DateTime.Now.AddMinutes(2);

                Console.Out.WriteLine("message sent queue size" + MessageProcessor.GetQueueSize());
                while (DateTime.Now < timeout && MessageProcessor.GetQueueSize() != 0)
                {
                    Thread.Sleep(1000);
                }
                host.Close();
                svc.Dispose();
                Thread.Sleep(1000);
            }
            catch (Exception ex)
            {
                string _err = "";
                while (ex != null)
                {
                    _err += ex.Message + " " + ex.StackTrace;
                    ex    = ex.InnerException;
                }
                CommonUtils.RemoveService(urlmod);
                Assert.Fail(_err);
            }
            TransactionalWebServicePolicy tp = MessageProcessor.GetPolicyIfAvailable(urlmod, true);

            Assert.IsNotNull(tp);
            Assert.IsTrue(String.IsNullOrEmpty(MessageProcessor.LastErrorMessage));
            string s2 = CommonUtils.VerifyLastMessagePayloadsTwoAgentsOneTransaction(urlmod);

            CommonUtils.RemoveService(urlmod);
            if (!String.IsNullOrEmpty(s2))
            {
                Assert.Fail(s2);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// monitored self hosted service and client handler added programmatically
        /// </summary>
        /// <param name="recordrequest"></param>
        /// <param name="recordresponse"></param>
        void TC00139_doWork(bool recordrequest, bool recordresponse)
        {
            Thread.Sleep(10000);
            CommonUtils.RemoveService(url_mod);
            CommonUtils.SetPolicy(url_mod, recordrequest, recordresponse);

            try
            {
                MessageProcessor mp = MessageProcessor.Instance;
                MessageProcessor.PurgePolicyCache();
                MessageProcessor.PurgeOutboundQueue();
                Assert.IsTrue(MessageProcessor.GetPolicyCacheSize() == 0);
                Assert.IsTrue(MessageProcessor.GetQueueSize() == 0);
                ServiceHost host = new ServiceHost(typeof(FGSMSNetServiceImpl));
                host.Description.Behaviors.Remove(typeof(org.miloss.fgsms.agent.wcf.AgentWCFServiceBehavior));
                host.Description.Behaviors.Add(new org.miloss.fgsms.agent.wcf.AgentWCFServiceBehavior());
                host.Open();
                IFGSMSNetService         svc = getproxyWithMonitor(url_mod);
                SomeComplexRequestObject req = new SomeComplexRequestObject();
                req.stdout = "hi";

                svc.getData(req);

                Thread.Sleep(5000);
                DateTime timeout = DateTime.Now.AddMinutes(2);
                Console.Out.WriteLine("message sent queue size" + MessageProcessor.GetQueueSize());
                while (MessageProcessor.GetQueueSize() > 0 && DateTime.Now < timeout)
                {
                    Thread.Sleep(1000);
                }
                ((IClientChannel)svc).Close();
                ((IClientChannel)svc).Dispose();
                host.Close();
            }
            catch (Exception ex)
            {
                string _err = "";
                while (ex != null)
                {
                    _err += ex.Message + " " + ex.StackTrace;
                    ex    = ex.InnerException;
                }
                CommonUtils.RemoveService(url_mod);
                Assert.Fail(_err);
            }

            Thread.Sleep(10000);
            string err = "";

            if (MessageProcessor.GetPolicyCacheSize() == 0)
            {
                err += "policy cache is empty, it should have at least one item in it";
            }
            if (!String.IsNullOrEmpty(MessageProcessor.LastErrorMessage))
            {
                err += "agent error " + MessageProcessor.LastErrorMessage;
            }

            TransactionalWebServicePolicy tp = MessageProcessor.GetPolicyIfAvailable(url_mod, true);

            if (tp == null)
            {
                err += "the policy for the service was not cached, which means something went wrong";
            }
            err += CommonUtils.VerifyLastMessagePayloads(url_mod, recordrequest, recordresponse, 2);
            err += CommonUtils.VerifyLastMessagePayloadsTwoAgentsOneTransaction(url_mod);
            CommonUtils.RemoveService(url_mod);
            if (!String.IsNullOrEmpty(err))
            {
                Assert.Fail(err);
            }
        }