mil.dod.th.ose.core/test/mil/dod/th/ose/core/factory/impl/TestFactoryServiceContextImpl.java
@SuppressWarnings("rawtypes")
    @Test
    public void testRemovePluginFactory() throws InvalidSyntaxException
    {
        ComponentInfo<FactoryInternal> component = 
                ComponentFactoryMocker.mockSingleComponent(FactoryInternal.class, m_FactoryInternalFactory);
        FactoryInternal factory = component.getObject();
        
        ServiceReference proxyServiceRef = mock(ServiceReference.class);
        when(proxyServiceRef.getProperty(ComponentConstants.COMPONENT_NAME)).thenReturn(PRODUCT_TYPE);
        when(factory.getProductType()).thenReturn(PRODUCT_TYPE);
        
        // have first object throw exception to ensure objects later in list are still disposed
        doThrow(new IllegalStateException()).when(factory).dispose(m_ObjectProxy1);
        
        // replay
        m_ServiceListenerAdpator.addService(proxyServiceRef, m_ProxyComponentFactory);
        m_ServiceListenerAdpator.removeService(m_ProxyComponentFactory);
        
        verify(factory).makeUnavailable();
        
        verify(factory).cleanup();
        
        verify(m_FactoryServiceProxy).onRemoveFactory(m_SUT, factory);
        
        verify(component.getInstance()).dispose();
        
        verify(factory).dispose(m_ObjectProxy1);
        verify(factory).dispose(m_ObjectProxy2);
        verify(m_FactoryRegistry).removeObject(m_ObjectUuid1);
        verify(m_FactoryRegistry).removeObject(m_ObjectUuid2);
        
        verify(m_CoreBundleContext).ungetService(proxyServiceRef);
        
        assertThat(m_SUT.getFactories().isEmpty(), is(true));
    }
/**
     * Verify plug-in factory is cleaned up properly.
     */
Verify plug-in factory is cleaned up properly.
Verify plug - in factory is cleaned up properly .
@SuppressWarnings("rawtypes")
    @Test
    public void testRemovePluginFactory() throws InvalidSyntaxException
    {
        ComponentInfo<FactoryInternal> component = 
                ComponentFactoryMocker.mockSingleComponent(FactoryInternal.class, m_FactoryInternalFactory);
        FactoryInternal factory = component.getObject();
        ServiceReference proxyServiceRef = mock(ServiceReference.class);
        when(proxyServiceRef.getProperty(ComponentConstants.COMPONENT_NAME)).thenReturn(PRODUCT_TYPE);
        when(factory.getProductType()).thenReturn(PRODUCT_TYPE);
        doThrow(new IllegalStateException()).when(factory).dispose(m_ObjectProxy1);
        m_ServiceListenerAdpator.addService(proxyServiceRef, m_ProxyComponentFactory);
        m_ServiceListenerAdpator.removeService(m_ProxyComponentFactory);
        verify(factory).makeUnavailable();
        verify(factory).cleanup();
        verify(m_FactoryServiceProxy).onRemoveFactory(m_SUT, factory);
        verify(component.getInstance()).dispose();
        verify(factory).dispose(m_ObjectProxy1);
        verify(factory).dispose(m_ObjectProxy2);
        verify(m_FactoryRegistry).removeObject(m_ObjectUuid1);
        verify(m_FactoryRegistry).removeObject(m_ObjectUuid2);
        verify(m_CoreBundleContext).ungetService(proxyServiceRef);
        assertThat(m_SUT.getFactories().isEmpty(), is(true));
    }
@ SuppressWarnings ( "rawtypes" ) @ Test public void testRemovePluginFactory ( ) throws InvalidSyntaxException { ComponentInfo < FactoryInternal > component = ComponentFactoryMocker . mockSingleComponent ( FactoryInternal . class , m_FactoryInternalFactory ) ; FactoryInternal factory = component . getObject ( ) ; ServiceReference proxyServiceRef = mock ( ServiceReference . class ) ; when ( proxyServiceRef . getProperty ( ComponentConstants . COMPONENT_NAME ) ) . thenReturn ( PRODUCT_TYPE ) ; when ( factory . getProductType ( ) ) . thenReturn ( PRODUCT_TYPE ) ; doThrow ( new IllegalStateException ( ) ) . when ( factory ) . dispose ( m_ObjectProxy1 ) ; m_ServiceListenerAdpator . addService ( proxyServiceRef , m_ProxyComponentFactory ) ; m_ServiceListenerAdpator . removeService ( m_ProxyComponentFactory ) ; verify ( factory ) . makeUnavailable ( ) ; verify ( factory ) . cleanup ( ) ; verify ( m_FactoryServiceProxy ) . onRemoveFactory ( m_SUT , factory ) ; verify ( component . getInstance ( ) ) . dispose ( ) ; verify ( factory ) . dispose ( m_ObjectProxy1 ) ; verify ( factory ) . dispose ( m_ObjectProxy2 ) ; verify ( m_FactoryRegistry ) . removeObject ( m_ObjectUuid1 ) ; verify ( m_FactoryRegistry ) . removeObject ( m_ObjectUuid2 ) ; verify ( m_CoreBundleContext ) . ungetService ( proxyServiceRef ) ; assertThat ( m_SUT . getFactories ( ) . isEmpty ( ) , is ( true ) ) ; }
Verify plug-in factory is cleaned up properly.
Verify plug - in factory is cleaned up properly .
// have first object throw exception to ensure objects later in list are still disposed // replay