Ejemplo n.º 1
0
        /// <summary>
        /// Sends the request to a remote server.
        /// </summary>
        /// <param name="context">The context.</param>
        private void SendRemoteRequest(TaskExecutionContext context)
        {
            // Generate the connection
            var connection = this.ServerConnectionFactory.GenerateConnection(this.ServerAddress);

            // Resolve the URN
            var urn = this.ProjectName;

            if (!UrnHelpers.IsCCNetUrn(urn))
            {
                urn = this.ServerConnectionFactory.GenerateUrn(this.ServerAddress, urn);
            }

            // Send the actual request
            logger.Debug("Sending force build on '{0}' to '{1}'", urn, this.ServerAddress);
            try
            {
                connection.Invoke(urn, "ForceBuild");
                var message = "Force build successfully sent to '" + ProjectName + "' at '" + this.ServerAddress + "'";
                logger.Info(message);
                context.AddEntryToBuildLog(message);
            }
            catch (RemoteServerException error)
            {
                var message = "Force build failed for '" + ProjectName + "' at '" + this.ServerAddress + "' - result code " + error.ResultCode;
                logger.Info(message);
                context.AddEntryToBuildLog(message);
                context.CurrentStatus = IntegrationStatus.Failure;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Sends the request to the local server.
        /// </summary>
        /// <param name="context">The context.</param>
        private void SendLocalRequest(TaskExecutionContext context)
        {
            // Resolve the URN
            var urn = this.ProjectName;

            if (!UrnHelpers.IsCCNetUrn(urn))
            {
                urn = UrnHelpers.GenerateProjectUrn(this.Project.Server, this.ProjectName);
            }

            // Send the actual request
            logger.Debug("Performing local force build on '{0}'", urn);
            var arguments = new InvokeArguments
            {
                Action = "ForceBuild"
            };
            var result = this.Project.Server.ActionInvoker.Invoke(urn, arguments);

            // Check the result
            if (result.ResultCode == RemoteResultCode.Success)
            {
                var message = "Force build successfully sent to '" + ProjectName + "'";
                logger.Info(message);
                context.AddEntryToBuildLog(message);
            }
            else
            {
                var message = "Force build failed for '" + ProjectName + "' - result code " + result.ResultCode;
                logger.Info(message);
                context.AddEntryToBuildLog(message);
                context.CurrentStatus = IntegrationStatus.Failure;
            }
        }
        public void ExtractServerUrnReturnsJustServerUrn()
        {
            var urn      = "urn:ccnet:local:project";
            var expected = "urn:ccnet:local";
            var actual   = UrnHelpers.ExtractServerUrn(urn);

            Assert.AreEqual(expected, actual);
        }
        public void GenerateProjectUrnGeneratesFromServer()
        {
            var server   = new Server("thisServer");
            var project  = "local";
            var expected = "urn:ccnet:thisServer:local";
            var actual   = UrnHelpers.GenerateProjectUrn(server, project);

            Assert.AreEqual(expected, actual);
        }
        public void GenerateProjectUrnGeneratesUrnUsingServerName()
        {
            var server   = "local";
            var project  = "project";
            var expected = "urn:ccnet:local:project";
            var actual   = UrnHelpers.GenerateProjectUrn(server, project);

            Assert.AreEqual(expected, actual);
        }
        public void GenerateProjectUrnDoesNothingIfProjectAlreadyAUrn()
        {
            var server   = "urn:ccnet:local";
            var project  = "urn:ccnet:local:project";
            var expected = "urn:ccnet:local:project";
            var actual   = UrnHelpers.GenerateProjectUrn(server, project);

            Assert.AreEqual(expected, actual);
        }
 public void GenerateProjectUrnFailsIfProjectMissing()
 {
     Assert.Throws <ArgumentNullException>(
         () => UrnHelpers.GenerateProjectUrn("server", null));
 }
 public void GenerateProjectUrnFailsIfServerNameBlank()
 {
     Assert.Throws <ArgumentNullException>(
         () => UrnHelpers.GenerateProjectUrn(string.Empty, "project"));
 }
 public void GenerateProjectUrnFailsIfServerMissing()
 {
     Assert.Throws <ArgumentNullException>(
         () => UrnHelpers.GenerateProjectUrn((Server)null, "project"));
 }
 public void IsCCNetUrnReturnsFalseWhenUrnMissing()
 {
     Assert.IsFalse(UrnHelpers.IsCCNetUrn(null));
 }
 public void IsCCNetUrnReturnsFalseWhenNotAUrn()
 {
     Assert.IsFalse(UrnHelpers.IsCCNetUrn("http://local"));
 }
 public void IsCCNetUrnReturnsFalseWhenMissingCCNet()
 {
     Assert.IsFalse(UrnHelpers.IsCCNetUrn("urn:local"));
 }
 public void ExtractServerUrnFailsIfUrnIncomplete()
 {
     Assert.Throws <ArgumentException>(
         () => UrnHelpers.ExtractServerUrn("urn:ccnet:"));
 }
 public void IsCCNetUrnReturnsTrueForCCNetUrn()
 {
     Assert.IsTrue(UrnHelpers.IsCCNetUrn("urn:ccnet:local"));
 }
 public void ExtractServerUrnFailsIfNotCCNetUrn()
 {
     Assert.Throws <ArgumentException>(
         () => UrnHelpers.ExtractServerUrn("http://somewhere"));
 }
 public void ExtractServerUrnFailsIfServerMissing()
 {
     Assert.Throws <ArgumentNullException>(
         () => UrnHelpers.ExtractServerUrn(null));
 }