From 64d2bc1ee4c56567e67ff0a874730159f2304d0b Mon Sep 17 00:00:00 2001 From: Paul Warren Date: Mon, 2 May 2022 21:46:14 -0700 Subject: [PATCH 1/3] iEnsure tests use different content for rendition property --- .../src/test/java/it/store/FilesystemStoreIT.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/spring-content-fs/src/test/java/it/store/FilesystemStoreIT.java b/spring-content-fs/src/test/java/it/store/FilesystemStoreIT.java index bb2c756b3..26c7fa6a6 100644 --- a/spring-content-fs/src/test/java/it/store/FilesystemStoreIT.java +++ b/spring-content-fs/src/test/java/it/store/FilesystemStoreIT.java @@ -270,7 +270,7 @@ public class FilesystemStoreIT { entity = repo.save(entity); store.setContent(entity, new ByteArrayInputStream("Hello Spring Content World!".getBytes())); - store.setContent(entity, PropertyPath.from("rendition"), new ByteArrayInputStream("Hello Spring Content World!".getBytes())); + store.setContent(entity, PropertyPath.from("rendition"), new ByteArrayInputStream("Hello Spring Content World!".getBytes())); }); It("should be able to store new content", () -> { @@ -281,7 +281,7 @@ public class FilesystemStoreIT { //rendition try (InputStream content = store.getContent(entity, PropertyPath.from("rendition"))) { - assertThat(IOUtils.contentEquals(new ByteArrayInputStream("Hello Spring Content World!".getBytes()), content), is(true)); + assertThat(IOUtils.contentEquals(new ByteArrayInputStream("Hello Spring Content World!".getBytes()), content), is(true)); } catch (IOException ioe) {} }); @@ -294,13 +294,13 @@ public class FilesystemStoreIT { //rendition assertThat(entity.getRenditionId(), is(notNullValue())); assertThat(entity.getRenditionId().trim().length(), greaterThan(0)); - Assert.assertEquals(entity.getRenditionLen(), 27L); + Assert.assertEquals(entity.getRenditionLen(), 40L); }); Context("when content is updated", () -> { BeforeEach(() ->{ store.setContent(entity, new ByteArrayInputStream("Hello Updated Spring Content World!".getBytes())); - store.setContent(entity, PropertyPath.from("rendition"), new ByteArrayInputStream("Hello Updated Spring Content World!".getBytes())); + store.setContent(entity, PropertyPath.from("rendition"), new ByteArrayInputStream("Hello Updated Spring Content World!".getBytes())); entity = repo.save(entity); }); @@ -315,7 +315,7 @@ public class FilesystemStoreIT { //rendition matches = false; try (InputStream content = store.getContent(entity, PropertyPath.from("rendition"))) { - matches = IOUtils.contentEquals(new ByteArrayInputStream("Hello Updated Spring Content World!".getBytes()), content); + matches = IOUtils.contentEquals(new ByteArrayInputStream("Hello Updated Spring Content World!".getBytes()), content); assertThat(matches, is(true)); } }); @@ -324,7 +324,7 @@ public class FilesystemStoreIT { Context("when content is updated with shorter content", () -> { BeforeEach(() -> { store.setContent(entity, new ByteArrayInputStream("Hello Spring World!".getBytes())); - store.setContent(entity, PropertyPath.from("rendition"), new ByteArrayInputStream("Hello Spring World!".getBytes())); + store.setContent(entity, PropertyPath.from("rendition"), new ByteArrayInputStream("Hello Spring World!".getBytes())); entity = repo.save(entity); }); It("should store only the new content", () -> { @@ -338,7 +338,7 @@ public class FilesystemStoreIT { //rendition matches = false; try (InputStream content = store.getContent(entity, PropertyPath.from("rendition"))) { - matches = IOUtils.contentEquals(new ByteArrayInputStream("Hello Spring World!".getBytes()), content); + matches = IOUtils.contentEquals(new ByteArrayInputStream("Hello Spring World!".getBytes()), content); assertThat(matches, is(true)); } }); From 2f522c3521856212905ab70d061280ff12e0f517 Mon Sep 17 00:00:00 2001 From: Paul Warren Date: Mon, 2 May 2022 21:50:50 -0700 Subject: [PATCH 2/3] S3 store getResource should use the id object not the entity --- .../content/s3/store/DefaultS3StoreImpl.java | 20 ++++++++++++++++--- .../content/s3/it/S3StoreIT.java | 20 +++++++++---------- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/spring-content-s3/src/main/java/internal/org/springframework/content/s3/store/DefaultS3StoreImpl.java b/spring-content-s3/src/main/java/internal/org/springframework/content/s3/store/DefaultS3StoreImpl.java index 37b1e6bf4..35dd3d324 100644 --- a/spring-content-s3/src/main/java/internal/org/springframework/content/s3/store/DefaultS3StoreImpl.java +++ b/spring-content-s3/src/main/java/internal/org/springframework/content/s3/store/DefaultS3StoreImpl.java @@ -115,8 +115,8 @@ public Resource getResource(S entity, PropertyPath propertyPath) { return null; S3ObjectId s3ObjectId = null; - if (placementService.canConvert(entity.getClass(), S3ObjectId.class)) { - s3ObjectId = placementService.convert(entity, S3ObjectId.class); + if (placementService.canConvert(property.getContentIdType(entity).getClass(), S3ObjectId.class)) { + s3ObjectId = placementService.convert(property.getContentId(entity), S3ObjectId.class); if (s3ObjectId != null) { return this.getResourceInternal(s3ObjectId); @@ -413,7 +413,7 @@ public S unsetContent(S entity, PropertyPath propertyPath) { if (entity == null) return entity; - deleteIfExists(entity); + deleteIfExists(entity, propertyPath); // reset content fields property.setContentId(entity, null, new org.springframework.content.commons.mappingcontext.Condition() { @@ -461,4 +461,18 @@ private void deleteIfExists(S entity) { } } } + + private void deleteIfExists(S entity, PropertyPath path) { + + Resource resource = this.getResource(entity, path); + if (resource != null && resource.exists() && resource instanceof DeletableResource) { + + try { + ((DeletableResource)resource).delete(); + } catch (Exception e) { + logger.error(format("Unexpected error unsetting content for entity %s", entity)); + throw new StoreAccessException(format("Unsetting content for entity %s", entity), e); + } + } + } } diff --git a/spring-content-s3/src/test/java/internal/org/springframework/content/s3/it/S3StoreIT.java b/spring-content-s3/src/test/java/internal/org/springframework/content/s3/it/S3StoreIT.java index ed2e7be32..0f5540070 100644 --- a/spring-content-s3/src/test/java/internal/org/springframework/content/s3/it/S3StoreIT.java +++ b/spring-content-s3/src/test/java/internal/org/springframework/content/s3/it/S3StoreIT.java @@ -97,7 +97,7 @@ public class S3StoreIT { private Exception e; - private AnnotationConfigApplicationContext context; + private AnnotationConfigApplicationContext context; private TestEntityRepository repo; private TestEntityStore store; @@ -118,7 +118,7 @@ public class S3StoreIT { client = context.getBean(S3Client.class); HeadBucketRequest headBucketRequest = HeadBucketRequest.builder() - .bucket("aws-test-bucket") + .bucket(BUCKET) .build(); try { @@ -126,7 +126,7 @@ public class S3StoreIT { } catch (NoSuchBucketException e) { CreateBucketRequest bucketRequest = CreateBucketRequest.builder() - .bucket("aws-test-bucket") + .bucket(BUCKET) .build(); client.createBucket(bucketRequest); } @@ -328,7 +328,7 @@ public class S3StoreIT { entity = repo.save(entity); store.setContent(entity, new ByteArrayInputStream("Hello Spring Content World!".getBytes())); - store.setContent(entity, PropertyPath.from("rendition"), new ByteArrayInputStream("Hello Spring Content World!".getBytes())); + store.setContent(entity, PropertyPath.from("rendition"), new ByteArrayInputStream("Hello Spring Content World!".getBytes())); }); It("should be able to store new content", () -> { @@ -339,7 +339,7 @@ public class S3StoreIT { //rendition try (InputStream content = store.getContent(entity, PropertyPath.from("rendition"))) { - assertThat(IOUtils.contentEquals(new ByteArrayInputStream("Hello Spring Content World!".getBytes()), content), is(true)); + assertThat(IOUtils.contentEquals(new ByteArrayInputStream("Hello Spring Content World!".getBytes()), content), is(true)); } catch (IOException ioe) {} }); @@ -352,13 +352,13 @@ public class S3StoreIT { //rendition assertThat(entity.getRenditionId(), is(notNullValue())); assertThat(entity.getRenditionId().trim().length(), greaterThan(0)); - Assert.assertEquals(entity.getRenditionLen(), 27L); + Assert.assertEquals(entity.getRenditionLen(), 40L); }); Context("when content is updated", () -> { BeforeEach(() ->{ store.setContent(entity, new ByteArrayInputStream("Hello Updated Spring Content World!".getBytes())); - store.setContent(entity, PropertyPath.from("rendition"), new ByteArrayInputStream("Hello Updated Spring Content World!".getBytes())); + store.setContent(entity, PropertyPath.from("rendition"), new ByteArrayInputStream("Hello Updated Spring Content World!".getBytes())); entity = repo.save(entity); }); @@ -373,7 +373,7 @@ public class S3StoreIT { //rendition matches = false; try (InputStream content = store.getContent(entity, PropertyPath.from("rendition"))) { - matches = IOUtils.contentEquals(new ByteArrayInputStream("Hello Updated Spring Content World!".getBytes()), content); + matches = IOUtils.contentEquals(new ByteArrayInputStream("Hello Updated Spring Content World!".getBytes()), content); assertThat(matches, is(true)); } }); @@ -382,7 +382,7 @@ public class S3StoreIT { Context("when content is updated with shorter content", () -> { BeforeEach(() -> { store.setContent(entity, new ByteArrayInputStream("Hello Spring World!".getBytes())); - store.setContent(entity, PropertyPath.from("rendition"), new ByteArrayInputStream("Hello Spring World!".getBytes())); + store.setContent(entity, PropertyPath.from("rendition"), new ByteArrayInputStream("Hello Spring World!".getBytes())); entity = repo.save(entity); }); It("should store only the new content", () -> { @@ -396,7 +396,7 @@ public class S3StoreIT { //rendition matches = false; try (InputStream content = store.getContent(entity, PropertyPath.from("rendition"))) { - matches = IOUtils.contentEquals(new ByteArrayInputStream("Hello Spring World!".getBytes()), content); + matches = IOUtils.contentEquals(new ByteArrayInputStream("Hello Spring World!".getBytes()), content); assertThat(matches, is(true)); } }); From 62c85853d12170f524873c69e3466d0296def37b Mon Sep 17 00:00:00 2001 From: Paul Warren Date: Mon, 2 May 2022 23:08:36 -0700 Subject: [PATCH 3/3] azure and gcs stores get resource from property path now use id object, not entity --- .../azure/store/DefaultAzureStorageImpl.java | 4 ++-- .../content/azure/it/AzureStorageIT.java | 14 +++++++------- .../content/gcs/store/DefaultGCPStorageImpl.java | 4 ++-- .../content/gcs/it/GCPStorageIT.java | 14 +++++++------- .../content/jpa/ContentStoreIT.java | 14 +++++++------- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/spring-content-azure-storage/src/main/java/internal/org/springframework/content/azure/store/DefaultAzureStorageImpl.java b/spring-content-azure-storage/src/main/java/internal/org/springframework/content/azure/store/DefaultAzureStorageImpl.java index 43358527b..52621d332 100644 --- a/spring-content-azure-storage/src/main/java/internal/org/springframework/content/azure/store/DefaultAzureStorageImpl.java +++ b/spring-content-azure-storage/src/main/java/internal/org/springframework/content/azure/store/DefaultAzureStorageImpl.java @@ -113,8 +113,8 @@ public Resource getResource(S entity, PropertyPath propertyPath) { return null; BlobId blobId = null; - if (placementService.canConvert(entity.getClass(), BlobId.class)) { - blobId = placementService.convert(entity, BlobId.class); + if (placementService.canConvert(property.getContentIdType(entity).getClass(), BlobId.class)) { + blobId = placementService.convert(property.getContentId(entity), BlobId.class); if (blobId != null) { return this.getResourceInternal(blobId); diff --git a/spring-content-azure-storage/src/test/java/internal/org/springframework/content/azure/it/AzureStorageIT.java b/spring-content-azure-storage/src/test/java/internal/org/springframework/content/azure/it/AzureStorageIT.java index 25b53781d..4691521f7 100644 --- a/spring-content-azure-storage/src/test/java/internal/org/springframework/content/azure/it/AzureStorageIT.java +++ b/spring-content-azure-storage/src/test/java/internal/org/springframework/content/azure/it/AzureStorageIT.java @@ -288,7 +288,7 @@ public class AzureStorageIT { entity = repo.save(entity); store.setContent(entity, new ByteArrayInputStream("Hello Spring Content World!".getBytes())); - store.setContent(entity, PropertyPath.from("rendition"), new ByteArrayInputStream("Hello Spring Content World!".getBytes())); + store.setContent(entity, PropertyPath.from("rendition"), new ByteArrayInputStream("Hello Spring Content World!".getBytes())); }); It("should be able to store new content", () -> { @@ -299,7 +299,7 @@ public class AzureStorageIT { //rendition try (InputStream content = store.getContent(entity, PropertyPath.from("rendition"))) { - assertThat(IOUtils.contentEquals(new ByteArrayInputStream("Hello Spring Content World!".getBytes()), content), is(true)); + assertThat(IOUtils.contentEquals(new ByteArrayInputStream("Hello Spring Content World!".getBytes()), content), is(true)); } catch (IOException ioe) {} }); @@ -312,13 +312,13 @@ public class AzureStorageIT { //rendition assertThat(entity.getRenditionId(), is(notNullValue())); assertThat(entity.getRenditionId().trim().length(), greaterThan(0)); - Assert.assertEquals(entity.getRenditionLen(), 27L); + Assert.assertEquals(entity.getRenditionLen(), 40L); }); Context("when content is updated", () -> { BeforeEach(() ->{ store.setContent(entity, new ByteArrayInputStream("Hello Updated Spring Content World!".getBytes())); - store.setContent(entity, PropertyPath.from("rendition"), new ByteArrayInputStream("Hello Updated Spring Content World!".getBytes())); + store.setContent(entity, PropertyPath.from("rendition"), new ByteArrayInputStream("Hello Updated Spring Content World!".getBytes())); entity = repo.save(entity); }); @@ -333,7 +333,7 @@ public class AzureStorageIT { //rendition matches = false; try (InputStream content = store.getContent(entity, PropertyPath.from("rendition"))) { - matches = IOUtils.contentEquals(new ByteArrayInputStream("Hello Updated Spring Content World!".getBytes()), content); + matches = IOUtils.contentEquals(new ByteArrayInputStream("Hello Updated Spring Content World!".getBytes()), content); assertThat(matches, is(true)); } }); @@ -342,7 +342,7 @@ public class AzureStorageIT { Context("when content is updated with shorter content", () -> { BeforeEach(() -> { store.setContent(entity, new ByteArrayInputStream("Hello Spring World!".getBytes())); - store.setContent(entity, PropertyPath.from("rendition"), new ByteArrayInputStream("Hello Spring World!".getBytes())); + store.setContent(entity, PropertyPath.from("rendition"), new ByteArrayInputStream("Hello Spring World!".getBytes())); entity = repo.save(entity); }); It("should store only the new content", () -> { @@ -356,7 +356,7 @@ public class AzureStorageIT { //rendition matches = false; try (InputStream content = store.getContent(entity, PropertyPath.from("rendition"))) { - matches = IOUtils.contentEquals(new ByteArrayInputStream("Hello Spring World!".getBytes()), content); + matches = IOUtils.contentEquals(new ByteArrayInputStream("Hello Spring World!".getBytes()), content); assertThat(matches, is(true)); } }); diff --git a/spring-content-gcs/src/main/java/internal/org/springframework/content/gcs/store/DefaultGCPStorageImpl.java b/spring-content-gcs/src/main/java/internal/org/springframework/content/gcs/store/DefaultGCPStorageImpl.java index a578a459d..c8fe5f627 100644 --- a/spring-content-gcs/src/main/java/internal/org/springframework/content/gcs/store/DefaultGCPStorageImpl.java +++ b/spring-content-gcs/src/main/java/internal/org/springframework/content/gcs/store/DefaultGCPStorageImpl.java @@ -113,8 +113,8 @@ public Resource getResource(S entity, PropertyPath propertyPath) { return null; BlobId blobId = null; - if (placementService.canConvert(entity.getClass(), BlobId.class)) { - blobId = placementService.convert(entity, BlobId.class); + if (placementService.canConvert(property.getContentIdType(entity).getClass(), BlobId.class)) { + blobId = placementService.convert(property.getContentId(entity), BlobId.class); if (blobId != null) { return this.getResourceInternal(blobId); diff --git a/spring-content-gcs/src/test/java/internal/org/springframework/content/gcs/it/GCPStorageIT.java b/spring-content-gcs/src/test/java/internal/org/springframework/content/gcs/it/GCPStorageIT.java index 295790088..40222afaf 100644 --- a/spring-content-gcs/src/test/java/internal/org/springframework/content/gcs/it/GCPStorageIT.java +++ b/spring-content-gcs/src/test/java/internal/org/springframework/content/gcs/it/GCPStorageIT.java @@ -282,7 +282,7 @@ public class GCPStorageIT { entity = repo.save(entity); store.setContent(entity, new ByteArrayInputStream("Hello Spring Content World!".getBytes())); - store.setContent(entity, PropertyPath.from("rendition"), new ByteArrayInputStream("Hello Spring Content World!".getBytes())); + store.setContent(entity, PropertyPath.from("rendition"), new ByteArrayInputStream("Hello Spring Content World!".getBytes())); }); It("should be able to store new content", () -> { @@ -293,7 +293,7 @@ public class GCPStorageIT { //rendition try (InputStream content = store.getContent(entity, PropertyPath.from("rendition"))) { - assertThat(IOUtils.contentEquals(new ByteArrayInputStream("Hello Spring Content World!".getBytes()), content), is(true)); + assertThat(IOUtils.contentEquals(new ByteArrayInputStream("Hello Spring Content World!".getBytes()), content), is(true)); } catch (IOException ioe) {} }); @@ -306,13 +306,13 @@ public class GCPStorageIT { //rendition assertThat(entity.getRenditionId(), is(notNullValue())); assertThat(entity.getRenditionId().trim().length(), greaterThan(0)); - Assert.assertEquals(entity.getRenditionLen(), 27L); + Assert.assertEquals(entity.getRenditionLen(), 40L); }); Context("when content is updated", () -> { BeforeEach(() ->{ store.setContent(entity, new ByteArrayInputStream("Hello Updated Spring Content World!".getBytes())); - store.setContent(entity, PropertyPath.from("rendition"), new ByteArrayInputStream("Hello Updated Spring Content World!".getBytes())); + store.setContent(entity, PropertyPath.from("rendition"), new ByteArrayInputStream("Hello Updated Spring Content World!".getBytes())); entity = repo.save(entity); }); @@ -327,7 +327,7 @@ public class GCPStorageIT { //rendition matches = false; try (InputStream content = store.getContent(entity, PropertyPath.from("rendition"))) { - matches = IOUtils.contentEquals(new ByteArrayInputStream("Hello Updated Spring Content World!".getBytes()), content); + matches = IOUtils.contentEquals(new ByteArrayInputStream("Hello Updated Spring Content World!".getBytes()), content); assertThat(matches, is(true)); } }); @@ -336,7 +336,7 @@ public class GCPStorageIT { Context("when content is updated with shorter content", () -> { BeforeEach(() -> { store.setContent(entity, new ByteArrayInputStream("Hello Spring World!".getBytes())); - store.setContent(entity, PropertyPath.from("rendition"), new ByteArrayInputStream("Hello Spring World!".getBytes())); + store.setContent(entity, PropertyPath.from("rendition"), new ByteArrayInputStream("Hello Spring World!".getBytes())); entity = repo.save(entity); }); It("should store only the new content", () -> { @@ -350,7 +350,7 @@ public class GCPStorageIT { //rendition matches = false; try (InputStream content = store.getContent(entity, PropertyPath.from("rendition"))) { - matches = IOUtils.contentEquals(new ByteArrayInputStream("Hello Spring World!".getBytes()), content); + matches = IOUtils.contentEquals(new ByteArrayInputStream("Hello Spring World!".getBytes()), content); assertThat(matches, is(true)); } }); diff --git a/spring-content-jpa/src/test/java/internal/org/springframework/content/jpa/ContentStoreIT.java b/spring-content-jpa/src/test/java/internal/org/springframework/content/jpa/ContentStoreIT.java index c108bb616..2e5523976 100644 --- a/spring-content-jpa/src/test/java/internal/org/springframework/content/jpa/ContentStoreIT.java +++ b/spring-content-jpa/src/test/java/internal/org/springframework/content/jpa/ContentStoreIT.java @@ -102,7 +102,7 @@ public class ContentStoreIT { claim = claimRepo.save(claim); claimFormStore.setContent(claim, PropertyPath.from("claimForm.content"), new ByteArrayInputStream("Hello Spring Content World!".getBytes())); - claimFormStore.setContent(claim, PropertyPath.from("claimForm.rendition"), new ByteArrayInputStream("Hello Spring Content World!".getBytes())); + claimFormStore.setContent(claim, PropertyPath.from("claimForm.rendition"), new ByteArrayInputStream("Hello Spring Content World!".getBytes())); }); It("should be able to store new content", () -> { @@ -117,7 +117,7 @@ public class ContentStoreIT { // rendition doInTransaction(ptm, () -> { try (InputStream content = claimFormStore.getContent(claim, PropertyPath.from("claimForm.rendition"))) { - assertThat(IOUtils.contentEquals(new ByteArrayInputStream("Hello Spring Content World!".getBytes()), content), is(true)); + assertThat(IOUtils.contentEquals(new ByteArrayInputStream("Hello Spring Content World!".getBytes()), content), is(true)); } catch (IOException ioe) {} return null; }); @@ -133,13 +133,13 @@ public class ContentStoreIT { // renditoin Assert.assertThat(claim.getClaimForm().getRenditionId(), is(notNullValue())); Assert.assertThat(claim.getClaimForm().getRenditionId().trim().length(), greaterThan(0)); - Assert.assertEquals(claim.getClaimForm().getContentLength(), 27L); + Assert.assertEquals(claim.getClaimForm().getRenditionLen(), 40L); }); Context("when content is updated", () -> { BeforeEach(() ->{ claimFormStore.setContent(claim, PropertyPath.from("claimForm.content"), new ByteArrayInputStream("Hello Updated Spring Content World!".getBytes())); - claimFormStore.setContent(claim, PropertyPath.from("claimForm.rendition"), new ByteArrayInputStream("Hello Updated Spring Content World!".getBytes())); + claimFormStore.setContent(claim, PropertyPath.from("claimForm.rendition"), new ByteArrayInputStream("Hello Updated Spring Content World!".getBytes())); claim = claimRepo.save(claim); }); @@ -159,7 +159,7 @@ public class ContentStoreIT { doInTransaction(ptm, () -> { boolean matches = false; try (InputStream content = claimFormStore.getContent(claim, PropertyPath.from("claimForm.rendition"))) { - matches = IOUtils.contentEquals(new ByteArrayInputStream("Hello Updated Spring Content World!".getBytes()), content); + matches = IOUtils.contentEquals(new ByteArrayInputStream("Hello Updated Spring Content World!".getBytes()), content); assertThat(matches, is(true)); } catch (IOException e) { } @@ -171,7 +171,7 @@ public class ContentStoreIT { Context("when content is updated with shorter content", () -> { BeforeEach(() -> { claimFormStore.setContent(claim, PropertyPath.from("claimForm.content"), new ByteArrayInputStream("Hello Spring World!".getBytes())); - claimFormStore.setContent(claim, PropertyPath.from("claimForm.rendition"), new ByteArrayInputStream("Hello Spring World!".getBytes())); + claimFormStore.setContent(claim, PropertyPath.from("claimForm.rendition"), new ByteArrayInputStream("Hello Spring World!".getBytes())); claim = claimRepo.save(claim); }); It("should store only the new content", () -> { @@ -190,7 +190,7 @@ public class ContentStoreIT { doInTransaction(ptm, () -> { boolean matches = false; try (InputStream content = claimFormStore.getContent(claim, PropertyPath.from("claimForm.rendition"))) { - matches = IOUtils.contentEquals(new ByteArrayInputStream("Hello Spring World!".getBytes()), content); + matches = IOUtils.contentEquals(new ByteArrayInputStream("Hello Spring World!".getBytes()), content); assertThat(matches, is(true)); } catch (IOException e) { }