mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-14 11:39:39 +02:00
Make XMPPError imutable and add stanza reference
This commit is contained in:
parent
83eda4c58d
commit
45feaecdf7
30 changed files with 308 additions and 94 deletions
|
@ -34,10 +34,11 @@ public class IBBPacketUtils {
|
|||
*
|
||||
* @param from the senders JID
|
||||
* @param to the recipients JID
|
||||
* @param xmppError the XMPP error
|
||||
* @param condition the XMPP error condition
|
||||
* @return an error IQ
|
||||
*/
|
||||
public static IQ createErrorIQ(Jid from, Jid to, XMPPError xmppError) {
|
||||
public static IQ createErrorIQ(Jid from, Jid to, XMPPError.Condition condition) {
|
||||
XMPPError.Builder xmppError = XMPPError.getBuilder(condition);
|
||||
IQ errorIQ = new ErrorIQ(xmppError);
|
||||
errorIQ.setType(IQ.Type.error);
|
||||
errorIQ.setFrom(from);
|
||||
|
|
|
@ -115,9 +115,8 @@ public class InBandBytestreamManagerTest extends InitExtensions {
|
|||
InBandBytestreamManager byteStreamManager = InBandBytestreamManager.getByteStreamManager(connection);
|
||||
|
||||
try {
|
||||
XMPPError xmppError = new XMPPError(
|
||||
IQ errorIQ = IBBPacketUtils.createErrorIQ(targetJID, initiatorJID,
|
||||
XMPPError.Condition.feature_not_implemented);
|
||||
IQ errorIQ = IBBPacketUtils.createErrorIQ(targetJID, initiatorJID, xmppError);
|
||||
protocol.addResponse(errorIQ);
|
||||
|
||||
// start In-Band Bytestream
|
||||
|
|
|
@ -431,11 +431,10 @@ public class Socks5ByteStreamManagerTest {
|
|||
Verification.requestTypeGET);
|
||||
|
||||
// build error packet to reject SOCKS5 Bytestream
|
||||
XMPPError xmppError = new XMPPError(XMPPError.Condition.not_acceptable);
|
||||
IQ rejectPacket = new ErrorIQ(xmppError);
|
||||
XMPPError.Builder builder = XMPPError.getBuilder(XMPPError.Condition.not_acceptable);
|
||||
IQ rejectPacket = new ErrorIQ(builder);
|
||||
rejectPacket.setFrom(targetJID);
|
||||
rejectPacket.setTo(initiatorJID);
|
||||
rejectPacket.setError(xmppError);
|
||||
|
||||
// return error packet as response to the bytestream initiation
|
||||
protocol.addResponse(rejectPacket, Verification.correspondingSenderReceiver,
|
||||
|
@ -450,7 +449,7 @@ public class Socks5ByteStreamManagerTest {
|
|||
}
|
||||
catch (XMPPErrorException e) {
|
||||
protocol.verifyAll();
|
||||
assertEquals(xmppError, e.getXMPPError());
|
||||
assertEquals(rejectPacket.getError(), e.getXMPPError());
|
||||
}
|
||||
catch (Exception e) {
|
||||
fail(e.getMessage());
|
||||
|
|
|
@ -109,7 +109,7 @@ public class Socks5ByteStreamRequestTest {
|
|||
fail("exception should be thrown");
|
||||
}
|
||||
catch (XMPPErrorException e) {
|
||||
assertTrue(e.getMessage().contains("Could not establish socket with any provided host"));
|
||||
assertTrue(e.getXMPPError().getDescriptiveText("en").contains("Could not establish socket with any provided host"));
|
||||
}
|
||||
|
||||
// verify targets response
|
||||
|
@ -153,7 +153,7 @@ public class Socks5ByteStreamRequestTest {
|
|||
fail("exception should be thrown");
|
||||
}
|
||||
catch (XMPPErrorException e) {
|
||||
assertTrue(e.getMessage().contains("Could not establish socket with any provided host"));
|
||||
assertTrue(e.getXMPPError().getDescriptiveText("en").contains("Could not establish socket with any provided host"));
|
||||
}
|
||||
|
||||
// verify targets response
|
||||
|
@ -200,7 +200,7 @@ public class Socks5ByteStreamRequestTest {
|
|||
fail("exception should be thrown");
|
||||
}
|
||||
catch (XMPPErrorException e) {
|
||||
assertTrue(e.getMessage().contains(
|
||||
assertTrue(e.getXMPPError().getDescriptiveText("en").contains(
|
||||
"Could not establish socket with any provided host"));
|
||||
}
|
||||
|
||||
|
@ -291,8 +291,8 @@ public class Socks5ByteStreamRequestTest {
|
|||
|
||||
fail("exception should be thrown");
|
||||
}
|
||||
catch (XMPPException e) {
|
||||
assertTrue(e.getMessage().contains(
|
||||
catch (XMPPErrorException e) {
|
||||
assertTrue(e.getXMPPError().getDescriptiveText("en").contains(
|
||||
"Could not establish socket with any provided host"));
|
||||
}
|
||||
|
||||
|
|
|
@ -201,8 +201,7 @@ public class Socks5ClientForInitiatorTest {
|
|||
public void shouldFailIfActivateSocks5ProxyFails() throws Exception {
|
||||
|
||||
// build error response as reply to the stream activation
|
||||
XMPPError xmppError = new XMPPError(XMPPError.Condition.internal_server_error);
|
||||
IQ error = new ErrorIQ(xmppError);
|
||||
IQ error = new ErrorIQ(XMPPError.getBuilder(XMPPError.Condition.internal_server_error));
|
||||
error.setFrom(proxyJID);
|
||||
error.setTo(initiatorJID);
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ public class ConfigureFormTest
|
|||
Node node = mgr.getNode("princely_musings");
|
||||
|
||||
PubSub errorIq = new PubSub();
|
||||
XMPPError error = new XMPPError(Condition.forbidden);
|
||||
XMPPError.Builder error = XMPPError.getBuilder(Condition.forbidden);
|
||||
errorIq.setError(error);
|
||||
con.addIQReply(errorIq);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue