Пример #1
0
        public Property Only_Overdue_Entries_Are_Deleted()
        {
            return(Prop.ForAll(
                       SupportedProviderSettings(),
                       Arb.Default.PositiveInt(),
                       Arb.Default.PositiveInt(),
                       (specificSettings, insertion, retention) =>
            {
                // Arrange
                int retentionDays = retention.Get;
                OverrideWithSpecificSettings(specificSettings, retentionDays: retentionDays);

                int insertionDays = insertion.Get;
                string id = GenId();

                IConfig config = EnsureLocalConfigPointsToCreatedDatastore();
                var spy = new DatabaseSpy(config);
                var insertionTime = DateTimeOffset.Now.Add(TimeSpan.FromDays(-insertionDays));
                spy.InsertOutException(CreateOutException(id, insertionTime));

                // Act
                ExerciseStartCleaning();

                // Assert
                bool hasEntries = spy.GetOutExceptions(id).Any();
                return (hasEntries == insertionDays < retentionDays)
                .When(insertionDays != retentionDays)
                .Classify(hasEntries, "OutException isn't deleted")
                .Classify(!hasEntries, "OutException is deleted");
            }));
        }
Пример #2
0
        public void MessageOlderThanRetentionDateWillBeDeleted(string specificSettings)
        {
            // Arrange: Insert a "retired" OutMessage with a referenced Reception Awareness.
            OverrideWithSpecificSettings(specificSettings);

            IConfig config = EnsureLocalConfigPointsToCreatedDatastore();
            string  outReferenceId = GenId(), outStandaloneId = GenId(),
                    inMessageId = GenId(), outExceptionId = GenId(),
                    inExceptionId = GenId();

            var        spy = new DatabaseSpy(config);
            OutMessage om  = CreateOutMessage(outReferenceId, insertionTime: DayBeforeYesterday, type: MessageType.Error);

            spy.InsertOutMessage(om);
            spy.InsertRetryReliability(RetryReliability.CreateForOutMessage(om.Id, maxRetryCount: 0, retryInterval: default(TimeSpan), type: RetryType.Send));
            spy.InsertOutMessage(CreateOutMessage(outStandaloneId, insertionTime: DayBeforeYesterday, type: MessageType.Receipt));
            spy.InsertInMessage(CreateInMessage(inMessageId, DayBeforeYesterday));
            spy.InsertOutException(CreateOutException(outExceptionId, DayBeforeYesterday));
            spy.InsertInException(CreateInException(inExceptionId, DayBeforeYesterday));

            // Act: AS4.NET Component will start the Clean Up Agent.
            ExerciseStartCleaning();

            // Assert: No OutMessage or Reception Awareness entries must be found for a given EbmsMessageId.
            Assert.Empty(spy.GetOutMessages(outReferenceId, outStandaloneId));
            Assert.Null(spy.GetRetryReliabilityFor(r => r.RefToOutMessageId == om.Id));
            Assert.Empty(spy.GetInMessages(inMessageId));
            Assert.Empty(spy.GetOutExceptions(outExceptionId));
            Assert.Empty(spy.GetInExceptions(inExceptionId));
        }
Пример #3
0
        public async Task OutException_Is_Set_To_Notified_When_Retry_Happen_Within_Allowed_MaxRetry(
            HttpStatusCode secondAttempt,
            Operation expected)
        {
            await TestComponentWithSettings(
                "outexception_notify_reliability_settings.xml",
                async (settings, as4Msh) =>
            {
                // Arrange
                var handler = new OutboundExceptionHandler(
                    () => new DatastoreContext(as4Msh.GetConfiguration()),
                    as4Msh.GetConfiguration(),
                    Registry.Instance.MessageBodyStore);

                const string url     = "http://localhost:7070/business/outexception/";
                string ebmsMessageId = $"entity-{Guid.NewGuid()}";

                var spy = new DatabaseSpy(as4Msh.GetConfiguration());
                //var entity = new OutMessage(ebmsMessageId);
                //spy.InsertOutMessage(entity);

                // Act
                await handler.HandleExecutionException(
                    new Exception("This is an test exception"),
                    new MessagingContext(new SubmitMessage())
                {
                    SendingPMode = NotifySendingPMode(url)
                });

                // Arrange
                SimulateNotifyFailureOnFirstAttempt(url, secondAttempt);


                OutException notified =
                    await PollUntilPresent(
                        () => spy.GetOutExceptions(
                            ex => ex.Operation == expected).FirstOrDefault(),
                        timeout: TimeSpan.FromSeconds(10));

                Entities.RetryReliability referenced = await PollUntilPresent(
                    () => spy.GetRetryReliabilityFor(r => r.RefToOutExceptionId == notified.Id),
                    timeout: TimeSpan.FromSeconds(5));
                Assert.Equal(RetryStatus.Completed, referenced.Status);
            });
        }