Search in sources :

Example 1 with Root

use of testTypes.Root in project jdk8u_jdk by JetBrains.

the class UnmarshalTest method unmarshalUnexpectedNsTest.

@Test
public void unmarshalUnexpectedNsTest() throws Exception {
    JAXBContext context;
    Unmarshaller unm;
    // Create JAXB context from testTypes package
    context = JAXBContext.newInstance("testTypes");
    // Create unmarshaller from JAXB context
    unm = context.createUnmarshaller();
    // Unmarshall xml document with unqualified dtime element
    Root r = (Root) unm.unmarshal(new InputSource(new StringReader(DOC)));
    // Print dtime value and check if it is null
    System.out.println("dtime is:" + r.getWhen().getDtime());
    assertNull(r.getWhen().getDtime());
}
Also used : InputSource(org.xml.sax.InputSource) Root(testTypes.Root) StringReader(java.io.StringReader) JAXBContext(javax.xml.bind.JAXBContext) Unmarshaller(javax.xml.bind.Unmarshaller) Test(org.testng.annotations.Test)

Aggregations

StringReader (java.io.StringReader)1 JAXBContext (javax.xml.bind.JAXBContext)1 Unmarshaller (javax.xml.bind.Unmarshaller)1 Test (org.testng.annotations.Test)1 InputSource (org.xml.sax.InputSource)1 Root (testTypes.Root)1