private EmsTemplate CreateTemplate()
 {
     EmsTemplate template = new EmsTemplate();
     template.DestinationResolver = mockDestinationResolver;
     template.SessionTransacted = UseTransactedTemplate;
     return template;
 }
        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();
                
        }
Example #3
0
 public SendDestinationCallback(EmsTemplate jmsTemplate, string destinationName, IMessageCreator messageCreator)
 {
     this.jmsTemplate = jmsTemplate;
     this.destinationName = destinationName;
     this.messageCreator = messageCreator;
 }
Example #4
0
 public SimpleMessageCreator(EmsTemplate jmsTemplate, object objectToConvert)
 {
     this.jmsTemplate = jmsTemplate;
     this.objectToConvert = objectToConvert;
 }
Example #5
0
 public ReceiveSelectedCallback(EmsTemplate jmsTemplate,
                                string destinationName,
                                string messageSelector)
 {
     this.jmsTemplate = jmsTemplate;
     this.destinationName = destinationName;
     this.messageSelector = messageSelector;
 }
Example #6
0
 public ConvertAndSendMessageCreator(EmsTemplate jmsTemplate, object message, MessagePostProcessorDelegate messagePostProcessorDelegate)
 {
     this.jmsTemplate = jmsTemplate;
     objectToConvert = message;
     this.messagePostProcessorDelegate = messagePostProcessorDelegate;
 }
Example #7
0
 public ConvertAndSendMessageCreator(EmsTemplate jmsTemplate, object message, IMessagePostProcessor messagePostProcessor)
 {
     this.jmsTemplate = jmsTemplate;
     objectToConvert = message;
     this.messagePostProcessor = messagePostProcessor;
 }
        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();

        }
Example #9
0
 public SendDestinationCallback(EmsTemplate jmsTemplate, Destination destination, MessageCreatorDelegate messageCreatorDelegate)
 {
     this.jmsTemplate = jmsTemplate;
     this.destination = destination;
     this.messageCreatorDelegate = messageCreatorDelegate;
 }
Example #10
0
 public ProducerCreatorCallback(EmsTemplate jmsTemplate, ProducerDelegate producerDelegate)
 {
     this.jmsTemplate = jmsTemplate;
     this.producerDelegate = producerDelegate;
 }
Example #11
0
            public ProducerCreatorCallback(EmsTemplate jmsTemplate, IProducerCallback producerCallback)
            {
                this.jmsTemplate = jmsTemplate;
				this.producerCallback = producerCallback;
            }
Example #12
0
 private void InitBlock(EmsTemplate enclosingInstance)
 {
     enclosingTemplateInstance = enclosingInstance;
 }
Example #13
0
 public EmsTemplateResourceFactory(EmsTemplate enclosingInstance)
 {
     InitBlock(enclosingInstance);
 }
Example #14
0
 public SendDestinationCallback(EmsTemplate jmsTemplate, Destination destination, IMessageCreator messageCreator)
 {
     this.jmsTemplate = jmsTemplate;
     this.destination = destination;
     this.messageCreator = messageCreator;
 }
Example #15
0
 public ReceiveCallback(EmsTemplate jmsTemplate, string destinationName)
 {
     this.jmsTemplate = jmsTemplate;
     this.destinationName = destinationName;
 }
Example #16
0
 public SendDestinationCallback(EmsTemplate jmsTemplate, string destinationName, MessageCreatorDelegate messageCreatorDelegate)
 {
     this.jmsTemplate = jmsTemplate;
     this.destinationName = destinationName;
     this.messageCreatorDelegate = messageCreatorDelegate;
 }
Example #17
0
 public ReceiveCallback(EmsTemplate jmsTemplate, Destination destination)
 {
     this.jmsTemplate = jmsTemplate;
     this.destination = destination;
 }
Example #18
0
 public SimplePublisher()
 {
     emsTemplate = new EmsTemplate(new EmsConnectionFactory("tcp://localhost:7222"));
 }
        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();
        }