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(); }
public SendDestinationCallback(EmsTemplate jmsTemplate, string destinationName, IMessageCreator messageCreator) { this.jmsTemplate = jmsTemplate; this.destinationName = destinationName; this.messageCreator = messageCreator; }
public SimpleMessageCreator(EmsTemplate jmsTemplate, object objectToConvert) { this.jmsTemplate = jmsTemplate; this.objectToConvert = objectToConvert; }
public ReceiveSelectedCallback(EmsTemplate jmsTemplate, string destinationName, string messageSelector) { this.jmsTemplate = jmsTemplate; this.destinationName = destinationName; this.messageSelector = messageSelector; }
public ConvertAndSendMessageCreator(EmsTemplate jmsTemplate, object message, MessagePostProcessorDelegate messagePostProcessorDelegate) { this.jmsTemplate = jmsTemplate; objectToConvert = message; this.messagePostProcessorDelegate = messagePostProcessorDelegate; }
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(); }
public SendDestinationCallback(EmsTemplate jmsTemplate, Destination destination, MessageCreatorDelegate messageCreatorDelegate) { this.jmsTemplate = jmsTemplate; this.destination = destination; this.messageCreatorDelegate = messageCreatorDelegate; }
public ProducerCreatorCallback(EmsTemplate jmsTemplate, ProducerDelegate producerDelegate) { this.jmsTemplate = jmsTemplate; this.producerDelegate = producerDelegate; }
public ProducerCreatorCallback(EmsTemplate jmsTemplate, IProducerCallback producerCallback) { this.jmsTemplate = jmsTemplate; this.producerCallback = producerCallback; }
private void InitBlock(EmsTemplate enclosingInstance) { enclosingTemplateInstance = enclosingInstance; }
public EmsTemplateResourceFactory(EmsTemplate enclosingInstance) { InitBlock(enclosingInstance); }
public SendDestinationCallback(EmsTemplate jmsTemplate, Destination destination, IMessageCreator messageCreator) { this.jmsTemplate = jmsTemplate; this.destination = destination; this.messageCreator = messageCreator; }
public ReceiveCallback(EmsTemplate jmsTemplate, string destinationName) { this.jmsTemplate = jmsTemplate; this.destinationName = destinationName; }
public SendDestinationCallback(EmsTemplate jmsTemplate, string destinationName, MessageCreatorDelegate messageCreatorDelegate) { this.jmsTemplate = jmsTemplate; this.destinationName = destinationName; this.messageCreatorDelegate = messageCreatorDelegate; }
public ReceiveCallback(EmsTemplate jmsTemplate, Destination destination) { this.jmsTemplate = jmsTemplate; this.destination = destination; }
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(); }