XmlDSigUtils extends XSDAbstractUtils { @Override public JAXBContext getJAXBContext() throws JAXBException { if (jc == null) { jc = JAXBContext.newInstance(ObjectFactory.class); } return jc; } private  XmlDSigUtils(); static XmlDSigUtils getInstance(); @Override JAXBContext getJAXBContext(); @Override List<Source> getXSDSources(); static final String XML_SCHEMA_LOCATION; static final String XMLDSIG_SCHEMA_LOCATION; static final String XMLDSIG_FILTER2_SCHEMA_LOCATION; }
@Test @SuppressWarnings("unchecked") public void test() throws JAXBException, SAXException { File xmldsigFile = new File("src/test/resources/XmlAliceSig.xml"); JAXBContext jc = xmlDSigUtils.getJAXBContext(); assertNotNull(jc); Schema schema = xmlDSigUtils.getSchema(); assertNotNull(schema); Unmarshaller unmarshaller = jc.createUnmarshaller(); unmarshaller.setSchema(schema); JAXBElement<SignatureType> unmarshalled = (JAXBElement<SignatureType>) unmarshaller.unmarshal(xmldsigFile); assertNotNull(unmarshalled); Marshaller marshaller = jc.createMarshaller(); marshaller.setSchema(schema); StringWriter sw = new StringWriter(); marshaller.marshal(unmarshalled, sw); String xmldsigString = sw.toString(); JAXBElement<SignatureType> unmarshalled2 = (JAXBElement<SignatureType>) unmarshaller.unmarshal(new StringReader(xmldsigString)); assertNotNull(unmarshalled2); }
@Test public void getJAXBContext() throws JAXBException { assertNotNull(xmlDSigUtils.getJAXBContext()); assertNotNull(xmlDSigUtils.getJAXBContext()); }