activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [1/5] activemq-artemis git commit: ARTEMIS-565 Replace json.org with javax.json
Date Tue, 26 Jul 2016 01:46:34 GMT
Repository: activemq-artemis
Updated Branches:
  refs/heads/master e66478020 -> 110158bb8


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d0ecf0f3/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementWithPagingServerTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementWithPagingServerTest.java
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementWithPagingServerTest.java
index 236403b..793e82d 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementWithPagingServerTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/ManagementWithPagingServerTest.java
@@ -17,6 +17,7 @@
 package org.apache.activemq.artemis.tests.integration.management;
 
 import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
+import org.apache.activemq.artemis.api.core.JsonUtil;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.api.core.client.ClientConsumer;
 import org.apache.activemq.artemis.api.core.client.ClientMessage;
@@ -31,11 +32,11 @@ import org.apache.activemq.artemis.core.server.ActiveMQServers;
 import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy;
 import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
 import org.apache.activemq.artemis.utils.RandomUtil;
-import org.apache.activemq.artemis.utils.json.JSONArray;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 
+import javax.json.JsonArray;
 import java.nio.ByteBuffer;
 
 /**
@@ -77,9 +78,9 @@ public class ManagementWithPagingServerTest extends ManagementTestBase {
 
       String result = queueControl.listMessagesAsJSON(null);
 
-      JSONArray array = new JSONArray(result);
+      JsonArray array = JsonUtil.readJsonArray(result);
 
-      assertEquals(num, array.length());
+      assertEquals(num, array.size());
 
       //kick off receiver
       receiver.start();
@@ -88,9 +89,9 @@ public class ManagementWithPagingServerTest extends ManagementTestBase {
 
       result = queueControl.listMessagesAsJSON(null);
 
-      array = new JSONArray(result);
+      array = JsonUtil.readJsonArray(result);
 
-      assertEquals(0, array.length());
+      assertEquals(0, array.size());
    }
 
    @Test
@@ -129,9 +130,9 @@ public class ManagementWithPagingServerTest extends ManagementTestBase
{
 
       String jsonString = queueControl.listMessagesAsJSON(filter);
       Assert.assertNotNull(jsonString);
-      JSONArray array = new JSONArray(jsonString);
-      Assert.assertEquals(num / 2, array.length());
-      Assert.assertEquals(matchingValue, array.getJSONObject(0).get("key"));
+      JsonArray array = JsonUtil.readJsonArray(jsonString);
+      Assert.assertEquals(num / 2, array.size());
+      Assert.assertEquals(matchingValue, array.getJsonObject(0).getJsonNumber("key").longValue());
 
       long n = queueControl.countMessages(filter);
       assertEquals(num / 2, n);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/d0ecf0f3/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlTest.java
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlTest.java
index e66e70d..0073c8d 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlTest.java
@@ -16,6 +16,8 @@
  */
 package org.apache.activemq.artemis.tests.integration.management;
 
+import javax.json.JsonArray;
+import javax.json.JsonObject;
 import javax.management.Notification;
 import javax.management.openmbean.CompositeData;
 import java.util.HashMap;
@@ -25,6 +27,7 @@ import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.activemq.artemis.api.core.ActiveMQException;
+import org.apache.activemq.artemis.api.core.JsonUtil;
 import org.apache.activemq.artemis.api.core.Message;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.api.core.client.ClientConsumer;
@@ -49,8 +52,6 @@ import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
 import org.apache.activemq.artemis.tests.integration.jms.server.management.JMSUtil;
 import org.apache.activemq.artemis.utils.Base64;
 import org.apache.activemq.artemis.utils.RandomUtil;
-import org.apache.activemq.artemis.utils.json.JSONArray;
-import org.apache.activemq.artemis.utils.json.JSONObject;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -219,16 +220,16 @@ public class QueueControlTest extends ManagementTestBase {
 
       System.out.println("Consumers: " + queueControl.listConsumersAsJSON());
 
-      JSONArray obj = new JSONArray(queueControl.listConsumersAsJSON());
+      JsonArray obj = JsonUtil.readJsonArray(queueControl.listConsumersAsJSON());
 
-      assertEquals(1, obj.length());
+      assertEquals(1, obj.size());
 
       consumer.close();
       Assert.assertEquals(0, queueControl.getConsumerCount());
 
-      obj = new JSONArray(queueControl.listConsumersAsJSON());
+      obj = JsonUtil.readJsonArray(queueControl.listConsumersAsJSON());
 
-      assertEquals(0, obj.length());
+      assertEquals(0, obj.size());
 
       session.deleteQueue(queue);
    }
@@ -562,16 +563,16 @@ public class QueueControlTest extends ManagementTestBase {
 
       String jsonString = queueControl.listScheduledMessagesAsJSON();
       Assert.assertNotNull(jsonString);
-      JSONArray array = new JSONArray(jsonString);
-      Assert.assertEquals(1, array.length());
-      Assert.assertEquals(intValue, array.getJSONObject(0).get("key"));
+      JsonArray array = JsonUtil.readJsonArray(jsonString);
+      Assert.assertEquals(1, array.size());
+      Assert.assertEquals(intValue, array.getJsonObject(0).getJsonNumber("key").intValue());
 
       Thread.sleep(delay + 500);
 
       jsonString = queueControl.listScheduledMessagesAsJSON();
       Assert.assertNotNull(jsonString);
-      array = new JSONArray(jsonString);
-      Assert.assertEquals(0, array.length());
+      array = JsonUtil.readJsonArray(jsonString);
+      Assert.assertEquals(0, array.size());
 
       consumeMessages(2, session, queue);
 
@@ -620,16 +621,16 @@ public class QueueControlTest extends ManagementTestBase {
 
       String jsonString = queueControl.listMessagesAsJSON(null);
       Assert.assertNotNull(jsonString);
-      JSONArray array = new JSONArray(jsonString);
-      Assert.assertEquals(1, array.length());
-      Assert.assertEquals(intValue, array.getJSONObject(0).get("key"));
+      JsonArray array = JsonUtil.readJsonArray(jsonString);
+      Assert.assertEquals(1, array.size());
+      Assert.assertEquals(intValue, array.getJsonObject(0).getInt("key"));
 
       consumeMessages(1, session, queue);
 
       jsonString = queueControl.listMessagesAsJSON(null);
       Assert.assertNotNull(jsonString);
-      array = new JSONArray(jsonString);
-      Assert.assertEquals(0, array.length());
+      array = JsonUtil.readJsonArray(jsonString);
+      Assert.assertEquals(0, array.size());
 
       session.deleteQueue(queue);
    }
@@ -736,16 +737,16 @@ public class QueueControlTest extends ManagementTestBase {
 
       String jsonString = queueControl.listMessagesAsJSON(filter);
       Assert.assertNotNull(jsonString);
-      JSONArray array = new JSONArray(jsonString);
-      Assert.assertEquals(1, array.length());
-      Assert.assertEquals(matchingValue, array.getJSONObject(0).get("key"));
+      JsonArray array = JsonUtil.readJsonArray(jsonString);
+      Assert.assertEquals(1, array.size());
+      Assert.assertEquals(matchingValue, array.getJsonObject(0).getJsonNumber("key").longValue());
 
       consumeMessages(2, session, queue);
 
       jsonString = queueControl.listMessagesAsJSON(filter);
       Assert.assertNotNull(jsonString);
-      array = new JSONArray(jsonString);
-      Assert.assertEquals(0, array.length());
+      array = JsonUtil.readJsonArray(jsonString);
+      Assert.assertEquals(0, array.size());
 
       session.deleteQueue(queue);
    }
@@ -2099,8 +2100,8 @@ public class QueueControlTest extends ManagementTestBase {
    }
 
    protected long getFirstMessageId(final QueueControl queueControl) throws Exception {
-      JSONArray array = new JSONArray(queueControl.getFirstMessageAsJSON());
-      JSONObject object = (JSONObject)array.get(0);
-      return object.getLong("messageID");
+      JsonArray array = JsonUtil.readJsonArray(queueControl.getFirstMessageAsJSON());
+      JsonObject object = (JsonObject) array.get(0);
+      return object.getJsonNumber("messageID").longValue();
    }
 }


Mime
View raw message