1 package com.mockobjects.jms; 2 3 import com.mockobjects.*; 4 import javax.jms.*; 5 6 public abstract class MockMessage extends MockObject implements Message { 7 8 protected ExpectationCounter myAcknowledgeCount = 9 new ExpectationCounter("MockMessage.acknowledge"); 10 protected ExpectationValue myJMSReplyTo = 11 new ExpectationValue("MockMessage.setJMSReplyTo"); 12 protected ExpectationCounter mySetJMSCorrelationIDCalls = 13 new ExpectationCounter("MockMessage.setJMSCorrelationID"); 14 15 private JMSException myException; 16 19 private final ReturnValue myJMSMessageID = new ReturnValue("messageID / correlationID"); 20 21 public void acknowledge() throws JMSException { 22 myAcknowledgeCount.inc(); 23 } 24 25 public void setExpectedAcknowledgeCalls(int calls) { 26 myAcknowledgeCount.setExpected(calls); 27 } 28 29 public void clearBody() { 30 notImplemented(); 31 } 32 33 public void clearProperties() { 34 notImplemented(); 35 } 36 37 public boolean getBooleanProperty(String name) { 38 notImplemented(); 39 return false; 40 } 41 42 public byte getByteProperty(String name) { 43 notImplemented(); 44 return 0; 45 } 46 47 public double getDoubleProperty(String name) { 48 notImplemented(); 49 return 0; 50 } 51 52 public float getFloatProperty(String name) { 53 notImplemented(); 54 return 0; 55 } 56 57 public int getIntProperty(String name) { 58 notImplemented(); 59 return 0; 60 } 61 62 public String getJMSCorrelationID() { 63 return (String )myJMSMessageID.getValue(); 64 } 65 66 public byte[] getJMSCorrelationIDAsBytes() { 67 notImplemented(); 68 return null; 69 } 70 71 public int getJMSDeliveryMode() { 72 notImplemented(); 73 return 0; 74 } 75 76 public Destination getJMSDestination() { 77 notImplemented(); 78 return null; 79 } 80 81 public long getJMSExpiration() { 82 notImplemented(); 83 return 0; 84 } 85 86 public String getJMSMessageID() { 87 return (String )myJMSMessageID.getValue(); 88 } 89 90 public int getJMSPriority() { 91 notImplemented(); 92 return 0; 93 } 94 95 public boolean getJMSRedelivered() { 96 notImplemented(); 97 return false; 98 } 99 100 public Destination getJMSReplyTo() { 101 notImplemented(); 102 return null; 103 } 104 105 public long getJMSTimestamp() { 106 notImplemented(); 107 return 0; 108 } 109 110 public String getJMSType() { 111 notImplemented(); 112 return null; 113 } 114 115 public long getLongProperty(String name) { 116 notImplemented(); 117 return 0; 118 } 119 120 public Object getObjectProperty(String name) { 121 notImplemented(); 122 return null; 123 } 124 125 public java.util.Enumeration getPropertyNames() { 126 notImplemented(); 127 return null; 128 } 129 130 public short getShortProperty(String name) { 131 notImplemented(); 132 return 0; 133 } 134 135 public String getStringProperty(String name) { 136 notImplemented(); 137 return null; 138 } 139 140 public boolean propertyExists(String name) { 141 notImplemented(); 142 return false; 143 } 144 145 public void setBooleanProperty(String name, boolean value) { 146 notImplemented(); 147 } 148 149 public void setByteProperty(String name, byte value) { 150 notImplemented(); 151 } 152 153 public void setDoubleProperty(String name, double value) { 154 notImplemented(); 155 } 156 157 public void setFloatProperty(String name, float value) { 158 notImplemented(); 159 } 160 161 public void setIntProperty(String name, int value) { 162 notImplemented(); 163 } 164 165 public void setJMSCorrelationID(String jmsCorrelationID) { 166 mySetJMSCorrelationIDCalls.inc(); 167 } 168 169 public void setJMSCorrelationIDAsBytes(byte[] correlationID) { 170 notImplemented(); 171 } 172 173 public void setJMSDeliveryMode(int deliveryMode) { 174 notImplemented(); 175 } 176 177 public void setJMSDestination(Destination destination) { 178 notImplemented(); 179 } 180 181 public void setJMSExpiration(long expiration) { 182 notImplemented(); 183 } 184 185 public void setJMSMessageID(String id) { 186 notImplemented(); 187 } 188 189 public void setJMSPriority(int priority) { 190 notImplemented(); 191 } 192 193 public void setJMSRedelivered(boolean redelivered) { 194 notImplemented(); 195 } 196 197 public void setJMSReplyTo(Destination replyTo) throws JMSException { 198 throwExceptionIfAny(); 199 myJMSReplyTo.setActual(replyTo); 200 } 201 202 public void setJMSTimestamp(long timestamp) { 203 notImplemented(); 204 } 205 206 public void setJMSType(String type) { 207 notImplemented(); 208 } 209 210 public void setLongProperty(String name, long value) { 211 notImplemented(); 212 } 213 214 public void setObjectProperty(String name, Object value) { 215 notImplemented(); 216 } 217 218 public void setShortProperty(String name, short value) { 219 notImplemented(); 220 } 221 222 public void setStringProperty(String name, String value) { 223 notImplemented(); 224 } 225 226 public void setExpectedJMSReplyTo(Destination expectedJMSReplyTo) { 227 myJMSReplyTo.setExpected(expectedJMSReplyTo); 228 } 229 230 public void setExpectedSetJMSCorrelationIDCalls(int callCount) { 231 mySetJMSCorrelationIDCalls.setExpected(callCount); 232 } 233 234 public void setupJMSMessageID(String jmsMessageID) { 235 myJMSMessageID.setValue(jmsMessageID); 236 } 237 238 public void setupThrowException(JMSException e) { 239 myException = e; 240 } 241 242 protected void throwExceptionIfAny() throws JMSException { 243 if (null != myException) { 244 throw myException; 245 } 246 } 247 } 248 249 | Popular Tags |