Package org.hornetq.utils.json

Examples of org.hornetq.utils.json.JSONArray


      ClientConsumer consumer = session.createConsumer(queue);
      Assert.assertEquals(1, queueControl.getConsumerCount());

      System.out.println("Consumers: " + queueControl.listConsumersAsJSON());

      JSONArray obj = new JSONArray(queueControl.listConsumersAsJSON());

      assertEquals(1, obj.length());

      consumer.close();
      Assert.assertEquals(0, queueControl.getConsumerCount());

      obj = new JSONArray(queueControl.listConsumersAsJSON());

      assertEquals(0, obj.length());

      session.deleteQueue(queue);
   }
View Full Code Here


      // unscheduled message
      producer.send(session.createMessage(false));

      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"));

      Thread.sleep(delay + 500);

      jsonString = queueControl.listScheduledMessagesAsJSON();
      Assert.assertNotNull(jsonString);
      array = new JSONArray(jsonString);
      Assert.assertEquals(0, array.length());

      ManagementTestBase.consumeMessages(2, session, queue);

      session.deleteQueue(queue);
   }
View Full Code Here

      message.putIntProperty(new SimpleString("key"), intValue);
      producer.send(message);

      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"));

      ManagementTestBase.consumeMessages(1, session, queue);

      jsonString = queueControl.listMessagesAsJSON(null);
      Assert.assertNotNull(jsonString);
      array = new JSONArray(jsonString);
      Assert.assertEquals(0, array.length());

      session.deleteQueue(queue);
   }
View Full Code Here

      unmatchingMessage.putLongProperty(key, unmatchingValue);
      producer.send(unmatchingMessage);

      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"));

      ManagementTestBase.consumeMessages(2, session, queue);

      jsonString = queueControl.listMessagesAsJSON(filter);
      Assert.assertNotNull(jsonString);
      array = new JSONArray(jsonString);
      Assert.assertEquals(0, array.length());

      session.deleteQueue(queue);
   }
View Full Code Here

   // Static --------------------------------------------------------

   private static String toJSON(final Map<String, Object>[] messages)
   {
      JSONArray array = toJSONMsgArray(messages);
      return array.toString();
   }
View Full Code Here

      return array.toString();
   }

   private static JSONArray toJSONMsgArray(final Map<String, Object>[] messages)
   {
      JSONArray array = new JSONArray();
      for (Map<String, Object> message : messages)
      {
         array.put(new JSONObject(message));
      }
      return array;
   }
View Full Code Here

   private static String toJSON(final  Map<String, Map<String, Object>[]> messages)
   {
      try
      {
         JSONArray arrayReturn = new JSONArray();
         for (Map.Entry<String, Map<String, Object>[]> entry: messages.entrySet())
         {
            JSONObject objectItem = new JSONObject();
            objectItem.put("consumerName", entry.getKey());
            objectItem.put("elements", toJSONMsgArray(entry.getValue()));
            arrayReturn.put(objectItem);
         }

         return arrayReturn.toString();
      }
      catch (JSONException e)
      {
         return "Invalid conversion " + e.toString();
      }
View Full Code Here

      clearIO();
      try
      {
         Collection<Consumer> consumers = queue.getConsumers();

         JSONArray jsonArray = new JSONArray();

         for (Consumer consumer : consumers)
         {

            if (consumer instanceof ServerConsumer)
            {
               ServerConsumer serverConsumer = (ServerConsumer)consumer;

               JSONObject obj = new JSONObject();
               obj.put("consumerID", serverConsumer.getID());
               obj.put("connectionID", serverConsumer.getConnectionID().toString());
               obj.put("sessionID", serverConsumer.getSessionID());
               obj.put("browseOnly", serverConsumer.isBrowseOnly());
               obj.put("creationTime", serverConsumer.getCreationTime());

               jsonArray.put(obj);
            }

         }

         return jsonArray.toString();
      }
      finally
      {
         blockOnIO();
      }
View Full Code Here

      Connection connection = JMSUtil.createConnection(InVMConnectorFactory.class.getName());
      MessageConsumer consumer = JMSUtil.createConsumer(connection, queue);

      Assert.assertEquals(1, queueControl.getConsumerCount());

      JSONArray jsonArray = new JSONArray(queueControl.listConsumersAsJSON());

      assertEquals(1, jsonArray.length());

      JMSUtil.sendMessages(queue, 2);

      Assert.assertEquals(2, queueControl.getMessageCount());
      Assert.assertEquals(2, queueControl.getMessagesAdded());
View Full Code Here

      Assert.assertEquals(2, queueControl.getMessageCount());

      String jsonString = queueControl.listMessagesAsJSON(null);
      Assert.assertNotNull(jsonString);
      JSONArray array = new JSONArray(jsonString);
      Assert.assertEquals(2, array.length());
      Assert.assertEquals(ids[0], array.getJSONObject(0).get("JMSMessageID"));
      Assert.assertEquals(ids[1], array.getJSONObject(1).get("JMSMessageID"));

      JMSUtil.consumeMessages(2, queue);

      jsonString = queueControl.listMessagesAsJSON(null);
      Assert.assertNotNull(jsonString);
      array = new JSONArray(jsonString);
      Assert.assertEquals(0, array.length());
   }
View Full Code Here

TOP

Related Classes of org.hornetq.utils.json.JSONArray

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.