Skip to content

Commit 9242fa1

Browse files
authored
Merge pull request #52 from mendix/uia/827-test-group-color
[UIA-827] Release of version 9.4.3
2 parents a37a89b + 7a7acba commit 9242fa1

11 files changed

+251
-262
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
66

77
## [Unreleased]
88

9+
## [9.4.3] - 2024-05-01
10+
11+
### Fixed:
12+
- We fixed an issue where the result of a test suite was not updated after running an individual test
13+
- We fixed an issue in transaction handling for teardown microflows that could result in a database lock
14+
- We changed the length to limited for the 'Name' attribute in the UnitTest entity
15+
916
## [9.4.2] - 2024-02-07
1017

1118
### Fixed:

dist/UnitTesting_9.4.3.mpk

2.94 MB
Binary file not shown.

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.mendix.UnitTesting</groupId>
88
<artifactId>UnitTesting</artifactId>
9-
<version>9.4.2</version>
9+
<version>9.4.3</version>
1010

1111
<repositories>
1212
<repository>

src/UnitTesting.mpr

0 Bytes
Binary file not shown.
Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
11
package unittesting;
22

3-
public class AbstractUnitTest
4-
{
5-
private static long startTime;
3+
public class AbstractUnitTest {
4+
private static long startTime;
65
private static long endTime;
76

87
public static long getTestRunTime() {
98
return endTime - startTime;
109
}
11-
10+
1211
public void startTimeMeasure() {
1312
startTime = System.currentTimeMillis();
1413
}
15-
14+
1615
public void endTimeMeasure() {
1716
endTime = System.currentTimeMillis();
1817
}
19-
20-
public void reportStep(String lastStep1)
21-
{
18+
19+
public void reportStep(String lastStep1) {
2220
TestManager.instance().reportStep(lastStep1);
2321
}
2422
}

src/javasource/unittesting/RemoteApiServlet.java

Lines changed: 38 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,23 @@ public class RemoteApiServlet extends RequestHandler {
3030
private static final Object COMMAND_START = "start";
3131
private static final Object COMMAND_STATUS = "status";
3232
private static final String PARAM_PASSWORD = "password";
33-
33+
3434
private final String password;
3535
private boolean detectedUnitTests = false;
36-
36+
3737
private final static ILogNode LOG = TestManager.LOG;
3838
private volatile TestSuiteRunner testSuiteRunner;
39-
39+
4040
public RemoteApiServlet(String password) {
4141
this.password = password;
4242
}
4343

4444
@Override
45-
protected void processRequest(IMxRuntimeRequest req,
46-
IMxRuntimeResponse resp, String path) throws Exception {
47-
45+
protected void processRequest(IMxRuntimeRequest req, IMxRuntimeResponse resp, String path) throws Exception {
46+
4847
HttpServletRequest request = req.getHttpServletRequest();
4948
HttpServletResponse response = resp.getHttpServletResponse();
50-
49+
5150
try {
5251
if (!"POST".equals(request.getMethod()))
5352
response.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
@@ -57,12 +56,10 @@ else if (COMMAND_STATUS.equals(path))
5756
serveRunStatus(request, response, path);
5857
else
5958
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
60-
}
61-
catch (IllegalArgumentException e) {
59+
} catch (IllegalArgumentException e) {
6260
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
6361
write(response, e.getMessage());
64-
}
65-
catch (InvalidCredentialsException e) {
62+
} catch (InvalidCredentialsException e) {
6663
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
6764
write(response, "Invalid password provided");
6865
}
@@ -74,60 +71,59 @@ private void write(HttpServletResponse response, String data) {
7471
} catch (Exception e) {
7572
throw new RuntimeException(e);
7673
}
77-
74+
7875
}
7976

80-
private synchronized void serveRunStatus(HttpServletRequest request,
81-
HttpServletResponse response, String path) throws Exception {
77+
private synchronized void serveRunStatus(HttpServletRequest request, HttpServletResponse response, String path)
78+
throws Exception {
8279
JSONObject input = parseInput(request);
8380
verifyPassword(input);
84-
81+
8582
if (testSuiteRunner == null) {
8683
throw new IllegalArgumentException("No testrun was started yet");
8784
}
88-
85+
8986
response.setStatus(HttpServletResponse.SC_OK);
9087
response.setHeader("Content-Type", "application/json");
9188
write(response, testSuiteRunner.getStatus().toString(4));
9289
}
9390

94-
private synchronized void serveRunStart(HttpServletRequest request,
95-
HttpServletResponse response, String path) throws IOException, CoreException, InvalidCredentialsException {
91+
private synchronized void serveRunStart(HttpServletRequest request, HttpServletResponse response, String path)
92+
throws IOException, CoreException, InvalidCredentialsException {
9693
JSONObject input = parseInput(request);
9794
verifyPassword(input);
98-
95+
9996
IContext context = Core.createSystemContext();
10097
if (!detectedUnitTests) {
10198
TestManager.instance().findAllTests(context);
10299
detectedUnitTests = true;
103100
}
104-
101+
105102
if (testSuiteRunner != null && !testSuiteRunner.isFinished()) {
106103
throw new IllegalArgumentException("Cannot start a test run while another test run is still running");
107104
}
108-
105+
109106
LOG.info("[remote api] starting new test run");
110107
testSuiteRunner = new TestSuiteRunner();
111-
108+
112109
Thread t = new Thread() {
113110
@Override
114111
public void run() {
115112
testSuiteRunner.run();
116113
}
117114
};
118-
115+
119116
t.start();
120-
response.setStatus(HttpServletResponse.SC_NO_CONTENT);
117+
response.setStatus(HttpServletResponse.SC_NO_CONTENT);
121118
}
122-
123-
124119

125120
private void verifyPassword(JSONObject input) throws InvalidCredentialsException {
126121
if (!input.has(PARAM_PASSWORD)) {
127122
LOG.warn("[remote api] Missing password");
128-
throw new IllegalArgumentException("No '" + PARAM_PASSWORD + "' attribute found in the JSON body. Please provide a password");
123+
throw new IllegalArgumentException(
124+
"No '" + PARAM_PASSWORD + "' attribute found in the JSON body. Please provide a password");
129125
}
130-
126+
131127
if (!password.equals(input.getString(PARAM_PASSWORD))) {
132128
LOG.warn("[remote api] Invalid password");
133129
throw new InvalidCredentialsException();
@@ -143,7 +139,7 @@ private class TestSuiteRunner {
143139
boolean finished = false;
144140
long startTime = System.currentTimeMillis();
145141
long totalTime = -1;
146-
142+
147143
public void run() {
148144
try {
149145
TestManager.instance().runTestSuites();
@@ -153,9 +149,9 @@ public void run() {
153149
totalTime = System.currentTimeMillis() - startTime;
154150
finished = true;
155151
LOG.info("[remote api] finished test run");
156-
}
152+
}
157153
}
158-
154+
159155
public synchronized boolean isFinished() {
160156
return finished;
161157
}
@@ -164,46 +160,46 @@ public synchronized JSONObject getStatus() throws CoreException {
164160
JSONObject result = new JSONObject();
165161
result.put("completed", this.finished);
166162
result.put("runtime", totalTime);
167-
163+
168164
IContext context = Core.createSystemContext();
169165
long count = 0l;
170166
long failures = 0l;
171-
172-
List<IMendixObject> testSuites = Core.retrieveXPathQuery(context, String.format("//%s", TestSuite.entityName));
167+
168+
List<IMendixObject> testSuites = Core.retrieveXPathQuery(context,
169+
String.format("//%s", TestSuite.entityName));
173170

174171
for (IMendixObject mxObject : testSuites) {
175172
TestSuite testSuite = TestSuite.initialize(context, mxObject);
176173
count += testSuite.getTestCount();
177174
failures += testSuite.getTestFailedCount();
178175
}
179-
176+
180177
result.put("tests", count);
181178
result.put("failures", failures);
182-
179+
183180
JSONArray failedTests = new JSONArray();
184181
result.put("failed_tests", failedTests);
185-
182+
186183
StringBuilder query = new StringBuilder();
187184
query.append(String.format("//%s", UnitTest.entityName));
188185
// Failed tests
189186
query.append("[" + UnitTest.MemberNames.Result + "=\"" + UnitTestResult._2_Failed + "\"]");
190187
// In test suites that are not running anymore
191188
query.append("[" + UnitTest.MemberNames.UnitTest_TestSuite + "/" + TestSuite.entityName + "/"
192189
+ TestSuite.MemberNames.Result + "=\"" + UnitTestResult._2_Failed + "\"]");
193-
190+
194191
List<IMendixObject> unitTests = Core.retrieveXPathQuery(context, query.toString());
195192

196-
for(IMendixObject mxObject : unitTests)
197-
{
193+
for (IMendixObject mxObject : unitTests) {
198194
UnitTest test = UnitTest.initialize(context, mxObject);
199195
JSONObject i = new JSONObject();
200196
i.put("name", test.getName());
201197
i.put("error", test.getResultMessage());
202198
i.put("step", test.getLastStep());
203199
failedTests.put(i);
204200
}
205-
201+
206202
return result;
207-
}
203+
}
208204
}
209205
}

0 commit comments

Comments
 (0)