public void testCache() throws Exception
{
ResteasyProviderFactory.pushContext(Providers.class, getProviderFactory());
{
ContextResolver<JAXBContextFinder> resolver = getProviderFactory().getContextResolver(JAXBContextFinder.class, MediaType.APPLICATION_XML_TYPE);
JAXBContextFinder finder = resolver.getContext(Child.class);
JAXBContext ctx = finder.findCachedContext(Child.class, MediaType.APPLICATION_XML_TYPE, null);
JAXBContext ctx2 = finder.findCachedContext(Child.class, MediaType.APPLICATION_XML_TYPE, null);
Assert.assertTrue(ctx == ctx2);
}
{
ContextResolver<JAXBContextFinder> resolver = getProviderFactory().getContextResolver(JAXBContextFinder.class, MediaType.APPLICATION_JSON_TYPE);
JAXBContextFinder finder = resolver.getContext(Child.class);
JAXBContext ctx = finder.findCachedContext(Child.class, MediaType.APPLICATION_JSON_TYPE, null);
JAXBContext ctx2 = finder.findCachedContext(Child.class, MediaType.APPLICATION_JSON_TYPE, null);
Assert.assertTrue(ctx == ctx2);
}
{
MediaType mediaType = new MediaType("application", "fastinfoset");
ContextResolver<JAXBContextFinder> resolver = getProviderFactory().getContextResolver(JAXBContextFinder.class, mediaType);
JAXBContextFinder finder = resolver.getContext(Child.class);
JAXBContext ctx = finder.findCachedContext(Child.class, mediaType, null);
JAXBContext ctx2 = finder.findCachedContext(Child.class, mediaType, null);
Assert.assertTrue(ctx == ctx2);
}
}