use of org.custommonkey.xmlunit.ElementNameAndTextQualifier in project opencast by opencast.
the class RoleParsingTest method testMarshalUser.
@Test
public void testMarshalUser() throws Exception {
StringWriter writer = new StringWriter();
JaxbRole role = new JaxbRole("ROLE_TEST", ORGANIZATION, "This is a test role");
jaxbContext.createMarshaller().marshal(role, writer);
String expectedOutput = IOUtils.toString(getClass().getResourceAsStream(ROLE_XML_FILE), "UTF-8");
Diff diff = new Diff(expectedOutput, writer.toString());
/* We don't care about ordering. */
diff.overrideElementQualifier(new ElementNameAndTextQualifier());
XMLAssert.assertXMLEqual(diff, true);
}
use of org.custommonkey.xmlunit.ElementNameAndTextQualifier in project opencast by opencast.
the class GroupParsingTest method testMarshalUser.
@Test
public void testMarshalUser() throws Exception {
StringWriter writer = new StringWriter();
StringWriter writer2 = new StringWriter();
Set<JaxbRole> roles = new HashSet<JaxbRole>();
roles.add(new JaxbRole("ROLE_COURSE_ADMIN", ORGANIZATION));
roles.add(new JaxbRole("ROLE_USER", ORGANIZATION));
Set<String> members = new HashSet<String>();
members.add("admin1");
members.add("admin2");
JaxbGroup group = new JaxbGroup("admin", ORGANIZATION, "Admin", "Admin group", roles, members);
jaxbContext.createMarshaller().marshal(group, writer);
String expectedOutput = IOUtils.toString(getClass().getResourceAsStream(GROUP_XML_FILE), "UTF-8");
StreamSource streamSource = new StreamSource(getClass().getResourceAsStream(GROUP_XML_FILE));
JaxbGroup groupFromFile = jaxbContext.createUnmarshaller().unmarshal(streamSource, JaxbGroup.class).getValue();
jaxbContext.createMarshaller().marshal(groupFromFile, writer2);
Diff diff = new Diff(writer2.toString(), writer.toString());
/* We don't care about ordering. */
diff.overrideElementQualifier(new ElementNameAndTextQualifier());
XMLAssert.assertXMLEqual(diff, true);
}
Aggregations