You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Mark Leicester <ma...@energyintellect.com> on 2003/08/09 15:08:14 UTC

AbstractSerializerTestCase

Hi Stephan,

I notice that there is no serializer test case, so I have written one using
a byte[] to store the output of the serializer for subsequent comparison
with another source.

Do you have plans for serializer test cases, and if so does this code fit
the bill? I thought I should post it to you and the list for comment before
I submit it as a patch.

I have not integrated it into the CompositeTestCase class.

It is called in the usual way, e.g.:

  public void testMIDISerializer() throws Exception
  {
    String type = "midi";
    String input = "resource://org/apache/cocoon/generation/Prelude.xmi";
    Parameters parameters = new Parameters();
    String control = "resource://org/apache/cocoon/generation/Prelude.mid";

    assertIdentical(loadByteArray(control),
      serialize(type, parameters, load(input)));
  }

Mark


Re: AbstractSerializerTestCase

Posted by Mark Leicester <ma...@energyintellect.com>.
On 11/08/2003 9:29, "Stephan Michels" <st...@apache.org> wrote:

> On Sat, 9 Aug 2003, Mark Leicester wrote:
> 
>> Do you have plans for serializer test cases, and if so does this code fit
>> the bill? I thought I should post it to you and the list for comment before
>> I submit it as a patch.
 
> Code is always welcome. I havn't written a Serializer testcase until now,
> because I find it difficult to test binary data. In my POV you must
> generate the expected output with a different tool than the component you
> want to test. In the case of binary data, it is not that easy.
Quite right. The chickens and the eggs.

In my case (with the XMidiGenerator and XMidiSerializer) I am trying to
confirm that a "round trip" has been successful, so for me this test is
ideal. After generating XML *from* my binary file I subsequently serialize
to a binary file which I hope is exactly the same as the original binary
file.

Also, I find that once I have finally succeeded in getting some code to work
it's good to have a test to confirm that if I make changes to it later, my
code is *still* working! So indeed, even if the expected output may have
been generated with the component I want to test, at least I can tell if the
component continues to behave consistently after I make changes.

> But anyway, I applied that patch.
Thanks!

Regards,
Mark


Re: AbstractSerializerTestCase

Posted by Stephan Michels <st...@apache.org>.

On Sat, 9 Aug 2003, Mark Leicester wrote:

> Hi Stephan,
>
> I notice that there is no serializer test case, so I have written one using
> a byte[] to store the output of the serializer for subsequent comparison
> with another source.
>
> Do you have plans for serializer test cases, and if so does this code fit
> the bill? I thought I should post it to you and the list for comment before
> I submit it as a patch.
>
> I have not integrated it into the CompositeTestCase class.
>
> It is called in the usual way, e.g.:
>
>   public void testMIDISerializer() throws Exception
>   {
>     String type = "midi";
>     String input = "resource://org/apache/cocoon/generation/Prelude.xmi";
>     Parameters parameters = new Parameters();
>     String control = "resource://org/apache/cocoon/generation/Prelude.mid";
>
>     assertIdentical(loadByteArray(control),
>       serialize(type, parameters, load(input)));
>   }

Code is always welcome. I havn't written a Serializer testcase until now,
because I find it difficult to test binary data. In my POV you must
generate the expected output with a different tool than the component you
want to test. In the case of binary data, it is not that easy.

But anyway, I applied that patch.

Thank you, Stephan.