Skip to content

Commit

Permalink
Merge branch '1.5.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
philwebb committed Oct 12, 2016
2 parents 264d844 + d818a09 commit 01900c8
Show file tree
Hide file tree
Showing 25 changed files with 130 additions and 118 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,13 @@ public Report(ConditionEvaluationReport report) {
add(this.negativeMatches, entry.getKey(), entry.getValue());
}
}
this.parent = report.getParent() != null ? new Report(report.getParent())
: null;
boolean hasParent = report.getParent() != null;
this.parent = (hasParent ? new Report(report.getParent()) : null);
}

private void add(Map<String, MessageAndConditions> map, String source,
ConditionAndOutcomes conditionAndOutcomes) {
String name = ClassUtils.getShortName(source);

map.put(name, new MessageAndConditions(conditionAndOutcomes));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public abstract class AbstractDatabaseInitializer {

private final ResourceLoader resourceLoader;

protected AbstractDatabaseInitializer(DataSource dataSource, ResourceLoader resourceLoader) {
protected AbstractDatabaseInitializer(DataSource dataSource,
ResourceLoader resourceLoader) {
Assert.notNull(dataSource, "DataSource must not be null");
Assert.notNull(resourceLoader, "ResourceLoader must not be null");
this.dataSource = dataSource;
Expand All @@ -51,17 +52,18 @@ protected AbstractDatabaseInitializer(DataSource dataSource, ResourceLoader reso

@PostConstruct
protected void initialize() {
if (isEnabled()) {
ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
String schemaLocation = getSchemaLocation();
if (schemaLocation.contains(PLATFORM_PLACEHOLDER)) {
String platform = getDatabaseName();
schemaLocation = schemaLocation.replace(PLATFORM_PLACEHOLDER, platform);
}
populator.addScript(this.resourceLoader.getResource(schemaLocation));
populator.setContinueOnError(true);
DatabasePopulatorUtils.execute(populator, this.dataSource);
if (!isEnabled()) {
return;
}
ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
String schemaLocation = getSchemaLocation();
if (schemaLocation.contains(PLATFORM_PLACEHOLDER)) {
String platform = getDatabaseName();
schemaLocation = schemaLocation.replace(PLATFORM_PLACEHOLDER, platform);
}
populator.addScript(this.resourceLoader.getResource(schemaLocation));
populator.setContinueOnError(true);
DatabasePopulatorUtils.execute(populator, this.dataSource);
}

protected abstract boolean isEnabled();
Expand All @@ -70,11 +72,10 @@ protected void initialize() {

protected String getDatabaseName() {
try {
String databaseProductName = JdbcUtils.extractDatabaseMetaData(
this.dataSource, "getDatabaseProductName").toString();
databaseProductName = JdbcUtils.commonDatabaseName(databaseProductName);
DatabaseDriver databaseDriver = DatabaseDriver.fromProductName(
databaseProductName);
String productName = JdbcUtils.commonDatabaseName(JdbcUtils
.extractDatabaseMetaData(this.dataSource, "getDatabaseProductName")
.toString());
DatabaseDriver databaseDriver = DatabaseDriver.fromProductName(productName);
if (databaseDriver == DatabaseDriver.UNKNOWN) {
throw new IllegalStateException("Unable to detect database type");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public class BatchDatabaseInitializer extends AbstractDatabaseInitializer {

private final BatchProperties properties;

public BatchDatabaseInitializer(DataSource dataSource,
ResourceLoader resourceLoader, BatchProperties properties) {
public BatchDatabaseInitializer(DataSource dataSource, ResourceLoader resourceLoader,
BatchProperties properties) {
super(dataSource, resourceLoader);
Assert.notNull(properties, "BatchProperties must not be null");
this.properties = properties;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ public class RepositoryRestProperties {
/**
* Strategy to use to determine which repositories get exposed.
*/
private RepositoryDetectionStrategies detectionStrategy =
RepositoryDetectionStrategies.DEFAULT;
private RepositoryDetectionStrategies detectionStrategy = RepositoryDetectionStrategies.DEFAULT;

/**
* Content type to use as a default when none is specified.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
* @author Stephane Nicoll
*/
@Configuration
@ConditionalOnClass({Message.class, JmsTemplate.class})
@ConditionalOnClass({ Message.class, JmsTemplate.class })
@ConditionalOnBean(ConnectionFactory.class)
@EnableConfigurationProperties(JmsProperties.class)
@Import(JmsAnnotationDrivenConfiguration.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ public String formatConcurrency() {
public static class Template {

/**
* Default destination to use on send/receive operations that do not
* have a destination parameter.
* Default destination to use on send/receive operations that do not have a
* destination parameter.
*/
private String defaultDestination;

Expand All @@ -156,16 +156,14 @@ public static class Template {
private Integer priority;

/**
* Time-to-live of a message when sending in milliseconds. Enable
* QoS when set.
* Time-to-live of a message when sending in milliseconds. Enable QoS when set.
*/
private Long timeToLive;

/**
* Enable explicit QoS when sending a message. When enabled, the
* delivery mode, priority and time-to-live properties will be
* used when sending a message. QoS is automatically enabled when
* at least one of those settings is customized.
* Enable explicit QoS when sending a message. When enabled, the delivery mode,
* priority and time-to-live properties will be used when sending a message. QoS
* is automatically enabled when at least one of those settings is customized.
*/
private Boolean qosEnabled;

Expand Down Expand Up @@ -291,8 +289,8 @@ public enum DeliveryMode {
NON_PERSISTENT(1),

/*
* Instructs the JMS provider to log the message to stable storage as part of
* the client's send operation.
* Instructs the JMS provider to log the message to stable storage as part of the
* client's send operation.
*/
PERSISTENT(2);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -658,15 +658,15 @@ public static class Tomcat {
private Charset uriEncoding;

/**
* Maximum number of connections that the server will accept and process
* at any given time. Once the limit has been reached, the operating system
* may still accept connections based on the "acceptCount" property.
* Maximum number of connections that the server will accept and process at any
* given time. Once the limit has been reached, the operating system may still
* accept connections based on the "acceptCount" property.
*/
private int maxConnections = 0;

/**
* Maximum queue length for incoming connection requests when all possible
* request processing threads are in use.
* Maximum queue length for incoming connection requests when all possible request
* processing threads are in use.
*/
private int acceptCount = 0;

Expand Down Expand Up @@ -827,34 +827,37 @@ private void customizeAcceptCount(TomcatEmbeddedServletContainerFactory factory)
public void customize(Connector connector) {
ProtocolHandler handler = connector.getProtocolHandler();
if (handler instanceof AbstractProtocol) {
AbstractProtocol protocol = (AbstractProtocol) handler;
AbstractProtocol<?> protocol = (AbstractProtocol<?>) handler;
protocol.setBacklog(Tomcat.this.acceptCount);
}
}

});
}

private void customizeMaxConnections(TomcatEmbeddedServletContainerFactory factory) {
private void customizeMaxConnections(
TomcatEmbeddedServletContainerFactory factory) {
factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {

@Override
public void customize(Connector connector) {
ProtocolHandler handler = connector.getProtocolHandler();
if (handler instanceof AbstractProtocol) {
AbstractProtocol protocol = (AbstractProtocol) handler;
AbstractProtocol<?> protocol = (AbstractProtocol<?>) handler;
protocol.setMaxConnections(Tomcat.this.maxConnections);
}
}

});
}

private void customizeConnectionTimeout(
TomcatEmbeddedServletContainerFactory factory, int connectionTimeout) {
for (Connector connector : factory.getAdditionalTomcatConnectors()) {
if (connector.getProtocolHandler() instanceof AbstractProtocol) {
AbstractProtocol<?> handler = (AbstractProtocol<?>) connector
.getProtocolHandler();
handler.setConnectionTimeout(connectionTimeout);
ProtocolHandler handler = connector.getProtocolHandler();
if (handler instanceof AbstractProtocol) {
AbstractProtocol<?> protocol = (AbstractProtocol<?>) handler;
protocol.setConnectionTimeout(connectionTimeout);
}
}
}
Expand Down Expand Up @@ -1108,6 +1111,7 @@ private void customizeConnectionTimeout(
JettyEmbeddedServletContainerFactory factory,
final int connectionTimeout) {
factory.addServerCustomizers(new JettyServerCustomizer() {

@Override
public void customize(Server server) {
for (org.eclipse.jetty.server.Connector connector : server
Expand All @@ -1118,6 +1122,7 @@ public void customize(Server server) {
}
}
}

});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.util.Set;

import com.datastax.driver.core.Session;

import org.junit.After;
import org.junit.Test;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ private void assertBeanMethodDisabled(FailureAnalysis analysis, String descripti

private void assertClassDisabled(FailureAnalysis analysis, String description,
String methodName) {
String expected = String.format("Bean method '%s' not loaded because", methodName);
String expected = String.format("Bean method '%s' not loaded because",
methodName);
assertThat(analysis.getDescription()).contains(expected);
assertThat(analysis.getDescription()).contains(description);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,13 @@ public void defaultEmbeddedDatabase() {
@Test
public void generateUniqueName() throws Exception {
this.context = load("spring.datasource.generate-unique-name=true");
AnnotationConfigApplicationContext context2 =
load("spring.datasource.generate-unique-name=true");
AnnotationConfigApplicationContext context2 = load(
"spring.datasource.generate-unique-name=true");
try {
DataSource dataSource = this.context.getBean(DataSource.class);
DataSource dataSource2 = context2.getBean(DataSource.class);
assertThat(getDatabaseName(dataSource))
.isNotEqualTo(getDatabaseName(dataSource2));
System.out.println(dataSource2);
}
finally {
context2.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,7 @@ public void testJmsTemplateFullCustomization() {
"spring.jms.template.default-destination=testQueue",
"spring.jms.template.delivery-delay=500",
"spring.jms.template.delivery-mode=non-persistent",
"spring.jms.template.priority=6",
"spring.jms.template.time-to-live=6000",
"spring.jms.template.priority=6", "spring.jms.template.time-to-live=6000",
"spring.jms.template.receive-timeout=2000");
JmsTemplate jmsTemplate = this.context.getBean(JmsTemplate.class);
assertThat(jmsTemplate.getMessageConverter())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,9 +444,9 @@ public void customTomcatAcceptCount() {

TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory();
this.properties.customize(container);
TomcatEmbeddedServletContainer embeddedContainer =
(TomcatEmbeddedServletContainer) container.getEmbeddedServletContainer();
assertThat(((AbstractProtocol) embeddedContainer.getTomcat().getConnector()
TomcatEmbeddedServletContainer embeddedContainer = (TomcatEmbeddedServletContainer) container
.getEmbeddedServletContainer();
assertThat(((AbstractProtocol<?>) embeddedContainer.getTomcat().getConnector()
.getProtocolHandler()).getBacklog()).isEqualTo(10);
}

Expand All @@ -458,9 +458,9 @@ public void customTomcatMaxConnections() {

TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory();
this.properties.customize(container);
TomcatEmbeddedServletContainer embeddedContainer =
(TomcatEmbeddedServletContainer) container.getEmbeddedServletContainer();
assertThat(((AbstractProtocol) embeddedContainer.getTomcat().getConnector()
TomcatEmbeddedServletContainer embeddedContainer = (TomcatEmbeddedServletContainer) container
.getEmbeddedServletContainer();
assertThat(((AbstractProtocol<?>) embeddedContainer.getTomcat().getConnector()
.getProtocolHandler()).getMaxConnections()).isEqualTo(5);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ public void warCreation() throws Exception {
assertThat(invocation.getOutput()).contains("Tomcat started");
assertThat(invocation.getOutput())
.contains("/WEB-INF/lib-provided/tomcat-embed-core");
assertThat(invocation.getOutput())
.contains("WEB-INF/classes!/root.properties");
assertThat(invocation.getOutput()).contains("WEB-INF/classes!/root.properties");
process.destroy();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,9 @@ private List<Library> addClasspathEntries(JarWriter writer,
return libraries;
}

protected void writeClasspathEntry(JarWriter writer,
MatchedResource entry) throws IOException {
writer.writeEntry(entry.getName(),
new FileInputStream(entry.getFile()));
protected void writeClasspathEntry(JarWriter writer, MatchedResource entry)
throws IOException {
writer.writeEntry(entry.getName(), new FileInputStream(entry.getFile()));
}

protected abstract LibraryScope getLibraryScope(File file);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import sample.hibernate52.domain.City;
import sample.hibernate52.service.CityRepository;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
import sample.hibernate52.domain.HotelSummary;
import sample.hibernate52.domain.Rating;
import sample.hibernate52.domain.RatingCount;
import sample.hibernate52.service.CityRepository;
import sample.hibernate52.service.HotelRepository;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import sample.web.thymeleaf3.SampleWebThymeleaf3Application;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -478,8 +478,11 @@ public Object getEarlyBeanReference(Object bean, String beanName)
}

@Override
public Object postProcessBeforeInitialization(Object bean, String beanName)
public Object postProcessAfterInitialization(Object bean, String beanName)
throws BeansException {
if (bean instanceof FactoryBean) {
return bean;
}
return createSpyIfNecessary(bean, beanName);
}

Expand Down
Loading

0 comments on commit 01900c8

Please sign in to comment.