http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/1e2a184f/microprofile/src/test/java/org/apache/tamaya/microprofile/imported/matchers/AdditionalMatchers.java ---------------------------------------------------------------------- diff --git a/microprofile/src/test/java/org/apache/tamaya/microprofile/imported/matchers/AdditionalMatchers.java b/microprofile/src/test/java/org/apache/tamaya/microprofile/imported/matchers/AdditionalMatchers.java new file mode 100644 index 0000000..31024d2 --- /dev/null +++ b/microprofile/src/test/java/org/apache/tamaya/microprofile/imported/matchers/AdditionalMatchers.java @@ -0,0 +1,61 @@ +/* + * 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.matchers; + +import org.hamcrest.BaseMatcher; +import org.hamcrest.Description; +import org.hamcrest.Matcher; + +import static org.hamcrest.Matchers.closeTo; + +/** + * + * @author Ondrej Mihalyi + */ +public final class AdditionalMatchers { + + private AdditionalMatchers() { + // utility class + } + + public static Matcher<Float> floatCloseTo(float value, float range) { + return new BaseMatcher<Float>() { + + private Matcher<Double> doubleMatcher = null; + + @Override + public boolean matches(Object item) { + if (item instanceof Float) { + return (doubleMatcher = closeTo(value, range)).matches(((Float)item).doubleValue()); + } + else { + return (doubleMatcher = closeTo(value, range)).matches(item); + } + } + + @Override + public void describeTo(Description description) { + doubleMatcher.describeTo(description); + } + }; + } + + +}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/1e2a184f/microprofile/src/test/java/org/apache/tamaya/microprofile/tck/TamayaConfigArchiveProcessor.java ---------------------------------------------------------------------- diff --git a/microprofile/src/test/java/org/apache/tamaya/microprofile/tck/TamayaConfigArchiveProcessor.java b/microprofile/src/test/java/org/apache/tamaya/microprofile/tck/TamayaConfigArchiveProcessor.java new file mode 100644 index 0000000..4522fb8 --- /dev/null +++ b/microprofile/src/test/java/org/apache/tamaya/microprofile/tck/TamayaConfigArchiveProcessor.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.tamaya.microprofile.tck; + +import org.apache.tamaya.microprofile.MicroprofileAdapter; +import org.apache.tamaya.microprofile.MicroprofileConfigProviderResolver; +import org.eclipse.microprofile.config.spi.ConfigProviderResolver; +import org.jboss.arquillian.container.test.spi.client.deployment.ApplicationArchiveProcessor; +import org.jboss.arquillian.test.spi.TestClass; +import org.jboss.shrinkwrap.api.Archive; +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.jboss.shrinkwrap.resolver.api.maven.Maven; + +import java.io.File; + +/** + * Adds the whole Config implementation classes and resources to the + * Arqillian deployment archive. This is needed to have the container + * pick up the beans from within the impl for the TCK tests. + * + * @author <a href="mailto:strub...@yahoo.de">Mark Struberg</a> + */ +public class TamayaConfigArchiveProcessor implements ApplicationArchiveProcessor { + + @Override + public void process(Archive<?> applicationArchive, TestClass testClass) { + if (applicationArchive instanceof WebArchive) { + File[] coreLibs = Maven.resolver() + .loadPomFromFile("pom.xml").resolve("org.apache.tamaya:tamaya-core") + .withTransitivity().asFile(); + File[] apiLibs = Maven.resolver() + .loadPomFromFile("pom.xml").resolve("org.apache.tamaya:tamaya-api") + .withTransitivity().asFile(); + File[] functionsLib = Maven.resolver() + .loadPomFromFile("pom.xml").resolve("org.apache.tamaya.ext:tamaya-functions") + .withTransitivity().asFile(); + + JavaArchive configJar = ShrinkWrap + .create(JavaArchive.class, "tamaya-config-impl.jar") + .addPackage(MicroprofileAdapter.class.getPackage()) + .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") + .addAsServiceProvider(ConfigProviderResolver.class, MicroprofileConfigProviderResolver.class); + ((WebArchive) applicationArchive).addAsLibraries( + configJar) + .addAsLibraries(apiLibs) + .addAsLibraries(coreLibs) + .addAsLibraries(functionsLib); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/1e2a184f/microprofile/src/test/java/org/apache/tamaya/microprofile/tck/TamayaConfigExtension.java ---------------------------------------------------------------------- diff --git a/microprofile/src/test/java/org/apache/tamaya/microprofile/tck/TamayaConfigExtension.java b/microprofile/src/test/java/org/apache/tamaya/microprofile/tck/TamayaConfigExtension.java new file mode 100644 index 0000000..9c0dfd3 --- /dev/null +++ b/microprofile/src/test/java/org/apache/tamaya/microprofile/tck/TamayaConfigExtension.java @@ -0,0 +1,36 @@ +/* + * 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.tamaya.microprofile.tck; + +import org.jboss.arquillian.container.test.spi.client.deployment.ApplicationArchiveProcessor; +import org.jboss.arquillian.core.spi.LoadableExtension; + +/** + * Arquillian extension to load Tamaya into Arquillian context. + * @author <a href="mailto:anat...@apache.org">Anatole Tresch</a> + */ +public class TamayaConfigExtension implements LoadableExtension { + + @Override + public void register(ExtensionBuilder extensionBuilder) { + extensionBuilder.service( + ApplicationArchiveProcessor.class, + TamayaConfigArchiveProcessor.class); + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/1e2a184f/microprofile/src/test/resources/META-INF/microprofile-config.properties ---------------------------------------------------------------------- diff --git a/microprofile/src/test/resources/META-INF/microprofile-config.properties b/microprofile/src/test/resources/META-INF/microprofile-config.properties new file mode 100644 index 0000000..6895df3 --- /dev/null +++ b/microprofile/src/test/resources/META-INF/microprofile-config.properties @@ -0,0 +1,100 @@ +# +# Copyright (c) 2016-2017 Contributors to the Eclipse Foundation +# +# See the NOTICES 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. +# + + +tck.config.test.javaconfig.properties.key1=VALue1 + + +tck.config.test.overwritten.in.custompropertyfile.key1=value from microprofile-config.properties + + +tck.config.test.javaconfig.converter.integervalue = 1234 +tck.config.test.javaconfig.converter.integervalue.broken = xxx + +tck.config.test.javaconfig.converter.longvalue = 1234567890 +tck.config.test.javaconfig.converter.longvalue.broken = xxx + +tck.config.test.javaconfig.converter.floatvalue = 12.34 +tck.config.test.javaconfig.converter.floatvalue.broken = alfasdf + +tck.config.test.javaconfig.converter.doublevalue = 12.34 +tck.config.test.javaconfig.converter.doublevalue.broken = alfasdf + +tck.config.test.javaconfig.converter.durationvalue = PT15M +tck.config.test.javaconfig.converter.durationvalue.broken = alfasdf + +tck.config.test.javaconfig.converter.localtimevalue = 10:37 +tck.config.test.javaconfig.converter.localtimevalue.broken = alfasdf + +tck.config.test.javaconfig.converter.localdatevalue = 2017-12-24 +tck.config.test.javaconfig.converter.localdatevalue.broken = alfasdf + +tck.config.test.javaconfig.converter.localdatetimevalue = 2017-12-24T10:25:30 +tck.config.test.javaconfig.converter.localdatetimevalue.broken = alfasdf + +tck.config.test.javaconfig.converter.offsetdatetimevalue = 2007-12-03T10:15:30+01:00 +tck.config.test.javaconfig.converter.offsetdatetimevalue.broken = alfasdf + +tck.config.test.javaconfig.converter.offsettimevalue = 13:45:30.123456789+02:00 +tck.config.test.javaconfig.converter.offsettimevalue.broken = alfasdf + +tck.config.test.javaconfig.converter.instantvalue = 2015-06-02T21:34:33.616Z +tck.config.test.javaconfig.converter.instantvalue.broken = alfasdf + +tck.config.test.javaconfig.configvalue.key1=value1 + +# test BooleanConverter START +tck.config.test.javaconfig.configvalue.boolean.true=true +tck.config.test.javaconfig.configvalue.boolean.true_uppercase=TRUE +tck.config.test.javaconfig.configvalue.boolean.true_mixedcase=TruE +tck.config.test.javaconfig.configvalue.boolean.false=false + +tck.config.test.javaconfig.configvalue.boolean.one=1 +tck.config.test.javaconfig.configvalue.boolean.zero=0 +tck.config.test.javaconfig.configvalue.boolean.seventeen=17 + +tck.config.test.javaconfig.configvalue.boolean.yes=yes +tck.config.test.javaconfig.configvalue.boolean.yes_uppercase=YES +tck.config.test.javaconfig.configvalue.boolean.yes_mixedcase=Yes +tck.config.test.javaconfig.configvalue.boolean.no=no + +tck.config.test.javaconfig.configvalue.boolean.y=y +tck.config.test.javaconfig.configvalue.boolean.y_uppercase=Y +tck.config.test.javaconfig.configvalue.boolean.n=n + +tck.config.test.javaconfig.configvalue.boolean.on=on +tck.config.test.javaconfig.configvalue.boolean.on_uppercase=ON +tck.config.test.javaconfig.configvalue.boolean.on_mixedcase=oN +tck.config.test.javaconfig.configvalue.boolean.off=off + +# test BooleanConverter END + +# various other converter +tck.config.test.javaconfig.configvalue.integer=1234 +tck.config.test.javaconfig.configvalue.long=1234567890123456 +tck.config.test.javaconfig.configvalue.float=12.34 +tck.config.test.javaconfig.configvalue.double=12.34567890123456 + +# Custom Converter tests +tck.config.test.javaconfig.converter.duckname=Hannelore + +# URL Converter tests +tck.config.test.javaconfig.converter.urlvalue=http://microprofile.io +tck.config.test.javaconfig.converter.urlvalue.broken=tt:--location \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/1e2a184f/microprofile/src/test/resources/META-INF/services/org.eclipse.microprofile.config.spi.ConfigSource ---------------------------------------------------------------------- diff --git a/microprofile/src/test/resources/META-INF/services/org.eclipse.microprofile.config.spi.ConfigSource b/microprofile/src/test/resources/META-INF/services/org.eclipse.microprofile.config.spi.ConfigSource index dc7c0fa..dbffc2a 100644 --- a/microprofile/src/test/resources/META-INF/services/org.eclipse.microprofile.config.spi.ConfigSource +++ b/microprofile/src/test/resources/META-INF/services/org.eclipse.microprofile.config.spi.ConfigSource @@ -16,4 +16,4 @@ # specific language governing permissions and limitations # under the License. # -org.apache.tamaya.microprofile.configsources.MPSystemPropertiesConfigSource +org.apache.tamaya.microprofile.imported.configsources.CustomDbConfigSource \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/1e2a184f/microprofile/src/test/resources/META-INF/services/org.eclipse.microprofile.config.spi.ConfigSourceProvider ---------------------------------------------------------------------- diff --git a/microprofile/src/test/resources/META-INF/services/org.eclipse.microprofile.config.spi.ConfigSourceProvider b/microprofile/src/test/resources/META-INF/services/org.eclipse.microprofile.config.spi.ConfigSourceProvider new file mode 100644 index 0000000..68c6ace --- /dev/null +++ b/microprofile/src/test/resources/META-INF/services/org.eclipse.microprofile.config.spi.ConfigSourceProvider @@ -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. +# + +org.apache.tamaya.microprofile.imported.configsources.CustomConfigSourceProvider \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/1e2a184f/microprofile/src/test/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension ---------------------------------------------------------------------- diff --git a/microprofile/src/test/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension b/microprofile/src/test/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension new file mode 100644 index 0000000..b2af25c --- /dev/null +++ b/microprofile/src/test/resources/META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension @@ -0,0 +1,19 @@ +# +# 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. +# +org.apache.tamaya.microprofile.tck.TamayaConfigExtension \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/1e2a184f/microprofile/src/test/tck-suite.xml ---------------------------------------------------------------------- diff --git a/microprofile/src/test/tck-suite.xml b/microprofile/src/test/tck-suite.xml new file mode 100644 index 0000000..7efa750 --- /dev/null +++ b/microprofile/src/test/tck-suite.xml @@ -0,0 +1,29 @@ +<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" > +<!-- +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 current 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. +--> +<suite name="microprofile-config-TCK" verbose="2" configfailurepolicy="continue" > + + <test name="microprofile-config 1.0 TCK"> + <packages> + <package name="org.eclipse.microprofile.config.tck.*"> + </package> + </packages> + </test> + +</suite> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/1e2a184f/microprofile/tck-suite.xml ---------------------------------------------------------------------- diff --git a/microprofile/tck-suite.xml b/microprofile/tck-suite.xml deleted file mode 100644 index 7efa750..0000000 --- a/microprofile/tck-suite.xml +++ /dev/null @@ -1,29 +0,0 @@ -<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" > -<!-- -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 current 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. ---> -<suite name="microprofile-config-TCK" verbose="2" configfailurepolicy="continue" > - - <test name="microprofile-config 1.0 TCK"> - <packages> - <package name="org.eclipse.microprofile.config.tck.*"> - </package> - </packages> - </test> - -</suite> \ No newline at end of file