Hi Geoff,

Geoff Groos wrote:

> Thanks Jörg,
> 
> I created an account but have run into some http:500s and what-not from
> jira while creating my account. I'll create the issue when I get all this
> stuff sorted out.
> 
> The second question I have, semi-related, is how would you guys suggest
> doing generational (ie cross-model-version) testing?
> 
> What I'd like to do is have tests like this:
> 
> public static class TestFixture{
> 
>     public static class MyModel{ //v1
>         Public int x;
>         Public int y;
>     }
> 
>     //And attempt to deserialize (using our moderately customized xstream
>     serializer) it as
> 
>     public static class MyModel{ //v2
>         Public int x;
>         Public int y;
>         Publix int z;
>     }
> 
>     //in something like this
>     @Test
>     public void
>     
when_we_added_an_extra_int_field_for_feature_1234_we_didnt_break_anything_because_our_deserialization_flow_is_so_nifty()
{
>            //setup
>         OurSerializerThatDelegatesToXStream serializer =
>         testHarness.provideSerializer();
> 
>         //act
>         String serialized = serializer.serialize(makeVersion1OfMyModel());
>         MyModel myModelV2 = serializer.deserialize(serialized);
> 
>         //assert
>         assertThat(myModelV2.z).followsProperDomainLogic();
>     }
> }
> 
> But of course Javac is going to complain about 2 'MyClass'es.
> 
> Any suggestions?

Why don't you simply take the XML representation of model 1 and deserialize 
it into model 2? Why do you still need to generate the XML representation of 
model 1?

> I was thinking about trying using 2 different canonical names (so MyClass1
> and MyClass2), and then add an entry to the aliasMap as part of the setup
> logic to tell XStream that MyClass1 is-a MyClass2.
> 
> But since that doesn’t involve nearly enough overly complex code, the
> other thing I was thinking of doing is copy-pasting class files around and
> then manually loading via some stupidly sophisticated mechanism. With a
> couple extra ant targets I could probably even make this bearable.

The strategy to handle newer versions of a class depends on the type of 
modification. There's no general rule.

See http://xstream.codehaus.org/faq.html#Serialization_newer_class_versions 
for some ideas.

Cheers,
Jörg


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to