Re: simple mock web service



paul wrote:
Thanks for all your help guys.

Gordon - you certainly got me going in the right direction, but I was
not able to find the end of the request - and I don't have any control
over what the request might be.

Andrew - I definitely do need to have a mock web service for what I'm
doing. What it is is that there are many client components, each
wrapped in a JUnit test; but the real web services are live, and
contain data which anyone can alter. The tests were failing simply
because someone somewhere had tweaked with the values, so what I wanted
to do was build an interceptor which forwards the request to the real
web service the first time, but whenever the same call was received
again, then it will return a cached response. The urls to the web
services are soft, and so as the tests run during the build, the
clients are pointed at the mock web services.


If you are writing a Unit test - then your class under test needs to be simulated 'as if' a web service framework would use it or provide a mock webserver framework for your class to call into. E.g. TDDing your own servlet class.


When unit testing, we are not acceptance testing, so we would not write a test that creates a client to connect to a remote webservice. We only write tests to exercise our classes that make up our application.

We would certainly not have any multi user client invocating upon the same mock.

Acceptance Tests (which are rarely written in xUnit - more likely in FitNesse, Watir, Selenium, etc) test the collaboration of our classes to see if we the feature is working.

Put another way...

Acceptance test  concerns Building the Right Code
Unit Tests       concerns Building the Code Right


To be a unit test - no file access, db access, network access should happen.

Chris - I hear what you are saying about how the String handles the
duff characters, but it is only a mock web service, the worst that can
happen is that a test will fail when it shouldn't have. Good to know
though, all the same. Your ByteArrayOutputStream works a treat - thanks
very much for that.

Paul

.



Relevant Pages

  • Re: Need to share data asynchronously between ASP.NET and Legacy S
    ... Otherise I would use the client side async web sevice stuff to some ... > would get the results of a specific request based on the request ... >> callbacks to communicate back to clients. ... >> very nicely and is fully based on Web Services and is transport agnostic. ...
    (microsoft.public.dotnet.distributed_apps)
  • Re: Best web server interface to D3
    ... I knew I would catch a flame from my request:) ... I have a client who has happily been ... D3, anything can connect into the middle-tier like web services, etc. ... This was written as a client rather than as a server because of often ...
    (comp.databases.pick)
  • Returning SoapFault as Envelope
    ... I have two web services, where first application receives a request and ... sends the request to the second web service. ... it the client application receives Error 404. ... SoapEnvelope response = new SoapEnvelope; ...
    (microsoft.public.dotnet.framework.webservices)
  • The underlying connection was closed - Remoting.Channels.Http.HttpClientTransportSink
    ... Web Services Client: ... closed: The request was c ... >System.Net.WebException: The underlying connection was ...
    (microsoft.public.dotnet.framework)
  • Re: How to return a user-defined data type object from a webservice?
    ... your client ... object coming from the server via the web service is in a different ... John Saunders | MVP - Windows Server System - Connected System Developer ... It's just not how Web Services works. ...
    (microsoft.public.dotnet.framework.webservices)