diff --git a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/parser/JsonParserDstu2Test.java b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/parser/JsonParserDstu2Test.java
index a3dd22d3f33..b764ba5be39 100644
--- a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/parser/JsonParserDstu2Test.java
+++ b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/parser/JsonParserDstu2Test.java
@@ -92,6 +92,24 @@ public class JsonParserDstu2Test {
assertThat(output, containsString("\"div\":\"
VALUE
\""));
}
+ /**
+ * See #390
+ */
+ @Test
+ public void testEncodeAndParseBundleWithNoEntries() {
+ ca.uhn.fhir.model.dstu2.resource.Bundle b = new ca.uhn.fhir.model.dstu2.resource.Bundle();
+ b.setId("123");
+ String encoded = ourCtx.newJsonParser().encodeResourceToString(b);
+ ourLog.info(encoded);
+
+ assertThat(encoded, containsString("123"));
+ assertThat(encoded, not(containsString("entry")));
+
+ b = ourCtx.newJsonParser().parseResource(ca.uhn.fhir.model.dstu2.resource.Bundle.class, encoded);
+ assertEquals("123", b.getId().getIdPart());
+ assertEquals(0, b.getEntry().size());
+ }
+
@Test
public void testEncodeNarrativeShouldIncludeNamespaceWithProcessingInstruction() {