in-memory messages?

13 views
Skip to first unread message

ro...@cgl.ucsf.edu

unread,
Nov 13, 2013, 5:52:20 PM11/13/13
to smock...@googlegroups.com
   mockServer.expect(anything()).andRespond(withMessage("response1.xml"));

It would be nice if there was an in-memory way to pass a message. If there is, it would be nice to have javadoc to help find it. It would also be nice to respond to one msg type one way, and another differently, without matching exact content.

Finally, it would be nice to have the ability to add printlns in between the matched expectation and the action.

Thanks,
Bill

Lukáš Křečan

unread,
Nov 16, 2013, 4:17:00 AM11/16/13
to smock...@googlegroups.com
Hi,
ďż˝
1) Can you please clarify, what you mean by in-memory passing of messages? If you do not want to load messages from files, you can use StringSource or StreamSource as a parameter of withMessage().
2) You can add multiple responses like in testMultiple test here https://smock.googlecode.com/hg/samples/springws-client-test/src/test/java/net/javacrumbs/calc/ClientTest.java
3) There is not built-in support, but you can implement RequestMatcher wrapper to log whatever you need

�� Cheers
����� Lukas




On 13.11.2013 23:52, ro...@cgl.ucsf.edu wrote:
� �mockServer.expect(anything()).andRespond(withMessage("response1.xml"));
--
Tuto zpr�vu jste obdr�eli, proto�e jste p�ihl�eni k odb�ru skupiny smock-info ve Skupin�ch Google.
Pokud chcete zru�it odb�r skupiny, aby v�m z n� ji� nechodily e-maily, za�lete e-mail na adresu smock-info+...@googlegroups.com.
Dal�� mo�nosti najdete na adrese https://groups.google.com/groups/opt_out.

ro...@cgl.ucsf.edu

unread,
Nov 18, 2013, 4:26:25 PM11/18/13
to smock...@googlegroups.com
Thanks, didn't find 1) documented or exampled, but it sounds like what I have in mind. For 2) I was thinking of something like this (demonstrating 2 with **, 1 with the response):

   String response = "...";
   mockServer.expect(anyClass(**QueryType1.class**)).andRespond(withMessage(response));

3) sounds like it would require modifying the source. If you use JMock at all, you may see why it's desirable.

Lukáš Křečan

unread,
Nov 19, 2013, 4:09:57 AM11/19/13
to smock...@googlegroups.com
Hi,
ďż˝ what I have been trying to say, is that you can implement the missing pieces yourself, without modifying the code. It just matter of implementing the right interface and creation of a static factory class. For example, for the logging, you can implement RequestMatcher interface and wrap another matcher. Something like this (although in a completely different context)ďż˝ https://github.com/lukas-krecan/hamcrest-logger/blob/master/src/main/java/net/javacrumbs/hamcrest/logger/HamcrestLoggerMatcher.java

The same applies to your anyClass(**QueryType1.class**). It should be quite simple to implement it.
ďż˝ Cheers
��� Lukas


On 18/11/13 22:26, ro...@cgl.ucsf.edu wrote:
Thanks, didn't find 1) documented or exampled, but it sounds like what I have in mind. For 2) I was thinking of something like this (demonstrating 2 with **, 1 with the response):

� �String response = "...";
� �mockServer.expect(anyClass(**QueryType1.class**)).andRespond(withMessage(response));

3) sounds like it would require modifying the source. If you use JMock at all, you may see why it's desirable.


On Saturday, November 16, 2013 1:17:00 AM UTC-8, Luk� K�e�an wrote:
Hi,
ďż˝
1) Can you please clarify, what you mean by in-memory passing of messages? If you do not want to load messages from files, you can use StringSource or StreamSource as a parameter of withMessage().
2) You can add multiple responses like in testMultiple test here https://smock.googlecode.com/hg/samples/springws-client-test/src/test/java/net/javacrumbs/calc/ClientTest.java
3) There is not built-in support, but you can implement RequestMatcher wrapper to log whatever you need

�� Cheers
����� Lukas




On 13.11.2013 23:52, ro...@cgl.ucsf.edu wrote:
� �mockServer.expect(anything()).andRespond(withMessage("response1.xml"));

It would be nice if there was an in-memory way to pass a message. If there is, it would be nice to have javadoc to help find it. It would also be nice to respond to one msg type one way, and another differently, without matching exact content.

Finally, it would be nice to have the ability to add printlns in between the matched expectation and the action.

Thanks,
Bill
--
Tuto zpr�vu jste obdr�eli, proto�e jste p�ihl�eni k odb�ru skupiny smock-info ve Skupin�ch Google.
Pokud chcete zru�it odb�r skupiny, aby v�m z n� ji� nechodily e-maily, za�lete e-mail na adresu smock-info+...@googlegroups.com.
Dal�� mo�nosti najdete na adrese https://groups.google.com/groups/opt_out.

Lukáš Křečan

unread,
Nov 19, 2013, 4:11:36 AM11/19/13
to smock...@googlegroups.com


On 18/11/13 22:26, ro...@cgl.ucsf.edu wrote:
Thanks, didn't find 1) documented or exampled, but it sounds like what I have in mind. For 2) I was thinking of something like this (demonstrating 2 with **, 1 with the response):

� �String response = "...";
� �mockServer.expect(anyClass(**QueryType1.class**)).andRespond(withMessage(response));

3) sounds like it would require modifying the source. If you use JMock at all, you may see why it's desirable.


On Saturday, November 16, 2013 1:17:00 AM UTC-8, Luk� K�e�an wrote:
Hi,
ďż˝
1) Can you please clarify, what you mean by in-memory passing of messages? If you do not want to load messages from files, you can use StringSource or StreamSource as a parameter of withMessage().
2) You can add multiple responses like in testMultiple test here https://smock.googlecode.com/hg/samples/springws-client-test/src/test/java/net/javacrumbs/calc/ClientTest.java
3) There is not built-in support, but you can implement RequestMatcher wrapper to log whatever you need

�� Cheers
����� Lukas




On 13.11.2013 23:52, ro...@cgl.ucsf.edu wrote:
� �mockServer.expect(anything()).andRespond(withMessage("response1.xml"));

It would be nice if there was an in-memory way to pass a message. If there is, it would be nice to have javadoc to help find it. It would also be nice to respond to one msg type one way, and another differently, without matching exact content.

Finally, it would be nice to have the ability to add printlns in between the matched expectation and the action.

Thanks,
Bill
--
Tuto zpr�vu jste obdr�eli, proto�e jste p�ihl�eni k odb�ru skupiny smock-info ve Skupin�ch Google.
Pokud chcete zru�it odb�r skupiny, aby v�m z n� ji� nechodily e-maily, za�lete e-mail na adresu smock-info+...@googlegroups.com.
Dal�� mo�nosti najdete na adrese https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages