Fix tests
This commit is contained in:
parent
dd95a52240
commit
3e8638a65f
|
@ -17,13 +17,16 @@ import static org.junit.Assert.assertNotNull;
|
|||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.forwardedUrlPattern;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
@ -120,6 +123,35 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
|
|||
TestUtil.clearAllStaticFieldsForUnitTest();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testSearchByExtendedChars() throws Exception {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
Patient p = new Patient();
|
||||
p.addName().addFamily("Jernelöv");
|
||||
p.addIdentifier().setValue("ID" + i);
|
||||
myPatientDao.create(p, mySrd);
|
||||
}
|
||||
|
||||
String uri = ourServerBase + "/Patient?name=" + URLEncoder.encode("Jernelöv", "UTF-8") + "&_count=5&_pretty=true";
|
||||
ourLog.info("URI: {}", uri);
|
||||
HttpGet get = new HttpGet(uri);
|
||||
CloseableHttpResponse resp = ourHttpClient.execute(get);
|
||||
try {
|
||||
assertEquals(200, resp.getStatusLine().getStatusCode());
|
||||
String output = IOUtils.toString(resp.getEntity().getContent());
|
||||
ourLog.info(output);
|
||||
|
||||
assertThat(output, containsString("<url value=\"" + ourServerBase + "/Patient?name=Jernel%C3%B6v&_pretty=true\"/>"));
|
||||
assertThat(output, containsString("<family value=\"Jernelöv\"/>"));
|
||||
} finally {
|
||||
IOUtils.closeQuietly(resp.getEntity().getContent());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void before() throws Exception {
|
||||
super.before();
|
||||
|
|
|
@ -2,6 +2,7 @@ package ca.uhn.fhir.rest.server;
|
|||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
@ -57,6 +58,18 @@ public class ServerSearchDstu2Test {
|
|||
assertEquals("param1value", ourLastRef.getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchWithEncodedValue() throws Exception {
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/?param1=" + URLEncoder.encode("Jernelöv", "UTF-8"));
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
ourLog.info(responseContent);
|
||||
assertEquals("searchParam1", ourLastMethod);
|
||||
assertEquals("Jernelöv", ourLastRef.getValue());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testSearchParam2() throws Exception {
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/?param2=param2value&foo=bar");
|
||||
|
|
|
@ -604,6 +604,15 @@
|
|||
|
||||
</section>
|
||||
|
||||
<!--
|
||||
<section name="Deploying to Containers">
|
||||
<Connector port="28081" protocol="HTTP/1.1"
|
||||
connectionTimeout="20000" URIEncoding="UTF-8"
|
||||
redirectPort="8443" maxHttpHeaderSize="32000" />
|
||||
</section>
|
||||
-->
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
</document>
|
||||
|
|
Loading…
Reference in New Issue