Fixed MP Config. (cherry picked from commit 4b2d148)
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/5d86cc80 Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/5d86cc80 Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/5d86cc80 Branch: refs/heads/master Commit: 5d86cc801ef8881a70c5c14019869c078b86c24b Parents: 2bd4df7 Author: Roberto Cortez <radcor...@yahoo.com> Authored: Tue Jul 24 21:04:23 2018 +0100 Committer: Roberto Cortez <radcor...@yahoo.com> Committed: Fri Jul 27 19:48:12 2018 +0100 ---------------------------------------------------------------------- tck/microprofile-tck/config/pom.xml | 4 -- .../MicroProfileConfigTCKArchiveProcessor.java | 15 +---- .../config/MicroProfileConfigurationTest.java | 69 ++++++++++++++++++++ 3 files changed, 72 insertions(+), 16 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tomee/blob/5d86cc80/tck/microprofile-tck/config/pom.xml ---------------------------------------------------------------------- diff --git a/tck/microprofile-tck/config/pom.xml b/tck/microprofile-tck/config/pom.xml index 5f509e8..56c1d28 100644 --- a/tck/microprofile-tck/config/pom.xml +++ b/tck/microprofile-tck/config/pom.xml @@ -29,16 +29,12 @@ <artifactId>microprofile-config-tck</artifactId> <name>OpenEJB :: TCK :: MicroProfile Config TCK</name> - <!-- TODO - see ServerClassConverter: requires a fix in geronimo-config-impl to use the Thread ClassLoader in ClassConverter. --> - <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> - <forkCount>1</forkCount> - <reuseForks>true</reuseForks> <dependenciesToScan> <dependency>org.eclipse.microprofile.config:microprofile-config-tck</dependency> </dependenciesToScan> http://git-wip-us.apache.org/repos/asf/tomee/blob/5d86cc80/tck/microprofile-tck/config/src/test/java/org/apache/openejb/tck/microprofile/config/MicroProfileConfigTCKArchiveProcessor.java ---------------------------------------------------------------------- diff --git a/tck/microprofile-tck/config/src/test/java/org/apache/openejb/tck/microprofile/config/MicroProfileConfigTCKArchiveProcessor.java b/tck/microprofile-tck/config/src/test/java/org/apache/openejb/tck/microprofile/config/MicroProfileConfigTCKArchiveProcessor.java index dcee75d..e07033b 100644 --- a/tck/microprofile-tck/config/src/test/java/org/apache/openejb/tck/microprofile/config/MicroProfileConfigTCKArchiveProcessor.java +++ b/tck/microprofile-tck/config/src/test/java/org/apache/openejb/tck/microprofile/config/MicroProfileConfigTCKArchiveProcessor.java @@ -1,7 +1,5 @@ package org.apache.openejb.tck.microprofile.config; -import static org.apache.openejb.loader.JarLocation.jarLocation; - import org.eclipse.microprofile.config.tck.converters.UpperCaseDuckConverter; import org.hamcrest.object.HasToString; import org.jboss.arquillian.container.test.spi.client.deployment.ApplicationArchiveProcessor; @@ -11,11 +9,9 @@ import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.jboss.shrinkwrap.api.spec.WebArchive; -import java.io.File; +import static org.apache.openejb.loader.JarLocation.jarLocation; public class MicroProfileConfigTCKArchiveProcessor implements ApplicationArchiveProcessor { - private File hamcrest; - @Override public void process(final Archive<?> archive, final TestClass testClass) { if (archive instanceof WebArchive) { @@ -24,15 +20,10 @@ public class MicroProfileConfigTCKArchiveProcessor implements ApplicationArchive // TODO - this could be fixed in the TCK by adding UpperCaseDuckConverter into org.eclipse.microprofile.config.tck.ConverterTest JavaArchive configJar = ShrinkWrap .create(JavaArchive.class, "config-tck-additional.jar") - .addClass(UpperCaseDuckConverter.class) - ; + .addClass(UpperCaseDuckConverter.class); war.addAsLibraries(configJar); - - if (hamcrest == null) { - hamcrest = jarLocation(HasToString.class); - } - war.addAsLibrary(hamcrest); + war.addAsLibrary(jarLocation(HasToString.class)); } } } http://git-wip-us.apache.org/repos/asf/tomee/blob/5d86cc80/tck/microprofile-tck/config/src/test/java/org/apache/openejb/tck/microprofile/config/MicroProfileConfigurationTest.java ---------------------------------------------------------------------- diff --git a/tck/microprofile-tck/config/src/test/java/org/apache/openejb/tck/microprofile/config/MicroProfileConfigurationTest.java b/tck/microprofile-tck/config/src/test/java/org/apache/openejb/tck/microprofile/config/MicroProfileConfigurationTest.java new file mode 100644 index 0000000..64e754d --- /dev/null +++ b/tck/microprofile-tck/config/src/test/java/org/apache/openejb/tck/microprofile/config/MicroProfileConfigurationTest.java @@ -0,0 +1,69 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.openejb.tck.microprofile.config; + +import org.eclipse.microprofile.config.Config; +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.spec.JavaArchive; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.testng.Assert; +import org.testng.annotations.Test; + +import javax.inject.Inject; + +import static org.testng.Assert.assertEquals; + +@Test +public class MicroProfileConfigurationTest extends Arquillian { + @Deployment + public static WebArchive deploy() { + JavaArchive testJar = ShrinkWrap + .create(JavaArchive.class, "microprofile-configuration.jar") + .addClass(ConfigurationBean.class) + .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") + .as(JavaArchive.class); + + WebArchive war = ShrinkWrap + .create(WebArchive.class, "microprofile-configuration.war") + .addAsLibrary(testJar); + + return war; + } + + @Inject + private ConfigurationBean configurationBean; + + @Test + public void testConfiguration() throws Exception { + assertEquals("SUCCESS", configurationBean.getConfig()); + } + + @Inject + private Config config; + + @Test + public void testDynamicValueInPropertyConfigSource() { + String configKey = "tck.config.test.systemproperty.dynamic.value"; + String configValue = "myDynamicValue;"; + + System.setProperty(configKey, configValue); + Assert.assertEquals(config.getValue(configKey, String.class), configValue); + } +}