You can subscribe to this list here.
2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(13) |
Aug
(151) |
Sep
(21) |
Oct
(6) |
Nov
(70) |
Dec
(8) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2002 |
Jan
(47) |
Feb
(66) |
Mar
(23) |
Apr
(115) |
May
(24) |
Jun
(53) |
Jul
(10) |
Aug
(279) |
Sep
(84) |
Oct
(149) |
Nov
(138) |
Dec
(52) |
2003 |
Jan
(22) |
Feb
(20) |
Mar
(29) |
Apr
(106) |
May
(170) |
Jun
(122) |
Jul
(70) |
Aug
(64) |
Sep
(27) |
Oct
(71) |
Nov
(49) |
Dec
(9) |
2004 |
Jan
(7) |
Feb
(38) |
Mar
(3) |
Apr
(9) |
May
(22) |
Jun
(4) |
Jul
(1) |
Aug
(2) |
Sep
(2) |
Oct
|
Nov
(15) |
Dec
(2) |
2005 |
Jan
(1) |
Feb
(1) |
Mar
|
Apr
(1) |
May
(28) |
Jun
(3) |
Jul
(11) |
Aug
(5) |
Sep
(1) |
Oct
(5) |
Nov
(2) |
Dec
(3) |
2006 |
Jan
(8) |
Feb
(3) |
Mar
(8) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Jeff M. <cus...@us...> - 2003-08-11 09:29:40
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects In directory sc8-pr-cvs1:/tmp/cvs-serv20940/src/core/com/mockobjects Modified Files: AbstractExpectationCollection.java ExpectationCollection.java Log Message: Added long support to collections Index: AbstractExpectationCollection.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/AbstractExpectationCollection.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- AbstractExpectationCollection.java 18 May 2003 20:59:36 -0000 1.7 +++ AbstractExpectationCollection.java 11 Aug 2003 09:29:37 -0000 1.8 @@ -24,7 +24,7 @@ public void addActualMany(Object[] items) { if(items == null) return; - + for (int i = 0; i < items.length; ++i) { addActual(items[i]); } @@ -96,5 +96,13 @@ "did not receive the expected collection items.", new HashSet(getExpectedCollection()), new HashSet(getActualCollection())); + } + + public void addActual(long actual) { + addActual(new Long(actual)); + } + + public void addExpected(long expected) { + addExpected(new Long(expected)); } } Index: ExpectationCollection.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/ExpectationCollection.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ExpectationCollection.java 27 Aug 2001 01:14:31 -0000 1.2 +++ ExpectationCollection.java 11 Aug 2003 09:29:37 -0000 1.3 @@ -14,6 +14,8 @@ void addActual(Object actual); + void addActual(long actual); + void addActualMany(Object[] actuals); void addActualMany(Enumeration actuals); @@ -22,6 +24,8 @@ void addExpected(Object expected); + + void addExpected(long expected); void addExpectedMany(Object[] expectedItems); |
From: Jeff M. <cus...@us...> - 2003-08-11 09:29:40
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects In directory sc8-pr-cvs1:/tmp/cvs-serv20940/src/core/test/mockobjects Modified Files: TestExpectationCollection.java Log Message: Added long support to collections Index: TestExpectationCollection.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/TestExpectationCollection.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- TestExpectationCollection.java 21 Oct 2002 22:52:38 -0000 1.1 +++ TestExpectationCollection.java 11 Aug 2003 09:29:38 -0000 1.2 @@ -179,4 +179,13 @@ assertVerifyFails(myExpectation); } + + public void testExpectingALong(){ + final long expectedLong = 666l; + + myExpectation.addExpected(expectedLong); + myExpectation.addActual(expectedLong); + + myExpectation.verify(); + } } |
From: Jeff M. <cus...@us...> - 2003-08-11 09:16:46
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects In directory sc8-pr-cvs1:/tmp/cvs-serv19045/src/core/test/mockobjects Added Files: TestReturnObjectMap.java Log Message: Added Return map --- NEW FILE: TestReturnObjectMap.java --- package test.mockobjects; import com.mockobjects.ReturnObjectMap; import com.mockobjects.util.TestCaseMo; import junit.framework.AssertionFailedError; public class TestReturnObjectMap extends TestCaseMo { private final ReturnObjectMap map = new ReturnObjectMap(getName()); private static final String KEY1 = "key1"; private static final String KEY2 = "key2"; private static final short SHORT_KEY1 = 1; private static final short SHORT_KEY2 = 2; private static final String VALUE_ONE = "one"; private static final String VALUE_TWO = "two"; public TestReturnObjectMap(String name) { super(name); } public static void main(String[] args) { start(new String[] { TestReturnObjectMap.class.getName()}); } public void testLeftoverObjectFails() { map.putReturnValue(KEY1, VALUE_ONE); assertVerifyFails(map); } public void testEmptyList() { map.verify(); } public void testReturnSucceeds() { map.putReturnValue(KEY1, VALUE_ONE); map.putReturnValue(KEY2, VALUE_TWO); assertEquals("Should be first result", VALUE_ONE, map.getValue(KEY1)); assertEquals("Should be second result", VALUE_TWO, map.getValue(KEY2)); map.verify(); } public void testReturnInt() { map.putReturnValue(KEY1, 1); assertEquals("Should be 1", 1, map.getIntValue(KEY1)); map.verify(); } public void testReturnBoolean() { map.putReturnValue(KEY1, true); assertEquals("Should be true", true, map.getBooleanValue(KEY1)); map.verify(); } public void testShortKey(){ map.putReturnValue(SHORT_KEY1, VALUE_ONE); map.putReturnValue(SHORT_KEY2, VALUE_TWO); assertEquals("Should be first result", VALUE_ONE, map.getValue(SHORT_KEY1)); assertEquals("Should be second result", VALUE_TWO, map.getValue(SHORT_KEY2)); map.verify(); } public void testNoListForKey(){ try { map.getValue(KEY1); fail("AssertionFiledError not thrown"); } catch (AssertionFailedError e) { assertEquals(getName() + " does not contain key1", e.getMessage()); } } public void testNullKey(){ map.putReturnValue(null, VALUE_ONE); assertEquals(VALUE_ONE, map.getValue(null)); } public void testManyReturns() { map.putReturnValue(KEY1, VALUE_ONE); assertEquals(map.getValue(KEY1),map.getValue(KEY1)); } } |
From: Jeff M. <cus...@us...> - 2003-08-11 09:16:46
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects In directory sc8-pr-cvs1:/tmp/cvs-serv19045/src/core/com/mockobjects Added Files: ReturnObjectMap.java Log Message: Added Return map --- NEW FILE: ReturnObjectMap.java --- package com.mockobjects; import com.mockobjects.util.AssertMo; import com.mockobjects.util.Null; import java.util.Hashtable; import java.util.Enumeration; /** * @version $Revision: 1.1 $ */ public class ReturnObjectMap extends MockObject { private final Hashtable returnValues = new Hashtable(); private final String name; public ReturnObjectMap(String name) { this.name = name; } public Object getValue(Object key) { if (key == null) { key = Null.NULL; } AssertMo.assertTrue(name + " does not contain " + key.toString(), returnValues.containsKey(key)); return ((CallCounter) returnValues.get(key)).getValue(); } public Object getValue(short key) { return getValue(new Short(key)); } public void putReturnValue(Object key, Object value) { returnValues.put(key != null ? key : Null.NULL, new CallCounter(key, value)); } public void putReturnValue(Object key, int value) { putReturnValue(key, new Integer(value)); } public void putReturnValue(short key, Object value) { putReturnValue(new Short(key), value); } public void putReturnValue(Object key, boolean value) { putReturnValue(key, new Boolean(value)); } public int getIntValue(Object key) { return ((Integer) getValue(key)).intValue(); } public boolean getBooleanValue(String key) { return ((Boolean) getValue(key)).booleanValue(); } private class CallCounter implements Verifiable { private int count = 0; private final Object value; private final Object key; public CallCounter(Object key, Object value) { this.key = key; this.value = value; } public Object getValue() { count++; return value; } public void verify() { AssertMo.assertTrue("Object never called for key: " + key, count > 0); } } public void verify() { super.verify(); for (Enumeration enumeration = returnValues.elements(); enumeration.hasMoreElements();) { ((Verifiable) enumeration.nextElement()).verify(); } } } |
From: Jeff M. <cus...@us...> - 2003-08-11 09:16:33
|
Update of /cvsroot/mockobjects/mockobjects-java/src/jdk/common/com/mockobjects/io In directory sc8-pr-cvs1:/tmp/cvs-serv19213/src/jdk/common/com/mockobjects/io Modified Files: MockFile.java MockIOFactory.java Log Message: Added mkdir for MockFile Index: MockFile.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/jdk/common/com/mockobjects/io/MockFile.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- MockFile.java 25 Jun 2003 09:20:28 -0000 1.7 +++ MockFile.java 11 Aug 2003 09:16:30 -0000 1.8 @@ -30,6 +30,8 @@ private final ReturnValue myPath = new ReturnValue("path"); private final ReturnValue absolutePath = new ReturnValue("absolute path"); private final ReturnValue length = new ReturnValue("length"); + private final ReturnValue lastModified = new ReturnValue("last modified"); + private final ReturnValue mkdir = new ReturnValue("mkdir"); public void setupGetName(final String name) { this.fileName.setValue(name); @@ -128,7 +130,7 @@ public boolean exists() { return exists.getBooleanValue(); } - + public void setupIsDirectory(boolean isDir) { this.isDirectory.setValue(isDir); } @@ -136,7 +138,7 @@ public boolean isDirectory() { return isDirectory.getBooleanValue(); } - + public void setupIsFile(boolean isFile) { this.isFile.setValue(isFile); } @@ -151,8 +153,11 @@ } public long lastModified() { - notImplemented(); - return 0; + return lastModified.getLongValue(); + } + + public void setupLastModified(long lastModified){ + this.lastModified.setValue(lastModified); } public void setupLength(long length){ @@ -210,8 +215,11 @@ } public boolean mkdir() { - notImplemented(); - return false; + return mkdir.getBooleanValue(); + } + + public void setupMkdir(boolean returnValue){ + mkdir.setValue(returnValue); } public void setupMkdirs(boolean mkdirs, int count) { Index: MockIOFactory.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/jdk/common/com/mockobjects/io/MockIOFactory.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- MockIOFactory.java 25 Jun 2003 09:22:29 -0000 1.3 +++ MockIOFactory.java 11 Aug 2003 09:16:30 -0000 1.4 @@ -4,18 +4,16 @@ import alt.java.io.IOFactory; import com.mockobjects.*; -import java.io.FileNotFoundException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.Writer; +import java.io.*; +import java.net.URLConnection; +import java.net.URL; public class MockIOFactory extends MockObject implements IOFactory { private final ReturnObjectBag inputStream = new ReturnObjectBag("input stream"); private final ReturnObjectBag outputStream = new ReturnObjectBag("output stream"); private final ReturnObjectList writers = new ReturnObjectList("writers"); - private final ReturnValue file = new ReturnValue("file"); - private final ExpectationValue fileName = new ExpectationValue("file name"); - + private final ReturnObjectBag file = new ReturnObjectBag("file"); + private final ReturnObjectBag connection = new ReturnObjectBag("connection"); public void setupInputStream(File expectedFile, InputStream returnStream) { this.inputStream.putObjectToReturn(expectedFile, returnStream); @@ -33,17 +31,12 @@ return (OutputStream)outputStream.getNextReturnObject(aFile); } - public void setupCreateFile(File file) { - this.file.setValue(file); - } - - public void setExpectedFileName(String fileName){ - this.fileName.setExpected(fileName); + public void setupCreateFile(String fileName, File file) { + this.file.putObjectToReturn(fileName, file); } public File createFile(String fileName) { - this.fileName.setActual(fileName); - return (File)file.getValue(); + return (File)file.getNextReturnObject(fileName); } public Writer createWriter() { @@ -52,5 +45,21 @@ public void setupCreateWriter(Writer writer){ writers.addObjectToReturn(writer); + } + + public URLConnection createConnection(URL aURL) throws IOException { + return (URLConnection) connection.getNextReturnObject(aURL); + } + + public void setupCreateConnection(URL url, URLConnection connection){ + this.connection.putObjectToReturn(url, connection); + } + + public InputStream createInputStream(URLConnection connection) throws IOException { + return (InputStream) inputStream.getNextReturnObject(connection); + } + + public void setupCreateInputStream(URLConnection connection, InputStream inputStream){ + this.inputStream.putObjectToReturn(connection, inputStream); } } |
From: Jeff M. <cus...@us...> - 2003-08-11 09:16:33
|
Update of /cvsroot/mockobjects/mockobjects-java/src/jdk/common/alt/java/io In directory sc8-pr-cvs1:/tmp/cvs-serv19213/src/jdk/common/alt/java/io Modified Files: IOFactory.java IOFactoryImpl.java Log Message: Added mkdir for MockFile Index: IOFactory.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/jdk/common/alt/java/io/IOFactory.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- IOFactory.java 25 Jun 2003 09:22:29 -0000 1.2 +++ IOFactory.java 11 Aug 2003 09:16:30 -0000 1.3 @@ -1,12 +1,15 @@ package alt.java.io; -import java.io.FileNotFoundException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.Writer; +import java.io.*; +import java.net.URL; +import java.net.URLConnection; public interface IOFactory { InputStream createInputStream(File aFile) throws FileNotFoundException; + + URLConnection createConnection(URL aURL) throws IOException; + + InputStream createInputStream(URLConnection connection) throws IOException; OutputStream createOutputStream(File aFile) throws FileNotFoundException; Index: IOFactoryImpl.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/jdk/common/alt/java/io/IOFactoryImpl.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- IOFactoryImpl.java 25 Jun 2003 09:22:29 -0000 1.2 +++ IOFactoryImpl.java 11 Aug 2003 09:16:30 -0000 1.3 @@ -1,16 +1,25 @@ package alt.java.io; import java.io.*; +import java.net.URL; +import java.net.URLConnection; public class IOFactoryImpl implements IOFactory { public InputStream createInputStream(File aFile) throws FileNotFoundException { return new FileInputStream(aFile.getRealFile()); } + public URLConnection createConnection(URL aURL) throws IOException { + return aURL.openConnection(); + } + + public InputStream createInputStream(URLConnection connection) throws IOException { + return connection.getInputStream(); + } + public OutputStream createOutputStream(File aFile) throws FileNotFoundException { return new FileOutputStream(aFile.getRealFile()); } - public File createFile(String fileName) { return new FileImpl(fileName); } |
Update of /cvsroot/mockobjects/mockobjects-java/src/j2ee/common/com/mockobjects/jms In directory sc8-pr-cvs1:/tmp/cvs-serv18822/src/j2ee/common/com/mockobjects/jms Modified Files: MockMessage.java MockObjectMessage.java MockQueueSender.java MockQueueSession.java MockSession.java MockTopicPublisher.java Log Message: Improve implementation of JMS Index: MockMessage.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/j2ee/common/com/mockobjects/jms/MockMessage.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- MockMessage.java 18 Mar 2003 14:28:44 -0000 1.3 +++ MockMessage.java 11 Aug 2003 09:14:38 -0000 1.4 @@ -1,7 +1,9 @@ package com.mockobjects.jms; import com.mockobjects.*; + import javax.jms.*; +import java.util.Enumeration; public abstract class MockMessage extends MockObject implements Message { @@ -13,10 +15,9 @@ new ExpectationCounter("MockMessage.setJMSCorrelationID"); private JMSException myException; - /** - * Used for both messageID and correlationID - */ private final ReturnValue myJMSMessageID = new ReturnValue("messageID / correlationID"); + private final ExpectationSet properties = new ExpectationSet("properties"); + private final ReturnObjectBag returnProperties = new ReturnObjectBag("properties"); public void acknowledge() throws JMSException { myAcknowledgeCount.inc(); @@ -60,7 +61,7 @@ } public String getJMSCorrelationID() { - return (String)myJMSMessageID.getValue(); + return (String) myJMSMessageID.getValue(); } public byte[] getJMSCorrelationIDAsBytes() { @@ -84,7 +85,7 @@ } public String getJMSMessageID() { - return (String)myJMSMessageID.getValue(); + return (String) myJMSMessageID.getValue(); } public int getJMSPriority() { @@ -122,7 +123,7 @@ return null; } - public java.util.Enumeration getPropertyNames() { + public Enumeration getPropertyNames() { notImplemented(); return null; } @@ -133,8 +134,11 @@ } public String getStringProperty(String name) { - notImplemented(); - return null; + return (String)returnProperties.getNextReturnObject(name); + } + + public void setupAddGetStringProperty(String name, String value) { + returnProperties.putObjectToReturn(name, value); } public boolean propertyExists(String name) { @@ -163,7 +167,7 @@ } public void setJMSCorrelationID(String jmsCorrelationID) { - mySetJMSCorrelationIDCalls.inc(); + mySetJMSCorrelationIDCalls.inc(); } public void setJMSCorrelationIDAsBytes(byte[] correlationID) { @@ -195,8 +199,8 @@ } public void setJMSReplyTo(Destination replyTo) throws JMSException { - throwExceptionIfAny(); - myJMSReplyTo.setActual(replyTo); + throwExceptionIfAny(); + myJMSReplyTo.setActual(replyTo); } public void setJMSTimestamp(long timestamp) { @@ -220,7 +224,7 @@ } public void setStringProperty(String name, String value) { - notImplemented(); + properties.addActual(new MapEntry(name, value)); } public void setExpectedJMSReplyTo(Destination expectedJMSReplyTo) { @@ -243,6 +247,10 @@ if (null != myException) { throw myException; } + } + + public void addExpectedProperty(String name, Object value){ + properties.addExpected(new MapEntry(name, value)); } } Index: MockObjectMessage.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/j2ee/common/com/mockobjects/jms/MockObjectMessage.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- MockObjectMessage.java 18 Mar 2003 14:28:44 -0000 1.2 +++ MockObjectMessage.java 11 Aug 2003 09:14:38 -0000 1.3 @@ -18,6 +18,9 @@ } public void setObject(Serializable serialisable) throws JMSException{ + notImplemented(); } + + } Index: MockQueueSender.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/j2ee/common/com/mockobjects/jms/MockQueueSender.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- MockQueueSender.java 22 Feb 2002 16:25:05 -0000 1.1 +++ MockQueueSender.java 11 Aug 2003 09:14:38 -0000 1.2 @@ -1,40 +1,61 @@ package com.mockobjects.jms; import com.mockobjects.*; + import javax.jms.*; public class MockQueueSender extends MockMessageProducer implements QueueSender { - protected ExpectationCounter mySendCalls = new ExpectationCounter("MockQueueSender.send"); - - public MockQueueSender() { - } - - public Queue getQueue() throws JMSException { - notImplemented(); - return null; - } - - public void send(Message message) throws JMSException { - mySendCalls.inc(); - throwExceptionIfAny(); - } - - public void send(Message message, int deliveryMode, int priority, long timeToLive) - throws JMSException { - notImplemented(); - } - - public void send(Queue queue, Message message) throws JMSException { - notImplemented(); - } - - public void send(Queue queue, Message message, int deliveryMode, int priority, long timeToLive) - throws JMSException { - notImplemented(); - } - - public void setExpectedSendCalls(int callCount) { - mySendCalls.setExpected(callCount); - } + protected ExpectationCounter mySendCalls = new ExpectationCounter("MockQueueSender.send"); + private final ExpectationList messages = new ExpectationList("messages"); + private final ExpectationList deliveryModes = new ExpectationList("deliveryModes"); + private final ExpectationList priorities = new ExpectationList("priorities"); + private final ExpectationList timeToLives = new ExpectationList("timeToLives"); + + public Queue getQueue() throws JMSException { + notImplemented(); + return null; + } + + public void send(Message message) throws JMSException { + mySendCalls.inc(); + throwExceptionIfAny(); + } + + public void send(Message message, int deliveryMode, int priority, long timeToLive) + throws JMSException { + messages.addActual(message); + deliveryModes.addActual(deliveryMode); + priorities.addActual(priority); + timeToLives.addActual(timeToLive); + } + + public void addExpectedMessage(Message message) { + messages.addExpected(message); + } + + public void addExpectedDeliveryModes(int deliveryMode) { + deliveryModes.addExpected(deliveryMode); + } + + public void addExpectedPriorities(int priority) { + priorities.addExpected(priority); + } + + public void addExpectedTimeToLive(long timeToLive) { + timeToLives.addExpected(timeToLive); + } + + public void send(Queue queue, Message message) throws JMSException { + notImplemented(); + } + + public void send(Queue queue, Message message, int deliveryMode, int priority, long timeToLive) + throws JMSException { + notImplemented(); + } + + public void setExpectedSendCalls(int callCount) { + mySendCalls.setExpected(callCount); + } } Index: MockQueueSession.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/j2ee/common/com/mockobjects/jms/MockQueueSession.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- MockQueueSession.java 18 Mar 2003 14:28:44 -0000 1.3 +++ MockQueueSession.java 11 Aug 2003 09:14:38 -0000 1.4 @@ -5,29 +5,23 @@ import javax.jms.*; public class MockQueueSession extends MockSession implements QueueSession { - - private final ExpectationValue mySendingQueue = new ExpectationValue("MockQueueSession.createSender"); - private final ExpectationValue myReceivingQueue = new ExpectationValue("MockQueueSession.createReceiver"); - private final ExpectationValue messageSelector = new ExpectationValue("message selector"); private final ExpectationValue queue = new ExpectationValue("queue"); - - private final ReturnValue queueToReturn = new ReturnValue("queue"); - private final ReturnValue myReceiver = new ReturnValue("reciever"); - private final ReturnValue mySender = new ReturnValue("reciever"); - private final ReturnValue myTemporaryQueue = new ReturnValue("reciever"); - private final ReturnValue queueBrowser = new ReturnValue("queue browser"); + private final ReturnObjectMap queueToReturn = new ReturnObjectMap("queue"); + private final ReturnObjectBag myReceiver = new ReturnObjectBag("reciever"); + private final ReturnObjectMap mySender = new ReturnObjectMap("sender"); + private final ReturnValue myTemporaryQueue = new ReturnValue("temporary queue"); + private final ReturnObjectMap queueBrowser = new ReturnObjectMap("queue browser"); public QueueBrowser createBrowser(Queue queue) throws JMSException { - this.queue.setActual(queue); - return (QueueBrowser) queueBrowser.getValue(); + return (QueueBrowser) queueBrowser.getValue(queue); } public void setExpectedQueue(Queue queue) { this.queue.setExpected(queue); } - public void setupCreateQueueBrowser(QueueBrowser browser) { - this.queueBrowser.setValue(browser); + public void setupCreateQueueBrowser(Queue queue, QueueBrowser browser) { + this.queueBrowser.putReturnValue(queue, browser); } public QueueBrowser createBrowser(Queue queue, String messageSelector) throws JMSException { @@ -35,32 +29,28 @@ return null; } - public void setupCreateQueue(Queue queue) { - this.queueToReturn.setValue(queue); + public void setupAddCreateQueue(String queueName, Queue queue) { + this.queueToReturn.putReturnValue(queueName, queue); } public Queue createQueue(String queueName) throws JMSException { throwExceptionIfAny(); - return (Queue) queueToReturn.getValue(); + return (Queue) queueToReturn.getValue(queueName); } public QueueReceiver createReceiver(Queue queue) throws JMSException { throwExceptionIfAny(); - myReceivingQueue.setActual(queue); - return (QueueReceiver) myReceiver.getValue(); + return (QueueReceiver) myReceiver.getNextReturnObject(queue); } public QueueReceiver createReceiver(Queue queue, String messageSelector) throws JMSException { - this.messageSelector.setActual(messageSelector); - myReceivingQueue.setActual(queue); throwExceptionIfAny(); - return (QueueReceiver) myReceiver.getValue(); + return (QueueReceiver) myReceiver.getNextReturnObject(new MapEntry(queue, messageSelector)); } public QueueSender createSender(Queue queue) throws JMSException { - mySendingQueue.setActual(queue); throwExceptionIfAny(); - return (QueueSender) mySender.getValue(); + return (QueueSender) mySender.getValue(queue); } public TemporaryQueue createTemporaryQueue() throws JMSException { @@ -68,27 +58,19 @@ return (TemporaryQueue) myTemporaryQueue.getValue(); } - public void setExpectedSendingQueue(Queue queue) { - mySendingQueue.setExpected(queue); - } - - public void setExpectedReceivingQueue(Queue queue) { - myReceivingQueue.setExpected(queue); + public void setupAddCreateReceiver(Queue queue, QueueReceiver receiver) { + myReceiver.putObjectToReturn(queue, receiver); } - public void setupReceiver(QueueReceiver receiver) { - myReceiver.setValue(receiver); + public void setupAddCreateReceiver(Queue queue, String selector, QueueReceiver receiver) { + myReceiver.putObjectToReturn(new MapEntry(queue, selector), receiver); } - public void setupSender(QueueSender sender) { - mySender.setValue(sender); + public void setupAddCreateSender(Queue queue, QueueSender sender) { + mySender.putReturnValue(queue, sender); } public void setupTemporaryQueue(MockTemporaryQueue temporaryQueue) { myTemporaryQueue.setValue(temporaryQueue); - } - - public void setExpectedMessageSelector(String messageSelector) { - this.messageSelector.setExpected(messageSelector); } } Index: MockSession.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/j2ee/common/com/mockobjects/jms/MockSession.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- MockSession.java 23 Feb 2002 18:50:35 -0000 1.2 +++ MockSession.java 11 Aug 2003 09:14:38 -0000 1.3 @@ -13,19 +13,19 @@ private TextMessage myTextMessage = new MockTextMessage(); private JMSException myException; - private ObjectMessage objectMessageToReturn; + private final ReturnObjectBag objectMessageToReturn = new ReturnObjectBag("object message"); - public void setupCreateObjectMessage(ObjectMessage objectMessageToReturn){ - this.objectMessageToReturn = objectMessageToReturn; + public void setupCreateObjectMessage(Object object, ObjectMessage objectMessageToReturn){ + this.objectMessageToReturn.putObjectToReturn(object, objectMessageToReturn); } public ObjectMessage createObjectMessage() throws JMSException { - return objectMessageToReturn; + return (ObjectMessage) objectMessageToReturn.getNextReturnObject(null); } public ObjectMessage createObjectMessage(Serializable object) throws JMSException { - return objectMessageToReturn; + return (ObjectMessage) objectMessageToReturn.getNextReturnObject(object); } public void rollback() throws JMSException { Index: MockTopicPublisher.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/j2ee/common/com/mockobjects/jms/MockTopicPublisher.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- MockTopicPublisher.java 22 Apr 2002 16:53:13 -0000 1.2 +++ MockTopicPublisher.java 11 Aug 2003 09:14:38 -0000 1.3 @@ -1,7 +1,11 @@ package com.mockobjects.jms; -import javax.jms.*; -import com.mockobjects.*; +import com.mockobjects.ExpectationValue; + +import javax.jms.JMSException; +import javax.jms.Message; +import javax.jms.Topic; +import javax.jms.TopicPublisher; public class MockTopicPublisher extends MockMessagePublisher implements TopicPublisher{ |
From: Jeff M. <cus...@us...> - 2003-08-11 09:13:55
|
Update of /cvsroot/mockobjects/mockobjects-java/src/j2ee/common/com/mockobjects/servlet In directory sc8-pr-cvs1:/tmp/cvs-serv18693/src/j2ee/common/com/mockobjects/servlet Modified Files: MockPageContext.java Log Message: Added methods required by 2.4 servlet spec Index: MockPageContext.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/j2ee/common/com/mockobjects/servlet/MockPageContext.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- MockPageContext.java 23 Feb 2002 18:50:35 -0000 1.1 +++ MockPageContext.java 11 Aug 2003 09:13:51 -0000 1.2 @@ -1,11 +1,15 @@ package com.mockobjects.servlet; -import java.util.*; +import com.mockobjects.Verifiable; +import com.mockobjects.util.AssertMo; + import javax.servlet.*; -import javax.servlet.http.*; -import javax.servlet.jsp.*; +import javax.servlet.http.HttpSession; +import javax.servlet.jsp.JspWriter; +import javax.servlet.jsp.PageContext; +import java.util.Enumeration; -public class MockPageContext extends PageContext{ +public class MockPageContext extends PageContext implements Verifiable { private JspWriter jspWriter; private ServletRequest request; private HttpSession httpSession; @@ -40,6 +44,14 @@ public void include(String s){ } + /** + * method required for servlet 2.4 spec + * not implemented + */ + public void include(String relativeUrlPath, boolean flush){ + AssertMo.notImplemented(getClass().getName()); + } + public void removeAttribute(String s, int i){ } @@ -109,6 +121,6 @@ return null; } - public void verify(){ - } + public void verify(){} + } |
From: Jeff M. <cus...@us...> - 2003-08-11 09:13:55
|
Update of /cvsroot/mockobjects/mockobjects-java/src/j2ee/1.3/com/mockobjects/servlet In directory sc8-pr-cvs1:/tmp/cvs-serv18693/src/j2ee/1.3/com/mockobjects/servlet Modified Files: MockHttpServletRequest.java MockHttpServletResponse.java Log Message: Added methods required by 2.4 servlet spec Index: MockHttpServletRequest.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletRequest.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- MockHttpServletRequest.java 25 Jun 2003 09:24:58 -0000 1.17 +++ MockHttpServletRequest.java 11 Aug 2003 09:13:50 -0000 1.18 @@ -410,4 +410,14 @@ public Map getParameterMap() { return (Map) parameterMap.getValue(); } + + /** + * method required for servlet 2.4 spec + * not implemented + * @return + */ + public int getRemotePort(){ + notImplemented(); + return -1; + } } Index: MockHttpServletResponse.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletResponse.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- MockHttpServletResponse.java 20 Nov 2002 19:08:58 -0000 1.2 +++ MockHttpServletResponse.java 11 Aug 2003 09:13:50 -0000 1.3 @@ -264,4 +264,13 @@ public void setupOutputStream(MockServletOutputStream anOutputStream) { myOutputStream = anOutputStream; } + + /** + * Not Implemented + * method required for servlet 2.4 spec + */ + public String getContentType(){ + notImplemented(); + return null; + } } |
From: Jeff M. <je...@cu...> - 2003-08-10 10:03:10
|
---------------------------------------------------- This email is autogenerated from the output from: <http://cvs.apache.org/builds/gump/2003-08-10/mockobjects.html> ---------------------------------------------------- Buildfile: build.xml project-properties: useful-file-patterns: source-locations: check-availabilities: [available] DEPRECATED - <available> used to override an existing property. [available] Build file should not reuse the same property name for different values. [available] DEPRECATED - <available> used to override an existing property. [available] Build file should not reuse the same property name for different values. [available] DEPRECATED - <available> used to override an existing property. [available] Build file should not reuse the same property name for different values. [available] DEPRECATED - <available> used to override an existing property. [available] Build file should not reuse the same property name for different values. call-me-first: [echo] --------- Mock Objects 20030810 --------- [echo] java.class.path = /home/rubys/jakarta/xml-xerces2/java/build/xmlParserAPIs.jar:/home/rubys/jakarta/xml-xerces2/java/build/xercesImpl.jar:.:/usr/java/j2sdk1.4.1_02/lib/tools.jar:/usr/java/j2sdk1.4.1_02/jre/lib/rt.jar:/usr/java/j2sdk1.4.1_02/lib/tools.jar:/home/rubys/jakarta/ant/dist/lib/ant.jar:/home/rubys/jakarta/ant/dist/lib/ant-launcher.jar:/home/rubys/jakarta/ant/dist/lib/ant-jmf.jar:/home/rubys/jakarta/ant/dist/lib/ant-junit.jar:/home/rubys/jakarta/ant/dist/lib/ant-stylebook.jar:/home/rubys/jakarta/ant/dist/lib/ant-swing.jar:/home/rubys/jakarta/ant/dist/lib/ant-trax.jar:/home/rubys/jakarta/ant/dist/lib/ant-xalan2.jar:/home/rubys/jakarta/ant/dist/lib/nodeps.jar:/home/rubys/jakarta/dist/junit/junit.jar:/opt/jaf-1.0.1/activation.jar:/home/rubys/jakarta/jakarta-servletapi-5/jsr152/dist/lib/jsp-api.jar:/home/rubys/jakarta/jakarta-servletapi-5/jsr154/dist/lib/servlet-api.jar:/opt/javamail-1.3/mail.jar:/opt/jms1.0.2/lib/jms.jar:/home/rubys/jakarta/mockobjects/out/core/classes:/home/rubys/jakarta/mockobjects/out/jdk/classes [echo] java.home = /usr/java/j2sdk1.4.1_02/jre [echo] user.home = /home/rubys [echo] ant.home = ${ant.home} compile-core: [javac] Compiling 103 source files to /home/rubys/jakarta/mockobjects/out/core/classes compile-jdk: [javac] Compiling 45 source files to /home/rubys/jakarta/mockobjects/out/jdk/classes [javac] Note: Some input files use or override a deprecated API. [javac] Note: Recompile with -deprecation for details. compile-j2ee: [mkdir] Created dir: /home/rubys/jakarta/mockobjects/out/j2ee/classes [javac] Compiling 64 source files to /home/rubys/jakarta/mockobjects/out/j2ee/classes [javac] /home/rubys/jakarta/mockobjects/src/j2ee/common/com/mockobjects/servlet/MockPageContext.java:8: com.mockobjects.servlet.MockPageContext should be declared abstract; it does not define include(java.lang.String,boolean) in javax.servlet.jsp.PageContext [javac] public class MockPageContext extends PageContext{ [javac] ^ [javac] /home/rubys/jakarta/mockobjects/src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletRequest.java:20: com.mockobjects.servlet.MockHttpServletRequest should be declared abstract; it does not define getRemotePort() in com.mockobjects.servlet.MockHttpServletRequest [javac] public class MockHttpServletRequest extends MockObject [javac] ^ [javac] /home/rubys/jakarta/mockobjects/src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletResponse.java:12: com.mockobjects.servlet.MockHttpServletResponse should be declared abstract; it does not define getContentType() in com.mockobjects.servlet.MockHttpServletResponse [javac] public class MockHttpServletResponse extends MockObject [javac] ^ [javac] Note: Some input files use or override a deprecated API. [javac] Note: Recompile with -deprecation for details. [javac] 3 errors BUILD FAILED /home/rubys/jakarta/mockobjects/build.xml:154: Compile failed; see the compiler error output for details. Total time: 10 seconds |
From: Steve F. <sm...@us...> - 2003-08-09 13:19:30
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic In directory sc8-pr-cvs1:/tmp/cvs-serv1286/src/core/test/mockobjects/dynamic Modified Files: MockCallableCollection.java CallSequenceTest.java Log Message: renamed match to stub Index: MockCallableCollection.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/MockCallableCollection.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- MockCallableCollection.java 9 Jul 2003 23:54:20 -0000 1.5 +++ MockCallableCollection.java 9 Aug 2003 13:19:25 -0000 1.6 @@ -31,7 +31,7 @@ resetCalls.inc(); } - public void addMatch(Callable callable) { + public void addStub(Callable callable) { matchedCallables.addActual(callable); } Index: CallSequenceTest.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/CallSequenceTest.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- CallSequenceTest.java 9 Jul 2003 02:14:00 -0000 1.13 +++ CallSequenceTest.java 9 Aug 2003 13:19:25 -0000 1.14 @@ -207,7 +207,7 @@ Callable methodASignature = new CallSignature(METHOD_A_NAME,METHOD_A_CONSTRAINTS, new ReturnStub("result1")); Callable anotherMethodASignature = new CallSignature(METHOD_A_NAME,METHOD_A_CONSTRAINTS, new ReturnStub("result2")); - callSequence.addMatch(methodASignature); + callSequence.addStub(methodASignature); callSequence.addExpect(new CallOnceExpectation(anotherMethodASignature)); assertSame("expected result from method B, as expect has precendence over match", "result2", |
From: Steve F. <sm...@us...> - 2003-08-09 13:18:48
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic In directory sc8-pr-cvs1:/tmp/cvs-serv1210/src/core/test/mockobjects/dynamic Modified Files: CallBagTest.java Log Message: renamed match to stub Index: CallBagTest.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/CallBagTest.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- CallBagTest.java 9 Jul 2003 23:54:20 -0000 1.10 +++ CallBagTest.java 9 Aug 2003 13:18:45 -0000 1.11 @@ -35,7 +35,7 @@ mockExpected.addedCallables.setExpectNothing(); mockStubs.addedCallables.addExpected(mockCallable); - callBag.addMatch(mockCallable); + callBag.addStub(mockCallable); verifyAll(); } |
From: Steve F. <sm...@us...> - 2003-08-09 13:18:40
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic In directory sc8-pr-cvs1:/tmp/cvs-serv1162/src/core/com/mockobjects/dynamic Modified Files: AbstractCallableCollection.java CallableCollection.java CoreMock.java CallSignature.java Log Message: renamed match to stub Index: AbstractCallableCollection.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/AbstractCallableCollection.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- AbstractCallableCollection.java 9 Jul 2003 02:14:00 -0000 1.4 +++ AbstractCallableCollection.java 9 Aug 2003 13:18:30 -0000 1.5 @@ -32,7 +32,7 @@ expectedCalls.add(call); } - public void addMatch(Callable call) { + public void addStub(Callable call) { stubCalls.add(call); } Index: CallableCollection.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/CallableCollection.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- CallableCollection.java 6 Jul 2003 02:28:51 -0000 1.1 +++ CallableCollection.java 9 Aug 2003 13:18:30 -0000 1.2 @@ -2,7 +2,7 @@ public interface CallableCollection extends Callable { void addExpect(Callable call); - void addMatch(Callable call); + void addStub(Callable call); /** * Resets all expected calls and expected matches. Index: CoreMock.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/CoreMock.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- CoreMock.java 9 Jul 2003 23:54:20 -0000 1.6 +++ CoreMock.java 9 Aug 2003 13:18:30 -0000 1.7 @@ -15,6 +15,8 @@ this.proxy = Proxy.newProxyInstance(getClass().getClassLoader(), new Class[] { mockedClass }, this); this.name = name; this.invocationMatchers = callables; + + // callables.addStub(new ProxyIsEqual(this.proxy)); } public Object proxy() { @@ -59,7 +61,7 @@ } public void stub(Callable invocationMatcher) { - invocationMatchers.addMatch(invocationMatcher); + invocationMatchers.addStub(invocationMatcher); } private boolean isCheckingEqualityOnProxy(Invocation invocation) { @@ -89,5 +91,28 @@ return name; } } + + public static class ProxyIsEqual implements Callable { + final Object proxy; + + public ProxyIsEqual(Object proxy) { + this.proxy = proxy; + } + + public String getDescription() { + return "Proxy is equal"; + } + + public Object call(Invocation invocation) throws Throwable { + return new Boolean(invocation.args[0] == proxy); + } + + public boolean matches(Invocation invocation) { + return (invocation.getMethodName().equals("equals")) && (invocation.args.length == 1) && + (Proxy.isProxyClass(invocation.args[0].getClass())); + } + + public void verify() { /* no op */ } + } } Index: CallSignature.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/CallSignature.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- CallSignature.java 7 Jul 2003 01:17:57 -0000 1.6 +++ CallSignature.java 9 Aug 2003 13:18:30 -0000 1.7 @@ -4,22 +4,22 @@ { private String methodName; private ConstraintMatcher constraints; - private Callable delegate; + private Callable delegateCall; - public CallSignature( String methodName, ConstraintMatcher constraints, Callable delegate ) { + public CallSignature( String methodName, ConstraintMatcher constraints, Callable delegateCall ) { this.methodName = methodName; this.constraints = constraints; - this.delegate = delegate; + this.delegateCall = delegateCall; } public Object call( Invocation invocation ) throws Throwable { - return delegate.call( invocation ); + return delegateCall.call( invocation ); } public void verify() { - delegate.verify(); + delegateCall.verify(); } public boolean matches(Invocation invocation) { @@ -32,6 +32,6 @@ // Implemented to aid visualisation in an IDE debugger public String toString() { - return CoreMock.className(this.getClass()) + "(" + this.getDescription() + ")"; + return CoreMock.className(getClass()) + "(" + getDescription() + ")"; } } |
From: Steve F. <sm...@us...> - 2003-08-09 13:18:18
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic In directory sc8-pr-cvs1:/tmp/cvs-serv1138/src/core/com/mockobjects/dynamic Modified Files: DefaultCallFactory.java Log Message: Simplified Index: DefaultCallFactory.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/DefaultCallFactory.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- DefaultCallFactory.java 6 Jul 2003 02:31:37 -0000 1.6 +++ DefaultCallFactory.java 9 Aug 2003 13:18:15 -0000 1.7 @@ -2,26 +2,10 @@ public class DefaultCallFactory implements CallableFactory { - private Callable createReturnStub(Object result) { - return new ReturnStub(result); - } - - private Callable createThrowStub( Throwable exception ) { - return new ThrowStub(exception); - } - - private Callable createVoidStub() { - return new VoidStub(); - } - public Callable createCallExpectation(Callable callable) { return new CallOnceExpectation(callable); } - private Callable createCallSignature(String methodName, ConstraintMatcher constraints, Callable callable) { - return new CallSignature( methodName, constraints, callable ); - } - public Callable createReturnCallable(String methodName, ConstraintMatcher constraints, Object result) { return createCallSignature(methodName, constraints, createReturnStub(result)); } @@ -33,5 +17,21 @@ public Callable createVoidCallable(String methodName, ConstraintMatcher constraints) { return createCallSignature(methodName, constraints, createVoidStub()); } + + private Callable createCallSignature(String methodName, ConstraintMatcher constraints, Callable callable) { + return new CallSignature( methodName, constraints, callable ); + } + + private Callable createReturnStub(Object result) { + return new ReturnStub(result); + } + + private Callable createThrowStub( Throwable exception ) { + return new ThrowStub(exception); + } + + private Callable createVoidStub() { + return new VoidStub(); + } } |
From: Steve F. <sm...@us...> - 2003-08-09 13:17:51
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic In directory sc8-pr-cvs1:/tmp/cvs-serv1070/src/core/com/mockobjects/dynamic Modified Files: Mock.java Log Message: white space Index: Mock.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/Mock.java,v retrieving revision 1.32 retrieving revision 1.33 diff -u -r1.32 -r1.33 --- Mock.java 9 Jul 2003 23:54:20 -0000 1.32 +++ Mock.java 9 Aug 2003 13:17:48 -0000 1.33 @@ -43,7 +43,6 @@ coreMock.expect(callableFactory.createCallExpectation(callableFactory.createVoidCallable(methodName, args))); } - public void expectAndReturn(String methodName, ConstraintMatcher args, Object result) { coreMock.expect(callableFactory.createCallExpectation(callableFactory.createReturnCallable(methodName, args, result))); } |
From: Steve F. <sm...@us...> - 2003-08-09 13:16:19
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic In directory sc8-pr-cvs1:/tmp/cvs-serv937/src/core/com/mockobjects/dynamic Modified Files: CallOnceExpectation.java Log Message: Renamed delegate to delegateCall to simplify comparison with C# Index: CallOnceExpectation.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/CallOnceExpectation.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- CallOnceExpectation.java 7 Jul 2003 01:17:57 -0000 1.5 +++ CallOnceExpectation.java 9 Aug 2003 13:16:17 -0000 1.6 @@ -3,36 +3,36 @@ import junit.framework.*; public class CallOnceExpectation implements Callable { - private Callable delegate; + private Callable delegateCall; private boolean wasCalled = false; - public CallOnceExpectation( Callable delegate ) { - this.delegate = delegate; + public CallOnceExpectation( Callable delegateCall ) { + this.delegateCall = delegateCall; } public String getDescription() { - return delegate.getDescription() + " [" + (wasCalled ? "" : "not ") + "called]"; + return delegateCall.getDescription() + " [" + (wasCalled ? "" : "not ") + "called]"; } public Object call(Invocation invocation) throws Throwable { wasCalled = true; - return delegate.call( invocation ); + return delegateCall.call( invocation ); } public boolean matches(Invocation invocation) { - return (!wasCalled) && delegate.matches( invocation ); + return (!wasCalled) && delegateCall.matches( invocation ); } public void verify() { if( !wasCalled ) { - throw new AssertionFailedError( delegate.getDescription() + " was expected but not called" ); + throw new AssertionFailedError( delegateCall.getDescription() + " was expected but not called" ); } - delegate.verify(); + delegateCall.verify(); } // Implemented to aid visualisation in an IDE debugger public String toString() { - return CoreMock.className(this.getClass()) + "(" + this.getDescription() + ")"; + return CoreMock.className(getClass()) + "(" + getDescription() + ")"; } } |
From: Jeff M. <je...@cu...> - 2003-08-09 10:11:04
|
---------------------------------------------------- This email is autogenerated from the output from: <http://cvs.apache.org/builds/gump/2003-08-09/mockobjects.html> ---------------------------------------------------- Buildfile: build.xml project-properties: useful-file-patterns: source-locations: check-availabilities: [available] DEPRECATED - <available> used to override an existing property. [available] Build file should not reuse the same property name for different values. [available] DEPRECATED - <available> used to override an existing property. [available] Build file should not reuse the same property name for different values. [available] DEPRECATED - <available> used to override an existing property. [available] Build file should not reuse the same property name for different values. [available] DEPRECATED - <available> used to override an existing property. [available] Build file should not reuse the same property name for different values. call-me-first: [echo] --------- Mock Objects 20030809 --------- [echo] java.class.path = /home/rubys/jakarta/xml-xerces2/java/build/xmlParserAPIs.jar:/home/rubys/jakarta/xml-xerces2/java/build/xercesImpl.jar:.:/usr/java/j2sdk1.4.1_02/lib/tools.jar:/usr/java/j2sdk1.4.1_02/jre/lib/rt.jar:/usr/java/j2sdk1.4.1_02/lib/tools.jar:/home/rubys/jakarta/ant/dist/lib/ant.jar:/home/rubys/jakarta/ant/dist/lib/ant-launcher.jar:/home/rubys/jakarta/ant/dist/lib/ant-jmf.jar:/home/rubys/jakarta/ant/dist/lib/ant-junit.jar:/home/rubys/jakarta/ant/dist/lib/ant-stylebook.jar:/home/rubys/jakarta/ant/dist/lib/ant-swing.jar:/home/rubys/jakarta/ant/dist/lib/ant-trax.jar:/home/rubys/jakarta/ant/dist/lib/ant-xalan2.jar:/home/rubys/jakarta/ant/dist/lib/nodeps.jar:/home/rubys/jakarta/dist/junit/junit.jar:/opt/jaf-1.0.1/activation.jar:/home/rubys/jakarta/jakarta-servletapi-5/jsr152/dist/lib/jsp-api.jar:/home/rubys/jakarta/jakarta-servletapi-5/jsr154/dist/lib/servlet-api.jar:/opt/javamail-1.3/mail.jar:/opt/jms1.0.2/lib/jms.jar:/home/rubys/jakarta/mockobjects/out/core/classes:/home/rubys/jakarta/mockobjects/out/jdk/classes [echo] java.home = /usr/java/j2sdk1.4.1_02/jre [echo] user.home = /home/rubys [echo] ant.home = ${ant.home} compile-core: [javac] Compiling 103 source files to /home/rubys/jakarta/mockobjects/out/core/classes compile-jdk: [javac] Compiling 45 source files to /home/rubys/jakarta/mockobjects/out/jdk/classes [javac] Note: Some input files use or override a deprecated API. [javac] Note: Recompile with -deprecation for details. compile-j2ee: [mkdir] Created dir: /home/rubys/jakarta/mockobjects/out/j2ee/classes [javac] Compiling 64 source files to /home/rubys/jakarta/mockobjects/out/j2ee/classes [javac] /home/rubys/jakarta/mockobjects/src/j2ee/common/com/mockobjects/servlet/MockPageContext.java:8: com.mockobjects.servlet.MockPageContext should be declared abstract; it does not define include(java.lang.String,boolean) in javax.servlet.jsp.PageContext [javac] public class MockPageContext extends PageContext{ [javac] ^ [javac] /home/rubys/jakarta/mockobjects/src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletRequest.java:20: com.mockobjects.servlet.MockHttpServletRequest should be declared abstract; it does not define getRemotePort() in com.mockobjects.servlet.MockHttpServletRequest [javac] public class MockHttpServletRequest extends MockObject [javac] ^ [javac] /home/rubys/jakarta/mockobjects/src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletResponse.java:12: com.mockobjects.servlet.MockHttpServletResponse should be declared abstract; it does not define getContentType() in com.mockobjects.servlet.MockHttpServletResponse [javac] public class MockHttpServletResponse extends MockObject [javac] ^ [javac] Note: Some input files use or override a deprecated API. [javac] Note: Recompile with -deprecation for details. [javac] 3 errors BUILD FAILED /home/rubys/jakarta/mockobjects/build.xml:154: Compile failed; see the compiler error output for details. Total time: 10 seconds |
From: Jeff M. <je...@cu...> - 2003-08-08 11:34:04
|
---------------------------------------------------- This email is autogenerated from the output from: <http://cvs.apache.org/builds/gump/2003-08-08/mockobjects.html> ---------------------------------------------------- Buildfile: build.xml project-properties: useful-file-patterns: source-locations: check-availabilities: [available] DEPRECATED - <available> used to override an existing property. [available] Build file should not reuse the same property name for different values. [available] DEPRECATED - <available> used to override an existing property. [available] Build file should not reuse the same property name for different values. [available] DEPRECATED - <available> used to override an existing property. [available] Build file should not reuse the same property name for different values. [available] DEPRECATED - <available> used to override an existing property. [available] Build file should not reuse the same property name for different values. call-me-first: [echo] --------- Mock Objects 20030808 --------- [echo] java.class.path = /home/rubys/jakarta/xml-xerces2/java/build/xmlParserAPIs.jar:/home/rubys/jakarta/xml-xerces2/java/build/xercesImpl.jar:.:/usr/java/j2sdk1.4.1_02/lib/tools.jar:/usr/java/j2sdk1.4.1_02/jre/lib/rt.jar:/usr/java/j2sdk1.4.1_02/lib/tools.jar:/home/rubys/jakarta/ant/dist/lib/ant.jar:/home/rubys/jakarta/ant/dist/lib/ant-launcher.jar:/home/rubys/jakarta/ant/dist/lib/ant-jmf.jar:/home/rubys/jakarta/ant/dist/lib/ant-junit.jar:/home/rubys/jakarta/ant/dist/lib/ant-stylebook.jar:/home/rubys/jakarta/ant/dist/lib/ant-swing.jar:/home/rubys/jakarta/ant/dist/lib/ant-trax.jar:/home/rubys/jakarta/ant/dist/lib/ant-xalan2.jar:/home/rubys/jakarta/ant/dist/lib/nodeps.jar:/home/rubys/jakarta/dist/junit/junit.jar:/opt/jaf-1.0.1/activation.jar:/home/rubys/jakarta/jakarta-servletapi-5/jsr152/dist/lib/jsp-api.jar:/home/rubys/jakarta/jakarta-servletapi-5/jsr154/dist/lib/servlet-api.jar:/opt/javamail-1.3/mail.jar:/opt/jms1.0.2/lib/jms.jar:/home/rubys/jakarta/mockobjects/out/core/classes:/home/rubys/jakarta/mockobjects/out/jdk/classes [echo] java.home = /usr/java/j2sdk1.4.1_02/jre [echo] user.home = /home/rubys [echo] ant.home = ${ant.home} compile-core: [javac] Compiling 103 source files to /home/rubys/jakarta/mockobjects/out/core/classes compile-jdk: [javac] Compiling 45 source files to /home/rubys/jakarta/mockobjects/out/jdk/classes [javac] Note: Some input files use or override a deprecated API. [javac] Note: Recompile with -deprecation for details. compile-j2ee: [mkdir] Created dir: /home/rubys/jakarta/mockobjects/out/j2ee/classes [javac] Compiling 64 source files to /home/rubys/jakarta/mockobjects/out/j2ee/classes [javac] /home/rubys/jakarta/mockobjects/src/j2ee/common/com/mockobjects/servlet/MockPageContext.java:8: com.mockobjects.servlet.MockPageContext should be declared abstract; it does not define include(java.lang.String,boolean) in javax.servlet.jsp.PageContext [javac] public class MockPageContext extends PageContext{ [javac] ^ [javac] /home/rubys/jakarta/mockobjects/src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletRequest.java:20: com.mockobjects.servlet.MockHttpServletRequest should be declared abstract; it does not define getRemotePort() in com.mockobjects.servlet.MockHttpServletRequest [javac] public class MockHttpServletRequest extends MockObject [javac] ^ [javac] /home/rubys/jakarta/mockobjects/src/j2ee/1.3/com/mockobjects/servlet/MockHttpServletResponse.java:12: com.mockobjects.servlet.MockHttpServletResponse should be declared abstract; it does not define getContentType() in com.mockobjects.servlet.MockHttpServletResponse [javac] public class MockHttpServletResponse extends MockObject [javac] ^ [javac] Note: Some input files use or override a deprecated API. [javac] Note: Recompile with -deprecation for details. [javac] 3 errors BUILD FAILED /home/rubys/jakarta/mockobjects/build.xml:154: Compile failed; see the compiler error output for details. Total time: 10 seconds |
From: Ranjan C. <ran...@ya...> - 2003-07-25 21:19:33
|
Hello, I am trying to use JUnit or some other tool to perform unit testing of ATG Dynamo droplets and form Handlers. Please let me know if there are any documents/ papers that discuss this subject. I am specifically interested in: (1) A description of how to use JUnit or some other tool to test droplets and form handlers, (2) some code example of unit testing of droplets and form handlers, and (3) advantages and disadvantages of using JUnit or another tool to test droplets and formhandlers. Thank you very much for all your help. Ranjan Chakrabarty e-mail: ran...@ya... __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com |
From: Vincent M. <vm...@pi...> - 2003-07-23 06:29:26
|
Hi Steve, > -----Original Message----- > From: Steve Freeman [mailto:st...@m3...] > Sent: 22 July 2003 01:01 > To: Vincent Massol > Cc: 'Moc...@Li...' > Subject: Re: [MO-java-dev] dynamic branch and merge > > Folks (and especially Vincent). I've been trying to find a way to break > through the morass of overloading to come up with a cleaner API for the > dynamics and it's not easy to do it incrementally. Maybe I'm just too > tired, or need a pair, but the backwards compatibility is getting in the > way. I've found that API compatibility is a mentality issue and not a technical one. If you do care about API compatibility then you'll be able to keep the compatibility (in several cases, it means restricting your refactoring changes and spreading them over releases). OTOH if you don't care much then everything is possible but then you may anger your users. My personal opinion is that mockobjects should have released a 1.0 version a long time ago and should be *stable* and care about API compatibility. Refactoring is nice to do but not when it comes to API-public parts. One other thing that we're not doing correctly I believe, is to warn users when we consider an API not to be stable and they should not use it in production project (i.e. they should just play with it). Naming it 0.09 is not a solution as this has been going on for several years now... so it makes no difference as if it were version 6.0. I've recently discovered that your choice about design should not be only driven by the beauty of OO constructs but also for extensibility in the compatibility sense (a good article: http://www.eclipse.org/eclipse/development/java-api-evolution.html). In other words you should design frameworks, so that they can be modified without breaking the user-public APIs. I did the mistake on Cactus of not knowing about this and we're correcting my mistake slowly as we go. "Internal" classes should be clearly identified and binary compatibility should be taken into account (see http://blogs.codehaus.org/people/vmassol/archives/000098.html). Thanks -Vincent > > I know Vincent's written it up in his book, but is there anyone else > that an API change would hurt? Or a way to do it under the covers? > > S. > > Vincent Massol wrote: > > Is this going to break the DynaMock API from released version 0.09? > > > > In any case I believe we should absolutely provide backward > > compatibility and mark changed methods as deprecated. All new public > > methods should also be tagged with the "@since" javadoc tag. > |
From: Jeff M. <cus...@us...> - 2003-07-22 10:25:03
|
Update of /cvsroot/mockobjects/mockobjects-java/src/j2ee/1.3/com/mockobjects/helpers In directory sc8-pr-cvs1:/tmp/cvs-serv26232/src/j2ee/1.3/com/mockobjects/helpers Modified Files: AbstractServletTestHelper.java ServletTestHelper.java Log Message: Made AbstractServletTestHelper extends MockObject to allow easier verification Added methods to allow a servlet to be tested with a certain status expectaion Index: AbstractServletTestHelper.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/j2ee/1.3/com/mockobjects/helpers/AbstractServletTestHelper.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- AbstractServletTestHelper.java 14 May 2003 15:17:32 -0000 1.4 +++ AbstractServletTestHelper.java 22 Jul 2003 10:25:00 -0000 1.5 @@ -1,11 +1,12 @@ package com.mockobjects.helpers; import com.mockobjects.servlet.*; +import com.mockobjects.MockObject; /** * $Revision$ */ -public abstract class AbstractServletTestHelper { +public abstract class AbstractServletTestHelper extends MockObject{ protected final MockHttpServletRequest request = new MockHttpServletRequest(); protected final MockHttpServletResponse response = new MockHttpServletResponse(); protected final MockHttpSession httpSession = new MockHttpSession(); Index: ServletTestHelper.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/j2ee/1.3/com/mockobjects/helpers/ServletTestHelper.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ServletTestHelper.java 14 May 2003 15:17:57 -0000 1.2 +++ ServletTestHelper.java 22 Jul 2003 10:25:00 -0000 1.3 @@ -32,14 +32,140 @@ testSubject.service(request, response); } + /** + * Calls the service method on the test subject after setting the HTTP method on the request to POST + * @throws ServletException + * @throws IOException + */ public void testDoPost() throws ServletException, IOException { - request.setupGetMethod("POST"); - testServlet(); + testServletWithMethod("POST"); } + /** + * Calls the service method on the test subject after setting the HTTP method on the request to GET + * @throws ServletException + * @throws IOException + */ public void testDoGet() throws ServletException, IOException { - request.setupGetMethod("GET"); + testServletWithMethod("GET"); + } + + /** + * Calls the service method on the test subject after setting the HTTP method on the request to PUT + * @throws ServletException + * @throws IOException + */ + public void testDoPut() throws ServletException, IOException { + testServletWithMethod("PUT"); + } + + /** + * Calls the service method on the test subject after setting the HTTP method on the request to PUT. + * The expected response status is also set so that it can be verified later. + * @throws ServletException + * @throws IOException + */ + public void testDoPutWithExpectedStatus(int status) throws ServletException, IOException { + testServletWithMethod("PUT", status); + } + + /** + * Calls the service method on the test subject after setting the HTTP method on the request to PUT. + * The expected response status and message are also set so that it can be verified later. + * @throws ServletException + * @throws IOException + */ + public void testDoPutWithExpectedStatus(int status, String message) throws ServletException, IOException { + testServletWithMethod("PUT", status, message); + } + + /** + * Calls the service method on the test subject after setting the HTTP method on the request to PUT + * The response status is set to expect not to be called. + * @throws ServletException + * @throws IOException + */ + public void testDoPutWithExpectedStatusNone() throws ServletException, IOException { + testServletWithMethodAndNoStatus("PUT"); + } + + /** + * Calls the service method on the test subject after setting the HTTP method on the request to GET. + * The expected response status is also set so that it can be verified later. + * @throws ServletException + * @throws IOException + */ + public void testDoGetWithExpectedStatus(int status) throws ServletException, IOException { + testServletWithMethod("GET", status); + } + + /** + * Calls the service method on the test subject after setting the HTTP method on the request to GET. + * The expected response status and message are also set so that it can be verified later. + * @throws ServletException + * @throws IOException + */ + public void testDoGetWithExpectedStatus(int status, String message) throws ServletException, IOException { + testServletWithMethod("GET", status, message); + } + + /** + * Calls the service method on the test subject after setting the HTTP method on the request to GET + * The response status is set to expect not to be called. + * @throws ServletException + * @throws IOException + */ + public void testDoGetWithExpectedStatusNone() throws ServletException, IOException { + testServletWithMethodAndNoStatus("GET"); + } + + /** + * Calls the service method on the test subject after setting the HTTP method on the request to POST. + * The expected response status is also set so that it can be verified later. + * @throws ServletException + * @throws IOException + */ + public void testDoPostWithExpectedStatus(int status) throws ServletException, IOException { + testServletWithMethod("POST", status); + } + + /** + * Calls the service method on the test subject after setting the HTTP method on the request to POST. + * The expected response status and message are also set so that it can be verified later. + * @throws ServletException + * @throws IOException + */ + public void testDoPostWithExpectedStatus(int status, String message) throws ServletException, IOException { + testServletWithMethod("POST", status, message); + } + + /** + * Calls the service method on the test subject after setting the HTTP method on the request to POST + * The response status is set to expect not to be called. + * @throws ServletException + * @throws IOException + */ + public void testDoPostWithExpectedStatusNone() throws ServletException, IOException { + testServletWithMethodAndNoStatus("POST"); + } + + private void testServletWithMethod(final String aMethod) throws ServletException, IOException { + request.setupGetMethod(aMethod); testServlet(); } + private void testServletWithMethod(final String aMethod, int status) throws ServletException, IOException { + response.setExpectedError(status); + testServletWithMethod(aMethod); + } + + private void testServletWithMethod(final String aMethod, int status, String message) throws ServletException, IOException { + response.setExpectedError(status, message); + testServletWithMethod(aMethod); + } + + private void testServletWithMethodAndNoStatus(final String aMethod) throws ServletException, IOException { + response.setExpectedErrorNothing(); + testServletWithMethod(aMethod); + } } |
From: Nat P. <nat...@b1...> - 2003-07-21 23:19:01
|
It'll hurt some of my projects, but I'm willing to defer a move over to a new API for some projects and try out a new API on others. I'd love to see a way to alleviate the overloading hassle. Tim's idea of creating "expected call" objects that you can add arguments and return values to seems a good way to go. However, I've found the decorator architecture incredibly flexible and I'm not sure if separating matching from expectations will be a good way to go. For example, I've recently been writing a structured graphics framework. One thing I need to test is the drawing order of layered graphics: elements should be drawn in their z-order. So I mock each layered element and expect draw calls. However, this does not test the order of calls: I need a call sequence that crosses multiple mocks. This is trivial to do with decorators because they have both a match and call method. It would be hard to do if the two methods are in separate objects. (I can provide more details if anybody is interested). Cheers, Nat. _______________________ Dr. Nathaniel Pryce B13media Ltd. http://www.b13media.com +44 (0)7712 526 661 ----- Original Message ----- From: "Steve Freeman" <st...@m3...> To: "Vincent Massol" <vm...@pi...> Cc: "'Moc...@Li...'" <moc...@li...> Sent: Tuesday, July 22, 2003 12:00 AM Subject: Re: [MO-java-dev] dynamic branch and merge > Folks (and especially Vincent). I've been trying to find a way to break > through the morass of overloading to come up with a cleaner API for the > dynamics and it's not easy to do it incrementally. Maybe I'm just too > tired, or need a pair, but the backwards compatibility is getting in the > way. > > I know Vincent's written it up in his book, but is there anyone else > that an API change would hurt? Or a way to do it under the covers? > > S. > > Vincent Massol wrote: > > Is this going to break the DynaMock API from released version 0.09? > > > > In any case I believe we should absolutely provide backward > > compatibility and mark changed methods as deprecated. All new public > > methods should also be tagged with the "@since" javadoc tag. > > > > > ------------------------------------------------------- > This SF.net email is sponsored by: VM Ware > With VMware you can run multiple operating systems on a single machine. > WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the > same time. Free trial click here: http://www.vmware.com/wl/offer/345/0 > _______________________________________________ > Mockobjects-java-dev mailing list > Moc...@li... > https://lists.sourceforge.net/lists/listinfo/mockobjects-java-dev |
From: Steve F. <st...@m3...> - 2003-07-21 23:01:01
|
Folks (and especially Vincent). I've been trying to find a way to break through the morass of overloading to come up with a cleaner API for the dynamics and it's not easy to do it incrementally. Maybe I'm just too tired, or need a pair, but the backwards compatibility is getting in the way. I know Vincent's written it up in his book, but is there anyone else that an API change would hurt? Or a way to do it under the covers? S. Vincent Massol wrote: > Is this going to break the DynaMock API from released version 0.09? > > In any case I believe we should absolutely provide backward > compatibility and mark changed methods as deprecated. All new public > methods should also be tagged with the "@since" javadoc tag. |
Update of /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic In directory sc8-pr-cvs1:/tmp/cvs-serv3011/src/core/test/mockobjects/dynamic Modified Files: MockCallableCollection.java DummyInterface.java MockTest.java CoreMockTest.java CallBagTest.java Removed Files: TestCallBag.java Log Message: Tidied up Mock and CoreMock Reworked some of the tests to be more legible and simpler. Also, closer to mock implementation Index: MockCallableCollection.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/MockCallableCollection.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- MockCallableCollection.java 7 Jul 2003 02:24:26 -0000 1.4 +++ MockCallableCollection.java 9 Jul 2003 23:54:20 -0000 1.5 @@ -1,14 +1,11 @@ package test.mockobjects.dynamic; -import com.mockobjects.ExpectationCounter; -import com.mockobjects.ExpectationList; -import com.mockobjects.MockObject; -import com.mockobjects.ReturnValues; +import com.mockobjects.*; import com.mockobjects.dynamic.Invocation; import com.mockobjects.dynamic.Callable; import com.mockobjects.dynamic.CallableCollection; -import com.mockobjects.util.NotImplementedException; import com.mockobjects.util.Verifier; +import junit.framework.AssertionFailedError; //Mock modified for []args public class MockCallableCollection extends MockObject implements CallableCollection { @@ -21,13 +18,17 @@ private ExpectationCounter myGetDescriptionCalls = new ExpectationCounter("com.mockobjects.dynamic.CallableAddable GetDescriptionCalls"); private ReturnValues myActualGetDescriptionReturnValues = new ReturnValues("GetDescription", true); private ExpectationCounter myCallCalls = new ExpectationCounter("com.mockobjects.dynamic.CallableAddable CallCalls"); - private ReturnValues myActualCallReturnValues = new ReturnValues("CallReturn", true); private ExpectationList myCallMethodNames = new ExpectationList("com.mockobjects.dynamic.CallableAddable methodName"); private ExpectationList myCallArguments = new ExpectationList("com.mockobjects.dynamic.CallableAddable arguments"); private ExpectationCounter myVerifyCalls = new ExpectationCounter("com.mockobjects.dynamic.CallableAddable VerifyCalls"); + public Object callResult = null; + public Throwable callException; + public ExpectationCounter resetCalls = new ExpectationCounter("CallableCollection reset calls"); + public AssertionFailedError verifyFailure; + public void reset() { - throw new NotImplementedException(); + resetCalls.inc(); } public void addMatch(Callable callable) { @@ -94,28 +95,23 @@ myCallArguments.addExpectedMany(args); } - public Object call(Invocation invocation) - throws Throwable { + public Object call(Invocation invocation) throws Throwable { myCallCalls.inc(); myCallMethodNames.addActual(invocation.getMethodName()); myCallArguments.addActualMany(invocation.args); - Object nextReturnValue = myActualCallReturnValues.getNext(); - - return (Object) nextReturnValue; - } - - public void setupCall(Object arg) { - myActualCallReturnValues.add(arg); + if (callException != null) throw callException; + return callResult; } - public void setExpectedVerifyCalls(int calls) { + public void setExpectedVerifyCalls(int calls) { myVerifyCalls.setExpected(calls); } - /** @deprected use verifyExpectations as this is a mockmock */ + /** @deprecated use verifyExpectations as this is a mockmock */ public void verify() { myVerifyCalls.inc(); + if (verifyFailure != null) throw verifyFailure; } public void verifyExpectations() { Index: DummyInterface.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/DummyInterface.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- DummyInterface.java 7 Jul 2003 00:19:33 -0000 1.3 +++ DummyInterface.java 9 Jul 2003 23:54:20 -0000 1.4 @@ -2,10 +2,11 @@ package test.mockobjects.dynamic; public interface DummyInterface { - void noArgVoidMethod(); + void noArgVoidMethod() throws Throwable; String noArgMethod(); String oneArgMethod( String arg1); String twoArgMethod( String arg1, String arg2 ) throws Throwable; + String getMockName(); final String METHOD_NOARGVOID_NAME = "noArgVoidMethod"; final Object[] METHOD_NOARGVOID_ARGS = new Object[0]; @@ -21,4 +22,5 @@ final String METHOD_TWOARG_NAME = "twoArgMethod"; final String[] METHOD_TWOARG_ARGS = new String[] { "twoP1", "twoP2" }; final String METHOD_TWOARG_RESULT = "resultTwoArgs"; + } Index: MockTest.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/MockTest.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- MockTest.java 7 Jul 2003 02:24:26 -0000 1.17 +++ MockTest.java 9 Jul 2003 23:54:20 -0000 1.18 @@ -14,13 +14,13 @@ final Throwable METHOD_EXCEPTION = new DummyThrowable("Configured test throwable"); final ConstraintMatcher METHOD_ONEARG_CONSTRAINTS = C.args(C.eq("oneP1")); final ConstraintMatcher METHOD_TWOARG_CONSTRAINTS = C.args(C.eq("twoP1"), C.eq("twoP2")); - + + private MockCallableFactory mockCallableFactory = new MockCallableFactory(); + private MockCallableCollection mockCallables = new MockCallableCollection(); + private MockCallable mockCall = new MockCallable("call match"); + private DummyInterface proxy; private Mock mock; - private MockCallableFactory mockCallableFactory = new MockCallableFactory(); - - private MockCallableCollection mockCallables = new MockCallableCollection(); - private MockCallable mockCall = new MockCallable("call match"); public MockTest(String name) throws Exception { super(name); @@ -28,13 +28,7 @@ public void setUp() { mock = new Mock(mockCallableFactory, mockCallables, DummyInterface.class, MOCK_NAME); - - try { - proxy = (DummyInterface)mock.proxy(); - } catch (ClassCastException ex) { - fail("proxy is not of expected interface type"); - } - + proxy = (DummyInterface)mock.proxy(); mockCallableFactory.setupCreateCallExpectation(mockCall); } Index: CoreMockTest.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/CoreMockTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- CoreMockTest.java 7 Jul 2003 00:19:33 -0000 1.1 +++ CoreMockTest.java 9 Jul 2003 23:54:20 -0000 1.2 @@ -13,67 +13,63 @@ public class CoreMockTest extends TestCase { - private static final String MOCK_NAME = "Test mock"; + private static final String MOCK_NAME = "Test coreMock"; private DummyInterface proxy; - private CoreMock mock; + private CoreMock coreMock; private MockCallableCollection mockCallables = new MockCallableCollection(); - private MockCallable mockCallable = new MockCallable("mockCallable"); - - public CoreMockTest(String name) { + private MockCallable mockCallable = new MockCallable("coreMock mockCallable"); + + public CoreMockTest(String name) { super(name); } public void setUp() { - mock = new CoreMock(DummyInterface.class, MOCK_NAME, mockCallables); + coreMock = new CoreMock(DummyInterface.class, MOCK_NAME, mockCallables); try { - proxy = (DummyInterface)mock.proxy(); + proxy = (DummyInterface)coreMock.proxy(); } catch (ClassCastException ex) { fail("proxy is not of expected interface type"); } } - public void testMockAnnotatesAssertionFailedErrors() + public void testMockAnnotatesAssertionFailedError() throws Throwable { final String originalMessage = "original message"; - mockCallables.setupCall(new AssertionFailedError(originalMessage)); + Object arg = new AssertionFailedError(originalMessage); + mockCallables.callResult = arg; - try { + try { proxy.noArgVoidMethod(); } catch (AssertionFailedError err) { AssertMo.assertIncludes("should contain original message", originalMessage, err.getMessage()); - AssertMo.assertIncludes("should contain mock name", MOCK_NAME, err.getMessage()); + AssertMo.assertIncludes("should contain coreMock name", MOCK_NAME, err.getMessage()); } } - public void testMockNameFromClass() throws Exception { - assertEquals("mockString", CoreMock.mockNameFromClass(String.class)); - } - - public void testMockProxyReturnsConfiguredResult() throws Throwable { - final String result = "configured result"; + public void testProxyReturnsConfiguredResult() throws Throwable { + final String RESULT = "configured result"; - mockCallables.setupCall(result); + mockCallables.callResult = RESULT; - assertSame("result is returned by mock", result, proxy.oneArgMethod("arg")); + assertSame("result is returned by coreMock", RESULT, proxy.oneArgMethod("arg")); } - public void testMockProxySendsAllArgument() throws Throwable { - mockCallables.addExpectedCall(DummyInterface.METHOD_TWOARG_NAME, DummyInterface.METHOD_TWOARG_ARGS); - mockCallables.setupCall("result ignored"); - + public void testProxySendsAllArgument() throws Throwable { + mockCallables.addExpectedCall(DummyInterface.METHOD_TWOARG_NAME, DummyInterface.METHOD_TWOARG_ARGS); + proxy.twoArgMethod(DummyInterface.METHOD_TWOARG_ARGS[0], DummyInterface.METHOD_TWOARG_ARGS[1]); // Can't use Verifier as we are verifying "verify" mockCallables.verifyExpectations(); } - public void testMockProxySendsEmptyArrayWhenNoArguments() - throws Exception { - mockCallables.addExpectedCall(DummyInterface.METHOD_NOARGVOID_NAME, DummyInterface.METHOD_NOARGVOID_ARGS); - mockCallables.setupCall("result ignored"); + public void testProxySendsEmptyArrayWhenNoArguments() throws Throwable { + mockCallables.callResult = "result ignored"; + + mockCallables.addExpectedCall(DummyInterface.METHOD_NOARGVOID_NAME, DummyInterface.METHOD_NOARGVOID_ARGS); proxy.noArgVoidMethod(); @@ -82,53 +78,106 @@ mockCallables.verifyExpectations(); } - public void testMockProxyThrowsConfiguredExceptions() throws Throwable { + public void testExceptionsPropagatedThroughProxy() throws Throwable { final Throwable throwable = new DummyThrowable(); - mockCallable.setupCallThrow(throwable); - mockCallables.setupCall(mockCallable); + mockCallables.callException = throwable; - try { + try { proxy.noArgVoidMethod(); } catch (Throwable ex) { - assertSame("exception is caught by mock", throwable, ex); + assertSame("exception is caught by coreMock", throwable, ex); + return; } - } - - public void testMockToStringContainsName() { - AssertMo.assertIncludes("result of toString() should include name", MOCK_NAME, mock.toString()); + fail("Should have thrown exception"); } public void testMockVerifies() throws Exception { mockCallables.setExpectedVerifyCalls(1); - mock.verify(); + coreMock.verify(); // Can't use Verifier as we are verifying "verify" mockCallables.verifyExpectations(); } public void testProxyEquality() throws Exception { - mockCallables.setupCall(new Boolean(false)); - mockCallables.setExpectedCallCalls(0); + mockCallables.callResult = new Boolean(false); + + mockCallables.setExpectedCallCalls(0); - assertTrue("Should handle proxy equality without checking expectations", proxy.equals(proxy)); + assertTrue("Proxy equality is implemented directly", proxy.equals(proxy)); Verifier.verifyObject(this); } - public void testProxyInEquality() throws Exception { - mockCallables.setupCall(new Boolean(false)); - mockCallables.addExpectedCall("equals", new Object[] {"not a proxy"}); + public void testProxyInequality() throws Exception { + mockCallables.callResult = new Boolean(false); + + mockCallables.addExpectedCall("equals", new Object[] {"not a proxy"}); assertFalse("Should handle proxy inequality by calling through", proxy.equals("not a proxy")); Verifier.verifyObject(this); } - + + public void testCallingGetMockNameOnProxyReturnsNameOfUnderlyingMock() { + mockCallables.setExpectedCallCalls(0); + + assertEquals("proxy.getMockName() returns name of underlying mock", MOCK_NAME, proxy.getMockName()); + + Verifier.verifyObject(this); + } + + public void testMockNameFromClass() throws Exception { + assertEquals("mockString", CoreMock.mockNameFromClass(String.class)); + } + + public void testMockToStringContainsName() { + AssertMo.assertIncludes("result of toString() should include name", MOCK_NAME, coreMock.toString()); + } + public void testProxyToString() throws Exception { - assertEquals("Should get a mock name without touching the underlying mock", MOCK_NAME, DynamicUtil.proxyToString(proxy)); - mock.verify(); // should not fail on a proxyToString call + assertEquals("Should get a coreMock name without touching the underlying coreMock", MOCK_NAME, DynamicUtil.proxyToString(proxy)); + coreMock.verify(); // should not fail on a proxyToString call } + public void testAddAnExpectation() { + mockCallables.addExpectedExpect(mockCallable); + + coreMock.expect(mockCallable); + + mockCallables.verifyExpectations(); + } + + public void testAddAStub() { + mockCallables.addExpectedMatch(mockCallable); + + coreMock.stub(mockCallable); + + mockCallables.verifyExpectations(); + } + + public void testReset() { + mockCallables.resetCalls.setExpected(1); + + coreMock.reset(); + + mockCallables.verifyExpectations(); + } + + public void testVerifyFailuresIncludeMockName() { + mockCallables.verifyFailure = new AssertionFailedError("verify failure"); + + mockCallables.setExpectedVerifyCalls(1); + + try { + coreMock.verify(); + } catch (AssertionFailedError expected) { + AssertMo.assertIncludes("Should include mock name", MOCK_NAME, expected.getMessage()); + mockCallables.verifyExpectations(); + return; + } + fail("Should have thrown exception"); + } } Index: CallBagTest.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/test/mockobjects/dynamic/CallBagTest.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- CallBagTest.java 9 Jul 2003 02:14:00 -0000 1.9 +++ CallBagTest.java 9 Jul 2003 23:54:20 -0000 1.10 @@ -1,183 +1,152 @@ package test.mockobjects.dynamic; -import com.mockobjects.dynamic.*; -import com.mockobjects.util.*; - -import junit.framework.*; - +import com.mockobjects.dynamic.CallBag; +import com.mockobjects.dynamic.Invocation; +import com.mockobjects.util.AssertMo; +import junit.framework.Assert; +import junit.framework.AssertionFailedError; +import junit.framework.TestCase; + +/** + * Copyright mockobjects.com 09-Jul-2003 + */ public class CallBagTest extends TestCase { - final String METHOD_A_NAME = "methodA"; - final String METHOD_A_RESULT = "resultA"; - final String METHOD_B_NAME = "methodB"; - final String METHOD_B_RESULT = "resultB"; - - final Throwable METHOD_A_EXCEPTION = new DummyThrowable("Configured test throwable"); - final String[] METHOD_A_ARGS = new String[] { "a1", "a2" }; - final Invocation METHOD_A_INVOCATION = new Invocation(METHOD_A_NAME, METHOD_A_ARGS); - - final ConstraintMatcher METHOD_A_CONSTRAINTS = C.args(C.eq("a1"), C.eq("a2")); - final String[] METHOD_B_ARGS = new String[] { "b1", "b2" }; - final Invocation METHOD_B_INVOCATION = new Invocation(METHOD_B_NAME, METHOD_B_ARGS); - - private CallBag callBag = new CallBag(); - - private MockCallable methodA = new MockCallable("method A"); - private MockCallable methodB = new MockCallable("method B"); - private MockCallable mockCallable = new MockCallable("mock callable"); - - - public CallBagTest(String name) { - super(name); - } - - public void testCallFailsOnEmptySet() throws Throwable { - try { - callBag.call(new Invocation("missingMethod", new Object[0])); - } catch (AssertionFailedError ex) { - AssertMo.assertIncludes("reports empty set in error message", "no methods", ex.getMessage()); - - return; - } - - fail("Should fail for a missing item"); - } - - public void testCallPassedToContainedElements() throws Throwable { - methodA.matches = true; - methodA.setupCallReturn(METHOD_A_RESULT); - - methodA.setExpectedMatches(METHOD_A_NAME, METHOD_A_ARGS); - methodA.callInvocation.setExpected(METHOD_A_INVOCATION); - - callBag.addExpect(methodB); - callBag.addExpect(methodA); - - assertSame("expected result from method A", METHOD_A_RESULT, callBag.call(METHOD_A_INVOCATION)); - - methodA.verifyExpectations(); - methodB.verifyExpectations(); - } - - public void testExpectOverridesMatch() throws Throwable { - - Callable methodASignature = new CallSignature(METHOD_A_NAME,METHOD_A_CONSTRAINTS, new ReturnStub("result1")); - Callable anotherMethodASignature = new CallSignature(METHOD_A_NAME,METHOD_A_CONSTRAINTS, new ReturnStub("result2")); - - callBag.addMatch(methodASignature); - callBag.addExpect(new CallOnceExpectation(anotherMethodASignature)); - - assertSame("expected result from method B, as expect has precendence over match", "result2", - callBag.call(METHOD_A_INVOCATION)); - } - - public void testCallPassedToContainedElementsOtherOrder() - throws Throwable { - methodA.matches = false; - methodB.setupCallReturn(METHOD_B_RESULT); - methodB.matches = true; - - methodB.callInvocation.setExpected(METHOD_B_INVOCATION); - methodB.setExpectedMatches(METHOD_B_NAME, METHOD_B_ARGS); - - callBag.addExpect(methodA); - callBag.addExpect(methodB); - - assertSame("expected result from method B", METHOD_B_RESULT, - callBag.call(METHOD_B_INVOCATION)); - - methodA.verifyExpectations(); - methodB.verifyExpectations(); - } - - public void testConfiguredResultReturned() throws Throwable { - final String result = "result"; - - mockCallable.setupCallReturn(result); - mockCallable.matches = true; - - callBag.addExpect(mockCallable); - - assertSame("result is returned by mock", result, callBag.call(new Invocation("method", new Object[0]))); - } - - public void testCallableThrowableThrown() - throws Throwable { - final Throwable throwable = new DummyThrowable(); - - mockCallable.matches = true; - mockCallable.setupCallThrow(throwable); - - callBag.addExpect(mockCallable); - - try { - callBag.call(new Invocation("anyMethod", new String[0])); - } catch (Throwable ex) { - assertSame("exception was thrown by mock", throwable, ex); - } - } - - public void testEmptySetVerifies() throws Exception { - callBag.verify(); - } - - public void testFailureIfNoElementMatches() throws Throwable { - final String methodCName = "methodC"; - final String[] methodCArgs = { "c1", "c2" }; - final Invocation methodCInvocation = new Invocation(methodCName, methodCArgs); - - methodA.setExpectedMatches(methodCName, methodCArgs); - methodA.matches = false; - methodA.callInvocation.setExpectNothing(); - methodB.callInvocation.setExpected(methodCInvocation); - methodB.matches = false; - methodB.callInvocation.setExpectNothing(); - - callBag.addExpect(methodA); - callBag.addExpect(methodB); - - try { - callBag.call(methodCInvocation); - } catch (AssertionFailedError ex) { - AssertMo.assertIncludes("method name is in error message", "methodC", ex.getMessage()); - AssertMo.assertIncludes("argument is in error message (1)", methodCArgs[0], ex.getMessage()); - AssertMo.assertIncludes("argument is in error message (2)", methodCArgs[1], ex.getMessage()); - - AssertMo.assertIncludes("shows set contents (A)", methodA.getDescription(), ex.getMessage()); - AssertMo.assertIncludes("shows set contents (B)", methodB.getDescription(), ex.getMessage()); - - return; - } - - fail("Should fail for a missing item"); - } - - public void testVerifiesIfAllContainedElementsVerify() - throws Throwable { - methodA.setExpectedVerifyCalls(1); - methodB.setExpectedVerifyCalls(1); - - callBag.addExpect(methodA); - callBag.addExpect(methodB); - callBag.verify(); - - methodA.verifyExpectations(); - methodB.verifyExpectations(); - } - - public void testVerifyFailsIfContainedElementDoesNotVerify() - throws Exception { - methodA.setExpectedVerifyCalls(1); - methodA.setupVerifyThrow(new AssertionFailedError("verify failed")); - callBag.addExpect(methodA); - - try { - callBag.verify(); - } catch (AssertionFailedError ex) { - methodA.verifyExpectations(); - - return; - } - - fail("Should have got a failure for contained element failing"); - } + public CallBagTest(String name) { + super(name); + } + + private MockCallable mockCallable = new MockCallable("mock callable"); + private MockCallableList mockExpected = new MockCallableList(); + private MockCallableList mockStubs = new MockCallableList(); + private Invocation dummyInvocation = new Invocation("missingMethod", new Object[0]); + + private CallBag callBag = new CallBag(mockExpected, mockStubs); + + public void testAddExpectation() { + mockExpected.addedCallables.addExpected(mockCallable); + mockStubs.addedCallables.setExpectNothing(); + + callBag.addExpect(mockCallable); + + verifyAll(); + } + + public void testAddStub() { + mockExpected.addedCallables.setExpectNothing(); + mockStubs.addedCallables.addExpected(mockCallable); + + callBag.addMatch(mockCallable); + + verifyAll(); + } + + public void testResetBothExpectationsAndStubs() { + mockExpected.clearCalls.setExpected(1); + mockStubs.clearCalls.setExpected(1); + + callBag.reset(); + + verifyAll(); + } + + public void testCallFailsWhenNoExpectationsOrStubs() throws Throwable { + mockExpected.lastMatchingCall = null; + mockStubs.lastMatchingCall = null; + mockExpected.isEmpty = true; + + mockExpected.lastMatchingCallInvocation.setExpected(dummyInvocation); + mockStubs.lastMatchingCallInvocation.setExpected(dummyInvocation); + + try { + callBag.call(dummyInvocation); + } catch (AssertionFailedError ex) { + AssertMo.assertIncludes("reports empty list", "no methods", ex.getMessage()); + verifyAll(); + return; + } + fail("Should fail for a missing item"); + } + + public void testCallReportsMissingMethodWhenNothingMatches() throws Throwable { + mockExpected.lastMatchingCall = null; + mockStubs.lastMatchingCall = null; + mockExpected.applied = mockCallable; + + mockExpected.lastMatchingCallInvocation.setExpected(dummyInvocation); + mockStubs.lastMatchingCallInvocation.setExpected(dummyInvocation); + + try { + callBag.call(dummyInvocation); + } catch (AssertionFailedError ex) { + AssertMo.assertIncludes("reports missing method", mockCallable.getDescription(), ex.getMessage()); + verifyAll(); + return; + } + fail("Should fail for a missing item"); + } + + public void testCallTriesExpectationsBeforeStubs() throws Throwable { + mockExpected.lastMatchingCall = mockCallable; + mockStubs.lastMatchingCall = null; + mockCallable.setupCallReturn("call result"); + + mockExpected.lastMatchingCallInvocation.setExpected(dummyInvocation); + mockStubs.lastMatchingCallInvocation.setExpectNothing(); + mockCallable.callInvocation.setExpected(dummyInvocation); + + assertEquals("Call should return", "call result", callBag.call(dummyInvocation)); + + verifyAll(); + } + + public void testCallTriesStubsIfNoExpectations() throws Throwable { + mockExpected.lastMatchingCall = null; + mockStubs.lastMatchingCall = mockCallable; + mockCallable.setupCallReturn("call result"); + + mockExpected.lastMatchingCallInvocation.setExpected(dummyInvocation); + mockStubs.lastMatchingCallInvocation.setExpected(dummyInvocation); + mockCallable.callInvocation.setExpected(dummyInvocation); + + assertEquals("Call should return", "call result", callBag.call(dummyInvocation)); + + verifyAll(); + } + + public void testCallExceptionsArePropagatedUp() { + Throwable throwable = new Throwable(); + mockExpected.lastMatchingCall = mockCallable; + mockCallable.setupCallThrow(throwable); + + try { + callBag.call(dummyInvocation); + } catch (Throwable ex) { + Assert.assertEquals("Should have caught throwable", throwable, ex); + return; + } + fail("Should throw throwable"); + } + + public void testVerifiesOnlyExpectationsNotStubs() { + mockExpected.verifyCalls.setExpected(1); + mockStubs.verifyCalls.setExpectNothing(); + + callBag.verify(); + + verifyAll(); + } + + public void testMatchesNotImplemented() { + try { + callBag.matches(dummyInvocation); + } catch (AssertionFailedError unused) { + return; + } + fail("Should have failed because not implemented"); + } + private void verifyAll() { + mockCallable.verifyExpectations(); + mockExpected.verifyExpectations(); + mockStubs.verifyExpectations(); + } } --- TestCallBag.java DELETED --- |
From: Steve F. <sm...@us...> - 2003-07-09 23:54:23
|
Update of /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic In directory sc8-pr-cvs1:/tmp/cvs-serv3011/src/core/com/mockobjects/dynamic Modified Files: CoreMock.java Mock.java Log Message: Tidied up Mock and CoreMock Reworked some of the tests to be more legible and simpler. Also, closer to mock implementation Index: CoreMock.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/CoreMock.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- CoreMock.java 7 Jul 2003 01:17:57 -0000 1.5 +++ CoreMock.java 9 Jul 2003 23:54:20 -0000 1.6 @@ -12,15 +12,15 @@ private String name; public CoreMock(Class mockedClass, String name, CallableCollection callables) { + this.proxy = Proxy.newProxyInstance(getClass().getClassLoader(), new Class[] { mockedClass }, this); this.name = name; this.invocationMatchers = callables; - this.proxy = Proxy.newProxyInstance(getClass().getClassLoader(), new Class[] { mockedClass }, this); } public Object proxy() { return this.proxy; } - + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { try { @@ -62,17 +62,17 @@ invocationMatchers.addMatch(invocationMatcher); } - protected boolean isCheckingEqualityOnProxy(Invocation invocation) { + private boolean isCheckingEqualityOnProxy(Invocation invocation) { return (invocation.getMethodName().equals("equals")) && (invocation.args.length == 1) && (Proxy.isProxyClass(invocation.args[0].getClass())); } - protected boolean isMockNameGetter(Invocation invocation) { + private boolean isMockNameGetter(Invocation invocation) { return (invocation.getMethodName().equals("getMockName")) && (invocation.args.length == 0); } public void reset() { - this.invocationMatchers.reset(); + invocationMatchers.reset(); } public static String mockNameFromClass(Class c) { Index: Mock.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/core/com/mockobjects/dynamic/Mock.java,v retrieving revision 1.31 retrieving revision 1.32 diff -u -r1.31 -r1.32 --- Mock.java 7 Jul 2003 01:19:21 -0000 1.31 +++ Mock.java 9 Jul 2003 23:54:20 -0000 1.32 @@ -38,7 +38,36 @@ return C.args(C.eq(constraintArg)); } } - + + public void expect(String methodName, ConstraintMatcher args) { + coreMock.expect(callableFactory.createCallExpectation(callableFactory.createVoidCallable(methodName, args))); + } + + + public void expectAndReturn(String methodName, ConstraintMatcher args, Object result) { + coreMock.expect(callableFactory.createCallExpectation(callableFactory.createReturnCallable(methodName, args, result))); + } + + public void expectAndThrow(String methodName, ConstraintMatcher args, Throwable exception) { + coreMock.expect(callableFactory.createCallExpectation(callableFactory.createThrowableCallable(methodName, args, exception))); + } + + public void match(String methodName, ConstraintMatcher args) { + coreMock.stub(callableFactory.createVoidCallable(methodName, args)); + } + + public void matchAndReturn(String methodName, ConstraintMatcher args, Object result) { + coreMock.stub(callableFactory.createReturnCallable(methodName, args, result)); + } + + public void matchAndThrow(String methodName, ConstraintMatcher args, Throwable throwable) { + coreMock.stub(callableFactory.createThrowableCallable(methodName, args, throwable)); + } + + /* + * --- Sugar methods ---- + */ + public void expect(String methodName) { expect(methodName, C.NO_ARGS); } @@ -47,56 +76,44 @@ expect(methodName, createConstraintMatcher(singleEqualArg)); } - public void expect(String methodName, ConstraintMatcher args) { - coreMock.expect(callableFactory.createCallExpectation(callableFactory.createVoidCallable(methodName, args))); - } - public void expectAndReturn(String methodName, Object result) { - this.expectAndReturn(methodName, C.NO_ARGS, result); + expectAndReturn(methodName, C.NO_ARGS, result); } public void expectAndReturn(String methodName, boolean result) { - this.expectAndReturn(methodName, new Boolean(result)); + expectAndReturn(methodName, new Boolean(result)); } public void expectAndReturn(String methodName, int result) { - this.expectAndReturn(methodName, new Integer(result)); + expectAndReturn(methodName, new Integer(result)); } public void expectAndReturn(String methodName, Object singleEqualArg, Object result) { - this.expectAndReturn(methodName, createConstraintMatcher(singleEqualArg), result); + expectAndReturn(methodName, createConstraintMatcher(singleEqualArg), result); } public void expectAndReturn(String methodName, Object singleEqualArg, boolean result) { - this.expectAndReturn(methodName, singleEqualArg, new Boolean(result)); + expectAndReturn(methodName, singleEqualArg, new Boolean(result)); } public void expectAndReturn(String methodName, Object singleEqualArg, int result) { - this.expectAndReturn(methodName, singleEqualArg, new Integer(result)); + expectAndReturn(methodName, singleEqualArg, new Integer(result)); } public void expectAndReturn(String methodName, ConstraintMatcher args, boolean result) { - this.expectAndReturn(methodName, args, new Boolean(result)); + expectAndReturn(methodName, args, new Boolean(result)); } public void expectAndReturn(String methodName, ConstraintMatcher args, int result) { - this.expectAndReturn(methodName, args, new Integer(result)); + expectAndReturn(methodName, args, new Integer(result)); } - public void expectAndReturn(String methodName, ConstraintMatcher args, Object result) { - coreMock.expect(callableFactory.createCallExpectation(callableFactory.createReturnCallable(methodName, args, result))); - } - public void expectAndThrow(String methodName, Throwable exception) { - this.expectAndThrow(methodName, C.NO_ARGS, exception); + expectAndThrow(methodName, C.NO_ARGS, exception); } public void expectAndThrow(String methodName, Object singleEqualArg, Throwable exception) { - this.expectAndThrow(methodName, createConstraintMatcher(singleEqualArg), exception); - } - - public void expectAndThrow(String methodName, ConstraintMatcher args, Throwable exception) { - coreMock.expect(callableFactory.createCallExpectation(callableFactory.createThrowableCallable(methodName, args, exception))); + expectAndThrow(methodName, createConstraintMatcher(singleEqualArg), exception); } public void match(String methodName) { @@ -115,74 +132,62 @@ match(methodName, new Boolean(singleEqualArg)); } - public void match(String methodName, ConstraintMatcher args) { - coreMock.stub(callableFactory.createVoidCallable(methodName, args)); - } - public void matchAndReturn(String methodName, Object result) { - this.matchAndReturn(methodName, C.NO_ARGS, result); + matchAndReturn(methodName, C.NO_ARGS, result); } public void matchAndReturn(String methodName, boolean result) { - this.matchAndReturn(methodName, new Boolean(result)); + matchAndReturn(methodName, new Boolean(result)); } public void matchAndReturn(String methodName, int result) { - this.matchAndReturn(methodName, new Integer(result)); + matchAndReturn(methodName, new Integer(result)); } public void matchAndReturn(String methodName, Object singleEqualArg, Object result) { - this.matchAndReturn(methodName, createConstraintMatcher(singleEqualArg), result); + matchAndReturn(methodName, createConstraintMatcher(singleEqualArg), result); } public void matchAndReturn(String methodName, boolean singleEqualArg, Object result) { - this.matchAndReturn(methodName, new Boolean(singleEqualArg), result); + matchAndReturn(methodName, new Boolean(singleEqualArg), result); } public void matchAndReturn(String methodName, int singleEqualArg, Object result) { - this.matchAndReturn(methodName, new Integer(singleEqualArg), result); + matchAndReturn(methodName, new Integer(singleEqualArg), result); } public void matchAndReturn(String methodName, Object singleEqualArg, boolean result) { - this.matchAndReturn(methodName, singleEqualArg, new Boolean(result)); + matchAndReturn(methodName, singleEqualArg, new Boolean(result)); } public void matchAndReturn(String methodName, Object singleEqualArg, int result) { - this.matchAndReturn(methodName, singleEqualArg, new Integer(result)); + matchAndReturn(methodName, singleEqualArg, new Integer(result)); } public void matchAndReturn(String methodName, ConstraintMatcher args, boolean result) { - this.matchAndReturn(methodName, args, new Boolean(result)); + matchAndReturn(methodName, args, new Boolean(result)); } public void matchAndReturn(String methodName, ConstraintMatcher args, int result) { - this.matchAndReturn(methodName, args, new Integer(result)); - } - - public void matchAndReturn(String methodName, ConstraintMatcher args, Object result) { - coreMock.stub(callableFactory.createReturnCallable(methodName, args, result)); + matchAndReturn(methodName, args, new Integer(result)); } public void matchAndThrow(String methodName, Throwable throwable) { - this.matchAndThrow(methodName, C.NO_ARGS, throwable); + matchAndThrow(methodName, C.NO_ARGS, throwable); } public void matchAndThrow(String methodName, Object singleEqualArg, Throwable throwable) { - this.matchAndThrow(methodName, createConstraintMatcher(singleEqualArg), throwable); + matchAndThrow(methodName, createConstraintMatcher(singleEqualArg), throwable); } public void matchAndThrow(String methodName, boolean singleEqualArg, Throwable throwable) { - this.matchAndThrow(methodName,new Boolean(singleEqualArg), throwable); + matchAndThrow(methodName,new Boolean(singleEqualArg), throwable); } public void matchAndThrow(String methodName, int singleEqualArg, Throwable throwable) { - this.matchAndThrow(methodName,new Integer(singleEqualArg), throwable); + matchAndThrow(methodName,new Integer(singleEqualArg), throwable); } - public void matchAndThrow(String methodName, ConstraintMatcher args, Throwable throwable) { - coreMock.stub(callableFactory.createThrowableCallable(methodName, args, throwable)); - } - /** @deprecated @see OrderedMock */ public void expect(String methodName, CallSequence deprecated) { |