TransportChannelProviderTest xref

    1   /***
    2    *
    3    * Copyright 2004 Protique Ltd
    4    *
    5    * Licensed under the Apache License, Version 2.0 (the "License");
    6    * you may not use this file except in compliance with the License.
    7    * You may obtain a copy of the License at
    8    *
    9    * http://www.apache.org/licenses/LICENSE-2.0
    10   *
    11   * Unless required by applicable law or agreed to in writing, software
    12   * distributed under the License is distributed on an "AS IS" BASIS,
    13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14   * See the License for the specific language governing permissions and
    15   * limitations under the License.
    16   *
    17   **/
    18  package org.codehaus.activemq.transport;
    19
    20  import junit.framework.TestCase;
    21  import org.codehaus.activemq.message.DefaultWireFormat;
    22  import org.codehaus.activemq.transport.vm.VmTransportChannel;
    23
    24  import javax.jms.JMSException;
    25  import java.net.URI;
    26  import java.net.URISyntaxException;
    27
    28  /***
    29   * @version $Revision: 1.1 $
    30   */
    31  public class TransportChannelProviderTest extends TestCase {
    32      public void testVmChannelWithProperties() throws Exception {
    33          TransportChannel channel = createChannel("vm://localhost?asyncSend=true&sendCapacity=100&receiveCapacity=20");
    34          assertTrue(channel instanceof VmTransportChannel);
    35
    36          VmTransportChannel vmChannel = (VmTransportChannel) channel;
    37          assertEquals("sendCapacity", 100, vmChannel.getSendCapacity());
    38          assertEquals("receiveCapacity", 20, vmChannel.getReceiveCapacity());
    39          assertEquals("asyncSend", true, vmChannel.isAsyncSend());
    40          vmChannel.start();
    41          assertTrue("has send channel", vmChannel.getSendChannel() != null);
    42          assertTrue("has receive channel", vmChannel.getReceiveChannel() != null);
    43          vmChannel.stop();
    44
    45          vmChannel = (VmTransportChannel) createChannel("vm://localhost?receiveCapacity=20");
    46          vmChannel.start();
    47          assertTrue("has no send channel", vmChannel.getSendChannel() == null);
    48          assertTrue("has receive channel", vmChannel.getReceiveChannel() == null);
    49          vmChannel.stop();
    50      }
    51
    52      protected TransportChannel createChannel(String uri) throws JMSException, URISyntaxException {
    53          return TransportChannelProvider.create(new DefaultWireFormat(), new URI(uri));
    54      }
    55  }