Skip to content

Commit 88037f1

Browse files
authored
Merge pull request #22 from passalaqua/fix/npe-teardown
Fix for the null pointer exception during tear down
2 parents 228c698 + 9993802 commit 88037f1

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/UnitTesting.mpr

0 Bytes
Binary file not shown.

src/javasource/unittesting/TestManager.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -144,22 +144,18 @@ private void runMfSetup(TestSuite testSuite)
144144

145145
private void runMfTearDown(TestSuite testSuite)
146146
{
147-
IContext tearDownContext = null;
147+
IContext tearDownContext = setupContext;
148148
if (Core.getMicroflowNames().contains(testSuite.getModule() + ".TearDown")) {
149149
try
150150
{
151151
LOG.info("Running TearDown microflow..");
152+
if (tearDownContext == null) {
153+
tearDownContext = Core.createSystemContext();
154+
}
152155
if (testSuite.getAutoRollbackMFs()) {
153-
if (Core.getMicroflowNames().contains(testSuite.getModule() + ".Setup")) {
154-
tearDownContext = setupContext;
155-
} else {
156-
tearDownContext = Core.createSystemContext();
157-
tearDownContext.startTransaction();
158-
}
159-
Core.execute(tearDownContext, testSuite.getModule() + ".TearDown", emptyArguments);
160-
} else {
161-
Core.execute(Core.createSystemContext(), testSuite.getModule() + ".TearDown", emptyArguments);
156+
tearDownContext.startTransaction();
162157
}
158+
Core.execute(tearDownContext, testSuite.getModule() + ".TearDown", emptyArguments);
163159
}
164160
catch (Exception e)
165161
{
@@ -168,9 +164,13 @@ private void runMfTearDown(TestSuite testSuite)
168164
}
169165
}
170166

171-
if (testSuite.getAutoRollbackMFs()) {
167+
// Either we had a teardown a teardown or
168+
if (testSuite.getAutoRollbackMFs() && tearDownContext != null) {
172169
tearDownContext.rollbackTransAction();
173170
}
171+
172+
// Make sure we clean setupContext after running this test/suite
173+
setupContext = null;
174174
}
175175

176176
public synchronized void runTestSuites() throws CoreException {

0 commit comments

Comments
 (0)