mil.dod.th.ose.remote.integration/src/mil/dod/th/ose/remote/integration/namespace/TestLinkLayerNamespace.java
@Test
    public void testIsAvailable() throws IOException, InterruptedException
    {
        MessageListener listener = new MessageListener(socket);
        
        //---Verify a valid address returns that it is available---
        // construct new link layer message type
        IsAvailableRequestData isAvailableRequest = IsAvailableRequestData.newBuilder().
                setUuid(linkUuid).
                setAddress("Example:5").
                build();
        
        LinkLayerNamespace.Builder linkLayerMessage = LinkLayerNamespace.newBuilder().
                setType(LinkLayerMessageType.IsAvailableRequest).
                setData(isAvailableRequest.toByteString());
        
        TerraHarvestMessage message = TerraHarvestMessageHelper.createTerraHarvestMsg(Namespace.LinkLayer, 
                linkLayerMessage);
        
        message.writeDelimitedTo(socket.getOutputStream());
        
        // listen for messages for a specific time interval
        LinkLayerNamespace response = (LinkLayerNamespace)listener.waitForMessage(Namespace.LinkLayer,
                LinkLayerMessageType.IsAvailableResponse, listenerTimeout);
       
        IsAvailableResponseData dataResponse = IsAvailableResponseData.parseFrom(
                response.getData());
        
        assertThat(dataResponse.getAvailable(), is(true));
        assertThat(dataResponse.getUuid(), is(linkUuid));
        
        //---Verify an invalid address returns an error message---
        // construct new link layer message type
        isAvailableRequest = IsAvailableRequestData.newBuilder().
                setUuid(linkUuid).
                setAddress("giraffe").
                build();
        
        linkLayerMessage = LinkLayerNamespace.newBuilder().
                setType(LinkLayerMessageType.IsAvailableRequest).
                setData(isAvailableRequest.toByteString());
        
        message = TerraHarvestMessageHelper.createTerraHarvestMsg(Namespace.LinkLayer, 
                linkLayerMessage);
        
        message.writeDelimitedTo(socket.getOutputStream());
        
        // listen for messages for a specific time interval
        BaseNamespace errorResponse = (BaseNamespace)listener.waitForMessage(Namespace.Base, 
                BaseMessageType.GenericErrorResponse, listenerTimeout);
        
        GenericErrorResponseData genericErrorResponseTest = GenericErrorResponseData.parseFrom(errorResponse.getData());
        
        assertThat(genericErrorResponseTest.getError(), is(ErrorCode.INVALID_VALUE));
    }
/**
     * Assuming that a link layer was created in setup, make sure that a valid address is available to the link layer.
     */
Assuming that a link layer was created in setup, make sure that a valid address is available to the link layer.
Assuming that a link layer was created in setup make sure that a valid address is available to the link layer .
@Test
    public void testIsAvailable() throws IOException, InterruptedException
    {
        MessageListener listener = new MessageListener(socket);
        IsAvailableRequestData isAvailableRequest = IsAvailableRequestData.newBuilder().
                setUuid(linkUuid).
                setAddress("Example:5").
                build();
        LinkLayerNamespace.Builder linkLayerMessage = LinkLayerNamespace.newBuilder().
                setType(LinkLayerMessageType.IsAvailableRequest).
                setData(isAvailableRequest.toByteString());
        TerraHarvestMessage message = TerraHarvestMessageHelper.createTerraHarvestMsg(Namespace.LinkLayer, 
                linkLayerMessage);
        message.writeDelimitedTo(socket.getOutputStream());
        LinkLayerNamespace response = (LinkLayerNamespace)listener.waitForMessage(Namespace.LinkLayer,
                LinkLayerMessageType.IsAvailableResponse, listenerTimeout);
        IsAvailableResponseData dataResponse = IsAvailableResponseData.parseFrom(
                response.getData());
        assertThat(dataResponse.getAvailable(), is(true));
        assertThat(dataResponse.getUuid(), is(linkUuid));
        isAvailableRequest = IsAvailableRequestData.newBuilder().
                setUuid(linkUuid).
                setAddress("giraffe").
                build();
        linkLayerMessage = LinkLayerNamespace.newBuilder().
                setType(LinkLayerMessageType.IsAvailableRequest).
                setData(isAvailableRequest.toByteString());
        message = TerraHarvestMessageHelper.createTerraHarvestMsg(Namespace.LinkLayer, 
                linkLayerMessage);
        message.writeDelimitedTo(socket.getOutputStream());
        BaseNamespace errorResponse = (BaseNamespace)listener.waitForMessage(Namespace.Base, 
                BaseMessageType.GenericErrorResponse, listenerTimeout);
        GenericErrorResponseData genericErrorResponseTest = GenericErrorResponseData.parseFrom(errorResponse.getData());
        assertThat(genericErrorResponseTest.getError(), is(ErrorCode.INVALID_VALUE));
    }
@ Test public void testIsAvailable ( ) throws IOException , InterruptedException { MessageListener listener = new MessageListener ( socket ) ; IsAvailableRequestData isAvailableRequest = IsAvailableRequestData . newBuilder ( ) . setUuid ( linkUuid ) . setAddress ( "Example:5" ) . build ( ) ; LinkLayerNamespace . Builder linkLayerMessage = LinkLayerNamespace . newBuilder ( ) . setType ( LinkLayerMessageType . IsAvailableRequest ) . setData ( isAvailableRequest . toByteString ( ) ) ; TerraHarvestMessage message = TerraHarvestMessageHelper . createTerraHarvestMsg ( Namespace . LinkLayer , linkLayerMessage ) ; message . writeDelimitedTo ( socket . getOutputStream ( ) ) ; LinkLayerNamespace response = ( LinkLayerNamespace ) listener . waitForMessage ( Namespace . LinkLayer , LinkLayerMessageType . IsAvailableResponse , listenerTimeout ) ; IsAvailableResponseData dataResponse = IsAvailableResponseData . parseFrom ( response . getData ( ) ) ; assertThat ( dataResponse . getAvailable ( ) , is ( true ) ) ; assertThat ( dataResponse . getUuid ( ) , is ( linkUuid ) ) ; isAvailableRequest = IsAvailableRequestData . newBuilder ( ) . setUuid ( linkUuid ) . setAddress ( "giraffe" ) . build ( ) ; linkLayerMessage = LinkLayerNamespace . newBuilder ( ) . setType ( LinkLayerMessageType . IsAvailableRequest ) . setData ( isAvailableRequest . toByteString ( ) ) ; message = TerraHarvestMessageHelper . createTerraHarvestMsg ( Namespace . LinkLayer , linkLayerMessage ) ; message . writeDelimitedTo ( socket . getOutputStream ( ) ) ; BaseNamespace errorResponse = ( BaseNamespace ) listener . waitForMessage ( Namespace . Base , BaseMessageType . GenericErrorResponse , listenerTimeout ) ; GenericErrorResponseData genericErrorResponseTest = GenericErrorResponseData . parseFrom ( errorResponse . getData ( ) ) ; assertThat ( genericErrorResponseTest . getError ( ) , is ( ErrorCode . INVALID_VALUE ) ) ; }
Assuming that a link layer was created in setup, make sure that a valid address is available to the link layer.
Assuming that a link layer was created in setup make sure that a valid address is available to the link layer .
//---Verify a valid address returns that it is available--- // construct new link layer message type // listen for messages for a specific time interval //---Verify an invalid address returns an error message--- // construct new link layer message type // listen for messages for a specific time interval