Commit e3a53cb0 authored by Andy Wilkinson's avatar Andy Wilkinson

Remove classes and methods deprecated since 1.2 and earlier

Closes gh-2697
parent 9243faa3
......@@ -158,7 +158,7 @@ public class EndpointWebMvcChildContextConfiguration {
* configures the security filter.
*/
@Configuration
@ConditionalOnMissingClass(name = "org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter")
@ConditionalOnMissingClass("org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter")
protected static class EndpointHandlerMappingConfiguration {
@Autowired(required = false)
......
/*
* Copyright 2012-2014 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.boot.actuate.endpoint;
import java.util.Collection;
import java.util.LinkedHashSet;
import org.springframework.boot.actuate.metrics.Metric;
import org.springframework.boot.actuate.metrics.reader.MetricReader;
import org.springframework.util.Assert;
/**
* Default implementation of {@link PublicMetrics} that exposes all metrics from a
* {@link MetricReader} along with memory information.
*
* @author Dave Syer
* @author Christian Dupuis
* @deprecated since 1.2 in favor of {@link SystemPublicMetrics},
* {@code MetricReaderPublicMetrics}
*/
@Deprecated
public class VanillaPublicMetrics extends SystemPublicMetrics {
private final MetricReader reader;
public VanillaPublicMetrics(MetricReader reader) {
Assert.notNull(reader, "MetricReader must not be null");
this.reader = reader;
}
@Override
public Collection<Metric<?>> metrics() {
Collection<Metric<?>> result = new LinkedHashSet<Metric<?>>();
for (Metric<?> metric : this.reader.findAll()) {
result.add(metric);
}
result.addAll(super.metrics());
return result;
}
}
/*
* Copyright 2010-2014 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.boot.actuate.system;
import java.io.File;
import org.springframework.boot.context.event.ApplicationStartedEvent;
/**
* An {@link org.springframework.context.ApplicationListener} that saves application PID
* into file. This application listener will be triggered exactly once per JVM, and the
* file name can be overridden at runtime with a System property or environment variable
* named "PIDFILE" (or "pidfile").
*
* @author Jakub Kubrynski
* @author Dave Syer
* @author Phillip Webb
* @since 1.0.2
* @deprecated since 1.2.0 in favor of {@link ApplicationPidFileWriter}
*/
@Deprecated
public class ApplicationPidListener extends ApplicationPidFileWriter {
public ApplicationPidListener() {
super();
setTriggerEventType(ApplicationStartedEvent.class);
}
public ApplicationPidListener(File file) {
super(file);
setTriggerEventType(ApplicationStartedEvent.class);
}
public ApplicationPidListener(String filename) {
super(filename);
setTriggerEventType(ApplicationStartedEvent.class);
}
}
/*
* Copyright 2012-2014 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.boot.actuate.endpoint;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import org.junit.Test;
import org.springframework.boot.actuate.metrics.Metric;
import org.springframework.boot.actuate.metrics.repository.InMemoryMetricRepository;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
/**
* Tests for {@link VanillaPublicMetrics}.
*
* @author Phillip Webb
* @author Christian Dupuis
*/
@Deprecated
public class VanillaPublicMetricsTests {
@Test
public void testMetrics() throws Exception {
InMemoryMetricRepository repository = new InMemoryMetricRepository();
repository.set(new Metric<Double>("a", 0.5, new Date()));
VanillaPublicMetrics publicMetrics = new VanillaPublicMetrics(repository);
Map<String, Metric<?>> results = new HashMap<String, Metric<?>>();
for (Metric<?> metric : publicMetrics.metrics()) {
results.put(metric.getName(), metric);
}
assertTrue(results.containsKey("mem"));
assertTrue(results.containsKey("mem.free"));
assertThat(results.get("a").getValue().doubleValue(), equalTo(0.5));
}
@Test
public void testSystemMetrics() throws Exception {
InMemoryMetricRepository repository = new InMemoryMetricRepository();
repository.set(new Metric<Double>("a", 0.5, new Date()));
VanillaPublicMetrics publicMetrics = new VanillaPublicMetrics(repository);
Map<String, Metric<?>> results = new HashMap<String, Metric<?>>();
for (Metric<?> metric : publicMetrics.metrics()) {
results.put(metric.getName(), metric);
}
assertTrue(results.containsKey("mem"));
assertTrue(results.containsKey("mem.free"));
assertTrue(results.containsKey("processors"));
assertTrue(results.containsKey("uptime"));
assertTrue(results.containsKey("heap.committed"));
assertTrue(results.containsKey("heap.init"));
assertTrue(results.containsKey("heap.used"));
assertTrue(results.containsKey("heap"));
assertTrue(results.containsKey("threads.peak"));
assertTrue(results.containsKey("threads.daemon"));
assertTrue(results.containsKey("threads"));
assertTrue(results.containsKey("classes.loaded"));
assertTrue(results.containsKey("classes.unloaded"));
assertTrue(results.containsKey("classes"));
}
}
......@@ -37,19 +37,16 @@ import org.springframework.context.annotation.Conditional;
public @interface ConditionalOnMissingClass {
/**
* The classes that must not be present. Since this annotation parsed by loading class
* bytecode it is safe to specify classes here that may ultimately not be on the
* classpath.
* @return the classes that must be present
* @deprecated Since 1.1.0 due to the fact that the reflection errors can occur when
* beans containing the annotation remain in the context. Use {@link #name()} instead.
* The names of the classes that must not be present.
* @return the names of the classes that must not be present
*/
@Deprecated
public Class<?>[] value() default {};
public String[] value() default {};
/**
* The classes names that must not be present.
* @return the class names that must be present.
* An alias for {@link #value} specifying the names of the classes that must not be
* present.
* @return the class names that must not be present.
* @deprecated since 1.3.0 in favor of {@link #value}.
*/
public String[] name() default {};
......
/*
* Copyright 2012-2014 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.boot.autoconfigure.groovy.template;
import groovy.text.markup.MarkupTemplateEngine;
import groovy.text.markup.TemplateConfiguration;
import groovy.text.markup.TemplateResolver;
import java.io.IOException;
import java.net.URL;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.web.servlet.view.groovy.GroovyMarkupConfigurer;
import org.springframework.web.servlet.view.groovy.GroovyMarkupViewResolver;
/**
* A custom {@link groovy.text.markup.TemplateResolver template resolver} which resolves
* templates using the locale found in the thread locale. This resolver ignores the
* template engine configuration locale.
*
* @author Cédric Champeau
* @since 1.1.0
* @deprecated since 1.2 in favor of Spring 4.1's {@link GroovyMarkupViewResolver} and
* {@link GroovyMarkupConfigurer}.
*/
@Deprecated
public class GroovyTemplateResolver implements TemplateResolver {
private ClassLoader templateClassLoader;
@Override
public void configure(final ClassLoader templateClassLoader,
final TemplateConfiguration configuration) {
this.templateClassLoader = templateClassLoader;
}
@Override
public URL resolveTemplate(final String templatePath) throws IOException {
MarkupTemplateEngine.TemplateResource templateResource = MarkupTemplateEngine.TemplateResource
.parse(templatePath);
URL resource = this.templateClassLoader.getResource(templateResource.withLocale(
LocaleContextHolder.getLocale().toString().replace("-", "_")).toString());
if (resource == null) {
// no resource found with the default locale, try without any locale
resource = this.templateClassLoader.getResource(templateResource.withLocale(
null).toString());
}
if (resource == null) {
throw new IOException("Unable to load template:" + templatePath);
}
return resource;
}
}
......@@ -35,7 +35,6 @@ import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.web.HttpMapperProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
......@@ -50,7 +49,6 @@ import org.springframework.util.ReflectionUtils;
import com.fasterxml.jackson.databind.Module;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.datatype.joda.cfg.JacksonJodaDateFormat;
import com.fasterxml.jackson.datatype.joda.ser.DateTimeSerializer;
......@@ -72,7 +70,6 @@ import com.fasterxml.jackson.datatype.joda.ser.DateTimeSerializer;
*/
@Configuration
@ConditionalOnClass(ObjectMapper.class)
@SuppressWarnings("deprecation")
public class JacksonAutoConfiguration {
@Autowired
......@@ -151,7 +148,7 @@ public class JacksonAutoConfiguration {
@Configuration
@ConditionalOnClass({ ObjectMapper.class, Jackson2ObjectMapperBuilder.class })
@EnableConfigurationProperties({ HttpMapperProperties.class, JacksonProperties.class })
@EnableConfigurationProperties(JacksonProperties.class)
static class JacksonObjectMapperBuilderConfiguration implements
ApplicationContextAware {
......@@ -160,22 +157,11 @@ public class JacksonAutoConfiguration {
@Autowired
private JacksonProperties jacksonProperties;
@Autowired
private HttpMapperProperties httpMapperProperties;
@Bean
@ConditionalOnMissingBean(Jackson2ObjectMapperBuilder.class)
public Jackson2ObjectMapperBuilder jacksonObjectMapperBuilder() {
Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder();
builder.applicationContext(this.applicationContext);
Boolean isJsonSortKeys = this.httpMapperProperties.isJsonSortKeys();
if (isJsonSortKeys != null && isJsonSortKeys) {
builder.featuresToEnable(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS);
}
Boolean isJsonPrettyPrint = this.httpMapperProperties.isJsonPrettyPrint();
if (isJsonPrettyPrint != null && isJsonPrettyPrint) {
builder.featuresToEnable(SerializationFeature.INDENT_OUTPUT);
}
if (this.jacksonProperties.getSerializationInclusion() != null) {
builder.serializationInclusion(this.jacksonProperties
.getSerializationInclusion());
......
......@@ -21,8 +21,6 @@ import java.util.Map;
import javax.sql.DataSource;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.boot.autoconfigure.jdbc.EmbeddedDatabaseConnection;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.orm.jpa.vendor.Database;
......@@ -38,8 +36,6 @@ import org.springframework.util.StringUtils;
@ConfigurationProperties(prefix = "spring.jpa")
public class JpaProperties {
private static final Log logger = LogFactory.getLog(JpaProperties.class);
/**
* Additional native properties to set on the JPA provider.
*/
......@@ -151,13 +147,6 @@ public class JpaProperties {
this.namingStrategy = namingStrategy;
}
@Deprecated
public void setNamingstrategy(Class<?> namingStrategy) {
logger.warn("The property spring.jpa.namingstrategy has been renamed, "
+ "please update your configuration to use namingStrategy or naming-strategy or naming_strategy");
this.setNamingStrategy(namingStrategy);
}
public String getDdlAuto() {
return this.ddlAuto;
}
......
......@@ -123,7 +123,7 @@ public class RedisAutoConfiguration {
* Redis connection configuration.
*/
@Configuration
@ConditionalOnMissingClass(name = "org.apache.commons.pool2.impl.GenericObjectPool")
@ConditionalOnMissingClass("org.apache.commons.pool2.impl.GenericObjectPool")
protected static class RedisConnectionConfiguration extends
AbstractRedisConfiguration {
......
......@@ -202,7 +202,7 @@ public class SpringBootWebSecurityConfiguration {
// Pull in a plain @EnableWebSecurity if Spring MVC is not available
@ConditionalOnMissingBean(WebMvcSecurityConfigurationConditions.class)
@ConditionalOnMissingClass(name = "org.springframework.web.servlet.support.RequestDataValueProcessor")
@ConditionalOnMissingClass("org.springframework.web.servlet.support.RequestDataValueProcessor")
@Configuration
@EnableWebSecurity
protected static class DefaultWebSecurityConfiguration {
......
......@@ -125,7 +125,7 @@ public class SocialWebAutoConfiguration {
@Configuration
@EnableSocial
@ConditionalOnWebApplication
@ConditionalOnMissingClass(name = "org.springframework.security.core.context.SecurityContextHolder")
@ConditionalOnMissingClass("org.springframework.security.core.context.SecurityContextHolder")
protected static class AnonymousUserIdSourceConfig extends SocialConfigurerAdapter {
@Override
......
......@@ -101,24 +101,6 @@ public abstract class AbstractViewResolverProperties {
this.contentType = contentType;
}
/**
* @deprecated since 1.2.0 in favor of {@link #getCharset()}
* @return the charset
*/
@Deprecated
public String getCharSet() {
return getCharset();
}
/**
* @deprecated since 1.2.0 in favor of {@link #setCharset(String)}
* @param charSet the charset
*/
@Deprecated
public void setCharSet(String charSet) {
setCharset(charSet);
}
public String getCharset() {
return this.charset;
}
......
/*
* Copyright 2012-2014 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.boot.autoconfigure.web;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.boot.autoconfigure.jackson.JacksonProperties;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.http.converter.HttpMessageConverter;
import com.fasterxml.jackson.databind.SerializationFeature;
/**
* Configuration properties to configure {@link HttpMessageConverter}s.
*
* @author Dave Syer
* @author Piotr Maj
* @author Sebastien Deleuze
* @deprecated in 1.2.0 favor of {@link JacksonProperties}
*/
@ConfigurationProperties(prefix = "http.mappers", ignoreUnknownFields = false)
@Deprecated
public class HttpMapperProperties {
private final Log logger = LogFactory.getLog(HttpMapperProperties.class);
/**
* Enable json pretty print.
*/
private Boolean jsonPrettyPrint;
/**
* Enable key sorting.
*/
private Boolean jsonSortKeys;
public void setJsonPrettyPrint(Boolean jsonPrettyPrint) {
this.logger.warn(getDeprecationMessage("http.mappers.json-pretty-print",
SerializationFeature.INDENT_OUTPUT));
this.jsonPrettyPrint = jsonPrettyPrint;
}
public Boolean isJsonPrettyPrint() {
return this.jsonPrettyPrint;
}
public void setJsonSortKeys(Boolean jsonSortKeys) {
this.logger.warn(getDeprecationMessage("http.mappers.json-sort-keys",
SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS));
this.jsonSortKeys = jsonSortKeys;
}
public Boolean isJsonSortKeys() {
return this.jsonSortKeys;
}
private String getDeprecationMessage(String property,
SerializationFeature alternativeFeature) {
return String.format("%s is deprecated. If you are using Jackson,"
+ " spring.jackson.serialization.%s=true should be used instead.",
property, alternativeFeature.name());
}
}
......@@ -16,12 +16,10 @@
package org.springframework.boot.autoconfigure.web;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
......@@ -43,26 +41,14 @@ class JacksonHttpMessageConvertersConfiguration {
@Configuration
@ConditionalOnClass(ObjectMapper.class)
@ConditionalOnBean(ObjectMapper.class)
@EnableConfigurationProperties(HttpMapperProperties.class)
@ConditionalOnProperty(name = HttpMessageConvertersAutoConfiguration.PREFERRED_MAPPER_PROPERTY, havingValue = "jackson", matchIfMissing = true)
@SuppressWarnings("deprecation")
protected static class MappingJackson2HttpMessageConverterConfiguration {
// This can be removed when the deprecated class is removed (the ObjectMapper will
// already have all the correct properties).
@Autowired
private HttpMapperProperties properties = new HttpMapperProperties();
@Bean
@ConditionalOnMissingBean
public MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter(
ObjectMapper objectMapper) {
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(
objectMapper);
if (this.properties.isJsonPrettyPrint() != null) {
converter.setPrettyPrint(this.properties.isJsonPrettyPrint());
}
return converter;
return new MappingJackson2HttpMessageConverter(objectMapper);
}
}
......@@ -70,23 +56,14 @@ class JacksonHttpMessageConvertersConfiguration {
@Configuration
@ConditionalOnClass(XmlMapper.class)
@ConditionalOnBean(Jackson2ObjectMapperBuilder.class)
@EnableConfigurationProperties(HttpMapperProperties.class)
@SuppressWarnings("deprecation")
protected static class MappingJackson2XmlHttpMessageConverterConfiguration {
@Autowired
private HttpMapperProperties properties = new HttpMapperProperties();
@Bean
@ConditionalOnMissingBean
public MappingJackson2XmlHttpMessageConverter mappingJackson2XmlHttpMessageConverter(
Jackson2ObjectMapperBuilder builder) {
MappingJackson2XmlHttpMessageConverter converter = new MappingJackson2XmlHttpMessageConverter();
converter.setObjectMapper(builder.createXmlMapper(true).build());
if (this.properties.isJsonPrettyPrint() != null) {
converter.setPrettyPrint(this.properties.isJsonPrettyPrint());
}
return converter;
return new MappingJackson2XmlHttpMessageConverter(builder.createXmlMapper(
true).build());
}
}
......
......@@ -51,7 +51,7 @@ public class ConditionalOnMissingClassTests {
}
@Configuration
@ConditionalOnMissingClass(ConditionalOnMissingClassTests.class)
@ConditionalOnMissingClass("org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClassTests")
protected static class BasicConfiguration {
@Bean
public String bar() {
......
......@@ -355,28 +355,6 @@ public class JacksonAutoConfigurationTests {
DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES));
}
@Test
public void httpMappersJsonPrettyPrintIsApplied() {
this.context.register(JacksonAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context,
"http.mappers.json-pretty-print:true");
this.context.refresh();
ObjectMapper objectMapper = this.context.getBean(ObjectMapper.class);
assertTrue(objectMapper.getSerializationConfig().isEnabled(
SerializationFeature.INDENT_OUTPUT));
}
@Test
public void httpMappersJsonSortKeysIsApplied() {
this.context.register(JacksonAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context,
"http.mappers.json-sort-keys:true");
this.context.refresh();
ObjectMapper objectMapper = this.context.getBean(ObjectMapper.class);
assertTrue(objectMapper.getSerializationConfig().isEnabled(
SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS));
}
@Test
public void moduleBeansAndWellKnownModulesAreRegisteredWithTheObjectMapperBuilder() {
this.context.register(ModuleConfig.class, JacksonAutoConfiguration.class);
......
......@@ -97,21 +97,6 @@ public class HibernateJpaAutoConfigurationTests extends AbstractJpaAutoConfigura
assertThat(actual, equalTo("org.hibernate.cfg.EJB3NamingStrategy"));
}
@Test
public void testNamingStrategyThatWorkedInOneDotOhContinuesToWork() {
EnvironmentTestUtils.addEnvironment(this.context,
"spring.jpa.hibernate.namingstrategy:"
+ "org.hibernate.cfg.EJB3NamingStrategy");
setupTestConfiguration();
this.context.refresh();
LocalContainerEntityManagerFactoryBean bean = this.context
.getBean(LocalContainerEntityManagerFactoryBean.class);
String actual = (String) bean.getJpaPropertyMap().get(
"hibernate.ejb.naming_strategy");
assertThat(actual, equalTo("org.hibernate.cfg.EJB3NamingStrategy"));
}
@Test
public void testCustomNamingStrategyViaJpaProperties() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context,
......
......@@ -21,7 +21,6 @@ import java.util.List;
import org.junit.After;
import org.junit.Test;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.boot.autoconfigure.gson.GsonAutoConfiguration;
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
import org.springframework.boot.test.EnvironmentTestUtils;
......@@ -38,7 +37,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
/**
......@@ -189,29 +187,6 @@ public class HttpMessageConvertersAutoConfigurationTests {
assertConverterBeanRegisteredWithHttpMessageConverters(StringHttpMessageConverter.class);
}
@Test
public void httpMapperPropertiesAreNotAppliedWhenNotConfigured() throws Exception {
this.context.register(JacksonObjectMapperConfig.class,
HttpMessageConvertersAutoConfiguration.class);
this.context.refresh();
MappingJackson2HttpMessageConverter converter = this.context
.getBean(MappingJackson2HttpMessageConverter.class);
assertNull(new DirectFieldAccessor(converter).getPropertyValue("prettyPrint"));
}
@Test
public void httpMapperPropertiesAreAppliedWhenConfigured() throws Exception {
this.context.register(JacksonObjectMapperConfig.class,
HttpMessageConvertersAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.context,
"http.mappers.jsonPrettyPrint:true");
this.context.refresh();
MappingJackson2HttpMessageConverter converter = this.context
.getBean(MappingJackson2HttpMessageConverter.class);
assertTrue((Boolean) new DirectFieldAccessor(converter)
.getPropertyValue("prettyPrint"));
}
private void assertConverterBeanExists(Class<?> type, String beanName) {
assertEquals(1, this.context.getBeansOfType(type).size());
List<String> beanNames = Arrays.asList(this.context.getBeanDefinitionNames());
......
......@@ -44,14 +44,10 @@ public class JmsCompilerAutoConfiguration extends CompilerAutoConfiguration {
}
@Override
@SuppressWarnings("deprecation")
public void applyImports(ImportCustomizer imports) throws CompilationFailedException {
imports.addStarImports("javax.jms", "org.springframework.jms.annotation",
"org.springframework.jms.config", "org.springframework.jms.core",
"org.springframework.jms.listener",
"org.springframework.jms.listener.adapter").addImports(
org.springframework.boot.groovy.EnableJmsMessaging.class
.getCanonicalName());
"org.springframework.jms.listener.adapter");
}
}
......@@ -45,7 +45,6 @@ public class RabbitCompilerAutoConfiguration extends CompilerAutoConfiguration {
}
@Override
@SuppressWarnings("deprecation")
public void applyImports(ImportCustomizer imports) throws CompilationFailedException {
imports.addStarImports("org.springframework.amqp.rabbit.annotation",
"org.springframework.amqp.rabbit.core",
......@@ -53,8 +52,6 @@ public class RabbitCompilerAutoConfiguration extends CompilerAutoConfiguration {
"org.springframework.amqp.rabbit.connection",
"org.springframework.amqp.rabbit.listener",
"org.springframework.amqp.rabbit.listener.adapter",
"org.springframework.amqp.core").addImports(
org.springframework.boot.groovy.EnableRabbitMessaging.class.getName());
"org.springframework.amqp.core");
}
}
/*
* Copyright 2012-2014 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.boot.groovy;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.springframework.boot.cli.compiler.autoconfigure.JmsCompilerAutoConfiguration;
/**
* Pseudo annotation used to trigger {@link JmsCompilerAutoConfiguration}.
*
* @deprecated since 1.2.0 in favor of {@code EnableJms}
*/
@Target(ElementType.TYPE)
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Deprecated
public @interface EnableJmsMessaging {
}
/*
* Copyright 2012-2014 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.boot.groovy;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.springframework.boot.cli.compiler.autoconfigure.RabbitCompilerAutoConfiguration;
/**
* Pseudo annotation used to trigger {@link RabbitCompilerAutoConfiguration}.
*
* @deprecated since 1.2.0 in favor of {@code EnableRabbit}
*/
@Target(ElementType.TYPE)
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Deprecated
public @interface EnableRabbitMessaging {
}
......@@ -469,7 +469,6 @@ public class SpringApplication {
* not exist or cannot be printed, a simple default is created.
* @param environment the environment
* @see #setShowBanner(boolean)
* @see #printBanner()
*/
protected void printBanner(Environment environment) {
String location = environment.getProperty("banner.location", "banner.txt");
......@@ -485,18 +484,10 @@ public class SpringApplication {
this.banner.printBanner(environment, this.mainApplicationClass, System.out);
return;
}
printBanner();
printDefaultBanner();
}
/**
* Print a simple banner message to the console. Subclasses can override this method
* to provide additional or alternative banners.
* @see #setShowBanner(boolean)
* @see #printBanner(Environment)
* @deprecated since 1.2.0 in favor of {@link #setBanner(Banner)}
*/
@Deprecated
protected void printBanner() {
private void printDefaultBanner() {
DEFAULT_BANNER.printBanner(null, this.mainApplicationClass, System.out);
}
......@@ -759,7 +750,7 @@ public class SpringApplication {
* Sets if the Spring banner should be displayed when the application runs. Defaults
* to {@code true}.
* @param showBanner if the banner should be shown
* @see #printBanner()
* @see #printDefaultBanner()
*/
public void setShowBanner(boolean showBanner) {
this.showBanner = showBanner;
......
......@@ -18,7 +18,6 @@ package org.springframework.boot.context.embedded.jetty;
import javax.servlet.ServletException;
import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.util.component.AbstractLifeCycle;
import org.eclipse.jetty.webapp.AbstractConfiguration;
import org.eclipse.jetty.webapp.Configuration;
......@@ -36,19 +35,6 @@ public class ServletContextInitializerConfiguration extends AbstractConfiguratio
private final ServletContextInitializer[] initializers;
/**
* Create a new {@link ServletContextInitializerConfiguration}.
* @param contextHandler the Jetty ContextHandler
* @param initializers the initializers that should be invoked
* @deprecated since 1.2.1 in favor of
* {@link #ServletContextInitializerConfiguration(ServletContextInitializer...)}
*/
@Deprecated
public ServletContextInitializerConfiguration(ContextHandler contextHandler,
ServletContextInitializer... initializers) {
this(initializers);
}
/**
* Create a new {@link ServletContextInitializerConfiguration}.
* @param initializers the initializers that should be invoked
......
/*
* Copyright 2012-2014 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.boot.json;
/**
* Really basic JSON parser for when you have nothing else available. Comes with some
* limitations with respect to the JSON specification (e.g. only supports String values),
* so users will probably prefer to have a library handle things instead (Jackson or Snake
* YAML are supported).
*
* @author Dave Syer
* @see JsonParserFactory
* @deprecated since 1.2.0 in favor of {@link BasicJsonParser}.
*/
@Deprecated
public class SimpleJsonParser extends BasicJsonParser {
}
/*
* Copyright 2012-2014 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.boot.orm.jpa;
import org.hibernate.cfg.NamingStrategy;
/**
* Hibernate {@link NamingStrategy} that follows Spring recommended naming conventions.
*
* @author Phillip Webb
* @deprecated Since 1.2.0 in favor of
* {@link org.springframework.boot.orm.jpa.hibernate.SpringNamingStrategy}
*/
@Deprecated
@SuppressWarnings("serial")
public class SpringNamingStrategy extends
org.springframework.boot.orm.jpa.hibernate.SpringNamingStrategy {
}
......@@ -39,6 +39,7 @@ import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEven
import org.springframework.boot.context.event.ApplicationPreparedEvent;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.boot.context.event.ApplicationStartedEvent;
import org.springframework.boot.test.OutputCapture;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ApplicationContextInitializer;
......@@ -99,6 +100,9 @@ public class SpringApplicationTests {
@Rule
public ExpectedException thrown = ExpectedException.none();
@Rule
public OutputCapture output = new OutputCapture();
private ConfigurableApplicationContext context;
private Environment getEnvironment() {
......@@ -171,22 +175,20 @@ public class SpringApplicationTests {
}
@Test
@SuppressWarnings("deprecation")
public void customBanner() throws Exception {
SpringApplication application = spy(new SpringApplication(ExampleConfig.class));
application.setWebEnvironment(false);
application.run("--banner.location=classpath:test-banner.txt");
verify(application, never()).printBanner();
assertThat(this.output.toString(), startsWith("Running a Test!"));
}
@Test
@SuppressWarnings("deprecation")
public void customBannerWithProperties() throws Exception {
SpringApplication application = spy(new SpringApplication(ExampleConfig.class));
application.setWebEnvironment(false);
application.run("--banner.location=classpath:test-banner-with-placeholder.txt",
"--test.property=123456");
verify(application, never()).printBanner();
assertThat(this.output.toString(), startsWith("Running a Test!\n\n123456"));
}
@Test
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment