Skip to content

Commit 18a7a2b

Browse files
committed
improved tests to check HTTP HEAD and permanent delete performance
1 parent b8ed13c commit 18a7a2b

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

dsf-fhir/dsf-fhir-server/src/test/java/dev/dsf/fhir/integration/BinaryIntegrationTest.java

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,23 @@ public void testReadAllowedLocalUser() throws Exception
7171
getWebserviceClient().read(Binary.class, created.getIdElement().getIdPart());
7272
}
7373

74+
@Test
75+
public void testReadHeadAllowedLocalUser() throws Exception
76+
{
77+
final String contentType = MediaType.TEXT_PLAIN;
78+
final byte[] data = "Hello World".getBytes(StandardCharsets.UTF_8);
79+
80+
Binary binary = new Binary();
81+
binary.setContentType(contentType);
82+
binary.setData(data);
83+
getReadAccessHelper().addLocal(binary);
84+
85+
BinaryDao binDao = getSpringWebApplicationContext().getBean(BinaryDao.class);
86+
Binary created = binDao.create(binary);
87+
88+
assertTrue(getWebserviceClient().exists(Binary.class, created.getIdElement().getIdPart()));
89+
}
90+
7491
@Test
7592
public void testReadAllowedLocalUserViaSecurityContext() throws Exception
7693
{
@@ -2915,7 +2932,7 @@ public void testCreate8MiB() throws Exception
29152932
}
29162933

29172934
@Test
2918-
public void testCreate4GiB() throws Exception
2935+
public void testCreateReadDelete4GiB() throws Exception
29192936
{
29202937
long payloadSize = RandomInputStream.ONE_GIBIBYTE * 4;
29212938

@@ -2933,6 +2950,15 @@ public void testCreate4GiB() throws Exception
29332950
MediaType.APPLICATION_OCTET_STREAM_TYPE, securityContext);
29342951
assertNotNull(created);
29352952

2953+
long t0h = System.currentTimeMillis();
2954+
assertTrue(getWebserviceClient().exists(Binary.class, created.getIdPart(), created.getVersionIdPart()));
2955+
long t1h = System.currentTimeMillis();
2956+
2957+
long headExecTime = t1h - t0h;
2958+
logger.info("HTTP HEAD call finished in {} ms", headExecTime);
2959+
assertTrue("HTTP HEAD call took longer then 200 ms, (" + headExecTime + ")", headExecTime < 200);
2960+
2961+
long t0g = System.currentTimeMillis();
29362962
InputStream in = getWebserviceClient().readBinary(created.getIdPart(), created.getVersionIdPart(),
29372963
MediaType.APPLICATION_OCTET_STREAM_TYPE);
29382964

@@ -2948,6 +2974,23 @@ public void testCreate4GiB() throws Exception
29482974

29492975
assertEquals(payloadSize, readSize);
29502976
}
2977+
long t1g = System.currentTimeMillis();
2978+
2979+
logger.info("HTTP GET call finished in {} ms", (t1g - t0g));
2980+
2981+
long t0d = System.currentTimeMillis();
2982+
getWebserviceClient().delete(Binary.class, created.getIdPart());
2983+
long t1d = System.currentTimeMillis();
2984+
2985+
long deleteExecTime = t1d - t0d;
2986+
logger.info("HTTP DELETE call finished in {} ms", deleteExecTime);
2987+
assertTrue("HTTP DELETE call took longer then 200 ms, (" + deleteExecTime + ")", deleteExecTime < 200);
2988+
2989+
long t0pd = System.currentTimeMillis();
2990+
getWebserviceClient().deletePermanently(Binary.class, created.getIdPart());
2991+
long t1pd = System.currentTimeMillis();
2992+
2993+
logger.info("Permanent delete call finished in {} ms", (t1pd - t0pd));
29512994
}
29522995

29532996
@Test

0 commit comments

Comments
 (0)