mil.dod.th.ose.core.integration/src/mil/dod/th/ose/core/integration/TestAssetDirectoryService.java
public void testSetAssetName() throws IllegalArgumentException, AssetException, IOException, InterruptedException, 
        IllegalStateException, FactoryException, PersistenceFailedException
    {
        AssetDirectoryService assetDirectoryService = ServiceUtils.getService(m_Context, AssetDirectoryService.class);
        assertThat(assetDirectoryService, is(notNullValue()));
        
        ConfigurationAdmin configAdmin = ServiceUtils.getService(m_Context, ConfigurationAdmin.class);
        assertThat(configAdmin, is(notNullValue()));
        
        EventHandlerSyncer syncer = new EventHandlerSyncer(m_Context, 
            FactoryDescriptor.TOPIC_FACTORY_OBJ_NAME_UPDATED, String.format("(%s=%s)", 
                FactoryDescriptor.EVENT_PROP_OBJ_NAME, "testSetNameAsset"));
        
        Asset asset = assetDirectoryService.createAsset(ExampleAsset.class.getName(), "testSetNameAsset");
        asset.setName("testSetNameAsset");
        
        syncer.waitForEvent(10);
        
        Asset asset2 = assetDirectoryService.createAsset(ExampleAsset.class.getName());
        
        try
        {
            asset2.setName("testSetNameAsset");
            fail("expecting exception");
        }
        catch (IllegalArgumentException e)
        {
            // do nothing, this exception is expected and does not need to be handled
        }

        assertThat(asset.getName(), is("testSetNameAsset"));
        assertThat(asset2.getName(), is(not("testSetNameAsset")));
    }
/*
     * Test that an asset name is correctly set if the name is unique. If the name is not unique it should not be set.
     */
Test that an asset name is correctly set if the name is unique. If the name is not unique it should not be set.
Test that an asset name is correctly set if the name is unique . If the name is not unique it should not be set .
public void testSetAssetName() throws IllegalArgumentException, AssetException, IOException, InterruptedException, 
        IllegalStateException, FactoryException, PersistenceFailedException
    {
        AssetDirectoryService assetDirectoryService = ServiceUtils.getService(m_Context, AssetDirectoryService.class);
        assertThat(assetDirectoryService, is(notNullValue()));
        ConfigurationAdmin configAdmin = ServiceUtils.getService(m_Context, ConfigurationAdmin.class);
        assertThat(configAdmin, is(notNullValue()));
        EventHandlerSyncer syncer = new EventHandlerSyncer(m_Context, 
            FactoryDescriptor.TOPIC_FACTORY_OBJ_NAME_UPDATED, String.format("(%s=%s)", 
                FactoryDescriptor.EVENT_PROP_OBJ_NAME, "testSetNameAsset"));
        Asset asset = assetDirectoryService.createAsset(ExampleAsset.class.getName(), "testSetNameAsset");
        asset.setName("testSetNameAsset");
        syncer.waitForEvent(10);
        Asset asset2 = assetDirectoryService.createAsset(ExampleAsset.class.getName());
        try
        {
            asset2.setName("testSetNameAsset");
            fail("expecting exception");
        }
        catch (IllegalArgumentException e)
        {
        }
        assertThat(asset.getName(), is("testSetNameAsset"));
        assertThat(asset2.getName(), is(not("testSetNameAsset")));
    }
public void testSetAssetName ( ) throws IllegalArgumentException , AssetException , IOException , InterruptedException , IllegalStateException , FactoryException , PersistenceFailedException { AssetDirectoryService assetDirectoryService = ServiceUtils . getService ( m_Context , AssetDirectoryService . class ) ; assertThat ( assetDirectoryService , is ( notNullValue ( ) ) ) ; ConfigurationAdmin configAdmin = ServiceUtils . getService ( m_Context , ConfigurationAdmin . class ) ; assertThat ( configAdmin , is ( notNullValue ( ) ) ) ; EventHandlerSyncer syncer = new EventHandlerSyncer ( m_Context , FactoryDescriptor . TOPIC_FACTORY_OBJ_NAME_UPDATED , String . format ( "(%s=%s)" , FactoryDescriptor . EVENT_PROP_OBJ_NAME , "testSetNameAsset" ) ) ; Asset asset = assetDirectoryService . createAsset ( ExampleAsset . class . getName ( ) , "testSetNameAsset" ) ; asset . setName ( "testSetNameAsset" ) ; syncer . waitForEvent ( 10 ) ; Asset asset2 = assetDirectoryService . createAsset ( ExampleAsset . class . getName ( ) ) ; try { asset2 . setName ( "testSetNameAsset" ) ; fail ( "expecting exception" ) ; } catch ( IllegalArgumentException e ) { } assertThat ( asset . getName ( ) , is ( "testSetNameAsset" ) ) ; assertThat ( asset2 . getName ( ) , is ( not ( "testSetNameAsset" ) ) ) ; }
Test that an asset name is correctly set if the name is unique.
Test that an asset name is correctly set if the name is unique .
// do nothing, this exception is expected and does not need to be handled