You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltaspike.apache.org by st...@apache.org on 2019/11/10 20:07:31 UTC

[deltaspike] branch master updated: DELTASPIKE-1364 Variables in @ConfigProperty

This is an automated email from the ASF dual-hosted git repository.

struberg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/deltaspike.git


The following commit(s) were added to refs/heads/master by this push:
     new 63bbcfb  DELTASPIKE-1364 Variables in @ConfigProperty
63bbcfb is described below

commit 63bbcfb75f437c7cee2578c07a4131e18e709ecf
Author: Mark Struberg <st...@apache.org>
AuthorDate: Sun Nov 10 21:03:10 2019 +0100

    DELTASPIKE-1364 Variables in @ConfigProperty
    
    Unit test only.
    Seems I already fixed that while reworking the Config to an interface.
---
 .../core/api/config/injectable/InjectableConfigPropertyTest.java | 8 ++++++++
 .../deltaspike/test/core/api/config/injectable/SettingsBean.java | 9 +++++++++
 .../src/test/resources/META-INF/apache-deltaspike.properties     | 8 ++++++++
 3 files changed, 25 insertions(+)

diff --git a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/config/injectable/InjectableConfigPropertyTest.java b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/config/injectable/InjectableConfigPropertyTest.java
index ec74c1a..2b4c8be 100644
--- a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/config/injectable/InjectableConfigPropertyTest.java
+++ b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/config/injectable/InjectableConfigPropertyTest.java
@@ -112,6 +112,13 @@ public class InjectableConfigPropertyTest
     }
 
     @Test
+    public void testProjectStageAwareReplacement()
+    {
+        SettingsBean settingsBean = BeanProvider.getContextualReference(SettingsBean.class, false);
+        assertEquals("https://myapp/login.xhtml", settingsBean.getProjectStageAwareVariableValue());
+    }
+
+    @Test
     public void checkDynamicConvertedInjections() throws MalformedURLException
     {
         SettingsBean settingsBean = BeanProvider.getContextualReference(SettingsBean.class, false);
@@ -126,6 +133,7 @@ public class InjectableConfigPropertyTest
         assertEquals("value", settingsBean.getCustomSourceValue());
     }
 
+
     @Test
     public void proxy() throws MalformedURLException
     {
diff --git a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/config/injectable/SettingsBean.java b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/config/injectable/SettingsBean.java
index b8848e4..cd582d2 100644
--- a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/config/injectable/SettingsBean.java
+++ b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/config/injectable/SettingsBean.java
@@ -109,6 +109,10 @@ public class SettingsBean
     @ConfigProperty(name = "custom-source.test")
     private String customSourceValue;
 
+    @Inject
+    @ConfigProperty(name = "myapp.login.url")
+    private String projectStageAwareVariableValue;
+
     protected SettingsBean()
     {
     }
@@ -223,6 +227,11 @@ public class SettingsBean
         return customSourceValue;
     }
 
+    public String getProjectStageAwareVariableValue()
+    {
+        return projectStageAwareVariableValue;
+    }
+
     public static class UrlList implements ConfigResolver.Converter<List<URL>>
     {
         @Override
diff --git a/deltaspike/core/impl/src/test/resources/META-INF/apache-deltaspike.properties b/deltaspike/core/impl/src/test/resources/META-INF/apache-deltaspike.properties
index 28e522f..b098884 100644
--- a/deltaspike/core/impl/src/test/resources/META-INF/apache-deltaspike.properties
+++ b/deltaspike/core/impl/src/test/resources/META-INF/apache-deltaspike.properties
@@ -56,3 +56,11 @@ urlListFromProperties = http://127.0.0.2
 
 prefix.suffix = done
 
+# test project stage aware replacement mechanism
+# Attention: Depending on whether another test did already run we might get
+# ProjectStage Production or UnitTest. So we set the same value for both now
+myapp.login.hostname=http://myapp
+myapp.login.hostname.Production=https://myapp
+myapp.login.hostname.UnitTest=https://myapp
+myapp.login.url=${myapp.login.hostname}/login.xhtml
+