Skip to content

Commit 446d663

Browse files
committed
Fix #204: High memory usage of Metamorph tests
The metamorph test framework loads all test definitions into memory prior to running the tests. For each test definition the Metamorph script under test is instantiated. If there are many test cases this can consume a lot of memory (in particular if the script is large). This is changed so that the Metamorph module is created in the `run` function of `TestCase` and stored in a local variable.
1 parent 3a509d9 commit 446d663

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/main/java/org/culturegraph/mf/test/TestCase.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,13 @@ public final class TestCase {
5151
private static final String STRICT_KEY_ORDER_ATTR = "strict-key-order";
5252
private static final String STRICT_VALUE_ORDER_ATTR = "strict-value-order";
5353

54-
5554
private static final String MIME_METAMORPH = "text/x-metamorph+xml";
5655
private static final String MIME_JAVACLASS = "application/java";
5756

5857
private final Element config;
5958

60-
private final Reader inputReader;
61-
private final StreamPipe<StreamReceiver> transformation;
62-
63-
@SuppressWarnings("unchecked")
6459
public TestCase(final Element config) {
6560
this.config = config;
66-
inputReader = getReader(INPUT_TAG);
67-
transformation = getTransformation();
6861
}
6962

7063
public String getName() {
@@ -76,8 +69,11 @@ public boolean isIgnore() {
7669
}
7770

7871
public void run() {
79-
72+
final Reader inputReader = getReader(INPUT_TAG);
73+
@SuppressWarnings("unchecked")
74+
final StreamPipe<StreamReceiver>transformation = getTransformation();
8075
final EventList resultStream = new EventList();
76+
8177
if (transformation == null) {
8278
inputReader.setReceiver(resultStream);
8379
} else {

0 commit comments

Comments
 (0)