On 16/02/12 02:54, Jeff Wang wrote:
Sorry, didn't see this message until just now...

On Fri, Feb 3, 2012 at 9:42 AM, Sergey Beryozkin<[email protected]>  wrote:
On 03/02/12 03:02, Jeff Wang wrote:

I'm having two difficulties with testing.  One practical, one theoretical.

practical:
If I have any @Context annotations, I can't actually call the service
via a client proxy.  I need to code the call separately (and
manually.)

I updated the proxies to simply ignore explicit Context parameters, they are
only populated on the server side...You'd need to pass 'null' if you have
explicit Context params, in meantime try injecting Contexts into fields...

I've had @Context UriInfo turn up null before when field-injected
(same code works method injected), but that was a long time ago.  I'll
try this later today.

theoretical:
Using the same JSON compile unit on the service and the test seems to
defeat the purpose.  If I have a webpage hitting my JAX-RS server, and
I change the name of a field, I'd like to have my test point that out,
so that when I fix my test, I can let my web team know.  But if I use
the same compile unit, whatever I change, even accidentally, will
marshall and unmarshall correctly, the actual user of the API may then
run into issues.

I'm not sure I understand completely, but just in case, it's possible to
adapt the in/out JSON sequences to the expected ones with the help of
TransformFeature, but only if the default JSONProvider is used

What I mean is, let's say I have a Book object.  And I accidentally
add "asdf" to the name element of a field.  I would have broken every
single one of the actual clients that called Bookstore.findBook(id),
but if I use either a direct client call or a proxy, the tests would
pass.  Essentially, if you're using the same class file on the client
side and the server side, all you're really doing is testing that
marshall and unmarshall works (the framework.)  Not that your JAXB
mapping or CXF annotation is correct (the actual code that you need to
write.)


I think I see what you mean this time...Note though, TransformFeature can also be used to 'drop' the new elements the clients which are only aware of the previous 'version' of the given payload do not expect - sorry, may be it is off topic

Sergey

While testing the framework is useful and have pointed out some
mapping mistakes to me, I would bet that the majority of programmer
errors lie in the actual code, and not in the framework.

Jeff


Sergey


Jeff


--
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com

Reply via email to