forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
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 quarkusio#16748 from stuartwdouglas/remove-system-…
…props Stop TestResourceManager using System props
- Loading branch information
Showing
20 changed files
with
269 additions
and
70 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
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
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
65 changes: 65 additions & 0 deletions
65
core/runtime/src/main/java/io/quarkus/runtime/configuration/RuntimeOverrideConfigSource.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,65 @@ | ||
package io.quarkus.runtime.configuration; | ||
|
||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
import org.eclipse.microprofile.config.spi.ConfigSource; | ||
|
||
/** | ||
* Config source that is used to handle {@code io.quarkus.bootstrap.app.StartupAction#overrideConfig(java.util.Map)} | ||
* | ||
*/ | ||
public class RuntimeOverrideConfigSource implements ConfigSource { | ||
|
||
public static final String FIELD_NAME = "CONFIG"; | ||
public static final String GENERATED_CLASS_NAME = RuntimeOverrideConfigSource.class.getName() + "$$GeneratedMapHolder"; | ||
|
||
final Map<String, String> values; | ||
|
||
public RuntimeOverrideConfigSource(ClassLoader classLoader) { | ||
try { | ||
Class<?> cls = classLoader.loadClass(GENERATED_CLASS_NAME); | ||
Map<String, String> values = (Map<String, String>) cls.getDeclaredField(FIELD_NAME).get(null); | ||
this.values = values == null ? Collections.emptyMap() : values; | ||
} catch (ClassNotFoundException | NoSuchFieldException | IllegalAccessException exception) { | ||
throw new RuntimeException(exception); | ||
} | ||
} | ||
|
||
public static void setConfig(ClassLoader runtimeClassLoader, Map<String, String> config) { | ||
try { | ||
Class<?> cls = runtimeClassLoader.loadClass(GENERATED_CLASS_NAME); | ||
cls.getDeclaredField(FIELD_NAME).set(null, new HashMap<>(config)); | ||
} catch (ClassNotFoundException | NoSuchFieldException | IllegalAccessException exception) { | ||
throw new RuntimeException(exception); | ||
} | ||
} | ||
|
||
@Override | ||
public Map<String, String> getProperties() { | ||
return new HashMap<>(values); | ||
} | ||
|
||
@Override | ||
public Set<String> getPropertyNames() { | ||
return values.keySet(); | ||
} | ||
|
||
@Override | ||
public int getOrdinal() { | ||
return 399; //one less that system properties | ||
} | ||
|
||
@Override | ||
public String getValue(String s) { | ||
return values.get(s); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "Config Override Config Source"; | ||
} | ||
|
||
} |
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
6 changes: 6 additions & 0 deletions
6
...pendent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/app/StartupAction.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
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
Oops, something went wrong.