mil.dod.th.ose.core/test/mil/dod/th/ose/core/impl/ccomm/physical/TestPhysicalLinkServiceProxy.java
@Test
    public void testOnRemoveFactory_Exception() throws PhysicalLinkException
    {
        PhysicalLinkInternal phys1 = mock(PhysicalLinkInternal.class);
        when(phys1.isOpen()).thenReturn(true);
        PhysicalLinkInternal phys2 = mock(PhysicalLinkInternal.class);
        when(phys2.isOpen()).thenReturn(true);
        doThrow(new PhysicalLinkException("exception")).when(phys2).close();
        
        Set<PhysicalLinkInternal> links = new HashSet<>();
        links.add(phys1);
        links.add(phys2);
        when(registry.getObjectsByProductType(PRODUCT_TYPE)).thenReturn(links);
        
        m_SUT.onRemoveFactory(factoryServiceContext, factory);
        
        verify(phys1).close();
        verify(phys2).close();
    }
/**
     * Verify if an exception thrown while closing a physical link that other links are still closed.
     */
Verify if an exception thrown while closing a physical link that other links are still closed.
Verify if an exception thrown while closing a physical link that other links are still closed .
@Test
    public void testOnRemoveFactory_Exception() throws PhysicalLinkException
    {
        PhysicalLinkInternal phys1 = mock(PhysicalLinkInternal.class);
        when(phys1.isOpen()).thenReturn(true);
        PhysicalLinkInternal phys2 = mock(PhysicalLinkInternal.class);
        when(phys2.isOpen()).thenReturn(true);
        doThrow(new PhysicalLinkException("exception")).when(phys2).close();
        Set<PhysicalLinkInternal> links = new HashSet<>();
        links.add(phys1);
        links.add(phys2);
        when(registry.getObjectsByProductType(PRODUCT_TYPE)).thenReturn(links);
        m_SUT.onRemoveFactory(factoryServiceContext, factory);
        verify(phys1).close();
        verify(phys2).close();
    }
@ Test public void testOnRemoveFactory_Exception ( ) throws PhysicalLinkException { PhysicalLinkInternal phys1 = mock ( PhysicalLinkInternal . class ) ; when ( phys1 . isOpen ( ) ) . thenReturn ( true ) ; PhysicalLinkInternal phys2 = mock ( PhysicalLinkInternal . class ) ; when ( phys2 . isOpen ( ) ) . thenReturn ( true ) ; doThrow ( new PhysicalLinkException ( "exception" ) ) . when ( phys2 ) . close ( ) ; Set < PhysicalLinkInternal > links = new HashSet < > ( ) ; links . add ( phys1 ) ; links . add ( phys2 ) ; when ( registry . getObjectsByProductType ( PRODUCT_TYPE ) ) . thenReturn ( links ) ; m_SUT . onRemoveFactory ( factoryServiceContext , factory ) ; verify ( phys1 ) . close ( ) ; verify ( phys2 ) . close ( ) ; }
Verify if an exception thrown while closing a physical link that other links are still closed.
Verify if an exception thrown while closing a physical link that other links are still closed .