javax.jms.MapMessage

Here are the examples of the java api class javax.jms.MapMessage taken from open source projects.

1. MapMessageTest#prepareMessage()

Project: activemq-artemis
File: MapMessageTest.java
// Protected -----------------------------------------------------
@Override
protected void prepareMessage(final Message m) throws JMSException {
    super.prepareMessage(m);
    MapMessage mm = (MapMessage) m;
    mm.setBoolean("boolean", true);
    mm.setByte("byte", (byte) 3);
    mm.setBytes("bytes", new byte[] { (byte) 3, (byte) 4, (byte) 5 });
    mm.setChar("char", (char) 6);
    mm.setDouble("double", 7.0);
    mm.setFloat("float", 8.0f);
    mm.setInt("int", 9);
    mm.setLong("long", 10L);
    mm.setObject("object", new String("this is an object"));
    mm.setShort("short", (short) 11);
    mm.setString("string", "this is a string");
}

2. CompressedInteropTest#sendCompressedMapMessageUsingOpenWire()

Project: activemq-artemis
File: CompressedInteropTest.java
private void sendCompressedMapMessageUsingOpenWire() throws Exception {
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    ActiveMQDestination destination = createDestination(session, ActiveMQDestination.QUEUE_TYPE);
    final ActiveMQMessageProducer producer = (ActiveMQMessageProducer) session.createProducer(destination);
    MapMessage mapMessage = session.createMapMessage();
    mapMessage.setBoolean("boolean-type", true);
    mapMessage.setByte("byte-type", (byte) 10);
    mapMessage.setBytes("bytes-type", TEXT.getBytes());
    mapMessage.setChar("char-type", 'A');
    mapMessage.setDouble("double-type", 55.3D);
    mapMessage.setFloat("float-type", 79.1F);
    mapMessage.setInt("int-type", 37);
    mapMessage.setLong("long-type", 56652L);
    mapMessage.setObject("object-type", new String("VVVV"));
    mapMessage.setShort("short-type", (short) 333);
    mapMessage.setString("string-type", TEXT);
    producer.send(mapMessage);
}

3. MessageCompressionTest#sendTestMapMessage()

Project: activemq-artemis
File: MessageCompressionTest.java
private void sendTestMapMessage(ActiveMQConnectionFactory factory, String message) throws JMSException {
    ActiveMQConnection connection = (ActiveMQConnection) factory.createConnection();
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    MessageProducer producer = session.createProducer(queue);
    MapMessage mapMessage = session.createMapMessage();
    mapMessage.setBoolean("boolean-type", true);
    mapMessage.setByte("byte-type", (byte) 10);
    mapMessage.setBytes("bytes-type", TEXT.getBytes());
    mapMessage.setChar("char-type", 'A');
    mapMessage.setDouble("double-type", 55.3D);
    mapMessage.setFloat("float-type", 79.1F);
    mapMessage.setInt("int-type", 37);
    mapMessage.setLong("long-type", 56652L);
    mapMessage.setObject("object-type", new String("VVVV"));
    mapMessage.setShort("short-type", (short) 333);
    mapMessage.setString("string-type", TEXT);
    producer.send(mapMessage);
    connection.close();
}

4. GeneralInteropTest#sendMapMessageUsingOpenWire()

Project: activemq-artemis
File: GeneralInteropTest.java
private void sendMapMessageUsingOpenWire() throws Exception {
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    ActiveMQDestination destination = createDestination(session, ActiveMQDestination.QUEUE_TYPE);
    System.out.println("destination: " + destination);
    final ActiveMQMessageProducer producer = (ActiveMQMessageProducer) session.createProducer(destination);
    MapMessage mapMessage = session.createMapMessage();
    mapMessage.setBoolean("aboolean", true);
    mapMessage.setByte("abyte", (byte) 4);
    mapMessage.setBytes("abytes", new byte[] { 4, 5 });
    mapMessage.setChar("achar", 'a');
    mapMessage.setDouble("adouble", 4.4);
    mapMessage.setFloat("afloat", 4.5f);
    mapMessage.setInt("aint", 40);
    mapMessage.setLong("along", 80L);
    mapMessage.setShort("ashort", (short) 65);
    mapMessage.setString("astring", "hello");
    producer.send(mapMessage);
}

5. JmsProduceMessageTypesTest#testSendJMSMapMessage()

Project: qpid-jms
File: JmsProduceMessageTypesTest.java
@Test(timeout = 60000)
public void testSendJMSMapMessage() throws Exception {
    connection = createAmqpConnection();
    connection.start();
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    assertNotNull(session);
    Queue queue = session.createQueue(name.getMethodName());
    MessageProducer producer = session.createProducer(queue);
    MapMessage message = session.createMapMessage();
    message.setBoolean("Boolean", false);
    message.setString("STRING", "TEST");
    producer.send(message);
    QueueViewMBean proxy = getProxyToQueue(name.getMethodName());
    assertEquals(1, proxy.getQueueSize());
    MessageConsumer consumer = session.createConsumer(queue);
    Message received = consumer.receive(5000);
    assertNotNull(received);
    assertTrue(received instanceof MapMessage);
    MapMessage map = (MapMessage) received;
    assertEquals("TEST", map.getString("STRING"));
    assertEquals(false, map.getBooleanProperty("Boolean"));
}

6. MercuryConsumerController#warmup()

Project: qpid-java
File: MercuryConsumerController.java
public void warmup() throws Exception {
    receiveFromController(OPCode.CONSUMER_STARTWARMUP);
    receiver.waitforCompletion(config.getWarmupCount());
    // It's more realistic for the consumer to signal this.
    MapMessage m1 = controllerSession.createMapMessage();
    m1.setInt(CODE, OPCode.PRODUCER_READY.ordinal());
    sendMessageToController(m1);
    MapMessage m2 = controllerSession.createMapMessage();
    m2.setInt(CODE, OPCode.CONSUMER_READY.ordinal());
    sendMessageToController(m2);
}

7. NestedMapMessageTest#createMessage()

Project: activemq-artemis
File: NestedMapMessageTest.java
@Override
protected Message createMessage(int index) throws JMSException {
    MapMessage answer = session.createMapMessage();
    answer.setString("textField", data[index]);
    Map<String, Object> grandChildMap = new HashMap<>();
    grandChildMap.put("x", "abc");
    grandChildMap.put("y", Arrays.asList(new Object[] { "a", "b", "c" }));
    Map<String, Object> nestedMap = new HashMap<>();
    nestedMap.put("a", "foo");
    nestedMap.put("b", Integer.valueOf(23));
    nestedMap.put("c", Long.valueOf(45));
    nestedMap.put("d", grandChildMap);
    answer.setObject("mapField", nestedMap);
    answer.setObject("listField", Arrays.asList(new Object[] { "a", "b", "c" }));
    return answer;
}

8. MercuryTestController#sendMessageToNodes()

Project: qpid-java
File: MercuryTestController.java
private synchronized void sendMessageToNodes(OPCode code, Collection<MapMessage> nodes) throws Exception {
    report.log("\nController: Sending code " + code);
    MessageProducer tmpProd = controllerSession.createProducer(null);
    MapMessage msg = controllerSession.createMapMessage();
    msg.setInt(CODE, code.ordinal());
    for (MapMessage node : nodes) {
        if (node.getString(REPLY_ADDR) == null) {
            report.log("REPLY_ADDR is null " + node);
        } else {
            report.log("Controller: Sending " + code + " to " + node.getString(REPLY_ADDR));
        }
        tmpProd.send(controllerSession.createQueue(node.getString(REPLY_ADDR)), msg);
    }
}

9. MessageHeaderTest#testCopyOnForeignMapMessage()

Project: activemq-artemis
File: MessageHeaderTest.java
@Test
public void testCopyOnForeignMapMessage() throws JMSException {
    ClientMessage clientMessage = new ClientMessageImpl(ActiveMQTextMessage.TYPE, true, 0, System.currentTimeMillis(), (byte) 4, 1000);
    ClientSession session = new FakeSession(clientMessage);
    MapMessage foreignMapMessage = new SimpleJMSMapMessage();
    foreignMapMessage.setInt("int", 1);
    foreignMapMessage.setString("string", "test");
    ActiveMQMapMessage copy = new ActiveMQMapMessage(foreignMapMessage, session);
    MessageHeaderTestBase.ensureEquivalent(foreignMapMessage, copy);
}

10. MapMessageTest#testNullValue()

Project: activemq-artemis
File: MapMessageTest.java
@Test
public void testNullValue() throws Exception {
    MapMessage m = session.createMapMessage();
    m.setString("nullValue", null);
    queueProd.send(m);
    MapMessage rm = (MapMessage) queueCons.receive(2000);
    ProxyAssertSupport.assertNotNull(rm);
    ProxyAssertSupport.assertNull(rm.getString("nullValue"));
}

11. MercuryConsumerController#runReceiver()

Project: qpid-java
File: MercuryConsumerController.java
public void runReceiver() throws Exception {
    if (_logger.isInfoEnabled()) {
        _logger.info("Consumer: " + id + " Starting iteration......" + "\n");
    }
    resetCounters();
    receiver.waitforCompletion(config.getMsgCount());
    MapMessage m = controllerSession.createMapMessage();
    m.setInt(CODE, OPCode.RECEIVED_END_MSG.ordinal());
    sendMessageToController(m);
}

12. MessageToStringTest#testMapMessage()

Project: qpid-java
File: MessageToStringTest.java
public void testMapMessage() throws JMSException, IOException {
    //Create Sample Message using UUIDs
    UUID test = UUID.randomUUID();
    MapMessage testMessage = _session.createMapMessage();
    byte[] testBytes = convertToBytes(test);
    testMessage.setBytes(BYTE_TEST, testBytes);
    sendAndTest(testMessage, testBytes);
}

13. AMQPEncodedMapMessageTest#testNullMessage()

Project: qpid-java
File: AMQPEncodedMapMessageTest.java
public void testNullMessage() throws JMSException {
    MapMessage m = _session.createMapMessage();
    ((AMQPEncodedMapMessage) m).setMap(null);
    _producer.send(m);
    AMQPEncodedMapMessage msg = (AMQPEncodedMapMessage) _consumer.receive(RECEIVE_TIMEOUT);
    assertNotNull("Message was not received on time", msg);
    assertEquals("Message content-type is incorrect", AMQPEncodedMapMessage.MIME_TYPE, ((AbstractJMSMessage) msg).getContentType());
    assertEquals("Message content should be null", null, ((AMQPEncodedMapMessage) msg).getMap());
}

14. AMQPEncodedMapMessageTest#testEmptyMessage()

Project: qpid-java
File: AMQPEncodedMapMessageTest.java
public void testEmptyMessage() throws JMSException {
    MapMessage m = _session.createMapMessage();
    _producer.send(m);
    AMQPEncodedMapMessage msg = (AMQPEncodedMapMessage) _consumer.receive(RECEIVE_TIMEOUT);
    assertNotNull("Message was not received on time", msg);
    assertEquals("Message content-type is incorrect", AMQPEncodedMapMessage.MIME_TYPE, ((AbstractJMSMessage) msg).getContentType());
    assertEquals("Message content should be an empty map", Collections.EMPTY_MAP, ((AMQPEncodedMapMessage) msg).getMap());
}

15. MapReceiver#main()

Project: qpid-java
File: MapReceiver.java
public static void main(String[] args) throws Exception {
    Connection connection = new AMQConnection("amqp://guest:guest@test/?brokerlist='tcp://localhost:5672'");
    connection.start();
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    Destination queue = new AMQAnyDestination("ADDR:message_queue; {create: always}");
    MessageConsumer consumer = session.createConsumer(queue);
    MapMessage m = (MapMessage) consumer.receive();
    System.out.println(m);
    connection.close();
}

16. JMSTopicProducer#sendMapMessage()

Project: flex-blazeds
File: JMSTopicProducer.java
@Override
void sendMapMessage(Map<String, ?> map, Map properties) throws JMSException {
    if (map == null)
        return;
    MapMessage message = session.createMapMessage();
    for (Map.Entry<String, ?> entry : map.entrySet()) message.setObject(entry.getKey(), entry.getValue());
    copyHeadersToProperties(properties, message);
    publisher.publish(message, getDeliveryMode(), messagePriority, getTimeToLive(properties));
}

17. JMSQueueProducer#sendMapMessage()

Project: flex-blazeds
File: JMSQueueProducer.java
@Override
void sendMapMessage(Map<String, ?> map, Map properties) throws JMSException {
    if (map == null)
        return;
    MapMessage message = session.createMapMessage();
    for (Map.Entry<String, ?> entry : map.entrySet()) message.setObject(entry.getKey(), entry.getValue());
    copyHeadersToProperties(properties, message);
    sender.send(message, getDeliveryMode(), messagePriority, getTimeToLive(properties));
}

18. JMSMessageProducerTest#testWithEmptyFeedOutputPaths()

Project: falcon
File: JMSMessageProducerTest.java
@Test
public void testWithEmptyFeedOutputPaths() throws Exception {
    List<String> args = createCommonArgs();
    List<String> newArgs = new ArrayList<String>(Arrays.asList("-" + WorkflowExecutionArgs.ENTITY_NAME.getName(), "agg-coord", "-" + WorkflowExecutionArgs.OUTPUT_FEED_NAMES.getName(), "null", "-" + WorkflowExecutionArgs.OUTPUT_FEED_PATHS.getName(), "null"));
    args.addAll(newArgs);
    List<String[]> messages = new ArrayList<String[]>();
    messages.add(args.toArray(new String[args.size()]));
    testProcessMessageCreator(messages, TOPIC_NAME);
    for (MapMessage m : mapMessages) {
        assertMessage(m);
        assertMessage(m);
        Assert.assertTrue(m.getString(WorkflowExecutionArgs.OUTPUT_FEED_NAMES.getName()).equals("null"));
        Assert.assertTrue(m.getString(WorkflowExecutionArgs.OUTPUT_FEED_PATHS.getName()).equals("null"));
    }
}

19. JMSMessageProducerTest#testWithFeedOutputPaths()

Project: falcon
File: JMSMessageProducerTest.java
@Test
public void testWithFeedOutputPaths() throws Exception {
    List<String> args = createCommonArgs();
    String[] outputFeedNames = { "click-logs", "raw-logs" };
    String[] outputFeeedPaths = { "/click-logs/10/05/05/00/20", "/raw-logs/10/05/05/00/20" };
    List<String> newArgs = new ArrayList<String>(Arrays.asList("-" + WorkflowExecutionArgs.ENTITY_NAME.getName(), "agg-coord", "-" + WorkflowExecutionArgs.OUTPUT_FEED_NAMES.getName(), "click-logs,raw-logs", "-" + WorkflowExecutionArgs.OUTPUT_FEED_PATHS.getName(), "/click-logs/10/05/05/00/20,/raw-logs/10/05/05/00/20"));
    args.addAll(newArgs);
    List<String[]> messages = new ArrayList<String[]>();
    messages.add(args.toArray(new String[args.size()]));
    testProcessMessageCreator(messages, TOPIC_NAME);
    int index = 0;
    for (MapMessage m : mapMessages) {
        assertMessage(m);
        Assert.assertTrue((m.getString(WorkflowExecutionArgs.OUTPUT_FEED_NAMES.getName()).equals(outputFeedNames[index])));
        Assert.assertTrue(m.getString(WorkflowExecutionArgs.OUTPUT_FEED_PATHS.getName()).equals(outputFeeedPaths[index]));
        ++index;
    }
}

20. Util#printMessageData()

Project: falcon
File: Util.java
/**
     * Prints JMSConsumer messages content.
     * @param messageConsumer the source JMSConsumer
     * @throws JMSException
     */
public static void printMessageData(JmsMessageConsumer messageConsumer) throws JMSException {
    LOGGER.info("dumping all queue data:");
    for (MapMessage mapMessage : messageConsumer.getReceivedMessages()) {
        StringBuilder stringBuilder = new StringBuilder();
        final Enumeration mapNames = mapMessage.getMapNames();
        while (mapNames.hasMoreElements()) {
            final String propName = mapNames.nextElement().toString();
            final String propValue = mapMessage.getString(propName);
            stringBuilder.append(propName).append('=').append(propValue).append(' ');
        }
        LOGGER.info(stringBuilder);
    }
}

21. JMSMultiPortOutputOperator#createMessageForMap()

Project: apex-malhar
File: JMSMultiPortOutputOperator.java
/**
   * Create a JMS MapMessage for the given Map.
   *
   * @param map the Map to convert
   * @return the resulting message
   * @throws JMSException if thrown by JMS methods
   */
private Message createMessageForMap(Map<?, ?> map) throws JMSException {
    MapMessage message = getSession().createMapMessage();
    for (Map.Entry<?, ?> entry : map.entrySet()) {
        if (!(entry.getKey() instanceof String)) {
            throw new RuntimeException("Cannot convert non-String key of type [" + entry.getKey().getClass() + "] to JMS MapMessage entry");
        }
        message.setObject((String) entry.getKey(), entry.getValue());
    }
    return message;
}

22. MapMessageTest#assertEquivalent()

Project: activemq-artemis
File: MapMessageTest.java
@Override
protected void assertEquivalent(final Message m, final int mode, final boolean redelivery) throws JMSException {
    super.assertEquivalent(m, mode, redelivery);
    MapMessage mm = (MapMessage) m;
    ProxyAssertSupport.assertEquals(true, mm.getBoolean("boolean"));
    ProxyAssertSupport.assertEquals((byte) 3, mm.getByte("byte"));
    byte[] bytes = mm.getBytes("bytes");
    ProxyAssertSupport.assertEquals((byte) 3, bytes[0]);
    ProxyAssertSupport.assertEquals((byte) 4, bytes[1]);
    ProxyAssertSupport.assertEquals((byte) 5, bytes[2]);
    ProxyAssertSupport.assertEquals((char) 6, mm.getChar("char"));
    ProxyAssertSupport.assertEquals(new Double(7.0), new Double(mm.getDouble("double")));
    ProxyAssertSupport.assertEquals(new Float(8.0f), new Float(mm.getFloat("float")));
    ProxyAssertSupport.assertEquals(9, mm.getInt("int"));
    ProxyAssertSupport.assertEquals(10L, mm.getLong("long"));
    ProxyAssertSupport.assertEquals("this is an object", mm.getObject("object"));
    ProxyAssertSupport.assertEquals((short) 11, mm.getShort("short"));
    ProxyAssertSupport.assertEquals("this is a string", mm.getString("string"));
}

23. ForeignMapMessageTest#assertEquivalent()

Project: activemq-artemis
File: ForeignMapMessageTest.java
@Override
protected void assertEquivalent(final Message m, final int mode, final boolean redelivery) throws JMSException {
    super.assertEquivalent(m, mode, redelivery);
    MapMessage map = (MapMessage) m;
    ProxyAssertSupport.assertTrue(map.getBoolean("boolean1"));
    ProxyAssertSupport.assertEquals(map.getChar("char1"), 'c');
    ProxyAssertSupport.assertEquals(map.getDouble("double1"), 1.0D, 0.0D);
    ProxyAssertSupport.assertEquals(map.getFloat("float1"), 2.0F, 0.0F);
    ProxyAssertSupport.assertEquals(map.getInt("int1"), 3);
    ProxyAssertSupport.assertEquals(map.getLong("long1"), 4L);
    ProxyAssertSupport.assertEquals(map.getObject("object1"), obj);
    ProxyAssertSupport.assertEquals(map.getShort("short1"), (short) 5);
    ProxyAssertSupport.assertEquals(map.getString("string1"), "stringvalue");
}

24. BrokerStatisticsPluginTest#testDestinationStatsWithDot()

Project: activemq-artemis
File: BrokerStatisticsPluginTest.java
public void testDestinationStatsWithDot() throws Exception {
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    Queue replyTo = session.createTemporaryQueue();
    MessageConsumer consumer = session.createConsumer(replyTo);
    Queue testQueue = session.createQueue("Test.Queue");
    MessageProducer producer = session.createProducer(null);
    Queue query = session.createQueue(StatisticsBroker.STATS_DESTINATION_PREFIX + "." + testQueue.getQueueName());
    Message msg = session.createMessage();
    producer.send(testQueue, msg);
    msg.setJMSReplyTo(replyTo);
    producer.send(query, msg);
    MapMessage reply = (MapMessage) consumer.receive(10 * 1000);
    assertNotNull(reply);
    assertTrue(reply.getMapNames().hasMoreElements());
    assertTrue(reply.getJMSTimestamp() > 0);
    assertEquals(Message.DEFAULT_PRIORITY, reply.getJMSPriority());
/*
        for (Enumeration e = reply.getMapNames();e.hasMoreElements();) {
            String name = e.nextElement().toString();
            System.err.println(name+"="+reply.getObject(name));
        }
        */
}

25. BrokerStatisticsPluginTest#testDestinationStats()

Project: activemq-artemis
File: BrokerStatisticsPluginTest.java
public void testDestinationStats() throws Exception {
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    Queue replyTo = session.createTemporaryQueue();
    MessageConsumer consumer = session.createConsumer(replyTo);
    Queue testQueue = session.createQueue("Test.Queue");
    MessageProducer producer = session.createProducer(null);
    Queue query = session.createQueue(StatisticsBroker.STATS_DESTINATION_PREFIX + testQueue.getQueueName());
    Message msg = session.createMessage();
    producer.send(testQueue, msg);
    msg.setJMSReplyTo(replyTo);
    producer.send(query, msg);
    MapMessage reply = (MapMessage) consumer.receive(10 * 1000);
    assertNotNull(reply);
    assertTrue(reply.getMapNames().hasMoreElements());
    assertTrue(reply.getJMSTimestamp() > 0);
    assertEquals(Message.DEFAULT_PRIORITY, reply.getJMSPriority());
/*
        for (Enumeration e = reply.getMapNames();e.hasMoreElements();) {
            String name = e.nextElement().toString();
            System.err.println(name+"="+reply.getObject(name));
        }
        */
}

26. BrokerStatisticsPluginTest#testBrokerStats()

Project: activemq-artemis
File: BrokerStatisticsPluginTest.java
public void testBrokerStats() throws Exception {
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    Queue replyTo = session.createTemporaryQueue();
    MessageConsumer consumer = session.createConsumer(replyTo);
    Queue query = session.createQueue(StatisticsBroker.STATS_BROKER_PREFIX);
    MessageProducer producer = session.createProducer(query);
    Message msg = session.createMessage();
    msg.setJMSReplyTo(replyTo);
    producer.send(msg);
    MapMessage reply = (MapMessage) consumer.receive(10 * 1000);
    assertNotNull(reply);
    assertTrue(reply.getMapNames().hasMoreElements());
    assertTrue(reply.getJMSTimestamp() > 0);
    assertEquals(Message.DEFAULT_PRIORITY, reply.getJMSPriority());
/*
        for (Enumeration e = reply.getMapNames();e.hasMoreElements();) {
            String name = e.nextElement().toString();
            System.err.println(name+"="+reply.getObject(name));
        }
        */
}

27. CompressionOverNetworkTest#testMapMessageCompression()

Project: activemq-artemis
File: CompressionOverNetworkTest.java
@Test
public void testMapMessageCompression() throws Exception {
    MessageConsumer consumer1 = remoteSession.createConsumer(included);
    MessageProducer producer = localSession.createProducer(included);
    producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
    waitForConsumerRegistration(localBroker, 1, included);
    MapMessage test = localSession.createMapMessage();
    for (int i = 0; i < 100; ++i) {
        test.setString(Integer.toString(i), "test string: " + i);
    }
    producer.send(test);
    Message msg = consumer1.receive(RECEIVE_TIMEOUT_MILLS);
    assertNotNull(msg);
    ActiveMQMapMessage message = (ActiveMQMapMessage) msg;
    assertTrue(message.isCompressed());
    for (int i = 0; i < 100; ++i) {
        assertEquals("test string: " + i, message.getString(Integer.toString(i)));
    }
}

28. AMQPEncodedMapMessageTest#testMessageWithContent()

Project: qpid-java
File: AMQPEncodedMapMessageTest.java
public void testMessageWithContent() throws JMSException {
    MapMessage m = _session.createMapMessage();
    m.setBoolean("Boolean", true);
    m.setByte("Byte", (byte) 5);
    byte[] bytes = new byte[] { (byte) 5, (byte) 8 };
    m.setBytes("Bytes", bytes);
    m.setChar("Char", 'X');
    m.setDouble("Double", 56.84);
    m.setFloat("Float", Integer.MAX_VALUE + 5000);
    m.setInt("Int", Integer.MAX_VALUE - 5000);
    m.setShort("Short", (short) 58);
    m.setString("String", "Hello");
    m.setObject("uuid", myUUID);
    _producer.send(m);
    AMQPEncodedMapMessage msg = (AMQPEncodedMapMessage) _consumer.receive(RECEIVE_TIMEOUT);
    assertNotNull("Message was not received on time", msg);
    assertEquals("Message content-type is incorrect", AMQPEncodedMapMessage.MIME_TYPE, ((AbstractJMSMessage) msg).getContentType());
    assertEquals(true, m.getBoolean("Boolean"));
    assertEquals((byte) 5, m.getByte("Byte"));
    byte[] bytesRcv = m.getBytes("Bytes");
    assertNotNull("Byte array is null", bytesRcv);
    assertEquals((byte) 5, bytesRcv[0]);
    assertEquals((byte) 8, bytesRcv[1]);
    assertEquals('X', m.getChar("Char"));
    assertEquals(56.84, m.getDouble("Double"));
    //assertEquals(Integer.MAX_VALUE + 5000,m.getFloat("Float"));
    assertEquals(Integer.MAX_VALUE - 5000, m.getInt("Int"));
    assertEquals((short) 58, m.getShort("Short"));
    assertEquals("Hello", m.getString("String"));
    assertEquals(myUUID, (UUID) m.getObject("uuid"));
}

29. JMSQueueControlTest#testBrowseMapMessages()

Project: activemq-artemis
File: JMSQueueControlTest.java
@Test
public void testBrowseMapMessages() throws Exception {
    JMSQueueControl queueControl = createManagementControl();
    Assert.assertEquals(0, getMessageCount(queueControl));
    ActiveMQJMSConnectionFactory cf = (ActiveMQJMSConnectionFactory) ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, new TransportConfiguration(InVMConnectorFactory.class.getName()));
    Connection conn = cf.createConnection();
    conn.start();
    Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
    MessageProducer producer = session.createProducer(queue);
    MapMessage message = session.createMapMessage();
    message.setString("stringP", "aStringP");
    message.setBoolean("booleanP", true);
    message.setByte("byteP", (byte) 1);
    message.setChar("charP", 'q');
    message.setDouble("doubleP", 3.2);
    message.setFloat("floatP", 4.5F);
    message.setInt("intP", 8);
    message.setLong("longP", 7);
    message.setShort("shortP", (short) 777);
    producer.send(message);
    Assert.assertEquals(1, getMessageCount(queueControl));
    CompositeData[] data = queueControl.browse();
    Assert.assertEquals(1, data.length);
    String contentMap = (String) data[0].get("ContentMap");
    Assert.assertNotNull(contentMap);
    Assert.assertTrue(contentMap.contains("intP=8"));
    Assert.assertTrue(contentMap.contains("floatP=4.5"));
    Assert.assertTrue(contentMap.contains("longP=7"));
    Assert.assertTrue(contentMap.contains("charP=q"));
    Assert.assertTrue(contentMap.contains("byteP=1"));
    Assert.assertTrue(contentMap.contains("doubleP=3.2"));
    Assert.assertTrue(contentMap.contains("stringP=aStringP"));
    Assert.assertTrue(contentMap.contains("booleanP=true"));
    Assert.assertTrue(contentMap.contains("shortP=777"));
    System.out.println(data[0]);
    JMSUtil.consumeMessages(1, queue);
    data = queueControl.browse();
    Assert.assertEquals(0, data.length);
    conn.close();
}

30. MercuryConsumerController#sendResults()

Project: qpid-java
File: MercuryConsumerController.java
public void sendResults() throws Exception {
    receiveFromController(OPCode.CONSUMER_STOP);
    reporter.report();
    MapMessage m = controllerSession.createMapMessage();
    m.setInt(CODE, OPCode.RECEIVED_CONSUMER_STATS.ordinal());
    m.setDouble(AVG_LATENCY, reporter.getAvgLatency());
    m.setDouble(MIN_LATENCY, reporter.getMinLatency());
    m.setDouble(MAX_LATENCY, reporter.getMaxLatency());
    m.setDouble(STD_DEV, reporter.getStdDev());
    m.setDouble(CONS_RATE, reporter.getRate());
    m.setLong(MSG_COUNT, reporter.getSampleSize());
    sendMessageToController(m);
    reporter.log(new StringBuilder("Total Msgs Received : ").append(reporter.getSampleSize()).toString());
    reporter.log(new StringBuilder("Consumer rate       : ").append(config.getDecimalFormat().format(reporter.getRate())).append(" msg/sec").toString());
    reporter.log(new StringBuilder("Avg Latency         : ").append(config.getDecimalFormat().format(reporter.getAvgLatency())).append(" ms").toString());
    reporter.log(new StringBuilder("Min Latency         : ").append(config.getDecimalFormat().format(reporter.getMinLatency())).append(" ms").toString());
    reporter.log(new StringBuilder("Max Latency         : ").append(config.getDecimalFormat().format(reporter.getMaxLatency())).append(" ms").toString());
    if (config.isPrintStdDev()) {
        reporter.log(new StringBuilder("Std Dev             : ").append(reporter.getStdDev()).toString());
    }
}

31. MapSender#main()

Project: qpid-java
File: MapSender.java
public static void main(String[] args) throws Exception {
    Connection connection = new AMQConnection("amqp://guest:guest@test/?brokerlist='tcp://localhost:5672'");
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    Destination queue = new AMQAnyDestination("ADDR:message_queue; {create: always}");
    MessageProducer producer = session.createProducer(queue);
    MapMessage m = session.createMapMessage();
    m.setIntProperty("Id", 987654321);
    m.setStringProperty("name", "Widget");
    m.setDoubleProperty("price", 0.99);
    List<String> colors = new ArrayList<String>();
    colors.add("red");
    colors.add("green");
    colors.add("white");
    m.setObject("colours", colors);
    Map<String, Double> dimensions = new HashMap<String, Double>();
    dimensions.put("length", 10.2);
    dimensions.put("width", 5.1);
    dimensions.put("depth", 2.0);
    m.setObject("dimensions", dimensions);
    List<List<Integer>> parts = new ArrayList<List<Integer>>();
    parts.add(Arrays.asList(new Integer[] { 1, 2, 5 }));
    parts.add(Arrays.asList(new Integer[] { 8, 2, 5 }));
    m.setObject("parts", parts);
    Map<String, Object> specs = new HashMap<String, Object>();
    specs.put("colours", colors);
    specs.put("dimensions", dimensions);
    specs.put("parts", parts);
    m.setObject("specs", specs);
    producer.send(m);
    connection.close();
}

32. MercuryProducerController#sendResults()

Project: qpid-java
File: MercuryProducerController.java
public void sendResults() throws Exception {
    MapMessage msg = controllerSession.createMapMessage();
    msg.setInt(CODE, OPCode.RECEIVED_PRODUCER_STATS.ordinal());
    msg.setDouble(PROD_RATE, reporter.getRate());
    sendMessageToController(msg);
    reporter.log(new StringBuilder("Producer rate: ").append(config.getDecimalFormat().format(reporter.getRate())).append(" msg/sec").toString());
}

33. AMQPEncodedMapMessageTest#testMessageWithMapEntries()

Project: qpid-java
File: AMQPEncodedMapMessageTest.java
public void testMessageWithMapEntries() throws JMSException {
    MapMessage m = _session.createMapMessage();
    Map<String, String> myMap = getMap();
    m.setObject("Map", myMap);
    Map<String, UUID> uuidMap = new HashMap<String, UUID>();
    uuidMap.put("uuid", myUUID);
    m.setObject("uuid-map", uuidMap);
    _producer.send(m);
    AMQPEncodedMapMessage msg = (AMQPEncodedMapMessage) _consumer.receive(RECEIVE_TIMEOUT);
    assertNotNull("Message was not received on time", msg);
    assertEquals("Message content-type is incorrect", AMQPEncodedMapMessage.MIME_TYPE, ((AbstractJMSMessage) msg).getContentType());
    Map<String, String> map = (Map<String, String>) msg.getObject("Map");
    assertNotNull("Map not received", map);
    for (int i = 1; i < 4; i++) {
        assertEquals("String" + i, map.get("Key" + i));
        i++;
    }
    Map<String, UUID> map2 = (Map<String, UUID>) msg.getObject("uuid-map");
    assertNotNull("Map not received", map2);
    assertEquals(myUUID, map2.get("uuid"));
}

34. AMQPEncodedMapMessageTest#testMessageWithListEntries()

Project: qpid-java
File: AMQPEncodedMapMessageTest.java
public void testMessageWithListEntries() throws JMSException {
    MapMessage m = _session.createMapMessage();
    List<Integer> myList = getList();
    m.setObject("List", myList);
    List<UUID> uuidList = new ArrayList<UUID>();
    uuidList.add(myUUID);
    m.setObject("uuid-list", uuidList);
    _producer.send(m);
    AMQPEncodedMapMessage msg = (AMQPEncodedMapMessage) _consumer.receive(RECEIVE_TIMEOUT);
    assertNotNull("Message was not received on time", msg);
    assertEquals("Message content-type is incorrect", AMQPEncodedMapMessage.MIME_TYPE, ((AbstractJMSMessage) msg).getContentType());
    List<Integer> list = (List<Integer>) msg.getObject("List");
    assertNotNull("List not received", list);
    Collections.sort(list);
    int i = 1;
    for (Integer j : list) {
        assertEquals(i, j.intValue());
        i++;
    }
    List<UUID> list2 = (List<UUID>) msg.getObject("uuid-list");
    assertNotNull("UUID List not received", list2);
    assertEquals(myUUID, list2.get(0));
}

35. MercuryTestController#calcStats()

Project: qpid-java
File: MercuryTestController.java
public void calcStats() throws Exception {
    double totLatency = 0.0;
    double totStdDev = 0.0;
    double totalConsRate = 0.0;
    double totalProdRate = 0.0;
    // for error handling
    MapMessage conStat = null;
    try {
        for (MapMessage m : consumers.values()) {
            conStat = m;
            minSystemLatency = Math.min(minSystemLatency, m.getDouble(MIN_LATENCY));
            maxSystemLatency = Math.max(maxSystemLatency, m.getDouble(MAX_LATENCY));
            totLatency = totLatency + m.getDouble(AVG_LATENCY);
            totStdDev = totStdDev + m.getDouble(STD_DEV);
            minSystemConsRate = Math.min(minSystemConsRate, m.getDouble(CONS_RATE));
            maxSystemConsRate = Math.max(maxSystemConsRate, m.getDouble(CONS_RATE));
            totalConsRate = totalConsRate + m.getDouble(CONS_RATE);
            totalMsgCount = totalMsgCount + m.getLong(MSG_COUNT);
        }
    } catch (Exception e) {
        System.err.println("Error calculating stats from Consumer : " + conStat);
    }
    // for error handling
    MapMessage prodStat = null;
    try {
        for (MapMessage m : producers.values()) {
            prodStat = m;
            minSystemProdRate = Math.min(minSystemProdRate, m.getDouble(PROD_RATE));
            maxSystemProdRate = Math.max(maxSystemProdRate, m.getDouble(PROD_RATE));
            totalProdRate = totalProdRate + m.getDouble(PROD_RATE);
        }
    } catch (Exception e) {
        System.err.println("Error calculating stats from Producer : " + conStat);
    }
    avgSystemLatency = totLatency / consumers.size();
    avgSystemLatencyStdDev = totStdDev / consumers.size();
    avgSystemConsRate = totalConsRate / consumers.size();
    avgSystemProdRate = totalProdRate / producers.size();
    report.log("Total test time     : " + totalTestTime + " in " + Clock.getPrecision());
    totalSystemThroughput = (totalMsgCount * Clock.convertToSecs() / totalTestTime);
}

36. MercuryProducerController#setUp()

Project: qpid-java
File: MercuryProducerController.java
public void setUp() throws Exception {
    super.setUp();
    sender = new QpidSend(reporter, config, con, dest);
    sender.setUp();
    MapMessage m = controllerSession.createMapMessage();
    m.setInt(CODE, OPCode.REGISTER_PRODUCER.ordinal());
    sendMessageToController(m);
}

37. MercuryConsumerController#setUp()

Project: qpid-java
File: MercuryConsumerController.java
public void setUp() throws Exception {
    super.setUp();
    receiver = new QpidReceive(reporter, config, con, dest);
    receiver.setUp();
    MapMessage m = controllerSession.createMapMessage();
    m.setInt(CODE, OPCode.REGISTER_CONSUMER.ordinal());
    sendMessageToController(m);
}

38. AMQPEncodedMapMessageTest#testMessageWithNestedListsAndMaps()

Project: qpid-java
File: AMQPEncodedMapMessageTest.java
public void testMessageWithNestedListsAndMaps() throws JMSException {
    MapMessage m = _session.createMapMessage();
    Map<String, Object> myMap = new HashMap<String, Object>();
    myMap.put("map", getMap());
    myMap.put("list", getList());
    m.setObject("Map", myMap);
    _producer.send(m);
    AMQPEncodedMapMessage msg = (AMQPEncodedMapMessage) _consumer.receive(RECEIVE_TIMEOUT);
    assertNotNull("Message was not received on time", msg);
    assertEquals("Message content-type is incorrect", AMQPEncodedMapMessage.MIME_TYPE, ((AbstractJMSMessage) msg).getContentType());
    Map<String, Object> mainMap = (Map<String, Object>) msg.getObject("Map");
    assertNotNull("Main Map not received", mainMap);
    Map<String, String> map = (Map<String, String>) mainMap.get("map");
    assertNotNull("Nested Map not received", map);
    for (int i = 1; i < 4; i++) {
        assertEquals("String" + i, map.get("Key" + i));
        i++;
    }
    List<Integer> list = (List<Integer>) mainMap.get("list");
    assertNotNull("Nested List not received", list);
    Collections.sort(list);
    int i = 1;
    for (Integer j : list) {
        assertEquals(i, j.intValue());
        i++;
    }
}

39. LargeMessageOverReplicationTest#testReceiveLargeMessage()

Project: activemq-artemis
File: LargeMessageOverReplicationTest.java
@Test
@BMRules(rules = { @BMRule(name = "InterruptReceive", targetClass = "org.apache.activemq.artemis.core.protocol.core.impl.CoreSessionCallback", targetMethod = "sendLargeMessageContinuation", targetLocation = "ENTRY", action = "org.apache.activemq.artemis.tests.extras.byteman.LargeMessageOverReplicationTest.messageChunkReceived();") })
public void testReceiveLargeMessage() throws Exception {
    MapMessage message = createLargeMessage();
    producer.send(message);
    session.commit();
    MessageConsumer consumer = session.createConsumer(queue);
    connection.start();
    MapMessage messageRec = null;
    try {
        consumer.receive(5000);
        Assert.fail("Expected a failure here");
    } catch (JMSException expected) {
    }
    session.rollback();
    messageRec = (MapMessage) consumer.receive(5000);
    Assert.assertNotNull(messageRec);
    session.commit();
    for (int i = 0; i < 10; i++) {
        Assert.assertEquals(1024 * 1024, message.getBytes("test" + i).length);
    }
}

40. LargeMessageOverReplicationTest#testSendLargeMessage()

Project: activemq-artemis
File: LargeMessageOverReplicationTest.java
/*
   * simple test to induce a potential race condition where the server's acceptors are active, but the server's
   * state != STARTED
   */
@Test
@BMRules(rules = { @BMRule(name = "InterruptSending", targetClass = "org.apache.activemq.artemis.core.protocol.core.impl.ActiveMQSessionContext", targetMethod = "sendLargeMessageChunk", targetLocation = "ENTRY", action = "org.apache.activemq.artemis.tests.extras.byteman.LargeMessageOverReplicationTest.messageChunkSent();") })
public void testSendLargeMessage() throws Exception {
    MapMessage message = createLargeMessage();
    try {
        producer.send(message);
        Assert.fail("expected an exception");
    //      session.commit();
    } catch (JMSException expected) {
    }
    session.rollback();
    producer.send(message);
    session.commit();
    MessageConsumer consumer = session.createConsumer(queue);
    connection.start();
    MapMessage messageRec = (MapMessage) consumer.receive(5000);
    Assert.assertNotNull(messageRec);
    for (int i = 0; i < 10; i++) {
        Assert.assertEquals(1024 * 1024, message.getBytes("test" + i).length);
    }
}

41. InactiveQueueTest#testNoSubscribers()

Project: activemq-artemis
File: InactiveQueueTest.java
public void testNoSubscribers() throws Exception {
    connection = connectionFactory.createConnection(USERNAME, DEFAULT_PASSWORD);
    assertNotNull(connection);
    connection.start();
    session = connection.createSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE);
    assertNotNull(session);
    destination = session.createQueue(QUEUE_NAME);
    assertNotNull(destination);
    publisher = session.createProducer(destination);
    assertNotNull(publisher);
    MapMessage msg = session.createMapMessage();
    assertNotNull(msg);
    msg.setString("key1", "value1");
    int loop;
    for (loop = 0; loop < MESSAGE_COUNT; loop++) {
        msg.setInt("key2", loop);
        publisher.send(msg, DELIVERY_MODE, DELIVERY_PRIORITY, Message.DEFAULT_TIME_TO_LIVE);
        if (loop % 500 == 0) {
            LOG.debug("Sent " + loop + " messages");
        }
    }
    Thread.sleep(1000000);
    assertEquals(loop, MESSAGE_COUNT);
    publisher.close();
    session.close();
    connection.stop();
    connection.stop();
}

42. MercuryBase#continueTest()

Project: qpid-java
File: MercuryBase.java
public boolean continueTest() throws Exception {
    MapMessage m = (MapMessage) receiveFromController.receive();
    OPCode code = OPCode.values()[m.getInt(CODE)];
    _logger.debug("Received Code : " + code);
    return (code == OPCode.CONTINUE_TEST);
}

43. MercuryBase#receiveFromController()

Project: qpid-java
File: MercuryBase.java
public void receiveFromController(OPCode expected) throws Exception {
    MapMessage m = (MapMessage) receiveFromController.receive();
    OPCode code = OPCode.values()[m.getInt(CODE)];
    _logger.debug("Received Code : " + code);
    if (expected != code) {
        throw new Exception("Expected OPCode : " + expected + " but received : " + code);
    }
}

44. JMSMessageProducerTest#testConsumerWithMultipleTopics()

Project: falcon
File: JMSMessageProducerTest.java
@Test
public void testConsumerWithMultipleTopics() throws Exception {
    List<String[]> messages = new ArrayList<String[]>();
    List<String> args = createCommonArgs();
    List<String> newArgs = new ArrayList<String>(Arrays.asList("-" + WorkflowExecutionArgs.ENTITY_NAME.getName(), "agg-coord", "-" + WorkflowExecutionArgs.OUTPUT_FEED_NAMES.getName(), "raw-logs", "-" + WorkflowExecutionArgs.OUTPUT_FEED_PATHS.getName(), "/raw-logs/10/05/05/00/20"));
    args.addAll(newArgs);
    messages.add(args.toArray(new String[args.size()]));
    args = createCommonArgs();
    newArgs = new ArrayList<String>(Arrays.asList("-" + WorkflowExecutionArgs.ENTITY_NAME.getName(), "agg-coord", "-" + WorkflowExecutionArgs.OUTPUT_FEED_NAMES.getName(), "click-logs", "-" + WorkflowExecutionArgs.OUTPUT_FEED_PATHS.getName(), "/click-logs/10/05/05/00/20"));
    args.addAll(newArgs);
    messages.add(args.toArray(new String[args.size()]));
    testProcessMessageCreator(messages, TOPIC_NAME + "," + SECONDARY_TOPIC_NAME);
    Assert.assertEquals(mapMessages.size(), 2);
    for (MapMessage m : mapMessages) {
        assertMessage(m);
    }
}

45. JMSMessageConsumerTest#getMockFalconMessage()

Project: falcon
File: JMSMessageConsumerTest.java
private Message getMockFalconMessage(int i, Session session) throws FalconException, JMSException {
    Map<String, String> message = new HashMap<String, String>();
    message.put(WorkflowExecutionArgs.BRKR_IMPL_CLASS.getName(), BROKER_IMPL_CLASS);
    message.put(WorkflowExecutionArgs.BRKR_URL.getName(), BROKER_URL);
    message.put(WorkflowExecutionArgs.CLUSTER_NAME.getName(), "cluster1");
    message.put(WorkflowExecutionArgs.ENTITY_NAME.getName(), "process1");
    message.put(WorkflowExecutionArgs.ENTITY_TYPE.getName(), "PROCESS");
    message.put(WorkflowExecutionArgs.OUTPUT_FEED_PATHS.getName(), "/clicks/hour/00/0" + i);
    message.put(WorkflowExecutionArgs.OUTPUT_FEED_NAMES.getName(), "clicks");
    message.put(WorkflowExecutionArgs.LOG_FILE.getName(), "/logfile");
    message.put(WorkflowExecutionArgs.LOG_DIR.getName(), "/tmp/falcon-log");
    message.put(WorkflowExecutionArgs.NOMINAL_TIME.getName(), "2012-10-10-10-10");
    message.put(WorkflowExecutionArgs.OPERATION.getName(), "GENERATE");
    message.put(WorkflowExecutionArgs.RUN_ID.getName(), "0");
    message.put(WorkflowExecutionArgs.TIMESTAMP.getName(), "2012-10-10-10-1" + i);
    message.put(WorkflowExecutionArgs.WORKFLOW_ID.getName(), "workflow-" + i);
    message.put(WorkflowExecutionArgs.TOPIC_NAME.getName(), TOPIC_NAME);
    message.put(WorkflowExecutionArgs.STATUS.getName(), i != 15 ? "SUCCEEDED" : "FAILED");
    message.put(WorkflowExecutionArgs.WORKFLOW_USER.getName(), FalconTestUtil.TEST_USER_1);
    String[] args = new String[message.size() * 2];
    int index = 0;
    for (Map.Entry<String, String> entry : message.entrySet()) {
        args[index++] = "-" + entry.getKey();
        args[index++] = entry.getValue();
    }
    WorkflowExecutionContext context = WorkflowExecutionContext.create(args, WorkflowExecutionContext.Type.POST_PROCESSING);
    MapMessage jmsMessage = session.createMapMessage();
    for (Map.Entry<WorkflowExecutionArgs, String> entry : context.entrySet()) {
        jmsMessage.setString(entry.getKey().getName(), entry.getValue());
    }
    return jmsMessage;
}

46. JMSMessageProducer#createMessage()

Project: falcon
File: JMSMessageProducer.java
public Message createMessage(Session session, Map<String, String> message) throws JMSException {
    MapMessage mapMessage = session.createMapMessage();
    for (Map.Entry<String, String> entry : message.entrySet()) {
        mapMessage.setString(entry.getKey(), entry.getValue());
    }
    return mapMessage;
}

47. RetentionTest#validateDataFromFeedQueue()

Project: falcon
File: RetentionTest.java
/**
     * Makes validation based on comparison of data which is expected to be removed with data
     * mentioned in messages from ActiveMQ.
     *
     * @param feedName feed name
     * @param messages messages from ActiveMQ
     * @param missingData data which is expected to be removed after retention succeeded
     * @throws OozieClientException
     * @throws JMSException
     */
private void validateDataFromFeedQueue(String feedName, List<MapMessage> messages, List<String> missingData) throws OozieClientException, JMSException {
    //just verify that each element in queue is same as deleted data!
    List<String> workflowIds = OozieUtil.getWorkflowJobs(clusterOC, OozieUtil.getBundles(clusterOC, feedName, EntityType.FEED).get(0));
    //create queue data folderList:
    List<String> deletedFolders = new ArrayList<>();
    for (MapMessage message : messages) {
        if (message != null) {
            Assert.assertEquals(message.getString("entityName"), feedName);
            String[] splitData = message.getString("feedInstancePaths").split(TEST_FOLDERS);
            deletedFolders.add(splitData[splitData.length - 1]);
            Assert.assertEquals(message.getString("operation"), "DELETE");
            Assert.assertEquals(message.getString("workflowId"), workflowIds.get(0));
            //verify other data also
            Assert.assertEquals(message.getJMSDestination().toString(), "topic://FALCON." + feedName);
            Assert.assertEquals(message.getString("status"), "SUCCEEDED");
        }
    }
    Assert.assertEquals(deletedFolders.size(), missingData.size(), "Output size is different than expected!");
    Assert.assertTrue(Arrays.deepEquals(missingData.toArray(new String[missingData.size()]), deletedFolders.toArray(new String[deletedFolders.size()])), "The missing data and message for delete operation don't correspond");
}

48. TestJMSSpringOutputAdapter#testOutputAdapter()

Project: esper
File: TestJMSSpringOutputAdapter.java
public void testOutputAdapter() throws Exception {
    Configuration config = new Configuration();
    config.getEngineDefaults().getThreading().setInternalTimerEnabled(false);
    // define output type
    Map<String, Object> typeProps = new HashMap<String, Object>();
    typeProps.put("prop1", String.class);
    typeProps.put("prop2", String.class);
    config.addEventType("MyOutputStream", typeProps);
    // define loader
    Properties props = new Properties();
    props.put(SpringContext.CLASSPATH_CONTEXT, "regression/jms_regression_output_spring.xml");
    config.addPluginLoader("MyLoader", SpringContextLoader.class.getName(), props);
    EPServiceProvider service = EPServiceProviderManager.getProvider(this.getClass().getName() + "_testOutputAdapter", config);
    service.getEPAdministrator().createEPL("insert into MyOutputStream " + "select theString as prop1, '>' || theString || '<' as prop2 from " + SupportSerializableBean.class.getName());
    service.getEPRuntime().sendEvent(new SupportSerializableBean("x1"));
    Message result = jmsReceiver.receiveMessage();
    assertNotNull(result);
    MapMessage mapMsg = (MapMessage) result;
    assertEquals("x1", mapMsg.getObject("prop1"));
    assertEquals(">x1<", mapMsg.getObject("prop2"));
    service.getEPRuntime().sendEvent(new SupportSerializableBean("x2"));
    result = jmsReceiver.receiveMessage();
    assertNotNull(result);
    mapMsg = (MapMessage) result;
    assertEquals("x2", mapMsg.getObject("prop1"));
    assertEquals(">x2<", mapMsg.getObject("prop2"));
}

49. GeneralInteropTest#testReceivingFromCore()

Project: activemq-artemis
File: GeneralInteropTest.java
@Test
public void testReceivingFromCore() throws Exception {
    final String text = "HelloWorld";
    //text messages
    sendTextMessageUsingCoreJms(queueName, text);
    connection.start();
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    ActiveMQDestination destination = createDestination(session, ActiveMQDestination.QUEUE_TYPE);
    System.out.println("destination: " + destination);
    final ActiveMQMessageConsumer consumer = (ActiveMQMessageConsumer) session.createConsumer(destination);
    TextMessage textMessage = (TextMessage) consumer.receive(5000);
    assertEquals(text, textMessage.getText());
    assertEquals(destination, textMessage.getJMSDestination());
    //map messages
    sendMapMessageUsingCoreJms(queueName);
    MapMessage mapMessage = (MapMessage) consumer.receive(5000);
    assertEquals(destination, mapMessage.getJMSDestination());
    assertTrue(mapMessage.getBoolean("aboolean"));
    assertEquals((byte) 4, mapMessage.getByte("abyte"));
    byte[] bytes = mapMessage.getBytes("abytes");
    assertEquals(2, bytes.length);
    assertEquals((byte) 4, bytes[0]);
    assertEquals((byte) 5, bytes[1]);
    assertEquals('a', mapMessage.getChar("achar"));
    Double doubleVal = mapMessage.getDouble("adouble");
    assertTrue(doubleVal.equals(Double.valueOf(4.4)));
    Float floatVal = mapMessage.getFloat("afloat");
    assertTrue(floatVal.equals(Float.valueOf(4.5F)));
    assertEquals(40, mapMessage.getInt("aint"));
    assertEquals(80L, mapMessage.getLong("along"));
    assertEquals(65, mapMessage.getShort("ashort"));
    assertEquals("hello", mapMessage.getString("astring"));
    //object message
    SimpleSerializable obj = new SimpleSerializable();
    sendObjectMessageUsingCoreJms(queueName, obj);
    ObjectMessage objectMessage = (ObjectMessage) consumer.receive(5000);
    SimpleSerializable data = (SimpleSerializable) objectMessage.getObject();
    assertEquals(obj.objName, data.objName);
    assertEquals(obj.intVal, data.intVal);
    assertEquals(obj.longVal, data.longVal);
    //stream messages
    sendStreamMessageUsingCoreJms(queueName);
    StreamMessage streamMessage = (StreamMessage) consumer.receive(5000);
    assertEquals(destination, streamMessage.getJMSDestination());
    assertTrue(streamMessage.readBoolean());
    assertEquals((byte) 2, streamMessage.readByte());
    byte[] streamBytes = new byte[2];
    streamMessage.readBytes(streamBytes);
    assertEquals(6, streamBytes[0]);
    assertEquals(7, streamBytes[1]);
    assertEquals('b', streamMessage.readChar());
    Double streamDouble = streamMessage.readDouble();
    assertTrue(streamDouble.equals(Double.valueOf(6.5)));
    Float streamFloat = streamMessage.readFloat();
    assertTrue(streamFloat.equals(Float.valueOf(93.9F)));
    assertEquals(7657, streamMessage.readInt());
    assertEquals(239999L, streamMessage.readLong());
    assertEquals((short) 34222, streamMessage.readShort());
    assertEquals("hello streammessage", streamMessage.readString());
    //bytes messages
    final byte[] bytesData = text.getBytes(StandardCharsets.UTF_8);
    sendBytesMessageUsingCoreJms(queueName, bytesData);
    BytesMessage bytesMessage = (BytesMessage) consumer.receive(5000);
    byte[] rawBytes = new byte[bytesData.length];
    bytesMessage.readBytes(rawBytes);
    for (int i = 0; i < bytesData.length; i++) {
        assertEquals("failed at " + i, bytesData[i], rawBytes[i]);
    }
    assertTrue(bytesMessage.readBoolean());
    assertEquals(99999L, bytesMessage.readLong());
    assertEquals('h', bytesMessage.readChar());
    assertEquals(987, bytesMessage.readInt());
    assertEquals((short) 1099, bytesMessage.readShort());
    assertEquals("hellobytes", bytesMessage.readUTF());
    //generic message
    sendMessageUsingCoreJms(queueName);
    javax.jms.Message genericMessage = consumer.receive(5000);
    assertEquals(destination, genericMessage.getJMSDestination());
    String value = genericMessage.getStringProperty("stringProperty");
    assertEquals("HelloMessage", value);
    assertFalse(genericMessage.getBooleanProperty("booleanProperty"));
    assertEquals(99999L, genericMessage.getLongProperty("longProperty"));
    assertEquals(979, genericMessage.getIntProperty("intProperty"));
    assertEquals((short) 1099, genericMessage.getShortProperty("shortProperty"));
    assertEquals("HelloMessage", genericMessage.getStringProperty("stringProperty"));
}

50. CompressedInteropTest#receiveMapMessageUsingCore()

Project: activemq-artemis
File: CompressedInteropTest.java
private void receiveMapMessageUsingCore() throws Exception {
    MapMessage mapMessage = (MapMessage) receiveMessageUsingCore();
    boolean booleanVal = mapMessage.getBoolean("boolean-type");
    assertTrue(booleanVal);
    byte byteVal = mapMessage.getByte("byte-type");
    assertEquals((byte) 10, byteVal);
    byte[] bytesVal = mapMessage.getBytes("bytes-type");
    byte[] originVal = TEXT.getBytes();
    assertEquals(originVal.length, bytesVal.length);
    for (int i = 0; i < bytesVal.length; i++) {
        assertTrue(bytesVal[i] == originVal[i]);
    }
    char charVal = mapMessage.getChar("char-type");
    assertEquals('A', charVal);
    double doubleVal = mapMessage.getDouble("double-type");
    assertEquals(55.3D, doubleVal, 0.1D);
    float floatVal = mapMessage.getFloat("float-type");
    assertEquals(79.1F, floatVal, 0.1F);
    int intVal = mapMessage.getInt("int-type");
    assertEquals(37, intVal);
    long longVal = mapMessage.getLong("long-type");
    assertEquals(56652L, longVal);
    Object objectVal = mapMessage.getObject("object-type");
    Object origVal = new String("VVVV");
    assertTrue(objectVal.equals(origVal));
    short shortVal = mapMessage.getShort("short-type");
    assertEquals((short) 333, shortVal);
    String strVal = mapMessage.getString("string-type");
    assertEquals(TEXT, strVal);
}

51. ReplicationWithDivertTest#createLargeMessage()

Project: activemq-artemis
File: ReplicationWithDivertTest.java
private MapMessage createLargeMessage() throws JMSException {
    MapMessage message = session.createMapMessage();
    for (int i = 0; i < 10; i++) {
        message.setBytes("test" + i, new byte[200 * 1024]);
    }
    return message;
}

52. RaceOnSyncLargeMessageOverReplicationTest#createLargeMessage()

Project: activemq-artemis
File: RaceOnSyncLargeMessageOverReplicationTest.java
private MapMessage createLargeMessage() throws JMSException {
    MapMessage message = session.createMapMessage();
    for (int i = 0; i < 10; i++) {
        message.setBytes("test" + i, new byte[1024 * 1024]);
    }
    return message;
}

53. RaceOnSyncLargeMessageOverReplication2Test#createLargeMessage()

Project: activemq-artemis
File: RaceOnSyncLargeMessageOverReplication2Test.java
private MapMessage createLargeMessage() throws JMSException {
    MapMessage message = session.createMapMessage();
    for (int i = 0; i < 10; i++) {
        message.setBytes("test" + i, new byte[1024 * 1024]);
    }
    return message;
}

54. LargeMessageOverReplicationTest#createLargeMessage()

Project: activemq-artemis
File: LargeMessageOverReplicationTest.java
private MapMessage createLargeMessage() throws JMSException {
    MapMessage message = session.createMapMessage();
    for (int i = 0; i < 10; i++) {
        message.setBytes("test" + i, new byte[1024 * 1024]);
    }
    return message;
}

55. NestedMapMessageTest#assertMessageValid()

Project: activemq-artemis
File: NestedMapMessageTest.java
@Override
@SuppressWarnings("rawtypes")
protected void assertMessageValid(int index, Message message) throws JMSException {
    assertTrue("Should be a MapMessage: " + message, message instanceof MapMessage);
    MapMessage mapMessage = (MapMessage) message;
    Object value = mapMessage.getObject("textField");
    assertEquals("textField", data[index], value);
    Map map = (Map) mapMessage.getObject("mapField");
    assertNotNull(map);
    assertEquals("mapField.a", "foo", map.get("a"));
    assertEquals("mapField.b", Integer.valueOf(23), map.get("b"));
    assertEquals("mapField.c", Long.valueOf(45), map.get("c"));
    value = map.get("d");
    assertTrue("mapField.d should be a Map", value instanceof Map);
    map = (Map) value;
    assertEquals("mapField.d.x", "abc", map.get("x"));
    value = map.get("y");
    assertTrue("mapField.d.y is a List", value instanceof List);
    List list = (List) value;
    LOG.debug("mapField.d.y: " + list);
    assertEquals("listField.size", 3, list.size());
    LOG.debug("Found map: " + map);
    list = (List) mapMessage.getObject("listField");
    LOG.debug("listField: " + list);
    assertEquals("listField.size", 3, list.size());
    assertEquals("listField[0]", "a", list.get(0));
    assertEquals("listField[1]", "b", list.get(1));
    assertEquals("listField[2]", "c", list.get(2));
}

56. BrokerStatisticsPluginTest#testSubscriptionStats()

Project: activemq-artemis
File: BrokerStatisticsPluginTest.java
@SuppressWarnings("unused")
public void testSubscriptionStats() throws Exception {
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    Queue replyTo = session.createTemporaryQueue();
    MessageConsumer consumer = session.createConsumer(replyTo);
    Queue testQueue = session.createQueue("Test.Queue");
    MessageConsumer testConsumer = session.createConsumer(testQueue);
    MessageProducer producer = session.createProducer(null);
    Queue query = session.createQueue(StatisticsBroker.STATS_SUBSCRIPTION_PREFIX);
    Message msg = session.createMessage();
    producer.send(testQueue, msg);
    msg.setJMSReplyTo(replyTo);
    producer.send(query, msg);
    MapMessage reply = (MapMessage) consumer.receive(10 * 1000);
    assertNotNull(reply);
    assertTrue(reply.getMapNames().hasMoreElements());
    assertTrue(reply.getJMSTimestamp() > 0);
    assertEquals(Message.DEFAULT_PRIORITY, reply.getJMSPriority());
/*for (Enumeration e = reply.getMapNames();e.hasMoreElements();) {
            String name = e.nextElement().toString();
            System.err.println(name+"="+reply.getObject(name));
        }*/
}

57. BrokerStatisticsPluginTest#testBrokerStatsReset()

Project: activemq-artemis
File: BrokerStatisticsPluginTest.java
public void testBrokerStatsReset() throws Exception {
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    Queue replyTo = session.createTemporaryQueue();
    MessageConsumer consumer = session.createConsumer(replyTo);
    Queue testQueue = session.createQueue("Test.Queue");
    Queue query = session.createQueue(StatisticsBroker.STATS_BROKER_PREFIX);
    MessageProducer producer = session.createProducer(null);
    producer.send(testQueue, session.createMessage());
    Message msg = session.createMessage();
    msg.setJMSReplyTo(replyTo);
    producer.send(query, msg);
    MapMessage reply = (MapMessage) consumer.receive(10 * 1000);
    assertNotNull(reply);
    assertTrue(reply.getMapNames().hasMoreElements());
    assertTrue(reply.getLong("enqueueCount") >= 1);
    msg = session.createMessage();
    msg.setBooleanProperty(StatisticsBroker.STATS_BROKER_RESET_HEADER, true);
    msg.setJMSReplyTo(replyTo);
    producer.send(query, msg);
    reply = (MapMessage) consumer.receive(10 * 1000);
    assertNotNull(reply);
    assertTrue(reply.getMapNames().hasMoreElements());
    assertEquals(0, reply.getLong("enqueueCount"));
    assertTrue(reply.getJMSTimestamp() > 0);
    assertEquals(Message.DEFAULT_PRIORITY, reply.getJMSPriority());
}

58. ActiveMQJMSProducer#send()

Project: activemq-artemis
File: ActiveMQJMSProducer.java
@Override
public JMSProducer send(Destination destination, Map<String, Object> body) {
    MapMessage message = context.createMapMessage();
    if (body != null) {
        try {
            for (Entry<String, Object> entry : body.entrySet()) {
                final String name = entry.getKey();
                final Object v = entry.getValue();
                if (v instanceof String) {
                    message.setString(name, (String) v);
                } else if (v instanceof Long) {
                    message.setLong(name, (Long) v);
                } else if (v instanceof Double) {
                    message.setDouble(name, (Double) v);
                } else if (v instanceof Integer) {
                    message.setInt(name, (Integer) v);
                } else if (v instanceof Character) {
                    message.setChar(name, (Character) v);
                } else if (v instanceof Short) {
                    message.setShort(name, (Short) v);
                } else if (v instanceof Boolean) {
                    message.setBoolean(name, (Boolean) v);
                } else if (v instanceof Float) {
                    message.setFloat(name, (Float) v);
                } else if (v instanceof Byte) {
                    message.setByte(name, (Byte) v);
                } else if (v instanceof byte[]) {
                    byte[] array = (byte[]) v;
                    message.setBytes(name, array, 0, array.length);
                } else {
                    message.setObject(name, v);
                }
            }
        } catch (JMSException e) {
            throw new MessageFormatRuntimeException(e.getMessage());
        }
    }
    send(destination, message);
    return this;
}