+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.utplsql.sqldev.ui.runner
+
+import java.awt.Component
+import java.awt.Container
+import java.awt.Dimension
+import java.awt.FlowLayout
+import java.awt.Insets
+import javax.swing.JScrollPane
+import javax.swing.SwingUtilities
+
+/**
+ * FlowLayout subclass that fully supports wrapping of components.
+ * Converted to Xtend based on http://www.camick.com/java/source/WrapLayout.java
+ */
+class WrapLayout extends FlowLayout {
+
+ /**
+ * Constructs a new WrapLayout
with a left
+ * alignment and a default 5-unit horizontal and vertical gap.
+ */
+ new() {
+ super()
+ }
+
+ /**
+ * Constructs a new FlowLayout
with the specified
+ * alignment and a default 5-unit horizontal and vertical gap.
+ * The value of the alignment argument must be one of
+ * WrapLayout
, WrapLayout
,
+ * or WrapLayout
.
+ * @param align the alignment value
+ */
+ new(int align) {
+ super(align)
+ }
+
+ /**
+ * Creates a new flow layout manager with the indicated alignment
+ * and the indicated horizontal and vertical gaps.
+ *
+ * The value of the alignment argument must be one of
+ * WrapLayout
, WrapLayout
,
+ * or WrapLayout
.
+ * @param align the alignment value
+ * @param hgap the horizontal gap between components
+ * @param vgap the vertical gap between components
+ */
+ new(int align, int hgap, int vgap) {
+ super(align, hgap, vgap)
+ }
+
+ /**
+ * Returns the preferred dimensions for this layout given the
+ * visible components in the specified target container.
+ * @param target the component which needs to be laid out
+ * @return the preferred dimensions to lay out the
+ * subcomponents of the specified container
+ */
+ override Dimension preferredLayoutSize(Container target) {
+ return layoutSize(target, true)
+ }
+
+ /**
+ * Returns the minimum dimensions needed to layout the visible
+ * components contained in the specified target container.
+ * @param target the component which needs to be laid out
+ * @return the minimum dimensions to lay out the
+ * subcomponents of the specified container
+ */
+ override Dimension minimumLayoutSize(Container target) {
+ var Dimension minimum = layoutSize(target, false)
+ minimum.width -= (getHgap() + 1)
+ return minimum
+ }
+
+ /**
+ * Returns the minimum or preferred dimension needed to layout the target
+ * container.
+ * @param target target to get layout size for
+ * @param preferred should preferred size be calculated
+ * @return the dimension to layout the target container
+ */
+ def private Dimension layoutSize(Container target, boolean preferred) {
+ synchronized (target.getTreeLock()) {
+ // Each row must fit with the width allocated to the containter.
+ // When the container width = 0, the preferred width of the container
+ // has not yet been calculated so lets ask for the maximum.
+ var int targetWidth = target.getSize().width
+ var Container container = target
+ while (container.getSize().width === 0 && container.getParent() !== null) {
+ container = container.getParent()
+ }
+ targetWidth = container.getSize().width
+ if(targetWidth === 0) targetWidth = Integer.MAX_VALUE
+ var int hgap = getHgap()
+ var int vgap = getVgap()
+ var Insets insets = target.getInsets()
+ var int horizontalInsetsAndGap = insets.left + insets.right + (hgap * 2)
+ var int maxWidth = targetWidth - horizontalInsetsAndGap
+ // Fit components into the allowed width
+ var Dimension dim = new Dimension(0, 0)
+ var int rowWidth = 0
+ var int rowHeight = 0
+ var int nmembers = target.getComponentCount()
+ for (var int i = 0; i < nmembers; i++) {
+ var Component m = target.getComponent(i)
+ if (m.isVisible()) {
+ var Dimension d = if(preferred) m.getPreferredSize() else m.getMinimumSize()
+ // Can't add the component to current row. Start a new row.
+ if (rowWidth + d.width > maxWidth) {
+ addRow(dim, rowWidth, rowHeight)
+ rowWidth = 0
+ rowHeight = 0
+ }
+ // Add a horizontal gap for all components after the first
+ if (rowWidth !== 0) {
+ rowWidth += hgap
+ }
+ rowWidth += d.width
+ rowHeight = Math.max(rowHeight, d.height)
+ }
+ }
+ addRow(dim, rowWidth, rowHeight)
+ dim.width += horizontalInsetsAndGap
+ dim.height += insets.top + insets.bottom + vgap * 2
+ // When using a scroll pane or the DecoratedLookAndFeel we need to
+ // make sure the preferred size is less than the size of the
+ // target containter so shrinking the container size works
+ // correctly. Removing the horizontal gap is an easy way to do this.
+ var Container scrollPane = SwingUtilities.getAncestorOfClass(JScrollPane, target)
+ if (scrollPane !== null && target.isValid()) {
+ dim.width -= (hgap + 1)
+ }
+ return dim
+ }
+ }
+
+ /*
+ * A new row has been completed. Use the dimensions of this row
+ * to update the preferred size for the container.
+ *
+ * @param dim update the width and height when appropriate
+ * @param rowWidth the width of the row to add
+ * @param rowHeight the height of the row to add
+ */
+ def private void addRow(Dimension dim, int rowWidth, int rowHeight) {
+ dim.width = Math.max(dim.width, rowWidth)
+ if (dim.height > 0) {
+ dim.height += getVgap()
+ }
+ dim.height += rowHeight
+ }
+}
diff --git a/sqldev/src/main/resources/org/utplsql/sqldev/resources/UtplsqlResources.properties b/sqldev/src/main/resources/org/utplsql/sqldev/resources/UtplsqlResources.properties
index 8dfc8eaa..7d8005ac 100644
--- a/sqldev/src/main/resources/org/utplsql/sqldev/resources/UtplsqlResources.properties
+++ b/sqldev/src/main/resources/org/utplsql/sqldev/resources/UtplsqlResources.properties
@@ -6,13 +6,40 @@ EXTENSION_DESCRIPTION=Extension for running unit tests in SQL Developer.
EXTENSION_OWNER=Philipp Salvisberg
MIN_SQLDEV_VERSION=12.2.0.19.0.7
+# Icons
+UTPLSQL_ICON=/org/utplsql/sqldev/resources/images/utPLSQL.png
+SUCCESS_ICON=/org/utplsql/sqldev/resources/images/success.png
+ERROR_ICON=/org/utplsql/sqldev/resources/images/error.png
+FAILURE_ICON=/org/utplsql/sqldev/resources/images/failure.png
+DISABLED_ICON=/org/utplsql/sqldev/resources/images/disabled.png
+WARNING_ICON=/org/utplsql/sqldev/resources/images/warning.png
+INFO_ICON=/org/utplsql/sqldev/resources/images/info.png
+REFRESH_ICON=/org/utplsql/sqldev/resources/images/refresh.png
+RUN_ICON=/org/utplsql/sqldev/resources/images/run.png
+RUN_WORKSHEET_ICON=/org/utplsql/sqldev/resources/images/run_worksheet.png
+CLEAR_ICON=/org/utplsql/sqldev/resources/images/clear.png
+CHECKMARK_ICON=/org/utplsql/sqldev/resources/images/checkmark.png
+STATUS_ICON=/org/utplsql/sqldev/resources/images/status.png
+# progress.gif - the animated version - does not work
+PROGRESS_ICON=/org/utplsql/sqldev/resources/images/progress.png
+
# Translatable text
PREF_LABEL=utPLSQL
+PREF_USE_REALTIME_REPORTER_LABEL=Use realtime reporter?
PREF_UNSHARED_WORKSHEET_LABEL=Open an unshared worksheet?
PREF_RESET_PACKAGE_LABEL=Reset package before running utPLSQL?
PREF_CLEAR_SCREEN_LABEL=Clear script output panel before running utPLSQL?
PREF_AUTO_EXECUTE_LABEL=Execute unit test automatically?
-PREF_CHECK_RUN_UTPLSQL_TEST_LABEL=Check availability of "Run utPLSQL test" menu option?
+PREF_CHECK_RUN_UTPLSQL_TEST_LABEL=Check availability of menu option?
+MENU_REALTIME_REPORTER_LABEL=Realtime Reporter
+PREF_NUMBER_OF_RUNS_IN_HISTORY_LABEL=Number of runs in history
+PREF_SHOW_DISABLED_COUNTER_LABEL=Show disabled counter?
+PREF_SHOW_WARNINGS_COUNTER_LABEL=Show warnings counter?
+PREF_SHOW_INFO_COUNTER_LABEL=Show info counter?
+PREF_SHOW_WARNING_INDICATOR_LABEL=Show warning indicator?
+PREF_SHOW_INFO_INDICATOR_LABEL=Show info indicator?
+PREF_SHOW_TEST_DESCRIPTION_LABEL=Show description (if present)?
+PREF_SYNC_DETAIL_TAB_LABEL=Synchronize detail tab based on test status?
PREF_TEST_PACKAGE_PREFIX_LABEL=Test package prefix
PREF_TEST_PACKAGE_SUFFIX_LABEL=Test package suffix
PREF_TEST_UNIT_PREFIX_LABEL=Test unit prefix
@@ -22,7 +49,7 @@ PREF_GENERATE_COMMENTS_LABEL=Generate comments?
PREF_DISABLE_TESTS_LABEL=Disable tests?
PREF_SUITE_PATH_LABEL=Suite path
PREF_INDENT_SPACES_LABEL=Indent spaces
-PREF_CHECK_GENERATE_UTPLSQL_TEST_LABEL=Check availability of "Generate utPLSQL test" menu option?
+PREF_CHECK_GENERATE_UTPLSQL_TEST_LABEL=Check availability of menu option?
PREF_CREATE_CODE_TEMPLATES_BUTTON_LABEL=Create code templates
PREF_ROOT_FOLDER_IN_ODDGEN_VIEW_LABEL=Root folder in Generators view
PREF_GENERATE_FILES_LABEL=Generate files?
@@ -40,3 +67,33 @@ WINDOW_EXCLUDE_OBJECS_LABEL=Exclude objects
WINDOW_RUN_BUTTON=Run
WINDOW_CANCEL_BUTTON=Cancel
WORKSHEET_TITLE=utPLSQL
+RUNNER_VIEW_TITLE=utPLSQL
+RUNNER_REFRESH_TOOLTIP=Reset ordering and refresh
+RUNNER_RERUN_TOOLTIP=Rerun all tests
+RUNNER_CLEAR_BUTTON=Clear history
+RUNNER_RERUN_WORKSHEET_TOOLTIP=Rerun all tests in a new worksheet
+RUNNER_TESTS_LABEL=Tests
+RUNNER_FAILURES_LABEL=Failures
+RUNNER_ERRORS_LABEL=Errors
+RUNNER_DISABLED_LABEL=Disabled
+RUNNER_WARNINGS_LABEL=Warnings
+RUNNER_INFO_LABEL=Info
+RUNNER_INITIALIZING_TEXT=Initializing...
+RUNNER_RUNNING_TEXT=Running tests...
+RUNNER_FINNISHED_TEXT=Finished after %.3f seconds.
+RUNNER_NO_TESTS_FOUND_TEXT=No tests found.
+RUNNER_RUN_MENUITEM=Run test
+RUNNER_RUN_WORKSHEET_MENUITEM=Run test in new worksheet
+RUNNER_TEST_ID_COLUMN=Suitepath
+RUNNER_TEST_EXECUTION_TIME_COLUMN=Time [s]
+RUNNER_OWNER_LABEL=Owner
+RUNNER_PACKAGE_LABEL=Package
+RUNNER_PROCEDURE_LABEL=Procedure
+RUNNER_DESCRIPTION_LABEL=Description
+RUNNER_START_LABEL=Start
+RUNNER_ASSERT_DESCRIPTION_COLUMN=Assert description (failed line)
+RUNNER_TEST_TAB_LABEL=Test
+RUNNER_FAILURES_TAB_LABEL=Failures
+RUNNER_ERRORS_TAB_LABEL=Errors
+RUNNER_WARNINGS_TAB_LABEL=Warnings
+RUNNER_INFO_TAB_LABEL=Info
diff --git a/sqldev/src/main/resources/org/utplsql/sqldev/resources/UtplsqlResources_de.properties b/sqldev/src/main/resources/org/utplsql/sqldev/resources/UtplsqlResources_de.properties
index 3fe1fa2d..8d1d7293 100644
--- a/sqldev/src/main/resources/org/utplsql/sqldev/resources/UtplsqlResources_de.properties
+++ b/sqldev/src/main/resources/org/utplsql/sqldev/resources/UtplsqlResources_de.properties
@@ -2,11 +2,21 @@
# Translatable text
PREF_LABEL=utPLSQL
+PREF_USE_REALTIME_REPORTER_LABEL=Realtime Reporter verwenden?
PREF_UNSHARED_WORKSHEET_LABEL=Arbeitsblatt mit eigener Verbindung öffnen?
PREF_RESET_PACKAGE_LABEL=Package vor der Ausführung von utPLSQL zurücksetzen?
PREF_CLEAR_SCREEN_LABEL=Skriptausgabe-Fenster vor der Ausführung von utPLSQL leeren?
PREF_AUTO_EXECUTE_LABEL=Unit Test automatisch ausführen?
-PREF_CHECK_RUN_UTPLSQL_TEST_LABEL=Verfügbarkeit der Menüoption "utPLSQL Test ausführen" prüfen?
+PREF_CHECK_RUN_UTPLSQL_TEST_LABEL=Verfügbarkeit der Menüoption prüfen?
+MENU_REALTIME_REPORTER_LABEL=Realtime Reporter
+PREF_NUMBER_OF_RUNS_IN_HISTORY_LABEL=Anzahl Ausführungen in der Historie
+PREF_SHOW_DISABLED_COUNTER_LABEL=Deaktiviert-Zähler anzeigen?
+PREF_SHOW_WARNINGS_COUNTER_LABEL=Warnungen-Zähler anzeigen?
+PREF_SHOW_INFO_COUNTER_LABEL=Info-Zähler anzeigen?
+PREF_SHOW_WARNING_INDICATOR_LABEL=Warnung-Indikator anzeigen?
+PREF_SHOW_INFO_INDICATOR_LABEL=Info-Indikator anzeigen?
+PREF_SHOW_TEST_DESCRIPTION_LABEL=Beschreibung anzeigen (falls vorhanden)?
+PREF_SYNC_DETAIL_TAB_LABEL=Detailansicht basierend auf dem Teststatus synchronisieren?
PREF_TEST_PACKAGE_PREFIX_LABEL=Test Package Präfix
PREF_TEST_PACKAGE_SUFFIX_LABEL=Test Package Suffix
PREF_TEST_UNIT_PREFIX_LABEL=Test Unit Präfix
@@ -16,7 +26,7 @@ PREF_GENERATE_COMMENTS_LABEL=Kommentare generieren?
PREF_DISABLE_TESTS_LABEL=Tests deaktivieren?
PREF_SUITE_PATH_LABEL=Suite-Pfad
PREF_INDENT_SPACES_LABEL=Einrückungsleerzeichen
-PREF_CHECK_GENERATE_UTPLSQL_TEST_LABEL=Verfügbarkeit der Menüoption "utPLSQL Test generieren" prüfen?
+PREF_CHECK_GENERATE_UTPLSQL_TEST_LABEL=Verfügbarkeit der Menüoption prüfen?
PREF_CREATE_CODE_TEMPLATES_BUTTON_LABEL=Codevorlagen erstellen
PREF_ROOT_FOLDER_IN_ODDGEN_VIEW_LABEL=Hauptverzeichnis in Generatoren Ansicht
PREF_GENERATE_FILES_LABEL=Dateien generieren?
@@ -34,3 +44,33 @@ WINDOW_EXCLUDE_OBJECS_LABEL=Exkludierte Objekte
WINDOW_RUN_BUTTON=Start
WINDOW_CANCEL_BUTTON=Abbrechen
WORKSHEET_TITLE=utPLSQL
+RUNNER_VIEW_TITLE=utPLSQL
+RUNNER_REFRESH_TOOLTIP=Sortierung zurücksetzen und aktualisieren
+RUNNER_RERUN_TOOLTIP=Alle Tests erneut ausführen
+RUNNER_RERUN_WORKSHEET_TOOLTIP=Alle Tests in einem neuen Arbeitsblatt erneut ausführen
+RUNNER_CLEAR_BUTTON=History löschen
+RUNNER_TESTS_LABEL=Tests
+RUNNER_FAILURES_LABEL=Fehlschläge
+RUNNER_ERRORS_LABEL=Fehler
+RUNNER_DISABLED_LABEL=Deaktiviert
+RUNNER_WARNINGS_LABEL=Warnungen
+RUNNER_INFO_LABEL=Info
+RUNNER_INITIALIZING_TEXT=Initialisierung...
+RUNNER_RUNNING_TEXT=Starte Tests...
+RUNNER_FINNISHED_TEXT=Beendet nach %.3f Sekunden.
+RUNNER_NO_TESTS_FOUND_TEXT=Keine Tests gefunden.
+RUNNER_RUN_MENUITEM=Run testTest ausführen
+RUNNER_RUN_WORKSHEET_MENUITEM=Test in neuem Arbeitsblatt ausführuen
+RUNNER_TEST_ID_COLUMN_NAME=Suitepath
+RUNNER_TEST_EXECUTION_TIME_COLUMN_NAME=Zeit [s]
+RUNNER_OWNER_LABEL=Besitzer
+RUNNER_PACKAGE_LABEL=Paket
+RUNNER_PROCEDURE_LABEL=Prozedur
+RUNNER_DESCRIPTION_LABEL=Beschreibung
+RUNNER_START_LABEL=Start
+RUNNER_ASSERT_DESCRIPTION_COLUMN_NAME=Assert Beschreibung (gescheiterte Zeile)
+RUNNER_TEST_TAB_LABEL=Test
+RUNNER_FAILURES_TAB_LABEL=Misserfolge
+RUNNER_ERRORS_TAB_LABEL=Fehler
+RUNNER_WARNINGS_TAB_LABEL=Warnungen
+RUNNER_INFO_TAB_LABEL=Info
diff --git a/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/checkmark.png b/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/checkmark.png
new file mode 100644
index 00000000..c17f9beb
Binary files /dev/null and b/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/checkmark.png differ
diff --git a/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/clear.png b/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/clear.png
new file mode 100644
index 00000000..7132e95c
Binary files /dev/null and b/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/clear.png differ
diff --git a/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/disabled.png b/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/disabled.png
new file mode 100644
index 00000000..b2afa029
Binary files /dev/null and b/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/disabled.png differ
diff --git a/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/disabled_32x32.png b/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/disabled_32x32.png
new file mode 100644
index 00000000..3fcb0ca6
Binary files /dev/null and b/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/disabled_32x32.png differ
diff --git a/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/error.png b/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/error.png
new file mode 100644
index 00000000..aefaed04
Binary files /dev/null and b/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/error.png differ
diff --git a/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/error_32x32.png b/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/error_32x32.png
new file mode 100644
index 00000000..91278fb8
Binary files /dev/null and b/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/error_32x32.png differ
diff --git a/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/failure.png b/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/failure.png
new file mode 100644
index 00000000..27bc6d87
Binary files /dev/null and b/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/failure.png differ
diff --git a/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/failure_32x32.png b/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/failure_32x32.png
new file mode 100644
index 00000000..ed3ecc10
Binary files /dev/null and b/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/failure_32x32.png differ
diff --git a/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/info.png b/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/info.png
new file mode 100644
index 00000000..eaf2ead8
Binary files /dev/null and b/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/info.png differ
diff --git a/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/progress.gif b/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/progress.gif
new file mode 100644
index 00000000..3356ba3e
Binary files /dev/null and b/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/progress.gif differ
diff --git a/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/progress.png b/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/progress.png
new file mode 100644
index 00000000..ab2c3673
Binary files /dev/null and b/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/progress.png differ
diff --git a/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/progress_32x32.png b/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/progress_32x32.png
new file mode 100644
index 00000000..1110463b
Binary files /dev/null and b/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/progress_32x32.png differ
diff --git a/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/refresh.png b/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/refresh.png
new file mode 100644
index 00000000..2aebd50a
Binary files /dev/null and b/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/refresh.png differ
diff --git a/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/run.png b/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/run.png
new file mode 100644
index 00000000..eebce3a8
Binary files /dev/null and b/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/run.png differ
diff --git a/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/run_worksheet.png b/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/run_worksheet.png
new file mode 100644
index 00000000..7a00f3b9
Binary files /dev/null and b/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/run_worksheet.png differ
diff --git a/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/status.png b/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/status.png
new file mode 100644
index 00000000..f6d3dd70
Binary files /dev/null and b/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/status.png differ
diff --git a/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/success.png b/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/success.png
new file mode 100644
index 00000000..525198af
Binary files /dev/null and b/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/success.png differ
diff --git a/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/success_32x32.png b/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/success_32x32.png
new file mode 100644
index 00000000..efb200a3
Binary files /dev/null and b/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/success_32x32.png differ
diff --git a/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/terminated_32x32.png b/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/terminated_32x32.png
new file mode 100644
index 00000000..defbbff7
Binary files /dev/null and b/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/terminated_32x32.png differ
diff --git a/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/utPLSQL.png b/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/utPLSQL.png
index c1d9b945..5014d77c 100644
Binary files a/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/utPLSQL.png and b/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/utPLSQL.png differ
diff --git a/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/utPLSQL_400x400.png b/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/utPLSQL_400x400.png
index 49f54b2b..0e784ddc 100644
Binary files a/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/utPLSQL_400x400.png and b/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/utPLSQL_400x400.png differ
diff --git a/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/warning.png b/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/warning.png
new file mode 100644
index 00000000..63e614db
Binary files /dev/null and b/sqldev/src/main/resources/org/utplsql/sqldev/resources/images/warning.png differ
diff --git a/sqldev/src/test/java/org/utplsql/sqldev/tests/AbstractJdbcTest.xtend b/sqldev/src/test/java/org/utplsql/sqldev/test/AbstractJdbcTest.xtend
similarity index 98%
rename from sqldev/src/test/java/org/utplsql/sqldev/tests/AbstractJdbcTest.xtend
rename to sqldev/src/test/java/org/utplsql/sqldev/test/AbstractJdbcTest.xtend
index 5341fb3f..015885e0 100644
--- a/sqldev/src/test/java/org/utplsql/sqldev/tests/AbstractJdbcTest.xtend
+++ b/sqldev/src/test/java/org/utplsql/sqldev/test/AbstractJdbcTest.xtend
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.utplsql.sqldev.tests
+package org.utplsql.sqldev.test
import java.io.StringReader
import java.util.ArrayList
diff --git a/sqldev/src/test/java/org/utplsql/sqldev/test/PrefixToolsTest.xtend b/sqldev/src/test/java/org/utplsql/sqldev/test/PrefixToolsTest.xtend
new file mode 100644
index 00000000..8c7d7760
--- /dev/null
+++ b/sqldev/src/test/java/org/utplsql/sqldev/test/PrefixToolsTest.xtend
@@ -0,0 +1,43 @@
+package org.utplsql.sqldev.test
+
+import org.junit.Assert
+import org.junit.Test
+import org.utplsql.sqldev.model.PrefixTools
+
+class PrefixToolsTest {
+ @Test
+ def void two() {
+ val actual = PrefixTools.commonPrefix(#["junit.test.a", "junit.test.b"])
+ val expected = "junit.test."
+ Assert.assertEquals(expected, actual)
+ }
+
+ @Test
+ def void oneWithDot() {
+ val actual = PrefixTools.commonPrefix(#["junit.test.a"])
+ val expected = "junit.test."
+ Assert.assertEquals(expected, actual)
+ }
+
+ @Test
+ def void oneWithoutDot() {
+ val actual = PrefixTools.commonPrefix(#["junit-test-a"])
+ val expected = ""
+ Assert.assertEquals(expected, actual)
+ }
+
+ @Test
+ def void twoOverlapLeft() {
+ val actual = PrefixTools.commonPrefix(#["a.b.c", "a.b.c.d"])
+ val expected = ""
+ Assert.assertEquals(expected, actual)
+ }
+
+ @Test
+ def void twoOverlapRight() {
+ val actual = PrefixTools.commonPrefix(#["a.b.c.d", "a.b.c"])
+ val expected = ""
+ Assert.assertEquals(expected, actual)
+ }
+
+}
\ No newline at end of file
diff --git a/sqldev/src/test/java/org/utplsql/sqldev/tests/ResourceTest.xtend b/sqldev/src/test/java/org/utplsql/sqldev/test/ResourceTest.xtend
similarity index 93%
rename from sqldev/src/test/java/org/utplsql/sqldev/tests/ResourceTest.xtend
rename to sqldev/src/test/java/org/utplsql/sqldev/test/ResourceTest.xtend
index c09751b3..d283cb5d 100644
--- a/sqldev/src/test/java/org/utplsql/sqldev/tests/ResourceTest.xtend
+++ b/sqldev/src/test/java/org/utplsql/sqldev/test/ResourceTest.xtend
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.utplsql.sqldev.tests
+package org.utplsql.sqldev.test
import org.junit.Assert
import org.junit.Test
@@ -22,7 +22,7 @@ import org.utplsql.sqldev.resources.UtplsqlResources
class ResourceTest {
@Test
- def void testWindowPathsLabel() {
+ def void windowPathsLabel() {
val actual = UtplsqlResources.getString("WINDOW_PATHS_LABEL")
val expected = "utPLSQL paths"
Assert.assertEquals(expected, actual)
diff --git a/sqldev/src/test/java/org/utplsql/sqldev/test/UrlToolsTest.xtend b/sqldev/src/test/java/org/utplsql/sqldev/test/UrlToolsTest.xtend
new file mode 100644
index 00000000..1ee8f4ac
--- /dev/null
+++ b/sqldev/src/test/java/org/utplsql/sqldev/test/UrlToolsTest.xtend
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2018 Philipp Salvisberg
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.utplsql.sqldev.test
+
+import org.junit.Assert
+import org.junit.Test
+import org.utplsql.sqldev.model.URLTools
+
+class UrlToolsTest {
+ val extension URLTools urlTools = new URLTools
+
+ @Test
+ def void replacePlusSign() {
+ Assert.assertEquals("+", "%2B".replaceHexChars)
+ Assert.assertEquals("++", "%2B%2B".replaceHexChars)
+ Assert.assertEquals("abc+%xyz", "abc%2B%xyz".replaceHexChars)
+ }
+
+ @Test
+ def void replaceAtSign() {
+ Assert.assertEquals("@", "%40".replaceHexChars)
+ Assert.assertEquals("@@", "%40%40".replaceHexChars)
+ Assert.assertEquals("abc@%xyz", "abc%40%xyz".replaceHexChars)
+ }
+
+ @Test
+ def void replaceAtAndPlusSign() {
+ Assert.assertEquals("@+", "%40%2B".replaceHexChars)
+ Assert.assertEquals("@+@+", "%40%2B%40%2B".replaceHexChars)
+ Assert.assertEquals("abc@+%xyz", "abc%40%2B%xyz".replaceHexChars)
+ }
+
+}
diff --git a/sqldev/src/test/java/org/utplsql/sqldev/tests/CodeCoverageReporterWindowTest.xtend b/sqldev/src/test/java/org/utplsql/sqldev/test/coverage/CodeCoverageReporterDialogTest.xtend
similarity index 74%
rename from sqldev/src/test/java/org/utplsql/sqldev/tests/CodeCoverageReporterWindowTest.xtend
rename to sqldev/src/test/java/org/utplsql/sqldev/test/coverage/CodeCoverageReporterDialogTest.xtend
index 333d69bc..a11c6b20 100644
--- a/sqldev/src/test/java/org/utplsql/sqldev/tests/CodeCoverageReporterWindowTest.xtend
+++ b/sqldev/src/test/java/org/utplsql/sqldev/test/coverage/CodeCoverageReporterDialogTest.xtend
@@ -13,18 +13,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.utplsql.sqldev.tests
+package org.utplsql.sqldev.test.coverage
import org.junit.Test
-import org.utplsql.sqldev.CodeCoverageReporter
+import org.utplsql.sqldev.coverage.CodeCoverageReporter
+import org.utplsql.sqldev.test.AbstractJdbcTest
-class CodeCoverageReporterWindowTest extends AbstractJdbcTest{
+class CodeCoverageReporterDialogTest extends AbstractJdbcTest{
@Test
- def void layoutTest() {
+ def void layout() {
val reporter = new CodeCoverageReporter(#["SCOTT"], #['a', 'b', 'c'], dataSource.connection)
reporter.showParameterWindow
- Thread.sleep(2 * 1000)
+ Thread.sleep(4 * 1000)
+ reporter.frame.exit
}
}
\ No newline at end of file
diff --git a/sqldev/src/test/java/org/utplsql/sqldev/test/coverage/CodeCoverageReporterTest.xtend b/sqldev/src/test/java/org/utplsql/sqldev/test/coverage/CodeCoverageReporterTest.xtend
new file mode 100644
index 00000000..7f91d53b
--- /dev/null
+++ b/sqldev/src/test/java/org/utplsql/sqldev/test/coverage/CodeCoverageReporterTest.xtend
@@ -0,0 +1,113 @@
+/*
+ * Copyright 2018 Philipp Salvisberg
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.utplsql.sqldev.test.coverage
+
+import java.io.File
+import java.nio.charset.StandardCharsets
+import java.nio.file.Files
+import java.nio.file.Path
+import java.util.Comparator
+import org.junit.AfterClass
+import org.junit.Assert
+import org.junit.BeforeClass
+import org.junit.Test
+import org.springframework.jdbc.BadSqlGrammarException
+import org.springframework.jdbc.datasource.SingleConnectionDataSource
+import org.utplsql.sqldev.coverage.CodeCoverageReporter
+import org.utplsql.sqldev.test.AbstractJdbcTest
+
+class CodeCoverageReporterTest extends AbstractJdbcTest{
+
+ @BeforeClass
+ def static void setup() {
+ jdbcTemplate.execute('''
+ CREATE OR REPLACE FUNCTION f RETURN INTEGER IS
+ BEGIN
+ RETURN 1;
+ END f;
+ ''')
+ jdbcTemplate.execute('''
+ CREATE OR REPLACE PACKAGE test_f IS
+ --%suite
+
+ --%test
+ PROCEDURE f;
+ END test_f;
+ ''')
+ jdbcTemplate.execute('''
+ CREATE OR REPLACE PACKAGE BODY test_f IS
+ --%test
+ PROCEDURE f IS
+ l_expected INTEGER := 1;
+ l_actual INTEGER;
+ BEGIN
+ l_actual := scott.f();
+ ut.expect(l_actual).to_equal(l_expected);
+ END f;
+ END test_f;
+ ''')
+ }
+
+ private def Path getNewestOutputFile() {
+ val file = File.createTempFile("test", ".txt")
+ val dir = file.parentFile
+ file.delete
+ val last = Files.list(dir.toPath)
+ .filter([f | !f.toFile.directory])
+ .filter([f | f.fileName.toString.startsWith("utplsql_")])
+ .filter([f | f.fileName.toString.endsWith(".html")])
+ .max(Comparator.comparingLong([f|f.toFile().lastModified()]))
+ return last.get
+ }
+
+ @Test
+ def void produceReportAndCloseConnection() {
+ // create temporary dataSource, closed by reporter
+ var ds = new SingleConnectionDataSource()
+ ds.driverClassName = "oracle.jdbc.OracleDriver"
+ ds.url = dataSource.url
+ ds.username = dataSource.username
+ ds.password = dataSource.password
+ val conn = ds.connection
+ val pathList=#[':test_f']
+ val includeObjectList = #['f']
+ val reporter = new CodeCoverageReporter(pathList, includeObjectList, conn)
+ val run = reporter.runAsync
+ run.join(20000)
+ Assert.assertEquals(true, conn.isClosed)
+ val outputFile = getNewestOutputFile
+ Assert.assertTrue(outputFile !== null)
+ val content = new String(Files.readAllBytes(outputFile), StandardCharsets.UTF_8)
+ Assert.assertTrue(content.contains('SCOTT.F
100 % lines covered
'))
+ }
+
+ @AfterClass
+ def static void teardown() {
+ try {
+ jdbcTemplate.execute("DROP PACKAGE test_f")
+ } catch (BadSqlGrammarException e) {
+ // ignore
+ }
+ try {
+ jdbcTemplate.execute("DROP FUNCTION f")
+ } catch (BadSqlGrammarException e) {
+ // ignore
+ }
+ }
+
+
+
+}
\ No newline at end of file
diff --git a/sqldev/src/test/java/org/utplsql/sqldev/test/dal/DalBugFixTest.xtend b/sqldev/src/test/java/org/utplsql/sqldev/test/dal/DalBugFixTest.xtend
new file mode 100644
index 00000000..d53fe158
--- /dev/null
+++ b/sqldev/src/test/java/org/utplsql/sqldev/test/dal/DalBugFixTest.xtend
@@ -0,0 +1,107 @@
+/*
+ * Copyright 2018 Philipp Salvisberg
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ package org.utplsql.sqldev.test.dal
+
+import org.junit.AfterClass
+import org.junit.Assert
+import org.junit.BeforeClass
+import org.junit.Test
+import org.springframework.jdbc.BadSqlGrammarException
+import org.utplsql.sqldev.dal.UtplsqlDao
+import org.utplsql.sqldev.test.AbstractJdbcTest
+
+class DalBugFixTest extends AbstractJdbcTest {
+
+ @BeforeClass
+ @AfterClass
+ def static void setupAndTeardown() {
+ try {
+ jdbcTemplate.execute("DROP PACKAGE junit_utplsql_test_pkg")
+ } catch (BadSqlGrammarException e) {
+ // ignore
+ }
+ }
+
+ @Test
+ // https://github.com/utPLSQL/utPLSQL-SQLDeveloper/issues/54
+ def void issue54FolderIconForSuitesWithoutTests() {
+ setupAndTeardown
+ jdbcTemplate.execute('''
+ CREATE OR REPLACE PACKAGE junit_utplsql_test_pkg IS
+ -- %suite
+
+ END junit_utplsql_test_pkg;
+ ''')
+ val dao = new UtplsqlDao(dataSource.connection)
+ val actualNodes = dao.runnables()
+ Assert.assertEquals(4, actualNodes.size)
+ val pkg = actualNodes.findFirst[it.id == "SCOTT:junit_utplsql_test_pkg"]
+ Assert.assertEquals("FOLDER_ICON", pkg.iconName)
+ jdbcTemplate.execute("DROP PACKAGE junit_utplsql_test_pkg")
+ }
+
+ @Test
+ // https://github.com/utPLSQL/utPLSQL-SQLDeveloper/issues/54
+ def void issue54PackageIconForSuitesWithTests() {
+ setupAndTeardown
+ jdbcTemplate.execute('''
+ CREATE OR REPLACE PACKAGE junit_utplsql_test_pkg IS
+ -- %suite
+
+ -- %test
+ PROCEDURE t1;
+
+ END junit_utplsql_test_pkg;
+ ''')
+ val dao = new UtplsqlDao(dataSource.connection)
+ val actualNodes = dao.runnables()
+ Assert.assertEquals(6, actualNodes.size)
+ val pkg = actualNodes.findFirst[it.id == "SCOTT:junit_utplsql_test_pkg"]
+ Assert.assertEquals("PACKAGE_ICON", pkg.iconName)
+ jdbcTemplate.execute("DROP PACKAGE junit_utplsql_test_pkg")
+ }
+
+ @Test
+ // https://github.com/utPLSQL/utPLSQL-SQLDeveloper/issues/55
+ def void issue55SuiteWithoutTests() {
+ setupAndTeardown
+ jdbcTemplate.execute('''
+ CREATE OR REPLACE PACKAGE junit_utplsql_test_pkg IS
+ -- %suite
+
+ END junit_utplsql_test_pkg;
+ ''')
+ val dao = new UtplsqlDao(dataSource.connection)
+ val actualNodes = dao.runnables()
+ Assert.assertEquals(4, actualNodes.size)
+ jdbcTemplate.execute("DROP PACKAGE junit_utplsql_test_pkg")
+ }
+
+ @Test
+ // https://github.com/utPLSQL/utPLSQL-SQLDeveloper/issues/56
+ def void issue56SuiteWithoutTests() {
+ jdbcTemplate.execute('''
+ CREATE OR REPLACE PACKAGE junit_utplsql_test_pkg IS
+ -- %suite
+
+ END junit_utplsql_test_pkg;
+ ''')
+ val dao = new UtplsqlDao(dataSource.connection)
+ Assert.assertTrue(dao.containsUtplsqlTest("scott", "junit_utplsql_test_pkg"))
+ jdbcTemplate.execute("DROP PACKAGE junit_utplsql_test_pkg")
+ }
+
+}
\ No newline at end of file
diff --git a/sqldev/src/test/java/org/utplsql/sqldev/tests/DalTest.xtend b/sqldev/src/test/java/org/utplsql/sqldev/test/dal/DalTest.xtend
similarity index 82%
rename from sqldev/src/test/java/org/utplsql/sqldev/tests/DalTest.xtend
rename to sqldev/src/test/java/org/utplsql/sqldev/test/dal/DalTest.xtend
index 19699259..25573974 100644
--- a/sqldev/src/test/java/org/utplsql/sqldev/tests/DalTest.xtend
+++ b/sqldev/src/test/java/org/utplsql/sqldev/test/dal/DalTest.xtend
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
- package org.utplsql.sqldev.tests
+ package org.utplsql.sqldev.test.dal
import java.util.ArrayList
import java.util.HashMap
@@ -24,6 +24,8 @@ import org.junit.Test
import org.springframework.jdbc.BadSqlGrammarException
import org.utplsql.sqldev.dal.UtplsqlDao
import org.utplsql.sqldev.model.ut.Annotation
+import org.utplsql.sqldev.test.AbstractJdbcTest
+import org.junit.Ignore
class DalTest extends AbstractJdbcTest {
@@ -36,6 +38,11 @@ class DalTest extends AbstractJdbcTest {
} catch (BadSqlGrammarException e) {
// ignore
}
+ try {
+ jdbcTemplate.execute("DROP PACKAGE BODY junit_utplsql_test_pkg")
+ } catch (BadSqlGrammarException e) {
+ // ignore
+ }
try {
jdbcTemplate.execute("DROP PACKAGE junit_no_test_pkg")
} catch (BadSqlGrammarException e) {
@@ -128,7 +135,10 @@ class DalTest extends AbstractJdbcTest {
@Test
def void containsUtplsqlTest304() {
- containsUtplsqlTest("3.0.4")
+ val dao = new UtplsqlDao(dataSource.connection)
+ if (dao.normalizedUtPlsqlVersionNumber < UtplsqlDao.FIRST_VERSION_WITHOUT_INTERNAL_API) {
+ containsUtplsqlTest("3.0.4")
+ }
}
@Test
@@ -136,6 +146,12 @@ class DalTest extends AbstractJdbcTest {
containsUtplsqlTest("3.1.3")
}
+ @Test
+ @Ignore
+ def void containsUtplsqlTest999() {
+ containsUtplsqlTest("9.9.9")
+ }
+
def void annotations(String utPlsqlVersion) {
val dao = new UtplsqlDao(dataSource.connection)
dao.utPlsqlVersion = utPlsqlVersion
@@ -178,7 +194,10 @@ class DalTest extends AbstractJdbcTest {
@Test
def void annotations304() {
- annotations("3.0.4")
+ val dao = new UtplsqlDao(dataSource.connection)
+ if (dao.normalizedUtPlsqlVersionNumber < UtplsqlDao.FIRST_VERSION_WITHOUT_INTERNAL_API) {
+ annotations("3.0.4")
+ }
}
@Test
@@ -186,6 +205,11 @@ class DalTest extends AbstractJdbcTest {
annotations("3.1.3")
}
+ @Test
+ def void annotations999() {
+ annotations("9.9.9")
+ }
+
def void testablesPackages(String utPlsqlVersion) {
val dao = new UtplsqlDao(dataSource.connection)
dao.utPlsqlVersion = utPlsqlVersion
@@ -216,7 +240,10 @@ class DalTest extends AbstractJdbcTest {
@Test
def void testablesPackages304() {
- testablesPackages("3.0.4")
+ val dao = new UtplsqlDao(dataSource.connection)
+ if (dao.normalizedUtPlsqlVersionNumber < UtplsqlDao.FIRST_VERSION_WITHOUT_INTERNAL_API) {
+ testablesPackages("3.0.4")
+ }
}
@Test
@@ -224,6 +251,11 @@ class DalTest extends AbstractJdbcTest {
testablesPackages("3.1.3")
}
+ @Test
+ def void testablesPackages999() {
+ testablesPackages("9.9.9")
+ }
+
def void testablesTypes(String utPlsqlVersion) {
val dao = new UtplsqlDao(dataSource.connection)
dao.utPlsqlVersion = utPlsqlVersion
@@ -247,7 +279,10 @@ class DalTest extends AbstractJdbcTest {
@Test
def void testablesTypes304() {
- testablesTypes("3.0.4")
+ val dao = new UtplsqlDao(dataSource.connection)
+ if (dao.normalizedUtPlsqlVersionNumber < UtplsqlDao.FIRST_VERSION_WITHOUT_INTERNAL_API) {
+ testablesTypes("3.0.4")
+ }
}
@Test
@@ -255,6 +290,11 @@ class DalTest extends AbstractJdbcTest {
testablesTypes("3.1.3")
}
+ @Test
+ def void testablesTypes999() {
+ testablesTypes("9.9.9")
+ }
+
def void testablesFunctions(String utPlsqlVersion) {
val dao = new UtplsqlDao(dataSource.connection)
dao.utPlsqlVersion = utPlsqlVersion
@@ -271,7 +311,10 @@ class DalTest extends AbstractJdbcTest {
@Test
def void testablesFunctions304() {
- testablesFunctions("3.0.4")
+ val dao = new UtplsqlDao(dataSource.connection)
+ if (dao.normalizedUtPlsqlVersionNumber < UtplsqlDao.FIRST_VERSION_WITHOUT_INTERNAL_API) {
+ testablesFunctions("3.0.4")
+ }
}
@Test
@@ -279,6 +322,11 @@ class DalTest extends AbstractJdbcTest {
testablesFunctions("3.1.3")
}
+ @Test
+ def void testablesFunctions999() {
+ testablesFunctions("9.9.9")
+ }
+
def void testablesProcedures(String utPlsqlVersion) {
val dao = new UtplsqlDao(dataSource.connection)
dao.utPlsqlVersion = utPlsqlVersion
@@ -295,7 +343,10 @@ class DalTest extends AbstractJdbcTest {
@Test
def void testablesProcedures304() {
- testablesProcedures("3.0.4")
+ val dao = new UtplsqlDao(dataSource.connection)
+ if (dao.normalizedUtPlsqlVersionNumber < UtplsqlDao.FIRST_VERSION_WITHOUT_INTERNAL_API) {
+ testablesProcedures("3.0.4")
+ }
}
@Test
@@ -303,6 +354,11 @@ class DalTest extends AbstractJdbcTest {
testablesProcedures("3.1.3")
}
+ @Test
+ def void testablesProcedures999() {
+ testablesProcedures("9.9.9")
+ }
+
def void runnables(String utPlsqlVersion) {
val dao = new UtplsqlDao(dataSource.connection)
dao.utPlsqlVersion = utPlsqlVersion
@@ -354,13 +410,21 @@ class DalTest extends AbstractJdbcTest {
@Test
def void runnables304() {
- runnables("3.0.4")
+ val dao = new UtplsqlDao(dataSource.connection)
+ if (dao.normalizedUtPlsqlVersionNumber < UtplsqlDao.FIRST_VERSION_WITHOUT_INTERNAL_API) {
+ runnables("3.0.4")
+ }
}
@Test
def void runnables313() {
runnables("3.1.3")
}
+
+ @Test
+ def void runnables999() {
+ runnables("9.9.9")
+ }
@Test
def void dbmsOutput() {
@@ -419,7 +483,7 @@ class DalTest extends AbstractJdbcTest {
l_actual INTEGER;
BEGIN
l_actual := junit_f;
- ut.expect(l_actual).to_equal(l_expected).to_equal(l_actual);
+ ut.expect(l_actual).to_equal(l_expected);
END f1;
END junit_utplsql_test_pkg;
''')
@@ -471,69 +535,57 @@ class DalTest extends AbstractJdbcTest {
Assert.assertEquals(expected, actual)
}
-
+
@Test
- def void issue54FolderIconForSuitesWithoutTests() {
- setupAndTeardown
- jdbcTemplate.execute('''
- CREATE OR REPLACE PACKAGE junit_utplsql_test_pkg IS
- -- %suite
-
- END junit_utplsql_test_pkg;
- ''')
+ def void getSourceOfPackage() {
val dao = new UtplsqlDao(dataSource.connection)
- val actualNodes = dao.runnables()
- Assert.assertEquals(4, actualNodes.size)
- val pkg = actualNodes.findFirst[it.id == "SCOTT:junit_utplsql_test_pkg"]
- Assert.assertEquals("FOLDER_ICON", pkg.iconName)
- jdbcTemplate.execute("DROP PACKAGE junit_utplsql_test_pkg")
- }
-
- @Test
- def void issue54PackageIconForSuitesWithTests() {
- setupAndTeardown
jdbcTemplate.execute('''
CREATE OR REPLACE PACKAGE junit_utplsql_test_pkg IS
-- %suite
-- %test
- PROCEDURE t1;
-
+ PROCEDURE p1;
END junit_utplsql_test_pkg;
''')
- val dao = new UtplsqlDao(dataSource.connection)
- val actualNodes = dao.runnables()
- Assert.assertEquals(6, actualNodes.size)
- val pkg = actualNodes.findFirst[it.id == "SCOTT:junit_utplsql_test_pkg"]
- Assert.assertEquals("PACKAGE_ICON", pkg.iconName)
+ val actual = dao.getSource("SCOTT", "PACKAGE", "JUNIT_UTPLSQL_TEST_PKG")
+ Assert.assertTrue(actual.contains("-- %suite"))
+ Assert.assertTrue(actual.contains("PROCEDURE p1;"))
jdbcTemplate.execute("DROP PACKAGE junit_utplsql_test_pkg")
}
@Test
- def void issue55SuiteWithoutTests() {
- setupAndTeardown
+ def void getSourceOfPackageBody() {
+ val dao = new UtplsqlDao(dataSource.connection)
jdbcTemplate.execute('''
- CREATE OR REPLACE PACKAGE junit_utplsql_test_pkg IS
- -- %suite
-
+ CREATE OR REPLACE PACKAGE BODY junit_utplsql_test_pkg IS
+ PROCEDURE p1 IS
+ l_expected INTEGER := 1;
+ l_actual INTEGER;
+ BEGIN
+ l_actual := junit_f;
+ ut.expect(l_actual).to_equal(l_expected);
+ END p1;
END junit_utplsql_test_pkg;
- ''')
- val dao = new UtplsqlDao(dataSource.connection)
- val actualNodes = dao.runnables()
- Assert.assertEquals(4, actualNodes.size)
- jdbcTemplate.execute("DROP PACKAGE junit_utplsql_test_pkg")
+ ''');
+ val actual = dao.getSource("SCOTT", "PACKAGE BODY", "JUNIT_UTPLSQL_TEST_PKG")
+ Assert.assertTrue(actual.contains("PACKAGE BODY"))
+ Assert.assertTrue(actual.contains("PROCEDURE p1 IS"))
+ jdbcTemplate.execute("DROP PACKAGE BODY junit_utplsql_test_pkg")
}
@Test
- def void issue56SuiteWithoutTests() {
+ def void getObjectType() {
+ val dao = new UtplsqlDao(dataSource.connection)
jdbcTemplate.execute('''
CREATE OR REPLACE PACKAGE junit_utplsql_test_pkg IS
-- %suite
+ -- %test
+ PROCEDURE p1;
END junit_utplsql_test_pkg;
''')
- val dao = new UtplsqlDao(dataSource.connection)
- Assert.assertTrue(dao.containsUtplsqlTest("scott", "junit_utplsql_test_pkg"))
+ val actual = dao.getObjectType("SCOTT", "JUNIT_UTPLSQL_TEST_PKG")
+ Assert.assertEquals("PACKAGE", actual)
jdbcTemplate.execute("DROP PACKAGE junit_utplsql_test_pkg")
}
diff --git a/sqldev/src/test/java/org/utplsql/sqldev/test/dal/RealtimeReporterFetchSizeTest.xtend b/sqldev/src/test/java/org/utplsql/sqldev/test/dal/RealtimeReporterFetchSizeTest.xtend
new file mode 100644
index 00000000..b713cbc2
--- /dev/null
+++ b/sqldev/src/test/java/org/utplsql/sqldev/test/dal/RealtimeReporterFetchSizeTest.xtend
@@ -0,0 +1,144 @@
+/*
+ * Copyright 2019 Philipp Salvisberg
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ package org.utplsql.sqldev.test.dal
+
+import java.util.UUID
+import java.util.logging.Logger
+import org.junit.AfterClass
+import org.junit.Assert
+import org.junit.BeforeClass
+import org.junit.Test
+import org.springframework.jdbc.BadSqlGrammarException
+import org.springframework.jdbc.datasource.SingleConnectionDataSource
+import org.utplsql.sqldev.dal.RealtimeReporterDao
+import org.utplsql.sqldev.test.AbstractJdbcTest
+
+class RealtimeReporterFetchSizeTest extends AbstractJdbcTest {
+
+ static val Logger logger = Logger.getLogger(RealtimeReporterFetchSizeTest.name);
+
+ @BeforeClass
+ def static void setup() {
+
+ jdbcTemplate.execute('''
+ CREATE OR REPLACE PACKAGE junit_utplsql_fetch_size_pkg is
+ --%suite(JUnit testing)
+
+ --%test(test 1 - 0 seconds)
+ PROCEDURE test_1_0;
+
+ --%test(test 2 - 1 seconds)
+ PROCEDURE test_2_1;
+
+ --%test(test 3 - 2 seconds)
+ PROCEDURE test_3_2;
+
+ --%test(test 4 - 0 seconds)
+ PROCEDURE test_4_0;
+
+ --%test(test 5 - 0 seconds)
+ PROCEDURE test_5_0;
+ END;
+ ''')
+ jdbcTemplate.execute('''
+ CREATE OR REPLACE PACKAGE BODY junit_utplsql_fetch_size_pkg is
+ PROCEDURE test_1_0 IS
+ BEGIN
+ NULL;
+ END;
+
+ PROCEDURE test_2_1 IS
+ BEGIN
+ dbms_session.sleep(1);
+ END;
+
+ PROCEDURE test_3_2 IS
+ BEGIN
+ dbms_session.sleep(2);
+ END;
+
+ PROCEDURE test_4_0 IS
+ BEGIN
+ NULL;
+ END;
+
+ PROCEDURE test_5_0 IS
+ BEGIN
+ NULL;
+ END;
+ END;
+ ''')
+ }
+
+ @AfterClass
+ def static void teardown() {
+ try {
+ jdbcTemplate.execute("DROP PACKAGE junit_utplsql_fetch_size_pkg")
+ } catch (BadSqlGrammarException e) {
+ // ignore
+ }
+ }
+
+ private def delayFreeStreamingConsumtionProducer(String reporterId) {
+ var ds = new SingleConnectionDataSource()
+ ds.driverClassName = "oracle.jdbc.OracleDriver"
+ ds.url = dataSource.url
+ ds.username = dataSource.username
+ ds.password = dataSource.password
+ val dao = new RealtimeReporterDao(ds.connection)
+ dao.produceReport(reporterId, #["junit_utplsql_fetch_size_pkg"])
+ }
+
+ @Test
+ def void delayFreeStreamingConsumtion() {
+ val long TOLERANCE_MS = 400
+ var ds = new SingleConnectionDataSource()
+ ds.driverClassName = "oracle.jdbc.OracleDriver"
+ ds.url = dataSource.url
+ ds.username = dataSource.username
+ ds.password = dataSource.password
+ val consumer = new TestRealtimerReporterEventTimedConsumer
+ val reporterId = UUID.randomUUID().toString.replace("-", "");
+ val dao = new RealtimeReporterDao(ds.connection)
+ val Runnable runnable = [|delayFreeStreamingConsumtionProducer(reporterId)]
+ val thread = new Thread(runnable)
+ thread.name = "utPLSQL run test"
+ thread.start
+ dao.consumeReport(reporterId, consumer)
+ logger.fine(consumer.postTestEvents.toString)
+ Assert.assertEquals(5, consumer.postTestEvents.entrySet.size)
+ val test_1_0 = consumer.postTestEvents.get("junit_utplsql_fetch_size_pkg.test_1_0")
+ val test_2_1 = consumer.postTestEvents.get("junit_utplsql_fetch_size_pkg.test_2_1")
+ val test_3_2 = consumer.postTestEvents.get("junit_utplsql_fetch_size_pkg.test_3_2")
+ val test_4_0 = consumer.postTestEvents.get("junit_utplsql_fetch_size_pkg.test_4_0")
+ val test_5_0 = consumer.postTestEvents.get("junit_utplsql_fetch_size_pkg.test_5_0")
+ val test_2_1_time = test_2_1 - test_1_0
+ logger.fine("test_2_1 time [ms]: " + test_2_1_time)
+ Assert.assertTrue("test_2_1 runtime was too long", test_2_1_time < 1000 + TOLERANCE_MS)
+ Assert.assertTrue("test_2_1 runtime was too short", test_2_1_time > 1000 - TOLERANCE_MS)
+ val test_3_2_time = test_3_2 - test_2_1
+ logger.fine("test_3_2 time [ms]: " + test_3_2_time)
+ Assert.assertTrue("test_3_2 runtime was too long", test_3_2_time < 2000 + TOLERANCE_MS)
+ Assert.assertTrue("test_3_2 runtime was too short", test_3_2_time > 2000 - TOLERANCE_MS)
+ val test_4_0_time = test_4_0 - test_3_2
+ logger.fine("test_4_0 time [ms]: " + test_4_0_time)
+ Assert.assertTrue("test_4_0 runtime was too long", test_4_0_time < TOLERANCE_MS)
+ val test_5_0_time = test_5_0 - test_4_0
+ logger.fine("test_5_0 time [ms]: " + test_5_0_time)
+ Assert.assertTrue("test_5_0 runtime was too long", test_5_0_time < TOLERANCE_MS)
+ }
+
+}
\ No newline at end of file
diff --git a/sqldev/src/test/java/org/utplsql/sqldev/test/dal/RealtimeReporterTest.xtend b/sqldev/src/test/java/org/utplsql/sqldev/test/dal/RealtimeReporterTest.xtend
new file mode 100644
index 00000000..908fe3f2
--- /dev/null
+++ b/sqldev/src/test/java/org/utplsql/sqldev/test/dal/RealtimeReporterTest.xtend
@@ -0,0 +1,183 @@
+/*
+ * Copyright 2018 Philipp Salvisberg
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ package org.utplsql.sqldev.test.dal
+
+import java.util.UUID
+import java.util.logging.Logger
+import org.junit.AfterClass
+import org.junit.Assert
+import org.junit.BeforeClass
+import org.junit.Test
+import org.springframework.jdbc.BadSqlGrammarException
+import org.utplsql.sqldev.dal.RealtimeReporterDao
+import org.utplsql.sqldev.model.runner.PostRunEvent
+import org.utplsql.sqldev.model.runner.PostSuiteEvent
+import org.utplsql.sqldev.model.runner.PostTestEvent
+import org.utplsql.sqldev.model.runner.PreRunEvent
+import org.utplsql.sqldev.model.runner.PreSuiteEvent
+import org.utplsql.sqldev.model.runner.PreTestEvent
+import org.utplsql.sqldev.test.AbstractJdbcTest
+
+class RealtimeReporterTest extends AbstractJdbcTest {
+
+ static val Logger logger = Logger.getLogger(RealtimeReporterTest.name);
+
+ @BeforeClass
+ def static void setup() {
+ jdbcTemplate.execute('''
+ CREATE OR REPLACE PACKAGE junit_utplsql_test1_pkg is
+ --%suite(JUnit testing)
+ --%suitepath(a)
+
+ --%context(test context)
+
+ --%test(test 1 - OK)
+ PROCEDURE test_1_ok;
+
+ --%test(test 2 - NOK)
+ PROCEDURE test_2_nok;
+
+ --%endcontext
+ END;
+ ''')
+ jdbcTemplate.execute('''
+ CREATE OR REPLACE PACKAGE BODY junit_utplsql_test1_pkg IS
+ PROCEDURE test_1_ok IS
+ BEGIN
+ ut.expect(1).to_equal(1);
+ END;
+
+ PROCEDURE test_2_nok IS
+ BEGIN
+ ut.expect(1).to_equal(2);
+ END;
+ END;
+ ''')
+ jdbcTemplate.execute('''
+ CREATE OR REPLACE PACKAGE junit_utplsql_test2_pkg IS
+ --%suite
+ --%suitepath(b)
+
+ --%test
+ PROCEDURE test_3_ok;
+
+ --%test
+ PROCEDURE test_4_nok;
+
+ --%test
+ --%disabled
+ PROCEDURE test_5;
+ end;
+ ''')
+ jdbcTemplate.execute('''
+ CREATE OR REPLACE PACKAGE BODY junit_utplsql_test2_pkg IS
+ PROCEDURE test_3_ok IS
+ BEGIN
+ ut3.ut.expect(2).to_equal(2);
+ END;
+
+ PROCEDURE test_4_nok IS
+ BEGIN
+ ut3.ut.expect(2).to_equal(3);
+ ut3.ut.expect(2).to_equal(4);
+ END;
+
+ PROCEDURE test_5 IS
+ BEGIN
+ null;
+ END;
+ END;
+ ''')
+ jdbcTemplate.execute('''
+ CREATE OR REPLACE PACKAGE junit_utplsql_test3_pkg IS
+ --%suite
+ --%suitepath(b)
+
+ --%test
+ PROCEDURE test_6_with_runtime_error;
+
+ --%test
+ PROCEDURE test_7_with_serveroutput;
+
+ --%afterall
+ PROCEDURE print_and_raise;
+ END;
+ ''')
+ jdbcTemplate.execute('''
+ CREATE OR REPLACE PACKAGE BODY junit_utplsql_test3_pkg IS
+ PROCEDURE test_6_with_runtime_error is
+ l_actual INTEGER;
+ BEGIN
+ EXECUTE IMMEDIATE 'select 6 from non_existing_table' INTO l_actual;
+ ut3.ut.expect(6).to_equal(l_actual);
+ END;
+
+ PROCEDURE test_7_with_serveroutput IS
+ BEGIN
+ dbms_output.put_line('before test 7');
+ ut3.ut.expect(7).to_equal(7);
+ dbms_output.put_line('after test 7');
+ END;
+
+ PROCEDURE print_and_raise IS
+ BEGIN
+ dbms_output.put_line('Now, a no_data_found exception is raised');
+ dbms_output.put_line('dbms_output and error stack is reported for this suite.');
+ dbms_output.put_line('A runtime error in afterall is counted as a warning.');
+ raise no_data_found;
+ END;
+ END;
+ ''')
+ }
+
+ @AfterClass
+ def static void teardown() {
+ try {
+ jdbcTemplate.execute("DROP PACKAGE junit_utplsql_test1_pkg")
+ } catch (BadSqlGrammarException e) {
+ // ignore
+ }
+ try {
+ jdbcTemplate.execute("DROP PACKAGE junit_utplsql_test2_pkg")
+ } catch (BadSqlGrammarException e) {
+ // ignore
+ }
+ try {
+ jdbcTemplate.execute("DROP PACKAGE junit_utplsql_test3_pkg")
+ } catch (BadSqlGrammarException e) {
+ // ignore
+ }
+ }
+
+ @Test
+ def void produceAndConsume() {
+ val dao = new RealtimeReporterDao(dataSource.connection)
+ val reporterId = UUID.randomUUID().toString.replace("-", "");
+ val consumer = new TestRealtimerReporterEventConsumer
+ dao.produceReport(reporterId, #[":a", ":b"])
+ dao.consumeReport(reporterId, consumer)
+ logger.fine(consumer.consumedList.toString)
+ Assert.assertEquals(1, consumer.consumedList.filter[it instanceof PreRunEvent].size)
+ Assert.assertEquals(1, consumer.consumedList.filter[it instanceof PostRunEvent].size)
+ // 2 suitepaths (a, b), 1 context, 3 packages -> 6 suites
+ Assert.assertEquals(6, consumer.consumedList.filter[it instanceof PreSuiteEvent].size)
+ Assert.assertEquals(6, consumer.consumedList.filter[it instanceof PostSuiteEvent].size)
+ Assert.assertEquals(7, consumer.consumedList.filter[it instanceof PreTestEvent].size)
+ Assert.assertEquals(7, consumer.consumedList.filter[it instanceof PostTestEvent].size)
+ Assert.assertEquals(28, consumer.consumedList.size)
+ }
+
+}
\ No newline at end of file
diff --git a/sqldev/src/test/java/org/utplsql/sqldev/test/dal/TestRealtimerReporterEventConsumer.xtend b/sqldev/src/test/java/org/utplsql/sqldev/test/dal/TestRealtimerReporterEventConsumer.xtend
new file mode 100644
index 00000000..caa75d71
--- /dev/null
+++ b/sqldev/src/test/java/org/utplsql/sqldev/test/dal/TestRealtimerReporterEventConsumer.xtend
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2018 Philipp Salvisberg
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.utplsql.sqldev.test.dal
+
+import java.util.ArrayList
+import org.utplsql.sqldev.dal.RealtimeReporterEventConsumer
+import org.utplsql.sqldev.model.runner.RealtimeReporterEvent
+
+class TestRealtimerReporterEventConsumer implements RealtimeReporterEventConsumer {
+
+ val consumedList = new ArrayList
+
+ def getConsumedList() {
+ return consumedList
+ }
+
+ override void process(RealtimeReporterEvent event) {
+ consumedList.add(event)
+ }
+
+}
\ No newline at end of file
diff --git a/sqldev/src/test/java/org/utplsql/sqldev/test/dal/TestRealtimerReporterEventTimedConsumer.xtend b/sqldev/src/test/java/org/utplsql/sqldev/test/dal/TestRealtimerReporterEventTimedConsumer.xtend
new file mode 100644
index 00000000..ff46d749
--- /dev/null
+++ b/sqldev/src/test/java/org/utplsql/sqldev/test/dal/TestRealtimerReporterEventTimedConsumer.xtend
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2019 Philipp Salvisberg
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.utplsql.sqldev.test.dal
+
+import java.util.HashMap
+import org.utplsql.sqldev.dal.RealtimeReporterEventConsumer
+import org.utplsql.sqldev.model.runner.RealtimeReporterEvent
+import org.utplsql.sqldev.model.runner.PostTestEvent
+
+class TestRealtimerReporterEventTimedConsumer implements RealtimeReporterEventConsumer {
+
+ val postTestEvents = new HashMap
+
+ def getPostTestEvents() {
+ return postTestEvents
+ }
+
+ override void process(RealtimeReporterEvent event) {
+ if (event instanceof PostTestEvent) {
+ postTestEvents.put(event.id, System.currentTimeMillis)
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/sqldev/src/test/java/org/utplsql/sqldev/test/parser/SqlDevParserTest.xtend b/sqldev/src/test/java/org/utplsql/sqldev/test/parser/SqlDevParserTest.xtend
new file mode 100644
index 00000000..a424e7d2
--- /dev/null
+++ b/sqldev/src/test/java/org/utplsql/sqldev/test/parser/SqlDevParserTest.xtend
@@ -0,0 +1,123 @@
+package org.utplsql.sqldev.test.parser
+
+import org.junit.Assert
+import org.junit.Test
+import org.utplsql.sqldev.parser.SqlDevParser
+
+class SqlDevParserTest {
+ val packageSpec = '''
+ CREATE OR REPLACE PACKAGE junit_utplsql_test1_pkg is
+ --%suite(JUnit testing)
+ --%suitepath(a)
+
+ --%context(test context)
+
+ --%test(test 1 - OK)
+ PRoCeDURE test_1_ok;
+
+ --%test(test 2 - NOK)
+ PROCEDURE test_2_nok;
+
+ --%test(test 3 - disabled)
+ --%disabled
+ PROCEDURE test_3_disabled;
+
+ --%test(test 4 - errored)
+ PROCEDURE test_4_errored;
+
+ --%test(test 5 - warnings)
+ PROCEDURE test_5_warnings;
+ --%endcontext
+
+ function my_Func (p IN number) RETURN BOOLEAN;
+ END;
+ '''
+
+ val packageBody = '''
+ CREATE OR REPLACE PACKAGE BODY junit_utplsql_test1_pkg IS
+ PROCEDURE test_1_ok IS
+ BEGIN
+ dbms_output.put_line('start test 1');
+ dbms_session.sleep(1);
+ ut.expect(1).to_equal(1);
+ dbms_output.put_line('end test 1');
+ END;
+
+ PROCEDURE test_2_nok IS
+ BEGIN
+ dbms_output.put_line('start test 2');
+ dbms_session.sleep(2);
+ ut.expect(1, 'first assert.').to_equal(2);
+ ut.expect(1, 'second assert.').to_equal(2);
+ dbms_output.put_line('end test 2');
+ END;
+
+ PROCEDURE test_3_disabled IS
+ BEGIN
+ NULL;
+ END;
+
+ PROCEDURE test_4_errored IS
+ BEGIN
+ EXECUTE IMMEDIATE 'bla bla';
+ END;
+
+ PROCEDURE test_5_warnings IS
+ BEGIN
+ COMMIT; -- will raise a warning
+ ut.expect(1).to_equal(1);
+ END;
+
+ FUNCTION my_Func (p IN number) RETURN BOOLEAN IS
+ RETURN TRUE;
+ END;
+ END;
+ '''
+
+ @Test
+ def void packageSpecMembers() {
+ val parser = new SqlDevParser
+ val actual = parser.getMembers(packageSpec)
+ Assert.assertEquals(6, actual.length)
+ val first = actual.get(0)
+ Assert.assertEquals("PROCEDURE", first.type)
+ Assert.assertEquals("test_1_ok", first.name)
+ val last = actual.get(5)
+ Assert.assertEquals("FUNCTION", last.type)
+ Assert.assertEquals("my_Func", last.name)
+ }
+
+ @Test
+ def void packageBodyMembers() {
+ val parser = new SqlDevParser
+ val actual = parser.getMembers(packageBody)
+ Assert.assertEquals(6, actual.length)
+ val first = actual.get(0)
+ Assert.assertEquals("PROCEDURE", first.type)
+ Assert.assertEquals("test_1_ok", first.name)
+ val last = actual.get(5)
+ Assert.assertEquals("FUNCTION", last.type)
+ Assert.assertEquals("my_Func", last.name)
+ }
+
+ @Test
+ def void StartLineSpec() {
+ val parser = new SqlDevParser
+ val first = parser.getMemberStartLine(packageSpec, 'test_1_ok')
+ Assert.assertEquals(8, first)
+ val last = parser.getMemberStartLine(packageSpec, 'my_func')
+ Assert.assertEquals(24, last)
+ }
+
+ @Test
+ def void StartLineBody() {
+ val parser = new SqlDevParser
+ val first = parser.getMemberStartLine(packageBody, 'test_1_ok')
+ Assert.assertEquals(2, first)
+ val last = parser.getMemberStartLine(packageBody, 'my_func')
+ Assert.assertEquals(35, last)
+ }
+
+
+
+}
\ No newline at end of file
diff --git a/sqldev/src/test/java/org/utplsql/sqldev/test/parser/UtplsqlParserBugFixTest.xtend b/sqldev/src/test/java/org/utplsql/sqldev/test/parser/UtplsqlParserBugFixTest.xtend
new file mode 100644
index 00000000..3ec0c926
--- /dev/null
+++ b/sqldev/src/test/java/org/utplsql/sqldev/test/parser/UtplsqlParserBugFixTest.xtend
@@ -0,0 +1,115 @@
+/*
+ * Copyright 2018 Philipp Salvisberg
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.utplsql.sqldev.test.parser
+
+import org.junit.Assert
+import org.junit.Test
+import org.utplsql.sqldev.parser.UtplsqlParser
+
+class UtplsqlParserBugFixTest {
+
+ @Test
+ // https://github.com/utPLSQL/utPLSQL-SQLDeveloper/issues/1
+ def issue1MatchingExprInStringLiterals() {
+ val plsql = '''
+ create or replace package body test_expect_not_to_be_null
+ is
+ gc_object_name constant varchar2(30) := 't_not_to_be_null_test';
+ gc_nested_table_name constant varchar2(30) := 'tt_not_to_be_null_test';
+ gc_varray_name constant varchar2(30) := 'tv_not_to_be_null_test';
+
+ procedure cleanup_expectations
+ is
+ begin
+ ut3.ut_expectation_processor.clear_expectations();
+ end;
+
+ procedure create_types
+ is
+ pragma autonomous_transaction;
+ begin
+ execute immediate 'create type '||gc_object_name||' is object (dummy number)';
+ execute immediate ' create type '||gc_nested_table_name||' is table of number';
+ execute immediate '
+ create type '||gc_varray_name||' is varray(1) of number';
+ end;
+
+ procedure drop_types
+ is
+ pragma autonomous_transaction;
+ begin
+ execute immediate 'drop type '||gc_object_name;
+ execute immediate ' drop type '||gc_nested_table_name;
+ execute immediate '
+ drop type '||gc_varray_name;
+ end;
+
+ procedure blob_not_null
+ is
+ begin
+ --Act
+ execute immediate expectations_helpers.unary_expectation_block('not_to_be_null', 'blob', 'to_blob(''abc'')');
+ --Assert
+ ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).to_be_empty();
+ end;
+
+ --and so on...
+
+ end;
+ '''
+ val parser = new UtplsqlParser(plsql)
+ Assert.assertEquals("test_expect_not_to_be_null.cleanup_expectations", parser.getPathAt(parser.toPosition(7,1)))
+ Assert.assertEquals("test_expect_not_to_be_null.create_types", parser.getPathAt(parser.toPosition(13,1)))
+ // was: '||gc_varray_name||'.drop_types
+ Assert.assertEquals("test_expect_not_to_be_null.drop_types", parser.getPathAt(parser.toPosition(23,1)))
+ // was: '||gc_varray_name||'.blob_not_null
+ Assert.assertEquals("test_expect_not_to_be_null.blob_not_null", parser.getPathAt(parser.toPosition(33,1)))
+ }
+
+ @Test
+ // https://github.com/utPLSQL/utPLSQL-SQLDeveloper/issues/7
+ def issue7WrongPositionWithWindowsLineSeparator() {
+ val plsql = '''
+ create or replace package test_expect_not_to_be_null
+ is
+ --%suite(expectations - not_to_be_null)
+ --%suitepath(utplsql.core.expectations.unary)
+
+ --%aftereach
+ procedure cleanup_expectations;
+
+ --%beforeall
+ procedure create_types;
+
+ --%afterall
+ procedure drop_types;
+
+ --%test(Gives success for not null blob)
+ procedure blob_not_null;
+
+ --%test(Gives success for blob with length 0)
+ procedure blob_0_length;
+
+ -- ...
+ end test_expect_not_to_be_null;
+ /
+ '''
+ val parser = new UtplsqlParser(plsql)
+ // was: test_expect_not_to_be_null.create_types
+ Assert.assertEquals("test_expect_not_to_be_null.blob_not_null", parser.getPathAt(parser.toPosition(13,26)))
+ }
+
+}
diff --git a/sqldev/src/test/java/org/utplsql/sqldev/tests/UtplsqlParserTest.xtend b/sqldev/src/test/java/org/utplsql/sqldev/test/parser/UtplsqlParserTest.xtend
similarity index 65%
rename from sqldev/src/test/java/org/utplsql/sqldev/tests/UtplsqlParserTest.xtend
rename to sqldev/src/test/java/org/utplsql/sqldev/test/parser/UtplsqlParserTest.xtend
index 93be55f4..b49293ac 100644
--- a/sqldev/src/test/java/org/utplsql/sqldev/tests/UtplsqlParserTest.xtend
+++ b/sqldev/src/test/java/org/utplsql/sqldev/test/parser/UtplsqlParserTest.xtend
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.utplsql.sqldev.tests
+package org.utplsql.sqldev.test.parser
import org.junit.AfterClass
import org.junit.Assert
@@ -21,6 +21,7 @@ import org.junit.BeforeClass
import org.junit.Test
import org.springframework.jdbc.BadSqlGrammarException
import org.utplsql.sqldev.parser.UtplsqlParser
+import org.utplsql.sqldev.test.AbstractJdbcTest
class UtplsqlParserTest extends AbstractJdbcTest {
@@ -74,7 +75,7 @@ class UtplsqlParserTest extends AbstractJdbcTest {
}
@Test
- def testPackage() {
+ def packageWithoutConnection() {
val parser = new UtplsqlParser(sqlScript)
val objects = parser.getObjects
Assert.assertEquals(2, objects.size)
@@ -98,11 +99,8 @@ class UtplsqlParserTest extends AbstractJdbcTest {
}
@Test
- def testPackageWithConnection() {
+ def packageWithConnection() {
val plsql = '''
- /*
- * some comment
- */
CREATE OR REPLACE PACKAGE pkg IS
-- %suite
-- %rollback(manual)
@@ -129,98 +127,9 @@ class UtplsqlParserTest extends AbstractJdbcTest {
Assert.assertEquals("SCOTT.PKG.p", parser.getPathAt(parser.toPosition(19,1)))
setupAndTeardown
}
-
- @Test
- def issue_1() {
- val plsql = '''
- create or replace package body test_expect_not_to_be_null
- is
- gc_object_name constant varchar2(30) := 't_not_to_be_null_test';
- gc_nested_table_name constant varchar2(30) := 'tt_not_to_be_null_test';
- gc_varray_name constant varchar2(30) := 'tv_not_to_be_null_test';
-
- procedure cleanup_expectations
- is
- begin
- ut3.ut_expectation_processor.clear_expectations();
- end;
-
- procedure create_types
- is
- pragma autonomous_transaction;
- begin
- execute immediate 'create type '||gc_object_name||' is object (dummy number)';
- execute immediate ' create type '||gc_nested_table_name||' is table of number';
- execute immediate '
- create type '||gc_varray_name||' is varray(1) of number';
- end;
-
- procedure drop_types
- is
- pragma autonomous_transaction;
- begin
- execute immediate 'drop type '||gc_object_name;
- execute immediate ' drop type '||gc_nested_table_name;
- execute immediate '
- drop type '||gc_varray_name;
- end;
-
- procedure blob_not_null
- is
- begin
- --Act
- execute immediate expectations_helpers.unary_expectation_block('not_to_be_null', 'blob', 'to_blob(''abc'')');
- --Assert
- ut.expect(anydata.convertCollection(ut3.ut_expectation_processor.get_failed_expectations())).to_be_empty();
- end;
-
- --and so on...
-
- end;
- '''
- val parser = new UtplsqlParser(plsql)
- Assert.assertEquals("test_expect_not_to_be_null.cleanup_expectations", parser.getPathAt(parser.toPosition(7,1)))
- Assert.assertEquals("test_expect_not_to_be_null.create_types", parser.getPathAt(parser.toPosition(13,1)))
- // was: '||gc_varray_name||'.drop_types
- Assert.assertEquals("test_expect_not_to_be_null.drop_types", parser.getPathAt(parser.toPosition(23,1)))
- // was: '||gc_varray_name||'.blob_not_null
- Assert.assertEquals("test_expect_not_to_be_null.blob_not_null", parser.getPathAt(parser.toPosition(33,1)))
- }
-
- @Test
- def issue_7() {
- val plsql = '''
- create or replace package test_expect_not_to_be_null
- is
- --%suite(expectations - not_to_be_null)
- --%suitepath(utplsql.core.expectations.unary)
-
- --%aftereach
- procedure cleanup_expectations;
-
- --%beforeall
- procedure create_types;
-
- --%afterall
- procedure drop_types;
-
- --%test(Gives success for not null blob)
- procedure blob_not_null;
-
- --%test(Gives success for blob with length 0)
- procedure blob_0_length;
-
- -- ...
- end test_expect_not_to_be_null;
- /
- '''
- val parser = new UtplsqlParser(plsql)
- // was: test_expect_not_to_be_null.create_types
- Assert.assertEquals("test_expect_not_to_be_null.blob_not_null", parser.getPathAt(parser.toPosition(13,26)))
- }
@Test
- def testProcedure() {
+ def procedure() {
val plsql = '''
create or replace procedure z
is
@@ -234,7 +143,7 @@ class UtplsqlParserTest extends AbstractJdbcTest {
}
@Test
- def testFunction() {
+ def function() {
val plsql = '''
create or replace procedure z
is
@@ -254,7 +163,7 @@ class UtplsqlParserTest extends AbstractJdbcTest {
}
@Test
- def testType() {
+ def type() {
val plsql = '''
create or replace type t force is
object (
@@ -272,7 +181,7 @@ class UtplsqlParserTest extends AbstractJdbcTest {
}
@Test
- def testTypeBody() {
+ def typeBody() {
val plsql = '''
create or replace type body t force is
member procedure p(self in t) is
@@ -288,7 +197,7 @@ class UtplsqlParserTest extends AbstractJdbcTest {
}
@Test
- def testUnknown() {
+ def unknown() {
val plsql = '''
create or replace unknown u is
begin
@@ -299,6 +208,90 @@ class UtplsqlParserTest extends AbstractJdbcTest {
val parser = new UtplsqlParser(plsql)
Assert.assertEquals(null, parser.getObjectAt(0))
}
+
+ @Test
+ def void StartLineSpec() {
+ val plsql = '''
+ CREATE OR REPLACE PACKAGE junit_utplsql_test1_pkg is
+ --%suite(JUnit testing)
+ --%suitepath(a)
+
+ --%context(test context)
+
+ --%test(test 1 - OK)
+ PRoCeDURE test_1_ok;
+
+ --%test(test 2 - NOK)
+ PROCEDURE test_2_nok;
+
+ --%test(test 3 - disabled)
+ --%disabled
+ PROCEDURE test_3_disabled;
+
+ --%test(test 4 - errored)
+ PROCEDURE test_4_errored;
+
+ --%test(test 5 - warnings)
+ PROCEDURE test_5_warnings;
+ --%endcontext
+
+ function my_Func (p IN number) RETURN BOOLEAN;
+ END;
+ '''
+ val parser = new UtplsqlParser(plsql)
+ val first = parser.getLineOf('test_1_ok')
+ Assert.assertEquals(8, first)
+ val last = parser.getLineOf('test_5_warnings')
+ Assert.assertEquals(21, last)
+ }
+
+ @Test
+ def void StartLineBody() {
+ val plsql = '''
+ CREATE OR REPLACE PACKAGE BODY junit_utplsql_test1_pkg IS
+ PROCEDURE test_1_ok IS
+ BEGIN
+ dbms_output.put_line('start test 1');
+ dbms_session.sleep(1);
+ ut.expect(1).to_equal(1);
+ dbms_output.put_line('end test 1');
+ END;
+
+ PROCEDURE test_2_nok IS
+ BEGIN
+ dbms_output.put_line('start test 2');
+ dbms_session.sleep(2);
+ ut.expect(1, 'first assert.').to_equal(2);
+ ut.expect(1, 'second assert.').to_equal(2);
+ dbms_output.put_line('end test 2');
+ END;
+
+ PROCEDURE test_3_disabled IS
+ BEGIN
+ NULL;
+ END;
+
+ PROCEDURE test_4_errored IS
+ BEGIN
+ EXECUTE IMMEDIATE 'bla bla';
+ END;
+
+ PROCEDURE test_5_warnings IS
+ BEGIN
+ COMMIT; -- will raise a warning
+ ut.expect(1).to_equal(1);
+ END;
+ FUNCTION my_Func (p IN number) RETURN BOOLEAN IS
+ RETURN TRUE;
+ END;
+ END;
+ '''
+ val parser = new UtplsqlParser(plsql)
+ val first = parser.getLineOf('test_1_ok')
+ Assert.assertEquals(2, first)
+ val last = parser.getLineOf('test_5_warnings')
+ Assert.assertEquals(29, last)
+ }
}
diff --git a/sqldev/src/test/java/org/utplsql/sqldev/tests/PreferenceModelTest.xtend b/sqldev/src/test/java/org/utplsql/sqldev/test/preference/PreferenceModelTest.xtend
similarity index 73%
rename from sqldev/src/test/java/org/utplsql/sqldev/tests/PreferenceModelTest.xtend
rename to sqldev/src/test/java/org/utplsql/sqldev/test/preference/PreferenceModelTest.xtend
index 206d690b..4b575fca 100644
--- a/sqldev/src/test/java/org/utplsql/sqldev/tests/PreferenceModelTest.xtend
+++ b/sqldev/src/test/java/org/utplsql/sqldev/test/preference/PreferenceModelTest.xtend
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.utplsql.sqldev.tests
+package org.utplsql.sqldev.test.preference
import org.junit.Assert
import org.junit.Test
@@ -22,17 +22,27 @@ import org.utplsql.sqldev.model.preference.PreferenceModel
class PreferenceModelTest {
@Test
- def testDefaultValues() {
+ def defaultValues() {
val PreferenceModel model = PreferenceModel.getInstance(null)
+ Assert.assertTrue(model.useRealtimeReporter)
Assert.assertTrue(model.unsharedWorksheet)
Assert.assertFalse(model.resetPackage)
Assert.assertFalse(model.clearScreen)
Assert.assertTrue(model.autoExecute)
Assert.assertFalse(model.checkRunUtplsqlTest)
+ Assert.assertEquals(model.numberOfRunsInHistory, 10)
+ Assert.assertFalse(model.showDisabledCounter)
+ Assert.assertFalse(model.showWarningsCounter)
+ Assert.assertFalse(model.showInfoCounter)
+ Assert.assertFalse(model.showWarningIndicator)
+ Assert.assertFalse(model.showInfoIndicator)
+ Assert.assertFalse(model.isShowTestDescription)
+ Assert.assertTrue(model.syncDetailTab)
Assert.assertEquals("test_", model.testPackagePrefix)
Assert.assertEquals("", model.testPackageSuffix)
Assert.assertEquals("", model.testUnitPrefix)
Assert.assertEquals("", model.testUnitSuffix)
+ Assert.assertEquals(1, model.numberOfTestsPerUnit)
Assert.assertFalse(model.checkGenerateUtplsqlTest)
Assert.assertTrue(model.generateComments)
Assert.assertFalse(model.disableTests)
@@ -40,6 +50,7 @@ class PreferenceModelTest {
Assert.assertEquals(3, model.indentSpaces)
Assert.assertTrue(model.generateFiles)
Assert.assertEquals(PreferenceModel.DEFAULT_OUTPUT_DIRECTORY, model.outputDirectory)
+ Assert.assertEquals(false, model.deleteExistingFiles)
Assert.assertEquals("utPLSQL", model.rootFolderInOddgenView)
- }
+ }
}
diff --git a/sqldev/src/test/java/org/utplsql/sqldev/test/preference/PreferencePanelTest.xtend b/sqldev/src/test/java/org/utplsql/sqldev/test/preference/PreferencePanelTest.xtend
new file mode 100644
index 00000000..2f5b66f9
--- /dev/null
+++ b/sqldev/src/test/java/org/utplsql/sqldev/test/preference/PreferencePanelTest.xtend
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2018 Philipp Salvisberg
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.utplsql.sqldev.test.preference
+
+import java.awt.Dimension
+import java.awt.Toolkit
+import javax.swing.JFrame
+import javax.swing.SwingUtilities
+import org.junit.Test
+import org.utplsql.sqldev.ui.preference.PreferencePanel
+
+class PreferencePanelTest {
+
+ @Test
+ def void layout() {
+ val frame = new JFrame("Preference Panel")
+ SwingUtilities.invokeLater(new Runnable() {
+ override run() {
+ val panel = new PreferencePanel
+ frame.add(panel)
+ frame.preferredSize = new Dimension(600, 400)
+ frame.pack
+ val dim = Toolkit.getDefaultToolkit().getScreenSize();
+ frame.setLocation(dim.width / 2 - frame.getSize().width / 2, dim.height / 2 - frame.getSize().height / 2);
+ frame.setVisible(true)
+ }
+ });
+ Thread.sleep(4 * 1000)
+ frame.dispose
+ }
+
+}
\ No newline at end of file
diff --git a/sqldev/src/test/java/org/utplsql/sqldev/test/runner/ExpectationTest.xtend b/sqldev/src/test/java/org/utplsql/sqldev/test/runner/ExpectationTest.xtend
new file mode 100644
index 00000000..7aca6152
--- /dev/null
+++ b/sqldev/src/test/java/org/utplsql/sqldev/test/runner/ExpectationTest.xtend
@@ -0,0 +1,46 @@
+package org.utplsql.sqldev.test.runner
+
+import org.junit.Assert
+import org.junit.Before
+import org.junit.Test
+import org.utplsql.sqldev.model.runner.Expectation
+
+class ExpectationTest {
+ var Expectation exceptionWithDescription
+ var Expectation exceptionWithoutDescription
+
+ @Before
+ def void setup() {
+ exceptionWithDescription = new Expectation
+ exceptionWithDescription.description = '''This assert must fail'''
+ exceptionWithDescription.message = '''at: 1 (number) was expected to equal: 2 (number)'''
+ exceptionWithDescription.caller = '''"SCOTT.JUNIT_UTPLSQL_TEST1_PKG.TEST_2_NOK", line 14 ut.expect(1, 'This assert must fail').to_equal(2);'''
+ exceptionWithoutDescription = new Expectation
+ exceptionWithoutDescription.message = exceptionWithDescription.message
+ exceptionWithoutDescription.caller = exceptionWithDescription.caller
+ exceptionWithoutDescription.message = '''at: 1 (number) was expected to equal: 2 (number)'''
+ exceptionWithoutDescription.caller = '''"SCOTT.JUNIT_UTPLSQL_TEST1_PKG.TEST_3_NOK", line 42 ut.expect(1).to_equal(2);'''
+ }
+
+ @Test
+ def void failedExpectationCallerLine() {
+ val actual = exceptionWithDescription.callerLine
+ val expected = new Integer(14)
+ Assert.assertEquals(expected, actual)
+ }
+
+ @Test
+ def void shortFailureTextWithDescription() {
+ val actual = exceptionWithDescription.shortFailureText
+ val expected = 'This assert must fail (line 14)'
+ Assert.assertEquals(expected, actual)
+ }
+
+ @Test
+ def void shortFailureTextWithoutDescription() {
+ val actual = exceptionWithoutDescription.shortFailureText
+ val expected = 'Line 42'
+ Assert.assertEquals(expected, actual)
+ }
+
+}
\ No newline at end of file
diff --git a/sqldev/src/test/java/org/utplsql/sqldev/test/runner/UtplsqlRunnerPanelTest.xtend b/sqldev/src/test/java/org/utplsql/sqldev/test/runner/UtplsqlRunnerPanelTest.xtend
new file mode 100644
index 00000000..45b72543
--- /dev/null
+++ b/sqldev/src/test/java/org/utplsql/sqldev/test/runner/UtplsqlRunnerPanelTest.xtend
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2018 Philipp Salvisberg
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ package org.utplsql.sqldev.test.runner
+
+import java.awt.Toolkit
+import java.util.UUID
+import javax.swing.JFrame
+import javax.swing.SwingUtilities
+import org.junit.Before
+import org.junit.Test
+import org.utplsql.sqldev.model.runner.Run
+import org.utplsql.sqldev.resources.UtplsqlResources
+import org.utplsql.sqldev.ui.runner.RunnerPanel
+
+class UtplsqlRunnerPanelTest {
+ var Run run
+
+ @Before
+ def void setup() {
+ val reporterId = UUID.randomUUID().toString.replace("-", "")
+ run = new Run(null, reporterId, #[])
+ run.startTime = "2019-06-09T13:42:42.123456"
+ run.counter.disabled = 0
+ run.counter.success = 0
+ run.counter.failure = 0
+ run.counter.error = 0
+ run.counter.warning = 0
+ run.totalNumberOfTests = 5
+ run.currentTestNumber = 0
+ }
+
+ @Test
+ def void showGUI() {
+ val start = System.currentTimeMillis
+ val frame = new JFrame("utPLSQL Runner Panel")
+ frame.defaultCloseOperation = JFrame.EXIT_ON_CLOSE;
+ val panel = new RunnerPanel
+ val gui = panel.getGUI
+ panel.model = run
+
+ SwingUtilities.invokeLater(new Runnable() {
+ override run() {
+ frame.add(gui)
+ frame.pack
+ val dim = Toolkit.getDefaultToolkit().getScreenSize();
+ frame.setLocation(dim.width / 2 - frame.getSize().width / 2, dim.height / 2 - frame.getSize().height / 2);
+ frame.setVisible(true)
+ }
+ });
+
+ run.status="starting"
+ panel.update(run.reporterId)
+ Thread.sleep(3000);
+
+ run.counter.success = run.counter.success + 1
+ run.status="utplsql.test.a"
+ panel.update(run.reporterId)
+ Thread.sleep(500);
+
+ run.counter.success = run.counter.success + 1
+ run.status="utplsql.test.b"
+ panel.update(run.reporterId)
+ Thread.sleep(500);
+
+ run.counter.success = run.counter.success + 1
+ run.status="utplsql.test.c"
+ panel.update(run.reporterId)
+ Thread.sleep(500);
+
+ run.counter.failure = run.counter.failure + 1
+ run.status="utplsql.test.d"
+ panel.update(run.reporterId)
+ Thread.sleep(500);
+
+ run.counter.success = run.counter.success + 1
+ run.status="utplsql.test.e"
+ val end = System.currentTimeMillis
+ run.status = String.format(UtplsqlResources.getString("RUNNER_FINNISHED_TEXT"), new Double(end-start)/1000)
+ panel.update(run.reporterId)
+ Thread.sleep(2000);
+ frame.dispose
+ }
+
+}
\ No newline at end of file
diff --git a/sqldev/src/test/java/org/utplsql/sqldev/test/runner/UtplsqlRunnerTest.xtend b/sqldev/src/test/java/org/utplsql/sqldev/test/runner/UtplsqlRunnerTest.xtend
new file mode 100644
index 00000000..23b840b5
--- /dev/null
+++ b/sqldev/src/test/java/org/utplsql/sqldev/test/runner/UtplsqlRunnerTest.xtend
@@ -0,0 +1,136 @@
+/*
+ * Copyright 2018 Philipp Salvisberg
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ package org.utplsql.sqldev.test.runner
+
+import org.junit.AfterClass
+import org.junit.BeforeClass
+import org.junit.Test
+import org.springframework.jdbc.BadSqlGrammarException
+import org.springframework.jdbc.datasource.SingleConnectionDataSource
+import org.utplsql.sqldev.runner.UtplsqlRunner
+import org.utplsql.sqldev.test.AbstractJdbcTest
+
+class UtplsqlRunnerTest extends AbstractJdbcTest {
+
+ @BeforeClass
+ def static void setup() {
+ jdbcTemplate.execute('''
+ CREATE OR REPLACE PACKAGE junit_utplsql_test1_pkg is
+ --%suite(JUnit testing)
+ --%suitepath(a)
+ /* tags annotation without parameter will raise a warning */
+ --%tags
+
+ --%context(test context)
+
+ --%test(test 1 - OK)
+ PROCEDURE test_1_ok;
+
+ --%test(test 2 - NOK)
+ PROCEDURE test_2_nok;
+
+ --%test(test 3 - disabled)
+ --%disabled
+ PROCEDURE test_3_disabled;
+
+ --%test(test 4 - errored)
+ PROCEDURE test_4_errored;
+
+ --%test(test 5 - warnings)
+ PROCEDURE test_5_warnings;
+
+ --%endcontext
+
+ --%afterall
+ procedure print_and_raise;
+ END;
+ ''')
+ jdbcTemplate.execute('''
+ CREATE OR REPLACE PACKAGE BODY junit_utplsql_test1_pkg IS
+ PROCEDURE test_1_ok IS
+ BEGIN
+ dbms_output.put_line('start test 1');
+ dbms_session.sleep(1);
+ ut.expect(1).to_equal(1);
+ dbms_output.put_line('end test 1');
+ END;
+
+ PROCEDURE test_2_nok IS
+ BEGIN
+ dbms_output.put_line('start test 2');
+ dbms_session.sleep(2);
+ ut.expect(1, 'first assert.').to_equal(2);
+ ut.expect(1, 'second assert.').to_equal(2);
+ dbms_output.put_line('end test 2');
+ END;
+
+ PROCEDURE test_3_disabled IS
+ BEGIN
+ NULL;
+ END;
+
+ PROCEDURE test_4_errored IS
+ BEGIN
+ EXECUTE IMMEDIATE 'bla bla';
+ END;
+
+ PROCEDURE test_5_warnings IS
+ BEGIN
+ COMMIT; -- will raise a warning
+ ut.expect(1).to_equal(1);
+ END;
+
+ PROCEDURE print_and_raise IS
+ BEGIN
+ dbms_output.put_line('Now, a no_data_found exception is raised');
+ dbms_output.put_line('dbms_output and error stack is reported for this suite.');
+ dbms_output.put_line('A runtime error in afterall is counted as a warning.');
+ RAISE no_data_found;
+ END;
+ END;
+ ''')
+ }
+
+ @AfterClass
+ def static void teardown() {
+ try {
+ jdbcTemplate.execute("DROP PACKAGE junit_utplsql_test1_pkg")
+ } catch (BadSqlGrammarException e) {
+ // ignore
+ }
+ }
+
+ @Test
+ def void runTestsWithMaxTime() {
+ var ds1 = new SingleConnectionDataSource()
+ ds1.driverClassName = "oracle.jdbc.OracleDriver"
+ ds1.url = dataSource.url
+ ds1.username = dataSource.username
+ ds1.password = dataSource.password
+ var ds2 = new SingleConnectionDataSource()
+ ds2.driverClassName = "oracle.jdbc.OracleDriver"
+ ds2.url = dataSource.url
+ ds2.username = dataSource.username
+ ds2.password = dataSource.password
+ var runner = new UtplsqlRunner(#[":a"], ds1.connection, ds2.connection)
+ runner.runTestAsync
+ runner.producerThread.join(200000)
+ runner.consumerThread.join(200000)
+ Thread.sleep(4 * 1000)
+ runner.dispose
+ }
+
+}
\ No newline at end of file
diff --git a/sqldev/src/test/java/org/utplsql/sqldev/tests/UrlToolsTest.xtend b/sqldev/src/test/java/org/utplsql/sqldev/tests/UrlToolsTest.xtend
deleted file mode 100644
index eee16ce3..00000000
--- a/sqldev/src/test/java/org/utplsql/sqldev/tests/UrlToolsTest.xtend
+++ /dev/null
@@ -1,31 +0,0 @@
-package org.utplsql.sqldev.tests
-
-import org.junit.Assert
-import org.junit.Test
-import org.utplsql.sqldev.model.URLTools
-
-class UrlToolsTest {
- val extension URLTools urlTools = new URLTools
-
- @Test
- def void testReplacePlusSign() {
- Assert.assertEquals("+", "%2B".replaceHexChars)
- Assert.assertEquals("++", "%2B%2B".replaceHexChars)
- Assert.assertEquals("abc+%xyz", "abc%2B%xyz".replaceHexChars)
- }
-
- @Test
- def void testReplaceAtSign() {
- Assert.assertEquals("@", "%40".replaceHexChars)
- Assert.assertEquals("@@", "%40%40".replaceHexChars)
- Assert.assertEquals("abc@%xyz", "abc%40%xyz".replaceHexChars)
- }
-
- @Test
- def void testReplaceAtAndPlusSign() {
- Assert.assertEquals("@+", "%40%2B".replaceHexChars)
- Assert.assertEquals("@+@+", "%40%2B%40%2B".replaceHexChars)
- Assert.assertEquals("abc@+%xyz", "abc%40%2B%xyz".replaceHexChars)
- }
-
-}