mil.dod.th.ose.core/test/mil/dod/th/ose/core/impl/ccomm/TestAddressServiceProxy.java
@Test
    public void testOnAddFactory() throws Exception
    {
        // basic mocking that always applies
        AddressFactory existingFactory = mock(AddressFactory.class);
        when(factoryServiceContext.getDirectoryService()).thenReturn(addrMgrSvc);
        when(addrMgrSvc.getFactoryByPrefix("dup-prefix")).thenReturn(existingFactory);
        
        // replay with new prefix, should be all good
        when(factory.getAddressCapabilities()).thenReturn(new AddressCapabilities().withPrefix("new-prefix"));
        m_SUT.beforeAddFactory(factoryServiceContext, factory);
        
        // replay with duplicate prefix
        when(factory.getAddressCapabilities()).thenReturn(new AddressCapabilities().withPrefix("dup-prefix"));
        
        try
        {
            m_SUT.beforeAddFactory(factoryServiceContext, factory);
            fail("Expecting exception as prefix is already defined");
        }
        catch (FactoryException e)
        {
            
        }
    }
/**
     * Verify that factories must be unique.
     */
Verify that factories must be unique.
Verify that factories must be unique .
@Test
    public void testOnAddFactory() throws Exception
    {
        AddressFactory existingFactory = mock(AddressFactory.class);
        when(factoryServiceContext.getDirectoryService()).thenReturn(addrMgrSvc);
        when(addrMgrSvc.getFactoryByPrefix("dup-prefix")).thenReturn(existingFactory);
        when(factory.getAddressCapabilities()).thenReturn(new AddressCapabilities().withPrefix("new-prefix"));
        m_SUT.beforeAddFactory(factoryServiceContext, factory);
        when(factory.getAddressCapabilities()).thenReturn(new AddressCapabilities().withPrefix("dup-prefix"));
        try
        {
            m_SUT.beforeAddFactory(factoryServiceContext, factory);
            fail("Expecting exception as prefix is already defined");
        }
        catch (FactoryException e)
        {
        }
    }
@ Test public void testOnAddFactory ( ) throws Exception { AddressFactory existingFactory = mock ( AddressFactory . class ) ; when ( factoryServiceContext . getDirectoryService ( ) ) . thenReturn ( addrMgrSvc ) ; when ( addrMgrSvc . getFactoryByPrefix ( "dup-prefix" ) ) . thenReturn ( existingFactory ) ; when ( factory . getAddressCapabilities ( ) ) . thenReturn ( new AddressCapabilities ( ) . withPrefix ( "new-prefix" ) ) ; m_SUT . beforeAddFactory ( factoryServiceContext , factory ) ; when ( factory . getAddressCapabilities ( ) ) . thenReturn ( new AddressCapabilities ( ) . withPrefix ( "dup-prefix" ) ) ; try { m_SUT . beforeAddFactory ( factoryServiceContext , factory ) ; fail ( "Expecting exception as prefix is already defined" ) ; } catch ( FactoryException e ) { } }
Verify that factories must be unique.
Verify that factories must be unique .
// basic mocking that always applies // replay with new prefix, should be all good // replay with duplicate prefix