Added StubProducer.
This commit is contained in:
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.jms;
|
||||
|
||||
import javax.jms.Destination;
|
||||
import javax.jms.InvalidDestinationException;
|
||||
import javax.jms.JMSException;
|
||||
import javax.jms.Message;
|
||||
import javax.jms.MessageProducer;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class StubProducer implements MessageProducer {
|
||||
|
||||
private Message lastMessageSent;
|
||||
|
||||
private Destination staticDestination;
|
||||
|
||||
|
||||
public StubProducer(Destination destination) {
|
||||
this.staticDestination = destination;
|
||||
}
|
||||
|
||||
|
||||
public Message getLastMessageSent() {
|
||||
return this.lastMessageSent;
|
||||
}
|
||||
|
||||
public void close() throws JMSException {
|
||||
}
|
||||
|
||||
public int getDeliveryMode() throws JMSException {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public Destination getDestination() throws JMSException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean getDisableMessageID() throws JMSException {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean getDisableMessageTimestamp() throws JMSException {
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getPriority() throws JMSException {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long getTimeToLive() throws JMSException {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void send(Message message) throws JMSException {
|
||||
if (this.staticDestination == null) {
|
||||
throw new UnsupportedOperationException("producer was not created with a static Destination");
|
||||
}
|
||||
this.lastMessageSent = message;
|
||||
}
|
||||
|
||||
public void send(Destination destination, Message message) throws JMSException {
|
||||
if (this.staticDestination != null) {
|
||||
throw new UnsupportedOperationException("producer was created with a static Destination");
|
||||
}
|
||||
if (destination == null) {
|
||||
throw new InvalidDestinationException("null destination");
|
||||
}
|
||||
this.lastMessageSent = message;
|
||||
}
|
||||
|
||||
public void send(Message message, int deliveryMode, int priority, long timeToLive) throws JMSException {
|
||||
if (this.staticDestination == null) {
|
||||
throw new UnsupportedOperationException("producer was not created with a static Destination");
|
||||
}
|
||||
this.lastMessageSent = message;
|
||||
}
|
||||
|
||||
public void send(Destination destination, Message message,
|
||||
int deliveryMode, int priority, long timeToLive) throws JMSException {
|
||||
if (this.staticDestination != null) {
|
||||
throw new UnsupportedOperationException("producer was created with a static Destination");
|
||||
}
|
||||
if (destination == null) {
|
||||
throw new InvalidDestinationException("null destination");
|
||||
}
|
||||
this.lastMessageSent = message;
|
||||
}
|
||||
|
||||
public void setDeliveryMode(int deliveryMode) throws JMSException {
|
||||
}
|
||||
|
||||
public void setDisableMessageID(boolean value) throws JMSException {
|
||||
}
|
||||
|
||||
public void setDisableMessageTimestamp(boolean value) throws JMSException {
|
||||
}
|
||||
|
||||
public void setPriority(int defaultPriority) throws JMSException {
|
||||
}
|
||||
|
||||
public void setTimeToLive(long timeToLive) throws JMSException {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -107,7 +107,7 @@ public class StubSession implements Session {
|
||||
}
|
||||
|
||||
public MessageProducer createProducer(Destination destination) throws JMSException {
|
||||
return null;
|
||||
return new StubProducer(destination);
|
||||
}
|
||||
|
||||
public Queue createQueue(String queueName) throws JMSException {
|
||||
@@ -131,7 +131,7 @@ public class StubSession implements Session {
|
||||
}
|
||||
|
||||
public TextMessage createTextMessage(String text) throws JMSException {
|
||||
return null;
|
||||
return new StubTextMessage(text);
|
||||
}
|
||||
|
||||
public Topic createTopic(String topicName) throws JMSException {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -38,6 +38,14 @@ public class StubTextMessage implements TextMessage {
|
||||
private ConcurrentHashMap<String, Object> properties = new ConcurrentHashMap<String, Object>();
|
||||
|
||||
|
||||
public StubTextMessage() {
|
||||
}
|
||||
|
||||
public StubTextMessage(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
|
||||
public String getText() throws JMSException {
|
||||
return this.text;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user