Use HttpStatus in ErrorPage

This commit is contained in:
Dave Syer
2013-05-08 15:33:25 +01:00
parent dc30add6c5
commit 8bfe07c730
9 changed files with 110 additions and 607 deletions

View File

@@ -16,8 +16,6 @@
package org.springframework.bootstrap.actuate.autoconfigure;
import java.util.Collections;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.HierarchicalBeanFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -107,8 +105,7 @@ public class ManagementServerConfiguration implements BeanPostProcessor {
factory.setAddress(this.configuration.getAddress());
factory.setContextPath(this.configuration.getContextPath());
factory.setErrorPages(Collections
.singleton(new ErrorPage(this.errorPath)));
factory.addErrorPages(new ErrorPage(this.errorPath));
this.initialized = true;
}

View File

@@ -16,8 +16,6 @@
package org.springframework.bootstrap.actuate.autoconfigure;
import java.util.Collections;
import javax.servlet.Servlet;
import org.apache.catalina.valves.AccessLogValve;
@@ -104,8 +102,7 @@ public class ServerConfiguration implements BeanPostProcessor, BeanFactoryAware
server);
}
factory.setErrorPages(Collections
.singleton(new ErrorPage(this.errorPath)));
factory.addErrorPages(new ErrorPage(this.errorPath));
this.initialized = true;
}

View File

@@ -0,0 +1,54 @@
/*
* Copyright 2012-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.bootstrap.actuate.properties;
import java.net.InetAddress;
import java.util.Collections;
import org.junit.Test;
import org.springframework.beans.MutablePropertyValues;
import org.springframework.bootstrap.bind.RelaxedDataBinder;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
/**
* Externalized configuration for server properties
*
* @author Dave Syer
*
*/
public class ServerPropertiesTests {
private ServerProperties properties = new ServerProperties();
@Test
public void testAddressBinding() throws Exception {
RelaxedDataBinder binder = new RelaxedDataBinder(this.properties, "server");
binder.bind(new MutablePropertyValues(Collections.singletonMap("server.address",
"127.0.0.1")));
assertFalse(binder.getBindingResult().hasErrors());
assertEquals(InetAddress.getLocalHost(), this.properties.getAddress());
}
@Test
public void testPortBinding() throws Exception {
new RelaxedDataBinder(this.properties, "server").bind(new MutablePropertyValues(
Collections.singletonMap("server.port", "9000")));
assertEquals(9000, this.properties.getPort());
}
}