mil.dod.th.ose.core.integration/src/mil/dod/th/ose/core/integration/TestAddressManagerService.java
public void testAddressCreation() 
        throws InterruptedException, CCommException, IllegalArgumentException, FactoryException
    {
        AddressManagerService addressManagerService = ServiceUtils.getService(m_Context, AddressManagerService.class);
        
        // Create the properties for a new address
        Map<String, Object> propsAddress1 = new HashMap<String, Object>();
        propsAddress1.put("a", 600);
        // Should create an address
        addressManagerService.getOrCreateAddress(ExampleAddress.class.getName(), "Addr1", propsAddress1);    
        propsAddress1 = null; // delete this variable so it can't be used again on accident
        
        // Create a new set of properties for a new address, testing that the link is null
        Map<String, Object> propsAddr2 = new HashMap<String, Object>();
        propsAddr2.put("a", 700);

        addressManagerService.getOrCreateAddress(ExampleAddress.class.getName(), "Addr2", propsAddr2);
        propsAddr2 = null; // again, delete variable so it can't be used again on accident
    
        // Need to test createAddress, checkAddressAlreadyExists for the other implementation of createAddress
        // property "a" must exist and equal "a", for success, in ExampleAddress.
        try{
            addressManagerService.getOrCreateAddress("Examplee:10"); // Invalid name
            // Using no parameters will generally fail by design in a real factory, but here it doesn't matter 
            fail("Expected to fail - invalid name - an extra character is on the end");
        }catch(CCommException e){    }
        
        try{
            addressManagerService.getOrCreateAddress("example:10"); // Case sensitivity - invalid name
            fail("Expected to fail - invalid name - currently case-sensitive");
        }catch(CCommException e){    }
        
        // Check with a valid prefix
        assertThat(addressManagerService.checkAddressAlreadyExists("Example:12345"),is(false));
        
        // Create the same address that was just checked
        Address a = addressManagerService.getOrCreateAddress("Example:12345");
        assertThat(a, not(nullValue()));
        
        assertThat(addressManagerService.checkAddressAlreadyExists("Example:12345"),is(true));
    }
/**
     * Verify new addresses can be created using the method that accepts a property dictionary.
     * 
     * Verify invalid prefixes will cause an exception to be thrown.
     */
Verify new addresses can be created using the method that accepts a property dictionary.

Verify invalid prefixes will cause an exception to be thrown.
Verify new addresses can be created using the method that accepts a property dictionary . Verify invalid prefixes will cause an exception to be thrown .
public void testAddressCreation() 
        throws InterruptedException, CCommException, IllegalArgumentException, FactoryException
    {
        AddressManagerService addressManagerService = ServiceUtils.getService(m_Context, AddressManagerService.class);
        Map<String, Object> propsAddress1 = new HashMap<String, Object>();
        propsAddress1.put("a", 600);
        addressManagerService.getOrCreateAddress(ExampleAddress.class.getName(), "Addr1", propsAddress1);    
        propsAddress1 = null; 
        Map<String, Object> propsAddr2 = new HashMap<String, Object>();
        propsAddr2.put("a", 700);
        addressManagerService.getOrCreateAddress(ExampleAddress.class.getName(), "Addr2", propsAddr2);
        propsAddr2 = null; 
        try{
            addressManagerService.getOrCreateAddress("Examplee:10"); 
            fail("Expected to fail - invalid name - an extra character is on the end");
        }catch(CCommException e){    }
        try{
            addressManagerService.getOrCreateAddress("example:10"); 
            fail("Expected to fail - invalid name - currently case-sensitive");
        }catch(CCommException e){    }
        assertThat(addressManagerService.checkAddressAlreadyExists("Example:12345"),is(false));
        Address a = addressManagerService.getOrCreateAddress("Example:12345");
        assertThat(a, not(nullValue()));
        assertThat(addressManagerService.checkAddressAlreadyExists("Example:12345"),is(true));
    }
public void testAddressCreation ( ) throws InterruptedException , CCommException , IllegalArgumentException , FactoryException { AddressManagerService addressManagerService = ServiceUtils . getService ( m_Context , AddressManagerService . class ) ; Map < String , Object > propsAddress1 = new HashMap < String , Object > ( ) ; propsAddress1 . put ( "a" , 600 ) ; addressManagerService . getOrCreateAddress ( ExampleAddress . class . getName ( ) , "Addr1" , propsAddress1 ) ; propsAddress1 = null ; Map < String , Object > propsAddr2 = new HashMap < String , Object > ( ) ; propsAddr2 . put ( "a" , 700 ) ; addressManagerService . getOrCreateAddress ( ExampleAddress . class . getName ( ) , "Addr2" , propsAddr2 ) ; propsAddr2 = null ; try { addressManagerService . getOrCreateAddress ( "Examplee:10" ) ; fail ( "Expected to fail - invalid name - an extra character is on the end" ) ; } catch ( CCommException e ) { } try { addressManagerService . getOrCreateAddress ( "example:10" ) ; fail ( "Expected to fail - invalid name - currently case-sensitive" ) ; } catch ( CCommException e ) { } assertThat ( addressManagerService . checkAddressAlreadyExists ( "Example:12345" ) , is ( false ) ) ; Address a = addressManagerService . getOrCreateAddress ( "Example:12345" ) ; assertThat ( a , not ( nullValue ( ) ) ) ; assertThat ( addressManagerService . checkAddressAlreadyExists ( "Example:12345" ) , is ( true ) ) ; }
Verify new addresses can be created using the method that accepts a property dictionary.
Verify new addresses can be created using the method that accepts a property dictionary .
// Create the properties for a new address // Should create an address // delete this variable so it can't be used again on accident // Create a new set of properties for a new address, testing that the link is null // again, delete variable so it can't be used again on accident // Need to test createAddress, checkAddressAlreadyExists for the other implementation of createAddress // property "a" must exist and equal "a", for success, in ExampleAddress. // Invalid name // Using no parameters will generally fail by design in a real factory, but here it doesn't matter  // Case sensitivity - invalid name // Check with a valid prefix // Create the same address that was just checked