RestfulSerialization extends XStreamXMLSerialization { @Override protected XStream getXStream() { XStream xStream = super.getXStream(); MethodValueSupportConverter converter = new MethodValueSupportConverter(new ReflectionConverter(xStream.getMapper(), xStream.getReflectionProvider())); xStream.registerConverter(new LinkConverter(converter, restfulie, config)); return xStream; } RestfulSerialization(HttpServletResponse response, TypeNameExtractor extractor, Restfulie restfulie, Configuration config, ProxyInitializer initializer, XStreamBuilder builder);   }
@Test public void shouldReturnAnXStreamInstanceWithSupportToLinkConvertersBasedOnReflection() { RestfulSerialization serialization = new RestfulSerialization(null, null, null, null, null, XStreamBuilderImpl.cleanInstance()); XStream xstream = serialization.getXStream(); Converter converter = xstream.getConverterLookup().lookupConverterForType(CustomType.class); assertThat(converter.getClass(), is(typeCompatibleWith(LinkConverter.class))); }
@Test public void shouldUseTheDefaultConverterForTypesThatAreNotHypermediaAware() { RestfulSerialization serialization = new RestfulSerialization(null, null, null, null, null, XStreamBuilderImpl.cleanInstance()); XStream xstream = serialization.getXStream(); Converter converter = xstream.getConverterLookup().lookupConverterForType(CustomNonHMType.class); assertThat(converter.getClass(), is(typeCompatibleWith(ReflectionConverter.class))); }
@Test public void shouldAllowCustomXStreamRetrieval() { RestfulSerialization serialization = new RestfulSerialization(null, null, null, null, null, XStreamBuilderImpl.cleanInstance()) { @Override protected XStream getXStream() { XStream xStream = super.getXStream(); xStream.registerConverter(new MegaConverter()); return xStream; } }; XStream xstream = serialization.getXStream(); Converter converter = xstream.getConverterLookup().lookupConverterForType(CustomType.class); assertThat(converter.getClass(), is(typeCompatibleWith(MegaConverter.class))); converter = xstream.getConverterLookup().lookupConverterForType(CustomNonHMType.class); assertThat(converter.getClass(), is(typeCompatibleWith(MegaConverter.class))); }