NO-JIRA fixing intermittent failure on ActiveMQServerControlTest

This commit is contained in:
Clebert Suconic 2022-12-13 11:59:53 -05:00
parent b5e25eb4fe
commit f6050b842e
1 changed files with 11 additions and 17 deletions

View File

@ -2615,32 +2615,26 @@ public class ActiveMQServerControlTest extends ManagementTestBase {
JsonArray array = JsonUtil.readJsonArray(jsonString); JsonArray array = JsonUtil.readJsonArray(jsonString);
Assert.assertEquals(usingCore() ? 3 : 2, array.size()); Assert.assertEquals(usingCore() ? 3 : 2, array.size());
String key = "creationTime";
JsonObject[] sorted = new JsonObject[array.size()]; JsonObject[] sorted = new JsonObject[array.size()];
for (int i = 0; i < array.size(); i++) { for (int i = 0; i < array.size(); i++) {
sorted[i] = array.getJsonObject(i); sorted[i] = array.getJsonObject(i);
} }
if (sorted[0].getJsonNumber(key).longValue() > sorted[1].getJsonNumber(key).longValue()) { JsonObject first = null;
JsonObject o = sorted[1]; JsonObject second = null;
sorted[1] = sorted[0];
sorted[0] = o; for (int i = 0; i < array.size(); i++) {
} JsonObject obj = array.getJsonObject(i);
if (usingCore()) { if (obj.getString("connectionID").equals(factories.get(0).getConnection().getID().toString())) {
if (sorted[1].getJsonNumber(key).longValue() > sorted[2].getJsonNumber(key).longValue()) { first = obj;
JsonObject o = sorted[2];
sorted[2] = sorted[1];
sorted[1] = o;
} }
if (sorted[0].getJsonNumber(key).longValue() > sorted[1].getJsonNumber(key).longValue()) { if (obj.getString("connectionID").equals(factories.get(1).getConnection().getID().toString())) {
JsonObject o = sorted[1]; second = obj;
sorted[1] = sorted[0];
sorted[0] = o;
} }
} }
JsonObject first = sorted[0]; Assert.assertNotNull(first);
JsonObject second = sorted[1]; Assert.assertNotNull(second);
Assert.assertTrue(first.getString("connectionID").length() > 0); Assert.assertTrue(first.getString("connectionID").length() > 0);
Assert.assertTrue(first.getString("clientAddress").length() > 0); Assert.assertTrue(first.getString("clientAddress").length() > 0);