You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by Eric Woods <wo...@gmail.com> on 2011/02/24 16:31:10 UTC
Testing XML/ATOM Serialization
Currently, testing the automated serialization from JSON to ATOM/XML is labor intensive and involves manually parsing XML. I think it would be easier to include test fixtures, local text files, which express a given server response in JSON, XML, and ATOM serializations. The unit tests can then compare against these local files to ensure the automated serialization matches the expected serialization in the test file.
A benefit to this approach (besides making it easier to test) is that the serialization in the text file can be clearly shown to third parties to reach consensus on the serialization format, whereas the XML parsing logic is more difficult to convey ;) What do you guys think?
- Eric W.
Re: Testing XML/ATOM Serialization
Posted by Eric Woods <wo...@gmail.com>.
I've submitted a patch which uses this new method, local test fixtures, here: https://issues.apache.org/jira/browse/SHINDIG-1511
- Eric W.
On Feb 26, 2011, at 1:39 PM, Eric Woods wrote:
> Completely agree, Matt. All comparisons will be deep comparisons between DOMs or JSONObjects. I've written a couple of utility methods to do the deep comparisons, which ignores whitespace and element ordering. So far, it's made the whole testing process MUCH cleaner and maintainable for future revisions to these data components.
>
> One question: I'm loading the test fixtures using Shindig's ResourceLoader. Unfortunately, this loader seems to require that the test data exist in a subdirectory of "content." I'd like to keep the fixture data within a "fixture" folder alongside the actual Java test code. Does anyone have a preferred way of doing this?
>
> Thanks,
> - Eric W.
Re: Testing XML/ATOM Serialization
Posted by Eric Woods <wo...@gmail.com>.
Completely agree, Matt. All comparisons will be deep comparisons between DOMs or JSONObjects. I've written a couple of utility methods to do the deep comparisons, which ignores whitespace and element ordering. So far, it's made the whole testing process MUCH cleaner and maintainable for future revisions to these data components.
One question: I'm loading the test fixtures using Shindig's ResourceLoader. Unfortunately, this loader seems to require that the test data exist in a subdirectory of "content." I'd like to keep the fixture data within a "fixture" folder alongside the actual Java test code. Does anyone have a preferred way of doing this?
Thanks,
- Eric W.
Re: Testing XML/ATOM Serialization
Posted by Matthew G Marum <mg...@us.ibm.com>.
I'm all for making things easier to test, but we may want to be careful
about doing a string to string comparisons between an expected output file
and the serialization. Whitespace changes, element reordering, or other
subtle syntactical differences could cause the tests to fail when the
semantics haven't changed at all.
So basically, I like this approach so long as the comparison is deeper than
string.equals().
Matt Marum
|------------>
| From: |
|------------>
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|Eric Woods <wo...@gmail.com> |
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| To: |
|------------>
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|dev@shindig.apache.org |
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Date: |
|------------>
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|02/24/2011 10:32 AM |
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Subject: |
|------------>
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|Testing XML/ATOM Serialization |
>--------------------------------------------------------------------------------------------------------------------------------------------------|
Currently, testing the automated serialization from JSON to ATOM/XML is
labor intensive and involves manually parsing XML. I think it would be
easier to include test fixtures, local text files, which express a given
server response in JSON, XML, and ATOM serializations. The unit tests can
then compare against these local files to ensure the automated
serialization matches the expected serialization in the test file.
A benefit to this approach (besides making it easier to test) is that the
serialization in the text file can be clearly shown to third parties to
reach consensus on the serialization format, whereas the XML parsing logic
is more difficult to convey ;) What do you guys think?
- Eric W.