pdu.addAttribute(new Attribute("a1", "v1"));
pdu.addAttribute(new Attribute("a2", "v2"));
String expected = " a1=\"v1\" a2=\"v2\"";
ByteArrayOutputStream out = new ByteArrayOutputStream();
Canonicalizer canonicalizer = new Canonicalizer(out);
Document doc = new Document(pdu);
canonicalizer.write(doc.query("//@*"));
byte[] result = out.toByteArray();
out.close();
String s = new String(out.toByteArray(), "UTF8");
assertEquals(expected, s);