-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Have unit test for Storage.clean() (#354)
- Loading branch information
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
src/test/java/nl/nn/testtool/test/junit/storage/TestStorages.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} |