Polish tests

See gh-20318
pull/20354/head
Johnny Lim 5 years ago committed by Stephane Nicoll
parent 296a13a479
commit 98738d22f4

@ -18,7 +18,6 @@ package org.springframework.boot.build.mavenplugin;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -46,7 +45,7 @@ public class PluginXmlParserTests {
assertThat(plugin.getVersion()).isEqualTo("2.2.0.GRADLE-SNAPSHOT"); assertThat(plugin.getVersion()).isEqualTo("2.2.0.GRADLE-SNAPSHOT");
assertThat(plugin.getGoalPrefix()).isEqualTo("spring-boot"); assertThat(plugin.getGoalPrefix()).isEqualTo("spring-boot");
assertThat(plugin.getMojos().stream().map(PluginXmlParser.Mojo::getGoal).collect(Collectors.toList())) assertThat(plugin.getMojos().stream().map(PluginXmlParser.Mojo::getGoal).collect(Collectors.toList()))
.isEqualTo(Arrays.<String>asList("build-info", "help", "repackage", "run", "start", "stop")); .containsExactly("build-info", "help", "repackage", "run", "start", "stop");
} }
@Test @Test

@ -154,6 +154,7 @@ class DataSourceAutoConfigurationTests {
@Test @Test
void dataSourceWhenNoConnectionPoolsAreAvailableWithUrlDoesNotCreateDataSource() { void dataSourceWhenNoConnectionPoolsAreAvailableWithUrlDoesNotCreateDataSource() {
this.contextRunner.with(hideConnectionPools()) this.contextRunner.with(hideConnectionPools())
.withPropertyValues("spring.datasource.url:jdbc:hsqldb:mem:testdb")
.run((context) -> assertThat(context).doesNotHaveBean(DataSource.class)); .run((context) -> assertThat(context).doesNotHaveBean(DataSource.class));
} }
@ -210,8 +211,8 @@ class DataSourceAutoConfigurationTests {
} }
private static Function<ApplicationContextRunner, ApplicationContextRunner> hideConnectionPools() { private static Function<ApplicationContextRunner, ApplicationContextRunner> hideConnectionPools() {
return (runner) -> runner.withClassLoader(new FilteredClassLoader("org.apache.tomcat", "com.zaxxer.hikari", return (runner) -> runner.withClassLoader(
"org.apache.commons.dbcp", "org.apache.commons.dbcp2")); new FilteredClassLoader("org.apache.tomcat", "com.zaxxer.hikari", "org.apache.commons.dbcp2"));
} }
private <T extends DataSource> void assertDataSource(Class<T> expectedType, List<String> hiddenPackages, private <T extends DataSource> void assertDataSource(Class<T> expectedType, List<String> hiddenPackages,

Loading…
Cancel
Save