Use new STU3 mimetypes by default
This commit is contained in:
parent
61d6f1ba8d
commit
f5eda76388
|
@ -17,6 +17,7 @@ tmp.txt
|
||||||
tmp.txt
|
tmp.txt
|
||||||
ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamString/
|
ca.uhn.fhir.jpa.entity.ResourceIndexedSearchParamString/
|
||||||
ca.uhn.fhir.jpa.entity.ResourceTable/
|
ca.uhn.fhir.jpa.entity.ResourceTable/
|
||||||
|
ca.uhn.fhir.jpa.entity.TermConcept/
|
||||||
|
|
||||||
# Vagrant stuff.
|
# Vagrant stuff.
|
||||||
.vagrant
|
.vagrant
|
||||||
|
|
|
@ -46,6 +46,11 @@ public enum EncodingEnum {
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
|
/** "xml" */
|
||||||
|
public static final String XML_PLAIN_STRING = "xml";
|
||||||
|
/** "json" */
|
||||||
|
public static final String JSON_PLAIN_STRING = "json";
|
||||||
|
|
||||||
private static Map<String, EncodingEnum> ourContentTypeToEncoding;
|
private static Map<String, EncodingEnum> ourContentTypeToEncoding;
|
||||||
private static Map<String, EncodingEnum> ourContentTypeToEncodingNonLegacy;
|
private static Map<String, EncodingEnum> ourContentTypeToEncodingNonLegacy;
|
||||||
private static Map<String, EncodingEnum> ourContentTypeToEncodingStrict;
|
private static Map<String, EncodingEnum> ourContentTypeToEncodingStrict;
|
||||||
|
@ -53,17 +58,24 @@ public enum EncodingEnum {
|
||||||
static {
|
static {
|
||||||
ourContentTypeToEncoding = new HashMap<String, EncodingEnum>();
|
ourContentTypeToEncoding = new HashMap<String, EncodingEnum>();
|
||||||
ourContentTypeToEncodingNonLegacy = new HashMap<String, EncodingEnum>();
|
ourContentTypeToEncodingNonLegacy = new HashMap<String, EncodingEnum>();
|
||||||
|
|
||||||
for (EncodingEnum next : values()) {
|
for (EncodingEnum next : values()) {
|
||||||
ourContentTypeToEncoding.put(next.getBundleContentType(), next);
|
ourContentTypeToEncoding.put(next.getBundleContentType(), next);
|
||||||
ourContentTypeToEncoding.put(next.myResourceContentTypeNonLegacy, next);
|
ourContentTypeToEncoding.put(next.myResourceContentTypeNonLegacy, next);
|
||||||
ourContentTypeToEncoding.put(next.myResourceContentTypeLegacy, next);
|
ourContentTypeToEncoding.put(next.myResourceContentTypeLegacy, next);
|
||||||
|
|
||||||
ourContentTypeToEncodingNonLegacy.put(next.myResourceContentTypeNonLegacy, next);
|
ourContentTypeToEncodingNonLegacy.put(next.myResourceContentTypeNonLegacy, next);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* See #346
|
||||||
|
*/
|
||||||
|
ourContentTypeToEncoding.put(next.myResourceContentTypeNonLegacy.replace('+', ' '), next);
|
||||||
|
ourContentTypeToEncoding.put(next.myResourceContentTypeLegacy.replace('+', ' '), next);
|
||||||
|
ourContentTypeToEncodingNonLegacy.put(next.myResourceContentTypeNonLegacy.replace('+', ' '), next);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add before we add the lenient ones
|
// Add before we add the lenient ones
|
||||||
ourContentTypeToEncodingStrict = Collections.unmodifiableMap(new HashMap<String, EncodingEnum>(ourContentTypeToEncoding));
|
ourContentTypeToEncodingStrict = Collections.unmodifiableMap(new HashMap<String, EncodingEnum>(ourContentTypeToEncoding));
|
||||||
ourContentTypeToEncodingNonLegacy = Collections.unmodifiableMap(ourContentTypeToEncodingNonLegacy);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* These are wrong, but we add them just to be tolerant of other
|
* These are wrong, but we add them just to be tolerant of other
|
||||||
|
@ -77,16 +89,10 @@ public enum EncodingEnum {
|
||||||
/*
|
/*
|
||||||
* Plain values, used for parameter values
|
* Plain values, used for parameter values
|
||||||
*/
|
*/
|
||||||
ourContentTypeToEncoding.put("json", JSON);
|
ourContentTypeToEncoding.put(JSON_PLAIN_STRING, JSON);
|
||||||
ourContentTypeToEncoding.put("xml", XML);
|
ourContentTypeToEncoding.put(XML_PLAIN_STRING, XML);
|
||||||
|
|
||||||
/*
|
ourContentTypeToEncodingNonLegacy = Collections.unmodifiableMap(ourContentTypeToEncodingNonLegacy);
|
||||||
* See #346
|
|
||||||
*/
|
|
||||||
for (EncodingEnum next : values()) {
|
|
||||||
ourContentTypeToEncoding.put(next.myResourceContentTypeNonLegacy.replace('+', ' '), next);
|
|
||||||
ourContentTypeToEncoding.put(next.myResourceContentTypeLegacy.replace('+', ' '), next);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -211,7 +211,7 @@ public class RestfulServerUtils {
|
||||||
nextPart = nextPart.trim();
|
nextPart = nextPart.trim();
|
||||||
EncodingEnum encoding = EncodingEnum.forContentType(nextPart);
|
EncodingEnum encoding = EncodingEnum.forContentType(nextPart);
|
||||||
if (encoding != null) {
|
if (encoding != null) {
|
||||||
retVal = new ResponseEncoding(encoding, nextPart);
|
retVal = new ResponseEncoding(theReq.getServer().getFhirContext(), encoding, nextPart);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -232,7 +232,7 @@ public class RestfulServerUtils {
|
||||||
for (String nextFormat : format) {
|
for (String nextFormat : format) {
|
||||||
EncodingEnum retVal = EncodingEnum.forContentType(nextFormat);
|
EncodingEnum retVal = EncodingEnum.forContentType(nextFormat);
|
||||||
if (retVal != null) {
|
if (retVal != null) {
|
||||||
return new ResponseEncoding(retVal, nextFormat);
|
return new ResponseEncoding(theReq.getServer().getFhirContext(), retVal, nextFormat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -288,12 +288,12 @@ public class RestfulServerUtils {
|
||||||
ResponseEncoding encoding;
|
ResponseEncoding encoding;
|
||||||
if (endSpaceIndex == -1) {
|
if (endSpaceIndex == -1) {
|
||||||
if (startSpaceIndex == 0) {
|
if (startSpaceIndex == 0) {
|
||||||
encoding = getEncodingForContentType(strict, nextToken);
|
encoding = getEncodingForContentType(theReq.getServer().getFhirContext(), strict, nextToken);
|
||||||
} else {
|
} else {
|
||||||
encoding = getEncodingForContentType(strict, nextToken.substring(startSpaceIndex));
|
encoding = getEncodingForContentType(theReq.getServer().getFhirContext(), strict, nextToken.substring(startSpaceIndex));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
encoding = getEncodingForContentType(strict, nextToken.substring(startSpaceIndex, endSpaceIndex));
|
encoding = getEncodingForContentType(theReq.getServer().getFhirContext(), strict, nextToken.substring(startSpaceIndex, endSpaceIndex));
|
||||||
String remaining = nextToken.substring(endSpaceIndex + 1);
|
String remaining = nextToken.substring(endSpaceIndex + 1);
|
||||||
StringTokenizer qualifierTok = new StringTokenizer(remaining, ";");
|
StringTokenizer qualifierTok = new StringTokenizer(remaining, ";");
|
||||||
while (qualifierTok.hasMoreTokens()) {
|
while (qualifierTok.hasMoreTokens()) {
|
||||||
|
@ -347,7 +347,7 @@ public class RestfulServerUtils {
|
||||||
public static ResponseEncoding determineResponseEncodingWithDefault(RequestDetails theReq) {
|
public static ResponseEncoding determineResponseEncodingWithDefault(RequestDetails theReq) {
|
||||||
ResponseEncoding retVal = determineResponseEncodingNoDefault(theReq, theReq.getServer().getDefaultResponseEncoding());
|
ResponseEncoding retVal = determineResponseEncodingNoDefault(theReq, theReq.getServer().getDefaultResponseEncoding());
|
||||||
if (retVal == null) {
|
if (retVal == null) {
|
||||||
retVal = new ResponseEncoding(theReq.getServer().getDefaultResponseEncoding(), null);
|
retVal = new ResponseEncoding(theReq.getServer().getFhirContext(), theReq.getServer().getDefaultResponseEncoding(), null);
|
||||||
}
|
}
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
@ -417,7 +417,7 @@ public class RestfulServerUtils {
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ResponseEncoding getEncodingForContentType(boolean theStrict, String theContentType) {
|
private static ResponseEncoding getEncodingForContentType(FhirContext theFhirContext, boolean theStrict, String theContentType) {
|
||||||
EncodingEnum encoding;
|
EncodingEnum encoding;
|
||||||
if (theStrict) {
|
if (theStrict) {
|
||||||
encoding = EncodingEnum.forContentTypeStrict(theContentType);
|
encoding = EncodingEnum.forContentTypeStrict(theContentType);
|
||||||
|
@ -427,7 +427,7 @@ public class RestfulServerUtils {
|
||||||
if (encoding == null) {
|
if (encoding == null) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return new ResponseEncoding(encoding, theContentType);
|
return new ResponseEncoding(theFhirContext, encoding, theContentType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -635,7 +635,7 @@ public class RestfulServerUtils {
|
||||||
|
|
||||||
// Ok, we're not serving a binary resource, so apply default encoding
|
// Ok, we're not serving a binary resource, so apply default encoding
|
||||||
if (responseEncoding == null) {
|
if (responseEncoding == null) {
|
||||||
responseEncoding = new ResponseEncoding(theServer.getDefaultResponseEncoding(), null);
|
responseEncoding = new ResponseEncoding(theServer.getFhirContext(), theServer.getDefaultResponseEncoding(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean encodingDomainResourceAsText = theSummaryMode.contains(SummaryEnum.TEXT);
|
boolean encodingDomainResourceAsText = theSummaryMode.contains(SummaryEnum.TEXT);
|
||||||
|
@ -752,13 +752,21 @@ public class RestfulServerUtils {
|
||||||
private final EncodingEnum myEncoding;
|
private final EncodingEnum myEncoding;
|
||||||
private final Boolean myNonLegacy;
|
private final Boolean myNonLegacy;
|
||||||
|
|
||||||
public ResponseEncoding(EncodingEnum theEncoding, String theContentType) {
|
public ResponseEncoding(FhirContext theCtx, EncodingEnum theEncoding, String theContentType) {
|
||||||
super();
|
super();
|
||||||
myEncoding = theEncoding;
|
myEncoding = theEncoding;
|
||||||
if (theContentType != null) {
|
if (theContentType != null) {
|
||||||
myNonLegacy = EncodingEnum.isNonLegacy(theContentType);
|
if (theContentType.equals(EncodingEnum.JSON_PLAIN_STRING) || theContentType.equals(EncodingEnum.XML_PLAIN_STRING)) {
|
||||||
|
myNonLegacy = !theCtx.getVersion().getVersion().isOlderThan(FhirVersionEnum.DSTU3);
|
||||||
|
} else {
|
||||||
|
myNonLegacy = EncodingEnum.isNonLegacy(theContentType);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
myNonLegacy = null;
|
if (theCtx.getVersion().getVersion().isOlderThan(FhirVersionEnum.DSTU3)) {
|
||||||
|
myNonLegacy = null;
|
||||||
|
} else {
|
||||||
|
myNonLegacy = Boolean.TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,10 +35,13 @@ import java.util.List;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.commons.lang3.Validate;
|
import org.apache.commons.lang3.Validate;
|
||||||
|
import org.apache.http.NameValuePair;
|
||||||
import org.apache.http.client.ClientProtocolException;
|
import org.apache.http.client.ClientProtocolException;
|
||||||
|
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
||||||
import org.apache.http.client.methods.*;
|
import org.apache.http.client.methods.*;
|
||||||
import org.apache.http.entity.ContentType;
|
import org.apache.http.entity.ContentType;
|
||||||
import org.apache.http.entity.StringEntity;
|
import org.apache.http.entity.StringEntity;
|
||||||
|
import org.apache.http.message.BasicNameValuePair;
|
||||||
import org.hl7.fhir.dstu3.model.*;
|
import org.hl7.fhir.dstu3.model.*;
|
||||||
import org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent;
|
import org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent;
|
||||||
import org.hl7.fhir.dstu3.model.Bundle.BundleType;
|
import org.hl7.fhir.dstu3.model.Bundle.BundleType;
|
||||||
|
@ -111,6 +114,39 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* See #411
|
||||||
|
*
|
||||||
|
* Let's see if we can reproduce this issue in JPA
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testSearchWithMixedParams() throws Exception {
|
||||||
|
Patient patient = new Patient();
|
||||||
|
patient.addIdentifier().setSystem("urn:system").setValue("0");
|
||||||
|
patient.addName().addFamily("testSearchWithMixedParams").addGiven("Joe");
|
||||||
|
myPatientDao.create(patient, mySrd).getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
|
HttpPost httpPost = new HttpPost(ourServerBase + "/Patient/_search?_format=application/xml");
|
||||||
|
httpPost.addHeader("Cache-Control","no-cache");
|
||||||
|
List<NameValuePair> parameters = Lists.newArrayList();
|
||||||
|
parameters.add(new BasicNameValuePair("name", "Smith"));
|
||||||
|
httpPost.setEntity(new UrlEncodedFormEntity(parameters));
|
||||||
|
|
||||||
|
ourLog.info("Outgoing post: {}", httpPost);
|
||||||
|
|
||||||
|
CloseableHttpResponse status = ourHttpClient.execute(httpPost);
|
||||||
|
try {
|
||||||
|
String responseContent = IOUtils.toString(status.getEntity().getContent(), StandardCharsets.UTF_8);
|
||||||
|
ourLog.info(responseContent);
|
||||||
|
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||||
|
} finally {
|
||||||
|
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSearchPagingKeepsOldSearches() throws Exception {
|
public void testSearchPagingKeepsOldSearches() throws Exception {
|
||||||
String methodName = "testSearchPagingKeepsOldSearches";
|
String methodName = "testSearchPagingKeepsOldSearches";
|
||||||
|
|
|
@ -7,6 +7,7 @@ import javax.sql.DataSource;
|
||||||
|
|
||||||
import org.apache.commons.dbcp2.BasicDataSource;
|
import org.apache.commons.dbcp2.BasicDataSource;
|
||||||
import org.apache.commons.lang3.time.DateUtils;
|
import org.apache.commons.lang3.time.DateUtils;
|
||||||
|
import org.hibernate.dialect.DerbyTenSevenDialect;
|
||||||
import org.hibernate.jpa.HibernatePersistenceProvider;
|
import org.hibernate.jpa.HibernatePersistenceProvider;
|
||||||
import org.springframework.beans.factory.annotation.Autowire;
|
import org.springframework.beans.factory.annotation.Autowire;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
@ -98,6 +99,7 @@ public class TdlDstu2Config extends BaseJavaConfigDstu2 {
|
||||||
|
|
||||||
private Properties jpaProperties() {
|
private Properties jpaProperties() {
|
||||||
Properties extraProperties = new Properties();
|
Properties extraProperties = new Properties();
|
||||||
|
extraProperties.put("hibernate.dialect", DerbyTenSevenDialect.class.getName());
|
||||||
extraProperties.put("hibernate.format_sql", "false");
|
extraProperties.put("hibernate.format_sql", "false");
|
||||||
extraProperties.put("hibernate.show_sql", "false");
|
extraProperties.put("hibernate.show_sql", "false");
|
||||||
extraProperties.put("hibernate.hbm2ddl.auto", "update");
|
extraProperties.put("hibernate.hbm2ddl.auto", "update");
|
||||||
|
|
|
@ -7,6 +7,7 @@ import javax.sql.DataSource;
|
||||||
|
|
||||||
import org.apache.commons.dbcp2.BasicDataSource;
|
import org.apache.commons.dbcp2.BasicDataSource;
|
||||||
import org.apache.commons.lang3.time.DateUtils;
|
import org.apache.commons.lang3.time.DateUtils;
|
||||||
|
import org.hibernate.dialect.DerbyTenSevenDialect;
|
||||||
import org.hibernate.jpa.HibernatePersistenceProvider;
|
import org.hibernate.jpa.HibernatePersistenceProvider;
|
||||||
import org.springframework.beans.factory.annotation.Autowire;
|
import org.springframework.beans.factory.annotation.Autowire;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
@ -88,6 +89,7 @@ public class TdlDstu3Config extends BaseJavaConfigDstu3 {
|
||||||
|
|
||||||
private Properties jpaProperties() {
|
private Properties jpaProperties() {
|
||||||
Properties extraProperties = new Properties();
|
Properties extraProperties = new Properties();
|
||||||
|
extraProperties.put("hibernate.dialect", DerbyTenSevenDialect.class.getName());
|
||||||
extraProperties.put("hibernate.format_sql", "false");
|
extraProperties.put("hibernate.format_sql", "false");
|
||||||
extraProperties.put("hibernate.show_sql", "false");
|
extraProperties.put("hibernate.show_sql", "false");
|
||||||
extraProperties.put("hibernate.hbm2ddl.auto", "update");
|
extraProperties.put("hibernate.hbm2ddl.auto", "update");
|
||||||
|
|
|
@ -6,6 +6,7 @@ import javax.persistence.EntityManagerFactory;
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
import org.apache.commons.dbcp2.BasicDataSource;
|
import org.apache.commons.dbcp2.BasicDataSource;
|
||||||
|
import org.hibernate.dialect.DerbyTenSevenDialect;
|
||||||
import org.hibernate.jpa.HibernatePersistenceProvider;
|
import org.hibernate.jpa.HibernatePersistenceProvider;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
|
@ -81,6 +82,7 @@ public class TestDstu1Config extends BaseJavaConfigDstu1 {
|
||||||
|
|
||||||
private Properties jpaProperties() {
|
private Properties jpaProperties() {
|
||||||
Properties extraProperties = new Properties();
|
Properties extraProperties = new Properties();
|
||||||
|
extraProperties.put("hibernate.dialect", DerbyTenSevenDialect.class.getName());
|
||||||
extraProperties.put("hibernate.format_sql", "true");
|
extraProperties.put("hibernate.format_sql", "true");
|
||||||
extraProperties.put("hibernate.show_sql", "false");
|
extraProperties.put("hibernate.show_sql", "false");
|
||||||
extraProperties.put("hibernate.hbm2ddl.auto", "update");
|
extraProperties.put("hibernate.hbm2ddl.auto", "update");
|
||||||
|
|
|
@ -7,6 +7,7 @@ import javax.sql.DataSource;
|
||||||
|
|
||||||
import org.apache.commons.dbcp2.BasicDataSource;
|
import org.apache.commons.dbcp2.BasicDataSource;
|
||||||
import org.apache.commons.lang3.time.DateUtils;
|
import org.apache.commons.lang3.time.DateUtils;
|
||||||
|
import org.hibernate.dialect.DerbyTenSevenDialect;
|
||||||
import org.hibernate.jpa.HibernatePersistenceProvider;
|
import org.hibernate.jpa.HibernatePersistenceProvider;
|
||||||
import org.springframework.beans.factory.annotation.Autowire;
|
import org.springframework.beans.factory.annotation.Autowire;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
@ -98,6 +99,7 @@ public class TestDstu2Config extends BaseJavaConfigDstu2 {
|
||||||
|
|
||||||
private Properties jpaProperties() {
|
private Properties jpaProperties() {
|
||||||
Properties extraProperties = new Properties();
|
Properties extraProperties = new Properties();
|
||||||
|
extraProperties.put("hibernate.dialect", DerbyTenSevenDialect.class.getName());
|
||||||
extraProperties.put("hibernate.format_sql", "false");
|
extraProperties.put("hibernate.format_sql", "false");
|
||||||
extraProperties.put("hibernate.show_sql", "false");
|
extraProperties.put("hibernate.show_sql", "false");
|
||||||
extraProperties.put("hibernate.hbm2ddl.auto", "update");
|
extraProperties.put("hibernate.hbm2ddl.auto", "update");
|
||||||
|
|
|
@ -7,6 +7,7 @@ import javax.sql.DataSource;
|
||||||
|
|
||||||
import org.apache.commons.dbcp2.BasicDataSource;
|
import org.apache.commons.dbcp2.BasicDataSource;
|
||||||
import org.apache.commons.lang3.time.DateUtils;
|
import org.apache.commons.lang3.time.DateUtils;
|
||||||
|
import org.hibernate.dialect.DerbyTenSevenDialect;
|
||||||
import org.hibernate.jpa.HibernatePersistenceProvider;
|
import org.hibernate.jpa.HibernatePersistenceProvider;
|
||||||
import org.springframework.beans.factory.annotation.Autowire;
|
import org.springframework.beans.factory.annotation.Autowire;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
@ -82,6 +83,7 @@ public class TestDstu3Config extends BaseJavaConfigDstu3 {
|
||||||
|
|
||||||
private Properties jpaProperties() {
|
private Properties jpaProperties() {
|
||||||
Properties extraProperties = new Properties();
|
Properties extraProperties = new Properties();
|
||||||
|
extraProperties.put("hibernate.dialect", DerbyTenSevenDialect.class.getName());
|
||||||
extraProperties.put("hibernate.format_sql", "false");
|
extraProperties.put("hibernate.format_sql", "false");
|
||||||
extraProperties.put("hibernate.show_sql", "false");
|
extraProperties.put("hibernate.show_sql", "false");
|
||||||
extraProperties.put("hibernate.hbm2ddl.auto", "update");
|
extraProperties.put("hibernate.hbm2ddl.auto", "update");
|
||||||
|
|
|
@ -6,6 +6,7 @@ import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
@ -159,7 +160,7 @@ public class BinaryDstu2Test {
|
||||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||||
assertEquals("foo", status.getFirstHeader("content-type").getValue());
|
assertEquals("foo", status.getFirstHeader("content-type").getValue());
|
||||||
assertEquals("Attachment;", status.getFirstHeader("Content-Disposition").getValue());
|
assertEquals("Attachment;", status.getFirstHeader("Content-Disposition").getValue()); // This is a security requirement!
|
||||||
assertArrayEquals(new byte[] { 1, 2, 3, 4 }, responseContent);
|
assertArrayEquals(new byte[] { 1, 2, 3, 4 }, responseContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,7 +171,7 @@ public class BinaryDstu2Test {
|
||||||
httpGet.addHeader("Accept", Constants.CT_FHIR_JSON);
|
httpGet.addHeader("Accept", Constants.CT_FHIR_JSON);
|
||||||
|
|
||||||
HttpResponse status = ourClient.execute(httpGet);
|
HttpResponse status = ourClient.execute(httpGet);
|
||||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
String responseContent = IOUtils.toString(status.getEntity().getContent(), StandardCharsets.UTF_8);
|
||||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||||
assertEquals(Constants.CT_FHIR_JSON + ";charset=utf-8", status.getFirstHeader("content-type").getValue().replace(" ", "").toLowerCase());
|
assertEquals(Constants.CT_FHIR_JSON + ";charset=utf-8", status.getFirstHeader("content-type").getValue().replace(" ", "").toLowerCase());
|
||||||
|
@ -183,7 +184,7 @@ public class BinaryDstu2Test {
|
||||||
public void testSearchJson() throws Exception {
|
public void testSearchJson() throws Exception {
|
||||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Binary?_pretty=true&_format=json");
|
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Binary?_pretty=true&_format=json");
|
||||||
HttpResponse status = ourClient.execute(httpGet);
|
HttpResponse status = ourClient.execute(httpGet);
|
||||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
String responseContent = IOUtils.toString(status.getEntity().getContent(), StandardCharsets.UTF_8);
|
||||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||||
assertEquals(Constants.CT_FHIR_JSON + ";charset=utf-8", status.getFirstHeader("content-type").getValue().replace(" ", "").replace("UTF", "utf"));
|
assertEquals(Constants.CT_FHIR_JSON + ";charset=utf-8", status.getFirstHeader("content-type").getValue().replace(" ", "").replace("UTF", "utf"));
|
||||||
|
@ -201,7 +202,7 @@ public class BinaryDstu2Test {
|
||||||
public void testSearchXml() throws Exception {
|
public void testSearchXml() throws Exception {
|
||||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Binary?_pretty=true");
|
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Binary?_pretty=true");
|
||||||
HttpResponse status = ourClient.execute(httpGet);
|
HttpResponse status = ourClient.execute(httpGet);
|
||||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
String responseContent = IOUtils.toString(status.getEntity().getContent(), StandardCharsets.UTF_8);
|
||||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||||
assertEquals(Constants.CT_FHIR_XML + ";charset=utf-8", status.getFirstHeader("content-type").getValue().replace(" ", "").replace("UTF", "utf"));
|
assertEquals(Constants.CT_FHIR_XML + ";charset=utf-8", status.getFirstHeader("content-type").getValue().replace(" ", "").replace("UTF", "utf"));
|
||||||
|
|
|
@ -88,7 +88,7 @@ public class ServerMimetypeDstu3Test {
|
||||||
httpPost.setEntity(new StringEntity(enc, ContentType.parse(Constants.CT_FHIR_XML + "; charset=utf-8")));
|
httpPost.setEntity(new StringEntity(enc, ContentType.parse(Constants.CT_FHIR_XML + "; charset=utf-8")));
|
||||||
HttpResponse status = ourClient.execute(httpPost);
|
HttpResponse status = ourClient.execute(httpPost);
|
||||||
|
|
||||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
String responseContent = IOUtils.toString(status.getEntity().getContent(), StandardCharsets.UTF_8);
|
||||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||||
|
|
||||||
ourLog.info("Response was:\n{}", responseContent);
|
ourLog.info("Response was:\n{}", responseContent);
|
||||||
|
@ -138,7 +138,7 @@ public class ServerMimetypeDstu3Test {
|
||||||
httpPost.setEntity(new StringEntity(enc, ContentType.parse(Constants.CT_FHIR_XML_NEW + "; charset=utf-8")));
|
httpPost.setEntity(new StringEntity(enc, ContentType.parse(Constants.CT_FHIR_XML_NEW + "; charset=utf-8")));
|
||||||
HttpResponse status = ourClient.execute(httpPost);
|
HttpResponse status = ourClient.execute(httpPost);
|
||||||
|
|
||||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
String responseContent = IOUtils.toString(status.getEntity().getContent(), StandardCharsets.UTF_8);
|
||||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||||
|
|
||||||
ourLog.info("Response was:\n{}", responseContent);
|
ourLog.info("Response was:\n{}", responseContent);
|
||||||
|
@ -159,7 +159,7 @@ public class ServerMimetypeDstu3Test {
|
||||||
httpPost.addHeader(Constants.HEADER_ACCEPT, Constants.CT_FHIR_XML_NEW);
|
httpPost.addHeader(Constants.HEADER_ACCEPT, Constants.CT_FHIR_XML_NEW);
|
||||||
HttpResponse status = ourClient.execute(httpPost);
|
HttpResponse status = ourClient.execute(httpPost);
|
||||||
|
|
||||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
String responseContent = IOUtils.toString(status.getEntity().getContent(), StandardCharsets.UTF_8);
|
||||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||||
|
|
||||||
ourLog.info("Response was:\n{}", responseContent);
|
ourLog.info("Response was:\n{}", responseContent);
|
||||||
|
@ -179,7 +179,7 @@ public class ServerMimetypeDstu3Test {
|
||||||
httpPost.setEntity(new StringEntity(enc, ContentType.parse(Constants.CT_FHIR_JSON + "; charset=utf-8")));
|
httpPost.setEntity(new StringEntity(enc, ContentType.parse(Constants.CT_FHIR_JSON + "; charset=utf-8")));
|
||||||
HttpResponse status = ourClient.execute(httpPost);
|
HttpResponse status = ourClient.execute(httpPost);
|
||||||
|
|
||||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
String responseContent = IOUtils.toString(status.getEntity().getContent(), StandardCharsets.UTF_8);
|
||||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||||
|
|
||||||
ourLog.info("Response was:\n{}", responseContent);
|
ourLog.info("Response was:\n{}", responseContent);
|
||||||
|
@ -199,7 +199,7 @@ public class ServerMimetypeDstu3Test {
|
||||||
httpPost.setEntity(new StringEntity(enc, ContentType.parse(Constants.CT_FHIR_JSON_NEW + "; charset=utf-8")));
|
httpPost.setEntity(new StringEntity(enc, ContentType.parse(Constants.CT_FHIR_JSON_NEW + "; charset=utf-8")));
|
||||||
HttpResponse status = ourClient.execute(httpPost);
|
HttpResponse status = ourClient.execute(httpPost);
|
||||||
|
|
||||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
String responseContent = IOUtils.toString(status.getEntity().getContent(), StandardCharsets.UTF_8);
|
||||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||||
|
|
||||||
ourLog.info("Response was:\n{}", responseContent);
|
ourLog.info("Response was:\n{}", responseContent);
|
||||||
|
@ -220,7 +220,7 @@ public class ServerMimetypeDstu3Test {
|
||||||
httpPost.addHeader(Constants.HEADER_ACCEPT, Constants.CT_FHIR_JSON_NEW);
|
httpPost.addHeader(Constants.HEADER_ACCEPT, Constants.CT_FHIR_JSON_NEW);
|
||||||
HttpResponse status = ourClient.execute(httpPost);
|
HttpResponse status = ourClient.execute(httpPost);
|
||||||
|
|
||||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
String responseContent = IOUtils.toString(status.getEntity().getContent(), StandardCharsets.UTF_8);
|
||||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||||
|
|
||||||
ourLog.info("Response was:\n{}", responseContent);
|
ourLog.info("Response was:\n{}", responseContent);
|
||||||
|
@ -236,7 +236,7 @@ public class ServerMimetypeDstu3Test {
|
||||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_format=xml");
|
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_format=xml");
|
||||||
HttpResponse status = ourClient.execute(httpGet);
|
HttpResponse status = ourClient.execute(httpGet);
|
||||||
|
|
||||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
String responseContent = IOUtils.toString(status.getEntity().getContent(), StandardCharsets.UTF_8);
|
||||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||||
|
|
||||||
ourLog.info("Response was:\n{}", responseContent);
|
ourLog.info("Response was:\n{}", responseContent);
|
||||||
|
@ -244,7 +244,7 @@ public class ServerMimetypeDstu3Test {
|
||||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||||
assertThat(responseContent, containsString("<Patient xmlns=\"http://hl7.org/fhir\">"));
|
assertThat(responseContent, containsString("<Patient xmlns=\"http://hl7.org/fhir\">"));
|
||||||
assertThat(responseContent, not(containsString("http://hl7.org/fhir/")));
|
assertThat(responseContent, not(containsString("http://hl7.org/fhir/")));
|
||||||
assertEquals(Constants.CT_FHIR_XML, status.getFirstHeader("content-type").getValue().replaceAll(";.*", ""));
|
assertEquals(Constants.CT_FHIR_XML_NEW, status.getFirstHeader("content-type").getValue().replaceAll(";.*", ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -253,7 +253,7 @@ public class ServerMimetypeDstu3Test {
|
||||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_format=" + Constants.CT_FHIR_XML);
|
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_format=" + Constants.CT_FHIR_XML);
|
||||||
HttpResponse status = ourClient.execute(httpGet);
|
HttpResponse status = ourClient.execute(httpGet);
|
||||||
|
|
||||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
String responseContent = IOUtils.toString(status.getEntity().getContent(), StandardCharsets.UTF_8);
|
||||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||||
|
|
||||||
ourLog.info("Response was:\n{}", responseContent);
|
ourLog.info("Response was:\n{}", responseContent);
|
||||||
|
@ -270,7 +270,7 @@ public class ServerMimetypeDstu3Test {
|
||||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_format=" + Constants.CT_FHIR_XML_NEW);
|
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_format=" + Constants.CT_FHIR_XML_NEW);
|
||||||
HttpResponse status = ourClient.execute(httpGet);
|
HttpResponse status = ourClient.execute(httpGet);
|
||||||
|
|
||||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
String responseContent = IOUtils.toString(status.getEntity().getContent(), StandardCharsets.UTF_8);
|
||||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||||
|
|
||||||
ourLog.info("Response was:\n{}", responseContent);
|
ourLog.info("Response was:\n{}", responseContent);
|
||||||
|
@ -278,7 +278,7 @@ public class ServerMimetypeDstu3Test {
|
||||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||||
assertThat(responseContent, containsString("<Patient xmlns=\"http://hl7.org/fhir\">"));
|
assertThat(responseContent, containsString("<Patient xmlns=\"http://hl7.org/fhir\">"));
|
||||||
assertThat(responseContent, not(containsString("http://hl7.org/fhir/")));
|
assertThat(responseContent, not(containsString("http://hl7.org/fhir/")));
|
||||||
assertEquals(Constants.CT_FHIR_XML, status.getFirstHeader("content-type").getValue().replaceAll(";.*", ""));
|
assertEquals(Constants.CT_FHIR_XML_NEW, status.getFirstHeader("content-type").getValue().replaceAll(";.*", ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -289,14 +289,14 @@ public class ServerMimetypeDstu3Test {
|
||||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_format=json");
|
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_format=json");
|
||||||
HttpResponse status = ourClient.execute(httpGet);
|
HttpResponse status = ourClient.execute(httpGet);
|
||||||
|
|
||||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
String responseContent = IOUtils.toString(status.getEntity().getContent(), StandardCharsets.UTF_8);
|
||||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||||
|
|
||||||
ourLog.info("Response was:\n{}", responseContent);
|
ourLog.info("Response was:\n{}", responseContent);
|
||||||
|
|
||||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||||
assertThat(responseContent, containsString("\"resourceType\""));
|
assertThat(responseContent, containsString("\"resourceType\""));
|
||||||
assertEquals(Constants.CT_FHIR_JSON, status.getFirstHeader("content-type").getValue().replaceAll(";.*", ""));
|
assertEquals(Constants.CT_FHIR_JSON_NEW, status.getFirstHeader("content-type").getValue().replaceAll(";.*", ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -305,7 +305,7 @@ public class ServerMimetypeDstu3Test {
|
||||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_format=" + Constants.CT_FHIR_JSON);
|
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_format=" + Constants.CT_FHIR_JSON);
|
||||||
HttpResponse status = ourClient.execute(httpGet);
|
HttpResponse status = ourClient.execute(httpGet);
|
||||||
|
|
||||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
String responseContent = IOUtils.toString(status.getEntity().getContent(), StandardCharsets.UTF_8);
|
||||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||||
|
|
||||||
ourLog.info("Response was:\n{}", responseContent);
|
ourLog.info("Response was:\n{}", responseContent);
|
||||||
|
@ -321,14 +321,14 @@ public class ServerMimetypeDstu3Test {
|
||||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_format=" + Constants.CT_FHIR_JSON_NEW);
|
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_format=" + Constants.CT_FHIR_JSON_NEW);
|
||||||
HttpResponse status = ourClient.execute(httpGet);
|
HttpResponse status = ourClient.execute(httpGet);
|
||||||
|
|
||||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
String responseContent = IOUtils.toString(status.getEntity().getContent(), StandardCharsets.UTF_8);
|
||||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||||
|
|
||||||
ourLog.info("Response was:\n{}", responseContent);
|
ourLog.info("Response was:\n{}", responseContent);
|
||||||
|
|
||||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||||
assertThat(responseContent, containsString("\"resourceType\""));
|
assertThat(responseContent, containsString("\"resourceType\""));
|
||||||
assertEquals(Constants.CT_FHIR_JSON, status.getFirstHeader("content-type").getValue().replaceAll(";.*", ""));
|
assertEquals(Constants.CT_FHIR_JSON_NEW, status.getFirstHeader("content-type").getValue().replaceAll(";.*", ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
|
|
|
@ -19,6 +19,11 @@
|
||||||
Thanks to Pater Girard for all of his help during the connectathon
|
Thanks to Pater Girard for all of his help during the connectathon
|
||||||
in implementing this feature!
|
in implementing this feature!
|
||||||
</action>
|
</action>
|
||||||
|
<action type="add">
|
||||||
|
Both client and server now use the new STU3 mime types by default
|
||||||
|
if running in STU3 mode (in other words, using an STU3
|
||||||
|
FhirContext).
|
||||||
|
</action>
|
||||||
<action type="fix">
|
<action type="fix">
|
||||||
In server, when returning a list of resources, the server sometimes failed to add
|
In server, when returning a list of resources, the server sometimes failed to add
|
||||||
<![CDATA[<code>_include</code>]]> resources to the response bundle if they were
|
<![CDATA[<code>_include</code>]]> resources to the response bundle if they were
|
||||||
|
|
Loading…
Reference in New Issue