Beispiel #1
0
        public void StreamToXMLPartialConstructorTest()
        {
            string            projectName   = "test project";
            IntegrationStatus buildStatus   = IntegrationStatus.Exception;
            DateTime          lastBuildDate = DateTime.Now;
            ProjectStatus     projectStatus = new ProjectStatus(projectName, buildStatus, lastBuildDate);

            XmlSerializer           serializer = new XmlSerializer(typeof(ProjectStatus));
            TextWriter              writer     = new StringWriter();
            XmlSerializerNamespaces nmsp       = new XmlSerializerNamespaces();

            nmsp.Add("", "");

            serializer.Serialize(writer, projectStatus, nmsp);

            Assert.AreEqual("<?xml version=\"1.0\" encoding=\"utf-16\"?>" + Environment.NewLine +
                            "<projectStatus " +
                            "showForceBuildButton=\"true\" " +
                            "showStartStopButton=\"true\" " +
                            "serverName=\"" + Environment.MachineName + "\" " +
                            "status=\"Running\" " +
                            "buildStatus=\"" + buildStatus.ToString() + "\" " +
                            "name=\"" + projectName + "\" " +
                            "queuePriority=\"0\" " +
                            "lastBuildDate=\"" + lastBuildDate.ToString("yyyy-MM-ddTHH:mm:ss.FFFFFFF") + "\" " +
                            "nextBuildTime=\"0001-01-01T00:00:00\"" +
                            ">" + Environment.NewLine +
                            "  <activity type=\"Sleeping\" />" + Environment.NewLine +
                            "  <parameters />" + Environment.NewLine +
                            "</projectStatus>",
                            writer.ToString());
        }
Beispiel #2
0
        public void StreamToXMLFullConstructorTest()
        {
            string                 projectName              = "full test";
            string                 category                 = "categ1";
            ProjectActivity        activity                 = ProjectActivity.Building;
            IntegrationStatus      buildStatus              = IntegrationStatus.Failure;
            ProjectIntegratorState status                   = ProjectIntegratorState.Stopped;
            string                 webURL                   = "someurl";
            DateTime               lastBuildDate            = DateTime.Now;
            string                 lastBuildLabel           = "lastLabel";
            string                 lastSuccessfulBuildLabel = "lastSuccess";
            DateTime               nextBuildTime            = DateTime.Now.AddDays(2);
            string                 buildStage               = "some stage";
            string                 queue    = "someQueue";
            int queuePriority               = 25;
            List <ParameterBase> parameters = new List <ParameterBase>();

            ProjectStatus projectStatus = new ProjectStatus(projectName, category, activity, buildStatus,
                                                            status, webURL, lastBuildDate, lastBuildLabel,
                                                            lastSuccessfulBuildLabel, nextBuildTime, buildStage,
                                                            queue, queuePriority, parameters);

            XmlSerializer           serializer = new XmlSerializer(typeof(ProjectStatus));
            TextWriter              writer     = new StringWriter();
            XmlSerializerNamespaces nmsp       = new XmlSerializerNamespaces();

            nmsp.Add("", "");

            serializer.Serialize(writer, projectStatus, nmsp);

            Assert.AreEqual("<?xml version=\"1.0\" encoding=\"utf-16\"?>" + Environment.NewLine +
                            "<projectStatus " +
                            "stage=\"" + buildStage + "\" " +
                            "showForceBuildButton=\"true\" " +
                            "showStartStopButton=\"true\" " +
                            "serverName=\"" + Environment.MachineName + "\" " +
                            "status=\"" + status.ToString() + "\" " +
                            "buildStatus=\"" + buildStatus.ToString() + "\" " +
                            "name=\"" + projectName + "\" " +
                            "category=\"" + category + "\" " +
                            "queueName=\"" + queue + "\" " +
                            "queuePriority=\"" + queuePriority.ToString() + "\" " +
                            "url=\"" + webURL + "\" " +
                            "lastBuildDate=\"" + lastBuildDate.ToString("yyyy-MM-ddTHH:mm:ss.FFFFFFF") + "\" " +
                            "lastBuildLabel=\"" + lastBuildLabel + "\" " +
                            "lastSuccessfulBuildLabel=\"" + lastSuccessfulBuildLabel + "\" " +
                            "nextBuildTime=\"" + nextBuildTime.ToString("yyyy-MM-ddTHH:mm:ss.FFFFFFF") + "\"" +
                            ">" + Environment.NewLine +
                            "  <activity type=\"" + activity.ToString() + "\" />" + Environment.NewLine +
                            "  <parameters />" + Environment.NewLine +
                            "</projectStatus>",
                            writer.ToString());
        }
Beispiel #3
0
        public void StreamToXMLFullConstructorWithParametersTest()
        {
            string                 projectName              = "full test";
            string                 category                 = "categ1";
            ProjectActivity        activity                 = ProjectActivity.Building;
            IntegrationStatus      buildStatus              = IntegrationStatus.Failure;
            ProjectIntegratorState status                   = ProjectIntegratorState.Stopped;
            string                 webURL                   = "someurl";
            DateTime               lastBuildDate            = DateTime.Now;
            string                 lastBuildLabel           = "lastLabel";
            string                 lastSuccessfulBuildLabel = "lastSuccess";
            DateTime               nextBuildTime            = DateTime.Now.AddDays(2);
            string                 buildStage               = "some stage";
            string                 queue    = "someQueue";
            int queuePriority               = 25;
            List <ParameterBase> parameters = new List <ParameterBase> {
                new TextParameter("textParam"), new BooleanParameter("boolParam")
            };

            ProjectStatus projectStatus = new ProjectStatus(projectName, category, activity, buildStatus,
                                                            status, webURL, lastBuildDate, lastBuildLabel,
                                                            lastSuccessfulBuildLabel, nextBuildTime, buildStage,
                                                            queue, queuePriority, parameters);

            string streamedParameters = String.Empty;

            foreach (ParameterBase parameter in parameters)
            {
                XmlSerializerNamespaces parameternmsp = new XmlSerializerNamespaces();
                parameternmsp.Add("", "");

                XmlSerializer parameterSerializer = new XmlSerializer(parameter.GetType());
                TextWriter    parameterWriter     = new StringWriter();

                XmlWriterSettings writerSettings = new XmlWriterSettings();
                writerSettings.OmitXmlDeclaration = true;
                using (XmlWriter xmlWriter = XmlWriter.Create(parameterWriter, writerSettings))
                {
                    parameterSerializer.Serialize(xmlWriter, parameter, parameternmsp);
                }
                string streamedParameter = parameterWriter.ToString();
                streamedParameter   = Regex.Replace(streamedParameter, parameter.GetType().Name, "parameter d3p1:type=\"" + parameter.GetType().Name + "\"", RegexOptions.IgnoreCase);
                streamedParameter   = Regex.Replace(streamedParameter, "/>", "xmlns:d3p1=\"http://www.w3.org/2001/XMLSchema-instance\" />", RegexOptions.IgnoreCase);
                streamedParameters += "    " + streamedParameter + "" + Environment.NewLine;
            }

            XmlSerializerNamespaces nmsp = new XmlSerializerNamespaces();

            nmsp.Add("", "");

            XmlSerializer serializer = new XmlSerializer(typeof(ProjectStatus));
            TextWriter    writer     = new StringWriter();

            serializer.Serialize(writer, projectStatus, nmsp);

            Assert.AreEqual("<?xml version=\"1.0\" encoding=\"utf-16\"?>" + Environment.NewLine +
                            "<projectStatus " +
                            "stage=\"" + buildStage + "\" " +
                            "showForceBuildButton=\"true\" " +
                            "showStartStopButton=\"true\" " +
                            "serverName=\"" + Environment.MachineName + "\" " +
                            "status=\"" + status.ToString() + "\" " +
                            "buildStatus=\"" + buildStatus.ToString() + "\" " +
                            "name=\"" + projectName + "\" " +
                            "category=\"" + category + "\" " +
                            "queueName=\"" + queue + "\" " +
                            "queuePriority=\"" + queuePriority.ToString() + "\" " +
                            "url=\"" + webURL + "\" " +
                            "lastBuildDate=\"" + lastBuildDate.ToString("yyyy-MM-ddTHH:mm:ss.FFFFFFF") + "\" " +
                            "lastBuildLabel=\"" + lastBuildLabel + "\" " +
                            "lastSuccessfulBuildLabel=\"" + lastSuccessfulBuildLabel + "\" " +
                            "nextBuildTime=\"" + nextBuildTime.ToString("yyyy-MM-ddTHH:mm:ss.FFFFFFF") + "\"" +
                            ">" + Environment.NewLine +
                            "  <activity type=\"" + activity.ToString() + "\" />" + Environment.NewLine +
                            "  <parameters>" + Environment.NewLine +
                            streamedParameters +
                            "  </parameters>" + Environment.NewLine +
                            "</projectStatus>",
                            writer.ToString());
        }
        private void Integrate()
        {
            Log.Info(string.Format("{0}:Begin", System.Reflection.MethodBase.GetCurrentMethod().Name));
            // should we integrate this pass?
            bool ShouldIntegration = this.ShouldRunIntegration();

            if (ShouldIntegration)
            {
                IntegrationStatus status = IntegrationStatus.Unknown;
                try
                {
                    Log.Info(string.Format("{0}.{1}:Before _integratable.RunIntegration", System.Reflection.MethodBase.GetCurrentMethod().ReflectedType.Name, System.Reflection.MethodBase.GetCurrentMethod().Name));
                    status = _integratable.RunIntegration(this.IntegrationResult).Status;
                    Log.Info(string.Format("{0}.{1}:results.Status={2}", System.Reflection.MethodBase.GetCurrentMethod().ReflectedType.Name, System.Reflection.MethodBase.GetCurrentMethod().Name, status.ToString()));
                    Log.Info(string.Format("{0}.{1}:After _integratable.RunIntegration", System.Reflection.MethodBase.GetCurrentMethod().ReflectedType.Name, System.Reflection.MethodBase.GetCurrentMethod().Name));
                }
                catch (Exception ex)
                {
                    Log.Error(ex);
                }

                // notify the schedule whether the build was successful or not
                Log.Info(string.Format("{0}.{1}:Before _trigger.IntegrationCompleted", System.Reflection.MethodBase.GetCurrentMethod().ReflectedType.Name, System.Reflection.MethodBase.GetCurrentMethod().Name));
                if (status != IntegrationStatus.Unknown && status != IntegrationStatus.Exception)
                {
                    _trigger.IntegrationCompleted();
                }
                Log.Info(string.Format("{0}.{1}:After _trigger.IntegrationCompleted", System.Reflection.MethodBase.GetCurrentMethod().ReflectedType.Name, System.Reflection.MethodBase.GetCurrentMethod().Name));
            }
            else
            {
                _trigger.IntegrationNotRun();
            }
            Log.Info(string.Format("{0}:End", System.Reflection.MethodBase.GetCurrentMethod().Name));
        }