mil.dod.th.ose.core/test/mil/dod/th/ose/core/factory/impl/TestFactoryServiceContextImpl.java
@SuppressWarnings("rawtypes")
    @Test
    public void testAddPluginFactory() 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);
        
        // replay
        m_ServiceListenerAdpator.addService(proxyServiceRef, m_ProxyComponentFactory);
        
        // verify the filter is based on the factory annotation (which is the class name of the base type)
        verify(m_CoreBundleContext)
            .createFilter("(" + ComponentConstants.COMPONENT_FACTORY + "=" + FactoryObject.class.getName() + ")");
        
        Dictionary<String, Object> props = new Hashtable<>();
        props.put(FactoryInternal.KEY_COMPONENT_FACTORY, m_ProxyComponentFactory);
        props.put(FactoryInternal.KEY_SERVICE_CONTEXT, m_SUT);
        props.put(FactoryInternal.KEY_SERVICE_REFERENCE, proxyServiceRef);
        verify(m_FactoryInternalFactory).newInstance(props);
        
        verify(factory, timeout(100)).registerServices();
        
        verify(m_FactoryRegistry, timeout(100)).restoreAllObjects(factory);
        
        verify(factory, timeout(100)).makeAvailable();
        
        assertThat(m_SUT.getFactories(), hasEntry(PRODUCT_TYPE, factory));
    }
/**
     * Verify plug-in factory is registered properly.
     */
Verify plug-in factory is registered properly.
Verify plug - in factory is registered properly .
@SuppressWarnings("rawtypes")
    @Test
    public void testAddPluginFactory() 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);
        m_ServiceListenerAdpator.addService(proxyServiceRef, m_ProxyComponentFactory);
        verify(m_CoreBundleContext)
            .createFilter("(" + ComponentConstants.COMPONENT_FACTORY + "=" + FactoryObject.class.getName() + ")");
        Dictionary<String, Object> props = new Hashtable<>();
        props.put(FactoryInternal.KEY_COMPONENT_FACTORY, m_ProxyComponentFactory);
        props.put(FactoryInternal.KEY_SERVICE_CONTEXT, m_SUT);
        props.put(FactoryInternal.KEY_SERVICE_REFERENCE, proxyServiceRef);
        verify(m_FactoryInternalFactory).newInstance(props);
        verify(factory, timeout(100)).registerServices();
        verify(m_FactoryRegistry, timeout(100)).restoreAllObjects(factory);
        verify(factory, timeout(100)).makeAvailable();
        assertThat(m_SUT.getFactories(), hasEntry(PRODUCT_TYPE, factory));
    }
@ SuppressWarnings ( "rawtypes" ) @ Test public void testAddPluginFactory ( ) 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 ) ; m_ServiceListenerAdpator . addService ( proxyServiceRef , m_ProxyComponentFactory ) ; verify ( m_CoreBundleContext ) . createFilter ( "(" + ComponentConstants . COMPONENT_FACTORY + "=" + FactoryObject . class . getName ( ) + ")" ) ; Dictionary < String , Object > props = new Hashtable < > ( ) ; props . put ( FactoryInternal . KEY_COMPONENT_FACTORY , m_ProxyComponentFactory ) ; props . put ( FactoryInternal . KEY_SERVICE_CONTEXT , m_SUT ) ; props . put ( FactoryInternal . KEY_SERVICE_REFERENCE , proxyServiceRef ) ; verify ( m_FactoryInternalFactory ) . newInstance ( props ) ; verify ( factory , timeout ( 100 ) ) . registerServices ( ) ; verify ( m_FactoryRegistry , timeout ( 100 ) ) . restoreAllObjects ( factory ) ; verify ( factory , timeout ( 100 ) ) . makeAvailable ( ) ; assertThat ( m_SUT . getFactories ( ) , hasEntry ( PRODUCT_TYPE , factory ) ) ; }
Verify plug-in factory is registered properly.
Verify plug - in factory is registered properly .
// replay // verify the filter is based on the factory annotation (which is the class name of the base type)