View Javadoc

1   /*
2    * $Id: TcpSocketKeyTestCase.java 20385 2010-11-29 20:25:26Z dfeist $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.transport.tcp;
12  
13  import org.mule.api.MuleException;
14  import org.mule.api.endpoint.ImmutableEndpoint;
15  import org.mule.tck.DynamicPortTestCase;
16  
17  public class TcpSocketKeyTestCase extends DynamicPortTestCase
18  {
19  
20      public void testHashAndEquals() throws MuleException
21      {
22          ImmutableEndpoint endpoint1in =
23                  muleContext.getEndpointFactory().getInboundEndpoint("globalEndpoint1");
24          TcpSocketKey key1in = new TcpSocketKey(endpoint1in);
25          ImmutableEndpoint endpoint1out =
26                  muleContext.getEndpointFactory().getOutboundEndpoint("globalEndpoint1");
27          TcpSocketKey key1out = new TcpSocketKey(endpoint1out);
28          ImmutableEndpoint endpoint2in =
29                  muleContext.getEndpointFactory().getInboundEndpoint("globalEndpoint2");
30          TcpSocketKey key2in = new TcpSocketKey(endpoint2in);
31  
32          assertEquals(key1in, key1in);
33          assertEquals(key1in, key1out);
34          assertNotSame(key1in, key2in);
35          assertEquals(key1in.hashCode(), key1in.hashCode());
36          assertEquals(key1in.hashCode(), key1out.hashCode());
37          assertFalse(key1in.hashCode() == key2in.hashCode());
38      }
39  
40      protected String getConfigResources()
41      {
42          return "tcp-socket-key-test.xml";
43      }
44  
45      @Override
46      protected int getNumPortsToFind()
47      {
48          return 2;
49      }
50  
51  }