Add support for binary file server via context negotation

If client sends "Accept: application/octet-stream" then the server
sends back a binary file (no placeholders and no text conversion)
This commit is contained in:
Dave Syer
2015-10-06 17:58:02 +01:00
parent 274c7cff49
commit c0ddcd800e
2 changed files with 22 additions and 2 deletions

View File

@@ -24,8 +24,6 @@ import org.junit.Test;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.config.server.environment.NativeEnvironmentRepository;
import org.springframework.cloud.config.server.environment.NativeEnvironmentRepositoryTests;
import org.springframework.cloud.config.server.resource.GenericResourceRepository;
import org.springframework.cloud.config.server.resource.ResourceController;
import org.springframework.context.ConfigurableApplicationContext;
/**
@@ -66,6 +64,13 @@ public class ResourceControllerTests {
assertEquals("{\n \"foo\": \"dev_bar\"\n}", resource);
}
@Test
public void templateReplacementNotForBinary() throws Exception {
this.environmentRepository.setSearchLocations("classpath:/test");
String resource = new String(this.controller.binary("foo", "bar", "dev", "template.json"));
assertEquals("{\n \"foo\": \"${foo}\"\n}", resource);
}
@Test
public void escapedPlaceholder() throws Exception {
this.environmentRepository.setSearchLocations("classpath:/test");