namespaceHandlerDictionary.register(stanzaHandler);
String firstBoundResource = sessionContext.bindResource();
String secondBoundResource = sessionContext.bindResource();
StanzaBuilder stanzaBuilder = StanzaBuilder.createIQStanza(null, null, IQStanzaType.GET, "test");
stanzaBuilder.addAttribute("from", new EntityImpl("lea", server.getDomain(), null).getFullQualifiedName());
stanzaBuilder.startInnerElement("query", "testNSURI").endInnerElement();
protocolWorker.processStanza(sessionContext.getServerRuntimeContext(), sessionContext, stanzaBuilder.build(), sessionStateHolder);
Stanza recordedResponse = sessionContext.getNextRecordedResponse();
assertUnknownSenderError(recordedResponse); // not allowed, bare id without resource and two resources bound
sessionContext.reset();
// unbind second resource, leaving only one
boolean noResourceRemains = sessionContext.getServerRuntimeContext().getResourceRegistry().unbindResource(secondBoundResource);
assertFalse(noResourceRemains);
// bare id allowed, only one resource is bound
stanzaBuilder = StanzaBuilder.createIQStanza(null, null, IQStanzaType.GET, "test");
stanzaBuilder.addAttribute("from", new EntityImpl("lea", server.getDomain(), null).getFullQualifiedName());
stanzaBuilder.startInnerElement("query", "testNSURI").endInnerElement();
protocolWorker.processStanza(sessionContext.getServerRuntimeContext(), sessionContext, stanzaBuilder.build(), sessionStateHolder);
stanzaHandler.assertHandlerCalled();
sessionContext.reset();
// second resource is now invalid and cannot be used anymore in a full qualified entity
stanzaBuilder = StanzaBuilder.createIQStanza(null, null, IQStanzaType.GET, "test");
stanzaBuilder.addAttribute("from", new EntityImpl("lea", server.getDomain(), secondBoundResource).getFullQualifiedName());
stanzaBuilder.startInnerElement("query", "testNSURI").endInnerElement();
protocolWorker.processStanza(sessionContext.getServerRuntimeContext(), sessionContext, stanzaBuilder.build(), sessionStateHolder);
recordedResponse = sessionContext.getNextRecordedResponse();
assertUnknownSenderError(recordedResponse);
}