Beispiel #1
0
        public void EnsureDuplicateQueueNamesAreAllowedOnSameTransportWithDifferentConnectionString()
        {
            var newInstance = new ServiceControlNewInstance
            {
                TransportPackage = "RabbitMQ",
                AuditQueue       = "RMQaudit",
                AuditLogQueue    = "RMQauditlog",
                ErrorQueue       = "RMQerror",
                ErrorLogQueue    = "RMQerrorlog",
                ConnectionString = "afakeconnectionstring"
            };

            var p = new ServiceControlQueueNameValidator(newInstance)
            {
                Instances = instances
            };
            var ex = Assert.Throws <EngineValidationException>(() => p.CheckQueueNamesAreNotTakenByAnotherInstance());

            Assert.That(ex.Message, Is.StringContaining("Some queue names specified are already assigned to another ServiceControl instance - Correct the values for"));

            newInstance.ConnectionString = "differentconnectionstring";
            p = new ServiceControlQueueNameValidator(newInstance)
            {
                Instances = instances
            };
            Assert.DoesNotThrow(() => p.CheckQueueNamesAreNotTakenByAnotherInstance());
        }
Beispiel #2
0
        public void DuplicateQueueNamesAreAllowedOnDifferentTransports_ShouldNotThrow()
        {
            var newInstance = new ServiceControlNewInstance
            {
                TransportPackage = "RabbitMQ",
                AuditLogQueue    = "auditlog",
                ErrorLogQueue    = "errorlog",
                AuditQueue       = "audit",
                ErrorQueue       = "error"
            };

            var p = new ServiceControlQueueNameValidator(newInstance)
            {
                Instances = instances
            };
            var ex = Assert.Throws <EngineValidationException>(() => p.CheckQueueNamesAreNotTakenByAnotherInstance());

            Assert.That(ex.Message, Is.StringContaining("Some queue names specified are already assigned to another ServiceControl instance - Correct the values for"));

            // null queues will default to default names
            p = new ServiceControlQueueNameValidator(new ServiceControlNewInstance())
            {
                Instances = instances
            };

            ex = Assert.Throws <EngineValidationException>(() => p.CheckQueueNamesAreNotTakenByAnotherInstance());
            Assert.That(ex.Message, Is.StringContaining("Some queue names specified are already assigned to another ServiceControl instance - Correct the values for"));
        }
        public void CheckQueueNamesAreNotTakenByAnotherInstance_ShouldThrow()
        {
            var newInstance = new ServiceControlNewInstance
            {
                TransportPackage = ServiceControlCoreTransports.All.First(t => t.Name == "MSMQ"),
                AuditLogQueue    = "auditlog",
                ErrorLogQueue    = "errorlog",
                AuditQueue       = "audit",
                ErrorQueue       = "error"
            };

            var p = new ServiceControlQueueNameValidator(newInstance)
            {
                Instances = instances
            };
            var ex = Assert.Throws <EngineValidationException>(() => p.CheckQueueNamesAreNotTakenByAnotherInstance());

            Assert.That(ex.Message, Does.Contain("Some queue names specified are already assigned to another ServiceControl instance - Correct the values for"));

            // null queues will default to default names
            p = new ServiceControlQueueNameValidator(new ServiceControlNewInstance())
            {
                Instances = instances
            };

            ex = Assert.Throws <EngineValidationException>(() => p.CheckQueueNamesAreNotTakenByAnotherInstance());
            Assert.That(ex.Message, Does.Contain("Some queue names specified are already assigned to another ServiceControl instance - Correct the values for"));
        }
        public void ValidateChanges()
        {
            try
            {
                new PathsValidator(this).RunValidation(false);
            }
            catch (EngineValidationException ex)
            {
                ReportCard.Errors.Add(ex.Message);
            }

            try
            {
                ServiceControlQueueNameValidator.Validate(this);
            }
            catch (EngineValidationException ex)
            {
                ReportCard.Errors.Add(ex.Message);
            }

            var oldSettings    = InstanceFinder.FindServiceControlInstance(Name);
            var passwordSet    = !string.IsNullOrWhiteSpace(ServiceAccountPwd);
            var accountChanged = !string.Equals(oldSettings.ServiceAccount, ServiceAccount, StringComparison.OrdinalIgnoreCase);

            if (passwordSet || accountChanged)
            {
                try
                {
                    ServiceAccountValidation.Validate(this);
                }
                catch (IdentityNotMappedException)
                {
                    ReportCard.Errors.Add("The service account specified does not exist");
                    return;
                }
                catch (EngineValidationException ex)
                {
                    ReportCard.Errors.Add(ex.Message);
                    return;
                }
            }

            try
            {
                ConnectionStringValidator.Validate(this);
            }
            catch (EngineValidationException ex)
            {
                ReportCard.Errors.Add(ex.Message);
            }
        }
Beispiel #5
0
        public void CheckQueueNamesAreNotTakenByAnotherInstance_ShouldSucceed()
        {
            var newInstance = new ServiceControlNewInstance
            {
                TransportPackage = "MSMQ",
                AuditLogQueue    = "auditlog2",
                ErrorLogQueue    = "errorlog2",
                AuditQueue       = "audit2",
                ErrorQueue       = "error2"
            };

            var p = new ServiceControlQueueNameValidator(newInstance)
            {
                Instances = instances
            };

            Assert.DoesNotThrow(() => p.CheckQueueNamesAreNotTakenByAnotherInstance());
        }
Beispiel #6
0
        public void CheckQueueNamesAreUniqueShouldSucceed()
        {
            var newInstance = new ServiceControlNewInstance
            {
                TransportPackage = "MSMQ",
                AuditLogQueue    = "auditlog",
                ErrorLogQueue    = "errorlog",
                AuditQueue       = "audit",
                ErrorQueue       = "error"
            };

            var p = new ServiceControlQueueNameValidator(newInstance)
            {
                Instances = new List <IServiceControlTransportConfig>()
            };

            Assert.DoesNotThrow(() => p.CheckQueueNamesAreUniqueWithinInstance());
        }
Beispiel #7
0
        public void CheckQueueNamesAreUniqueShouldThrow()
        {
            var newInstance = new ServiceControlNewInstance
            {
                TransportPackage = "MSMQ",
                AuditLogQueue    = "audit",
                ErrorLogQueue    = "error",
                AuditQueue       = "audit",
                ErrorQueue       = "error"
            };

            var p = new ServiceControlQueueNameValidator(newInstance)
            {
                Instances = new List <IServiceControlTransportConfig>()
            };

            var ex = Assert.Throws <EngineValidationException>(() => p.CheckQueueNamesAreUniqueWithinInstance());

            Assert.That(ex.Message, Is.StringContaining("Each of the queue names specified for a instance should be unique"));
        }
Beispiel #8
0
        public void Validate(Func <PathInfo, bool> promptToProceed)
        {
            if (TransportPackage.Equals("MSMQ", StringComparison.OrdinalIgnoreCase))
            {
                try
                {
                    MsmqConfigValidator.Validate();
                }
                catch (EngineValidationException ex)
                {
                    ReportCard.Errors.Add(ex.Message);
                }
            }

            try
            {
                PortValidator.Validate(this);
            }
            catch (EngineValidationException ex)
            {
                ReportCard.Errors.Add(ex.Message);
            }

            try
            {
                DatabaseMaintenancePortValidator.Validate(this);
            }
            catch (EngineValidationException ex)
            {
                ReportCard.Errors.Add(ex.Message);
            }

            try
            {
                ReportCard.CancelRequested = new PathsValidator(this).RunValidation(true, promptToProceed);
            }
            catch (EngineValidationException ex)
            {
                ReportCard.Errors.Add(ex.Message);
            }

            try
            {
                ServiceControlQueueNameValidator.Validate(this);
            }
            catch (EngineValidationException ex)
            {
                ReportCard.Errors.Add(ex.Message);
            }

            try
            {
                CheckForConflictingUrlAclReservations();
            }
            catch (EngineValidationException ex)
            {
                ReportCard.Errors.Add(ex.Message);
            }

            try
            {
                ServiceAccountValidation.Validate(this);
                ConnectionStringValidator.Validate(this);
            }
            catch (IdentityNotMappedException)
            {
                ReportCard.Errors.Add("The service account specified does not exist");
            }
            catch (EngineValidationException ex)
            {
                ReportCard.Errors.Add(ex.Message);
            }
        }