* @version $Rev: 673544 $ $Date: 2008-07-02 16:26:10 -0700 (Wed, 02 Jul 2008) $
*/
public class JAXBContextCacheTestCase {
@Test
public void testCache() throws JAXBException {
JAXBContextCache cache = new JAXBContextCache();
JAXBContext context1 = cache.getJAXBContext(String.class);
JAXBContext context2 = cache.getJAXBContext(int.class);
JAXBContext context3 = cache.getJAXBContext(String[].class);
JAXBContext context4 = cache.getJAXBContext(Source.class);
Assert.assertSame(context1, context2);
Assert.assertNotSame(context2, context3);
Assert.assertSame(context1, context4);
QName name = new QName("http://example.com/ns1", "e1");
JAXBElement<String> element = new JAXBElement<String>(name, String.class, "123");
StringWriter sw = new StringWriter();
context4.createMarshaller().marshal(element, sw);
StreamSource source = new StreamSource(new StringReader(sw.toString()), null);
context4.createUnmarshaller().unmarshal(source, String.class);
JAXBContext context5 = cache.getJAXBContext(Address.class);
JAXBContext context6 = cache.getJAXBContext(PurchaseOrderType.class);
Assert.assertSame(context5, context6);
}