Example usage for org.springframework.oxm MarshallingFailureException getMessage

List of usage examples for org.springframework.oxm MarshallingFailureException getMessage

Introduction

In this page you can find the example usage for org.springframework.oxm MarshallingFailureException getMessage.

Prototype

@Override
@Nullable
public String getMessage() 

Source Link

Document

Return the detail message, including the message from the nested exception if there is one.

Usage

From source file:no.digipost.signature.client.core.internal.xml.MarshallingTest.java

@Test
public void invalid_signature_job_request_causes_exceptions() {
    XMLExitUrls exitUrls = new XMLExitUrls().withCompletionUrl(null)
            .withRejectionUrl("http://localhost/rejected").withErrorUrl("http://localhost/failed");

    XMLDirectSignatureJobRequest signatureJobRequest = new XMLDirectSignatureJobRequest("123abc", exitUrls,
            null);//from   w w  w . ja v  a2 s. c o m

    try {
        marshal(signatureJobRequest, new ByteArrayOutputStream());
        fail("Should have failed with XSD-validation error due to completion-url being empty.");
    } catch (MarshallingFailureException e) {
        assertThat(e.getMessage(), allOf(containsString("completion-url"), containsString("is expected")));
    }
}

From source file:no.digipost.signature.client.core.internal.xml.MarshallingTest.java

@Test
public void invalid_manifests_causes_exceptions() {
    XMLSender sender = new XMLSender().withOrganizationNumber("123456789");
    XMLPortalSigner portalSigner = new XMLPortalSigner().withPersonalIdentificationNumber("12345678910");
    XMLDirectSigner directSigner = new XMLDirectSigner().withPersonalIdentificationNumber("12345678910");
    XMLPortalDocument portalDocument = new XMLPortalDocument("Title", "Non-sensitive title", "Message", null,
            "application/pdf");
    XMLDirectDocument directDocument = new XMLDirectDocument("Title", "Message", null, "application/pdf");

    XMLDirectSignatureJobManifest directManifest = new XMLDirectSignatureJobManifest(
            Arrays.asList(directSigner), sender, directDocument);
    XMLPortalSignatureJobManifest portalManifest = new XMLPortalSignatureJobManifest(
            new XMLPortalSigners().withSigners(portalSigner), sender, portalDocument, null);

    try {/*  w ww.j  a v  a  2s  . co m*/
        marshal(directManifest, new ByteArrayOutputStream());
        marshal(portalManifest, new ByteArrayOutputStream());
        fail("Should have failed with XSD-validation error due to href-attribute on document element being empty.");
    } catch (MarshallingFailureException e) {
        assertThat(e.getMessage(), allOf(containsString("href"), containsString("must appear")));
    }
}