test_class.declarator: CORRECT_MESSAGE = "UDP payload!"
test_class.modifier: private static final
test_class.original_string: private static final String CORRECT_MESSAGE = "UDP payload!";
test_class.type: String
test_class.var_name: CORRECT_MESSAGE
test_class.declarator: WRONG_MESSAGE_ADDITIONAL_WHITESPACE = "UDP payload! "
test_class.modifier: private static final
test_class.original_string: private static final String WRONG_MESSAGE_ADDITIONAL_WHITESPACE = "UDP payload! ";
test_class.type: String
test_class.var_name: WRONG_MESSAGE_ADDITIONAL_WHITESPACE
test_class.declarator: WRONG_MESSAGE = "TCP payload!"
test_class.modifier: private static final
test_class.original_string: private static final String WRONG_MESSAGE = "TCP 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: 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.declarator: sendPacket
test_class.modifier: private
test_class.original_string: private DatagramPacket sendPacket;
test_class.type: DatagramPacket
test_class.var_name: sendPacket
test_class.declarator: toReturn
test_class.modifier: private
test_class.original_string: private InetAddress toReturn;
test_class.type: InetAddress
test_class.var_name: toReturn
test_class.file: RMBTClient/src/test/java/at/rtr/rmbt/client/v2/task/EchoProtocolUdpTaskTest.java
test_class.identifier: EchoProtocolUdpTaskTest
test_case.body: @Test
      public void testCorrectUdpEchoResponse(@Mocked final DatagramSocket mock, @Mocked final InetAddress inetAddress) throws Exception {
  
          new Expectations() {{
  
              // spoof the internet address (as we WILL get an UnknownHostException otherwise)
              InetAddress.getByName(anyString);
              result = toReturn;  //return loopback address
  
              // check the sent data for correctness, when send is called
              mock.send((DatagramPacket) any);
              result = new Delegate() {
                  void delegateMethod(DatagramPacket packet) {
                      sendPacket = packet;
                  }
              };
  
              //return the correct message
              mock.receive((DatagramPacket) any);
              result = new Delegate() {
                  void delegateMethod(DatagramPacket packet) {
                      packet.setData(CORRECT_MESSAGE.getBytes());
                  }
              };
  
          }};
  
          final EchoProtocolUdpTask task = new EchoProtocolUdpTask(qosTest, clientHolder.getTaskDescList().get(0), 0);
          final QoSTestResult res = task.call();
  
          assertEquals("Payload sent to server != " + CORRECT_MESSAGE, CORRECT_MESSAGE, new String(sendPacket.getData()));
          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_UDP, 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: EchoProtocolUdpTaskTest.testCorrectUdpEchoResponse(@Mocked final DatagramSocket mock, @Mocked final InetAddress inetAddress)
test_case.full_signature: @Test public void testCorrectUdpEchoResponse(@Mocked final DatagramSocket mock, @Mocked final InetAddress inetAddress)
test_case.identifier: testCorrectUdpEchoResponse
test_case.invocations: getByName send receive setData getBytes get getTaskDescList call assertEquals getData assertEquals get getResultMap assertEquals get getResultMap assertEquals get getResultMap assertEquals get getResultMap
test_case.modifiers: @Test public
test_case.parameters: (@Mocked final DatagramSocket mock, @Mocked final InetAddress inetAddress)
test_case.return: void
test_case.signature: void testCorrectUdpEchoResponse(@Mocked final DatagramSocket mock, @Mocked final InetAddress inetAddress)
focal_class.file: RMBTClient/src/main/java/at/rtr/rmbt/client/v2/task/EchoProtocolUdpTask.java
focal_class.identifier: EchoProtocolUdpTask
focal_class.class_method_signature: EchoProtocolUdpTask.EchoProtocolUdpTask(QualityOfServiceTest nnTest, TaskDesc taskDesc, int threadId)
focal_class.full_signature: public  EchoProtocolUdpTask(QualityOfServiceTest nnTest, TaskDesc taskDesc, int threadId)
focal_class.identifier: EchoProtocolUdpTask
focal_class.modifiers: public
focal_class.parameters: (QualityOfServiceTest nnTest, TaskDesc taskDesc, int threadId)
focal_class.signature:  EchoProtocolUdpTask(QualityOfServiceTest nnTest, TaskDesc taskDesc, int threadId)
focal_class.class_method_signature: EchoProtocolUdpTask.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);
  
  			if (testHost != null && testPort != null) {
  
  				try (final DatagramSocket socket = new DatagramSocket()) {
  					socket.connect(InetAddress.getByName(this.testHost), this.testPort);
  					socket.setSoTimeout((int) (this.timeout / 1e6));
  
  					final byte[] payloadBytes = payload.getBytes();
  
  					final DatagramPacket sendPacket = new DatagramPacket(payloadBytes, payloadBytes.length, InetAddress.getByName(this.testHost), this.testPort);
  					//increase the payload size to check for potentially added characters
  					final DatagramPacket receivePacket = new DatagramPacket(new byte[payloadBytes.length + 1], payloadBytes.length + 1);
  
  					final long startTime = System.nanoTime();
  					socket.send(sendPacket);
  					socket.receive(receivePacket);
  					final long duration = System.nanoTime() - startTime;
  
  					final String testResponse = new String(receivePacket.getData(), 0, receivePacket.getLength());
  					if (sendPacket.getLength() == receivePacket.getLength() && 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));
  
  					result.getResultMap().put(RESULT, testResponse);
  
  				} catch (SocketTimeoutException ex) {
  					result.getResultMap().put(RESULT_STATUS, "TIMEOUT");
  				} catch (Exception ex) {
  				    ex.printStackTrace();
  					result.getResultMap().put(RESULT_STATUS, "ERROR");
  				}
  
  			} else {
  				result.getResultMap().put(RESULT_STATUS, "ERROR");
  			}
  
  		} catch (final Exception ex) {
  			ex.printStackTrace();
  			result.getResultMap().put(RESULT_STATUS, "ERROR");
  		} 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);
  
  			result.getResultMap().put(AbstractEchoProtocolTask.PARAM_PAYLOAD, this.payload);
  
  			result.getResultMap().put(AbstractEchoProtocolTask.RESULT_PROTOCOL, AbstractEchoProtocolTask.PROTOCOL_UDP);
  
  			onEnd(result);
  		}
  
  		return result;
  		    
  	}
focal_method.class_method_signature: EchoProtocolUdpTask.call()
focal_method.full_signature: public QoSTestResult call()
focal_method.identifier: call
focal_method.invocations: initQoSTestResult onStart connect getByName setSoTimeout getBytes getByName nanoTime send receive nanoTime getData getLength getLength getLength equals put getResultMap put getResultMap put getResultMap toString put getResultMap put getResultMap printStackTrace 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()