Esempio n. 1
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. 2
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);
            }
        }