XmlPolicyModelMarshallerTestpublic class XmlPolicyModelMarshallerTest extends TestCase
Fields Summary |
---|
private PolicyModelMarshaller | marshaller | private PolicyModelUnmarshaller | unmarshaller |
Constructors Summary |
---|
public XmlPolicyModelMarshallerTest(String testName)
super(testName);
|
Methods Summary |
---|
protected void | setUp()
| protected void | tearDown()
| public void | testMarshal()Test of marshal method, of class com.sun.xml.ws.policy.sourcemodel.XmlPolicyModelMarshaller.
PolicySourceModel model = null;
Object storage = null;
try {
marshaller.marshal(model, storage);
fail("Expected NullPointerException");
} catch (NullPointerException e) {
}
StringWriter writer = new StringWriter();
XMLOutputFactory factory = XMLOutputFactory.newInstance();
XMLStreamWriter streamWriter = factory.createXMLStreamWriter(writer);
storage = streamWriter;
try {
marshaller.marshal(model, storage);
fail("Expected NullPointerException");
} catch (NullPointerException e) {
}
model = PolicyResourceLoader.unmarshallModel("complex_policy/nested_assertions_with_alternatives.xml");
storage = null;
try {
marshaller.marshal(model, storage);
fail("Expected NullPointerException");
} catch (NullPointerException e) {
}
storage = new Object();
try {
marshaller.marshal(model, storage);
fail("Expected PolicyException");
} catch (PolicyException e) {
}
storage = streamWriter;
marshaller.marshal(model, storage);
String policy = writer.toString();
// Verifying that produced policy String is not empty
assertTrue(policy.length() > 10);
| public void | testMarshallingAssertionsWithVisibilityAttribute()
String[] modelFileNames = new String[]{
"policy_0_visible",
"policy_1_visible",
"policy_2_visible"
};
XMLOutputFactory factory = XMLOutputFactory.newInstance();
for (String modelFileName : modelFileNames) {
PolicySourceModel model = PolicyResourceLoader.unmarshallModel("visibility/" + modelFileName + ".xml");
StringWriter writer = new StringWriter();
XMLStreamWriter streamWriter = factory.createXMLStreamWriter(writer);
marshaller.marshal(model, streamWriter);
StringReader reader = new StringReader(writer.toString());
PolicySourceModel resultModel = unmarshaller.unmarshalModel(reader);
PolicySourceModel expectedModel = PolicyResourceLoader.unmarshallModel("visibility/" + modelFileName + "_expected.xml");
assertEquals(modelFileName, expectedModel, resultModel);
System.out.println(writer.toString());
}
|
|