@Nullable public SMTestProxy popSuite(final String suiteName) throws EmptyStackException {
  if (myStack.isEmpty()) {
    if (SMTestRunnerConnectionUtil.isInDebugMode()) {
      LOG.error("Pop error: Tests/suites stack is empty. Test runner tried to close test suite " + "which has been already closed or wasn't started at all. Unexpected suite name [" + suiteName + "]");
    }
    return null;
  }
  final SMTestProxy topSuite=myStack.peek();
  if (!suiteName.equals(topSuite.getName())) {
    if (SMTestRunnerConnectionUtil.isInDebugMode()) {
      LOG.error("Pop error: Unexpected closing suite. Expected [" + suiteName + "] but ["+ topSuite.getName()+ "] was found. Rest of stack: "+ getSuitePathPresentation());
    }
 else {
      SMTestProxy expectedProxy=null;
      for (      SMTestProxy candidateProxy : myStack) {
        if (suiteName.equals(candidateProxy.getName())) {
          expectedProxy=candidateProxy;
          break;
        }
      }
      if (expectedProxy != null) {
        SMTestProxy proxy=topSuite;
        while (proxy != expectedProxy) {
          proxy=myStack.pop();
        }
        return expectedProxy;
      }
 else {
        return null;
      }
    }
    return null;
  }
 else {
    myStack.pop();
  }
  return topSuite;
}

@ Nullable public SMTestProxy popSuite ( final String suiteName ) throws EmptyStackException { if ( myStack . isEmpty ( ) ) { if ( SMTestRunnerConnectionUtil . isInDebugMode ( ) ) { LOG . error ( "Pop error: Tests/suites stack is empty. Test runner tried to close test suite " + "which has been already closed or wasn't started at all. Unexpected suite name [" + suiteName + "]" ) ; } return null ; } final SMTestProxy topSuite = myStack . peek ( ) ; if ( ! suiteName . equals ( topSuite . getName ( ) ) ) { if ( SMTestRunnerConnectionUtil . isInDebugMode ( ) ) { LOG . error ( "Pop error: Unexpected closing suite. Expected [" + suiteName + "] but [" + topSuite . getName ( ) + "] was found. Rest of stack: " + getSuitePathPresentation ( ) ) ; } else { SMTestProxy expectedProxy = null ; for ( SMTestProxy candidateProxy : myStack ) { if ( suiteName . equals ( candidateProxy . getName ( ) ) ) { expectedProxy = candidateProxy ; break ; } } if ( expectedProxy != null ) { SMTestProxy proxy = topSuite ; while ( proxy != expectedProxy ) { proxy = myStack . pop ( ) ; } return expectedProxy ; } else { return null ; } } return null ; } else { myStack . pop ( ) ; } return topSuite ; }
pop element form stack and checks consistency
