|
ActiveMQ example source code file (JMSInputStreamTest.java)
The ActiveMQ JMSInputStreamTest.java source code/** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.activemq.streams; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.io.OutputStream; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; import javax.jms.Destination; import javax.jms.JMSException; import javax.jms.Message; import junit.framework.Test; import org.apache.activemq.ActiveMQConnection; import org.apache.activemq.ActiveMQInputStream; import org.apache.activemq.JmsTestSupport; import org.apache.activemq.command.ActiveMQQueue; import org.apache.activemq.command.ActiveMQTopic; /** * JMSInputStreamTest */ public class JMSInputStreamTest extends JmsTestSupport { public Destination destination; protected DataOutputStream out; protected DataInputStream in; private ActiveMQConnection connection2; private ActiveMQInputStream amqIn; public static Test suite() { return suite(JMSInputStreamTest.class); } public static void main(String[] args) { junit.textui.TestRunner.run(suite()); } public void initCombos() { addCombinationValues("destination", new Object[] {new ActiveMQQueue("TEST.QUEUE"), new ActiveMQTopic("TEST.TOPIC")}); } /* * @see TestCase#setUp() */ protected void setUp() throws Exception { super.setAutoFail(true); super.setUp(); } /** * Setup connection and streams * * @param props * @throws JMSException */ private void setUpConnection(Map<String, Object> props, long timeout) throws JMSException { connection2 = (ActiveMQConnection)factory.createConnection(userName, password); connections.add(connection2); OutputStream amqOut; if (props != null) { amqOut = connection.createOutputStream(destination, props, Message.DEFAULT_DELIVERY_MODE, Message.DEFAULT_PRIORITY, Message.DEFAULT_TIME_TO_LIVE); } else { amqOut = connection.createOutputStream(destination); } out = new DataOutputStream(amqOut); if (timeout == -1) { amqIn = (ActiveMQInputStream) connection2.createInputStream(destination); } else { amqIn = (ActiveMQInputStream) connection2.createInputStream(destination, null, false, timeout); } in = new DataInputStream(amqIn); } /* * @see TestCase#tearDown() */ protected void tearDown() throws Exception { super.tearDown(); } /** * Test for AMQ-3010 */ public void testInputStreamTimeout() throws Exception { long timeout = 500; setUpConnection(null, timeout); try { in.read(); fail(); } catch (ActiveMQInputStream.ReadTimeoutException e) { // timeout reached, everything ok } in.close(); } // Test for AMQ-2988 public void testStreamsWithProperties() throws Exception { String name1 = "PROPERTY_1"; String name2 = "PROPERTY_2"; String value1 = "VALUE_1"; String value2 = "VALUE_2"; Map<String,Object> jmsProperties = new HashMap Other ActiveMQ examples (source code examples)Here is a short list of links related to this ActiveMQ JMSInputStreamTest.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.