mil.dod.th.ose.core/test/mil/dod/th/ose/core/impl/ccomm/TestLinkLayerRegistryCallback.java
@Test
    public void testPreObjectPhysWrongOwner() throws ConfigurationException
    {
        LinkLayerInternal linkInternal = mock(LinkLayerInternal.class);
        String physObjName = "name";
        LinkLayerAttributes attrs = mock(LinkLayerAttributes.class);
        when(linkInternal.getConfig()).thenReturn(attrs);
        when(attrs.physicalLinkName()).thenReturn(physObjName);
        
        //grab phys link from comms
        PhysicalLinkInternal physInternal = mock(PhysicalLinkInternal.class);
        when(m_FactPhysInternal.getObjectByName(physObjName)).thenReturn(physInternal);
        
        when(physInternal.isInUse()).thenReturn(true);
        when(physInternal.getOwner()).thenReturn(mock(LinkLayer.class));

        try
        {
            m_SUT.preObjectInitialize(linkInternal);
            fail("Expected as physical link owner is not the link object.");
        }
        catch (FactoryException e)
        {
            //expected as physical link prop is null
        }
        
        try
        {
            m_SUT.preObjectUpdated(linkInternal);
            fail("Expected as physical link owner is not the link object.");
        }
        catch (FactoryException e)
        {
            //expected as physical link prop is null
        }
    }
/**
     * Verify exception if the owner of a physical link is not the link layer object.
     */
Verify exception if the owner of a physical link is not the link layer object.
Verify exception if the owner of a physical link is not the link layer object .
@Test
    public void testPreObjectPhysWrongOwner() throws ConfigurationException
    {
        LinkLayerInternal linkInternal = mock(LinkLayerInternal.class);
        String physObjName = "name";
        LinkLayerAttributes attrs = mock(LinkLayerAttributes.class);
        when(linkInternal.getConfig()).thenReturn(attrs);
        when(attrs.physicalLinkName()).thenReturn(physObjName);
        PhysicalLinkInternal physInternal = mock(PhysicalLinkInternal.class);
        when(m_FactPhysInternal.getObjectByName(physObjName)).thenReturn(physInternal);
        when(physInternal.isInUse()).thenReturn(true);
        when(physInternal.getOwner()).thenReturn(mock(LinkLayer.class));
        try
        {
            m_SUT.preObjectInitialize(linkInternal);
            fail("Expected as physical link owner is not the link object.");
        }
        catch (FactoryException e)
        {
        }
        try
        {
            m_SUT.preObjectUpdated(linkInternal);
            fail("Expected as physical link owner is not the link object.");
        }
        catch (FactoryException e)
        {
        }
    }
@ Test public void testPreObjectPhysWrongOwner ( ) throws ConfigurationException { LinkLayerInternal linkInternal = mock ( LinkLayerInternal . class ) ; String physObjName = "name" ; LinkLayerAttributes attrs = mock ( LinkLayerAttributes . class ) ; when ( linkInternal . getConfig ( ) ) . thenReturn ( attrs ) ; when ( attrs . physicalLinkName ( ) ) . thenReturn ( physObjName ) ; PhysicalLinkInternal physInternal = mock ( PhysicalLinkInternal . class ) ; when ( m_FactPhysInternal . getObjectByName ( physObjName ) ) . thenReturn ( physInternal ) ; when ( physInternal . isInUse ( ) ) . thenReturn ( true ) ; when ( physInternal . getOwner ( ) ) . thenReturn ( mock ( LinkLayer . class ) ) ; try { m_SUT . preObjectInitialize ( linkInternal ) ; fail ( "Expected as physical link owner is not the link object." ) ; } catch ( FactoryException e ) { } try { m_SUT . preObjectUpdated ( linkInternal ) ; fail ( "Expected as physical link owner is not the link object." ) ; } catch ( FactoryException e ) { } }
Verify exception if the owner of a physical link is not the link layer object.
Verify exception if the owner of a physical link is not the link layer object .
//grab phys link from comms //expected as physical link prop is null //expected as physical link prop is null