use of org.exquery.serialization.annotation.MethodAnnotation in project exist by eXist-db.
the class RegistryFunctionsTest method outputMethod.
@Test
public void outputMethod() throws SerializationAnnotationException, TransformerException, IOException, SAXException {
// test setup
final String methodStr = "html5";
final MethodAnnotation method = new MethodAnnotation();
method.setName(SerializationAnnotationName.method.getQName());
method.setLiterals(new Literal[] { new Literal() {
@Override
public Type getType() {
return Type.STRING;
}
@Override
public String getValue() {
return methodStr;
}
} });
method.initialise();
// execute serialize method
final MemTreeBuilder builder = new MemTreeBuilder();
builder.startDocument();
RegistryFunctions.serializeSerializationAnnotation(builder, method);
builder.endDocument();
// assert result
final String xmlResult = documentToString(builder.getDocument());
final Source srcExpected = Input.fromString("<method xmlns=\"http://www.w3.org/2010/xslt-xquery-serialization\">" + methodStr + "</method>").build();
final Source srcActual = Input.fromString(xmlResult).build();
final Diff diff = DiffBuilder.compare(srcExpected).withTest(srcActual).checkForIdentical().build();
assertFalse(diff.toString(), diff.hasDifferences());
}
Aggregations