mil.dod.th.ose.core.integration/src/mil/dod/th/ose/core/integration/TestAddressManagerService.java
public void testAddressCreationWithName() 
        throws InterruptedException, CCommException, IllegalArgumentException, FactoryException
    {
        AddressManagerService addressManagerService = ServiceUtils.getService(m_Context, AddressManagerService.class);
        
        // Create the properties for a new address
        Address addr1 = addressManagerService.getOrCreateAddress("Example:100", "UniqueName");
        assertThat(addressManagerService.getAddressByName("UniqueName"), is(addr1));
        
        Address addr2 = addressManagerService.getOrCreateAddress("Example:200", "DoNotCopy");
        assertThat(addressManagerService.getAddressByName("DoNotCopy"), is(addr2));

        // Verify address names/descriptors can be returned
        assertThat(addressManagerService.getAddressNames(), hasItems("UniqueName", "DoNotCopy"));
        Map<String, String> nameMap = addressManagerService.getAddressNamesWithDescriptor();
        assertThat(nameMap.size(), is(2));
        assertThat(nameMap.keySet(), hasItems("UniqueName", "DoNotCopy"));
        assertThat(nameMap.values(), hasItems("Example:100", "Example:200"));

        // Try to create an address with a duplicate name and verify it was not created.
        int size = addressManagerService.getAddressDescriptiveStrings().size();
        try
        {
            addressManagerService.getOrCreateAddress("Example:300", "DoNotCopy");
        }
        catch (Exception e)
        {
            assertThat(e.getCause().getMessage(), containsString("Duplicate name: [DoNotCopy]"));
        }
        
        //check no new addresses were added
        assertThat(addressManagerService.getAddressDescriptiveStrings().size(), is(size));
        
        //check first and second addresses were created
        assertThat(addr1.isManaged(), is(true));
        assertThat(addr2.isManaged(), is(true));
    }
/**
     * Verify new addresses can be created and named.
     */
Verify new addresses can be created and named.
Verify new addresses can be created and named .
public void testAddressCreationWithName() 
        throws InterruptedException, CCommException, IllegalArgumentException, FactoryException
    {
        AddressManagerService addressManagerService = ServiceUtils.getService(m_Context, AddressManagerService.class);
        Address addr1 = addressManagerService.getOrCreateAddress("Example:100", "UniqueName");
        assertThat(addressManagerService.getAddressByName("UniqueName"), is(addr1));
        Address addr2 = addressManagerService.getOrCreateAddress("Example:200", "DoNotCopy");
        assertThat(addressManagerService.getAddressByName("DoNotCopy"), is(addr2));
        assertThat(addressManagerService.getAddressNames(), hasItems("UniqueName", "DoNotCopy"));
        Map<String, String> nameMap = addressManagerService.getAddressNamesWithDescriptor();
        assertThat(nameMap.size(), is(2));
        assertThat(nameMap.keySet(), hasItems("UniqueName", "DoNotCopy"));
        assertThat(nameMap.values(), hasItems("Example:100", "Example:200"));
        int size = addressManagerService.getAddressDescriptiveStrings().size();
        try
        {
            addressManagerService.getOrCreateAddress("Example:300", "DoNotCopy");
        }
        catch (Exception e)
        {
            assertThat(e.getCause().getMessage(), containsString("Duplicate name: [DoNotCopy]"));
        }
        assertThat(addressManagerService.getAddressDescriptiveStrings().size(), is(size));
        assertThat(addr1.isManaged(), is(true));
        assertThat(addr2.isManaged(), is(true));
    }
public void testAddressCreationWithName ( ) throws InterruptedException , CCommException , IllegalArgumentException , FactoryException { AddressManagerService addressManagerService = ServiceUtils . getService ( m_Context , AddressManagerService . class ) ; Address addr1 = addressManagerService . getOrCreateAddress ( "Example:100" , "UniqueName" ) ; assertThat ( addressManagerService . getAddressByName ( "UniqueName" ) , is ( addr1 ) ) ; Address addr2 = addressManagerService . getOrCreateAddress ( "Example:200" , "DoNotCopy" ) ; assertThat ( addressManagerService . getAddressByName ( "DoNotCopy" ) , is ( addr2 ) ) ; assertThat ( addressManagerService . getAddressNames ( ) , hasItems ( "UniqueName" , "DoNotCopy" ) ) ; Map < String , String > nameMap = addressManagerService . getAddressNamesWithDescriptor ( ) ; assertThat ( nameMap . size ( ) , is ( 2 ) ) ; assertThat ( nameMap . keySet ( ) , hasItems ( "UniqueName" , "DoNotCopy" ) ) ; assertThat ( nameMap . values ( ) , hasItems ( "Example:100" , "Example:200" ) ) ; int size = addressManagerService . getAddressDescriptiveStrings ( ) . size ( ) ; try { addressManagerService . getOrCreateAddress ( "Example:300" , "DoNotCopy" ) ; } catch ( Exception e ) { assertThat ( e . getCause ( ) . getMessage ( ) , containsString ( "Duplicate name: [DoNotCopy]" ) ) ; } assertThat ( addressManagerService . getAddressDescriptiveStrings ( ) . size ( ) , is ( size ) ) ; assertThat ( addr1 . isManaged ( ) , is ( true ) ) ; assertThat ( addr2 . isManaged ( ) , is ( true ) ) ; }
Verify new addresses can be created and named.
Verify new addresses can be created and named .
// Create the properties for a new address // Verify address names/descriptors can be returned // Try to create an address with a duplicate name and verify it was not created. //check no new addresses were added //check first and second addresses were created