JaxbUtil { public static <T> JAXBContext createContextIfNull(Class<T> clazz, JAXBContext context) { if (context != null) return context; try { return JAXBContext.newInstance(clazz.getPackage().getName()); } catch (JAXBException e) { LOG.error("Failed to create JaxbContext for {}", clazz.getPackage().getName(), e); return null; } } private  JaxbUtil(); static JAXBContext createContextIfNull(Class<T> clazz, JAXBContext context); @SuppressWarnings("unchecked") static T convertTo(byte[] xml, JAXBContext context, Schema validationSchema, ValidationEventHandler validationEventHandler); static String convertToString(T xmlObject, JAXBContext context, Schema validationSchema, ValidationEventHandler validationEventHandler); static Schema createSchemaIfNull(String xsd, Schema schema); static String getErrorLocation(ValidationEvent event); static String getXmlMixedContentAsString(List<Object> contents); static String convertNodeToString(Node node); static Node convertStringToNode(String xmlStr);  }
@Test public void createContext() { JAXBContext context = null; context = JaxbUtil.createContextIfNull(Resources.class, context); assertNotNull(context); }