package org.utplsql.cli;

import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.utplsql.api.reporter.CoreReporters;

import java.util.List;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
 * Unit test for run command.
 *
 * @author philipp salivsberg
 */
class RunCommandIssue20IT {

    private static final Logger logger = LoggerFactory.getLogger(RunCommandIssue20IT.class);

    @Test
    void runLoop() {
        IRunCommand runCmd = TestHelper.createRunCommand(
                TestHelper.getConnectionString(),
                "-p=TEST_BETWNSTR.normal_case",
                "-f=ut_documentation_reporter",
                "--catch-ora-stuck");
        List<ReporterOptions> reporterOptionsList = runCmd.getReporterOptionsList();
        ReporterOptions reporterOptions1 = reporterOptionsList.get(0);
        assertEquals(CoreReporters.UT_DOCUMENTATION_REPORTER.name(), reporterOptions1.getReporterName());
        assertTrue(reporterOptions1.outputToScreen());
        // Loop in same JVM, uses a lot of new connections without closing existing ones, this might lead to 
        //   "Could not establish connection to database. Reason: IO Error: Got minus one from a read call"
        // before hitting the hanger at oracle.jdbc.driver.OracleStruct.getOracleAttributes(OracleStruct.java:347)
        // You may increase processes and implicitly sessions by "alter system set processes=1024 scope=spfile;"
        for (int i=0; i <= 120; i++) {
            logger.info("=======================");
            logger.info("Loop number " + i);
            logger.info("=======================");
            int result = runCmd.run();
            if (result != 0) {
                logger.error("Got an error during run. Return Code was " + result + "." );
                break;
            }
        }
    }

}
package org.utplsql.cli;

import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.utplsql.api.reporter.CoreReporters;

import java.util.List;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
 * Unit test for run command.
 *
 * @author philipp salivsberg
 */
class RunCommandIssue20IT {

    private static final Logger logger = LoggerFactory.getLogger(RunCommandIssue20IT.class);

    @Test
    void runLoop() {
        IRunCommand runCmd = TestHelper.createRunCommand(
                TestHelper.getConnectionString(),
                "-p=TEST_BETWNSTR.normal_case",
                "-f=ut_documentation_reporter",
                "--ora-stuck-timeout=3");
        List<ReporterOptions> reporterOptionsList = runCmd.getReporterOptionsList();
        ReporterOptions reporterOptions1 = reporterOptionsList.get(0);
        assertEquals(CoreReporters.UT_DOCUMENTATION_REPORTER.name(), reporterOptions1.getReporterName());
        assertTrue(reporterOptions1.outputToScreen());
        // Loop in same JVM, uses a lot of new connections without closing existing ones, this might lead to 
        //   "Could not establish connection to database. Reason: IO Error: Got minus one from a read call"
        // before hitting the hanger at oracle.jdbc.driver.OracleStruct.getOracleAttributes(OracleStruct.java:347)
        // You may increase processes and implicitly sessions by "alter system set processes=1024 scope=spfile;"
        for (int i=0; i <= 120; i++) {
            logger.info("=======================");
            logger.info("Loop number " + i);
            logger.info("=======================");
            int result = runCmd.run();
            if (result != 0) {
                logger.error("Got an error during run. Return Code was " + result + "." );
                break;
            }
        }
    }

}
Fix another test