Example #1
0
 @Test
 public void loadStaticContextFactories() {
   assertNotNull(XMLObjectProviderRegistrySupport.getParserPool());
   assertNotNull(XMLObjectProviderRegistrySupport.getBuilderFactory());
   assertNotNull(XMLObjectProviderRegistrySupport.getMarshallerFactory());
   assertNotNull(XMLObjectProviderRegistrySupport.getUnmarshallerFactory());
 }
  /** Tests unmarshalling a full response message. */
  @Test
  public void testResponseUnmarshall() {

    try {
      InputStream in = ResponseTest.class.getResourceAsStream(fullResponsePath);
      Document responseDoc = parserPool.parse(in);
      Unmarshaller unmarshaller =
          XMLObjectProviderRegistrySupport.getUnmarshallerFactory()
              .getUnmarshaller(responseDoc.getDocumentElement());

      Response response = (Response) unmarshaller.unmarshall(responseDoc.getDocumentElement());

      Assert.assertEquals(
          response.getElementQName().getLocalPart(),
          "Response",
          "First element of response data was not expected Response");
    } catch (XMLParserException xe) {
      Assert.fail("Unable to parse XML file: " + xe);
    } catch (UnmarshallingException ue) {
      Assert.fail("Unable to unmarshall XML: " + ue);
    }
  }