@Test public void shouldCreateValidNotification() throws XmlException, IOException, OXFException { String sesUrl = "http://ses.host"; String dialect = "http://my-funny/dialect"; ParameterContainer parameters = new ParameterContainer(); parameters.addParameterShell(SESRequestBuilder_00.NOTIFY_SES_URL, sesUrl); parameters.addParameterShell(SESRequestBuilder_00.NOTIFY_TOPIC_DIALECT, dialect); parameters.addParameterShell(SESRequestBuilder_00.NOTIFY_TOPIC, "<start>topic</start>"); parameters.addParameterShell(SESRequestBuilder_00.NOTIFY_XML_MESSAGE, readMessage()); SESRequestBuilder_00 request = new SESRequestBuilder_00(); String asText = request.buildNotifyRequest(parameters); EnvelopeDocument envelope = EnvelopeDocument.Factory.parse(asText); XMLBeansParser.registerLaxValidationCase(SASamplingPointCase.getInstance()); Collection<XmlError> errors = XMLBeansParser.validate(envelope); Assert.assertTrue("Notification is not valid: " + errors, errors.isEmpty()); XmlCursor bodyCur = envelope.getEnvelope().getBody().newCursor(); bodyCur.toFirstChild(); Assert.assertTrue(bodyCur.getObject() instanceof Notify); XmlCursor tmpCur = ((Notify) bodyCur.getObject()).getNotificationMessageArray()[0].getMessage().newCursor(); tmpCur.toFirstChild(); Assert.assertTrue(tmpCur.getObject() instanceof ObservationType); Assert.assertTrue( ((Notify) bodyCur.getObject()) .getNotificationMessageArray()[0] .getTopic() .getDialect() .trim() .equals(dialect)); tmpCur = ((Notify) bodyCur.getObject()).getNotificationMessageArray()[0].getTopic().newCursor(); Assert.assertTrue(tmpCur.getObject().xmlText().contains("<start>")); }