@Test
public void fromXml() throws XMLSemanticError {

    UserMessageArchivePreferences preferences = new SimpleUserMessageArchivePreferences(
            DefaultUserArchiveBehaviour.ROSTER, Collections.singleton(EntityImpl.parseUnchecked("always@foo.com")),
            Collections.singleton(EntityImpl.parseUnchecked("never@foo.com")));
    XMLElement prefsElement = UserMessageArchivePreferencesElement.toXml("foo", preferences);
    UserMessageArchivePreferences parsedPreferences = UserMessageArchivePreferencesElement.fromXml(prefsElement);
    
    assertEquals(preferences.getDefaultBehaviour(), parsedPreferences.getDefaultBehaviour());
    assertEquals(preferences.getAlwaysArchivedToOrFromJids().size(), parsedPreferences.getAlwaysArchivedToOrFromJids().size());
    assertEquals(preferences.getNeverArchivedToOrFromJids().size(), parsedPreferences.getNeverArchivedToOrFromJids().size());
}