mil.dod.th.ose.gui.integration/src/mil/dod/th/ose/gui/integration/webapp/channel/TestChannelQueuedMessages.java
@Test
    public void testQueuedMessages() throws InterruptedException, ExecutionException, TimeoutException
    {
        //Navigate to the channels page.
        NavigationHelper.navigateToPage(m_Driver, NavigationButtonNameConstants.NAVBUT_PROP_CHANNELS);
        
        //Create a socket channel connecting to the gui.
        ChannelsHelper.createSocketChannel(m_Driver, ChannelsHelper.HOST_NAME, 
                ChannelsHelper.DEFAULT_GUI_CONNECTION_PORT);
        
        //Set the GUI as the active controller.
        ControllerHelper.setActiveControllerByName(m_Driver, ControllerHelper.DEFAULT_GUI_NAME);
        
        //Navigate to the system configuration page.
        NavigationHelper.navigateToPage(m_Driver, NavigationButtonNameConstants.NAVBUT_PROP_SYS_CONFIG);
        
        GeneralHelper.sleepWithText(5, "Waiting for AJAX to update with list of all web GUI bundles");
        
        BundleManagerUtil.startBundle(m_Driver, "example.ccomm.main");
        BundleManagerUtil.startBundle(m_Driver, "example.ccomm.serial");
        
        //Navigate to comms page to create a comms stack.
        NavigationHelper.navigateToPage(m_Driver, NavigationButtonNameConstants.NAVBUT_PROP_COMMS);
        
        CommsAddDialogHelper.forceAddPhysicalLink(m_Driver, "forcedPlink");
        
        //Create the comms stack needed to create a transport channel.
        CommsGeneralHelper.createStack(m_Driver, "forcedPlink", "testLink", "example.ccomms.ExampleLinkLayer", 
                "testTrans", "example.ccomms.DirectTransport");
        
        //Create the transport channel.
        ChannelsHelper.createTransportChannel(m_Driver, "testTrans", "0x00000001", "prefix:local", "prefix:remote");
        
        //Remove the controller socket channel.
        ChannelsHelper.removeSocketChannel(m_Driver, "0x0000007D", 
                ControllerHelper.DEFAULT_CONTROLLER_NAME, ChannelsHelper.HOST_NAME, "4000", false);
        //Remove the gui socket channel.
        ChannelsHelper.removeSocketChannel(m_Driver, "0x00000001", ControllerHelper.DEFAULT_GUI_NAME, 
                ChannelsHelper.HOST_NAME, "4001", false);
        
        //Expand the right side bar so that the test can access the controller mode.
        NavigationHelper.expandRightSideBarOnly(m_Driver);
        
        //Change the mode 5 times to queue up messages.
        for (int i = 0; i < 5; i++)
        {
            //Bring up the controller mode selection dialog.
            ControllerHelper.changeControllerOpMode(m_Driver, ControllerHelper.DEFAULT_GUI_NAME, 
                OperationMode.OPERATIONAL_MODE, false);
            
            //Thread sleep needed since loops tend to move too quickly in selenium.
            Thread.sleep(1000);
        }
        
        //Refresh channels page by navigating to it. Needed to updated queued message count.
        NavigationHelper.navigateToPage(m_Driver, NavigationButtonNameConstants.NAVBUT_PROP_CHANNELS);
        
        //Check the queued message count and assert that it is greater than zero.
        WebElement transChannelTable = m_Driver.findElement(By.cssSelector("tbody[id$='transTable_data']"));
        WebElement transChannel = transChannelTable.findElements(By.tagName("tr")).get(0);
        String queuedMsgCountStr = transChannel.findElements(By.tagName("td")).get(5).getText().split("\\r?\\n")[0];
        assertThat(Integer.parseInt(queuedMsgCountStr), greaterThan(0));
        
        //Clear the queued messages.
        final WebElement clearQueuedMessages = m_Driver.findElement(
                By.cssSelector("button[id$='clearTransportQueue']"));
        GrowlVerifier.verifyAndWaitToDisappear(20, clearQueuedMessages, "Channel Queue Cleared");
        
        //Refresh channels page by navigating to it. Needed to updated queued message count.
        NavigationHelper.navigateToPage(m_Driver, NavigationButtonNameConstants.NAVBUT_PROP_CHANNELS);
        NavigationHelper.collapseRightSideBarOnly(m_Driver);
        
        //Check queued message count after clearing. Should be 0.
        transChannelTable = m_Driver.findElement(By.cssSelector("tbody[id$='transTable_data']"));
        transChannel = transChannelTable.findElements(By.tagName("tr")).get(0);
        queuedMsgCountStr = transChannel.findElements(By.tagName("td")).get(5).getText().split("\\r?\\n")[0];
        assertThat(Integer.parseInt(queuedMsgCountStr), is(0));
        
        //Remove the transport channel.
        ChannelsHelper.removeTransportChannel(m_Driver, "0x00000001", ControllerHelper.DEFAULT_GUI_NAME, 
                "testTrans", "prefix:local", "prefix:remote", true);
        
        //Add back the socket channel for the gui.
        ChannelsHelper.createSocketChannel(m_Driver, ChannelsHelper.HOST_NAME, "4001");
        
        //Navigate to the comms page.
        NavigationHelper.navigateToPage(m_Driver, NavigationButtonNameConstants.NAVBUT_PROP_COMMS);
        
        //Remove the comms stack needed for the transport channel.
        CommsGeneralHelper.removeStack(m_Driver, "testTrans", "Layer Deleted");
        
        //Current issue with comms layer and stacks not being complete will cause additional growl messages to appear.
        //Sleep needed to allow growl messages to full disappear.
        Thread.sleep(7000);
        
        //Navigate to the channels page.
        NavigationHelper.navigateToPage(m_Driver, NavigationButtonNameConstants.NAVBUT_PROP_CHANNELS);
        
        //Remove the gui socket channel.
        ChannelsHelper.removeSocketChannel(m_Driver, "0x00000001", ControllerHelper.DEFAULT_GUI_NAME, 
                ChannelsHelper.HOST_NAME, "4001", true);
        
        //Add back the socket channel for the controller.
        ChannelsHelper.createSocketChannel(m_Driver, ChannelsHelper.HOST_NAME, "4000");
    }
/**
     * Test the queued messages feature of the channels page.
     * Verify that the queue message count increments and can be cleared.
     */
Test the queued messages feature of the channels page.
Verify that the queue message count increments and can be cleared.
Test the queued messages feature of the channels page . Verify that the queue message count increments and can be cleared .
@Test
    public void testQueuedMessages() throws InterruptedException, ExecutionException, TimeoutException
    {
        NavigationHelper.navigateToPage(m_Driver, NavigationButtonNameConstants.NAVBUT_PROP_CHANNELS);
        ChannelsHelper.createSocketChannel(m_Driver, ChannelsHelper.HOST_NAME, 
                ChannelsHelper.DEFAULT_GUI_CONNECTION_PORT);
        ControllerHelper.setActiveControllerByName(m_Driver, ControllerHelper.DEFAULT_GUI_NAME);
        NavigationHelper.navigateToPage(m_Driver, NavigationButtonNameConstants.NAVBUT_PROP_SYS_CONFIG);
        GeneralHelper.sleepWithText(5, "Waiting for AJAX to update with list of all web GUI bundles");
        BundleManagerUtil.startBundle(m_Driver, "example.ccomm.main");
        BundleManagerUtil.startBundle(m_Driver, "example.ccomm.serial");
        NavigationHelper.navigateToPage(m_Driver, NavigationButtonNameConstants.NAVBUT_PROP_COMMS);
        CommsAddDialogHelper.forceAddPhysicalLink(m_Driver, "forcedPlink");
        CommsGeneralHelper.createStack(m_Driver, "forcedPlink", "testLink", "example.ccomms.ExampleLinkLayer", 
                "testTrans", "example.ccomms.DirectTransport");
        ChannelsHelper.createTransportChannel(m_Driver, "testTrans", "0x00000001", "prefix:local", "prefix:remote");
        ChannelsHelper.removeSocketChannel(m_Driver, "0x0000007D", 
                ControllerHelper.DEFAULT_CONTROLLER_NAME, ChannelsHelper.HOST_NAME, "4000", false);
        ChannelsHelper.removeSocketChannel(m_Driver, "0x00000001", ControllerHelper.DEFAULT_GUI_NAME, 
                ChannelsHelper.HOST_NAME, "4001", false);
        NavigationHelper.expandRightSideBarOnly(m_Driver);
        for (int i = 0; i < 5; i++)
        {
            ControllerHelper.changeControllerOpMode(m_Driver, ControllerHelper.DEFAULT_GUI_NAME, 
                OperationMode.OPERATIONAL_MODE, false);
            Thread.sleep(1000);
        }
        NavigationHelper.navigateToPage(m_Driver, NavigationButtonNameConstants.NAVBUT_PROP_CHANNELS);
        WebElement transChannelTable = m_Driver.findElement(By.cssSelector("tbody[id$='transTable_data']"));
        WebElement transChannel = transChannelTable.findElements(By.tagName("tr")).get(0);
        String queuedMsgCountStr = transChannel.findElements(By.tagName("td")).get(5).getText().split("\\r?\\n")[0];
        assertThat(Integer.parseInt(queuedMsgCountStr), greaterThan(0));
        final WebElement clearQueuedMessages = m_Driver.findElement(
                By.cssSelector("button[id$='clearTransportQueue']"));
        GrowlVerifier.verifyAndWaitToDisappear(20, clearQueuedMessages, "Channel Queue Cleared");
        NavigationHelper.navigateToPage(m_Driver, NavigationButtonNameConstants.NAVBUT_PROP_CHANNELS);
        NavigationHelper.collapseRightSideBarOnly(m_Driver);
        transChannelTable = m_Driver.findElement(By.cssSelector("tbody[id$='transTable_data']"));
        transChannel = transChannelTable.findElements(By.tagName("tr")).get(0);
        queuedMsgCountStr = transChannel.findElements(By.tagName("td")).get(5).getText().split("\\r?\\n")[0];
        assertThat(Integer.parseInt(queuedMsgCountStr), is(0));
        ChannelsHelper.removeTransportChannel(m_Driver, "0x00000001", ControllerHelper.DEFAULT_GUI_NAME, 
                "testTrans", "prefix:local", "prefix:remote", true);
        ChannelsHelper.createSocketChannel(m_Driver, ChannelsHelper.HOST_NAME, "4001");
        NavigationHelper.navigateToPage(m_Driver, NavigationButtonNameConstants.NAVBUT_PROP_COMMS);
        CommsGeneralHelper.removeStack(m_Driver, "testTrans", "Layer Deleted");
        Thread.sleep(7000);
        NavigationHelper.navigateToPage(m_Driver, NavigationButtonNameConstants.NAVBUT_PROP_CHANNELS);
        ChannelsHelper.removeSocketChannel(m_Driver, "0x00000001", ControllerHelper.DEFAULT_GUI_NAME, 
                ChannelsHelper.HOST_NAME, "4001", true);
        ChannelsHelper.createSocketChannel(m_Driver, ChannelsHelper.HOST_NAME, "4000");
    }
@ Test public void testQueuedMessages ( ) throws InterruptedException , ExecutionException , TimeoutException { NavigationHelper . navigateToPage ( m_Driver , NavigationButtonNameConstants . NAVBUT_PROP_CHANNELS ) ; ChannelsHelper . createSocketChannel ( m_Driver , ChannelsHelper . HOST_NAME , ChannelsHelper . DEFAULT_GUI_CONNECTION_PORT ) ; ControllerHelper . setActiveControllerByName ( m_Driver , ControllerHelper . DEFAULT_GUI_NAME ) ; NavigationHelper . navigateToPage ( m_Driver , NavigationButtonNameConstants . NAVBUT_PROP_SYS_CONFIG ) ; GeneralHelper . sleepWithText ( 5 , "Waiting for AJAX to update with list of all web GUI bundles" ) ; BundleManagerUtil . startBundle ( m_Driver , "example.ccomm.main" ) ; BundleManagerUtil . startBundle ( m_Driver , "example.ccomm.serial" ) ; NavigationHelper . navigateToPage ( m_Driver , NavigationButtonNameConstants . NAVBUT_PROP_COMMS ) ; CommsAddDialogHelper . forceAddPhysicalLink ( m_Driver , "forcedPlink" ) ; CommsGeneralHelper . createStack ( m_Driver , "forcedPlink" , "testLink" , "example.ccomms.ExampleLinkLayer" , "testTrans" , "example.ccomms.DirectTransport" ) ; ChannelsHelper . createTransportChannel ( m_Driver , "testTrans" , "0x00000001" , "prefix:local" , "prefix:remote" ) ; ChannelsHelper . removeSocketChannel ( m_Driver , "0x0000007D" , ControllerHelper . DEFAULT_CONTROLLER_NAME , ChannelsHelper . HOST_NAME , "4000" , false ) ; ChannelsHelper . removeSocketChannel ( m_Driver , "0x00000001" , ControllerHelper . DEFAULT_GUI_NAME , ChannelsHelper . HOST_NAME , "4001" , false ) ; NavigationHelper . expandRightSideBarOnly ( m_Driver ) ; for ( int i = 0 ; i < 5 ; i ++ ) { ControllerHelper . changeControllerOpMode ( m_Driver , ControllerHelper . DEFAULT_GUI_NAME , OperationMode . OPERATIONAL_MODE , false ) ; Thread . sleep ( 1000 ) ; } NavigationHelper . navigateToPage ( m_Driver , NavigationButtonNameConstants . NAVBUT_PROP_CHANNELS ) ; WebElement transChannelTable = m_Driver . findElement ( By . cssSelector ( "tbody[id$='transTable_data']" ) ) ; WebElement transChannel = transChannelTable . findElements ( By . tagName ( "tr" ) ) . get ( 0 ) ; String queuedMsgCountStr = transChannel . findElements ( By . tagName ( "td" ) ) . get ( 5 ) . getText ( ) . split ( "\\r?\\n" ) [ 0 ] ; assertThat ( Integer . parseInt ( queuedMsgCountStr ) , greaterThan ( 0 ) ) ; final WebElement clearQueuedMessages = m_Driver . findElement ( By . cssSelector ( "button[id$='clearTransportQueue']" ) ) ; GrowlVerifier . verifyAndWaitToDisappear ( 20 , clearQueuedMessages , "Channel Queue Cleared" ) ; NavigationHelper . navigateToPage ( m_Driver , NavigationButtonNameConstants . NAVBUT_PROP_CHANNELS ) ; NavigationHelper . collapseRightSideBarOnly ( m_Driver ) ; transChannelTable = m_Driver . findElement ( By . cssSelector ( "tbody[id$='transTable_data']" ) ) ; transChannel = transChannelTable . findElements ( By . tagName ( "tr" ) ) . get ( 0 ) ; queuedMsgCountStr = transChannel . findElements ( By . tagName ( "td" ) ) . get ( 5 ) . getText ( ) . split ( "\\r?\\n" ) [ 0 ] ; assertThat ( Integer . parseInt ( queuedMsgCountStr ) , is ( 0 ) ) ; ChannelsHelper . removeTransportChannel ( m_Driver , "0x00000001" , ControllerHelper . DEFAULT_GUI_NAME , "testTrans" , "prefix:local" , "prefix:remote" , true ) ; ChannelsHelper . createSocketChannel ( m_Driver , ChannelsHelper . HOST_NAME , "4001" ) ; NavigationHelper . navigateToPage ( m_Driver , NavigationButtonNameConstants . NAVBUT_PROP_COMMS ) ; CommsGeneralHelper . removeStack ( m_Driver , "testTrans" , "Layer Deleted" ) ; Thread . sleep ( 7000 ) ; NavigationHelper . navigateToPage ( m_Driver , NavigationButtonNameConstants . NAVBUT_PROP_CHANNELS ) ; ChannelsHelper . removeSocketChannel ( m_Driver , "0x00000001" , ControllerHelper . DEFAULT_GUI_NAME , ChannelsHelper . HOST_NAME , "4001" , true ) ; ChannelsHelper . createSocketChannel ( m_Driver , ChannelsHelper . HOST_NAME , "4000" ) ; }
Test the queued messages feature of the channels page.
Test the queued messages feature of the channels page .
//Navigate to the channels page. //Create a socket channel connecting to the gui. //Set the GUI as the active controller. //Navigate to the system configuration page. //Navigate to comms page to create a comms stack. //Create the comms stack needed to create a transport channel. //Create the transport channel. //Remove the controller socket channel. //Remove the gui socket channel. //Expand the right side bar so that the test can access the controller mode. //Change the mode 5 times to queue up messages. //Bring up the controller mode selection dialog. //Thread sleep needed since loops tend to move too quickly in selenium. //Refresh channels page by navigating to it. Needed to updated queued message count. //Check the queued message count and assert that it is greater than zero. //Clear the queued messages. //Refresh channels page by navigating to it. Needed to updated queued message count. //Check queued message count after clearing. Should be 0. //Remove the transport channel. //Add back the socket channel for the gui. //Navigate to the comms page. //Remove the comms stack needed for the transport channel. //Current issue with comms layer and stacks not being complete will cause additional growl messages to appear. //Sleep needed to allow growl messages to full disappear. //Navigate to the channels page. //Remove the gui socket channel. //Add back the socket channel for the controller.