1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2025-09-10 18:59:41 +02:00

Merge branch '4.3'

This commit is contained in:
Florian Schmaus 2018-06-23 17:18:17 +02:00
commit ce4f3352a2
33 changed files with 119 additions and 77 deletions

View file

@ -94,7 +94,7 @@ public class CompressionTest extends SmackTestCase {
setupConnection.getAccountManager().createAccount("user0", "user0");
} catch (XMPPException e) {
// Do nothing if the accout already exists
if (e.getXMPPError().getCode() != 409) {
if (e.getStanzaError().getCode() != 409) {
throw e;
}
}

View file

@ -84,9 +84,9 @@ public class LastActivityManagerTest extends SmackTestCase {
LastActivityManager.getLastActivity(conn0, getFullJID(2));
fail("No error was received from the server. User was able to get info of other user not in his roster.");
} catch (XMPPException e) {
assertNotNull("No error was returned from the server", e.getXMPPError());
assertNotNull("No error was returned from the server", e.getStanzaError());
assertEquals("Forbidden error was not returned from the server", 403,
e.getXMPPError().getCode());
e.getStanzaError().getCode());
}
}
@ -121,7 +121,7 @@ public class LastActivityManagerTest extends SmackTestCase {
try {
lastActivity = LastActivityManager.getLastActivity(conn0, getHost());
} catch (XMPPException e) {
if (e.getXMPPError().getCode() == 403) {
if (e.getStanzaError().getCode() == 403) {
//The test can not be done since the host do not allow this kind of request
return;
}

View file

@ -77,7 +77,7 @@ public class ServiceDiscoveryManagerTest extends SmackTestCase {
fail("Unexpected identities were returned instead of a 404 error");
}
catch (XMPPException e) {
assertEquals("Incorrect error", 404, e.getXMPPError().getCode());
assertEquals("Incorrect error", 404, e.getStanzaError().getCode());
}
catch (Exception e) {
e.printStackTrace();

View file

@ -527,7 +527,7 @@ public class MultiUserChatTest extends SmackTestCase {
fail("Other user was able to join with other user's reserved nickname");
}
catch (XMPPException e) {
XMPPError xmppError = e.getXMPPError();
XMPPError xmppError = e.getStanzaError();
assertNotNull(
"No XMPPError was received when joining with other user's reserved nickname",
xmppError);
@ -551,7 +551,7 @@ public class MultiUserChatTest extends SmackTestCase {
muc3.sendRegistrationForm(answerForm);
}
catch (XMPPException e) {
XMPPError xmppError = e.getXMPPError();
XMPPError xmppError = e.getStanzaError();
assertNotNull(
"No XMPPError was received when reserving an already reserved nickname",
xmppError);
@ -605,7 +605,7 @@ public class MultiUserChatTest extends SmackTestCase {
fail("User2 was allowed to change the room's subject");
}
catch (XMPPException e) {
XMPPError xmppError = e.getXMPPError();
XMPPError xmppError = e.getStanzaError();
assertNotNull(
"No XMPPError was received when changing the room's subject",
xmppError);
@ -677,7 +677,7 @@ public class MultiUserChatTest extends SmackTestCase {
fail("User2 was able to kick a room owner");
}
catch (XMPPException e) {
XMPPError xmppError = e.getXMPPError();
XMPPError xmppError = e.getStanzaError();
assertNotNull("No XMPPError was received when kicking a room owner", xmppError);
assertEquals(
"A simple participant was able to kick another participant from the room",
@ -754,7 +754,7 @@ public class MultiUserChatTest extends SmackTestCase {
fail("User2 was able to ban a room owner");
}
catch (XMPPException e) {
XMPPError xmppError = e.getXMPPError();
XMPPError xmppError = e.getStanzaError();
assertNotNull("No XMPPError was received when banning a room owner", xmppError);
assertEquals(
"A simple participant was able to ban another participant from the room",
@ -842,7 +842,7 @@ public class MultiUserChatTest extends SmackTestCase {
fail("User2 was able to grant voice");
}
catch (XMPPException e) {
XMPPError xmppError = e.getXMPPError();
XMPPError xmppError = e.getStanzaError();
assertNotNull("No XMPPError was received granting voice", xmppError);
assertEquals(
"A visitor was able to grant voice to another visitor",
@ -947,7 +947,7 @@ public class MultiUserChatTest extends SmackTestCase {
fail("User2 was able to grant moderator privileges");
}
catch (XMPPException e) {
XMPPError xmppError = e.getXMPPError();
XMPPError xmppError = e.getStanzaError();
assertNotNull("No XMPPError was received granting moderator privileges", xmppError);
assertEquals(
"A visitor was able to grant moderator privileges to another visitor",
@ -1078,7 +1078,7 @@ public class MultiUserChatTest extends SmackTestCase {
fail("User2 was able to grant membership privileges");
}
catch (XMPPException e) {
XMPPError xmppError = e.getXMPPError();
XMPPError xmppError = e.getStanzaError();
assertNotNull(
"No XMPPError was received granting membership privileges",
xmppError);
@ -1188,7 +1188,7 @@ public class MultiUserChatTest extends SmackTestCase {
fail("User2 was able to grant admin privileges");
}
catch (XMPPException e) {
XMPPError xmppError = e.getXMPPError();
XMPPError xmppError = e.getStanzaError();
assertNotNull("No XMPPError was received granting admin privileges", xmppError);
assertEquals(
"A visitor was able to grant admin privileges to another visitor",
@ -1363,7 +1363,7 @@ public class MultiUserChatTest extends SmackTestCase {
fail("User2 was able to grant ownership privileges");
}
catch (XMPPException e) {
XMPPError xmppError = e.getXMPPError();
XMPPError xmppError = e.getStanzaError();
assertNotNull("No XMPPError was received granting ownership privileges", xmppError);
assertEquals(
"A visitor was able to grant ownership privileges to another visitor",
@ -1609,7 +1609,7 @@ public class MultiUserChatTest extends SmackTestCase {
fail("User2 was able to get the list of owners");
}
catch (XMPPException e) {
XMPPError xmppError = e.getXMPPError();
XMPPError xmppError = e.getStanzaError();
assertNotNull("No XMPPError was received getting the list of owners", xmppError);
assertEquals(
"A member was able to get the list of owners",

View file

@ -73,8 +73,8 @@ public class MultiUserSubscriptionUseCases extends PubSubTestCase
}
catch (XMPPException exc)
{
assertEquals("bad-request", exc.getXMPPError().getCondition());
assertEquals(XMPPError.Type.MODIFY, exc.getXMPPError().getType());
assertEquals("bad-request", exc.getStanzaError().getCondition());
assertEquals(XMPPError.Type.MODIFY, exc.getStanzaError().getType());
}
List<Item> items = user2Node.getItems(sub1.getId());
assertTrue(items.size() == 5);

View file

@ -47,7 +47,7 @@ public class PublisherUseCases extends SingleUserTestCase
fail("Exception should be thrown when there is no payload");
}
catch (XMPPException e) {
XMPPError err = e.getXMPPError();
XMPPError err = e.getStanzaError();
assertTrue(err.getType().equals(XMPPError.Type.MODIFY));
assertTrue(err.getCondition().equals(Condition.bad_request.toString()));
assertNotNull(err.getExtension("payload-required", PubSubNamespace.ERROR.getXmlns()));
@ -59,7 +59,7 @@ public class PublisherUseCases extends SingleUserTestCase
fail("Exception should be thrown when there is no payload");
}
catch (XMPPException e) {
XMPPError err = e.getXMPPError();
XMPPError err = e.getStanzaError();
assertTrue(err.getType().equals(XMPPError.Type.MODIFY));
assertTrue(err.getCondition().equals(Condition.bad_request.toString()));
assertNotNull(err.getExtension("payload-required", PubSubNamespace.ERROR.getXmlns()));
@ -104,7 +104,7 @@ public class PublisherUseCases extends SingleUserTestCase
fail("Exception should be thrown when there is no payload");
}
catch (XMPPException e) {
XMPPError err = e.getXMPPError();
XMPPError err = e.getStanzaError();
assertTrue(err.getType().equals(XMPPError.Type.MODIFY));
assertTrue(err.getCondition().equals(Condition.bad_request.toString()));
assertNotNull(err.getExtension("payload-required", PubSubNamespace.ERROR.getXmlns()));
@ -116,7 +116,7 @@ public class PublisherUseCases extends SingleUserTestCase
fail("Exception should be thrown when there is no payload");
}
catch (XMPPException e) {
XMPPError err = e.getXMPPError();
XMPPError err = e.getStanzaError();
assertTrue(err.getType().equals(XMPPError.Type.MODIFY));
assertTrue(err.getCondition().equals(Condition.bad_request.toString()));
assertNotNull(err.getExtension("payload-required", PubSubNamespace.ERROR.getXmlns()));

View file

@ -67,7 +67,7 @@ public class TestEvents extends SmackTestCase
}
catch (XMPPException e)
{
if (e.getXMPPError().getType() == Type.CANCEL && e.getXMPPError().getCondition().equals("item-not-found"))
if (e.getStanzaError().getType() == Type.CANCEL && e.getXMPPError().getCondition().equals("item-not-found"))
creatorNode = creatorMgr.createNode(nodeId);
else
throw e;

View file

@ -433,7 +433,7 @@ public final class AdHocCommandManager extends Manager {
// If there is an exception caused by the next, complete,
// prev or cancel method, then that error is returned to the
// requester.
StanzaError error = e.getXMPPError();
StanzaError error = e.getStanzaError();
// If the error type is cancel, then the execution is
// canceled therefore the status must show that, and the
@ -543,7 +543,7 @@ public final class AdHocCommandManager extends Manager {
// If there is an exception caused by the next, complete,
// prev or cancel method, then that error is returned to the
// requester.
StanzaError error = e.getXMPPError();
StanzaError error = e.getStanzaError();
// If the error type is cancel, then the execution is
// canceled therefore the status must show that, and the

View file

@ -344,7 +344,7 @@ public class OutgoingFileTransfer extends FileTransfer {
}
private void handleXMPPException(XMPPErrorException e) {
StanzaError error = e.getXMPPError();
StanzaError error = e.getStanzaError();
if (error != null) {
switch (error.getCondition()) {
case forbidden:

View file

@ -221,7 +221,7 @@ public final class PrivateDataManager extends Manager {
return true;
}
catch (XMPPErrorException e) {
if (e.getXMPPError().getCondition() == Condition.service_unavailable) {
if (e.getStanzaError().getCondition() == Condition.service_unavailable) {
return false;
}
else {

View file

@ -149,7 +149,7 @@ public final class PingManager extends Manager {
return true;
}
final StanzaError xmppError = xmppErrorException.getXMPPError();
final StanzaError xmppError = xmppErrorException.getStanzaError();
// We may received an error response from an intermediate service returning an error like
// 'remote-server-not-found' or 'remote-server-timeout' to us (which would fake the 'from' address,

View file

@ -276,12 +276,12 @@ public final class PubSubManager extends Manager {
return createNode(id);
}
catch (XMPPErrorException e1) {
if (e1.getXMPPError().getCondition() == Condition.item_not_found) {
if (e1.getStanzaError().getCondition() == Condition.item_not_found) {
try {
return createNode(id);
}
catch (XMPPErrorException e2) {
if (e2.getXMPPError().getCondition() == Condition.conflict) {
if (e2.getStanzaError().getCondition() == Condition.conflict) {
// The node was created in the meantime, re-try getNode(). Note that this case should be rare.
try {
return getNode(id);
@ -294,7 +294,7 @@ public final class PubSubManager extends Manager {
throw e2;
}
}
if (e1.getXMPPError().getCondition() == Condition.service_unavailable) {
if (e1.getStanzaError().getCondition() == Condition.service_unavailable) {
// This could be caused by Prosody bug #805 (see https://prosody.im/issues/issue/805). Prosody does not
// answer to disco#info requests on the node ID, which makes it undecidable if a node is a leaf or
// collection node.
@ -326,7 +326,7 @@ public final class PubSubManager extends Manager {
node = getNode(id);
}
catch (XMPPErrorException e) {
if (e.getXMPPError().getCondition() == Condition.service_unavailable) {
if (e.getStanzaError().getCondition() == Condition.service_unavailable) {
// This could be caused by Prosody bug #805 (see https://prosody.im/issues/issue/805). Prosody does not
// answer to disco#info requests on the node ID, which makes it undecidable if a node is a leaf or
// collection node.
@ -349,7 +349,7 @@ public final class PubSubManager extends Manager {
// Try to ensure that this is not a collection node by asking for one item form the node.
leafNode.getItems(1);
} catch (XMPPErrorException e) {
Condition condition = e.getXMPPError().getCondition();
Condition condition = e.getStanzaError().getCondition();
if (condition == Condition.feature_not_implemented) {
// XEP-0060 § 6.5.9.5: Item retrieval not supported, e.g. because node is a collection node
throw new PubSubException.NotALeafNodeException(id, pubSubService);
@ -369,7 +369,7 @@ public final class PubSubManager extends Manager {
return createNode(id);
}
catch (XMPPErrorException e1) {
if (e1.getXMPPError().getCondition() == Condition.conflict) {
if (e1.getStanzaError().getCondition() == Condition.conflict) {
return getLeafNodeProsodyWorkaround(id);
}
throw e1;
@ -556,7 +556,7 @@ public final class PubSubManager extends Manager {
leafNode = createNode();
}
catch (XMPPErrorException e) {
if (e.getXMPPError().getCondition() == StanzaError.Condition.forbidden) {
if (e.getStanzaError().getCondition() == StanzaError.Condition.forbidden) {
return false;
}
throw e;

View file

@ -125,7 +125,7 @@ public class InBandBytestreamManagerTest extends InitExtensions {
}
catch (XMPPErrorException e) {
assertEquals(StanzaError.Condition.feature_not_implemented,
e.getXMPPError().getCondition());
e.getStanzaError().getCondition());
}
}

View file

@ -451,7 +451,7 @@ public class Socks5ByteStreamManagerTest {
}
catch (XMPPErrorException e) {
protocol.verifyAll();
assertEquals(rejectPacket.getError(), e.getXMPPError());
assertEquals(rejectPacket.getError(), e.getStanzaError());
}
catch (Exception e) {
fail(e.getMessage());

View file

@ -110,7 +110,7 @@ public class Socks5ByteStreamRequestTest {
fail("exception should be thrown");
}
catch (XMPPErrorException e) {
assertTrue(e.getXMPPError().getDescriptiveText("en").contains("Could not establish socket with any provided host"));
assertTrue(e.getStanzaError().getDescriptiveText("en").contains("Could not establish socket with any provided host"));
}
// verify targets response
@ -154,7 +154,7 @@ public class Socks5ByteStreamRequestTest {
fail("exception should be thrown");
}
catch (XMPPErrorException e) {
assertTrue(e.getXMPPError().getDescriptiveText("en").contains("Could not establish socket with any provided host"));
assertTrue(e.getStanzaError().getDescriptiveText("en").contains("Could not establish socket with any provided host"));
}
// verify targets response
@ -201,7 +201,7 @@ public class Socks5ByteStreamRequestTest {
fail("exception should be thrown");
}
catch (XMPPErrorException e) {
assertTrue(e.getXMPPError().getDescriptiveText("en").contains(
assertTrue(e.getStanzaError().getDescriptiveText("en").contains(
"Could not establish socket with any provided host"));
}
@ -293,7 +293,7 @@ public class Socks5ByteStreamRequestTest {
fail("exception should be thrown");
}
catch (XMPPErrorException e) {
assertTrue(e.getXMPPError().getDescriptiveText("en").contains(
assertTrue(e.getStanzaError().getDescriptiveText("en").contains(
"Could not establish socket with any provided host"));
}

View file

@ -231,7 +231,7 @@ public class Socks5ClientForInitiatorTest {
fail("exception should be thrown");
}
catch (XMPPErrorException e) {
assertTrue(StanzaError.Condition.internal_server_error.equals(e.getXMPPError().getCondition()));
assertTrue(StanzaError.Condition.internal_server_error.equals(e.getStanzaError().getCondition()));
protocol.verifyAll();
}

View file

@ -77,7 +77,7 @@ public class ConfigureFormTest extends InitExtensions {
fail();
}
catch (XMPPErrorException e) {
Assert.assertEquals(StanzaError.Type.AUTH, e.getXMPPError().getType());
Assert.assertEquals(StanzaError.Type.AUTH, e.getStanzaError().getType());
}
}