コード例 #1
0
ファイル: test_client_udp.py プロジェクト: cindy126/TCP-UDP
 def test_case5(self):
     # start server thread
     t = threading.Thread(target=mockServer)
     t.start()
     # use functions in client source code to do normal operation
     clientSocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
     client_python_udp.sendCommand(clientSocket, "localhost", serverPort, "ls")
     rc = client_python_udp.receiveDataToFile(clientSocket, "debugOutput.txt") 
     self.assertEqual(rc, "Did not receive response.")
     # check server function return value
     t.join(5.0)
     self.assertFalse(t.is_alive())      # server thread should have completed   
コード例 #2
0
ファイル: test_server_udp.py プロジェクト: cindy126/TCP-UDP
 def test_case3(self):
     # start server thread
     que = queue.Queue()
     t = threading.Thread(target=threadServer, args=(que,))
     t.start()
     # use functions in client source code to send command
     clientSocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
     client_python_udp.sendCommand(clientSocket, "localhost", serverPort, "ls")
     # check server function return value
     t.join(5.0)
     self.assertFalse(t.is_alive())      # server thread should have completed   
     self.assertEqual(que.get(), "File transmission failed.")
コード例 #3
0
ファイル: test_server_udp.py プロジェクト: cindy126/TCP-UDP
 def test_case1(self):
     # start server thread
     que = queue.Queue()
     t = threading.Thread(target=threadServer, args=(que,))
     t.start()
     # use functions in client source code to do normal operation
     clientSocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
     client_python_udp.sendCommand(clientSocket, "localhost", serverPort, "ls")
     client_python_udp.receiveDataToFile(clientSocket, "debugOutput.txt")    
     # check server function return value
     t.join(5.0)
     self.assertFalse(t.is_alive())      # server thread should have completed   
     self.assertEqual(que.get(), "Successful file transmission.")
コード例 #4
0
ファイル: test_client_udp.py プロジェクト: cindy126/TCP-UDP
 def test_case3(self):
     # indicate server is not running
     clientSocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
     rc = client_python_udp.sendCommand(clientSocket, "localhost", serverPort, "ls")
     self.assertEqual(rc, "Failed to send command. Terminating.")