getXMLObject().setType(type);
// Now get the attributes
Collection<XMLAttribute> attributes = getXMLObject().getAttributes();
assertEquals(1, attributes.size());
XMLAttribute typeAtt = attributes.iterator().next();
// Ensure the attribute is correct
assertEquals(type, typeAtt.getValue());
assertEquals(XMLNode.NS_URI_XSI, typeAtt.getNamespace());
assertEquals(typeName, typeAtt.getName());
// Test the type is toStringing properly
String asString = getXMLObject().toString();
assertTrue(asString, asString.contains(XMLNode.NS_PREFIX_XSI + ":" + typeName + "=\"" + type + "\""));
// Set the type again
getXMLObject().setType(anotherType);
// Get the type attribute again
attributes = getXMLObject().getAttributes();
assertEquals(1, attributes.size());
typeAtt = attributes.iterator().next();
// Ensure the attribute is still correct and has the new value
assertEquals(anotherType, typeAtt.getValue());
assertEquals(XMLNode.NS_URI_XSI, typeAtt.getNamespace());
assertEquals(typeName, typeAtt.getName());
asString = getXMLObject().toString();
assertTrue(asString.contains(XMLNode.NS_PREFIX_XSI + ":" + typeName + "=\"" + anotherType + "\""));
}