Merge remote-tracking branch 'origin/2.0.x' into 2.1.x
This commit is contained in:
@@ -32,12 +32,14 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.core.io.ByteArrayResource;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
||||
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
|
||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||
import org.springframework.util.MimeTypeUtils;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||
|
||||
@@ -64,7 +66,7 @@ public class ResourceControllerIntegrationTests {
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
Mockito.reset(this.repository);
|
||||
Mockito.reset(this.repository, this.resources);
|
||||
this.mvc = MockMvcBuilders.webAppContextSetup(this.context).build();
|
||||
}
|
||||
|
||||
@@ -93,6 +95,20 @@ public class ResourceControllerIntegrationTests {
|
||||
Mockito.verify(this.resources).findOne("foo", "default", null, "foo.txt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void binaryResourceNoLabel() throws Exception {
|
||||
Mockito.when(this.repository.findOne("foo", "default", null))
|
||||
.thenReturn(new Environment("foo", "default", "master"));
|
||||
Mockito.when(this.resources.findOne("foo", "default", null, "foo.txt"))
|
||||
.thenReturn(new ByteArrayResource("hello".getBytes()));
|
||||
this.mvc.perform(MockMvcRequestBuilders.get("/foo/default/foo.txt")
|
||||
.param("useDefaultLabel", "")
|
||||
.header(HttpHeaders.ACCEPT, MimeTypeUtils.APPLICATION_OCTET_STREAM_VALUE))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk());
|
||||
Mockito.verify(this.repository).findOne("foo", "default", null);
|
||||
Mockito.verify(this.resources).findOne("foo", "default", null, "foo.txt");
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@EnableWebMvc
|
||||
@Import(PropertyPlaceholderAutoConfiguration.class)
|
||||
|
||||
@@ -299,4 +299,15 @@ public class ResourceControllerTests {
|
||||
return text.replace("\n", "").replace("\t", "");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void defaultLabelForBinary() throws Exception {
|
||||
this.environmentRepository.setSearchLocations("classpath:/test/{application}");
|
||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||
ServletWebRequest webRequest = new ServletWebRequest(request,
|
||||
new MockHttpServletResponse());
|
||||
request.setRequestURI("/dev/spam/bar/" + "foo.txt");
|
||||
byte[] resource = this.controller.binary("dev/spam", "bar", webRequest);
|
||||
assertThat(new String(resource)).isEqualToIgnoringNewLines("foo: dev_bar/spam");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user