Skip to content

Commit b2e31f2

Browse files
authored
Merge pull request #758 from paulcwarren/feature/add-json-content-rest-test
Add a test to prove we can handle json content
2 parents 3895452 + 913a4d2 commit b2e31f2

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

spring-content-autoconfigure/src/main/resources/META-INF/spring.factories

-2
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,3 @@ internal.org.springframework.content.solr.boot.autoconfigure.SolrAutoConfigurati
1111
internal.org.springframework.content.solr.boot.autoconfigure.SolrExtensionAutoConfiguration,\
1212
internal.org.springframework.content.renditions.boot.autoconfigure.RenditionsContentAutoConfiguration,\
1313
internal.org.springframework.versions.jpa.boot.autoconfigure.JpaVersionsAutoConfiguration
14-
15-

spring-content-rest/src/test/java/it/internal/org/springframework/content/rest/controllers/ContentPropertyRestEndpointsIT.java

+19
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,25 @@ public class ContentPropertyRestEndpointsIT {
130130
}
131131
});
132132
});
133+
Context("a PUT to /{store}/{id} with json content", () -> {
134+
It("should set the content and return 201", () -> {
135+
String content = "{\"content\":\"Hello New Spring Content World!\"}";
136+
mvc.perform(
137+
put("/testEntity8s/" + testEntity2.getId() + "/child")
138+
.content(content)
139+
.contentType("application/json"))
140+
.andExpect(status().isCreated());
141+
142+
Optional<TestEntity8> fetched = repository2.findById(testEntity2.getId());
143+
assertThat(fetched.isPresent(), is(true));
144+
assertThat(fetched.get().getChild().getContentId(), is(not(nullValue())));
145+
assertThat(fetched.get().getChild().getContentLen(), is(45L));
146+
assertThat(fetched.get().getChild().getContentMimeType(), is("application/json"));
147+
try (InputStream actual = store.getResource(fetched.get(), PropertyPath.from("child")).getInputStream()) {
148+
IOUtils.contentEquals(actual, new ByteArrayInputStream(content.getBytes()));
149+
}
150+
});
151+
});
133152
});
134153
Context("given that it has content", () -> {
135154
BeforeEach(() -> {

0 commit comments

Comments
 (0)