mil.dod.th.ose.core/test/mil/dod/th/ose/core/impl/ccomm/TestCustomCommsServiceImpl_System.java
@Test
    public void testPrintDeep() 
        throws CCommException, IOException, InterruptedException, IllegalArgumentException, IllegalStateException, 
            FactoryException, UnmarshalException
    {
        //physical link mocks
        String phys1 = "phys1";
        String phys2 = "phys2";
        Map<String, Object> physPropKeys = new HashMap<>();
        physPropKeys.put("someKey","someValue");
        PhysicalLinkInternal physInt1 = mock(PhysicalLinkInternal.class);
        when(physInt1.getName()).thenReturn(phys1);
        when(physInt1.getProperties()).thenReturn(physPropKeys);
        
        PhysicalLinkInternal physInt2 = mock(PhysicalLinkInternal.class);
        when(physInt2.getName()).thenReturn(phys2);
        Set<PhysicalLinkInternal> physLinks = new HashSet<>();
        physLinks.add(physInt1);
        physLinks.add(physInt2);
        when(m_PhysRegistry.getObjects()).thenReturn(physLinks);
        
        //link layer mocks
        LinkLayerInternal linkInt1 = mock(LinkLayerInternal.class);
        when(linkInt1.getName()).thenReturn("link1");
        LinkLayerInternal linkInt2 = mock(LinkLayerInternal.class);
        when(linkInt2.getName()).thenReturn("link2");
        when(linkInt2.getPhysicalLink()).thenReturn(physInt2);
        LinkLayerInternal linkInt3 = mock(LinkLayerInternal.class);
        when(linkInt3.getName()).thenReturn("link3");
        Set<LinkLayerInternal> links = new HashSet<>();
        links.add(linkInt1);
        links.add(linkInt2);
        links.add(linkInt3);
        when(m_LinkRegistry.getObjects()).thenReturn(links);
        
        //trans layer mocks
        TransportLayerInternal transInt1 = mock(TransportLayerInternal.class);
        when(transInt1.getName()).thenReturn("trans1");
        TransportLayerInternal transInt2 = mock(TransportLayerInternal.class);
        when(transInt2.getName()).thenReturn("trans2");
        when(transInt2.getLinkLayer()).thenReturn(linkInt2);
        TransportLayerInternal transInt3 = mock(TransportLayerInternal.class);
        when(transInt3.getName()).thenReturn("trans3");
        when(transInt3.getLinkLayer()).thenReturn(linkInt3);
        Set<TransportLayerInternal> transLinks = new HashSet<>();
        transLinks.add(transInt1);
        transLinks.add(transInt2);
        transLinks.add(transInt3);
        when(m_TransRegistry.getObjects()).thenReturn(transLinks);
        
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        PrintStream printStream = new PrintStream(out);
        m_SUT.printDeep(printStream);
        
        //assert phys attrs
        assertThat(out.toString(), 
                containsString("phys1: Open: false, InUse: false, Properties:"));
        assertThat(out.toString(), 
                containsString("someKey = someValue"));
        assertThat(out.toString(), 
                containsString("phys2: Open: false, InUse: false, Properties:"));
        
        //assert link layer attrs
        assertThat(out.toString(), containsString("link1: Physical Link: <None>"));
        assertThat(out.toString(), containsString("link2: Physical Link: phys2"));
        assertThat(out.toString(), containsString("link3: Physical Link: <None>"));
        
        //assert trans attrs
        assertThat(out.toString(), 
                containsString("trans1: Link Layer: <None>, Physical Link: <None>"));
        assertThat(out.toString(), 
                containsString("trans2: Link Layer: link2, Physical Link: phys2"));
        assertThat(out.toString(), 
                containsString("trans3: Link Layer: link3, Physical Link: <None>"));
        
        //general header and footer
        assertThat(out.toString(), 
                containsString("****************Printing Deep:"));
        assertThat(out.toString(), 
                containsString("****************End of print deep"));
        assertThat(out.toString(), 
                containsString("------Transport Layer------"));
        assertThat(out.toString(), 
                containsString("------Link Layer-----------"));
        assertThat(out.toString(), 
                containsString("------PhysicalLink Layer-------"));
    }
/**
     * Tests correct output from print deep for all custom comms layer types.
     * 
     * NOTE: this test is whitespace sensitive.
     */
Tests correct output from print deep for all custom comms layer types.

this test is whitespace sensitive.
Tests correct output from print deep for all custom comms layer types . this test is whitespace sensitive .
@Test
    public void testPrintDeep() 
        throws CCommException, IOException, InterruptedException, IllegalArgumentException, IllegalStateException, 
            FactoryException, UnmarshalException
    {
        String phys1 = "phys1";
        String phys2 = "phys2";
        Map<String, Object> physPropKeys = new HashMap<>();
        physPropKeys.put("someKey","someValue");
        PhysicalLinkInternal physInt1 = mock(PhysicalLinkInternal.class);
        when(physInt1.getName()).thenReturn(phys1);
        when(physInt1.getProperties()).thenReturn(physPropKeys);
        PhysicalLinkInternal physInt2 = mock(PhysicalLinkInternal.class);
        when(physInt2.getName()).thenReturn(phys2);
        Set<PhysicalLinkInternal> physLinks = new HashSet<>();
        physLinks.add(physInt1);
        physLinks.add(physInt2);
        when(m_PhysRegistry.getObjects()).thenReturn(physLinks);
        LinkLayerInternal linkInt1 = mock(LinkLayerInternal.class);
        when(linkInt1.getName()).thenReturn("link1");
        LinkLayerInternal linkInt2 = mock(LinkLayerInternal.class);
        when(linkInt2.getName()).thenReturn("link2");
        when(linkInt2.getPhysicalLink()).thenReturn(physInt2);
        LinkLayerInternal linkInt3 = mock(LinkLayerInternal.class);
        when(linkInt3.getName()).thenReturn("link3");
        Set<LinkLayerInternal> links = new HashSet<>();
        links.add(linkInt1);
        links.add(linkInt2);
        links.add(linkInt3);
        when(m_LinkRegistry.getObjects()).thenReturn(links);
        TransportLayerInternal transInt1 = mock(TransportLayerInternal.class);
        when(transInt1.getName()).thenReturn("trans1");
        TransportLayerInternal transInt2 = mock(TransportLayerInternal.class);
        when(transInt2.getName()).thenReturn("trans2");
        when(transInt2.getLinkLayer()).thenReturn(linkInt2);
        TransportLayerInternal transInt3 = mock(TransportLayerInternal.class);
        when(transInt3.getName()).thenReturn("trans3");
        when(transInt3.getLinkLayer()).thenReturn(linkInt3);
        Set<TransportLayerInternal> transLinks = new HashSet<>();
        transLinks.add(transInt1);
        transLinks.add(transInt2);
        transLinks.add(transInt3);
        when(m_TransRegistry.getObjects()).thenReturn(transLinks);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        PrintStream printStream = new PrintStream(out);
        m_SUT.printDeep(printStream);
        assertThat(out.toString(), 
                containsString("phys1: Open: false, InUse: false, Properties:"));
        assertThat(out.toString(), 
                containsString("someKey = someValue"));
        assertThat(out.toString(), 
                containsString("phys2: Open: false, InUse: false, Properties:"));
        assertThat(out.toString(), containsString("link1: Physical Link: <None>"));
        assertThat(out.toString(), containsString("link2: Physical Link: phys2"));
        assertThat(out.toString(), containsString("link3: Physical Link: <None>"));
        assertThat(out.toString(), 
                containsString("trans1: Link Layer: <None>, Physical Link: <None>"));
        assertThat(out.toString(), 
                containsString("trans2: Link Layer: link2, Physical Link: phys2"));
        assertThat(out.toString(), 
                containsString("trans3: Link Layer: link3, Physical Link: <None>"));
        assertThat(out.toString(), 
                containsString("****************Printing Deep:"));
        assertThat(out.toString(), 
                containsString("****************End of print deep"));
        assertThat(out.toString(), 
                containsString("------Transport Layer------"));
        assertThat(out.toString(), 
                containsString("------Link Layer-----------"));
        assertThat(out.toString(), 
                containsString("------PhysicalLink Layer-------"));
    }
@ Test public void testPrintDeep ( ) throws CCommException , IOException , InterruptedException , IllegalArgumentException , IllegalStateException , FactoryException , UnmarshalException { String phys1 = "phys1" ; String phys2 = "phys2" ; Map < String , Object > physPropKeys = new HashMap < > ( ) ; physPropKeys . put ( "someKey" , "someValue" ) ; PhysicalLinkInternal physInt1 = mock ( PhysicalLinkInternal . class ) ; when ( physInt1 . getName ( ) ) . thenReturn ( phys1 ) ; when ( physInt1 . getProperties ( ) ) . thenReturn ( physPropKeys ) ; PhysicalLinkInternal physInt2 = mock ( PhysicalLinkInternal . class ) ; when ( physInt2 . getName ( ) ) . thenReturn ( phys2 ) ; Set < PhysicalLinkInternal > physLinks = new HashSet < > ( ) ; physLinks . add ( physInt1 ) ; physLinks . add ( physInt2 ) ; when ( m_PhysRegistry . getObjects ( ) ) . thenReturn ( physLinks ) ; LinkLayerInternal linkInt1 = mock ( LinkLayerInternal . class ) ; when ( linkInt1 . getName ( ) ) . thenReturn ( "link1" ) ; LinkLayerInternal linkInt2 = mock ( LinkLayerInternal . class ) ; when ( linkInt2 . getName ( ) ) . thenReturn ( "link2" ) ; when ( linkInt2 . getPhysicalLink ( ) ) . thenReturn ( physInt2 ) ; LinkLayerInternal linkInt3 = mock ( LinkLayerInternal . class ) ; when ( linkInt3 . getName ( ) ) . thenReturn ( "link3" ) ; Set < LinkLayerInternal > links = new HashSet < > ( ) ; links . add ( linkInt1 ) ; links . add ( linkInt2 ) ; links . add ( linkInt3 ) ; when ( m_LinkRegistry . getObjects ( ) ) . thenReturn ( links ) ; TransportLayerInternal transInt1 = mock ( TransportLayerInternal . class ) ; when ( transInt1 . getName ( ) ) . thenReturn ( "trans1" ) ; TransportLayerInternal transInt2 = mock ( TransportLayerInternal . class ) ; when ( transInt2 . getName ( ) ) . thenReturn ( "trans2" ) ; when ( transInt2 . getLinkLayer ( ) ) . thenReturn ( linkInt2 ) ; TransportLayerInternal transInt3 = mock ( TransportLayerInternal . class ) ; when ( transInt3 . getName ( ) ) . thenReturn ( "trans3" ) ; when ( transInt3 . getLinkLayer ( ) ) . thenReturn ( linkInt3 ) ; Set < TransportLayerInternal > transLinks = new HashSet < > ( ) ; transLinks . add ( transInt1 ) ; transLinks . add ( transInt2 ) ; transLinks . add ( transInt3 ) ; when ( m_TransRegistry . getObjects ( ) ) . thenReturn ( transLinks ) ; ByteArrayOutputStream out = new ByteArrayOutputStream ( ) ; PrintStream printStream = new PrintStream ( out ) ; m_SUT . printDeep ( printStream ) ; assertThat ( out . toString ( ) , containsString ( "phys1: Open: false, InUse: false, Properties:" ) ) ; assertThat ( out . toString ( ) , containsString ( "someKey = someValue" ) ) ; assertThat ( out . toString ( ) , containsString ( "phys2: Open: false, InUse: false, Properties:" ) ) ; assertThat ( out . toString ( ) , containsString ( "link1: Physical Link: <None>" ) ) ; assertThat ( out . toString ( ) , containsString ( "link2: Physical Link: phys2" ) ) ; assertThat ( out . toString ( ) , containsString ( "link3: Physical Link: <None>" ) ) ; assertThat ( out . toString ( ) , containsString ( "trans1: Link Layer: <None>, Physical Link: <None>" ) ) ; assertThat ( out . toString ( ) , containsString ( "trans2: Link Layer: link2, Physical Link: phys2" ) ) ; assertThat ( out . toString ( ) , containsString ( "trans3: Link Layer: link3, Physical Link: <None>" ) ) ; assertThat ( out . toString ( ) , containsString ( "****************Printing Deep:" ) ) ; assertThat ( out . toString ( ) , containsString ( "****************End of print deep" ) ) ; assertThat ( out . toString ( ) , containsString ( "------Transport Layer------" ) ) ; assertThat ( out . toString ( ) , containsString ( "------Link Layer-----------" ) ) ; assertThat ( out . toString ( ) , containsString ( "------PhysicalLink Layer-------" ) ) ; }
Tests correct output from print deep for all custom comms layer types.
Tests correct output from print deep for all custom comms layer types .
//physical link mocks //link layer mocks //trans layer mocks //assert phys attrs //assert link layer attrs //assert trans attrs //general header and footer