mil.dod.th.ose.gui.webapp/test/mil/dod/th/ose/gui/webapp/channel/TestChannelGuiDialogHelper.java
@Test
    public void testValidateSocketDoesNotExist()
    {
        UIComponent component = mock(UIComponent.class);
        
        UIInput hostName = mock(UIInput.class);
        UIInput port = mock(UIInput.class);
        when(hostName.getId()).thenReturn("hostName");
        when(hostName.getLocalValue()).thenReturn("localhost");
        
        when(port.getId()).thenReturn("hostPort");
        when(port.getLocalValue()).thenReturn(4000);
        
        when(component.findComponent("hostName")).thenReturn(hostName);
        when(component.findComponent("hostPort")).thenReturn(port);
        
        ComponentSystemEvent event = mock(ComponentSystemEvent.class);
        when(event.getComponent()).thenReturn(component);
        
        when(m_RemoteChannelLookup.checkChannelSocketExists("localhost", 4000)).thenReturn(false);
        m_SUT.validateSocketDoesNotExist(event);
        
        verify(m_GrowlUtil, times(0)).createLocalFacesMessage(eq(FacesMessage.SEVERITY_WARN), 
                eq("Socket Exists"), Mockito.anyString());
        verify(m_FacesUtil, times(0)).getFacesContext();
        verify(m_FacesContext, times(0)).renderResponse();
        
        when(m_RemoteChannelLookup.checkChannelSocketExists("localhost", 4000)).thenReturn(true);
        m_SUT.validateSocketDoesNotExist(event);
        
        verify(m_GrowlUtil, times(1)).createLocalFacesMessage(eq(FacesMessage.SEVERITY_WARN), eq("Socket Exists"), 
                eq("A socket with hostname localhost and port 4000 already exists."));
        verify(m_FacesUtil, times(1)).getFacesContext();
        verify(m_FacesContext, times(1)).renderResponse();
    }
/**
     * Verify that a duplicate socket can be found and indicated.
     */
Verify that a duplicate socket can be found and indicated.
Verify that a duplicate socket can be found and indicated .
@Test
    public void testValidateSocketDoesNotExist()
    {
        UIComponent component = mock(UIComponent.class);
        UIInput hostName = mock(UIInput.class);
        UIInput port = mock(UIInput.class);
        when(hostName.getId()).thenReturn("hostName");
        when(hostName.getLocalValue()).thenReturn("localhost");
        when(port.getId()).thenReturn("hostPort");
        when(port.getLocalValue()).thenReturn(4000);
        when(component.findComponent("hostName")).thenReturn(hostName);
        when(component.findComponent("hostPort")).thenReturn(port);
        ComponentSystemEvent event = mock(ComponentSystemEvent.class);
        when(event.getComponent()).thenReturn(component);
        when(m_RemoteChannelLookup.checkChannelSocketExists("localhost", 4000)).thenReturn(false);
        m_SUT.validateSocketDoesNotExist(event);
        verify(m_GrowlUtil, times(0)).createLocalFacesMessage(eq(FacesMessage.SEVERITY_WARN), 
                eq("Socket Exists"), Mockito.anyString());
        verify(m_FacesUtil, times(0)).getFacesContext();
        verify(m_FacesContext, times(0)).renderResponse();
        when(m_RemoteChannelLookup.checkChannelSocketExists("localhost", 4000)).thenReturn(true);
        m_SUT.validateSocketDoesNotExist(event);
        verify(m_GrowlUtil, times(1)).createLocalFacesMessage(eq(FacesMessage.SEVERITY_WARN), eq("Socket Exists"), 
                eq("A socket with hostname localhost and port 4000 already exists."));
        verify(m_FacesUtil, times(1)).getFacesContext();
        verify(m_FacesContext, times(1)).renderResponse();
    }
@ Test public void testValidateSocketDoesNotExist ( ) { UIComponent component = mock ( UIComponent . class ) ; UIInput hostName = mock ( UIInput . class ) ; UIInput port = mock ( UIInput . class ) ; when ( hostName . getId ( ) ) . thenReturn ( "hostName" ) ; when ( hostName . getLocalValue ( ) ) . thenReturn ( "localhost" ) ; when ( port . getId ( ) ) . thenReturn ( "hostPort" ) ; when ( port . getLocalValue ( ) ) . thenReturn ( 4000 ) ; when ( component . findComponent ( "hostName" ) ) . thenReturn ( hostName ) ; when ( component . findComponent ( "hostPort" ) ) . thenReturn ( port ) ; ComponentSystemEvent event = mock ( ComponentSystemEvent . class ) ; when ( event . getComponent ( ) ) . thenReturn ( component ) ; when ( m_RemoteChannelLookup . checkChannelSocketExists ( "localhost" , 4000 ) ) . thenReturn ( false ) ; m_SUT . validateSocketDoesNotExist ( event ) ; verify ( m_GrowlUtil , times ( 0 ) ) . createLocalFacesMessage ( eq ( FacesMessage . SEVERITY_WARN ) , eq ( "Socket Exists" ) , Mockito . anyString ( ) ) ; verify ( m_FacesUtil , times ( 0 ) ) . getFacesContext ( ) ; verify ( m_FacesContext , times ( 0 ) ) . renderResponse ( ) ; when ( m_RemoteChannelLookup . checkChannelSocketExists ( "localhost" , 4000 ) ) . thenReturn ( true ) ; m_SUT . validateSocketDoesNotExist ( event ) ; verify ( m_GrowlUtil , times ( 1 ) ) . createLocalFacesMessage ( eq ( FacesMessage . SEVERITY_WARN ) , eq ( "Socket Exists" ) , eq ( "A socket with hostname localhost and port 4000 already exists." ) ) ; verify ( m_FacesUtil , times ( 1 ) ) . getFacesContext ( ) ; verify ( m_FacesContext , times ( 1 ) ) . renderResponse ( ) ; }
Verify that a duplicate socket can be found and indicated.
Verify that a duplicate socket can be found and indicated .