Beispiel #1
0
        public void TestCallBackServiceAcceptToMsrFromReestrMspCatalogItemsResponseMessage()
        {
            using (new FakeHttpContext())
            {
                var pathToXML = Path.Combine(HttpRuntime.AppDomainAppPath,
                                             $"{Context.XMLMessagePath}{ToMsrFromReestrMspCatalogItemsResponse.NameForESB}.xml");
                var xmlTemplateDoc = new XmlDocument();
                xmlTemplateDoc.Load(pathToXML);
                var xmlStringMsg = xmlTemplateDoc.InnerXml;

                var msg = new MessageFromESB
                {
                    MessageTypeID = ToMsrFromReestrMspCatalogItemsResponse.NameForESB,
                    Body          = xmlStringMsg,
                    SenderName    = "TestSender"
                };

                var cb = new CallbackSubscriber();
                try
                {
                    cb.AcceptMessage(msg);
                }
                catch (Exception ex)
                {
                    Assert.Fail($"Произошло неожиданное исключение - {ex.Message}");
                }
            }
        }
Beispiel #2
0
        public void TestCallBackServiceUnknowMessageEx()
        {
            var msg = new MessageFromESB
            {
                MessageTypeID = "TestUnknowTypeMessage",
                Body          = "",
                SenderName    = "TestSender"
            };

            try
            {
                var cb = new CallbackSubscriber();
                cb.AcceptMessage(msg);
            }
            catch (UnknowMessageTypeException)
            {
                throw;
            }
            catch (Exception ex)
            {
                Assert.Fail($"Произошло неожиданное исключение - {ex.Message}");
            }
        }
        public void Setup()
        {
            //TODO: this became an integration test - proper ProjectionCoreService and ProjectionManager testing is required as well
            _bus.Subscribe(_consumer);

            var queues = GivenCoreQueues();

            _managerMessageDispatcher = new ProjectionManagerMessageDispatcher(queues);
            _manager = new ProjectionManager(
                GetInputQueue(),
                GetInputQueue(),
                queues,
                _timeProvider,
                ProjectionType.All,
                _ioDispatcher,
                TimeSpan.FromMinutes(Opts.ProjectionsQueryExpiryDefault),
                _initializeSystemProjections);

            IPublisher inputQueue   = GetInputQueue();
            IPublisher publisher    = GetInputQueue();
            var        ioDispatcher = new IODispatcher(publisher, new PublishEnvelope(inputQueue));

            _bus.Subscribe <ProjectionManagementMessage.Internal.CleanupExpired>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Internal.Deleted>(_manager);
            _bus.Subscribe <CoreProjectionStatusMessage.Started>(_manager);
            _bus.Subscribe <CoreProjectionStatusMessage.Stopped>(_manager);
            _bus.Subscribe <CoreProjectionStatusMessage.Prepared>(_manager);
            _bus.Subscribe <CoreProjectionStatusMessage.Faulted>(_manager);
            _bus.Subscribe <CoreProjectionStatusMessage.StateReport>(_manager);
            _bus.Subscribe <CoreProjectionStatusMessage.ResultReport>(_manager);
            _bus.Subscribe <CoreProjectionStatusMessage.StatisticsReport>(_manager);
            _bus.Subscribe <CoreProjectionManagementMessage.SlaveProjectionReaderAssigned>(_manager);
            _bus.Subscribe <CoreProjectionStatusMessage.ProjectionWorkerStarted>(_manager);

            _bus.Subscribe <ProjectionManagementMessage.Command.Post>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Command.PostBatch>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Command.UpdateQuery>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Command.GetQuery>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Command.Delete>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Command.GetStatistics>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Command.GetState>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Command.GetResult>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Command.Disable>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Command.Enable>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Command.Abort>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Command.SetRunAs>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Command.Reset>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Command.StartSlaveProjections>(_manager);
            _bus.Subscribe <ClientMessage.WriteEventsCompleted>(_manager);
            _bus.Subscribe <ClientMessage.ReadStreamEventsBackwardCompleted>(_manager);
            _bus.Subscribe <ClientMessage.WriteEventsCompleted>(_manager);
            _bus.Subscribe <ProjectionSubsystemMessage.StartComponents>(_manager);
            _bus.Subscribe <ProjectionSubsystemMessage.StopComponents>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.ReaderReady>(_manager);
            _bus.Subscribe(
                CallbackSubscriber.Create <ProjectionManagementMessage.Starting>(
                    starting => _queue.Publish(new ProjectionManagementMessage.ReaderReady())));
            _bus.Subscribe <PartitionProcessingResultBase>(_managerMessageDispatcher);
            _bus.Subscribe <CoreProjectionManagementControlMessage>(_managerMessageDispatcher);
            _bus.Subscribe <PartitionProcessingResultOutputBase>(_managerMessageDispatcher);

            _bus.Subscribe <ClientMessage.ReadStreamEventsForwardCompleted>(ioDispatcher.ForwardReader);
            _bus.Subscribe <ClientMessage.ReadStreamEventsBackwardCompleted>(ioDispatcher.BackwardReader);
            _bus.Subscribe <ClientMessage.WriteEventsCompleted>(ioDispatcher.Writer);
            _bus.Subscribe <ClientMessage.DeleteStreamCompleted>(ioDispatcher.StreamDeleter);
            _bus.Subscribe <IODispatcherDelayedMessage>(ioDispatcher.Awaker);
            _bus.Subscribe <IODispatcherDelayedMessage>(ioDispatcher);

            AwakeService = new AwakeService();
            _bus.Subscribe <StorageMessage.EventCommitted>(AwakeService);
            _bus.Subscribe <StorageMessage.TfEofAtNonCommitRecord>(AwakeService);
            _bus.Subscribe <AwakeServiceMessage.SubscribeAwake>(AwakeService);
            _bus.Subscribe <AwakeServiceMessage.UnsubscribeAwake>(AwakeService);


            Given();
            WhenLoop();
        }
        public void Setup()
        {
            //TODO: this became an integration test - proper ProjectionCoreService and ProjectionManager testing is required as well
            _bus.Subscribe(_consumer);

            _processingQueues = GivenProcessingQueues();
            var queues = _processingQueues.ToDictionary(v => v.Item5, v => (IPublisher)v.Item1);

            _managerMessageDispatcher = new ProjectionManagerMessageDispatcher(queues);
            _manager = new ProjectionManager(
                GetInputQueue(),
                GetInputQueue(),
                queues,
                _timeProvider,
                ProjectionType.All,
                _ioDispatcher,
                _initializeSystemProjections);

            _coordinator = new ProjectionCoreCoordinator(
                ProjectionType.All,
                ProjectionCoreWorkersNode.CreateTimeoutSchedulers(queues.Count),
                queues.Values.ToArray(),
                _bus,
                Envelope);

            _bus.Subscribe <ProjectionManagementMessage.Internal.CleanupExpired>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Internal.Deleted>(_manager);
            _bus.Subscribe <CoreProjectionStatusMessage.Started>(_manager);
            _bus.Subscribe <CoreProjectionStatusMessage.Stopped>(_manager);
            _bus.Subscribe <CoreProjectionStatusMessage.Prepared>(_manager);
            _bus.Subscribe <CoreProjectionStatusMessage.Faulted>(_manager);
            _bus.Subscribe <CoreProjectionStatusMessage.StateReport>(_manager);
            _bus.Subscribe <CoreProjectionStatusMessage.ResultReport>(_manager);
            _bus.Subscribe <CoreProjectionStatusMessage.StatisticsReport>(_manager);
            _bus.Subscribe <CoreProjectionManagementMessage.SlaveProjectionReaderAssigned>(_manager);
            _bus.Subscribe <CoreProjectionStatusMessage.ProjectionWorkerStarted>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Command.Post>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Command.UpdateQuery>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Command.GetQuery>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Command.Delete>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Command.GetStatistics>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Command.GetState>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Command.GetResult>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Command.Disable>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Command.Enable>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Command.Abort>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Command.SetRunAs>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Command.Reset>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.Command.StartSlaveProjections>(_manager);
            _bus.Subscribe <ClientMessage.WriteEventsCompleted>(_manager);
            _bus.Subscribe <ClientMessage.ReadStreamEventsBackwardCompleted>(_manager);
            _bus.Subscribe <ClientMessage.DeleteStreamCompleted>(_manager);
            _bus.Subscribe <SystemMessage.StateChangeMessage>(_manager);
            _bus.Subscribe <SystemMessage.SystemCoreReady>(_manager);
            _bus.Subscribe <ProjectionManagementMessage.ReaderReady>(_manager);
            _bus.Subscribe(
                CallbackSubscriber.Create <ProjectionManagementMessage.Starting>(
                    starting => _queue.Publish(new ProjectionManagementMessage.ReaderReady())));

            _bus.Subscribe <SystemMessage.StateChangeMessage>(_coordinator);
            _bus.Subscribe <SystemMessage.SystemCoreReady>(_coordinator);

            if (GetInputQueue() != _processingQueues.First().Item2)
            {
                _bus.Subscribe <PartitionProcessingResultBase>(_managerMessageDispatcher);
                _bus.Subscribe <CoreProjectionManagementControlMessage>(
                    _managerMessageDispatcher);
                _bus.Subscribe <PartitionProcessingResultOutputBase>(_managerMessageDispatcher);
                _bus.Subscribe <ReaderSubscriptionManagement.SpoolStreamReading>(_managerMessageDispatcher);
            }

            foreach (var q in _processingQueues)
            {
                SetUpCoreServices(q.Item5, q.Item1, q.Item2, q.Item3, q.Item4);
            }

            //Given();
            WhenLoop();
        }