edu.udayton.udri.asset.axis/test/edu/udayton/udri/asset/axis/TestAxisAsset.java
@Test
    public void testGetPanTilt() throws AssetException, IOException, IllegalStateException, InterruptedException
    {
        final char[] responseBytes = 
                new char[]{'p', 'a', 'n', '=', '4', '.', '0', '\n', 't', 'i', 'l', 't', '=', '8','.', '1'};
        
        InputStream stream = new InputStream()
        {
            private int m_Counter;
            @Override
            public int read() throws IOException
            {
                int toReturn = -1;
                if (m_Counter < responseBytes.length)
                {
                    toReturn = responseBytes[m_Counter];
                    m_Counter++;
                }
                return toReturn;
            }
        };
        
        when(m_UrlService.constructUrlConnection(m_UrlString)).thenReturn(m_Connection);
        when(m_Connection.getInputStream()).thenReturn(stream);
        
        //mock behavior
        when(m_CommandProcessor.processGetPanTilt(m_Ip)).thenReturn(m_UrlString);
        
        //process the command
        GetPanTiltResponse response = (GetPanTiltResponse)m_SUT.onExecuteCommand(new GetPanTiltCommand());

        assertThat(response.getPanTilt().getAzimuth().getValue(), closeTo(4.0, 0.00001));
        assertThat(response.getPanTilt().getElevation().getValue(), closeTo(8.1, 0.00001));
    }
/**
     * Verify get pan/tilt command interactions.
     */
Verify get pan/tilt command interactions.
Verify get pan / tilt command interactions .
@Test
    public void testGetPanTilt() throws AssetException, IOException, IllegalStateException, InterruptedException
    {
        final char[] responseBytes = 
                new char[]{'p', 'a', 'n', '=', '4', '.', '0', '\n', 't', 'i', 'l', 't', '=', '8','.', '1'};
        InputStream stream = new InputStream()
        {
            private int m_Counter;
            @Override
            public int read() throws IOException
            {
                int toReturn = -1;
                if (m_Counter < responseBytes.length)
                {
                    toReturn = responseBytes[m_Counter];
                    m_Counter++;
                }
                return toReturn;
            }
        };
        when(m_UrlService.constructUrlConnection(m_UrlString)).thenReturn(m_Connection);
        when(m_Connection.getInputStream()).thenReturn(stream);
        when(m_CommandProcessor.processGetPanTilt(m_Ip)).thenReturn(m_UrlString);
        GetPanTiltResponse response = (GetPanTiltResponse)m_SUT.onExecuteCommand(new GetPanTiltCommand());
        assertThat(response.getPanTilt().getAzimuth().getValue(), closeTo(4.0, 0.00001));
        assertThat(response.getPanTilt().getElevation().getValue(), closeTo(8.1, 0.00001));
    }
@ Test public void testGetPanTilt ( ) throws AssetException , IOException , IllegalStateException , InterruptedException { final char [ ] responseBytes = new char [ ] { 'p' , 'a' , 'n' , '=' , '4' , '.' , '0' , '\n' , 't' , 'i' , 'l' , 't' , '=' , '8' , '.' , '1' } ; InputStream stream = new InputStream ( ) { private int m_Counter ; @ Override public int read ( ) throws IOException { int toReturn = - 1 ; if ( m_Counter < responseBytes . length ) { toReturn = responseBytes [ m_Counter ] ; m_Counter ++ ; } return toReturn ; } } ; when ( m_UrlService . constructUrlConnection ( m_UrlString ) ) . thenReturn ( m_Connection ) ; when ( m_Connection . getInputStream ( ) ) . thenReturn ( stream ) ; when ( m_CommandProcessor . processGetPanTilt ( m_Ip ) ) . thenReturn ( m_UrlString ) ; GetPanTiltResponse response = ( GetPanTiltResponse ) m_SUT . onExecuteCommand ( new GetPanTiltCommand ( ) ) ; assertThat ( response . getPanTilt ( ) . getAzimuth ( ) . getValue ( ) , closeTo ( 4.0 , 0.00001 ) ) ; assertThat ( response . getPanTilt ( ) . getElevation ( ) . getValue ( ) , closeTo ( 8.1 , 0.00001 ) ) ; }
Verify get pan/tilt command interactions.
Verify get pan / tilt command interactions .
//mock behavior //process the command