mil.dod.th.ose.core/test/mil/dod/th/ose/core/impl/ccomm/transport/TestTransportLayerServiceProxy.java
@SuppressWarnings({"unchecked", "rawtypes"})
    @Test
    public void testOnRemoveFactory()
    {
        //product type
        String productType1 = "a";
        
        //mock behavior
        FactoryRegistry reg = mock(FactoryRegistry.class);
        FactoryServiceContext context = mock(FactoryServiceContext.class);
        when(context.getRegistry()).thenReturn(reg);
        
        //create a transport object to return
        FactoryInternal fact1 = mock(FactoryInternal.class);
        when(fact1.getProductType()).thenReturn(productType1);
        TransportLayerInternal trans1 = mock(TransportLayerInternal.class);
        when(trans1.getFactory()).thenReturn(fact1);
        TransportLayerInternal trans2 = mock(TransportLayerInternal.class);
        when(trans2.getFactory()).thenReturn(fact1);
        
        Set<TransportLayerInternal> transports = new HashSet<>();
        transports.add(trans1);
        transports.add(trans2);
        when(reg.getObjectsByProductType(productType1)).thenReturn(transports);
        
        m_SUT.onRemoveFactory(context, fact1);
        
        verify(trans1).shutdown();
        verify(trans2).shutdown();
    }
/**
     * Verify that transport layers are shutdown when a factory is removed.
     */
Verify that transport layers are shutdown when a factory is removed.
Verify that transport layers are shutdown when a factory is removed .
@SuppressWarnings({"unchecked", "rawtypes"})
    @Test
    public void testOnRemoveFactory()
    {
        String productType1 = "a";
        FactoryRegistry reg = mock(FactoryRegistry.class);
        FactoryServiceContext context = mock(FactoryServiceContext.class);
        when(context.getRegistry()).thenReturn(reg);
        FactoryInternal fact1 = mock(FactoryInternal.class);
        when(fact1.getProductType()).thenReturn(productType1);
        TransportLayerInternal trans1 = mock(TransportLayerInternal.class);
        when(trans1.getFactory()).thenReturn(fact1);
        TransportLayerInternal trans2 = mock(TransportLayerInternal.class);
        when(trans2.getFactory()).thenReturn(fact1);
        Set<TransportLayerInternal> transports = new HashSet<>();
        transports.add(trans1);
        transports.add(trans2);
        when(reg.getObjectsByProductType(productType1)).thenReturn(transports);
        m_SUT.onRemoveFactory(context, fact1);
        verify(trans1).shutdown();
        verify(trans2).shutdown();
    }
@ SuppressWarnings ( { "unchecked" , "rawtypes" } ) @ Test public void testOnRemoveFactory ( ) { String productType1 = "a" ; FactoryRegistry reg = mock ( FactoryRegistry . class ) ; FactoryServiceContext context = mock ( FactoryServiceContext . class ) ; when ( context . getRegistry ( ) ) . thenReturn ( reg ) ; FactoryInternal fact1 = mock ( FactoryInternal . class ) ; when ( fact1 . getProductType ( ) ) . thenReturn ( productType1 ) ; TransportLayerInternal trans1 = mock ( TransportLayerInternal . class ) ; when ( trans1 . getFactory ( ) ) . thenReturn ( fact1 ) ; TransportLayerInternal trans2 = mock ( TransportLayerInternal . class ) ; when ( trans2 . getFactory ( ) ) . thenReturn ( fact1 ) ; Set < TransportLayerInternal > transports = new HashSet < > ( ) ; transports . add ( trans1 ) ; transports . add ( trans2 ) ; when ( reg . getObjectsByProductType ( productType1 ) ) . thenReturn ( transports ) ; m_SUT . onRemoveFactory ( context , fact1 ) ; verify ( trans1 ) . shutdown ( ) ; verify ( trans2 ) . shutdown ( ) ; }
Verify that transport layers are shutdown when a factory is removed.
Verify that transport layers are shutdown when a factory is removed .
//product type //mock behavior //create a transport object to return