Fix #445 - Server was using the wrong mimetype for conf statement

This commit is contained in:
James Agnew 2016-09-16 13:25:03 -04:00
parent e1b41d8bf5
commit 12790d385c
3 changed files with 38 additions and 6 deletions

View File

@ -223,8 +223,8 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
retVal.setKind(ConformanceStatementKind.INSTANCE);
retVal.getSoftware().setName(myServerConfiguration.getServerName());
retVal.getSoftware().setVersion(myServerConfiguration.getServerVersion());
retVal.addFormat(Constants.CT_FHIR_XML);
retVal.addFormat(Constants.CT_FHIR_JSON);
retVal.addFormat(Constants.CT_FHIR_XML_NEW);
retVal.addFormat(Constants.CT_FHIR_JSON_NEW);
retVal.setStatus(ConformanceResourceStatus.ACTIVE);
ConformanceRestComponent rest = retVal.addRest();

View File

@ -1,11 +1,13 @@
package ca.uhn.fhir.rest.server;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
@ -25,10 +27,7 @@ import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.hl7.fhir.dstu3.model.DateType;
import org.hl7.fhir.dstu3.model.IdType;
import org.hl7.fhir.dstu3.model.OperationOutcome;
import org.hl7.fhir.dstu3.model.Patient;
import org.hl7.fhir.dstu3.model.*;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@ -53,6 +52,32 @@ public class ServerMimetypeDstu3Test {
private static int ourPort;
private static Server ourServer;
@Test
public void testConformanceMetadataUsesNewMimetypes() throws Exception {
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/metadata");
CloseableHttpResponse status = ourClient.execute(httpGet);
try {
String content = IOUtils.toString(status.getEntity().getContent(), StandardCharsets.UTF_8);
Conformance conf = ourCtx.newXmlParser().parseResource(Conformance.class, content);
List<String> strings = toStrings(conf.getFormat());
assertThat(strings, contains(Constants.CT_FHIR_XML_NEW, Constants.CT_FHIR_JSON_NEW));
} finally {
status.close();
}
}
private List<String> toStrings(List<CodeType> theFormat) {
ArrayList<String> retVal = new ArrayList<>();
for (CodeType next : theFormat) {
retVal.add(next.asStringValue());
}
return retVal;
}
@Test
public void testCreateWithXmlLegacyNoAcceptHeader() throws Exception {
Patient p = new Patient();

View File

@ -42,6 +42,13 @@
default type for profile is used. Thanks to
Filip Domazet for the pull request!
</action>
<action type="fix" issue="445">
STU3 servers were adding the old MimeType
strings to the
<![CDATA[<code>Conformance.format</code>]]>
part of the generated server conformance
statement
</action>
</release>
<release version="2.0" date="2016-08-30">
<action type="fix">