You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tamaya.apache.org by an...@apache.org on 2017/08/09 23:09:35 UTC
[2/2] incubator-tamaya-sandbox git commit: TAMAYA-260: Added missing
artifacts.
TAMAYA-260: Added missing artifacts.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/commit/41305de4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/tree/41305de4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/diff/41305de4
Branch: refs/heads/java8
Commit: 41305de4381b34b7f9d664ce10812d767cd3977d
Parents: c9676a8
Author: anatole <an...@apache.org>
Authored: Thu Aug 10 01:00:03 2017 +0200
Committer: anatole <an...@apache.org>
Committed: Thu Aug 10 01:00:03 2017 +0200
----------------------------------------------------------------------
.../imported/CdiOptionalInjectionTest.java | 71 ++++++++++++++++++++
.../imported/base/AbstractTest.java | 42 ++++++++++++
.../src/test/resources/sampleconfig.yaml | 18 +++++
3 files changed, 131 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/41305de4/microprofile/src/test/java/org/apache/tamaya/microprofile/imported/CdiOptionalInjectionTest.java
----------------------------------------------------------------------
diff --git a/microprofile/src/test/java/org/apache/tamaya/microprofile/imported/CdiOptionalInjectionTest.java b/microprofile/src/test/java/org/apache/tamaya/microprofile/imported/CdiOptionalInjectionTest.java
new file mode 100644
index 0000000..ee6d158
--- /dev/null
+++ b/microprofile/src/test/java/org/apache/tamaya/microprofile/imported/CdiOptionalInjectionTest.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2016-2017 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * 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.tamaya.microprofile.imported;
+
+import org.eclipse.microprofile.config.tck.OptionalValuesBean;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.testng.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import javax.inject.Inject;
+
+/**
+ * Verify injection of {@code Optional<T>} fields.
+ *
+ * @author <a href="mailto:struberg@apache.org">Mark Struberg</a>
+ */
+public class CdiOptionalInjectionTest extends Arquillian{
+
+ private @Inject OptionalValuesBean optionalValuesBean;
+
+ @Deployment
+ public static WebArchive deploy() {
+ JavaArchive testJar = ShrinkWrap
+ .create(JavaArchive.class, "cdiOptionalInjectionTest.jar")
+ .addClasses(org.eclipse.microprofile.config.tck.CdiOptionalInjectionTest.class, OptionalValuesBean.class)
+ .addAsManifestResource(new StringAsset("my.optional.int.property=1234\nmy.optional.string.property=hello"),
+ "microprofile-config.properties")
+ .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")
+ .as(JavaArchive.class);
+
+ WebArchive war = ShrinkWrap
+ .create(WebArchive.class, "cdiOptionalInjectionTest.war")
+ .addAsLibrary(testJar);
+ return war;
+ }
+
+
+ @Test
+ public void testOptionalInjection() {
+ Assert.assertTrue(optionalValuesBean.getIntProperty().isPresent());
+ Assert.assertEquals(optionalValuesBean.getIntProperty().get(), Integer.valueOf(1234));
+
+ Assert.assertFalse(optionalValuesBean.getNotexistingProperty().isPresent());
+
+ Assert.assertTrue(optionalValuesBean.getStringValue().isPresent());
+ Assert.assertEquals(optionalValuesBean.getStringValue().get(), "hello");
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/41305de4/microprofile/src/test/java/org/apache/tamaya/microprofile/imported/base/AbstractTest.java
----------------------------------------------------------------------
diff --git a/microprofile/src/test/java/org/apache/tamaya/microprofile/imported/base/AbstractTest.java b/microprofile/src/test/java/org/apache/tamaya/microprofile/imported/base/AbstractTest.java
new file mode 100644
index 0000000..0c9d3cc
--- /dev/null
+++ b/microprofile/src/test/java/org/apache/tamaya/microprofile/imported/base/AbstractTest.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2016-2017 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * 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.tamaya.microprofile.imported.base;
+
+import org.jboss.shrinkwrap.api.asset.UrlAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+
+
+/**
+ * @author <a href="mailto:struberg@apache.org">Mark Struberg</a>
+ */
+public class AbstractTest {
+
+
+ public static void addFile(JavaArchive archive, String originalPath) {
+ archive.addAsResource(new UrlAsset(Thread.currentThread().getContextClassLoader().getResource("internal/" + originalPath)),
+ originalPath);
+ }
+
+ public static void addFile(JavaArchive archive, String originalFile, String targetFile) {
+ archive.addAsResource(new UrlAsset(Thread.currentThread().getContextClassLoader().getResource(originalFile)),
+ targetFile);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/41305de4/microprofile/src/test/resources/sampleconfig.yaml
----------------------------------------------------------------------
diff --git a/microprofile/src/test/resources/sampleconfig.yaml b/microprofile/src/test/resources/sampleconfig.yaml
new file mode 100644
index 0000000..27f2392
--- /dev/null
+++ b/microprofile/src/test/resources/sampleconfig.yaml
@@ -0,0 +1,18 @@
+#
+# Copyright (c) 2016-2017 Mark Struberg and others
+#
+# 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.
+#
+# just needed as a trigger for the ConfigSource pickup.
+# Content is hardcoded in SampleYamlConfigSource
\ No newline at end of file