mil.dod.th.ose.core/test/mil/dod/th/ose/core/factory/impl/TestFactoryDescriptorImpl.java
@Test
    public void testDispose()
    {
        List<ComponentInfo<FactoryObjectProxy>> components = 
                ComponentFactoryMocker.mockComponents(FactoryObjectProxy.class, componentFactory, 3);
        
        FactoryObjectProxy obj1 = m_SUT.create();
        FactoryObjectProxy obj2 = m_SUT.create();
        FactoryObjectProxy obj3 = m_SUT.create();
        
        // dispose of object and make sure the property component instance is disposed and not others
        m_SUT.dispose(obj2);
        verify(components.get(0).getInstance(), never()).dispose();
        verify(components.get(1).getInstance()).dispose();
        verify(components.get(2).getInstance(), never()).dispose();
        
        m_SUT.dispose(obj3);
        verify(components.get(0).getInstance(), never()).dispose();
        verify(components.get(1).getInstance()).dispose(); // still holder at 1
        verify(components.get(2).getInstance()).dispose(); // now disposed
        
        // dispose of last one, each should be disposed exactly 1 time
        m_SUT.dispose(obj1);
        verify(components.get(0).getInstance()).dispose();
        verify(components.get(1).getInstance()).dispose();
        verify(components.get(2).getInstance()).dispose();
        
        // dispose object again, shouldn't cause exception or additional calls to dispose
        m_SUT.dispose(obj1);
        verify(components.get(0).getInstance()).dispose();
        verify(components.get(1).getInstance()).dispose();
        verify(components.get(2).getInstance()).dispose();
    }
/**
     * Verify the dispose method will dispose of previously created instance.
     */
Verify the dispose method will dispose of previously created instance.
Verify the dispose method will dispose of previously created instance .
@Test
    public void testDispose()
    {
        List<ComponentInfo<FactoryObjectProxy>> components = 
                ComponentFactoryMocker.mockComponents(FactoryObjectProxy.class, componentFactory, 3);
        FactoryObjectProxy obj1 = m_SUT.create();
        FactoryObjectProxy obj2 = m_SUT.create();
        FactoryObjectProxy obj3 = m_SUT.create();
        m_SUT.dispose(obj2);
        verify(components.get(0).getInstance(), never()).dispose();
        verify(components.get(1).getInstance()).dispose();
        verify(components.get(2).getInstance(), never()).dispose();
        m_SUT.dispose(obj3);
        verify(components.get(0).getInstance(), never()).dispose();
        verify(components.get(1).getInstance()).dispose(); 
        verify(components.get(2).getInstance()).dispose(); 
        m_SUT.dispose(obj1);
        verify(components.get(0).getInstance()).dispose();
        verify(components.get(1).getInstance()).dispose();
        verify(components.get(2).getInstance()).dispose();
        m_SUT.dispose(obj1);
        verify(components.get(0).getInstance()).dispose();
        verify(components.get(1).getInstance()).dispose();
        verify(components.get(2).getInstance()).dispose();
    }
@ Test public void testDispose ( ) { List < ComponentInfo < FactoryObjectProxy > > components = ComponentFactoryMocker . mockComponents ( FactoryObjectProxy . class , componentFactory , 3 ) ; FactoryObjectProxy obj1 = m_SUT . create ( ) ; FactoryObjectProxy obj2 = m_SUT . create ( ) ; FactoryObjectProxy obj3 = m_SUT . create ( ) ; m_SUT . dispose ( obj2 ) ; verify ( components . get ( 0 ) . getInstance ( ) , never ( ) ) . dispose ( ) ; verify ( components . get ( 1 ) . getInstance ( ) ) . dispose ( ) ; verify ( components . get ( 2 ) . getInstance ( ) , never ( ) ) . dispose ( ) ; m_SUT . dispose ( obj3 ) ; verify ( components . get ( 0 ) . getInstance ( ) , never ( ) ) . dispose ( ) ; verify ( components . get ( 1 ) . getInstance ( ) ) . dispose ( ) ; verify ( components . get ( 2 ) . getInstance ( ) ) . dispose ( ) ; m_SUT . dispose ( obj1 ) ; verify ( components . get ( 0 ) . getInstance ( ) ) . dispose ( ) ; verify ( components . get ( 1 ) . getInstance ( ) ) . dispose ( ) ; verify ( components . get ( 2 ) . getInstance ( ) ) . dispose ( ) ; m_SUT . dispose ( obj1 ) ; verify ( components . get ( 0 ) . getInstance ( ) ) . dispose ( ) ; verify ( components . get ( 1 ) . getInstance ( ) ) . dispose ( ) ; verify ( components . get ( 2 ) . getInstance ( ) ) . dispose ( ) ; }
Verify the dispose method will dispose of previously created instance.
Verify the dispose method will dispose of previously created instance .
// dispose of object and make sure the property component instance is disposed and not others // still holder at 1 // now disposed // dispose of last one, each should be disposed exactly 1 time // dispose object again, shouldn't cause exception or additional calls to dispose