1 package org.simantics.modeling.tests.commands;
3 import junit.framework.Assert;
5 import org.simantics.db.testing.common.WriteCommand;
6 import org.simantics.modeling.tests.cases.ModelingCommandSequenceTest;
8 public class AssertMemoryConsumption extends WriteCommand<ModelingCommandSequenceTest> {
12 public AssertMemoryConsumption(int expected) {
13 this.expected = expected;
17 public void run(ModelingCommandSequenceTest environment) throws Exception {
18 Assert.assertTrue(getUsedMemory() < expected);
21 private long getUsedMemory() {
26 Runtime runtime = Runtime.getRuntime();
27 return runtime.totalMemory() - runtime.freeMemory();