◐ Shell
reader mode source ↗
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
* Copyright 2018 Philipp Salvisberg <philipp.salvisberg@trivadis.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -28,7 +28,6 @@
import org.springframework.jdbc.core.CallableStatementCallback;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.SingleConnectionDataSource;
import org.utplsql.sqldev.exception.GenericRuntimeException;
import org.utplsql.sqldev.model.StringTools;
import org.utplsql.sqldev.model.XMLTools;
import org.utplsql.sqldev.model.runner.Counter;
Expand Down Expand Up @@ -211,8 +210,8 @@ public String getHtmlCoverage(final String reporterId) {
rs.close();
return sb1.toString();
});
}
private RealtimeReporterEvent convert(final String itemType, final String text) {
logger.fine(() -> "\n---- " + itemType + " ----\n" + text);
try {
@@ -234,13 +233,15 @@ private RealtimeReporterEvent convert(final String itemType, final String text)
}
return event;
} catch (SAXException e) {
final String msg = "Parse error while processing " + itemType + " with content: " + text;
logger.severe(() -> msg);
throw new GenericRuntimeException(msg, e);
} catch (IOException e) {
final String msg = "I/O error while processing " + itemType + " with content: " + text;
logger.severe(() -> msg);
throw new GenericRuntimeException(msg, e);
}
}

Expand Down
96 changes: 59 additions & 37 deletions sqldev/src/main/java/org/utplsql/sqldev/ui/runner/RunnerPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,52 @@ private void runCodeCoverage(boolean selectedOnly) {
reporter.showParameterWindow();
}

@SuppressWarnings("DuplicatedCode")
private void initializeGUI() {
// Base panel containing all components
Expand Down @@ -767,45 +813,18 @@ private void initializeGUI() {
if (currentRun.getConsumerConn() != null) {
// Aborts JDBC Connection. Connection might still run in the background. That's expected.
DatabaseTools.abortConnection(currentRun.getConsumerConn());
for (Test test : currentRun.getTests().values()) {
if (test.getEndTime() == null && !test.isDisabled()) {
test.setDisabled(true);
test.getCounter().setDisabled(1);
test.getCounter().setWarning(1);
test.setWarnings(UtplsqlResources.getString("RUNNER_STOP_TEST_MESSAGE"));
test.setStartTime(null);
}
}
// recalculate counters and fix inconsistencies
currentRun.getCounter().setSuccess(0);
currentRun.getCounter().setFailure(0);
currentRun.getCounter().setError(0);
currentRun.getCounter().setDisabled(0);
currentRun.getCounter().setWarning(0);
for (Test test : currentRun.getTests().values()) {
if (test.isDisabled() && test.getCounter().getDisabled() == 0) {
test.getCounter().setDisabled(1);
}
if (test.getFailedExpectations() != null && !test.getFailedExpectations().isEmpty() && test.getCounter().getFailure() == 0) {
test.getCounter().setFailure(1);
}
if (test.getErrorStack() != null && test.getCounter().getError() == 0) {
test.getCounter().setError(1);
}
currentRun.getCounter().setSuccess(currentRun.getCounter().getSuccess() + test.getCounter().getSuccess());
currentRun.getCounter().setFailure(currentRun.getCounter().getFailure() + test.getCounter().getFailure());
currentRun.getCounter().setError(currentRun.getCounter().getError() + test.getCounter().getError());
currentRun.getCounter().setDisabled(currentRun.getCounter().getDisabled() + test.getCounter().getDisabled());
currentRun.getCounter().setWarning(currentRun.getCounter().getWarning() + test.getCounter().getWarning());
}
// terminate run
currentRun.setEndTime(UtplsqlRunner.getSysdate());
double now = (double) System.currentTimeMillis();
currentRun.setExecutionTime((now - currentRun.getStart()) / 1000);
currentRun.setCurrentTestNumber(0);
currentRun.setStatus(UtplsqlResources.getString("RUNNER_STOP_RUN_MESSAGE"));
// update run in GUI
update(currentRun.getReporterId());
}
});
stopButton.setEnabled(false);
Expand Down Expand Up @@ -871,6 +890,9 @@ private void initializeGUI() {
if (currentRun.getExecutionTime() != null) {
time.setSeconds(currentRun.getExecutionTime());
elapsedTimeTimer.stop();
} else {
final Double now = (double) System.currentTimeMillis();
time.setSeconds((now - currentRun.getStart()) / 1000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ RUNNER_CODE_COVERAGE_TOOLTIP=Rerun all tests with code coverage
RUNNER_STOP_TOOLTIP=Stops the consumer session of the current test run immediately, the JDBC connection might be closed delayed
RUNNER_STOP_TEST_MESSAGE=Test disabled due to abortion of the test run.
RUNNER_STOP_RUN_MESSAGE=Test run aborted.
RUNNER_CLEAR_BUTTON=Clear run history
RUNNER_TESTS_LABEL=Tests
RUNNER_FAILURES_LABEL=Failures
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ RUNNER_CODE_COVERAGE_TOOLTIP=Alle Tests mit Codeabdeckung ausf\u00fchren
RUNNER_STOP_TOOLTIP=Stoppt die Verbrauchersitzung des aktuellen Testlaufs, die JDBC-Verbindung wird m\00f6glicherweise verz\00fgert geschlossen
RUNNER_STOP_TEST_MESSAGE=Test wurde aufgrund eines Abbruchs des Testlaufs deaktiviert.
RUNNER_STOP_RUN_MESSAGE=Testlauf abgebrochen.
RUNNER_CLEAR_BUTTON=Run History l\u00f6schen
RUNNER_TESTS_LABEL=Tests
RUNNER_FAILURES_LABEL=Fehlschl\u00e4ge
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package org.utplsql.sqldev.test.runner;

import java.sql.Connection;
import java.util.Arrays;

import org.junit.After;
import org.junit.Assert;
Expand Down Expand Up @@ -110,31 +110,45 @@ public void setup() {
sb.append("END;");
jdbcTemplate.execute(sb.toString());
new CodeCoverageReporterTest().setup();
}

@After
public void teardown() {
executeAndIgnore(jdbcTemplate, "DROP PACKAGE junit_utplsql_test1_pkg");
new CodeCoverageReporterTest().teardown();
}

@Test
public void runTestsWithMaxTime() {
final SingleConnectionDataSource ds1 = new SingleConnectionDataSource();
ds1.setDriverClassName("oracle.jdbc.OracleDriver");
ds1.setUrl(dataSource.getUrl());
ds1.setUsername(dataSource.getUsername());
ds1.setPassword(dataSource.getPassword());
final Connection producerConn = DatabaseTools.getConnection(ds1);

final SingleConnectionDataSource ds2 = new SingleConnectionDataSource();
ds2.setDriverClassName("oracle.jdbc.OracleDriver");
ds2.setUrl(dataSource.getUrl());
ds2.setUsername(dataSource.getUsername());
ds2.setPassword(dataSource.getPassword());
final Connection consumerConn = DatabaseTools.getConnection(ds2);

UtplsqlRunner runner = new UtplsqlRunner(Arrays.asList(":a"), producerConn, consumerConn);
runner.runTestAsync();

SystemTools.waitForThread(runner.getProducerThread(), 200000);
Expand All @@ -146,27 +160,26 @@ public void runTestsWithMaxTime() {

@Test
public void runTestsWithCodeCoverage() {
final SingleConnectionDataSource ds1 = new SingleConnectionDataSource();
ds1.setDriverClassName("oracle.jdbc.OracleDriver");
ds1.setUrl(dataSource.getUrl());
ds1.setUsername(dataSource.getUsername());
ds1.setPassword(dataSource.getPassword());
final Connection producerConn = DatabaseTools.getConnection(ds1);

final SingleConnectionDataSource ds2 = new SingleConnectionDataSource();
ds2.setDriverClassName("oracle.jdbc.OracleDriver");
ds2.setUrl(dataSource.getUrl());
ds2.setUsername(dataSource.getUsername());
ds2.setPassword(dataSource.getPassword());
final Connection consumerConn = DatabaseTools.getConnection(ds2);

UtplsqlRunner runner = new UtplsqlRunner(Arrays.asList(":test_f"), null, null, null, producerConn, consumerConn);
runner.runTestAsync();

SystemTools.waitForThread(runner.getProducerThread(), 200000);
SystemTools.waitForThread(runner.getConsumerThread(), 200000);
SystemTools.sleep(4 * 1000);
Assert.assertNotNull(runner);
runner.dispose();
}
}
Toggle all file notes Toggle all file annotations