예제 #1
0
        //----< test TestRequest serialization and deserialization >-----

        static private void testTestRequest()
        {
            // Serialize and Deserialize TestRequest data structure
            "Testing Serialization of TestRequest data structure".title();
            TestElement te1 = new TestElement();

            te1.testName = "test1";
            te1.addDriver("td1.dll");
            te1.addCode("tc1.dll");
            te1.addCode("tc2.dll");
            TestElement te2 = new TestElement();

            te2.testName = "test2";
            te2.addDriver("td2.dll");
            te2.addCode("tc3.dll");
            te2.addCode("tc4.dll");
            TestRequest tr = new TestRequest();

            tr.author = "Jim Fawcett";
            tr.tests.Add(te1);
            tr.tests.Add(te2);
            string trXml = tr.ToXml();

            Console.Write("\n  Serialized TestRequest data structure:\n\n  {0}\n", trXml);

            "Testing Deserialization of TestRequest from XML".title();
            TestRequest newRequest = trXml.FromXml <TestRequest>();
            string      typeName   = newRequest.GetType().Name;

            Console.Write("\n  deserializing xml string results in type: {0}\n", typeName);
            Console.Write(newRequest);
            Console.WriteLine();

            // Create and Parse TestRequest message
            "Testing Creation and Parsing of TestRequest Message".title();
            Message msg = new Message();

            msg.to     = "TH";
            msg.from   = "CL";
            msg.type   = "basic";
            msg.author = "Fawcett";
            Console.Write("\n  base message:\n    {0}", msg.ToString());
            msg.show();

            Console.Write("\n  Creating Message using TestRequest data structure\n");
            Message rqstMsg = new Message();

            rqstMsg.author = "Fawcett";
            rqstMsg.to     = "localhost:8080";
            rqstMsg.from   = "localhost:8091";
            rqstMsg.type   = "TestRequest";
            rqstMsg.time   = DateTime.Now;
            rqstMsg.body   = tr.ToXml();
            rqstMsg.show();
            Console.Write("\n  retrieving testRequest object:");
            TestRequest newTrq = rqstMsg.body.FromXml <TestRequest>();

            Console.Write("\n{0}\n", newTrq);
        }
        /*----< dequeue a test request, wait for a ready child to process >----*/

        void threadProc2()
        {
            while (true)
            {
                TestRequest request = requestQ_.deQ();
                try
                {
                    int i = readyQ_.deQ();
                    Console.Write("\n  Polled from request queue and send to child {0}", i);
                    Msg childMsg = new Msg(Msg.MessageType.request);
                    childMsg.to       = childs_[i].address;
                    childMsg.from     = "http://localhost:8080/IPluggableComm";
                    childMsg.argument = request.ToXml();
                    childMsg.command  = Msg.Command.testRequest;

                    try
                    {
                        createCommIfNeeded();
                        comm_.postMessage(childMsg);
                    }
                    catch
                    {
                        Console.Write("\n  Error: can't connect");
                    }

                    childs_[i].setBusy();
                }
                catch
                {
                    Console.Write("\n  Error: child builder doesn't exist");
                }
            }
        }
예제 #3
0
        /*----< reset build request content to default >----------------*/

        private void btnResetRequest_Click(object sender, RoutedEventArgs e)
        {
            tr        = new TestRequest();
            tr.author = "Kaiqi Zhang";

            requestTextBox.Text = tr.ToXml();
        }
예제 #4
0
        /*----< add a new test to the build request structure >-------*/

        private void btnAddToRequest_Click(object sender, RoutedEventArgs e)
        {
            if (tr == null)
            {
                tr        = new TestRequest();
                tr.author = "Kaiqi Zhang";
            }

            TestElement te = new TestElement();

            te.buildTool = "MSBuild";

            // build config xml
            string configFile = "";

            foreach (var item in fileListBox.SelectedItems)
            {
                string fileName = (string)item;
                if (System.IO.Path.GetExtension(fileName) == ".csproj")
                {
                    configFile = fileName;
                }
            }
            if (configFile == "")
            {
                MessageBox.Show("Please select one BuildConfig file (*.csproj).", "Add to Request",
                                MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            te.buildConfig = configFile;
            te.testName    = System.IO.Path.GetFileNameWithoutExtension(configFile);

            // cs files
            foreach (var item in fileListBox.SelectedItems)
            {
                string fileName = (string)item;
                if (System.IO.Path.GetExtension(fileName) == ".cs")
                {
                    te.addCode(fileName);
                }
            }

            tr.tests.Add(te);

            requestTextBox.Text = tr.ToXml();
        }
예제 #5
0
        /*----< send test requests to TestHarness >-----------------------*/

        private void sendRequestToTH(TestRequest tr, Msg msg)
        {
            Msg trMsg = new Msg(Msg.MessageType.request);

            trMsg.to       = "http://localhost:8083/IPluggableComm";
            trMsg.from     = msg.to;
            trMsg.argument = tr.ToXml();
            trMsg.command  = Msg.Command.testRequest;

            try
            {
                createCommIfNeeded();
                comm_.postMessage(trMsg);
            }
            catch
            {
                Console.Write("\n  Error: can't connect");
            }
        }