Skip to content

Commit cf26469

Browse files
Merge pull request #130 from utPLSQL/bugfix/issue-126-suite-descriptions-b
Bugfix #126 - Suite descriptions are not aggregated
2 parents 6df7d05 + 51684d7 commit cf26469

File tree

5 files changed

+117
-8
lines changed

5 files changed

+117
-8
lines changed

sqldev/src/main/java/org/utplsql/sqldev/model/XMLTools.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,13 @@ public Node getElementNode(final Node node, final String tagName) {
130130
Node resultNode = null;
131131
if (node instanceof Element) {
132132
NodeList list = ((Element) node).getElementsByTagName(tagName);
133-
if (list != null && list.getLength() > 0) {
133+
if (list != null && list.getLength() > 0 && list.item(0).getParentNode() == node) {
134134
resultNode = list.item(0);
135135
}
136136
}
137137
return resultNode;
138138
}
139-
139+
140140
public DocumentBuilder createDocumentBuilder() {
141141
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
142142
try {

sqldev/src/main/java/org/utplsql/sqldev/runner/UtplsqlRunner.java

+6
Original file line numberDiff line numberDiff line change
@@ -469,4 +469,10 @@ public Thread getProducerThread() {
469469
public Thread getConsumerThread() {
470470
return consumerThread;
471471
}
472+
473+
// for testing purposes only
474+
public Run getRun() {
475+
return run;
476+
}
477+
472478
}

sqldev/src/main/java/org/utplsql/sqldev/ui/runner/TestOverviewTreeTableModel.java

-6
Original file line numberDiff line numberDiff line change
@@ -483,12 +483,6 @@ public Object getValueAt(Object node, int col) {
483483
switch (col) {
484484
case 0:
485485
if (showDescription && itemNode.getDescription() != null) {
486-
if (itemNode.getUserObject() instanceof Suite) {
487-
if (!itemNode.getName().contains("context_#")) {
488-
// description of suites might be bewildering, hence use it for contexts only
489-
return itemNode.getName();
490-
}
491-
}
492486
return itemNode.getDescription();
493487
} else {
494488
return itemNode.getName();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
/*
2+
* Copyright 2021 Philipp Salvisberg <philipp.salvisberg@trivadis.com>
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.utplsql.sqldev.test.runner;
17+
18+
import java.sql.Connection;
19+
import java.util.Collections;
20+
import java.util.LinkedHashMap;
21+
22+
import org.junit.After;
23+
import org.junit.Assert;
24+
import org.junit.Before;
25+
import org.junit.Test;
26+
import org.springframework.jdbc.datasource.SingleConnectionDataSource;
27+
import org.utplsql.sqldev.model.DatabaseTools;
28+
import org.utplsql.sqldev.model.SystemTools;
29+
import org.utplsql.sqldev.model.runner.ItemNode;
30+
import org.utplsql.sqldev.runner.UtplsqlRunner;
31+
import org.utplsql.sqldev.test.AbstractJdbcTest;
32+
33+
public class UtplsqlRunnerAggregationTest extends AbstractJdbcTest {
34+
static final int SHOW_GUI_AFTER_RUN_COMPLETION_IN_SECONDS = 0;
35+
36+
@Before
37+
public void setup() {
38+
// based on https://github.com/utPLSQL/utPLSQL-SQLDeveloper/issues/126
39+
jdbcTemplate.execute(
40+
"create or replace package x is\n"
41+
+ "\n"
42+
+ " --%suite(suite x)\n"
43+
+ " --%suitepath(foo.bar)\n"
44+
+ "\n"
45+
+ " --%test(feature a)\n"
46+
+ " --%disabled\n"
47+
+ " procedure test_a;\n"
48+
+ "\n"
49+
+ " --%test(feature b)\n"
50+
+ " --%disabled\n"
51+
+ " procedure test_b;\n"
52+
+ "\n"
53+
+ "end;");
54+
jdbcTemplate.execute(
55+
"create or replace package y is\n"
56+
+ "\n"
57+
+ " --%suite(suite y)\n"
58+
+ " --%suitepath(foo.bar)\n"
59+
+ "\n"
60+
+ " --%test(feature c)\n"
61+
+ " --%disabled\n"
62+
+ " procedure test_c;\n"
63+
+ "\n"
64+
+ " --%test(feature d)\n"
65+
+ " --%disabled\n"
66+
+ " procedure test_d;\n"
67+
+ "\n"
68+
+ "end;");
69+
}
70+
71+
@After
72+
public void teardown() {
73+
executeAndIgnore(jdbcTemplate, "DROP PACKAGE x");
74+
executeAndIgnore(jdbcTemplate, "DROP PACKAGE y");
75+
}
76+
77+
private Connection getNewConnection() {
78+
final SingleConnectionDataSource ds = new SingleConnectionDataSource();
79+
ds.setDriverClassName("oracle.jdbc.OracleDriver");
80+
ds.setUrl(dataSource.getUrl());
81+
ds.setUsername(dataSource.getUsername());
82+
ds.setPassword(dataSource.getPassword());
83+
return DatabaseTools.getConnection(ds);
84+
}
85+
86+
@Test
87+
public void aggregateDescription() {
88+
UtplsqlRunner runner = new UtplsqlRunner(Collections.singletonList(":foo"), getNewConnection(), getNewConnection());
89+
runner.runTestAsync();
90+
SystemTools.waitForThread(runner.getProducerThread(), 10000);
91+
SystemTools.waitForThread(runner.getConsumerThread(), 10000);
92+
Assert.assertNotNull(runner);
93+
LinkedHashMap<String, ItemNode> nodes = runner.getRun().getItemNodes();
94+
Assert.assertEquals(9, nodes.size()); // 8 + 1 for the run node
95+
Assert.assertNotNull(nodes.get(runner.getRun().getReporterId()));
96+
Assert.assertNull(nodes.get("foo").getDescription());
97+
Assert.assertNull(nodes.get("foo.bar").getDescription());
98+
Assert.assertEquals("suite y", nodes.get("foo.bar.y").getDescription());
99+
Assert.assertEquals("suite x", nodes.get("foo.bar.x").getDescription());
100+
Assert.assertEquals("feature c", nodes.get("foo.bar.y.test_c").getDescription());
101+
Assert.assertEquals("feature d", nodes.get("foo.bar.y.test_d").getDescription());
102+
Assert.assertEquals("feature a", nodes.get("foo.bar.x.test_a").getDescription());
103+
Assert.assertEquals("feature b", nodes.get("foo.bar.x.test_b").getDescription());
104+
SystemTools.sleep(SHOW_GUI_AFTER_RUN_COMPLETION_IN_SECONDS * 1000);
105+
runner.dispose();
106+
}
107+
108+
}

sqldev/src/test/java/org/utplsql/sqldev/test/runner/UtplsqlRunnerTest.java

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public void setupDefaultPreferences() {
5252
preferences.setShowSuccessfulTests(true);
5353
preferences.setShowWarningIndicator(false);
5454
preferences.setShowInfoIndicator(false);
55+
preferences.setShowTestDescription(true);
5556
}
5657
}
5758

0 commit comments

Comments
 (0)