-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18104 from radcortez/fix-17892
Do not record Env values in the runtime defaults
- Loading branch information
Showing
4 changed files
with
87 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
core/test-extension/deployment/src/test/java/io/quarkus/extest/RuntimeDefaultsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package io.quarkus.extest; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
import javax.inject.Inject; | ||
|
||
import org.eclipse.microprofile.config.Config; | ||
import org.eclipse.microprofile.config.spi.ConfigSource; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class RuntimeDefaultsTest { | ||
@RegisterExtension | ||
static final QuarkusUnitTest TEST = new QuarkusUnitTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
// Don't change this to types, because of classloader class cast exception. | ||
.addAsServiceProvider("org.eclipse.microprofile.config.spi.ConfigSource", | ||
"io.quarkus.extest.runtime.config.EnvBuildTimeConfigSource") | ||
.addAsResource("application.properties")); | ||
|
||
@Inject | ||
Config config; | ||
|
||
@Test | ||
void doNotRecordEnvRuntimeDefaults() { | ||
ConfigSource defaultValues = null; | ||
for (ConfigSource configSource : config.getConfigSources()) { | ||
if (configSource.getName().contains("PropertiesConfigSource[source=Specified default values]")) { | ||
defaultValues = configSource; | ||
break; | ||
} | ||
} | ||
assertNotNull(defaultValues); | ||
|
||
assertEquals("properties", defaultValues.getValue("bt.do.not.record")); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...sion/runtime/src/main/java/io/quarkus/extest/runtime/config/EnvBuildTimeConfigSource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package io.quarkus.extest.runtime.config; | ||
|
||
import java.util.HashMap; | ||
|
||
import io.smallrye.config.EnvConfigSource; | ||
|
||
public class EnvBuildTimeConfigSource extends EnvConfigSource { | ||
public EnvBuildTimeConfigSource() { | ||
super(new HashMap<String, String>() { | ||
{ | ||
put("BT_DO_NOT_RECORD", "env-source"); | ||
} | ||
}, Integer.MAX_VALUE); | ||
} | ||
} |