AbstractStanzaGenerator sg = getDefaultStanzaGenerator();
Stanza stanza = sg.getStanza(clientNotAuthorized, pubsubService, "id123", testNode);
ResponseStanzaContainer result = sendStanza(stanza, true);
assertTrue(result.hasResponse());
IQStanza response = new IQStanza(result.getResponseStanza());
assertEquals(IQStanzaType.ERROR.value(), response.getType());
assertEquals("id123", response.getAttributeValue("id")); // IDs must match
XMLElement error = response.getInnerElementsNamed("error").get(0); //jump directly to the error part
assertEquals("error", error.getName());
assertEquals("auth", error.getAttributeValue("type"));
List<XMLElement> errorContent = error.getInnerElements();
assertEquals(1, errorContent.size());