You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@harmony.apache.org by Alexei Zakharov <al...@gmail.com> on 2006/06/22 15:12:07 UTC

[classlib] [beans] xml resource files in tests

Hi people,

While working on java.beans tests I've faced a funny problem. There
are tests for XMLEncoder that perform line by line comparison of the
encoder's output with static xml files from /test/resources folder
(string compare). And it seems that at some point of time someone
simply prepend Apache license to all static xmls and all tests fail
since then. :)
Since there is no easy way to force XMLEncoder to generate Apache
license, I see two possible resolutions:
1. Remove the license from xmls. I am not sure we can do that.
2. Replace string compare with xml compare, by means of sax parser for
example. Comments will be thrown away in this case.
Personally I like (2) more. However, it will take additional efforts.
Suggestions?

-- 
Alexei Zakharov,
Intel Middleware Product Division

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [classlib] [beans] xml resource files in tests

Posted by Geir Magnusson Jr <ge...@pobox.com>.
I thought I said it in public as well.  Sorry.

Alexei Zakharov wrote:
> Since this code is located in unit test IMHO it makes some sense to
> compare the output line by line with the desired content.  Of course
> it also can be (should be) read into DOM but I will need to refactor
> the tests to apply it.
> 
> BTW, Geir has said (in private) it is ok to simply remove the license
> from test data. So I'm going to do as he suggested.
> 
> Of course
> 
> 2006/6/26, Tim Ellison <t....@gmail.com>:
>> Should the tests be doing a line-by line comparison anyway?  i.e. I can
>> reformat the XML file and it still means the same thing, I would not
>> expect the test to fail.
>>
>> Can't you read the golden data into a DOM and check it is the same
>> (maybe Node.isEqualNode(Node) or thereabouts)?
>>
>> Regards,
>> Tim
>>
>> Alexei Zakharov wrote:
>> > Well, the real question I'd like to get an answer for was: is it
>> > really impossible to remove the license from these files?
>> >
>> > 2006/6/22, Alexei Zakharov <al...@gmail.com>:
>> >> Ilya, yes, it is technically possible. But IMHO is not very elegant at
>> >> the same time.
>> >>
>> >> 2006/6/22, Ilya Neverov <il...@gmail.com>:
>> >> > Hi,
>> >> >
>> >> > Is it easier to preprocess golden files data before the string
>> >> > comparison? Removing first XML comment with the text
>> >> > "Copyright*Apache" seems to be an action which can not modify
>> content
>> >> > used in the comparison.
>> >> >
>> >> > Thank you.
>> >> > Ilya Neverov,
>> >> > Intel Middleware Products Division
>> >> >
>> >> > On 6/22/06, Alexei Zakharov <al...@gmail.com> wrote:
>> >> > > Hi people,
>> >> > >
>> >> > > While working on java.beans tests I've faced a funny problem.
>> There
>> >> > > are tests for XMLEncoder that perform line by line comparison
>> of the
>> >> > > encoder's output with static xml files from /test/resources folder
>> >> > > (string compare). And it seems that at some point of time someone
>> >> > > simply prepend Apache license to all static xmls and all tests
>> fail
>> >> > > since then. :)
>> >> > > Since there is no easy way to force XMLEncoder to generate Apache
>> >> > > license, I see two possible resolutions:
>> >> > > 1. Remove the license from xmls. I am not sure we can do that.
>> >> > > 2. Replace string compare with xml compare, by means of sax parser
>> >> for
>> >> > > example. Comments will be thrown away in this case.
>> >> > > Personally I like (2) more. However, it will take additional
>> efforts.
>> >> > > Suggestions?
>> >> > >
>> >> > > --
>> >> > > Alexei Zakharov,
>> >> > > Intel Middleware Product Division
>> >
>>
>> -- 
>>
>> Tim Ellison (t.p.ellison@gmail.com)
>> IBM Java technology centre, UK.
>>
>> ---------------------------------------------------------------------
>> Terms of use : http://incubator.apache.org/harmony/mailing.html
>> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
>> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>>
>>
> 
> 

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [classlib] [beans] xml resource files in tests

Posted by Alexei Zakharov <al...@gmail.com>.
Since this code is located in unit test IMHO it makes some sense to
compare the output line by line with the desired content.  Of course
it also can be (should be) read into DOM but I will need to refactor
the tests to apply it.

BTW, Geir has said (in private) it is ok to simply remove the license
from test data. So I'm going to do as he suggested.

Of course

2006/6/26, Tim Ellison <t....@gmail.com>:
> Should the tests be doing a line-by line comparison anyway?  i.e. I can
> reformat the XML file and it still means the same thing, I would not
> expect the test to fail.
>
> Can't you read the golden data into a DOM and check it is the same
> (maybe Node.isEqualNode(Node) or thereabouts)?
>
> Regards,
> Tim
>
> Alexei Zakharov wrote:
> > Well, the real question I'd like to get an answer for was: is it
> > really impossible to remove the license from these files?
> >
> > 2006/6/22, Alexei Zakharov <al...@gmail.com>:
> >> Ilya, yes, it is technically possible. But IMHO is not very elegant at
> >> the same time.
> >>
> >> 2006/6/22, Ilya Neverov <il...@gmail.com>:
> >> > Hi,
> >> >
> >> > Is it easier to preprocess golden files data before the string
> >> > comparison? Removing first XML comment with the text
> >> > "Copyright*Apache" seems to be an action which can not modify content
> >> > used in the comparison.
> >> >
> >> > Thank you.
> >> > Ilya Neverov,
> >> > Intel Middleware Products Division
> >> >
> >> > On 6/22/06, Alexei Zakharov <al...@gmail.com> wrote:
> >> > > Hi people,
> >> > >
> >> > > While working on java.beans tests I've faced a funny problem. There
> >> > > are tests for XMLEncoder that perform line by line comparison of the
> >> > > encoder's output with static xml files from /test/resources folder
> >> > > (string compare). And it seems that at some point of time someone
> >> > > simply prepend Apache license to all static xmls and all tests fail
> >> > > since then. :)
> >> > > Since there is no easy way to force XMLEncoder to generate Apache
> >> > > license, I see two possible resolutions:
> >> > > 1. Remove the license from xmls. I am not sure we can do that.
> >> > > 2. Replace string compare with xml compare, by means of sax parser
> >> for
> >> > > example. Comments will be thrown away in this case.
> >> > > Personally I like (2) more. However, it will take additional efforts.
> >> > > Suggestions?
> >> > >
> >> > > --
> >> > > Alexei Zakharov,
> >> > > Intel Middleware Product Division
> >
>
> --
>
> Tim Ellison (t.p.ellison@gmail.com)
> IBM Java technology centre, UK.
>
> ---------------------------------------------------------------------
> Terms of use : http://incubator.apache.org/harmony/mailing.html
> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>
>


-- 
Alexei Zakharov,
Intel Middleware Product Division

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [classlib] [beans] xml resource files in tests

Posted by Thorbjørn Ravn Andersen <th...@gmail.com>.
Tim Ellison skrev  den 26-06-2006 13:22:
> Should the tests be doing a line-by line comparison anyway?  i.e. I can
> reformat the XML file and it still means the same thing, I would not
> expect the test to fail.
>   
James Clark defined Canonical XML in order to be able to compare xml 
documents as byte streams.

http://www.jclark.com/xml/canonxml.html

Perhaps this would be a good place to incorporate it?

-- 
  Thorbjørn


Re: [classlib] [beans] xml resource files in tests

Posted by Tim Ellison <t....@gmail.com>.
Should the tests be doing a line-by line comparison anyway?  i.e. I can
reformat the XML file and it still means the same thing, I would not
expect the test to fail.

Can't you read the golden data into a DOM and check it is the same
(maybe Node.isEqualNode(Node) or thereabouts)?

Regards,
Tim

Alexei Zakharov wrote:
> Well, the real question I'd like to get an answer for was: is it
> really impossible to remove the license from these files?
> 
> 2006/6/22, Alexei Zakharov <al...@gmail.com>:
>> Ilya, yes, it is technically possible. But IMHO is not very elegant at
>> the same time.
>>
>> 2006/6/22, Ilya Neverov <il...@gmail.com>:
>> > Hi,
>> >
>> > Is it easier to preprocess golden files data before the string
>> > comparison? Removing first XML comment with the text
>> > "Copyright*Apache" seems to be an action which can not modify content
>> > used in the comparison.
>> >
>> > Thank you.
>> > Ilya Neverov,
>> > Intel Middleware Products Division
>> >
>> > On 6/22/06, Alexei Zakharov <al...@gmail.com> wrote:
>> > > Hi people,
>> > >
>> > > While working on java.beans tests I've faced a funny problem. There
>> > > are tests for XMLEncoder that perform line by line comparison of the
>> > > encoder's output with static xml files from /test/resources folder
>> > > (string compare). And it seems that at some point of time someone
>> > > simply prepend Apache license to all static xmls and all tests fail
>> > > since then. :)
>> > > Since there is no easy way to force XMLEncoder to generate Apache
>> > > license, I see two possible resolutions:
>> > > 1. Remove the license from xmls. I am not sure we can do that.
>> > > 2. Replace string compare with xml compare, by means of sax parser
>> for
>> > > example. Comments will be thrown away in this case.
>> > > Personally I like (2) more. However, it will take additional efforts.
>> > > Suggestions?
>> > >
>> > > --
>> > > Alexei Zakharov,
>> > > Intel Middleware Product Division
> 

-- 

Tim Ellison (t.p.ellison@gmail.com)
IBM Java technology centre, UK.

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [classlib] [beans] xml resource files in tests

Posted by Alexei Zakharov <al...@gmail.com>.
Well, the real question I'd like to get an answer for was: is it
really impossible to remove the license from these files?

2006/6/22, Alexei Zakharov <al...@gmail.com>:
> Ilya, yes, it is technically possible. But IMHO is not very elegant at
> the same time.
>
> 2006/6/22, Ilya Neverov <il...@gmail.com>:
> > Hi,
> >
> > Is it easier to preprocess golden files data before the string
> > comparison? Removing first XML comment with the text
> > "Copyright*Apache" seems to be an action which can not modify content
> > used in the comparison.
> >
> > Thank you.
> > Ilya Neverov,
> > Intel Middleware Products Division
> >
> > On 6/22/06, Alexei Zakharov <al...@gmail.com> wrote:
> > > Hi people,
> > >
> > > While working on java.beans tests I've faced a funny problem. There
> > > are tests for XMLEncoder that perform line by line comparison of the
> > > encoder's output with static xml files from /test/resources folder
> > > (string compare). And it seems that at some point of time someone
> > > simply prepend Apache license to all static xmls and all tests fail
> > > since then. :)
> > > Since there is no easy way to force XMLEncoder to generate Apache
> > > license, I see two possible resolutions:
> > > 1. Remove the license from xmls. I am not sure we can do that.
> > > 2. Replace string compare with xml compare, by means of sax parser for
> > > example. Comments will be thrown away in this case.
> > > Personally I like (2) more. However, it will take additional efforts.
> > > Suggestions?
> > >
> > > --
> > > Alexei Zakharov,
> > > Intel Middleware Product Division

-- 
Alexei Zakharov,
Intel Middleware Product Division

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [classlib] [beans] xml resource files in tests

Posted by Alexei Zakharov <al...@gmail.com>.
Ilya, yes, it is technically possible. But IMHO is not very elegant at
the same time.

2006/6/22, Ilya Neverov <il...@gmail.com>:
> Hi,
>
> Is it easier to preprocess golden files data before the string
> comparison? Removing first XML comment with the text
> "Copyright*Apache" seems to be an action which can not modify content
> used in the comparison.
>
> Thank you.
> Ilya Neverov,
> Intel Middleware Products Division
>
> On 6/22/06, Alexei Zakharov <al...@gmail.com> wrote:
> > Hi people,
> >
> > While working on java.beans tests I've faced a funny problem. There
> > are tests for XMLEncoder that perform line by line comparison of the
> > encoder's output with static xml files from /test/resources folder
> > (string compare). And it seems that at some point of time someone
> > simply prepend Apache license to all static xmls and all tests fail
> > since then. :)
> > Since there is no easy way to force XMLEncoder to generate Apache
> > license, I see two possible resolutions:
> > 1. Remove the license from xmls. I am not sure we can do that.
> > 2. Replace string compare with xml compare, by means of sax parser for
> > example. Comments will be thrown away in this case.
> > Personally I like (2) more. However, it will take additional efforts.
> > Suggestions?
> >
> > --
> > Alexei Zakharov,
> > Intel Middleware Product Division



-- 
Alexei Zakharov,
Intel Middleware Product Division

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [classlib] [beans] xml resource files in tests

Posted by Ilya Neverov <il...@gmail.com>.
Hi,

Is it easier to preprocess golden files data before the string
comparison? Removing first XML comment with the text
"Copyright*Apache" seems to be an action which can not modify content
used in the comparison.

Thank you.
Ilya Neverov,
Intel Middleware Products Division

On 6/22/06, Alexei Zakharov <al...@gmail.com> wrote:
> Hi people,
>
> While working on java.beans tests I've faced a funny problem. There
> are tests for XMLEncoder that perform line by line comparison of the
> encoder's output with static xml files from /test/resources folder
> (string compare). And it seems that at some point of time someone
> simply prepend Apache license to all static xmls and all tests fail
> since then. :)
> Since there is no easy way to force XMLEncoder to generate Apache
> license, I see two possible resolutions:
> 1. Remove the license from xmls. I am not sure we can do that.
> 2. Replace string compare with xml compare, by means of sax parser for
> example. Comments will be thrown away in this case.
> Personally I like (2) more. However, it will take additional efforts.
> Suggestions?
>
> --
> Alexei Zakharov,
> Intel Middleware Product Division
>
> ---------------------------------------------------------------------
> Terms of use : http://incubator.apache.org/harmony/mailing.html
> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org