mil.dod.th.ose.core.integration/src/mil/dod/th/ose/core/integration/TestCustomCommsService.java
public void testSetLinkLayerName() throws IllegalArgumentException, IOException, InterruptedException, 
        CCommException, IllegalStateException, FactoryException, PersistenceFailedException
    {
        CustomCommsService customCommsService = ServiceUtils.getService(m_Context, CustomCommsService.class);
        assertThat(customCommsService, is(notNullValue()));
        
        UUID physUuid = customCommsService.tryCreatePhysicalLink(PhysicalLinkTypeEnum.I_2_C, "testLinkPhys");
        PhysicalLink plink = customCommsService.requestPhysicalLink(physUuid);
        
        LinkLayer link = customCommsService.createLinkLayer(ExampleLinkLayer.class.getName(), plink.getName());
        
        link.setName("testSetNameLink");
        
        int size = customCommsService.getLinkLayers().size();
        
        Map<String, Object> props = new HashMap<>();
        props.put("some prop", "some value");
        UUID  physUuid2 = customCommsService.tryCreatePhysicalLink(PhysicalLinkTypeEnum.I_2_C, "testLinkPhys2", props);
        PhysicalLink plink2 = customCommsService.requestPhysicalLink(physUuid2);
        
        try
        {
            customCommsService.createLinkLayer(ExampleLinkLayer.class.getName(), "testSetNameLink", plink2.getName());
            fail("Should have thrown an exception");
        }
        catch (CCommException e)
        {
            assertThat(e.getCause().getMessage(), 
                    containsString("Duplicate name: [testSetNameLink] is already in use"));
        }
        
        assertThat(customCommsService.getLinkLayer("testSetNameLink"), is(link));
        // verify that no new link layer was created
        assertThat(customCommsService.getLinkLayers().size(), is(size));
        
        //verify valid creation of a link layer with specified name
        LinkLayer link2 = customCommsService.createLinkLayer(ExampleLinkLayer.class.getName(), "testSetNameLink2", 
                plink2.getName());
        assertThat(link2.getName(), is("testSetNameLink2"));
        
        try
        {
            link2.setName("testSetNameLink");
            fail("Should have thrown an exception");
        }
        catch(IllegalArgumentException e)
        {
            //duplicate name
        }
        
        assertThat(link.getName(), is("testSetNameLink"));
        assertThat(link2.getName(), is(not("testSetNameLink")));
    }
/**
     * Test setting the link layer's name. The name should only be set if it is unique.
     */
Test setting the link layer's name. The name should only be set if it is unique.
Test setting the link layer ' s name . The name should only be set if it is unique .
public void testSetLinkLayerName() throws IllegalArgumentException, IOException, InterruptedException, 
        CCommException, IllegalStateException, FactoryException, PersistenceFailedException
    {
        CustomCommsService customCommsService = ServiceUtils.getService(m_Context, CustomCommsService.class);
        assertThat(customCommsService, is(notNullValue()));
        UUID physUuid = customCommsService.tryCreatePhysicalLink(PhysicalLinkTypeEnum.I_2_C, "testLinkPhys");
        PhysicalLink plink = customCommsService.requestPhysicalLink(physUuid);
        LinkLayer link = customCommsService.createLinkLayer(ExampleLinkLayer.class.getName(), plink.getName());
        link.setName("testSetNameLink");
        int size = customCommsService.getLinkLayers().size();
        Map<String, Object> props = new HashMap<>();
        props.put("some prop", "some value");
        UUID  physUuid2 = customCommsService.tryCreatePhysicalLink(PhysicalLinkTypeEnum.I_2_C, "testLinkPhys2", props);
        PhysicalLink plink2 = customCommsService.requestPhysicalLink(physUuid2);
        try
        {
            customCommsService.createLinkLayer(ExampleLinkLayer.class.getName(), "testSetNameLink", plink2.getName());
            fail("Should have thrown an exception");
        }
        catch (CCommException e)
        {
            assertThat(e.getCause().getMessage(), 
                    containsString("Duplicate name: [testSetNameLink] is already in use"));
        }
        assertThat(customCommsService.getLinkLayer("testSetNameLink"), is(link));
        assertThat(customCommsService.getLinkLayers().size(), is(size));
        LinkLayer link2 = customCommsService.createLinkLayer(ExampleLinkLayer.class.getName(), "testSetNameLink2", 
                plink2.getName());
        assertThat(link2.getName(), is("testSetNameLink2"));
        try
        {
            link2.setName("testSetNameLink");
            fail("Should have thrown an exception");
        }
        catch(IllegalArgumentException e)
        {
        }
        assertThat(link.getName(), is("testSetNameLink"));
        assertThat(link2.getName(), is(not("testSetNameLink")));
    }
public void testSetLinkLayerName ( ) throws IllegalArgumentException , IOException , InterruptedException , CCommException , IllegalStateException , FactoryException , PersistenceFailedException { CustomCommsService customCommsService = ServiceUtils . getService ( m_Context , CustomCommsService . class ) ; assertThat ( customCommsService , is ( notNullValue ( ) ) ) ; UUID physUuid = customCommsService . tryCreatePhysicalLink ( PhysicalLinkTypeEnum . I_2_C , "testLinkPhys" ) ; PhysicalLink plink = customCommsService . requestPhysicalLink ( physUuid ) ; LinkLayer link = customCommsService . createLinkLayer ( ExampleLinkLayer . class . getName ( ) , plink . getName ( ) ) ; link . setName ( "testSetNameLink" ) ; int size = customCommsService . getLinkLayers ( ) . size ( ) ; Map < String , Object > props = new HashMap < > ( ) ; props . put ( "some prop" , "some value" ) ; UUID physUuid2 = customCommsService . tryCreatePhysicalLink ( PhysicalLinkTypeEnum . I_2_C , "testLinkPhys2" , props ) ; PhysicalLink plink2 = customCommsService . requestPhysicalLink ( physUuid2 ) ; try { customCommsService . createLinkLayer ( ExampleLinkLayer . class . getName ( ) , "testSetNameLink" , plink2 . getName ( ) ) ; fail ( "Should have thrown an exception" ) ; } catch ( CCommException e ) { assertThat ( e . getCause ( ) . getMessage ( ) , containsString ( "Duplicate name: [testSetNameLink] is already in use" ) ) ; } assertThat ( customCommsService . getLinkLayer ( "testSetNameLink" ) , is ( link ) ) ; assertThat ( customCommsService . getLinkLayers ( ) . size ( ) , is ( size ) ) ; LinkLayer link2 = customCommsService . createLinkLayer ( ExampleLinkLayer . class . getName ( ) , "testSetNameLink2" , plink2 . getName ( ) ) ; assertThat ( link2 . getName ( ) , is ( "testSetNameLink2" ) ) ; try { link2 . setName ( "testSetNameLink" ) ; fail ( "Should have thrown an exception" ) ; } catch ( IllegalArgumentException e ) { } assertThat ( link . getName ( ) , is ( "testSetNameLink" ) ) ; assertThat ( link2 . getName ( ) , is ( not ( "testSetNameLink" ) ) ) ; }
Test setting the link layer's name.
Test setting the link layer ' s name .
// verify that no new link layer was created //verify valid creation of a link layer with specified name //duplicate name