-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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 #15257 from radcortez/fix-15221
Ignore config_ordinal for default values source
- Loading branch information
Showing
2 changed files
with
54 additions
and
0 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
49 changes: 49 additions & 0 deletions
49
extensions/arc/deployment/src/test/java/io/quarkus/arc/test/config/ConfigDefaultValues.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,49 @@ | ||
package io.quarkus.arc.test.config; | ||
|
||
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.asset.StringAsset; | ||
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 ConfigDefaultValues { | ||
@RegisterExtension | ||
static final QuarkusUnitTest TEST = new QuarkusUnitTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addAsResource(new StringAsset("config_ordinal=1000\n" + | ||
"my.prop=1234\n"), "application.properties")); | ||
@Inject | ||
Config config; | ||
|
||
@Test | ||
void configDefaultValues() { | ||
ConfigSource defaultValues = getConfigSourceByName("PropertiesConfigSource[source=Specified default values]"); | ||
assertNotNull(defaultValues); | ||
assertEquals(Integer.MIN_VALUE + 100, defaultValues.getOrdinal()); | ||
|
||
ConfigSource applicationProperties = getConfigSourceByName("PropertiesConfigSource[source=application.properties]"); | ||
assertNotNull(applicationProperties); | ||
assertEquals(1000, applicationProperties.getOrdinal()); | ||
|
||
assertEquals("1234", defaultValues.getValue("my.prop")); | ||
assertEquals("1234", applicationProperties.getValue("my.prop")); | ||
} | ||
|
||
private ConfigSource getConfigSourceByName(String name) { | ||
for (ConfigSource configSource : config.getConfigSources()) { | ||
if (configSource.getName().contains(name)) { | ||
return configSource; | ||
} | ||
} | ||
return null; | ||
} | ||
} |