Esempio n. 1
0
        private void InsertToBeForwardedInMessage(string pmodeId, MessageExchangePattern mep, AS4Message tobeForwarded)
        {
            foreach (MessageUnit m in tobeForwarded.MessageUnits)
            {
                string location =
                    Registry.Instance
                    .MessageBodyStore
                    .SaveAS4Message(
                        _as4Msh.GetConfiguration().InMessageStoreLocation,
                        tobeForwarded);

                var inMessage = new InMessage(m.MessageId)
                {
                    Intermediary = true,
                    Operation    =
                        m.MessageId == tobeForwarded.PrimaryMessageUnit.MessageId
                            ? Operation.ToBeForwarded
                            : Operation.NotApplicable,
                    MessageLocation = location,
                    MEP             = mep,
                    ContentType     = tobeForwarded.ContentType
                };

                ReceivingProcessingMode forwardPMode =
                    _as4Msh.GetConfiguration()
                    .GetReceivingPModes()
                    .First(p => p.Id == pmodeId);

                inMessage.SetPModeInformation(forwardPMode);
                inMessage.SetStatus(InStatus.Received);
                inMessage.AssignAS4Properties(m);
                _databaseSpy.InsertInMessage(inMessage);
            }
        }
Esempio n. 2
0
        public Property Only_Entries_With_Allowed_Operations_Are_Deleted()
        {
            return(Prop.ForAll(
                       SupportedProviderSettings(),
                       Arb.From <Operation>(),
                       (specificSettings, operation) =>
            {
                // Arrange
                OverrideWithSpecificSettings(specificSettings);

                string id = GenId();
                InMessage m = CreateInMessage(id, insertionTime: DayBeforeYesterday);
                m.Operation = operation;

                IConfig config = EnsureLocalConfigPointsToCreatedDatastore();
                var spy = new DatabaseSpy(config);
                spy.InsertInMessage(m);

                // Act
                ExerciseStartCleaning();

                // Assert
                bool hasEntries = spy.GetInMessages(id).Any();
                string description = $"InMessage {(hasEntries ? "isn't" : "is")} deleted, with Operation: {operation}";
                return (hasEntries == !AllowedOperations.Contains(operation)).Collect(description);
            }));
        }
Esempio n. 3
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));
        }
Esempio n. 4
0
 private void InsertUserMessage(UserMessage user)
 {
     _databaseSpy.InsertInMessage(
         new InMessage(user.MessageId)
     {
         Mpc             = user.Mpc,
         EbmsMessageType = MessageType.UserMessage,
         ContentType     = Constants.ContentTypes.Soap
     });
 }