From: Steve F. <sm...@us...> - 2002-02-23 18:50:38
|
Update of /cvsroot/mockobjects/mockobjects-java/src/j2ee/common/com/mockobjects/jms In directory usw-pr-cvs1:/tmp/cvs-serv6563/src/j2ee/common/com/mockobjects/jms Modified Files: MockConnection.java MockMessageConsumer.java MockSession.java Added Files: MockMessagePublisher.java MockObjectMessage.java MockTopic.java MockTopicConnection.java MockTopicConnectionFactory.java MockTopicPublisher.java MockTopicSession.java MockTopicSubscriber.java Log Message: Reworked build structure for j2ee libraries. --- NEW FILE: MockMessagePublisher.java --- package com.mockobjects.jms; import com.mockobjects.*; import javax.jms.*; public class MockMessagePublisher extends MockObject implements MessageProducer{ public void close() throws JMSException{ notYetImplemented(); } public int getDeliveryMode() throws JMSException{ notYetImplemented(); return -1; } public boolean getDisableMessageID() throws JMSException{ notYetImplemented(); return false; } public boolean getDisableMessageTimestamp() throws JMSException{ notYetImplemented(); return false; } public int getPriority() throws JMSException{ notYetImplemented(); return -1; } public long getTimeToLive() throws JMSException{ notYetImplemented(); return -1; } public void setDeliveryMode(int deliveryMode) throws JMSException{ notYetImplemented(); } public void setDisableMessageID(boolean disableMessageId) throws JMSException{ notYetImplemented(); } public void setDisableMessageTimestamp(boolean disableMessageTimeStamp) throws JMSException{ notYetImplemented(); } public void setPriority(int priority) throws JMSException{ notYetImplemented(); } public void setTimeToLive(long timeToLive) throws JMSException{ notYetImplemented(); } } --- NEW FILE: MockObjectMessage.java --- package com.mockobjects.jms; import java.io.*; import javax.jms.*; public class MockObjectMessage extends MockMessage implements ObjectMessage{ private Serializable objectToReturn; public void setupGetObject(Serializable objectToReturn){ this.objectToReturn = objectToReturn; } public Serializable getObject() throws JMSException{ return objectToReturn; } public void setObject(Serializable serialisable) throws JMSException{ } } --- NEW FILE: MockTopic.java --- package com.mockobjects.jms; import com.mockobjects.*; import javax.jms.*; public class MockTopic extends MockObject implements Topic{ public String getTopicName() throws JMSException{ notYetImplemented(); return null; } } --- NEW FILE: MockTopicConnection.java --- package com.mockobjects.jms; import com.mockobjects.*; import javax.jms.*; public class MockTopicConnection extends MockConnection implements TopicConnection{ private TopicSession topicSessionToReturn; public void setupCreateTopicSession(TopicSession topicSessionToReturn){ this.topicSessionToReturn = topicSessionToReturn; } public ConnectionConsumer createConnectionConsumer(Topic topic, String messageSelector, ServerSessionPool sessionPool, int maxMessages) throws JMSException{ notYetImplemented(); return null; } public ConnectionConsumer createDurableConnectionConsumer(Topic topic, String subscriptionName, String messageSelector, ServerSessionPool sessionPool, int maxMessages) throws JMSException{ notYetImplemented(); return null; } public TopicSession createTopicSession(boolean transacted, int acknowledgeMode) throws JMSException{ return topicSessionToReturn; } } --- NEW FILE: MockTopicConnectionFactory.java --- package com.mockobjects.jms; import com.mockobjects.*; import javax.jms.*; public class MockTopicConnectionFactory extends MockObject implements TopicConnectionFactory{ private TopicConnection topicConnectionToReturn; public void setupCreateTopicConnection( TopicConnection topicConnectionToReturn){ this.topicConnectionToReturn = topicConnectionToReturn; } public TopicConnection createTopicConnection() throws JMSException{ return topicConnectionToReturn; } public TopicConnection createTopicConnection(String userName, String password) throws JMSException{ return topicConnectionToReturn; } } --- NEW FILE: MockTopicPublisher.java --- package com.mockobjects.jms; import javax.jms.*; import com.mockobjects.*; public class MockTopicPublisher extends MockMessagePublisher implements TopicPublisher{ private ExpectationValue message = new ExpectationValue("message"); public void setExpectedMessage(Message message){ this.message.setExpected(message); } public Topic getTopic() throws JMSException{ notYetImplemented(); return null; } public void publish(Message message) throws JMSException{ this.message.setActual(message); } public void publish(Message message, int deliveryMode, int priority, long timeToLive) throws JMSException{ this.message.setActual(message); } public void publish(Topic topic, Message message) throws JMSException{ this.message.setActual(message); } public void publish(Topic topic, Message message, int deliveryMode, int priority, long timeToLive) throws JMSException{ this.message.setActual(message); } } --- NEW FILE: MockTopicSession.java --- package com.mockobjects.jms; import com.mockobjects.*; import javax.jms.*; public class MockTopicSession extends MockSession implements TopicSession{ private Topic topicToReturn; private ExpectationValue topicName = new ExpectationValue("topicName"); private ExpectationCounter createTopicCalls = new ExpectationCounter("createTopicCalls"); private TopicPublisher topicPublisherToReturn; private TopicSubscriber topicSubscriberToReturn; public void setupCreateTopic(Topic topicToReturn){ this.topicToReturn = topicToReturn; } public void setExpectedTopicName(String topicName){ this.topicName.setExpected(topicName); } public void setupCreateTopicCalls(int createTopicCalls){ this.createTopicCalls.setExpected(createTopicCalls); } public TopicSubscriber createDurableSubscriber(Topic topic, String name) throws JMSException{ notYetImplemented(); return null; } public TopicSubscriber createDurableSubscriber(Topic topic, String name, String messsageSelecter, boolean noLocal) throws JMSException{ notYetImplemented(); return null; } public void setupCreatePublisher(TopicPublisher topicPublisherToReturn){ this.topicPublisherToReturn = topicPublisherToReturn; } public TopicPublisher createPublisher(Topic topic) throws JMSException{ return topicPublisherToReturn; } public void setupTopicSubscriber(TopicSubscriber topicSubscriberToReturn){ this.topicSubscriberToReturn = topicSubscriberToReturn; } public TopicSubscriber createSubscriber(Topic topic) throws JMSException{ return topicSubscriberToReturn; } public TopicSubscriber createSubscriber(Topic topic, String messsageSelecter, boolean noLocal) throws JMSException{ return topicSubscriberToReturn; } public TemporaryTopic createTemporaryTopic() throws JMSException{ notYetImplemented(); return null; } public Topic createTopic(String topicName) throws JMSException{ this.topicName.setActual(topicName); this.createTopicCalls.inc(); return topicToReturn; } public void unsubscribe(String topicName) throws JMSException{ notYetImplemented(); } } --- NEW FILE: MockTopicSubscriber.java --- package com.mockobjects.jms; import javax.jms.*; import com.mockobjects.*; public class MockTopicSubscriber extends MockMessageConsumer implements TopicSubscriber{ public boolean getNoLocal() throws JMSException{ notYetImplemented(); return false; } public Topic getTopic() throws JMSException{ notYetImplemented(); return null; } } Index: MockConnection.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/j2ee/common/com/mockobjects/jms/MockConnection.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- MockConnection.java 22 Feb 2002 16:25:05 -0000 1.1 +++ MockConnection.java 23 Feb 2002 18:50:35 -0000 1.2 @@ -77,4 +77,4 @@ throw myException; } } -} \ No newline at end of file +} Index: MockMessageConsumer.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/j2ee/common/com/mockobjects/jms/MockMessageConsumer.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- MockMessageConsumer.java 22 Feb 2002 16:25:05 -0000 1.1 +++ MockMessageConsumer.java 23 Feb 2002 18:50:35 -0000 1.2 @@ -3,91 +3,97 @@ import com.mockobjects.*; import javax.jms.*; -public abstract class MockMessageConsumer extends MockObject implements MessageConsumer { +public class MockMessageConsumer extends MockObject implements MessageConsumer{ + private Message myMessage; + private boolean myExpiresOnTimeout = false; + private JMSException myException; + protected ExpectationCounter myCloseCalls = + new ExpectationCounter("MockMessageConsumer.close"); + protected ExpectationCounter myReceiveCalls = + new ExpectationCounter("MockMessageConsumer.receive"); + private ExpectationValue messageListener = + new ExpectationValue("messageListener"); - protected ExpectationCounter myCloseCalls = new ExpectationCounter("MockMessageConsumer.close"); - protected ExpectationCounter myReceiveCalls = new ExpectationCounter("MockMessageConsumer.receive"); + public void setExpectedMessageListener(MessageListener messageListener){ + this.messageListener.setExpected(messageListener); + } + + public void close() throws JMSException { + throwExceptionIfAny(); + myCloseCalls.inc(); + } + + public MessageListener getMessageListener() throws JMSException { + notImplemented(); + return null; + } + + public String getMessageSelector() throws JMSException { + notImplemented(); + return null; + } - private Message myMessage; - private boolean myExpiresOnTimeout = false; - private JMSException myException; - - public MockMessageConsumer() { - } - - public void close() throws JMSException { - throwExceptionIfAny(); - myCloseCalls.inc(); - } - - public MessageListener getMessageListener() throws JMSException { - notImplemented(); - return null; - } - - public String getMessageSelector() throws JMSException { - notImplemented(); - return null; - } - - public Message receive() throws JMSException { - throwExceptionIfAny(); - myReceiveCalls.inc(); - if (myExpiresOnTimeout) { - synchronized(this) { - try { - wait(); - } catch (InterruptedException e) { - throw new junit.framework.AssertionFailedError("Thread interrupted"); + public Message receive() throws JMSException { + throwExceptionIfAny(); + myReceiveCalls.inc(); + if (myExpiresOnTimeout) { + synchronized(this) { + try { + wait(); + } catch (InterruptedException e) { + throw new junit.framework.AssertionFailedError( + "Thread interrupted"); + } + } } - } + return myMessage; + } + + public Message receive(long timeout) throws JMSException { + throwExceptionIfAny(); + myReceiveCalls.inc(); + if (myExpiresOnTimeout) { + return null; + } else { + return myMessage; + } + } + + + public Message receiveNoWait() throws JMSException { + throwExceptionIfAny(); + myReceiveCalls.inc(); + return myMessage; } - return myMessage; - } - public Message receive(long timeout) throws JMSException { - throwExceptionIfAny(); - myReceiveCalls.inc(); - if (myExpiresOnTimeout) { - return null; - } else { - return myMessage; - } - } - - public Message receiveNoWait() throws JMSException { - throwExceptionIfAny(); - myReceiveCalls.inc(); - return myMessage; - } - - public void setMessageListener(MessageListener listener) throws JMSException { - notImplemented(); - } - - public void setExpectedCloseCalls(int callCount) { - myCloseCalls.setExpected(callCount); - } - - public void setExpectedReceiveCalls(int callCount) { - myReceiveCalls.setExpected(callCount); - } - - public void setupReceivedMessage(Message message) { - myMessage = message; - } - - public void setupExpiresOnTimeout(boolean expiresOnTimeout) { - myExpiresOnTimeout = expiresOnTimeout; - } - - public void setupThrowException(JMSException e) { - myException = e; - } - - protected void throwExceptionIfAny() throws JMSException { - if (null != myException) { - throw myException; + public void setExpectedCloseCalls(int callCount) { + myCloseCalls.setExpected(callCount); + } + + public void setExpectedReceiveCalls(int callCount) { + myReceiveCalls.setExpected(callCount); + } + + public void setupReceivedMessage(Message message) { + myMessage = message; + } + + public void setupExpiresOnTimeout(boolean expiresOnTimeout) { + myExpiresOnTimeout = expiresOnTimeout; + } + + public void setupThrowException(JMSException e) { + myException = e; + } + + public void setMessageListener(MessageListener messageListener) + throws JMSException{ + this.messageListener.setActual(messageListener); + } + + protected void throwExceptionIfAny() throws JMSException { + if (null != myException) { + throw myException; + } } - } -} \ No newline at end of file +} Index: MockSession.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/j2ee/common/com/mockobjects/jms/MockSession.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- MockSession.java 22 Feb 2002 16:25:05 -0000 1.1 +++ MockSession.java 23 Feb 2002 18:50:35 -0000 1.2 @@ -6,109 +6,113 @@ public class MockSession extends MockObject implements Session { - protected ExpectationCounter myCloseCalls = new ExpectationCounter("MockSession.close"); - protected ExpectationCounter myCreateTextMessageCalls = new ExpectationCounter("MockSession.createTextMessage"); + protected ExpectationCounter myCloseCalls = + new ExpectationCounter("MockSession.close"); + protected ExpectationCounter myCreateTextMessageCalls = + new ExpectationCounter("MockSession.createTextMessage"); + + private TextMessage myTextMessage = new MockTextMessage(); + private JMSException myException; + private ObjectMessage objectMessageToReturn; - private TextMessage myTextMessage = new MockTextMessage(); - private JMSException myException; + public void setupCreateObjectMessage(ObjectMessage objectMessageToReturn){ + this.objectMessageToReturn = objectMessageToReturn; + } + + public ObjectMessage createObjectMessage() throws JMSException { + return objectMessageToReturn; + } + + public ObjectMessage createObjectMessage(Serializable object) + throws JMSException { + return objectMessageToReturn; + } + + public void rollback() throws JMSException { + notImplemented(); + } + + public void setupTextMessage(TextMessage textMessage) { + myTextMessage = textMessage; + } + + public BytesMessage createBytesMessage() throws JMSException { + notImplemented(); + return null; + } + + public MapMessage createMapMessage() throws JMSException { + notImplemented(); + return null; + } + + public Message createMessage() throws JMSException { + notImplemented(); + return null; + } + + public boolean getTransacted() throws JMSException { + notImplemented(); + return false; + } + + public void recover() throws JMSException { + notImplemented(); + } + + public void close() throws JMSException { + throwExceptionIfAny(); + myCloseCalls.inc(); + } + + public void commit() throws JMSException { + notImplemented(); + } + + public void setMessageListener(MessageListener listener) + throws JMSException { + notImplemented(); + } + + public void setExpectedCloseCalls(int callCount) { + myCloseCalls.setExpected(callCount); + } + + public void setExpectedCreateTextMessageCalls(int callCount) { + myCreateTextMessageCalls.setExpected(callCount); + } + + public StreamMessage createStreamMessage() throws JMSException { + notImplemented(); + return null; + } + + public TextMessage createTextMessage() throws JMSException { + myCreateTextMessageCalls.inc(); + return myTextMessage; + } + + public TextMessage createTextMessage(String text) throws JMSException { + myTextMessage.setText(text); + return myTextMessage; + } - public MockSession() { - } + public MessageListener getMessageListener() throws JMSException { + notImplemented(); + return null; + } + + public void run() { + notImplemented(); + } + + public void setupThrowException(JMSException e) { + myException = e; + } - public void close() throws JMSException { - throwExceptionIfAny(); - myCloseCalls.inc(); - } - - public void commit() throws JMSException { - notImplemented(); - } - - public BytesMessage createBytesMessage() throws JMSException { - notImplemented(); - return null; - } - - public MapMessage createMapMessage() throws JMSException { - notImplemented(); - return null; - } - - public Message createMessage() throws JMSException { - notImplemented(); - return null; - } - - public ObjectMessage createObjectMessage() throws JMSException { - notImplemented(); - return null; - } - - public ObjectMessage createObjectMessage(Serializable object) throws JMSException { - notImplemented(); - return null; - } - - public StreamMessage createStreamMessage() throws JMSException { - notImplemented(); - return null; - } - - public TextMessage createTextMessage() throws JMSException { - myCreateTextMessageCalls.inc(); - return myTextMessage; - } - - public TextMessage createTextMessage(String text) throws JMSException { - myTextMessage.setText(text); - return myTextMessage; - } - - public MessageListener getMessageListener() throws JMSException { - notImplemented(); - return null; - } - - public boolean getTransacted() throws JMSException { - notImplemented(); - return false; - } - - public void recover() throws JMSException { - notImplemented(); - } - - public void rollback() throws JMSException { - notImplemented(); - } - - public void run() { - notImplemented(); - } - - public void setMessageListener(MessageListener listener) throws JMSException { - notImplemented(); - } - - public void setExpectedCloseCalls(int callCount) { - myCloseCalls.setExpected(callCount); - } - - public void setExpectedCreateTextMessageCalls(int callCount) { - myCreateTextMessageCalls.setExpected(callCount); - } - - public void setupTextMessage(TextMessage textMessage) { - myTextMessage = textMessage; - } - - public void setupThrowException(JMSException e) { - myException = e; - } - - protected void throwExceptionIfAny() throws JMSException { - if (null != myException) { - throw myException; + protected void throwExceptionIfAny() throws JMSException { + if (null != myException) { + throw myException; + } } - } -} \ No newline at end of file +} |