You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by ro...@apache.org on 2019/11/25 18:43:44 UTC

[aries-cdi] 25/27: mp-config test

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

rotty3000 pushed a commit to branch rotty3000/cdi-spi
in repository https://gitbox.apache.org/repos/asf/aries-cdi.git

commit ce32f13d70d4937a66af040a837318a390624075
Author: Raymond Augé <ro...@apache.org>
AuthorDate: Sun Nov 24 15:58:05 2019 -0500

    mp-config test
    
    Signed-off-by: Raymond Augé <ro...@apache.org>
---
 cdi-itests/bnd.bnd                                 |  3 +-
 cdi-itests/bnd/tb16.bnd                            | 13 ++++++
 cdi-itests/owb-itest.bndrun                        |  1 +
 cdi-itests/pom.xml                                 |  4 ++
 .../aries/cdi/test/cases/AbstractTestCase.java     |  9 +++-
 .../apache/aries/cdi/test/cases/MpConfigTests.java | 48 ++++++++++++++++++++++
 .../apache/aries/cdi/test/tb16/ConfiguredBean.java | 42 +++++++++++++++++++
 .../apache/aries/cdi/test/tb16/package-info.java   | 16 ++++++++
 cdi-itests/weld-itest.bndrun                       |  1 +
 9 files changed, 134 insertions(+), 3 deletions(-)

diff --git a/cdi-itests/bnd.bnd b/cdi-itests/bnd.bnd
index 1fd7594..d574c45 100644
--- a/cdi-itests/bnd.bnd
+++ b/cdi-itests/bnd.bnd
@@ -57,7 +57,8 @@ p = org.apache.aries.cdi.test
 	tb152_3_1_1l.jar,\
 	tb12.jar,\
 	tb13.jar,\
-	tb14.jar
+	tb14.jar,\
+	tb16.jar
 
 # Don't forget that we had to coax the `maven-jar-plugin` NOT to include the `sub-bundle` packages in
 # the root bundle:
diff --git a/cdi-itests/bnd/tb16.bnd b/cdi-itests/bnd/tb16.bnd
new file mode 100644
index 0000000..c6d1f50
--- /dev/null
+++ b/cdi-itests/bnd/tb16.bnd
@@ -0,0 +1,13 @@
+#    Licensed under the Apache License, Version 2.0 (the "License");
+#    you may not use this file except in compliance with the License.
+#    You may obtain a copy of the License at
+#
+#        http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#    See the License for the specific language governing permissions and
+#    limitations under the License.
+
+Export-Package: ${p}.tb16.*;-split-package:=first
diff --git a/cdi-itests/owb-itest.bndrun b/cdi-itests/owb-itest.bndrun
index 183d25f..e6fb820 100644
--- a/cdi-itests/owb-itest.bndrun
+++ b/cdi-itests/owb-itest.bndrun
@@ -31,6 +31,7 @@
 	openwebbeans-web;version='[2.0.13,2.0.14)',\
 	org.apache.aries.cdi.extender;version='[1.0.3,1.0.4)',\
 	org.apache.aries.cdi.extension.jndi;version='[1.0.3,1.0.4)',\
+	org.apache.aries.cdi.extension.mp-config;version='[1.0.3,1.0.4)',\
 	org.apache.aries.cdi.extra;version='[1.0.3,1.0.4)',\
 	org.apache.aries.cdi.itests;version='[1.0.3,1.0.4)',\
 	org.apache.aries.cdi.owb;version='[1.0.3,1.0.4)',\
diff --git a/cdi-itests/pom.xml b/cdi-itests/pom.xml
index 0a8aea2..9697bb8 100644
--- a/cdi-itests/pom.xml
+++ b/cdi-itests/pom.xml
@@ -64,6 +64,10 @@
 			<artifactId>org.apache.aries.cdi.extra</artifactId>
 		</dependency>
 		<dependency>
+			<groupId>org.apache.aries.cdi</groupId>
+			<artifactId>org.apache.aries.cdi.extension.mp-config</artifactId>
+		</dependency>
+		<dependency>
 			<groupId>org.apache.felix</groupId>
 			<artifactId>org.apache.felix.http.servlet-api</artifactId>
 		</dependency>
diff --git a/cdi-itests/src/main/java/org/apache/aries/cdi/test/cases/AbstractTestCase.java b/cdi-itests/src/main/java/org/apache/aries/cdi/test/cases/AbstractTestCase.java
index 4c2fcda..25414dd 100644
--- a/cdi-itests/src/main/java/org/apache/aries/cdi/test/cases/AbstractTestCase.java
+++ b/cdi-itests/src/main/java/org/apache/aries/cdi/test/cases/AbstractTestCase.java
@@ -17,6 +17,7 @@ package org.apache.aries.cdi.test.cases;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
+import static org.osgi.service.cdi.CDIConstants.CDI_EXTENSION_PROPERTY;
 
 import java.io.InputStream;
 import java.util.Dictionary;
@@ -64,13 +65,17 @@ import org.osgi.util.tracker.ServiceTrackerCustomizer;
 	namespace = ServiceNamespace.SERVICE_NAMESPACE
 )
 @Requirement(
-	namespace = CDIConstants.CDI_EXTENSION_PROPERTY,
+	namespace = CDI_EXTENSION_PROPERTY,
 	name = "aries.cdi.http"
 )
 @Requirement(
-	namespace = CDIConstants.CDI_EXTENSION_PROPERTY,
+	namespace = CDI_EXTENSION_PROPERTY,
 	name = "aries.cdi.jndi"
 )
+@Requirement(
+	namespace = CDI_EXTENSION_PROPERTY,
+	name = "eclipse.microprofile.config"
+)
 public abstract class AbstractTestCase {
 
 	@Rule
diff --git a/cdi-itests/src/main/java/org/apache/aries/cdi/test/cases/MpConfigTests.java b/cdi-itests/src/main/java/org/apache/aries/cdi/test/cases/MpConfigTests.java
new file mode 100644
index 0000000..7b083e5
--- /dev/null
+++ b/cdi-itests/src/main/java/org/apache/aries/cdi/test/cases/MpConfigTests.java
@@ -0,0 +1,48 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.aries.cdi.test.cases;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.apache.aries.cdi.test.interfaces.Pojo;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.util.tracker.ServiceTracker;
+
+public class MpConfigTests extends SlimTestCase {
+
+	@Test
+	public void testConfigIsSet() throws Exception {
+		Bundle tb2Bundle = installBundle("tb16.jar", false);
+
+		tb2Bundle.start();
+
+		ServiceTracker<Pojo, Pojo> st = new ServiceTracker<Pojo, Pojo>(
+			bundleContext, Pojo.class, null);
+		st.open(true);
+
+		try {
+			Pojo pojo = st.waitForService(timeout);
+			assertNotNull(pojo);
+			assertEquals("[foo]", pojo.foo(null));
+		}
+		finally {
+			st.close();
+			tb2Bundle.uninstall();
+		}
+	}
+
+}
diff --git a/cdi-itests/src/main/java/org/apache/aries/cdi/test/tb16/ConfiguredBean.java b/cdi-itests/src/main/java/org/apache/aries/cdi/test/tb16/ConfiguredBean.java
new file mode 100644
index 0000000..478caa9
--- /dev/null
+++ b/cdi-itests/src/main/java/org/apache/aries/cdi/test/tb16/ConfiguredBean.java
@@ -0,0 +1,42 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.aries.cdi.test.tb16;
+
+import java.util.List;
+
+import javax.inject.Inject;
+
+import org.apache.aries.cdi.test.interfaces.Pojo;
+import org.eclipse.microprofile.config.inject.ConfigProperty;
+import org.osgi.service.cdi.annotations.Service;
+
+@Service
+public class ConfiguredBean implements Pojo {
+
+	@Inject
+	@ConfigProperty(name = "tck.config.test.javaconfig.converter.stringvalues")
+	private List<String> myStringList;
+
+	@Override
+	public String foo(String ignored) {
+		return myStringList.toString();
+	}
+
+	@Override
+	public int getCount() {
+		return 0;
+	}
+
+}
diff --git a/cdi-itests/src/main/java/org/apache/aries/cdi/test/tb16/package-info.java b/cdi-itests/src/main/java/org/apache/aries/cdi/test/tb16/package-info.java
new file mode 100644
index 0000000..315634c
--- /dev/null
+++ b/cdi-itests/src/main/java/org/apache/aries/cdi/test/tb16/package-info.java
@@ -0,0 +1,16 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+@org.osgi.service.cdi.annotations.Beans
+package org.apache.aries.cdi.test.tb16;
diff --git a/cdi-itests/weld-itest.bndrun b/cdi-itests/weld-itest.bndrun
index e452bf3..2c4d345 100644
--- a/cdi-itests/weld-itest.bndrun
+++ b/cdi-itests/weld-itest.bndrun
@@ -40,6 +40,7 @@
 	org.apache.aries.cdi.extender;version='[1.0.3,1.0.4)',\
 	org.apache.aries.cdi.extension.http;version='[1.0.3,1.0.4)',\
 	org.apache.aries.cdi.extension.jndi;version='[1.0.3,1.0.4)',\
+	org.apache.aries.cdi.extension.mp-config;version='[1.0.3,1.0.4)',\
 	org.apache.aries.cdi.extra;version='[1.0.3,1.0.4)',\
 	org.apache.aries.cdi.itests;version='[1.0.3,1.0.4)',\
 	org.apache.aries.cdi.spi;version='[1.0.3,1.0.4)',\