-
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.
- Loading branch information
Showing
12 changed files
with
275 additions
and
12 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
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
48 changes: 48 additions & 0 deletions
48
...ion-tests/smallrye-config/src/main/java/io/quarkus/it/smallrye/config/ConfigResource.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,48 @@ | ||
package io.quarkus.it.smallrye.config; | ||
|
||
import javax.inject.Inject; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.PathParam; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MediaType; | ||
import javax.ws.rs.core.Response; | ||
|
||
import org.eclipse.microprofile.config.Config; | ||
|
||
import io.quarkus.runtime.annotations.RegisterForReflection; | ||
import io.smallrye.config.ConfigValue; | ||
import io.smallrye.config.SmallRyeConfig; | ||
|
||
@Path("/config") | ||
@Produces(MediaType.APPLICATION_JSON) | ||
public class ConfigResource { | ||
@Inject | ||
Config config; | ||
|
||
@GET | ||
@Path("/{name}") | ||
public Response configValue(@PathParam("name") final String name) { | ||
final io.smallrye.config.ConfigValue configValue = ((SmallRyeConfig) config).getConfigValue(name); | ||
return Response.ok(new ConfigValue(configValue.getName(), configValue.getValue())).build(); | ||
} | ||
|
||
@RegisterForReflection | ||
public static class ConfigValue { | ||
final String name; | ||
final String value; | ||
|
||
public ConfigValue(final String name, final String value) { | ||
this.name = name; | ||
this.value = value; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public String getValue() { | ||
return value; | ||
} | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
...smallrye-config/src/main/java/io/quarkus/it/smallrye/config/MultipleProfilesResource.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,70 @@ | ||
package io.quarkus.it.smallrye.config; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
import javax.enterprise.inject.Instance; | ||
import javax.inject.Inject; | ||
import javax.ws.rs.Consumes; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MediaType; | ||
import javax.ws.rs.core.Response; | ||
|
||
import io.quarkus.arc.profile.IfBuildProfile; | ||
import io.quarkus.arc.profile.UnlessBuildProfile; | ||
|
||
@Path("/profiles") | ||
@Consumes(MediaType.TEXT_PLAIN) | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public class MultipleProfilesResource { | ||
@Inject | ||
Instance<ActiveProfile> activeProfiles; | ||
|
||
@GET | ||
public Response getActiveProfiles() { | ||
return Response.ok(activeProfiles.stream() | ||
.map(ActiveProfile::value) | ||
.reduce((integer, integer2) -> integer | integer2) | ||
.orElse(0)).build(); | ||
} | ||
|
||
public interface ActiveProfile { | ||
int value(); | ||
} | ||
|
||
@ApplicationScoped | ||
@IfBuildProfile("common") | ||
public static class CommonProfile implements ActiveProfile { | ||
@Override | ||
public int value() { | ||
return 1; | ||
} | ||
} | ||
|
||
@ApplicationScoped | ||
@IfBuildProfile("test") | ||
public static class TestProfile implements ActiveProfile { | ||
@Override | ||
public int value() { | ||
return 2; | ||
} | ||
} | ||
|
||
@ApplicationScoped | ||
@IfBuildProfile("prod") | ||
public static class ProdProfile implements ActiveProfile { | ||
@Override | ||
public int value() { | ||
return 4; | ||
} | ||
} | ||
|
||
@ApplicationScoped | ||
@UnlessBuildProfile("main") | ||
public static class MainProfile implements ActiveProfile { | ||
@Override | ||
public int value() { | ||
return 8; | ||
} | ||
} | ||
} |
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
14 changes: 14 additions & 0 deletions
14
integration-tests/smallrye-config/src/main/resources/application.properties
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
7 changes: 7 additions & 0 deletions
7
...tests/smallrye-config/src/test/java/io/quarkus/it/smallrye/config/MultipleProfilesIT.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,7 @@ | ||
package io.quarkus.it.smallrye.config; | ||
|
||
import io.quarkus.test.junit.NativeImageTest; | ||
|
||
@NativeImageTest | ||
public class MultipleProfilesIT extends MultipleProflesTest { | ||
} |
Oops, something went wrong.