test_class.declarator: CORRECT_MESSAGE = "TCP payload!"
test_class.modifier: private static final
test_class.original_string: private static final String CORRECT_MESSAGE = "TCP payload!";
test_class.type: String
test_class.var_name: CORRECT_MESSAGE
test_class.declarator: WRONG_MESSAGE_ADDITIONAL_WHITESPACE = "TCP payload! "
test_class.modifier: private static final
test_class.original_string: private static final String WRONG_MESSAGE_ADDITIONAL_WHITESPACE = "TCP payload! ";
test_class.type: String
test_class.var_name: WRONG_MESSAGE_ADDITIONAL_WHITESPACE
test_class.declarator: WRONG_MESSAGE = "UDP payload!"
test_class.modifier: private static final
test_class.original_string: private static final String WRONG_MESSAGE = "UDP payload!";
test_class.type: String
test_class.var_name: WRONG_MESSAGE
test_class.declarator: ECHO_SERVICE_HOST = "echo.host"
test_class.modifier: private static final
test_class.original_string: private static final String ECHO_SERVICE_HOST = "echo.host";
test_class.type: String
test_class.var_name: ECHO_SERVICE_HOST
test_class.declarator: testOutputStream
test_class.modifier: private
test_class.original_string: private OutputStream testOutputStream;
test_class.type: OutputStream
test_class.var_name: testOutputStream
test_class.declarator: qosTest
test_class.modifier: private
test_class.original_string: private QualityOfServiceTest qosTest;
test_class.type: QualityOfServiceTest
test_class.var_name: qosTest
test_class.declarator: testSettings
test_class.modifier: private
test_class.original_string: private TestSettings testSettings;
test_class.type: TestSettings
test_class.var_name: testSettings
test_class.declarator: clientHolder
test_class.modifier: private
test_class.original_string: private RMBTClient clientHolder;
test_class.type: RMBTClient
test_class.var_name: clientHolder
test_class.file: RMBTClient/src/test/java/at/rtr/rmbt/client/v2/task/EchoProtocolTcpTaskTest.java
test_class.identifier: EchoProtocolTcpTaskTest
test_case.body: @Test
      public void testCorrectTcpEchoResponse(@Mocked final Socket socket) throws Exception {
  
          new Expectations() {{
  
              //return an outputstream we control
              socket.getOutputStream();
              result = testOutputStream;
  
              //return the sent message
              socket.getInputStream();
              result = new ByteArrayInputStream(CORRECT_MESSAGE.getBytes());
  
          }};
  
          final EchoProtocolTcpTask task = new EchoProtocolTcpTask(qosTest, clientHolder.getTaskDescList().get(0), 0);
          final QoSTestResult res = task.call();
  
          // the server receives the message with a \n at the end, thus the comparison needs be made against a message w/appended \n
          assertEquals("Payload sent to server != " + CORRECT_MESSAGE, CORRECT_MESSAGE + "\n", testOutputStream.toString());
          assertEquals("Result did not return OK","OK", res.getResultMap().get(AbstractEchoProtocolTask.RESULT_STATUS));
          assertEquals("Wrong echo service host in result", ECHO_SERVICE_HOST, res.getResultMap().get("echo_protocol_objective_host"));
          assertEquals("Wrong protocol type in result", AbstractEchoProtocolTask.PROTOCOL_TCP, res.getResultMap().get(AbstractEchoProtocolTask.RESULT_PROTOCOL));
          assertEquals("Payload stored in result !=" + CORRECT_MESSAGE, CORRECT_MESSAGE, res.getResultMap().get(AbstractEchoProtocolTask.RESULT));
  
      }
test_case.class_method_signature: EchoProtocolTcpTaskTest.testCorrectTcpEchoResponse(@Mocked final Socket socket)
test_case.full_signature: @Test public void testCorrectTcpEchoResponse(@Mocked final Socket socket)
test_case.identifier: testCorrectTcpEchoResponse
test_case.invocations: getOutputStream getInputStream getBytes get getTaskDescList call assertEquals toString assertEquals get getResultMap assertEquals get getResultMap assertEquals get getResultMap assertEquals get getResultMap
test_case.modifiers: @Test public
test_case.parameters: (@Mocked final Socket socket)
test_case.return: void
test_case.signature: void testCorrectTcpEchoResponse(@Mocked final Socket socket)
focal_class.file: RMBTClient/src/main/java/at/rtr/rmbt/client/v2/task/EchoProtocolTcpTask.java
focal_class.identifier: EchoProtocolTcpTask
focal_class.class_method_signature: EchoProtocolTcpTask.EchoProtocolTcpTask(QualityOfServiceTest nnTest, TaskDesc taskDesc, int threadId)
focal_class.full_signature: public  EchoProtocolTcpTask(QualityOfServiceTest nnTest, TaskDesc taskDesc, int threadId)
focal_class.identifier: EchoProtocolTcpTask
focal_class.modifiers: public
focal_class.parameters: (QualityOfServiceTest nnTest, TaskDesc taskDesc, int threadId)
focal_class.signature:  EchoProtocolTcpTask(QualityOfServiceTest nnTest, TaskDesc taskDesc, int threadId)
focal_class.class_method_signature: EchoProtocolTcpTask.call()
focal_class.full_signature: public QoSTestResult call()
focal_class.identifier: call
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: QoSTestResult
focal_class.signature: QoSTestResult call()
focal_class.superclass: extends AbstractEchoProtocolTask
focal_method.body: public QoSTestResult call() throws Exception {
  		final QoSTestResult result = initQoSTestResult(QosMeasurementType.ECHO_PROTOCOL);
  		try {
  			onStart(result);
  
  			try {
  				System.out.println("ECHO_PROTOCOL_TCP_TASK: " + getTestServerAddr() + ":" + getTestServerPort());
  		    	
  
  		    	if (this.testPort != null && this.testHost != null) {
  					try (Socket socket = getSocket(testHost, testPort, false, (int)(timeout/1000000))){
  						socket.setSoTimeout((int)(timeout/1000000));
  						
  						final long startTime = System.nanoTime();
  						sendMessage(socket, this.payload + "\n");
  						final String testResponse = readLine(socket);
  						final long duration = System.nanoTime() - startTime;
  
  						result.getResultMap().put(RESULT, testResponse);
  						socket.close();
  						if (this.payload.equals(testResponse)) {
  							result.getResultMap().put(RESULT_STATUS, "OK");
  						} else {
  							result.getResultMap().put(RESULT_STATUS, "ERROR");
  						}
  						result.getResultMap().put(RESULT_RTT_NS, Long.toString(duration));
  					}
  					catch (SocketTimeoutException e) {
  						result.getResultMap().put(RESULT_STATUS, "TIMEOUT");
  					}
  					catch (Exception e) {
  						result.getResultMap().put(RESULT_STATUS, "ERROR");
  					}
  		    	} else {
  		    		result.getResultMap().put(RESULT_STATUS, "ERROR");
  				}
  				
  			}
  			catch (Exception e) {
  				e.printStackTrace();
  				result.getResultMap().put(RESULT_STATUS, "ERROR");
  			}
  			
  			return result;
  		}
  		catch (Exception e)  {
  			throw e;
  		}
  		finally {
  
  			if (this.testPort != null) {
  				result.getResultMap().put(RESULT_PORT, testPort);
  			}
  
  			if (this.testHost != null) {
  				result.getResultMap().put("echo_protocol_objective_host", this.testHost);
  			}
  
  			result.getResultMap().put(RESULT_TIMEOUT, timeout);
  
  			if (this.payload != null) {
  				result.getResultMap().put(AbstractEchoProtocolTask.PARAM_PAYLOAD, this.payload);
  			}
  
  			result.getResultMap().put(AbstractEchoProtocolTask.RESULT_PROTOCOL, AbstractEchoProtocolTask.PROTOCOL_TCP);
  
  			onEnd(result);
  		}
  	}
focal_method.class_method_signature: EchoProtocolTcpTask.call()
focal_method.full_signature: public QoSTestResult call()
focal_method.identifier: call
focal_method.invocations: initQoSTestResult onStart println getTestServerAddr getTestServerPort getSocket setSoTimeout nanoTime sendMessage readLine nanoTime put getResultMap close equals put getResultMap put getResultMap put getResultMap toString put getResultMap put getResultMap put getResultMap printStackTrace put getResultMap put getResultMap put getResultMap put getResultMap put getResultMap put getResultMap onEnd
focal_method.modifiers: public
focal_method.parameters: ()
focal_method.return: QoSTestResult
focal_method.signature: QoSTestResult call()