|
1 | 1 | /*
|
2 |
| - * Copyright 2012-2020 the original author or authors. |
| 2 | + * Copyright 2012-2021 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
@@ -57,6 +57,20 @@ void createWhenLoaderHasLogParameterInjectsLog() {
|
57 | 57 | Arrays.asList(LoggingConfigDataLoader.class.getName()));
|
58 | 58 | }
|
59 | 59 |
|
| 60 | + @Test |
| 61 | + void createWhenLoaderHasDeferredLogFactoryParameterInjectsDeferredLogFactory() { |
| 62 | + ConfigDataLoaders loaders = new ConfigDataLoaders(this.logFactory, this.bootstrapContext, |
| 63 | + Arrays.asList(DeferredLogFactoryConfigDataLoader.class.getName())); |
| 64 | + assertThat(loaders).extracting("loaders").asList() |
| 65 | + .satisfies(this::containsValidDeferredLogFactoryConfigDataLoader); |
| 66 | + } |
| 67 | + |
| 68 | + private void containsValidDeferredLogFactoryConfigDataLoader(List<?> list) { |
| 69 | + assertThat(list).hasSize(1); |
| 70 | + DeferredLogFactoryConfigDataLoader loader = (DeferredLogFactoryConfigDataLoader) list.get(0); |
| 71 | + assertThat(loader.getLogFactory()).isSameAs(this.logFactory); |
| 72 | + } |
| 73 | + |
60 | 74 | @Test
|
61 | 75 | void createWhenLoaderHasBootstrapParametersInjectsBootstrapContext() {
|
62 | 76 | new ConfigDataLoaders(this.logFactory, this.bootstrapContext,
|
@@ -144,6 +158,26 @@ public ConfigData load(ConfigDataLoaderContext context, ConfigDataResource resou
|
144 | 158 |
|
145 | 159 | }
|
146 | 160 |
|
| 161 | + static class DeferredLogFactoryConfigDataLoader implements ConfigDataLoader<ConfigDataResource> { |
| 162 | + |
| 163 | + private final DeferredLogFactory logFactory; |
| 164 | + |
| 165 | + DeferredLogFactoryConfigDataLoader(DeferredLogFactory logFactory) { |
| 166 | + assertThat(logFactory).isNotNull(); |
| 167 | + this.logFactory = logFactory; |
| 168 | + } |
| 169 | + |
| 170 | + @Override |
| 171 | + public ConfigData load(ConfigDataLoaderContext context, ConfigDataResource resource) throws IOException { |
| 172 | + throw new AssertionError("Unexpected call"); |
| 173 | + } |
| 174 | + |
| 175 | + DeferredLogFactory getLogFactory() { |
| 176 | + return this.logFactory; |
| 177 | + } |
| 178 | + |
| 179 | + } |
| 180 | + |
147 | 181 | static class BootstrappingConfigDataLoader implements ConfigDataLoader<ConfigDataResource> {
|
148 | 182 |
|
149 | 183 | BootstrappingConfigDataLoader(ConfigurableBootstrapContext configurableBootstrapContext,
|
|
0 commit comments