use of jetbrains.communicator.p2p.MockXmlResponseProvider in project intellij-plugins by JetBrains.
the class TestUtil method testSendXmlMessage_Functional.
public static void testSendXmlMessage_Functional(BaseTestCase testCase, User self, final boolean checkResponse) {
final String[] log = new String[] { "" };
log[0] = "";
final String comment = "��� mes&&<>sage";
MockXmlMessage message = new MockXmlMessage("tagName", "myNamespace") {
@Override
public boolean needsResponse() {
return checkResponse;
}
@Override
public void fillRequest(Element element) {
element.setText(comment);
}
@Override
public void processResponse(Element responseElement) {
log[0] += responseElement.getAttributeValue("foo");
}
};
final MockXmlResponseProvider mockXmlResponseProvider = new MockXmlResponseProvider("tagName", "myNamespace", testCase.getBroadcaster()) {
@Override
public boolean processAndFillResponse(Element response, Element request, Transport transport, String remoteUser) {
log[0] += remoteUser + " " + request.getName() + " " + request.getText();
assertEquals("root element expected", "tagName", request.getName());
response.setAttribute("foo", "gar");
return true;
}
};
Pico.getInstance().registerComponentInstance(mockXmlResponseProvider);
testCase.disposeOnTearDown(new Disposable() {
@Override
public void dispose() {
Pico.getInstance().unregisterComponentByInstance(mockXmlResponseProvider);
}
});
self.sendXmlMessage(message);
new WaitFor(500) {
@Override
protected boolean condition() {
if (checkResponse) {
return log[0].endsWith("gar");
} else {
return log[0].length() > 0;
}
}
};
String expectedLog = self.getName() + " tagName " + comment;
expectedLog += checkResponse ? "gar" : "";
assertEquals("Message expected", expectedLog, log[0]);
}
Aggregations