Skip to content

Commit

Permalink
Have unit test for Storage.clean() (#354)
Browse files Browse the repository at this point in the history
  • Loading branch information
mhdirkse authored Jan 8, 2025
1 parent 4532277 commit fb3e580
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/test/java/nl/nn/testtool/test/junit/storage/TestStorages.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package nl.nn.testtool.test.junit.storage;

import nl.nn.testtool.storage.Storage;
import nl.nn.testtool.test.junit.ReportRelatedTestCase;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.lang.invoke.MethodHandles;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

public class TestStorages extends ReportRelatedTestCase {
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
private Storage storage;

@Before
public void setUp() {
super.setUp();
storage = testTool.getDebugStorage();
assertNotNull(storage);
try {
storage.clear();
assertEquals(0, storage.getSize());
} catch(Exception e) {
log.error("Exception while clearing storage: ", e);
}
}

@Test
public void testClearStorage() throws Exception {
createReport();
createReport();
assertEquals(2, storage.getSize());
storage.clear();
assertEquals(0, storage.getSize());
}

private void createReport() {
String correlationId = getCorrelationId();
testTool.startpoint(correlationId, this.getClass().getTypeName(), reportName, "startmessage");
testTool.endpoint(correlationId, this.getClass().getTypeName(), reportName, "endmessage");
}
}

0 comments on commit fb3e580

Please sign in to comment.