mil.dod.th.ose.core/test/mil/dod/th/ose/core/impl/ccomm/TestCustomCommsServiceImpl_Transport.java
@Test
    public void testLinkLayerAlreadyOwnedCreateTransport() throws IllegalArgumentException, FactoryException, 
        FactoryObjectInformationException, CCommException, ClassNotFoundException
    {
        String name = "name";
        when(m_TransInternal.getLinkLayer()).thenReturn(m_LinkInternal);
        when(m_LinkInternal.getName()).thenReturn(name);
        
        //checks if get transport back
        String transName = "trans";
        TransportLayer transport = m_SUT.createTransportLayer(TL_PRODUCT_TYPE, transName, name);
        
        //assert
        assertThat(transport, is(notNullValue()));

        //verify
        Map<String, Object> props = new HashMap<>();
        props.put(TransportLayerAttributes.CONFIG_PROP_LINK_LAYER_NAME, name);
        verify(m_TransRegistry).createNewObject(m_TransFactory, transName, props);
        verify(m_WakeLock).activate();
        verify(m_WakeLock).cancel();
        
        //reg mocking
        Set<TransportLayerInternal> transList = new HashSet<>();
        transList.add(m_TransInternal);
        when(m_TransRegistry.getObjects()).thenReturn(transList);
        
        //request to create another link with the same link layer, but different name
        String transName2 = "nameAlso";
        TransportLayer transport2 = m_SUT.createTransportLayer(TL_PRODUCT_TYPE, transName2, name);
        
        //assert
        assertThat(transport, is(notNullValue()));
        assertThat(transport, is(transport2));

        //verify call to reg only made once
        verify(m_TransRegistry, times(1)).createNewObject(m_TransFactory, transName, props);
        verify(m_WakeLock).activate();
        verify(m_WakeLock).cancel();
    }
/**
     * Verify return of previously created transport if a new request is received with the 
     * same link layer.
     */
Verify return of previously created transport if a new request is received with the
same link layer.
Verify return of previously created transport if a new request is received with the same link layer .
@Test
    public void testLinkLayerAlreadyOwnedCreateTransport() throws IllegalArgumentException, FactoryException, 
        FactoryObjectInformationException, CCommException, ClassNotFoundException
    {
        String name = "name";
        when(m_TransInternal.getLinkLayer()).thenReturn(m_LinkInternal);
        when(m_LinkInternal.getName()).thenReturn(name);
        String transName = "trans";
        TransportLayer transport = m_SUT.createTransportLayer(TL_PRODUCT_TYPE, transName, name);
        assertThat(transport, is(notNullValue()));
        Map<String, Object> props = new HashMap<>();
        props.put(TransportLayerAttributes.CONFIG_PROP_LINK_LAYER_NAME, name);
        verify(m_TransRegistry).createNewObject(m_TransFactory, transName, props);
        verify(m_WakeLock).activate();
        verify(m_WakeLock).cancel();
        Set<TransportLayerInternal> transList = new HashSet<>();
        transList.add(m_TransInternal);
        when(m_TransRegistry.getObjects()).thenReturn(transList);
        String transName2 = "nameAlso";
        TransportLayer transport2 = m_SUT.createTransportLayer(TL_PRODUCT_TYPE, transName2, name);
        assertThat(transport, is(notNullValue()));
        assertThat(transport, is(transport2));
         call to reg only made once
        verify(m_TransRegistry, times(1)).createNewObject(m_TransFactory, transName, props);
        verify(m_WakeLock).activate();
        verify(m_WakeLock).cancel();
    }
@ Test public void testLinkLayerAlreadyOwnedCreateTransport ( ) throws IllegalArgumentException , FactoryException , FactoryObjectInformationException , CCommException , ClassNotFoundException { String name = "name" ; when ( m_TransInternal . getLinkLayer ( ) ) . thenReturn ( m_LinkInternal ) ; when ( m_LinkInternal . getName ( ) ) . thenReturn ( name ) ; String transName = "trans" ; TransportLayer transport = m_SUT . createTransportLayer ( TL_PRODUCT_TYPE , transName , name ) ; assertThat ( transport , is ( notNullValue ( ) ) ) ; Map < String , Object > props = new HashMap < > ( ) ; props . put ( TransportLayerAttributes . CONFIG_PROP_LINK_LAYER_NAME , name ) ; verify ( m_TransRegistry ) . createNewObject ( m_TransFactory , transName , props ) ; verify ( m_WakeLock ) . activate ( ) ; verify ( m_WakeLock ) . cancel ( ) ; Set < TransportLayerInternal > transList = new HashSet < > ( ) ; transList . add ( m_TransInternal ) ; when ( m_TransRegistry . getObjects ( ) ) . thenReturn ( transList ) ; String transName2 = "nameAlso" ; TransportLayer transport2 = m_SUT . createTransportLayer ( TL_PRODUCT_TYPE , transName2 , name ) ; assertThat ( transport , is ( notNullValue ( ) ) ) ; assertThat ( transport , is ( transport2 ) ) ; verify ( m_TransRegistry , times ( 1 ) ) . createNewObject ( m_TransFactory , transName , props ) ; verify ( m_WakeLock ) . activate ( ) ; verify ( m_WakeLock ) . cancel ( ) ; }
Verify return of previously created transport if a new request is received with the
 same link layer.
Verify return of previously created transport if a new request is received with the same link layer .
//checks if get transport back //assert //verify //reg mocking //request to create another link with the same link layer, but different name //assert //verify call to reg only made once