Search in sources :

Example 1 with DomSerializer

use of com.sun.xml.txw2.output.DomSerializer in project metro-jax-ws by eclipse-ee4j.

the class PolicyModelMarshallerTest method testMarshal_Collection_Object.

/**
 * Test of marshal method, of class PolicyModelMarshaller.
 */
public void testMarshal_Collection_Object() throws PolicyException {
    Collection<PolicySourceModel> models = new LinkedList<PolicySourceModel>();
    PolicySourceModel model = PolicySourceModel.createPolicySourceModel(NamespaceVersion.v1_2);
    PolicySourceModel model2 = PolicySourceModel.createPolicySourceModel(NamespaceVersion.v1_5);
    models.add(model);
    models.add(model2);
    Document document = builder.newDocument();
    TypedXmlWriter storage = TXW.create(new QName("policies"), TypedXmlWriter.class, new DomSerializer(document));
    PolicyModelMarshaller instance = PolicyModelMarshaller.getXmlMarshaller(false);
    instance.marshal(models, storage);
    storage.commit();
    Element element = document.getDocumentElement();
    Node policyElement = element.getFirstChild();
    assertEquals(policyElement.getLocalName(), "Policy");
}
Also used : DomSerializer(com.sun.xml.txw2.output.DomSerializer) QName(javax.xml.namespace.QName) Element(org.w3c.dom.Element) Node(org.w3c.dom.Node) Document(org.w3c.dom.Document) TypedXmlWriter(com.sun.xml.txw2.TypedXmlWriter) LinkedList(java.util.LinkedList)

Example 2 with DomSerializer

use of com.sun.xml.txw2.output.DomSerializer in project metro-jax-ws by eclipse-ee4j.

the class PolicyModelMarshallerTest method testMarshal_PolicySourceModel_Object.

/**
 * Test of marshal method, of class PolicyModelMarshaller.
 */
public void testMarshal_PolicySourceModel_Object() throws PolicyException {
    PolicySourceModel model = PolicySourceModel.createPolicySourceModel(NamespaceVersion.v1_2);
    Document document = builder.newDocument();
    TypedXmlWriter storage = TXW.create(new QName("root"), TypedXmlWriter.class, new DomSerializer(document));
    PolicyModelMarshaller instance = PolicyModelMarshaller.getXmlMarshaller(false);
    instance.marshal(model, storage);
    storage.commit();
    Element element = document.getDocumentElement();
    Node policyElement = element.getFirstChild();
    assertEquals(policyElement.getLocalName(), "Policy");
}
Also used : DomSerializer(com.sun.xml.txw2.output.DomSerializer) QName(javax.xml.namespace.QName) Element(org.w3c.dom.Element) Node(org.w3c.dom.Node) Document(org.w3c.dom.Document) TypedXmlWriter(com.sun.xml.txw2.TypedXmlWriter)

Example 3 with DomSerializer

use of com.sun.xml.txw2.output.DomSerializer in project metro-jax-ws by eclipse-ee4j.

the class PolicyModelMarshallerTest method testMarshalPrefixWrite.

public void testMarshalPrefixWrite() throws PolicyException {
    PolicySourceModel model = PolicySourceModel.createPolicySourceModel(NamespaceVersion.v1_5, "id", null);
    ModelNode root = model.getRootNode();
    ModelNode all = root.createChildAllNode();
    AssertionData assertion = AssertionData.createAssertionData(new QName("http://schemas.foo.com/", "Assertion"));
    all.createChildAssertionNode(assertion);
    Document document = builder.newDocument();
    TypedXmlWriter storage = TXW.create(new QName("root"), TypedXmlWriter.class, new DomSerializer(document));
    PolicyModelMarshaller instance = PolicyModelMarshaller.getXmlMarshaller(false);
    instance.marshal(model, storage);
    storage.commit();
    Element element = document.getDocumentElement();
    Node policyElement = element.getFirstChild();
    assertEquals(NamespaceVersion.v1_5.getDefaultNamespacePrefix(), policyElement.getPrefix());
    NamedNodeMap map = policyElement.getAttributes();
    Node id = map.getNamedItemNS(PolicyConstants.WSU_ID.getNamespaceURI(), PolicyConstants.WSU_ID.getLocalPart());
    assertEquals(PolicyConstants.WSU_NAMESPACE_PREFIX, id.getPrefix());
}
Also used : NamedNodeMap(org.w3c.dom.NamedNodeMap) DomSerializer(com.sun.xml.txw2.output.DomSerializer) QName(javax.xml.namespace.QName) Element(org.w3c.dom.Element) Node(org.w3c.dom.Node) Document(org.w3c.dom.Document) TypedXmlWriter(com.sun.xml.txw2.TypedXmlWriter)

Aggregations

TypedXmlWriter (com.sun.xml.txw2.TypedXmlWriter)3 DomSerializer (com.sun.xml.txw2.output.DomSerializer)3 QName (javax.xml.namespace.QName)3 Document (org.w3c.dom.Document)3 Element (org.w3c.dom.Element)3 Node (org.w3c.dom.Node)3 LinkedList (java.util.LinkedList)1 NamedNodeMap (org.w3c.dom.NamedNodeMap)1