Test_SimpleSocket.pf Source File


This file depends on

sourcefile~~test_simplesocket.pf~~EfferentGraph sourcefile~test_simplesocket.pf Test_SimpleSocket.pf sourcefile~abstractmessage.f90 AbstractMessage.F90 sourcefile~test_simplesocket.pf->sourcefile~abstractmessage.f90 sourcefile~abstractsocket.f90 AbstractSocket.F90 sourcefile~test_simplesocket.pf->sourcefile~abstractsocket.f90 sourcefile~addreaddatacollectionmessage.f90 AddReadDataCollectionMessage.F90 sourcefile~test_simplesocket.pf->sourcefile~addreaddatacollectionmessage.f90 sourcefile~arrayreference.f90 ArrayReference.F90 sourcefile~test_simplesocket.pf->sourcefile~arrayreference.f90 sourcefile~basethread.f90 BaseThread.F90 sourcefile~test_simplesocket.pf->sourcefile~basethread.f90 sourcefile~clientthread.f90 ClientThread.F90 sourcefile~test_simplesocket.pf->sourcefile~clientthread.f90 sourcefile~donemessage.f90 DoneMessage.F90 sourcefile~test_simplesocket.pf->sourcefile~donemessage.f90 sourcefile~idmessage.f90 IDMessage.F90 sourcefile~test_simplesocket.pf->sourcefile~idmessage.f90 sourcefile~mockclient.f90 MockClient.F90 sourcefile~test_simplesocket.pf->sourcefile~mockclient.f90 sourcefile~mockserverthread.f90 MockServerThread.F90 sourcefile~test_simplesocket.pf->sourcefile~mockserverthread.f90 sourcefile~serverthread.f90 ServerThread.F90 sourcefile~test_simplesocket.pf->sourcefile~serverthread.f90 sourcefile~simplesocket.f90 SimpleSocket.F90 sourcefile~test_simplesocket.pf->sourcefile~simplesocket.f90 sourcefile~terminatemessage.f90 TerminateMessage.F90 sourcefile~test_simplesocket.pf->sourcefile~terminatemessage.f90

Source Code

module test_SimpleSocket
   use pfunit
   use pFIO_AbstractMessageMod
   use pFIO_AbstractSocketMod
   use pFIO_SimpleSocketMod
   use pFIO_ArrayReferenceMod
   use pFIO_BaseThreadMod
   use pFIO_ServerThreadMod
   use pFIO_ClientThreadMod
   use MockServerThreadMod
   use MockClientMod

   use pFIO_TerminateMessageMod
   use pFIO_DoneMessageMod
   use pFIO_AddReadDataCollectionMessageMod
   use pFIO_IdMessageMod

   implicit none

contains


   @test
   subroutine test_send_terminate()
      type (SimpleSocket) :: client_connection
      type (MockServerThread), target :: s
      type (SimpleSocket),target :: server_connection
      class(BaseThread), pointer :: visitor
      class(AbstractSocket), pointer :: connection
      class(AbstractMessage), allocatable:: msg
     
      server_connection = SimpleSocket()
      call s%set_connection(server_connection)
      call client_connection%set_visitor(s)
      call client_connection%send(TerminateMessage())
      @assertEqual('handle_Terminate()', s%log)
      visitor =>client_connection%visitor
      connection=>visitor%get_connection()
      call connection%receive(msg)
      @assertEqual(TERMINATE_ID,msg%get_type_id())
   end subroutine test_send_terminate

   @test
   subroutine test_send_done()
      type (SimpleSocket) :: client_connection
      type (MockServerThread), target :: s
      type (SimpleSocket) :: server_connection
      class(BaseThread), pointer :: visitor
      class(AbstractSocket), pointer :: connection
      class(AbstractMessage), allocatable :: msg

      call s%set_connection(server_connection)
      call client_connection%set_visitor(s)
      call client_connection%send(DoneMessage())
      @assertEqual('handle_Done()', s%log)
      visitor =>client_connection%visitor
      connection=>visitor%get_connection()
      call connection%receive(msg)
      @assertEqual(DONE_ID,msg%get_type_id())
   end subroutine test_send_done


end module test_SimpleSocket