@Test public void parseDeliveryReportRequestWithDates() throws Exception { StringBuilder string0 = new StringBuilder(200) .append("<?xml version=\"1.0\"?>\n") .append("<operation type=\"deliveryReport\">\n") .append(" <account username=\"customer1\" password=\"test1\"/>\n") .append(" <application>TestApp1</application>\n") .append(" <deliveryReportRequest>\n") .append(" <status code=\"5\" message=\"EXPIRED\"/>\n") .append(" <ticketId>000:20090118002220948:000</ticketId>\n") .append(" <messageError code=\"102\"/>\n") .append(" <createDate>2010-05-30T09:30:10.000Z</createDate>\n") .append(" <finalDate>2010-05-30T09:30:15.314Z</finalDate>\n") .append(" </deliveryReportRequest>\n") .append("</operation>\n") .append(""); ByteArrayInputStream is = new ByteArrayInputStream(string0.toString().getBytes()); SxmpParser parser = new SxmpParser(); Operation operation = parser.parse(is); logger.debug("{}", operation); Assert.assertEquals(Operation.Type.DELIVERY_REPORT, operation.getType()); Assert.assertEquals(true, operation.isRequest()); DeliveryReportRequest reportReq = (DeliveryReportRequest)operation; Assert.assertEquals("customer1", reportReq.getAccount().getUsername()); Assert.assertEquals("test1", reportReq.getAccount().getPassword()); Assert.assertEquals("TestApp1", reportReq.getApplication().getName()); Assert.assertEquals("000:20090118002220948:000", reportReq.getTicketId()); Assert.assertEquals(new Integer(5), reportReq.getStatus().getCode()); Assert.assertEquals("EXPIRED", reportReq.getStatus().getMessage()); Assert.assertEquals(new Integer(102), reportReq.getMessageErrorCode()); Assert.assertEquals(new DateTime(2010,5,30,9,30,10,0, DateTimeZone.UTC), reportReq.getCreateDate()); Assert.assertEquals(new DateTime(2010,5,30,9,30,15,314, DateTimeZone.UTC), reportReq.getFinalDate()); }
public Operation parse(InputStream in) throws SxmpParsingException, IOException, SAXException, ParserConfigurationException { SAXParserFactory factory = SAXParserFactory.newInstance(); SAXParser parser = factory.newSAXParser(); parser.getXMLReader().setFeature("http: parser.getXMLReader().setFeature("http: parser.getXMLReader().setFeature("http: parser.getXMLReader().setFeature("http: parser.getXMLReader().setFeature("http: parser.getXMLReader().setFeature("http: parser.getXMLReader().setFeature("http: Handler handler = new Handler(); XMLReader reader = parser.getXMLReader(); reader.setContentHandler(handler); reader.setErrorHandler(handler); reader.setEntityResolver(handler); try { parser.parse(new InputSource(in), handler); } catch (com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException e) { throw new SxmpParsingException(SxmpErrorCode.INVALID_XML, "XML encoding mismatch", null); } if (handler.error != null) { throw handler.error; } if (handler.getOperation() == null) { throw new SxmpParsingException(SxmpErrorCode.MISSING_REQUIRED_ELEMENT, "The operation type [" + handler.operationType.getValue() + "] requires a request element", new PartialOperation(handler.operationType)); } try { handler.getOperation().validate(); } catch (SxmpErrorException e) { throw new SxmpParsingException(e.getErrorCode(), e.getErrorMessage(), handler.getOperation()); } return handler.getOperation(); }
SxmpParser { public Operation parse(InputStream in) throws SxmpParsingException, IOException, SAXException, ParserConfigurationException { SAXParserFactory factory = SAXParserFactory.newInstance(); SAXParser parser = factory.newSAXParser(); parser.getXMLReader().setFeature("http: parser.getXMLReader().setFeature("http: parser.getXMLReader().setFeature("http: parser.getXMLReader().setFeature("http: parser.getXMLReader().setFeature("http: parser.getXMLReader().setFeature("http: parser.getXMLReader().setFeature("http: Handler handler = new Handler(); XMLReader reader = parser.getXMLReader(); reader.setContentHandler(handler); reader.setErrorHandler(handler); reader.setEntityResolver(handler); try { parser.parse(new InputSource(in), handler); } catch (com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException e) { throw new SxmpParsingException(SxmpErrorCode.INVALID_XML, "XML encoding mismatch", null); } if (handler.error != null) { throw handler.error; } if (handler.getOperation() == null) { throw new SxmpParsingException(SxmpErrorCode.MISSING_REQUIRED_ELEMENT, "The operation type [" + handler.operationType.getValue() + "] requires a request element", new PartialOperation(handler.operationType)); } try { handler.getOperation().validate(); } catch (SxmpErrorException e) { throw new SxmpParsingException(e.getErrorCode(), e.getErrorMessage(), handler.getOperation()); } return handler.getOperation(); } }
SxmpParser { public Operation parse(InputStream in) throws SxmpParsingException, IOException, SAXException, ParserConfigurationException { SAXParserFactory factory = SAXParserFactory.newInstance(); SAXParser parser = factory.newSAXParser(); parser.getXMLReader().setFeature("http: parser.getXMLReader().setFeature("http: parser.getXMLReader().setFeature("http: parser.getXMLReader().setFeature("http: parser.getXMLReader().setFeature("http: parser.getXMLReader().setFeature("http: parser.getXMLReader().setFeature("http: Handler handler = new Handler(); XMLReader reader = parser.getXMLReader(); reader.setContentHandler(handler); reader.setErrorHandler(handler); reader.setEntityResolver(handler); try { parser.parse(new InputSource(in), handler); } catch (com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException e) { throw new SxmpParsingException(SxmpErrorCode.INVALID_XML, "XML encoding mismatch", null); } if (handler.error != null) { throw handler.error; } if (handler.getOperation() == null) { throw new SxmpParsingException(SxmpErrorCode.MISSING_REQUIRED_ELEMENT, "The operation type [" + handler.operationType.getValue() + "] requires a request element", new PartialOperation(handler.operationType)); } try { handler.getOperation().validate(); } catch (SxmpErrorException e) { throw new SxmpParsingException(e.getErrorCode(), e.getErrorMessage(), handler.getOperation()); } return handler.getOperation(); } SxmpParser();  SxmpParser(final String version); }
SxmpParser { public Operation parse(InputStream in) throws SxmpParsingException, IOException, SAXException, ParserConfigurationException { SAXParserFactory factory = SAXParserFactory.newInstance(); SAXParser parser = factory.newSAXParser(); parser.getXMLReader().setFeature("http: parser.getXMLReader().setFeature("http: parser.getXMLReader().setFeature("http: parser.getXMLReader().setFeature("http: parser.getXMLReader().setFeature("http: parser.getXMLReader().setFeature("http: parser.getXMLReader().setFeature("http: Handler handler = new Handler(); XMLReader reader = parser.getXMLReader(); reader.setContentHandler(handler); reader.setErrorHandler(handler); reader.setEntityResolver(handler); try { parser.parse(new InputSource(in), handler); } catch (com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException e) { throw new SxmpParsingException(SxmpErrorCode.INVALID_XML, "XML encoding mismatch", null); } if (handler.error != null) { throw handler.error; } if (handler.getOperation() == null) { throw new SxmpParsingException(SxmpErrorCode.MISSING_REQUIRED_ELEMENT, "The operation type [" + handler.operationType.getValue() + "] requires a request element", new PartialOperation(handler.operationType)); } try { handler.getOperation().validate(); } catch (SxmpErrorException e) { throw new SxmpParsingException(e.getErrorCode(), e.getErrorMessage(), handler.getOperation()); } return handler.getOperation(); } SxmpParser();  SxmpParser(final String version); Operation parse(InputStream in); }
SxmpParser { public Operation parse(InputStream in) throws SxmpParsingException, IOException, SAXException, ParserConfigurationException { SAXParserFactory factory = SAXParserFactory.newInstance(); SAXParser parser = factory.newSAXParser(); parser.getXMLReader().setFeature("http: parser.getXMLReader().setFeature("http: parser.getXMLReader().setFeature("http: parser.getXMLReader().setFeature("http: parser.getXMLReader().setFeature("http: parser.getXMLReader().setFeature("http: parser.getXMLReader().setFeature("http: Handler handler = new Handler(); XMLReader reader = parser.getXMLReader(); reader.setContentHandler(handler); reader.setErrorHandler(handler); reader.setEntityResolver(handler); try { parser.parse(new InputSource(in), handler); } catch (com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException e) { throw new SxmpParsingException(SxmpErrorCode.INVALID_XML, "XML encoding mismatch", null); } if (handler.error != null) { throw handler.error; } if (handler.getOperation() == null) { throw new SxmpParsingException(SxmpErrorCode.MISSING_REQUIRED_ELEMENT, "The operation type [" + handler.operationType.getValue() + "] requires a request element", new PartialOperation(handler.operationType)); } try { handler.getOperation().validate(); } catch (SxmpErrorException e) { throw new SxmpParsingException(e.getErrorCode(), e.getErrorMessage(), handler.getOperation()); } return handler.getOperation(); } SxmpParser();  SxmpParser(final String version); Operation parse(InputStream in); static final String VERSION_1_0; static final String VERSION_1_1; static final String VERSION_1_2; }