Merge branch '1.3.x'

pull/6716/head
Andy Wilkinson 8 years ago
commit d4c9a2b271

@ -21,7 +21,6 @@ import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource; import javax.sql.DataSource;
import liquibase.integration.spring.SpringLiquibase; import liquibase.integration.spring.SpringLiquibase;
import liquibase.servicelocator.ServiceLocator;
import org.springframework.beans.factory.ObjectProvider; import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.AutoConfigureAfter;
@ -35,7 +34,6 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder; import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.liquibase.CommonsLoggingLiquibaseLogger;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
@ -52,6 +50,7 @@ import org.springframework.util.Assert;
* @author Dave Syer * @author Dave Syer
* @author Phillip Webb * @author Phillip Webb
* @author Eddú Meléndez * @author Eddú Meléndez
* @author Andy Wilkinson
* @since 1.1.0 * @since 1.1.0
*/ */
@Configuration @Configuration
@ -95,9 +94,6 @@ public class LiquibaseAutoConfiguration {
+ " (please add changelog or check your Liquibase " + " (please add changelog or check your Liquibase "
+ "configuration)"); + "configuration)");
} }
ServiceLocator serviceLocator = ServiceLocator.getInstance();
serviceLocator.addPackageToScan(
CommonsLoggingLiquibaseLogger.class.getPackage().getName());
} }
@Bean @Bean

@ -34,6 +34,8 @@ import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfigurati
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder; import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration; import org.springframework.boot.autoconfigure.jdbc.EmbeddedDataSourceConfiguration;
import org.springframework.boot.liquibase.CommonsLoggingLiquibaseLogger; import org.springframework.boot.liquibase.CommonsLoggingLiquibaseLogger;
import org.springframework.boot.liquibase.LiquibaseServiceLocatorApplicationListener;
import org.springframework.boot.test.rule.OutputCapture;
import org.springframework.boot.test.util.EnvironmentTestUtils; import org.springframework.boot.test.util.EnvironmentTestUtils;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
@ -48,8 +50,8 @@ import static org.assertj.core.api.Assertions.assertThat;
* Tests for {@link LiquibaseAutoConfiguration}. * Tests for {@link LiquibaseAutoConfiguration}.
* *
* @author Marcel Overdijk * @author Marcel Overdijk
* @author Andy Wilkinson
* @author Eddú Meléndez * @author Eddú Meléndez
* @author Andy Wilkinson
*/ */
public class LiquibaseAutoConfigurationTests { public class LiquibaseAutoConfigurationTests {
@ -59,12 +61,16 @@ public class LiquibaseAutoConfigurationTests {
@Rule @Rule
public TemporaryFolder temp = new TemporaryFolder(); public TemporaryFolder temp = new TemporaryFolder();
@Rule
public OutputCapture outputCapture = new OutputCapture();
private AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); private AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
@Before @Before
public void init() { public void init() {
EnvironmentTestUtils.addEnvironment(this.context, EnvironmentTestUtils.addEnvironment(this.context,
"spring.datasource.name:liquibasetest"); "spring.datasource.name:liquibasetest");
new LiquibaseServiceLocatorApplicationListener().onApplicationEvent(null);
} }
@After @After
@ -203,6 +209,7 @@ public class LiquibaseAutoConfigurationTests {
SpringLiquibase liquibase = this.context.getBean(SpringLiquibase.class); SpringLiquibase liquibase = this.context.getBean(SpringLiquibase.class);
Object log = ReflectionTestUtils.getField(liquibase, "log"); Object log = ReflectionTestUtils.getField(liquibase, "log");
assertThat(log).isInstanceOf(CommonsLoggingLiquibaseLogger.class); assertThat(log).isInstanceOf(CommonsLoggingLiquibaseLogger.class);
assertThat(this.outputCapture.toString()).doesNotContain(": liquibase:");
} }
@Test @Test

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2014 the original author or authors. * Copyright 2012-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -51,8 +51,12 @@ public class LiquibaseServiceLocatorApplicationListener
private static class LiquibasePresent { private static class LiquibasePresent {
public void replaceServiceLocator() { public void replaceServiceLocator() {
ServiceLocator.setInstance(new CustomResolverServiceLocator( CustomResolverServiceLocator customResolverServiceLocator = new CustomResolverServiceLocator(
new SpringPackageScanClassResolver(logger))); new SpringPackageScanClassResolver(logger));
customResolverServiceLocator.addPackageToScan(
CommonsLoggingLiquibaseLogger.class.getPackage().getName());
ServiceLocator.setInstance(customResolverServiceLocator);
liquibase.logging.LogFactory.reset();
} }
} }

Loading…
Cancel
Save