Skip to content

Commit

Permalink
Merge pull request #758 from paulcwarren/feature/add-json-content-res…
Browse files Browse the repository at this point in the history
…t-test

Add a test to prove we can handle json content
  • Loading branch information
paulcwarren authored Feb 3, 2022
2 parents 3895452 + 913a4d2 commit b2e31f2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,3 @@ internal.org.springframework.content.solr.boot.autoconfigure.SolrAutoConfigurati
internal.org.springframework.content.solr.boot.autoconfigure.SolrExtensionAutoConfiguration,\
internal.org.springframework.content.renditions.boot.autoconfigure.RenditionsContentAutoConfiguration,\
internal.org.springframework.versions.jpa.boot.autoconfigure.JpaVersionsAutoConfiguration


Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,25 @@ public class ContentPropertyRestEndpointsIT {
}
});
});
Context("a PUT to /{store}/{id} with json content", () -> {
It("should set the content and return 201", () -> {
String content = "{\"content\":\"Hello New Spring Content World!\"}";
mvc.perform(
put("/testEntity8s/" + testEntity2.getId() + "/child")
.content(content)
.contentType("application/json"))
.andExpect(status().isCreated());

Optional<TestEntity8> fetched = repository2.findById(testEntity2.getId());
assertThat(fetched.isPresent(), is(true));
assertThat(fetched.get().getChild().getContentId(), is(not(nullValue())));
assertThat(fetched.get().getChild().getContentLen(), is(45L));
assertThat(fetched.get().getChild().getContentMimeType(), is("application/json"));
try (InputStream actual = store.getResource(fetched.get(), PropertyPath.from("child")).getInputStream()) {
IOUtils.contentEquals(actual, new ByteArrayInputStream(content.getBytes()));
}
});
});
});
Context("given that it has content", () -> {
BeforeEach(() -> {
Expand Down

0 comments on commit b2e31f2

Please sign in to comment.