Merge branch 'pr/1944' into test-1944
This commit is contained in:
@@ -22,12 +22,15 @@ import java.nio.charset.Charset;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.cloud.config.environment.Environment;
|
||||
import org.springframework.cloud.config.server.encryption.ResourceEncryptor;
|
||||
import org.springframework.cloud.config.server.environment.EnvironmentRepository;
|
||||
import org.springframework.cloud.config.server.environment.RepositoryException;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
@@ -225,4 +228,9 @@ public class ResourceController {
|
||||
public void notFound(NoSuchResourceException e) {
|
||||
}
|
||||
|
||||
@ExceptionHandler(RepositoryException.class)
|
||||
public void noSuchLabel(HttpServletResponse response) throws IOException {
|
||||
response.sendError(HttpStatus.NOT_FOUND.value());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.springframework.cloud.config.environment.Environment;
|
||||
import org.springframework.cloud.config.server.encryption.ResourceEncryptor;
|
||||
import org.springframework.cloud.config.server.environment.EnvironmentController;
|
||||
import org.springframework.cloud.config.server.environment.EnvironmentRepository;
|
||||
import org.springframework.cloud.config.server.environment.NoSuchLabelException;
|
||||
import org.springframework.cloud.config.server.resource.ResourceControllerIntegrationTests.ControllerConfiguration;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
@@ -156,6 +157,14 @@ public class ResourceControllerIntegrationTests {
|
||||
verify(this.resources).findOne("foo", "default", null, "foo.txt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resourceWithMissingLabel() throws Exception {
|
||||
when(this.resources.findOne("foo", "default", "missing", "foo.txt"))
|
||||
.thenThrow(new NoSuchLabelException("Planned"));
|
||||
this.mvc.perform(MockMvcRequestBuilders.get("/foo/default/missing/foo.txt"))
|
||||
.andExpect(MockMvcResultMatchers.status().isNotFound());
|
||||
}
|
||||
|
||||
@SpringBootConfiguration
|
||||
@EnableAutoConfiguration
|
||||
public static class ControllerConfiguration {
|
||||
|
||||
Reference in New Issue
Block a user