コード例 #1
0
 private EmsTemplate CreateTemplate()
 {
     EmsTemplate template = new EmsTemplate();
     template.DestinationResolver = mockDestinationResolver;
     template.SessionTransacted = UseTransactedTemplate;
     return template;
 }
コード例 #2
0
        public void TransactionCommit()
        {
            IConnectionFactory connectionFactory = (IConnectionFactory) mocks.CreateMock(typeof (IConnectionFactory));
            IConnection connection = (IConnection) mocks.CreateMock(typeof (IConnection));
            ISession session = (ISession) mocks.CreateMock(typeof (ISession));

            using (mocks.Ordered())
            {
                SetupCommitExpectations(connection, connectionFactory, session);
            }

            mocks.ReplayAll();

            EmsTransactionManager tm = new EmsTransactionManager(connectionFactory);
            ITransactionStatus ts = tm.GetTransaction(new DefaultTransactionDefinition());
            EmsTemplate nt = new EmsTemplate(connectionFactory);
            nt.Execute(new AssertSessionCallback(session));
            tm.Commit(ts);

            mocks.VerifyAll();
                
        }
コード例 #3
0
ファイル: EmsTemplate.cs プロジェクト: fgq841103/spring-net
 public SendDestinationCallback(EmsTemplate jmsTemplate, string destinationName, IMessageCreator messageCreator)
 {
     this.jmsTemplate = jmsTemplate;
     this.destinationName = destinationName;
     this.messageCreator = messageCreator;
 }
コード例 #4
0
ファイル: EmsTemplate.cs プロジェクト: fgq841103/spring-net
 public SimpleMessageCreator(EmsTemplate jmsTemplate, object objectToConvert)
 {
     this.jmsTemplate = jmsTemplate;
     this.objectToConvert = objectToConvert;
 }
コード例 #5
0
ファイル: EmsTemplate.cs プロジェクト: fgq841103/spring-net
 public ReceiveSelectedCallback(EmsTemplate jmsTemplate,
                                string destinationName,
                                string messageSelector)
 {
     this.jmsTemplate = jmsTemplate;
     this.destinationName = destinationName;
     this.messageSelector = messageSelector;
 }
コード例 #6
0
ファイル: EmsTemplate.cs プロジェクト: fgq841103/spring-net
 public ConvertAndSendMessageCreator(EmsTemplate jmsTemplate, object message, MessagePostProcessorDelegate messagePostProcessorDelegate)
 {
     this.jmsTemplate = jmsTemplate;
     objectToConvert = message;
     this.messagePostProcessorDelegate = messagePostProcessorDelegate;
 }
コード例 #7
0
ファイル: EmsTemplate.cs プロジェクト: fgq841103/spring-net
 public ConvertAndSendMessageCreator(EmsTemplate jmsTemplate, object message, IMessagePostProcessor messagePostProcessor)
 {
     this.jmsTemplate = jmsTemplate;
     objectToConvert = message;
     this.messagePostProcessor = messagePostProcessor;
 }
コード例 #8
0
        public void TransactionSuspension()
        {
            IConnectionFactory connectionFactory = (IConnectionFactory)mocks.CreateMock(typeof(IConnectionFactory));
            IConnection connection = (IConnection)mocks.CreateMock(typeof(IConnection));
            ISession session = (ISession)mocks.CreateMock(typeof(ISession));
            ISession session2 = (ISession)mocks.CreateMock(typeof(ISession));


            Expect.Call(connectionFactory.CreateConnection()).Return(connection).Repeat.Twice();
            Expect.Call(connection.CreateSession(true, Session.SESSION_TRANSACTED)).Return(session).Repeat.Once();
            Expect.Call(connection.CreateSession(true, Session.SESSION_TRANSACTED)).Return(session2).Repeat.Once();

            session.Commit();
            LastCall.On(session).Repeat.Once();
            session2.Commit();
            LastCall.On(session2).Repeat.Once();

            session.Close();
            LastCall.On(session).Repeat.Once();
            session2.Close();
            LastCall.On(session2).Repeat.Once();

            connection.Close();
            LastCall.On(connection).Repeat.Twice();

            mocks.ReplayAll();

            EmsTransactionManager tm = new EmsTransactionManager(connectionFactory);
            ITransactionStatus ts = tm.GetTransaction(new DefaultTransactionDefinition());
            EmsTemplate nt = new EmsTemplate(connectionFactory);


            TransactionTemplate tt = new TransactionTemplate(tm);
            tt.PropagationBehavior = TransactionPropagation.RequiresNew;
            tt.Execute(delegate(ITransactionStatus status)
                           {
                               nt.Execute(new AssertNotSameSessionCallback(session));
                               return null;
                           });

            nt.Execute(new AssertSessionCallback(session));

            tm.Commit(ts);

            mocks.VerifyAll();

        }
コード例 #9
0
ファイル: EmsTemplate.cs プロジェクト: fgq841103/spring-net
 public SendDestinationCallback(EmsTemplate jmsTemplate, Destination destination, MessageCreatorDelegate messageCreatorDelegate)
 {
     this.jmsTemplate = jmsTemplate;
     this.destination = destination;
     this.messageCreatorDelegate = messageCreatorDelegate;
 }
コード例 #10
0
ファイル: EmsTemplate.cs プロジェクト: fgq841103/spring-net
 public ProducerCreatorCallback(EmsTemplate jmsTemplate, ProducerDelegate producerDelegate)
 {
     this.jmsTemplate = jmsTemplate;
     this.producerDelegate = producerDelegate;
 }
コード例 #11
0
ファイル: EmsTemplate.cs プロジェクト: fgq841103/spring-net
            public ProducerCreatorCallback(EmsTemplate jmsTemplate, IProducerCallback producerCallback)
            {
                this.jmsTemplate = jmsTemplate;
				this.producerCallback = producerCallback;
            }
コード例 #12
0
ファイル: EmsTemplate.cs プロジェクト: fgq841103/spring-net
 private void InitBlock(EmsTemplate enclosingInstance)
 {
     enclosingTemplateInstance = enclosingInstance;
 }
コード例 #13
0
ファイル: EmsTemplate.cs プロジェクト: fgq841103/spring-net
 public EmsTemplateResourceFactory(EmsTemplate enclosingInstance)
 {
     InitBlock(enclosingInstance);
 }
コード例 #14
0
ファイル: EmsTemplate.cs プロジェクト: fgq841103/spring-net
 public SendDestinationCallback(EmsTemplate jmsTemplate, Destination destination, IMessageCreator messageCreator)
 {
     this.jmsTemplate = jmsTemplate;
     this.destination = destination;
     this.messageCreator = messageCreator;
 }
コード例 #15
0
ファイル: EmsTemplate.cs プロジェクト: fgq841103/spring-net
 public ReceiveCallback(EmsTemplate jmsTemplate, string destinationName)
 {
     this.jmsTemplate = jmsTemplate;
     this.destinationName = destinationName;
 }
コード例 #16
0
ファイル: EmsTemplate.cs プロジェクト: fgq841103/spring-net
 public SendDestinationCallback(EmsTemplate jmsTemplate, string destinationName, MessageCreatorDelegate messageCreatorDelegate)
 {
     this.jmsTemplate = jmsTemplate;
     this.destinationName = destinationName;
     this.messageCreatorDelegate = messageCreatorDelegate;
 }
コード例 #17
0
ファイル: EmsTemplate.cs プロジェクト: fgq841103/spring-net
 public ReceiveCallback(EmsTemplate jmsTemplate, Destination destination)
 {
     this.jmsTemplate = jmsTemplate;
     this.destination = destination;
 }
コード例 #18
0
 public SimplePublisher()
 {
     emsTemplate = new EmsTemplate(new EmsConnectionFactory("tcp://localhost:7222"));
 }
コード例 #19
0
        public void ParticipatingTransactionWithRollback()
        {
            IConnectionFactory connectionFactory = (IConnectionFactory) mocks.CreateMock(typeof (IConnectionFactory));
            IConnection connection = (IConnection) mocks.CreateMock(typeof (IConnection));
            ISession session = (ISession) mocks.CreateMock(typeof (ISession));

            using (mocks.Ordered())
            {
                SetupRollbackExpectations(connection, connectionFactory, session);
            }

            mocks.ReplayAll();

            EmsTransactionManager tm = new EmsTransactionManager(connectionFactory);
            ITransactionStatus ts = tm.GetTransaction(new DefaultTransactionDefinition());
            EmsTemplate nt = new EmsTemplate(connectionFactory);
            nt.Execute(new AssertSessionCallback(session));

            TransactionTemplate tt = new TransactionTemplate(tm);
            tt.Execute(delegate(ITransactionStatus status)
                           {
                               nt.Execute(new AssertSessionCallback(session));
                               status.SetRollbackOnly();
                               return null;
                           });
            try
            {
                tm.Commit(ts);
                Assert.Fail("Should have thrown UnexpectedRollbackException");
            } catch (UnexpectedRollbackException)
            {
                
            }

            mocks.VerifyAll();
        }