@Test public void canNotMarshal_invalidObject_whenUsingSchema() { exception.expect(JuRuntimeException.class); exception.expectCause(Is.isA(MarshalException.class)); XmlUtils.marshaller() .schema(JuUrl.resourceRelativeTo("player.xsd", this.getClass())) .marshalToString(this.getMichael(100)); }
@Ignore("Cannot set prefix mapper on all platforms...") @Test public void canMarshall_object_withMultipleNamespaces_andCustomDefaultPrefix() { String xml = XmlUtils.marshaller() .setNamespacePrefix(null, "urn:inftec.ch/ju/util/xml/ns/ref") .marshalToString(this.getComplexRoot()); TestUtils.assertEqualsXmlResource("XmlUtilsJaxbTest_canMarshall_object_withMultipleNamespaces_andCustomDefaultPrefix.xml", xml); }
@Test public void canMarshall_object_withMultipleNamespaces() { String xml = XmlUtils.marshaller() .marshalToString(this.getComplexRoot()); TestUtils.assertEqualsXmlResource("XmlUtilsJaxbTest_canMarshall_object_withMultipleNamespaces.xml", xml); }
@Test public void canMarshal_invalidObject_whenNotUsingSchema() { XmlUtils.marshaller().marshalToString(this.getMichael(100)); }
@Test public void canCreateXml_fromJaxbObject_usingFormattedOutput() { String xmlString = XmlUtils.marshaller().formattedOutput(true).marshalToString(this.getMichael()); TestUtils.assertEqualsResource("XmlUtilsTest_canCreateXml_fromJaxbObject_usingFormattedOutput.xml", xmlString); }
@Ignore("Cannot set prefix mapper on all platforms...") @Test public void canMarshall_object_withMultipleNamespaces_andCustomPrefixes() { String xml = XmlUtils.marshaller() .setNamespacePrefix("m", "urn:inftec.ch/ju/util/xml/ns/main") .setNamespacePrefix("r", "urn:inftec.ch/ju/util/xml/ns/ref") .marshalToString(this.getComplexRoot()); TestUtils.assertEqualsXmlResource("XmlUtilsJaxbTest_canMarshall_object_withMultipleNamespaces_andCustomPrefixes.xml", xml); }
@Test public void canCreateXml_fromJaxbObject() { String xmlString = XmlUtils.marshaller().marshalToString(this.getMichael()); TestUtils.assertEqualsResource("XmlUtilsTest_canCreateXml_fromJaxbObject.xml", xmlString); }