コード例 #1
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));
        }
コード例 #2
0
        private void InsertRelatedSignedUserMessage(IPMode nrrPMode, AS4Message signedUserMessage)
        {
            string location = Registry.Instance.MessageBodyStore
                              .SaveAS4Message(_as4Msh.GetConfiguration().OutMessageStoreLocation, signedUserMessage);

            var outMessage = new OutMessage(signedUserMessage.GetPrimaryMessageId())
            {
                ContentType     = signedUserMessage.ContentType,
                MessageLocation = location,
            };

            outMessage.SetPModeInformation(nrrPMode);

            _databaseSpy.InsertOutMessage(outMessage);
        }
コード例 #3
0
        public Property Only_Awnsered_UserMessages_Are_Deleted()
        {
            return(Prop.ForAll(
                       SupportedProviderSettings(),
                       Arb.From <OutStatus>(),
                       (specificSettings, status) =>
            {
                // Arrange
                OverrideWithSpecificSettings(specificSettings);

                string id = GenId();
                OutMessage m = CreateOutMessage(
                    id, insertionTime: DayBeforeYesterday, type: MessageType.UserMessage);
                m.SetStatus(status);

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

                // Act
                ExerciseStartCleaning();

                // Assert
                bool isCleaned = !spy.GetOutMessages(id).Any();
                bool isAckOrNack = status == OutStatus.Ack || status == OutStatus.Nack;
                return isCleaned == isAckOrNack;
            }));
        }
コード例 #4
0
        private long InsertReceipt(Receipt receipt, string url, Operation operation)
        {
            string location =
                Registry.Instance
                .MessageBodyStore
                .SaveAS4Message(
                    _as4Msh.GetConfiguration().OutMessageStoreLocation,
                    AS4Message.Create(receipt));

            var entity = new OutMessage(receipt.MessageId)
            {
                EbmsRefToMessageId = receipt.RefToMessageId,
                EbmsMessageType    = MessageType.Receipt,
                ContentType        = Constants.ContentTypes.Soap,
                MessageLocation    = location,
                Url       = url,
                Operation = operation
            };

            _databaseSpy.InsertOutMessage(entity);

            return(entity.Id);
        }
コード例 #5
0
        public async Task PullSendAgentReturnsUserMessage_ForPullRequestWithEmptyMpc()
        {
            // Arrange
            var userMessage =
                AS4Message.Create(
                    new UserMessage(
                        $"user-{Guid.NewGuid()}",
                        new CollaborationInfo(
                            new AgreementReference(
                                value: "http://eu.europe.agreements.org",
                                pmodeId: "pullsendagent-pmode"))));

            var outMessage = new OutMessage(userMessage.GetPrimaryMessageId())
            {
                ContentType     = userMessage.ContentType,
                MEP             = MessageExchangePattern.Pull,
                Operation       = Operation.ToBeSent,
                MessageLocation =
                    Registry.Instance
                    .MessageBodyStore
                    .SaveAS4Message(_as4Msh.GetConfiguration().OutExceptionStoreLocation, userMessage)
            };

            outMessage.AssignAS4Properties(userMessage.PrimaryMessageUnit);
            _databaseSpy.InsertOutMessage(outMessage);

            // Act
            HttpResponseMessage userMessageResponse =
                await StubSender.SendRequest(PullSendUrl, Encoding.UTF8.GetBytes(pullrequest_without_mpc), "application/soap+xml");

            // Assert
            AS4Message as4Message = await userMessageResponse.DeserializeToAS4Message();

            Assert.True(as4Message.IsUserMessage, "AS4 Message isn't a User Message");
            Assert.Equal(Constants.Namespaces.EbmsDefaultMpc, as4Message.FirstUserMessage.Mpc);
        }
コード例 #6
0
        private void PutMessageToSend(AS4Message as4Message, SendingProcessingMode pmode, bool actAsIntermediaryMsh)
        {
            var outMessage = new OutMessage(as4Message.GetPrimaryMessageId())
            {
                ContentType     = as4Message.ContentType,
                MessageLocation =
                    Registry.Instance
                    .MessageBodyStore.SaveAS4Message(
                        Config.Instance.OutMessageStoreLocation,
                        as4Message),
                Intermediary    = actAsIntermediaryMsh,
                EbmsMessageType = MessageType.UserMessage,
                MEP             = MessageExchangePattern.Push,
                Operation       = Operation.ToBeSent,
            };

            outMessage.SetPModeInformation(pmode);

            _databaseSpy.InsertOutMessage(outMessage);
        }