test_class.declarator: loopback
test_class.modifier: private
test_class.original_string: private InetAddress loopback;
test_class.type: InetAddress
test_class.var_name: loopback
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: qosTest
test_class.modifier: private
test_class.original_string: private QualityOfServiceTest qosTest;
test_class.type: QualityOfServiceTest
test_class.var_name: qosTest
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: incomingTaskDesc
test_class.modifier: private
test_class.original_string: private TaskDesc incomingTaskDesc;
test_class.type: TaskDesc
test_class.var_name: incomingTaskDesc
test_class.file: RMBTClient/src/test/java/at/rtr/rmbt/client/v2/task/TcpTaskTest.java
test_class.identifier: TcpTaskTest
test_case.body: @Test
      public void testTcpOutgoingConnectionError (@Mocked final QoSControlConnection controlConnection,
                                          @Mocked final Socket socket) throws Exception {
  
          new Expectations() {{
  
              controlConnection.sendTaskCommand((AbstractQoSTask) any, withPrefix("TCPTEST OUT"), (ControlConnectionResponseCallback) any);
              result = new Delegate () {
                  public void delegateMethod (AbstractQoSTask qoSTask, String cmd, ControlConnectionResponseCallback callback) {
                      callback.onResponse("OK", cmd);
                  }
              };
  
              socket.getInputStream();
              result = new ConnectException("Forcefully thrown exception");
  
          }};
  
          final TcpTask tcpTask = new TcpTask(qosTest, clientHolder.getTaskDescList().get(0), 0);
          tcpTask.setControlConnection(controlConnection);
  
          final QoSTestResult res = tcpTask.call();
  
          assertEquals("Result did not return ERROR","ERROR", res.getResultMap().get(TcpTask.RESULT_OUT));
          assertEquals("Incorrect test out port", 80, res.getResultMap().get(TcpTask.RESULT_PORT_OUT));
      }
test_case.class_method_signature: TcpTaskTest.testTcpOutgoingConnectionError(@Mocked final QoSControlConnection controlConnection,
                                          @Mocked final Socket socket)
test_case.full_signature: @Test public void testTcpOutgoingConnectionError(@Mocked final QoSControlConnection controlConnection,
                                          @Mocked final Socket socket)
test_case.identifier: testTcpOutgoingConnectionError
test_case.invocations: sendTaskCommand withPrefix onResponse getInputStream get getTaskDescList setControlConnection call assertEquals get getResultMap assertEquals get getResultMap
test_case.modifiers: @Test public
test_case.parameters: (@Mocked final QoSControlConnection controlConnection,
                                          @Mocked final Socket socket)
test_case.return: void
test_case.signature: void testTcpOutgoingConnectionError(@Mocked final QoSControlConnection controlConnection,
                                          @Mocked final Socket socket)
focal_class.declarator: testPortOut
focal_class.modifier: private final
focal_class.original_string: private final Integer testPortOut;
focal_class.type: Integer
focal_class.var_name: testPortOut
focal_class.declarator: testPortIn
focal_class.modifier: private final
focal_class.original_string: private final Integer testPortIn;
focal_class.type: Integer
focal_class.var_name: testPortIn
focal_class.declarator: timeout
focal_class.modifier: private final
focal_class.original_string: private final long timeout;
focal_class.type: long
focal_class.var_name: timeout
focal_class.declarator: DEFAULT_TIMEOUT = 3000000000L
focal_class.modifier: private final static
focal_class.original_string: private final static long DEFAULT_TIMEOUT = 3000000000L;
focal_class.type: long
focal_class.var_name: DEFAULT_TIMEOUT
focal_class.declarator: PARAM_PORT_IN = "in_port"
focal_class.modifier: public final static
focal_class.original_string: public final static String PARAM_PORT_IN = "in_port";
focal_class.type: String
focal_class.var_name: PARAM_PORT_IN
focal_class.declarator: PARAM_PORT_OUT = "out_port"
focal_class.modifier: public final static
focal_class.original_string: public final static String PARAM_PORT_OUT = "out_port";
focal_class.type: String
focal_class.var_name: PARAM_PORT_OUT
focal_class.declarator: PARAM_TIMEOUT = "timeout"
focal_class.modifier: public final static
focal_class.original_string: public final static String PARAM_TIMEOUT = "timeout";
focal_class.type: String
focal_class.var_name: PARAM_TIMEOUT
focal_class.declarator: RESULT_PORT_IN = "tcp_objective_in_port"
focal_class.modifier: public final static
focal_class.original_string: public final static String RESULT_PORT_IN = "tcp_objective_in_port";
focal_class.type: String
focal_class.var_name: RESULT_PORT_IN
focal_class.declarator: RESULT_PORT_OUT = "tcp_objective_out_port"
focal_class.modifier: public final static
focal_class.original_string: public final static String RESULT_PORT_OUT = "tcp_objective_out_port";
focal_class.type: String
focal_class.var_name: RESULT_PORT_OUT
focal_class.declarator: RESULT_TIMEOUT = "tcp_objective_timeout"
focal_class.modifier: public final static
focal_class.original_string: public final static String RESULT_TIMEOUT = "tcp_objective_timeout";
focal_class.type: String
focal_class.var_name: RESULT_TIMEOUT
focal_class.declarator: RESULT_IN = "tcp_result_in"
focal_class.modifier: public final static
focal_class.original_string: public final static String RESULT_IN = "tcp_result_in";
focal_class.type: String
focal_class.var_name: RESULT_IN
focal_class.declarator: RESULT_OUT = "tcp_result_out"
focal_class.modifier: public final static
focal_class.original_string: public final static String RESULT_OUT = "tcp_result_out";
focal_class.type: String
focal_class.var_name: RESULT_OUT
focal_class.declarator: RESULT_RESPONSE_OUT = "tcp_result_out_response"
focal_class.modifier: public final static
focal_class.original_string: public final static String RESULT_RESPONSE_OUT = "tcp_result_out_response";
focal_class.type: String
focal_class.var_name: RESULT_RESPONSE_OUT
focal_class.declarator: RESULT_RESPONSE_IN = "tcp_result_in_response"
focal_class.modifier: public final static
focal_class.original_string: public final static String RESULT_RESPONSE_IN = "tcp_result_in_response";
focal_class.type: String
focal_class.var_name: RESULT_RESPONSE_IN
focal_class.file: RMBTClient/src/main/java/at/rtr/rmbt/client/v2/task/TcpTask.java
focal_class.identifier: TcpTask
focal_class.class_method_signature: TcpTask.TcpTask(QualityOfServiceTest nnTest, TaskDesc taskDesc, int threadId)
focal_class.full_signature: public  TcpTask(QualityOfServiceTest nnTest, TaskDesc taskDesc, int threadId)
focal_class.identifier: TcpTask
focal_class.modifiers: public
focal_class.parameters: (QualityOfServiceTest nnTest, TaskDesc taskDesc, int threadId)
focal_class.signature:  TcpTask(QualityOfServiceTest nnTest, TaskDesc taskDesc, int threadId)
focal_class.class_method_signature: TcpTask.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.class_method_signature: TcpTask.initTask()
focal_class.full_signature: @Override public void initTask()
focal_class.identifier: initTask
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void initTask()
focal_class.class_method_signature: TcpTask.getTestType()
focal_class.full_signature: public QosMeasurementType getTestType()
focal_class.identifier: getTestType
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: QosMeasurementType
focal_class.signature: QosMeasurementType getTestType()
focal_class.class_method_signature: TcpTask.needsQoSControlConnection()
focal_class.full_signature: public boolean needsQoSControlConnection()
focal_class.identifier: needsQoSControlConnection
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean needsQoSControlConnection()
focal_class.superclass: extends AbstractQoSTask
focal_method.body: public QoSTestResult call() throws Exception {
  		final QoSTestResult result = initQoSTestResult(QosMeasurementType.TCP);
  		try {
  			onStart(result);
  			
  			if (this.testPortIn != null) {
  				result.getResultMap().put(RESULT_IN, "FAILED");			
  			}
  			if (this.testPortOut != null) {
  				result.getResultMap().put(RESULT_OUT, "FAILED");			
  			}
  			
  			Socket socketIn = null;
  			
  			try {
  				System.out.println("TCPTASK: " + getTestServerAddr() + ":" + getTestServerPort());
  		    	
  		    	String response = null;
  		    	
  		    	if (this.testPortOut != null) {
  		    		//needed for timeout:
  		    		final CountDownLatch latch = new CountDownLatch(1);
  		    		
  		    		//response handler
  		    		final ControlConnectionResponseCallback callback = new ControlConnectionResponseCallback() {
  						
  						public void onResponse(final String response, final String request) {
  				    		if (response != null && response.startsWith("OK")) {
  				    			System.out.println("got response: " + response);
  				    			Socket socketOut = null;
  				    			
  				    			try {
  					    			socketOut = getSocket(getTestServerAddr(), testPortOut, false, (int)(timeout/1000000));
  					    			socketOut.setSoTimeout((int)(timeout/1000000));
  					    			sendMessage(socketOut, "PING\n");
  					    			final String testResponse = readLine(socketOut);
  								
  					    			System.out.println("TCP OUT TEST response: " + testResponse);
  								
  					    			result.getResultMap().put(RESULT_RESPONSE_OUT, testResponse);
  					    			socketOut.close();
  					    			result.getResultMap().put(RESULT_OUT, "OK");
  				    			}
  				    			catch (SocketTimeoutException e) {
  				    				result.getResultMap().put(RESULT_OUT, "TIMEOUT");
  				    			}
  				    			catch (Exception e) {
  				    				result.getResultMap().put(RESULT_OUT, "ERROR");
  				    			}
  				    			finally {
  					    			latch.countDown();
  				    			}
  				    		} else {
  				    			// we don't need to await the timeout on wrong response (and it shouldn't be a timeout)
  								result.getResultMap().put(RESULT_OUT, "ERROR");
  								latch.countDown();
  							}
  						}
  					};	    				
  		    		
  					sendCommand("TCPTEST OUT " + testPortOut, callback);
  					if(!latch.await(timeout, TimeUnit.NANOSECONDS)) {
  						result.getResultMap().put(RESULT_OUT, "TIMEOUT");
  					}
  		    	}
  				
  		    	if (this.testPortIn != null) {
  		    		try (ServerSocket serverSocket = new ServerSocket(testPortIn)) {
  						sendCommand("TCPTEST IN " + testPortIn, null);
  
  						serverSocket.setSoTimeout((int)(timeout/1000000));
  						socketIn = serverSocket.accept();
  						socketIn.setSoTimeout((int)(timeout/1000000));
  						response = readLine(socketIn);
  						System.out.println("TCP IN TEST response: " + response);						
  						result.getResultMap().put(RESULT_RESPONSE_IN, response);
  						socketIn.close();
  						result.getResultMap().put(RESULT_IN, "OK");	    				    			
  		    		}
  					catch (SocketTimeoutException e) {
  						result.getResultMap().put(RESULT_IN, "TIMEOUT");
  					}
  					catch (Exception e) {
  						result.getResultMap().put(RESULT_IN, "ERROR");
  					}
  		    	}
  				
  			}
  			catch (Exception e) {
  				e.printStackTrace();
  			}
  			
  			if (this.testPortIn != null) {
  				result.getResultMap().put(RESULT_PORT_IN, testPortIn);			
  			}
  
  			if (this.testPortOut != null) {
  				result.getResultMap().put(RESULT_PORT_OUT, testPortOut);	
  			}
  			
  			result.getResultMap().put(RESULT_TIMEOUT, timeout);
  			
  			return result;			
  		}
  		catch (Exception e)  {
  			throw e;
  		}
  		finally {
  			onEnd(result);
  		}
  	}
focal_method.class_method_signature: TcpTask.call()
focal_method.full_signature: public QoSTestResult call()
focal_method.identifier: call
focal_method.invocations: initQoSTestResult onStart put getResultMap put getResultMap println getTestServerAddr getTestServerPort startsWith println getSocket getTestServerAddr setSoTimeout sendMessage readLine println put getResultMap close put getResultMap put getResultMap put getResultMap countDown put getResultMap countDown sendCommand await put getResultMap sendCommand setSoTimeout accept setSoTimeout readLine println put getResultMap close put getResultMap put getResultMap put getResultMap printStackTrace put getResultMap put getResultMap put getResultMap onEnd
focal_method.modifiers: public
focal_method.parameters: ()
focal_method.return: QoSTestResult
focal_method.signature: QoSTestResult call()