1   /*
2    * $Id: TcpSocketKeyTestCase.java 10489 2008-01-23 17:53:38Z dfeist $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.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.FunctionalTestCase;
16  import org.mule.transport.tcp.TcpSocketKey;
17  
18  public class TcpSocketKeyTestCase extends FunctionalTestCase
19  {
20  
21      public void testHashAndEquals() throws MuleException
22      {
23          ImmutableEndpoint endpoint1in =
24                  muleContext.getRegistry().lookupEndpointFactory().getInboundEndpoint("globalEndpoint1");
25          TcpSocketKey key1in = new TcpSocketKey(endpoint1in);
26          ImmutableEndpoint endpoint1out =
27                  muleContext.getRegistry().lookupEndpointFactory().getOutboundEndpoint("globalEndpoint1");
28          TcpSocketKey key1out = new TcpSocketKey(endpoint1out);
29          ImmutableEndpoint endpoint2in =
30                  muleContext.getRegistry().lookupEndpointFactory().getInboundEndpoint("globalEndpoint2");
31          TcpSocketKey key2in = new TcpSocketKey(endpoint2in);
32  
33          assertEquals(key1in, key1in);
34          assertEquals(key1in, key1out);
35          assertNotSame(key1in, key2in);
36          assertEquals(key1in.hashCode(), key1in.hashCode());
37          assertEquals(key1in.hashCode(), key1out.hashCode());
38          assertFalse(key1in.hashCode() == key2in.hashCode());
39      }
40  
41      protected String getConfigResources()
42      {
43          return "tcp-socket-key-test.xml";
44      }
45  
46  }