mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/TestRemoteChannelLookupImpl.java
@Test
    public void testSyncClientSocketChannelPersist()
    {
        //Mock the needed socket channels.
        SocketChannel persistedChannel = mock(SocketChannel.class);
        SocketChannel nonPersistedChannel = mock(SocketChannel.class);
        SocketChannel alwaysPersistedChannel = mock(SocketChannel.class);
        
        when(m_ClientSocketChannelInstance.getInstance()).thenReturn(persistedChannel, nonPersistedChannel, 
                alwaysPersistedChannel);
        
        stubSocketChannel(persistedChannel, "host1", 1000, false);
        stubSocketChannel(nonPersistedChannel, "host2", 1005, true);
        stubSocketChannel(alwaysPersistedChannel, "host3", 1010, false);

        //Define remote system IDs
        Integer systemId1 = 75;
        Integer systemId2 = 150;
        Integer systemId3 = 225;
        
        //Sync the socket channels
        SocketChannel returned1 = m_SUT.syncClientSocketChannel("host1", 1000, systemId1, true);
        SocketChannel returned2 = m_SUT.syncClientSocketChannel("host2", 1005, systemId2, false, true);
        SocketChannel returned3 = m_SUT.syncClientSocketChannel("host3", 1010, systemId3);
        
        //Verify that the appropriate channels are returned by the sync methods.
        assertThat(returned1, is(persistedChannel));
        assertThat(returned2, is(nonPersistedChannel));
        assertThat(returned3, is(alwaysPersistedChannel));
        
        //Verify that all channels are added to the remote lookup regardless of whether or not they should be persisted.
        assertThat((SocketChannel)m_SUT.getChannel(systemId1), is(persistedChannel));
        assertThat((SocketChannel)m_SUT.getChannel(systemId2), is(nonPersistedChannel));
        assertThat((SocketChannel)m_SUT.getChannel(systemId3), is(alwaysPersistedChannel));
        
        //Verify that only sockets channels with system ID 1 and 3 are persisted.
        verify(m_PersistentDataStore).persist(Mockito.any(Class.class), Mockito.any(UUID.class), 
                eq(systemId1.toString()), Mockito.any(byte[].class));
        verify(m_PersistentDataStore, never()).persist(Mockito.any(Class.class), Mockito.any(UUID.class), 
                eq(systemId2.toString()), Mockito.any(byte[].class));
        verify(m_PersistentDataStore).persist(Mockito.any(Class.class), Mockito.any(UUID.class), 
                eq(systemId3.toString()), Mockito.any(byte[].class));
    }
/**
     * Verify that the syncClientSocketChannel methods persist the channel when appropriate.
     */
Verify that the syncClientSocketChannel methods persist the channel when appropriate.
Verify that the syncClientSocketChannel methods persist the channel when appropriate .
@Test
    public void testSyncClientSocketChannelPersist()
    {
        SocketChannel persistedChannel = mock(SocketChannel.class);
        SocketChannel nonPersistedChannel = mock(SocketChannel.class);
        SocketChannel alwaysPersistedChannel = mock(SocketChannel.class);
        when(m_ClientSocketChannelInstance.getInstance()).thenReturn(persistedChannel, nonPersistedChannel, 
                alwaysPersistedChannel);
        stubSocketChannel(persistedChannel, "host1", 1000, false);
        stubSocketChannel(nonPersistedChannel, "host2", 1005, true);
        stubSocketChannel(alwaysPersistedChannel, "host3", 1010, false);
        Integer systemId1 = 75;
        Integer systemId2 = 150;
        Integer systemId3 = 225;
        SocketChannel returned1 = m_SUT.syncClientSocketChannel("host1", 1000, systemId1, true);
        SocketChannel returned2 = m_SUT.syncClientSocketChannel("host2", 1005, systemId2, false, true);
        SocketChannel returned3 = m_SUT.syncClientSocketChannel("host3", 1010, systemId3);
        assertThat(returned1, is(persistedChannel));
        assertThat(returned2, is(nonPersistedChannel));
        assertThat(returned3, is(alwaysPersistedChannel));
        assertThat((SocketChannel)m_SUT.getChannel(systemId1), is(persistedChannel));
        assertThat((SocketChannel)m_SUT.getChannel(systemId2), is(nonPersistedChannel));
        assertThat((SocketChannel)m_SUT.getChannel(systemId3), is(alwaysPersistedChannel));
        verify(m_PersistentDataStore).persist(Mockito.any(Class.class), Mockito.any(UUID.class), 
                eq(systemId1.toString()), Mockito.any(byte[].class));
        verify(m_PersistentDataStore, never()).persist(Mockito.any(Class.class), Mockito.any(UUID.class), 
                eq(systemId2.toString()), Mockito.any(byte[].class));
        verify(m_PersistentDataStore).persist(Mockito.any(Class.class), Mockito.any(UUID.class), 
                eq(systemId3.toString()), Mockito.any(byte[].class));
    }
@ Test public void testSyncClientSocketChannelPersist ( ) { SocketChannel persistedChannel = mock ( SocketChannel . class ) ; SocketChannel nonPersistedChannel = mock ( SocketChannel . class ) ; SocketChannel alwaysPersistedChannel = mock ( SocketChannel . class ) ; when ( m_ClientSocketChannelInstance . getInstance ( ) ) . thenReturn ( persistedChannel , nonPersistedChannel , alwaysPersistedChannel ) ; stubSocketChannel ( persistedChannel , "host1" , 1000 , false ) ; stubSocketChannel ( nonPersistedChannel , "host2" , 1005 , true ) ; stubSocketChannel ( alwaysPersistedChannel , "host3" , 1010 , false ) ; Integer systemId1 = 75 ; Integer systemId2 = 150 ; Integer systemId3 = 225 ; SocketChannel returned1 = m_SUT . syncClientSocketChannel ( "host1" , 1000 , systemId1 , true ) ; SocketChannel returned2 = m_SUT . syncClientSocketChannel ( "host2" , 1005 , systemId2 , false , true ) ; SocketChannel returned3 = m_SUT . syncClientSocketChannel ( "host3" , 1010 , systemId3 ) ; assertThat ( returned1 , is ( persistedChannel ) ) ; assertThat ( returned2 , is ( nonPersistedChannel ) ) ; assertThat ( returned3 , is ( alwaysPersistedChannel ) ) ; assertThat ( ( SocketChannel ) m_SUT . getChannel ( systemId1 ) , is ( persistedChannel ) ) ; assertThat ( ( SocketChannel ) m_SUT . getChannel ( systemId2 ) , is ( nonPersistedChannel ) ) ; assertThat ( ( SocketChannel ) m_SUT . getChannel ( systemId3 ) , is ( alwaysPersistedChannel ) ) ; verify ( m_PersistentDataStore ) . persist ( Mockito . any ( Class . class ) , Mockito . any ( UUID . class ) , eq ( systemId1 . toString ( ) ) , Mockito . any ( byte [ ] . class ) ) ; verify ( m_PersistentDataStore , never ( ) ) . persist ( Mockito . any ( Class . class ) , Mockito . any ( UUID . class ) , eq ( systemId2 . toString ( ) ) , Mockito . any ( byte [ ] . class ) ) ; verify ( m_PersistentDataStore ) . persist ( Mockito . any ( Class . class ) , Mockito . any ( UUID . class ) , eq ( systemId3 . toString ( ) ) , Mockito . any ( byte [ ] . class ) ) ; }
Verify that the syncClientSocketChannel methods persist the channel when appropriate.
Verify that the syncClientSocketChannel methods persist the channel when appropriate .
//Mock the needed socket channels. //Define remote system IDs //Sync the socket channels //Verify that the appropriate channels are returned by the sync methods. //Verify that all channels are added to the remote lookup regardless of whether or not they should be persisted. //Verify that only sockets channels with system ID 1 and 3 are persisted.