mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/TestServerSocketChannel.java
@Test
    public void testMatches()
    {
        // mock some different property values
        Socket socket1 = mock(Socket.class);
        SocketAddress socketAddress = mock(SocketAddress.class);
        when(socketAddress.toString()).thenReturn(REMOTE_SOCKET_ADDR);
        when(socket1.getRemoteSocketAddress()).thenReturn(socketAddress);
        Socket socket2 = mock(Socket.class);
        
        // setup a channel
        Map<String, Object> actualProps = new HashMap<String, Object>();
        actualProps.put(ServerSocketChannel.SOCKET_PROP_KEY, socket1);
        actualProps.put(ComponentConstants.COMPONENT_ID, 23);
        actualProps.put(ComponentConstants.COMPONENT_NAME, AbstractSocketChannel.class.getName());
        actualProps.put("some random value that might be there", "blah");
        m_SUT.activate(actualProps);
        
        // different props should not match
        Map<String, Object> props = new HashMap<String, Object>();
        props.put(ServerSocketChannel.SOCKET_PROP_KEY, socket2);
        assertThat(m_SUT.matches(props), is(false));
        
        // same props for transport and address should match, should ignore default props of a component
        props.put(ServerSocketChannel.SOCKET_PROP_KEY, socket1);
        assertThat(m_SUT.matches(props), is(true));
    }
/**
     * Verify the matches method returns true if the socket property matches
     */
Verify the matches method returns true if the socket property matches
Verify the matches method returns true if the socket property matches
@Test
    public void testMatches()
    {
        Socket socket1 = mock(Socket.class);
        SocketAddress socketAddress = mock(SocketAddress.class);
        when(socketAddress.toString()).thenReturn(REMOTE_SOCKET_ADDR);
        when(socket1.getRemoteSocketAddress()).thenReturn(socketAddress);
        Socket socket2 = mock(Socket.class);
        Map<String, Object> actualProps = new HashMap<String, Object>();
        actualProps.put(ServerSocketChannel.SOCKET_PROP_KEY, socket1);
        actualProps.put(ComponentConstants.COMPONENT_ID, 23);
        actualProps.put(ComponentConstants.COMPONENT_NAME, AbstractSocketChannel.class.getName());
        actualProps.put("some random value that might be there", "blah");
        m_SUT.activate(actualProps);
        Map<String, Object> props = new HashMap<String, Object>();
        props.put(ServerSocketChannel.SOCKET_PROP_KEY, socket2);
        assertThat(m_SUT.matches(props), is(false));
        props.put(ServerSocketChannel.SOCKET_PROP_KEY, socket1);
        assertThat(m_SUT.matches(props), is(true));
    }
@ Test public void testMatches ( ) { Socket socket1 = mock ( Socket . class ) ; SocketAddress socketAddress = mock ( SocketAddress . class ) ; when ( socketAddress . toString ( ) ) . thenReturn ( REMOTE_SOCKET_ADDR ) ; when ( socket1 . getRemoteSocketAddress ( ) ) . thenReturn ( socketAddress ) ; Socket socket2 = mock ( Socket . class ) ; Map < String , Object > actualProps = new HashMap < String , Object > ( ) ; actualProps . put ( ServerSocketChannel . SOCKET_PROP_KEY , socket1 ) ; actualProps . put ( ComponentConstants . COMPONENT_ID , 23 ) ; actualProps . put ( ComponentConstants . COMPONENT_NAME , AbstractSocketChannel . class . getName ( ) ) ; actualProps . put ( "some random value that might be there" , "blah" ) ; m_SUT . activate ( actualProps ) ; Map < String , Object > props = new HashMap < String , Object > ( ) ; props . put ( ServerSocketChannel . SOCKET_PROP_KEY , socket2 ) ; assertThat ( m_SUT . matches ( props ) , is ( false ) ) ; props . put ( ServerSocketChannel . SOCKET_PROP_KEY , socket1 ) ; assertThat ( m_SUT . matches ( props ) , is ( true ) ) ; }
Verify the matches method returns true if the socket property matches
Verify the matches method returns true if the socket property matches
// mock some different property values // setup a channel // different props should not match // same props for transport and address should match, should ignore default props of a component