Polish
This commit is contained in:
parent
56d820a8d4
commit
f0693989f1
|
|
@ -64,7 +64,7 @@ public class SessionsEndpointAutoConfigurationTests {
|
||||||
static class SessionConfiguration {
|
static class SessionConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public FindByIndexNameSessionRepository sessionRepository() {
|
public FindByIndexNameSessionRepository<?> sessionRepository() {
|
||||||
return mock(FindByIndexNameSessionRepository.class);
|
return mock(FindByIndexNameSessionRepository.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ public class SessionsEndpoint {
|
||||||
|
|
||||||
public SessionsReport(Map<String, ? extends Session> sessions) {
|
public SessionsReport(Map<String, ? extends Session> sessions) {
|
||||||
this.sessions = sessions.entrySet().stream()
|
this.sessions = sessions.entrySet().stream()
|
||||||
.map(s -> new SessionDescriptor(s.getValue()))
|
.map((s) -> new SessionDescriptor(s.getValue()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,10 +40,10 @@ public class SessionsEndpointTests {
|
||||||
|
|
||||||
private static final Session session = new MapSession();
|
private static final Session session = new MapSession();
|
||||||
|
|
||||||
private final FindByIndexNameSessionRepository repository = mock(
|
@SuppressWarnings("unchecked")
|
||||||
|
private final FindByIndexNameSessionRepository<Session> repository = mock(
|
||||||
FindByIndexNameSessionRepository.class);
|
FindByIndexNameSessionRepository.class);
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private final SessionsEndpoint endpoint = new SessionsEndpoint(this.repository);
|
private final SessionsEndpoint endpoint = new SessionsEndpoint(this.repository);
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,8 @@ public class SessionsEndpointWebIntegrationTests {
|
||||||
|
|
||||||
private static final Session session = new MapSession();
|
private static final Session session = new MapSession();
|
||||||
|
|
||||||
private static final FindByIndexNameSessionRepository repository = mock(
|
@SuppressWarnings("unchecked")
|
||||||
|
private static final FindByIndexNameSessionRepository<Session> repository = mock(
|
||||||
FindByIndexNameSessionRepository.class);
|
FindByIndexNameSessionRepository.class);
|
||||||
|
|
||||||
private static WebTestClient client;
|
private static WebTestClient client;
|
||||||
|
|
@ -59,7 +60,7 @@ public class SessionsEndpointWebIntegrationTests {
|
||||||
public void sessionsForUsernameNoResults() throws Exception {
|
public void sessionsForUsernameNoResults() throws Exception {
|
||||||
given(repository.findByIndexNameAndIndexValue(
|
given(repository.findByIndexNameAndIndexValue(
|
||||||
FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, "user"))
|
FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, "user"))
|
||||||
.willReturn(Collections.emptyMap());
|
.willReturn(Collections.emptyMap());
|
||||||
client.get()
|
client.get()
|
||||||
.uri((builder) -> builder.path("/application/sessions")
|
.uri((builder) -> builder.path("/application/sessions")
|
||||||
.queryParam("username", "user").build())
|
.queryParam("username", "user").build())
|
||||||
|
|
@ -83,7 +84,6 @@ public class SessionsEndpointWebIntegrationTests {
|
||||||
protected static class TestConfiguration {
|
protected static class TestConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public SessionsEndpoint sessionsEndpoint() {
|
public SessionsEndpoint sessionsEndpoint() {
|
||||||
return new SessionsEndpoint(repository);
|
return new SessionsEndpoint(repository);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -67,12 +67,12 @@ class JsonbHttpMessageConvertersConfiguration {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ConditionalOnMissingBean({ MappingJackson2HttpMessageConverter.class, GsonHttpMessageConverter.class })
|
@ConditionalOnMissingBean({ MappingJackson2HttpMessageConverter.class,
|
||||||
|
GsonHttpMessageConverter.class })
|
||||||
static class JacksonAndGsonMissing {
|
static class JacksonAndGsonMissing {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,15 +61,17 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
public class HttpMessageConvertersAutoConfigurationTests {
|
public class HttpMessageConvertersAutoConfigurationTests {
|
||||||
|
|
||||||
private ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
private ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||||
.withConfiguration(AutoConfigurations.of(
|
.withConfiguration(
|
||||||
HttpMessageConvertersAutoConfiguration.class));
|
AutoConfigurations.of(HttpMessageConvertersAutoConfiguration.class));
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void jacksonNotAvailable() {
|
public void jacksonNotAvailable() {
|
||||||
this.contextRunner.run((context) -> {
|
this.contextRunner.run((context) -> {
|
||||||
assertThat(context).doesNotHaveBean(ObjectMapper.class);
|
assertThat(context).doesNotHaveBean(ObjectMapper.class);
|
||||||
assertThat(context).doesNotHaveBean(MappingJackson2HttpMessageConverter.class);
|
assertThat(context)
|
||||||
assertThat(context).doesNotHaveBean(MappingJackson2XmlHttpMessageConverter.class);
|
.doesNotHaveBean(MappingJackson2HttpMessageConverter.class);
|
||||||
|
assertThat(context)
|
||||||
|
.doesNotHaveBean(MappingJackson2XmlHttpMessageConverter.class);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -96,10 +98,11 @@ public class HttpMessageConvertersAutoConfigurationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void jacksonCustomConverter() {
|
public void jacksonCustomConverter() {
|
||||||
this.contextRunner.withUserConfiguration(JacksonObjectMapperConfig.class,
|
this.contextRunner
|
||||||
JacksonConverterConfig.class
|
.withUserConfiguration(JacksonObjectMapperConfig.class,
|
||||||
).run(assertConverter(MappingJackson2HttpMessageConverter.class,
|
JacksonConverterConfig.class)
|
||||||
"customJacksonMessageConverter"));
|
.run(assertConverter(MappingJackson2HttpMessageConverter.class,
|
||||||
|
"customJacksonMessageConverter"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -112,10 +115,10 @@ public class HttpMessageConvertersAutoConfigurationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void gsonDefaultConverter() {
|
public void gsonDefaultConverter() {
|
||||||
this.contextRunner.withConfiguration(AutoConfigurations.of(
|
this.contextRunner
|
||||||
GsonAutoConfiguration.class)
|
.withConfiguration(AutoConfigurations.of(GsonAutoConfiguration.class))
|
||||||
).run(assertConverter(GsonHttpMessageConverter.class,
|
.run(assertConverter(GsonHttpMessageConverter.class,
|
||||||
"gsonHttpMessageConverter"));
|
"gsonHttpMessageConverter"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -128,15 +131,17 @@ public class HttpMessageConvertersAutoConfigurationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void gsonCanBePreferred() {
|
public void gsonCanBePreferred() {
|
||||||
allOptionsRunner().withPropertyValues(
|
allOptionsRunner()
|
||||||
"spring.http.converters.preferred-json-mapper:gson").run((context) -> {
|
.withPropertyValues("spring.http.converters.preferred-json-mapper:gson")
|
||||||
assertConverterBeanExists(context, GsonHttpMessageConverter.class,
|
.run((context) -> {
|
||||||
"gsonHttpMessageConverter");
|
assertConverterBeanExists(context, GsonHttpMessageConverter.class,
|
||||||
assertConverterBeanRegisteredWithHttpMessageConverters(context,
|
"gsonHttpMessageConverter");
|
||||||
GsonHttpMessageConverter.class);
|
assertConverterBeanRegisteredWithHttpMessageConverters(context,
|
||||||
assertThat(context).doesNotHaveBean(JsonbHttpMessageConverter.class);
|
GsonHttpMessageConverter.class);
|
||||||
assertThat(context).doesNotHaveBean(MappingJackson2HttpMessageConverter.class);
|
assertThat(context).doesNotHaveBean(JsonbHttpMessageConverter.class);
|
||||||
});
|
assertThat(context)
|
||||||
|
.doesNotHaveBean(MappingJackson2HttpMessageConverter.class);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -149,10 +154,10 @@ public class HttpMessageConvertersAutoConfigurationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void jsonbDefaultConverter() {
|
public void jsonbDefaultConverter() {
|
||||||
this.contextRunner.withConfiguration(AutoConfigurations.of(
|
this.contextRunner
|
||||||
JsonbAutoConfiguration.class)
|
.withConfiguration(AutoConfigurations.of(JsonbAutoConfiguration.class))
|
||||||
).run(assertConverter(JsonbHttpMessageConverter.class,
|
.run(assertConverter(JsonbHttpMessageConverter.class,
|
||||||
"jsonbHttpMessageConverter"));
|
"jsonbHttpMessageConverter"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -165,15 +170,17 @@ public class HttpMessageConvertersAutoConfigurationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void jsonbCanBePreferred() {
|
public void jsonbCanBePreferred() {
|
||||||
allOptionsRunner().withPropertyValues(
|
allOptionsRunner()
|
||||||
"spring.http.converters.preferred-json-mapper:jsonb").run((context) -> {
|
.withPropertyValues("spring.http.converters.preferred-json-mapper:jsonb")
|
||||||
assertConverterBeanExists(context, JsonbHttpMessageConverter.class,
|
.run((context) -> {
|
||||||
"jsonbHttpMessageConverter");
|
assertConverterBeanExists(context, JsonbHttpMessageConverter.class,
|
||||||
assertConverterBeanRegisteredWithHttpMessageConverters(context,
|
"jsonbHttpMessageConverter");
|
||||||
JsonbHttpMessageConverter.class);
|
assertConverterBeanRegisteredWithHttpMessageConverters(context,
|
||||||
assertThat(context).doesNotHaveBean(GsonHttpMessageConverter.class);
|
JsonbHttpMessageConverter.class);
|
||||||
assertThat(context).doesNotHaveBean(MappingJackson2HttpMessageConverter.class);
|
assertThat(context).doesNotHaveBean(GsonHttpMessageConverter.class);
|
||||||
});
|
assertThat(context)
|
||||||
|
.doesNotHaveBean(MappingJackson2HttpMessageConverter.class);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -193,22 +200,26 @@ public class HttpMessageConvertersAutoConfigurationTests {
|
||||||
public void typeConstrainedConverterDoesNotPreventAutoConfigurationOfJacksonConverter() {
|
public void typeConstrainedConverterDoesNotPreventAutoConfigurationOfJacksonConverter() {
|
||||||
this.contextRunner.withUserConfiguration(JacksonObjectMapperBuilderConfig.class,
|
this.contextRunner.withUserConfiguration(JacksonObjectMapperBuilderConfig.class,
|
||||||
TypeConstrainedConverterConfiguration.class).run((context) -> {
|
TypeConstrainedConverterConfiguration.class).run((context) -> {
|
||||||
BeanDefinition beanDefinition = ((GenericApplicationContext) context.getSourceApplicationContext())
|
BeanDefinition beanDefinition = ((GenericApplicationContext) context
|
||||||
.getBeanDefinition("mappingJackson2HttpMessageConverter");
|
.getSourceApplicationContext()).getBeanDefinition(
|
||||||
assertThat(beanDefinition.getFactoryBeanName()).isEqualTo(
|
"mappingJackson2HttpMessageConverter");
|
||||||
MappingJackson2HttpMessageConverterConfiguration.class.getName());
|
assertThat(beanDefinition.getFactoryBeanName()).isEqualTo(
|
||||||
});
|
MappingJackson2HttpMessageConverterConfiguration.class
|
||||||
|
.getName());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void typeConstrainedConverterFromSpringDataDoesNotPreventAutoConfigurationOfJacksonConverter() {
|
public void typeConstrainedConverterFromSpringDataDoesNotPreventAutoConfigurationOfJacksonConverter() {
|
||||||
this.contextRunner.withUserConfiguration(JacksonObjectMapperBuilderConfig.class,
|
this.contextRunner.withUserConfiguration(JacksonObjectMapperBuilderConfig.class,
|
||||||
RepositoryRestMvcConfiguration.class).run((context) -> {
|
RepositoryRestMvcConfiguration.class).run((context) -> {
|
||||||
BeanDefinition beanDefinition = ((GenericApplicationContext) context.getSourceApplicationContext())
|
BeanDefinition beanDefinition = ((GenericApplicationContext) context
|
||||||
.getBeanDefinition("mappingJackson2HttpMessageConverter");
|
.getSourceApplicationContext()).getBeanDefinition(
|
||||||
assertThat(beanDefinition.getFactoryBeanName()).isEqualTo(
|
"mappingJackson2HttpMessageConverter");
|
||||||
MappingJackson2HttpMessageConverterConfiguration.class.getName());
|
assertThat(beanDefinition.getFactoryBeanName()).isEqualTo(
|
||||||
});
|
MappingJackson2HttpMessageConverterConfiguration.class
|
||||||
|
.getName());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -225,13 +236,13 @@ public class HttpMessageConvertersAutoConfigurationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void gsonIsPreferredIfJacksonIsNotAvailable() {
|
public void gsonIsPreferredIfJacksonIsNotAvailable() {
|
||||||
allOptionsRunner()
|
allOptionsRunner().withClassLoader(
|
||||||
.withClassLoader(new HidePackagesClassLoader(
|
new HidePackagesClassLoader(ObjectMapper.class.getPackage().getName()))
|
||||||
ObjectMapper.class.getPackage().getName())).run((context) -> {
|
.run((context) -> {
|
||||||
assertConverterBeanExists(context, GsonHttpMessageConverter.class,
|
assertConverterBeanExists(context, GsonHttpMessageConverter.class,
|
||||||
"gsonHttpMessageConverter");
|
"gsonHttpMessageConverter");
|
||||||
assertThat(context).doesNotHaveBean(JsonbHttpMessageConverter.class);
|
assertThat(context).doesNotHaveBean(JsonbHttpMessageConverter.class);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -245,17 +256,17 @@ public class HttpMessageConvertersAutoConfigurationTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
private ApplicationContextRunner allOptionsRunner() {
|
private ApplicationContextRunner allOptionsRunner() {
|
||||||
return this.contextRunner.withConfiguration(AutoConfigurations.of(
|
return this.contextRunner
|
||||||
GsonAutoConfiguration.class, JacksonAutoConfiguration.class,
|
.withConfiguration(AutoConfigurations.of(GsonAutoConfiguration.class,
|
||||||
JsonbAutoConfiguration.class));
|
JacksonAutoConfiguration.class, JsonbAutoConfiguration.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private ContextConsumer<AssertableApplicationContext> assertConverter(
|
private ContextConsumer<AssertableApplicationContext> assertConverter(
|
||||||
Class<? extends HttpMessageConverter> converterType, String beanName) {
|
Class<? extends HttpMessageConverter<?>> converterType, String beanName) {
|
||||||
return context -> {
|
return (context) -> {
|
||||||
assertConverterBeanExists(context, converterType, beanName);
|
assertConverterBeanExists(context, converterType, beanName);
|
||||||
assertConverterBeanRegisteredWithHttpMessageConverters(context, converterType);
|
assertConverterBeanRegisteredWithHttpMessageConverters(context,
|
||||||
|
converterType);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -266,8 +277,9 @@ public class HttpMessageConvertersAutoConfigurationTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertConverterBeanRegisteredWithHttpMessageConverters(
|
private void assertConverterBeanRegisteredWithHttpMessageConverters(
|
||||||
AssertableApplicationContext context, Class<? extends HttpMessageConverter> type) {
|
AssertableApplicationContext context,
|
||||||
HttpMessageConverter converter = context.getBean(type);
|
Class<? extends HttpMessageConverter<?>> type) {
|
||||||
|
HttpMessageConverter<?> converter = context.getBean(type);
|
||||||
HttpMessageConverters converters = context.getBean(HttpMessageConverters.class);
|
HttpMessageConverters converters = context.getBean(HttpMessageConverters.class);
|
||||||
assertThat(converters.getConverters()).contains(converter);
|
assertThat(converters.getConverters()).contains(converter);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,8 +47,8 @@ import org.springframework.test.context.BootstrapWith;
|
||||||
* <p>
|
* <p>
|
||||||
* By default, tests annotated with {@code JsonTest} will also initialize
|
* By default, tests annotated with {@code JsonTest} will also initialize
|
||||||
* {@link JacksonTester}, {@link JsonbTester} and {@link GsonTester} fields. More
|
* {@link JacksonTester}, {@link JsonbTester} and {@link GsonTester} fields. More
|
||||||
* fine-grained control can be provided via the {@link AutoConfigureJsonTesters @AutoConfigureJsonTesters}
|
* fine-grained control can be provided via the
|
||||||
* annotation.
|
* {@link AutoConfigureJsonTesters @AutoConfigureJsonTesters} annotation.
|
||||||
*
|
*
|
||||||
* @author Phillip Webb
|
* @author Phillip Webb
|
||||||
* @see AutoConfigureJson
|
* @see AutoConfigureJson
|
||||||
|
|
|
||||||
|
|
@ -370,7 +370,7 @@ public class ApplicationContextAssert<C extends ApplicationContext>
|
||||||
|
|
||||||
private ContextFailedToStart<C> contextFailedToStartWhenExpecting(
|
private ContextFailedToStart<C> contextFailedToStartWhenExpecting(
|
||||||
String expectationFormat, Object... arguments) {
|
String expectationFormat, Object... arguments) {
|
||||||
return new ContextFailedToStart<C>(getApplicationContext(), this.startupFailure,
|
return new ContextFailedToStart<>(getApplicationContext(), this.startupFailure,
|
||||||
expectationFormat, arguments);
|
expectationFormat, arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,12 +39,13 @@ class CollectionBinder extends IndexedElementsBinder<Collection<Object>> {
|
||||||
protected Object bind(ConfigurationPropertyName name, Bindable<?> target,
|
protected Object bind(ConfigurationPropertyName name, Bindable<?> target,
|
||||||
AggregateElementBinder elementBinder, Class<?> type) {
|
AggregateElementBinder elementBinder, Class<?> type) {
|
||||||
Class<?> collectionType = (type != null ? type
|
Class<?> collectionType = (type != null ? type
|
||||||
: ResolvableType.forClassWithGenerics(List.class, Object.class).resolve());
|
: ResolvableType.forClassWithGenerics(List.class, Object.class)
|
||||||
|
.resolve());
|
||||||
IndexedCollectionSupplier collection = new IndexedCollectionSupplier(
|
IndexedCollectionSupplier collection = new IndexedCollectionSupplier(
|
||||||
() -> CollectionFactory.createCollection(collectionType, 0));
|
() -> CollectionFactory.createCollection(collectionType, 0));
|
||||||
ResolvableType elementType = target.getType().asCollection().getGeneric();
|
ResolvableType elementType = target.getType().asCollection().getGeneric();
|
||||||
bindIndexed(name, target, elementBinder, collection, ResolvableType.forClass(collectionType),
|
bindIndexed(name, target, elementBinder, collection,
|
||||||
elementType);
|
ResolvableType.forClass(collectionType), elementType);
|
||||||
if (collection.wasSupplied()) {
|
if (collection.wasSupplied()) {
|
||||||
return collection.get();
|
return collection.get();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,9 @@ class MapBinder extends AggregateBinder<Map<Object, Object>> {
|
||||||
protected Object bind(ConfigurationPropertyName name, Bindable<?> target,
|
protected Object bind(ConfigurationPropertyName name, Bindable<?> target,
|
||||||
AggregateElementBinder elementBinder, Class<?> type) {
|
AggregateElementBinder elementBinder, Class<?> type) {
|
||||||
Class<?> mapType = (type != null ? type
|
Class<?> mapType = (type != null ? type
|
||||||
: ResolvableType.forClassWithGenerics(Map.class, Object.class, Object.class).resolve());
|
: ResolvableType
|
||||||
|
.forClassWithGenerics(Map.class, Object.class, Object.class)
|
||||||
|
.resolve());
|
||||||
Map<Object, Object> map = CollectionFactory.createMap(mapType, 0);
|
Map<Object, Object> map = CollectionFactory.createMap(mapType, 0);
|
||||||
Bindable<?> resolvedTarget = resolveTarget(target);
|
Bindable<?> resolvedTarget = resolveTarget(target);
|
||||||
for (ConfigurationPropertySource source : getContext().getSources()) {
|
for (ConfigurationPropertySource source : getContext().getSources()) {
|
||||||
|
|
|
||||||
|
|
@ -58,11 +58,11 @@ public final class DataSourceBuilder<T extends DataSource> {
|
||||||
private Map<String, String> properties = new HashMap<>();
|
private Map<String, String> properties = new HashMap<>();
|
||||||
|
|
||||||
public static DataSourceBuilder<?> create() {
|
public static DataSourceBuilder<?> create() {
|
||||||
return new DataSourceBuilder<DataSource>(null);
|
return new DataSourceBuilder<>(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DataSourceBuilder<?> create(ClassLoader classLoader) {
|
public static DataSourceBuilder<?> create(ClassLoader classLoader) {
|
||||||
return new DataSourceBuilder<DataSource>(classLoader);
|
return new DataSourceBuilder<>(classLoader);
|
||||||
}
|
}
|
||||||
|
|
||||||
private DataSourceBuilder(ClassLoader classLoader) {
|
private DataSourceBuilder(ClassLoader classLoader) {
|
||||||
|
|
|
||||||
|
|
@ -199,13 +199,15 @@ public class BinderTests {
|
||||||
@Test
|
@Test
|
||||||
public void bindWhenHasMalformedDateShouldThrowException() throws Exception {
|
public void bindWhenHasMalformedDateShouldThrowException() throws Exception {
|
||||||
this.thrown.expectCause(instanceOf(ConversionFailedException.class));
|
this.thrown.expectCause(instanceOf(ConversionFailedException.class));
|
||||||
this.sources.add(new MockConfigurationPropertySource("foo", "2014-04-01T01:30:00.000-05:00"));
|
this.sources.add(new MockConfigurationPropertySource("foo",
|
||||||
|
"2014-04-01T01:30:00.000-05:00"));
|
||||||
this.binder.bind("foo", Bindable.of(LocalDate.class));
|
this.binder.bind("foo", Bindable.of(LocalDate.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void bindWhenHasAnnotationsShouldChangeConvertedValue() throws Exception {
|
public void bindWhenHasAnnotationsShouldChangeConvertedValue() throws Exception {
|
||||||
this.sources.add(new MockConfigurationPropertySource("foo", "2014-04-01T01:30:00.000-05:00"));
|
this.sources.add(new MockConfigurationPropertySource("foo",
|
||||||
|
"2014-04-01T01:30:00.000-05:00"));
|
||||||
DateTimeFormat annotation = AnnotationUtils.synthesizeAnnotation(
|
DateTimeFormat annotation = AnnotationUtils.synthesizeAnnotation(
|
||||||
Collections.singletonMap("iso", DateTimeFormat.ISO.DATE_TIME),
|
Collections.singletonMap("iso", DateTimeFormat.ISO.DATE_TIME),
|
||||||
DateTimeFormat.class, null);
|
DateTimeFormat.class, null);
|
||||||
|
|
|
||||||
|
|
@ -322,8 +322,7 @@ public class CollectionBinderTests {
|
||||||
MockConfigurationPropertySource source = new MockConfigurationPropertySource();
|
MockConfigurationPropertySource source = new MockConfigurationPropertySource();
|
||||||
source.put("foo.items", "a,b,c,c");
|
source.put("foo.items", "a,b,c,c");
|
||||||
this.sources.add(source);
|
this.sources.add(source);
|
||||||
ExampleCustomBean result = this.binder
|
ExampleCustomBean result = this.binder.bind("foo", ExampleCustomBean.class).get();
|
||||||
.bind("foo", ExampleCustomBean.class).get();
|
|
||||||
assertThat(result.getItems()).hasSize(4);
|
assertThat(result.getItems()).hasSize(4);
|
||||||
assertThat(result.getItems()).containsExactly("a", "b", "c", "c");
|
assertThat(result.getItems()).containsExactly("a", "b", "c", "c");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -73,8 +73,8 @@ public class DataSourceBuilderTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void specificTypeOfDataSource() {
|
public void specificTypeOfDataSource() {
|
||||||
HikariDataSource hikariDataSource = DataSourceBuilder.create().type(HikariDataSource.class)
|
HikariDataSource hikariDataSource = DataSourceBuilder.create()
|
||||||
.build();
|
.type(HikariDataSource.class).build();
|
||||||
assertThat(hikariDataSource).isInstanceOf(HikariDataSource.class);
|
assertThat(hikariDataSource).isInstanceOf(HikariDataSource.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue