http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/346a4f38/modules/injection/cdi/src/main/java/org/apache/tamaya/integration/cdi/TamayaSEInjectionExtension.java ---------------------------------------------------------------------- diff --git a/modules/injection/cdi/src/main/java/org/apache/tamaya/integration/cdi/TamayaSEInjectionExtension.java b/modules/injection/cdi/src/main/java/org/apache/tamaya/integration/cdi/TamayaSEInjectionExtension.java deleted file mode 100644 index 57bf2a5..0000000 --- a/modules/injection/cdi/src/main/java/org/apache/tamaya/integration/cdi/TamayaSEInjectionExtension.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * 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.integration.cdi; - - -import org.apache.tamaya.inject.ConfigurationInjection; -import org.apache.tamaya.inject.api.Config; -import org.apache.tamaya.inject.api.ConfigDefaultSections; - -import javax.enterprise.context.spi.CreationalContext; -import javax.enterprise.event.Observes; -import javax.enterprise.inject.Vetoed; -import javax.enterprise.inject.spi.*; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.Set; - -/** - * CDI portable extension that integrates {@link org.apache.tamaya.inject.ConfigurationInjector} - * with CDI by adding configuration features to CDI (config enable CDI beans). - */ -@Vetoed -public final class TamayaSEInjectionExtension implements Extension { - - /** - * Method that injects the values into any configured fields, by wrapping the given - * InjectionTarget. - * @param pit the injection target - * @param <T> the target type - */ - public <T> void initializeConfiguredFields(final @Observes ProcessInjectionTarget<T> pit) { - final AnnotatedType<T> at = pit.getAnnotatedType(); - if (!isConfigured(at.getJavaClass())) { - return; - } - final InjectionTarget<T> it = pit.getInjectionTarget(); - InjectionTarget<T> wrapped = new InjectionTarget<T>() { - @Override - public void inject(T instance, CreationalContext<T> ctx) { - it.inject(instance, ctx); - ConfigurationInjection.getConfigurationInjector().configure(instance); - } - - @Override - public void postConstruct(T instance) { - it.postConstruct(instance); - } - - @Override - public void preDestroy(T instance) { - it.dispose(instance); - } - - @Override - public void dispose(T instance) { - it.dispose(instance); - } - - @Override - public Set<InjectionPoint> getInjectionPoints() { - return it.getInjectionPoints(); - } - - @Override - public T produce(CreationalContext<T> ctx) { - return it.produce(ctx); - } - }; - pit.setInjectionTarget(wrapped); - } - - private boolean isConfigured(Class type) { - if (type.getAnnotation(ConfigDefaultSections.class) != null) { - return true; - } - // if no class level annotation is there we might have field level annotations only - for (Field field : type.getDeclaredFields()) { - if (field.isAnnotationPresent(Config.class)) { - return true; - } - } - // if no class level annotation is there we might have method level annotations only - for (Method method : type.getDeclaredMethods()) { - if(method.isAnnotationPresent(Config.class)) { - return true; - } - } - return false; - } - - -}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/346a4f38/modules/injection/cdi/src/main/java/org/apache/tamaya/integration/cdi/extra/ConfiguredVetoExtension.java ---------------------------------------------------------------------- diff --git a/modules/injection/cdi/src/main/java/org/apache/tamaya/integration/cdi/extra/ConfiguredVetoExtension.java b/modules/injection/cdi/src/main/java/org/apache/tamaya/integration/cdi/extra/ConfiguredVetoExtension.java deleted file mode 100644 index 84ff5a2..0000000 --- a/modules/injection/cdi/src/main/java/org/apache/tamaya/integration/cdi/extra/ConfiguredVetoExtension.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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.integration.cdi.extra; - -import org.apache.tamaya.ConfigurationProvider; - -import javax.enterprise.event.Observes; -import javax.enterprise.inject.spi.Extension; -import javax.enterprise.inject.spi.ProcessAnnotatedType; - -/** - * CDI Extension that can be used to veto on beans by configuring the fully qualified class names (as regex expression) - * under {@code javax.enterprise.inject.vetoed}. Multiple expression can be added as comma separated values. - */ -public class ConfiguredVetoExtension implements Extension { - - public void observesBean(@Observes ProcessAnnotatedType<?> type){ - String vetoedTypesVal = ConfigurationProvider.getConfiguration().get("javax.enterprise.inject.vetoed"); - String[] vetoedTypes = vetoedTypesVal.split(","); - for(String typeExpr:vetoedTypes){ - if(type.getAnnotatedType().getJavaClass().getName().matches(typeExpr)){ - type.veto(); - } - } - } - -} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/346a4f38/modules/injection/cdi/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension ---------------------------------------------------------------------- diff --git a/modules/injection/cdi/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension b/modules/injection/cdi/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension index 63ad743..d6bab38 100644 --- a/modules/injection/cdi/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension +++ b/modules/injection/cdi/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension @@ -16,6 +16,6 @@ # specific language governing permissions and limitations # under the License. # -#org.apache.tamaya.integration.cdi.TamayaCDIInjectionExtension -#org.apache.tamaya.integration.cdi.TamayaSEInjectionExtension -org.apache.tamaya.integration.cdi.TamayaCDIAccessor +#org.apache.tamaya.cdi.TamayaCDIInjectionExtension +#org.apache.tamaya.cdi.TamayaSEInjectionExtension +org.apache.tamaya.cdi.TamayaCDIAccessor http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/346a4f38/modules/injection/cdi/src/main/resources/META-INF/services/org.apache.tamaya.spi.ServiceContext ---------------------------------------------------------------------- diff --git a/modules/injection/cdi/src/main/resources/META-INF/services/org.apache.tamaya.spi.ServiceContext b/modules/injection/cdi/src/main/resources/META-INF/services/org.apache.tamaya.spi.ServiceContext index 4fe7e01..8e56de8 100644 --- a/modules/injection/cdi/src/main/resources/META-INF/services/org.apache.tamaya.spi.ServiceContext +++ b/modules/injection/cdi/src/main/resources/META-INF/services/org.apache.tamaya.spi.ServiceContext @@ -16,4 +16,4 @@ # specific language governing permissions and limitations # under the License. # -org.apache.tamaya.integration.cdi.CDIAwareServiceContext \ No newline at end of file +org.apache.tamaya.cdi.CDIAwareServiceContext \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/346a4f38/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/ConfigurationProducerFailedInjectionTest.java ---------------------------------------------------------------------- diff --git a/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/ConfigurationProducerFailedInjectionTest.java b/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/ConfigurationProducerFailedInjectionTest.java new file mode 100644 index 0000000..a590c0d --- /dev/null +++ b/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/ConfigurationProducerFailedInjectionTest.java @@ -0,0 +1,33 @@ +/* + * 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.cdi; + +import org.apache.openejb.OpenEjbContainer; +import org.junit.Test; + +import javax.ejb.embeddable.EJBContainer; + +public class ConfigurationProducerFailedInjectionTest { + + @Test(expected = OpenEjbContainer.AssembleApplicationException.class) + public void notFoundShouldNotDeploy() { + // this explicitly tests that a non resolvable config makes + // the deployment fail and we won't have any failure at runtime + EJBContainer.createEJBContainer(); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/346a4f38/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/ConfigurationProducerTest.java ---------------------------------------------------------------------- diff --git a/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/ConfigurationProducerTest.java b/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/ConfigurationProducerTest.java new file mode 100644 index 0000000..127deb2 --- /dev/null +++ b/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/ConfigurationProducerTest.java @@ -0,0 +1,171 @@ +/* + * 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.cdi; + +import org.apache.openejb.jee.EjbJar; +import org.apache.openejb.junit.ApplicationComposer; +import org.apache.openejb.testing.Classes; +import org.apache.openejb.testing.Module; +import org.apache.tamaya.cdi.ConfigurationProducer; +import org.apache.tamaya.cdi.TamayaCDIAccessor; +import org.apache.tamaya.cdi.TamayaCDIInjectionExtension; +import org.apache.tamaya.inject.api.Config; +import org.junit.Test; +import org.junit.runner.RunWith; + +import javax.inject.Inject; +import java.io.File; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +@RunWith(ApplicationComposer.class) +public class ConfigurationProducerTest { + + @Module + @Classes(cdi = true, value = { + AllTypes.class, + TamayaCDIInjectionExtension.class, TamayaCDIAccessor.class, + ConfigurationProducer.class + }) + public EjbJar jar() { + return new EjbJar("config"); + } + + @Inject + private AllTypes allTypes; + + @Test + public void defaultValues() { + assertNotNull(allTypes); + assertEquals("defaultString", allTypes.getDefaultString()); + assertEquals(new File("./"), allTypes.getDefaultFile()); +// assertEquals(new Duration("2 hours and 54 minutes"), allTypes.getDefaultDuration()); + assertEquals(true, allTypes.getDefaultBoolean()); + assertEquals(45, (int) allTypes.getDefaultInteger()); + } + + @Test + public void actualPropertyValues() { + assertNotNull(allTypes); + assertEquals("hello", allTypes.getString()); + assertEquals(new File("./conf"), allTypes.getFile()); +// assertEquals(new Duration("10 minutes and 57 seconds"), allTypes.getDuration()); + assertEquals(true, allTypes.getaBoolean()); + assertEquals(123, (int) allTypes.getInteger()); + } + + static class AllTypes { + + @Inject + @Config(value = "string.value", defaultValue = "defaultString") + private String string; + + @Inject + @Config(value = "defaultString.value", defaultValue = "defaultString") + private String defaultString; + + @Inject + @Config(value = "file.value", defaultValue = "./") + private File file; + + @Inject + @Config(value = "defaultFile.value", defaultValue = "./") + private File defaultFile; + +// @Inject +// @Config(value = "duration.value", defaultValue = "2 hours and 54 minutes") +// private Duration duration; +// +// @Inject +// @Config(value = "defaultDuration.value", defaultValue = "2 hours and 54 minutes") +// private Duration defaultDuration; + + @Inject + @Config(value = "boolean.value", defaultValue = "true") + private Boolean aBoolean; + + @Inject + @Config(value = "defaultBoolean.value", defaultValue = "true") + private Boolean defaultBoolean; + + @Inject + @Config(value = "integer.value", defaultValue = "45") + private Integer integer; + + @Inject + @Config(value = "defaultInteger.value", defaultValue = "45") + private Integer defaultInteger; + + public String getString() { + return string; + } + + public File getFile() { + return file; + } + +// public Duration getDuration() { +// return duration; +// } + + public Boolean getaBoolean() { + return aBoolean; + } + + public Integer getInteger() { + return integer; + } + + public String getDefaultString() { + return defaultString; + } + + public File getDefaultFile() { + return defaultFile; + } + +// public Duration getDefaultDuration() { +// return defaultDuration; +// } + + public Boolean getDefaultBoolean() { + return defaultBoolean; + } + + public Integer getDefaultInteger() { + return defaultInteger; + } + + @Override + public String toString() { + return "AllTypes{" + + "string='" + string + '\'' + + ", defaultString='" + defaultString + '\'' + + ", file=" + file + + ", defaultFile=" + defaultFile + +// ", duration=" + duration + +// ", defaultDuration=" + defaultDuration + + ", aBoolean=" + aBoolean + + ", defaultBoolean=" + defaultBoolean + + ", integer=" + integer + + ", defaultInteger=" + defaultInteger + + '}'; + } + } + +} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/346a4f38/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/ConfigurationResolverTest.java ---------------------------------------------------------------------- diff --git a/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/ConfigurationResolverTest.java b/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/ConfigurationResolverTest.java new file mode 100644 index 0000000..f7e501d --- /dev/null +++ b/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/ConfigurationResolverTest.java @@ -0,0 +1,112 @@ +///* +// * 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.cdi; +// +//import org.apache.openejb.loader.SystemInstance; +//import org.junit.Before; +//import org.junit.Test; +// +//import static org.junit.Assert.*; +// +//public class ConfigurationResolverTest { +// +// private ConfigurationResolver resolver; +// +// @Before +// public void cleanEnv() { +// SystemInstance.reset(); +// System.clearProperty("environment"); +// +// resolver = new ConfigurationResolver(); +// } +// +// @Test +// public void defaultEnvironment() { +// assertEquals("test", resolver.getEnvironment()); +// } +// +// @Test +// public void overrideDefaultEnvironment() { +// System.setProperty("environment", "dev"); +// +// // don't use the field cause before is invoked before we have a chance to set the environment +// assertEquals("dev", new ConfigurationResolver().getEnvironment()); +// } +// +// @Test +// public void isResolvable() { +// +// { // precondition +// try { +// resolver.isResolvableConfig(null, "value"); +// fail("a null key is not resolvable"); +// +// } catch (final NullPointerException e) { +// // expected +// } +// } +// { // precondition +// try { +// resolver.isResolvableConfig("key", null); +// fail("a null default value is not resolvable"); +// +// } catch (final NullPointerException e) { +// // expected +// } +// } +// +// // loaded from test.properties +// assertTrue(resolver.isResolvableConfig("remote.wsdl.location", "")); +// assertFalse(resolver.isResolvableConfig("something", "")); +// +// // loaded from base.properties +// assertTrue(resolver.isResolvableConfig("remote.username", "")); +// assertFalse(resolver.isResolvableConfig("bla", "")); +// } +// +// @Test +// public void found() { +// +// { // precondition +// try { +// resolver.isResolvableConfig(null, "value"); +// fail("a null key is not resolvable"); +// +// } catch (final NullPointerException e) { +// // expected +// } +// } +// { // precondition +// try { +// resolver.isResolvableConfig("key", null); +// fail("a null default value is not resolvable"); +// +// } catch (final NullPointerException e) { +// // expected +// } +// } +// +// // loaded from test.properties +// assertEquals("classpath:/service-wsdl.xml", resolver.resolve("remote.wsdl.location", "")); +// assertEquals("something-else", resolver.resolve("something", "something-else")); +// +// // loaded from base.properties +// assertEquals("joecool", resolver.resolve("remote.username", "")); +// assertEquals("blabla", resolver.resolve("bla", "blabla")); +// } +// +//} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/346a4f38/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/ConfiguredClass.java ---------------------------------------------------------------------- diff --git a/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/ConfiguredClass.java b/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/ConfiguredClass.java new file mode 100644 index 0000000..5d71d5d --- /dev/null +++ b/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/ConfiguredClass.java @@ -0,0 +1,111 @@ +/* + * + * 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. + * + */ +package org.apache.tamaya.cdi; + +import org.apache.tamaya.inject.api.Config; + +import javax.inject.Singleton; +import java.math.BigDecimal; + +/** + * Class to be loaded from CDI to ensure fields are correctly configured using CDI injection mechanisms. + */ +@Singleton +public class ConfiguredClass{ + + @Config + private String testProperty; + + @Config(value = {"a.b.c.key1","a.b.c.key2","a.b.c.key3"}, defaultValue = "The current \\${JAVA_HOME} env property is ${env:JAVA_HOME}.") + String value1; + + @Config({"foo","a.b.c.key2"}) + private String value2; + + @Config(defaultValue = "N/A") + private String runtimeVersion; + + @Config(defaultValue = "${sys:java.version}") + private String javaVersion2; + + @Config(defaultValue = "5") + private Integer int1; + + @Config + private int int2; + + @Config + private boolean booleanT; + + @Config("BD") + private BigDecimal bigNumber; + + @Config("double1") + private double doubleValue; + + public String getTestProperty() { + return testProperty; + } + + public String getValue1() { + return value1; + } + + public String getValue2() { + return value2; + } + + public String getRuntimeVersion() { + return runtimeVersion; + } + + public String getJavaVersion2() { + return javaVersion2; + } + + public Integer getInt1() { + return int1; + } + + public int getInt2() { + return int2; + } + + public boolean isBooleanT() { + return booleanT; + } + + public BigDecimal getBigNumber() { + return bigNumber; + } + + public double getDoubleValue() { + return doubleValue; + } + + @Override + public String toString(){ + return super.toString() + ": testProperty="+testProperty+", value1="+value1+", value2="+value2 + +", int1="+int1+", int2="+int2+", booleanT="+booleanT+", bigNumber="+bigNumber + +", runtimeVersion="+runtimeVersion+", javaVersion2="+javaVersion2; + } + +} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/346a4f38/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/ConfiguredTest.java ---------------------------------------------------------------------- diff --git a/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/ConfiguredTest.java b/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/ConfiguredTest.java new file mode 100644 index 0000000..2c36a52 --- /dev/null +++ b/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/ConfiguredTest.java @@ -0,0 +1,83 @@ +/* + * 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. + * + */ +package org.apache.tamaya.cdi; + +import org.apache.deltaspike.testcontrol.api.TestControl; +import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner; +import org.hamcrest.MatcherAssert; +import org.junit.Test; +import org.junit.runner.RunWith; + +import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.inject.spi.CDI; +import javax.inject.Singleton; + +import static org.hamcrest.core.Is.is; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +/** + * Tests for CDI integration. + */ +@RunWith(CdiTestRunner.class) +@TestControl(startScopes = {ApplicationScoped.class, Singleton.class}) +public class ConfiguredTest{ + + @Test + public void test_Configuration_is_injected_correctly(){ + ConfiguredClass item = CDI.current().select(ConfiguredClass.class).get(); + System.out.println("********************************************"); + System.out.println(item); + System.out.println("********************************************"); + double actual = 1234.5678; + MatcherAssert.assertThat(item.getDoubleValue(), is(actual)); + } + + @Test + public void test_Default_injections_are_accessible(){ + InjectedClass injectedClass = CDI.current().select(InjectedClass.class).get(); + System.out.println("********************************************"); + System.out.println(injectedClass); + System.out.println("********************************************"); + assertNotNull(injectedClass.builder1); + assertNotNull(injectedClass.builder2); + assertNotNull(injectedClass.config); + assertNotNull(injectedClass.configContext); + } + + @Test + public void test_Injected_builders_are_notSame(){ + InjectedClass injectedClass = CDI.current().select(InjectedClass.class).get(); + assertTrue(injectedClass.builder1 != injectedClass.builder2); + } + + @Test + public void test_Injected_configs_are_same(){ + InjectedClass injectedClass = CDI.current().select(InjectedClass.class).get(); + assertTrue(injectedClass.config == injectedClass.config2); + } + + @Test + public void test_Injected_configContexts_are_same(){ + InjectedClass injectedClass = CDI.current().select(InjectedClass.class).get(); + assertTrue(injectedClass.configContext == injectedClass.configContext2); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/346a4f38/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/EnvironmentsTest.java ---------------------------------------------------------------------- diff --git a/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/EnvironmentsTest.java b/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/EnvironmentsTest.java new file mode 100644 index 0000000..b697d27 --- /dev/null +++ b/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/EnvironmentsTest.java @@ -0,0 +1,83 @@ +///* +// * 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.integration.cdi; +// +//import org.junit.Test; +// +//import java.util.Map; +//import java.util.Properties; +// +//import static org.junit.Assert.assertEquals; +// +///** +// * Tests the related environment properties exist +// */ +//public class EnvironmentsTest { +// +// @Test +// public void testGetProperties() throws Exception { +// +// final Properties test = Environments.getProperties("test"); +// +// // loaded from test.properties +// assertEquals("classpath:/test-service-wsdl.xml", test.getProperty("remote.wsdl.location")); +// +// // loaded from base.properties +// assertEquals("joecool", test.getProperty("remote.username")); +// } +// +// @Test(expected = IllegalArgumentException.class) +// public void noEnvFound() { +// Environments.getProperties("does not exists"); +// } +// +// @Test +// public void dev() throws Exception { +// +// final Properties test = Environments.getProperties("dev"); +// +// assertEquals("org.apache.openejb.cipher.StaticDESPasswordCipher", test.getProperty("cipher")); +// assertEquals("NjAq6q2agYVnvSMz+eYUZg==", test.getProperty("remote.password")); +// assertEquals("1443", test.getProperty("remote.port")); +// assertEquals("https://srv1114.supertribe.org:1443/remote/service/url", test.getProperty("remote.target.url")); +// assertEquals("srv1114.supertribe.org:1443", test.getProperty("remote.address")); +// assertEquals("srv1114.supertribe.org", test.getProperty("remote.host")); +// assertEquals("classpath:/service-wsdl.xml", test.getProperty("remote.wsdl.location")); +// assertEquals("joecool", test.getProperty("remote.username")); +// } +// +// @Test +// public void cert() throws Exception { +// final Properties test = Environments.getProperties("cert"); +// assertEquals("srv1016.supertribe.org", test.getProperty("remote.host")); +// assertEquals("joecool", test.getProperty("remote.username")); +// } +// +// @Test +// public void prod() throws Exception { +// final Properties test = Environments.getProperties("prod"); +// assertEquals("remotedb001.supertribe.org", test.getProperty("remote.host")); +// assertEquals("joecool", test.getProperty("remote.username")); +// } +// +// +// private static void generateAsserts(Properties test) { +// for (Map.Entry<Object, Object> entry : test.entrySet()) { +// System.out.printf("assertEquals(\"%s\", test.getProperty(\"%s\"));%n", entry.getProperty(), entry.getKey()); +// } +// } +//} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/346a4f38/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/InjectedClass.java ---------------------------------------------------------------------- diff --git a/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/InjectedClass.java b/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/InjectedClass.java new file mode 100644 index 0000000..f3e746b --- /dev/null +++ b/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/InjectedClass.java @@ -0,0 +1,62 @@ +/* + * 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. + * + */ +package org.apache.tamaya.cdi; + +import org.apache.tamaya.Configuration; +import org.apache.tamaya.spi.ConfigurationContext; +import org.apache.tamaya.spi.ConfigurationContextBuilder; + +import javax.inject.Inject; +import javax.inject.Singleton; + +/** + * Class loaded by CDI to test correct injection of Configuration API artifacts. + */ +@Singleton +public class InjectedClass { + + @Inject + Configuration config; + + @Inject + Configuration config2; + + @Inject + ConfigurationContext configContext; + + @Inject + ConfigurationContext configContext2; + + @Inject + ConfigurationContextBuilder builder1; + + @Inject + ConfigurationContextBuilder builder2; + + @Override + public String toString() { + return "InjectedClass{" + + "config=" + config + + ", configContext=" + configContext + + ", builder1=" + builder1 + + ", builder2=" + builder2 + + '}'; + } +} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/346a4f38/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/InterpolationTest.java ---------------------------------------------------------------------- diff --git a/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/InterpolationTest.java b/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/InterpolationTest.java new file mode 100644 index 0000000..9b3ca4d --- /dev/null +++ b/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/InterpolationTest.java @@ -0,0 +1,62 @@ +/* + * 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.cdi; +// +//import org.junit.Test; +//import org.tomitribe.util.IO; +// +//import java.net.URL; +//import java.util.Properties; +// +//import static org.junit.Assert.assertEquals; +// +//public class InterpolationTest { +// +// @Test +// public void testInterpolate() throws Exception { +// final Properties interpolated; +// { +// final Properties properties = new Properties(); +// properties.setProperty("foo.host", "localhost"); +// properties.setProperty("foo.port", "1234"); +// properties.setProperty("address", "http://${foo.host}:${foo.port}"); +// properties.setProperty("url", "${address}/webapp"); +// properties.setProperty("urlUnchanged", "${not an address}/webapp"); +// +// interpolated = Interpolation.interpolate(properties); +// } +// +// assertEquals("localhost", interpolated.getProperty("foo.host")); +// assertEquals("1234", interpolated.getProperty("foo.port")); +// assertEquals("http://localhost:1234", interpolated.getProperty("address")); +// assertEquals("http://localhost:1234/webapp", interpolated.getProperty("url")); +// assertEquals("${not an address}/webapp", interpolated.getProperty("urlUnchanged")); +// } +// +// @Test +// public void test() throws Exception { +// +// final ClassLoader loader = Thread.currentThread().getContextClassLoader(); +// +// final URL resource = loader.getResource("test.properties"); +// final Properties properties = Interpolation.interpolate(IO.readProperties(resource)); +// +// //remote.wsdl.location = classpath:/lx01116-zhr-active-partner-service-wsdl.xml +// assertEquals("classpath:/test-service-wsdl.xml", properties.getProperty("remote.wsdl.location")); +// } +// +//} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/346a4f38/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/NotFoundNoDefault.java ---------------------------------------------------------------------- diff --git a/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/NotFoundNoDefault.java b/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/NotFoundNoDefault.java new file mode 100644 index 0000000..56151ec --- /dev/null +++ b/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/NotFoundNoDefault.java @@ -0,0 +1,78 @@ +///* +// * 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.integration.cdi; +// +//import org.apache.tamaya.inject.api.Config; +//import org.tomitribe.util.Duration; +// +//import javax.inject.Inject; +//import java.io.File; +// +//public class NotFoundNoDefault { +// +// @Inject +// @Config("string.bla") +// private String string; +// +// @Inject +// @Config("file.bla") +// private File file; +// +// @Inject +// @Config("duration.bla") +// private Duration duration; +// +// @Inject +// @Config("boolean.bla") +// private Boolean aBoolean; +// +// @Inject +// @Config("integer.bla") +// private Integer integer; +// +// public String getString() { +// return string; +// } +// +// public File getFile() { +// return file; +// } +// +// public Duration getDuration() { +// return duration; +// } +// +// public Boolean getaBoolean() { +// return aBoolean; +// } +// +// public Integer getInteger() { +// return integer; +// } +// +// @Override +// public String toString() { +// return "NotFoundNoDefault{" + +// "string='" + string + '\'' + +// ", file=" + file + +// ", duration=" + duration + +// ", aBoolean=" + aBoolean + +// ", integer=" + integer + +// '}'; +// } +// +// } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/346a4f38/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/cfg/ProvidedPropertySource.java ---------------------------------------------------------------------- diff --git a/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/cfg/ProvidedPropertySource.java b/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/cfg/ProvidedPropertySource.java new file mode 100644 index 0000000..8ed0588 --- /dev/null +++ b/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/cfg/ProvidedPropertySource.java @@ -0,0 +1,66 @@ +/* + * 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. + * + */ +package org.apache.tamaya.cdi.cfg; + +import org.apache.tamaya.spi.PropertySource; +import org.apache.tamaya.spi.PropertyValue; + +import javax.enterprise.inject.Vetoed; +import java.util.HashMap; +import java.util.Map; + +/** + * Created by Anatole on 17.09.2015. + */ +@Vetoed +class ProvidedPropertySource implements PropertySource{ + + final Map<String,PropertyValue> config = new HashMap<>(); + + public ProvidedPropertySource(){ + config.put("a.b.c.key3", PropertyValue.of("a.b.c.key3","keys current a.b.c.key3",getName())); + config.put("a.b.c.key4", PropertyValue.of("a.b.c.key4","keys current a.b.c.key4", getName())); + } + + @Override + public int getOrdinal() { + return 10; + } + + @Override + public String getName() { + return getClass().getName(); + } + + @Override + public PropertyValue get(String key) { + return config.get(key); + } + + @Override + public Map<String, PropertyValue> getProperties() { + return config; + } + + @Override + public boolean isScannable() { + return true; + } +} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/346a4f38/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/cfg/TestConfigProvider.java ---------------------------------------------------------------------- diff --git a/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/cfg/TestConfigProvider.java b/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/cfg/TestConfigProvider.java new file mode 100644 index 0000000..036b9da --- /dev/null +++ b/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/cfg/TestConfigProvider.java @@ -0,0 +1,45 @@ +/* + * 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. + */ +package org.apache.tamaya.cdi.cfg; + +import org.apache.tamaya.spi.PropertySource; +import org.apache.tamaya.spi.PropertySourceProvider; + +import javax.enterprise.context.ApplicationScoped; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +/** + * Created by Anatole on 29.09.2014. + */ +@ApplicationScoped +public class TestConfigProvider implements PropertySourceProvider { + + private List<PropertySource> configs = new ArrayList<>(); + + public TestConfigProvider(){ + configs.add(new ProvidedPropertySource()); + } + + @Override + public Collection<PropertySource> getPropertySources() { + return configs; + } +} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/346a4f38/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/cfg/TestPropertySource.java ---------------------------------------------------------------------- diff --git a/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/cfg/TestPropertySource.java b/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/cfg/TestPropertySource.java new file mode 100644 index 0000000..e31070a --- /dev/null +++ b/modules/injection/cdi/src/test/java/org/apache/tamaya/cdi/cfg/TestPropertySource.java @@ -0,0 +1,82 @@ +/* + * 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. + * + */ +package org.apache.tamaya.cdi.cfg; + +import org.apache.tamaya.spi.PropertySource; +import org.apache.tamaya.spi.PropertyValue; + +import javax.inject.Singleton; +import java.util.HashMap; +import java.util.Map; + +/** + * Created by Anatole on 17.09.2015. + */ +@Singleton +public class TestPropertySource implements PropertySource{ + + final Map<String,String> config = new HashMap<>(); + + public TestPropertySource(){ + config.put("a.b.c.key1", "keys current a.b.c.key1"); + config.put("a.b.c.key2", "keys current a.b.c.key2"); + config.put("a.b.key3", "keys current a.b.key3"); + config.put("a.b.key4", "keys current a.b.key4"); + config.put("a.key5", "keys current a.key5"); + config.put("a.key6", "keys current a.key6"); + config.put("int1", "123456"); + config.put("int2", "111222"); + config.put("testProperty", "testPropertyValue!"); + config.put("booleanT", "true"); + config.put("double1", "1234.5678"); + config.put("BD", "123456789123456789123456789123456789.123456789123456789123456789123456789"); + config.put("testProperty", "keys current testProperty"); + config.put("runtimeVersion", "${java.version}"); + config.put("{meta}source.type:"+getClass().getName(), "PropertySource"); + } + + public int getOrdinal() { + return 10; + } + + @Override + public String getName() { + return getClass().getName(); + } + + @Override + public PropertyValue get(String key) { + String val = this.config.get(key); + if(val!=null) { + return PropertyValue.of(key, val, getName()); + } + return null; + } + + @Override + public Map<String, PropertyValue> getProperties() { + return PropertyValue.map(config ,getName()); + } + + @Override + public boolean isScannable() { + return true; + } +} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/346a4f38/modules/injection/cdi/src/test/java/org/apache/tamaya/integration/cdi/ConfigurationProducerFailedInjectionTest.java ---------------------------------------------------------------------- diff --git a/modules/injection/cdi/src/test/java/org/apache/tamaya/integration/cdi/ConfigurationProducerFailedInjectionTest.java b/modules/injection/cdi/src/test/java/org/apache/tamaya/integration/cdi/ConfigurationProducerFailedInjectionTest.java deleted file mode 100644 index 6bfda3a..0000000 --- a/modules/injection/cdi/src/test/java/org/apache/tamaya/integration/cdi/ConfigurationProducerFailedInjectionTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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.integration.cdi; - -import org.apache.openejb.OpenEjbContainer; -import org.junit.Test; - -import javax.ejb.embeddable.EJBContainer; - -public class ConfigurationProducerFailedInjectionTest { - - @Test(expected = OpenEjbContainer.AssembleApplicationException.class) - public void notFoundShouldNotDeploy() { - // this explicitly tests that a non resolvable config makes - // the deployment fail and we won't have any failure at runtime - EJBContainer.createEJBContainer(); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/346a4f38/modules/injection/cdi/src/test/java/org/apache/tamaya/integration/cdi/ConfigurationProducerTest.java ---------------------------------------------------------------------- diff --git a/modules/injection/cdi/src/test/java/org/apache/tamaya/integration/cdi/ConfigurationProducerTest.java b/modules/injection/cdi/src/test/java/org/apache/tamaya/integration/cdi/ConfigurationProducerTest.java deleted file mode 100644 index b32ef33..0000000 --- a/modules/injection/cdi/src/test/java/org/apache/tamaya/integration/cdi/ConfigurationProducerTest.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * 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.integration.cdi; - -import org.apache.openejb.jee.EjbJar; -import org.apache.openejb.junit.ApplicationComposer; -import org.apache.openejb.testing.Classes; -import org.apache.openejb.testing.Module; -import org.apache.tamaya.inject.api.Config; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.tomitribe.util.Duration; - -import javax.inject.Inject; -import java.io.File; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -@RunWith(ApplicationComposer.class) -public class ConfigurationProducerTest { - - @Module - @Classes(cdi = true, value = { - AllTypes.class, - TamayaCDIInjectionExtension.class, TamayaCDIAccessor.class, - ConfigurationProducer.class - }) - public EjbJar jar() { - return new EjbJar("config"); - } - - @Inject - private AllTypes allTypes; - - @Test - public void defaultValues() { - assertNotNull(allTypes); - assertEquals("defaultString", allTypes.getDefaultString()); - assertEquals(new File("./"), allTypes.getDefaultFile()); -// assertEquals(new Duration("2 hours and 54 minutes"), allTypes.getDefaultDuration()); - assertEquals(true, allTypes.getDefaultBoolean()); - assertEquals(45, (int) allTypes.getDefaultInteger()); - } - - @Test - public void actualPropertyValues() { - assertNotNull(allTypes); - assertEquals("hello", allTypes.getString()); - assertEquals(new File("./conf"), allTypes.getFile()); -// assertEquals(new Duration("10 minutes and 57 seconds"), allTypes.getDuration()); - assertEquals(true, allTypes.getaBoolean()); - assertEquals(123, (int) allTypes.getInteger()); - } - - static class AllTypes { - - @Inject - @Config(value = "string.value", defaultValue = "defaultString") - private String string; - - @Inject - @Config(value = "defaultString.value", defaultValue = "defaultString") - private String defaultString; - - @Inject - @Config(value = "file.value", defaultValue = "./") - private File file; - - @Inject - @Config(value = "defaultFile.value", defaultValue = "./") - private File defaultFile; - -// @Inject -// @Config(value = "duration.value", defaultValue = "2 hours and 54 minutes") -// private Duration duration; -// -// @Inject -// @Config(value = "defaultDuration.value", defaultValue = "2 hours and 54 minutes") -// private Duration defaultDuration; - - @Inject - @Config(value = "boolean.value", defaultValue = "true") - private Boolean aBoolean; - - @Inject - @Config(value = "defaultBoolean.value", defaultValue = "true") - private Boolean defaultBoolean; - - @Inject - @Config(value = "integer.value", defaultValue = "45") - private Integer integer; - - @Inject - @Config(value = "defaultInteger.value", defaultValue = "45") - private Integer defaultInteger; - - public String getString() { - return string; - } - - public File getFile() { - return file; - } - -// public Duration getDuration() { -// return duration; -// } - - public Boolean getaBoolean() { - return aBoolean; - } - - public Integer getInteger() { - return integer; - } - - public String getDefaultString() { - return defaultString; - } - - public File getDefaultFile() { - return defaultFile; - } - -// public Duration getDefaultDuration() { -// return defaultDuration; -// } - - public Boolean getDefaultBoolean() { - return defaultBoolean; - } - - public Integer getDefaultInteger() { - return defaultInteger; - } - - @Override - public String toString() { - return "AllTypes{" + - "string='" + string + '\'' + - ", defaultString='" + defaultString + '\'' + - ", file=" + file + - ", defaultFile=" + defaultFile + -// ", duration=" + duration + -// ", defaultDuration=" + defaultDuration + - ", aBoolean=" + aBoolean + - ", defaultBoolean=" + defaultBoolean + - ", integer=" + integer + - ", defaultInteger=" + defaultInteger + - '}'; - } - } - -} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/346a4f38/modules/injection/cdi/src/test/java/org/apache/tamaya/integration/cdi/ConfigurationResolverTest.java ---------------------------------------------------------------------- diff --git a/modules/injection/cdi/src/test/java/org/apache/tamaya/integration/cdi/ConfigurationResolverTest.java b/modules/injection/cdi/src/test/java/org/apache/tamaya/integration/cdi/ConfigurationResolverTest.java deleted file mode 100644 index 1c551b2..0000000 --- a/modules/injection/cdi/src/test/java/org/apache/tamaya/integration/cdi/ConfigurationResolverTest.java +++ /dev/null @@ -1,112 +0,0 @@ -///* -// * 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.integration.cdi; -// -//import org.apache.openejb.loader.SystemInstance; -//import org.junit.Before; -//import org.junit.Test; -// -//import static org.junit.Assert.*; -// -//public class ConfigurationResolverTest { -// -// private ConfigurationResolver resolver; -// -// @Before -// public void cleanEnv() { -// SystemInstance.reset(); -// System.clearProperty("environment"); -// -// resolver = new ConfigurationResolver(); -// } -// -// @Test -// public void defaultEnvironment() { -// assertEquals("test", resolver.getEnvironment()); -// } -// -// @Test -// public void overrideDefaultEnvironment() { -// System.setProperty("environment", "dev"); -// -// // don't use the field cause before is invoked before we have a chance to set the environment -// assertEquals("dev", new ConfigurationResolver().getEnvironment()); -// } -// -// @Test -// public void isResolvable() { -// -// { // precondition -// try { -// resolver.isResolvableConfig(null, "value"); -// fail("a null key is not resolvable"); -// -// } catch (final NullPointerException e) { -// // expected -// } -// } -// { // precondition -// try { -// resolver.isResolvableConfig("key", null); -// fail("a null default value is not resolvable"); -// -// } catch (final NullPointerException e) { -// // expected -// } -// } -// -// // loaded from test.properties -// assertTrue(resolver.isResolvableConfig("remote.wsdl.location", "")); -// assertFalse(resolver.isResolvableConfig("something", "")); -// -// // loaded from base.properties -// assertTrue(resolver.isResolvableConfig("remote.username", "")); -// assertFalse(resolver.isResolvableConfig("bla", "")); -// } -// -// @Test -// public void found() { -// -// { // precondition -// try { -// resolver.isResolvableConfig(null, "value"); -// fail("a null key is not resolvable"); -// -// } catch (final NullPointerException e) { -// // expected -// } -// } -// { // precondition -// try { -// resolver.isResolvableConfig("key", null); -// fail("a null default value is not resolvable"); -// -// } catch (final NullPointerException e) { -// // expected -// } -// } -// -// // loaded from test.properties -// assertEquals("classpath:/service-wsdl.xml", resolver.resolve("remote.wsdl.location", "")); -// assertEquals("something-else", resolver.resolve("something", "something-else")); -// -// // loaded from base.properties -// assertEquals("joecool", resolver.resolve("remote.username", "")); -// assertEquals("blabla", resolver.resolve("bla", "blabla")); -// } -// -//} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/346a4f38/modules/injection/cdi/src/test/java/org/apache/tamaya/integration/cdi/ConfiguredClass.java ---------------------------------------------------------------------- diff --git a/modules/injection/cdi/src/test/java/org/apache/tamaya/integration/cdi/ConfiguredClass.java b/modules/injection/cdi/src/test/java/org/apache/tamaya/integration/cdi/ConfiguredClass.java deleted file mode 100644 index 4ae8b07..0000000 --- a/modules/injection/cdi/src/test/java/org/apache/tamaya/integration/cdi/ConfiguredClass.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * - * 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. - * - */ -package org.apache.tamaya.integration.cdi; - -import org.apache.tamaya.inject.api.Config; - -import javax.inject.Singleton; -import java.math.BigDecimal; - -/** - * Class to be loaded from CDI to ensure fields are correctly configured using CDI injection mechanisms. - */ -@Singleton -public class ConfiguredClass{ - - @Config - private String testProperty; - - @Config(value = {"a.b.c.key1","a.b.c.key2","a.b.c.key3"}, defaultValue = "The current \\${JAVA_HOME} env property is ${env:JAVA_HOME}.") - String value1; - - @Config({"foo","a.b.c.key2"}) - private String value2; - - @Config(defaultValue = "N/A") - private String runtimeVersion; - - @Config(defaultValue = "${sys:java.version}") - private String javaVersion2; - - @Config(defaultValue = "5") - private Integer int1; - - @Config - private int int2; - - @Config - private boolean booleanT; - - @Config("BD") - private BigDecimal bigNumber; - - @Config("double1") - private double doubleValue; - - public String getTestProperty() { - return testProperty; - } - - public String getValue1() { - return value1; - } - - public String getValue2() { - return value2; - } - - public String getRuntimeVersion() { - return runtimeVersion; - } - - public String getJavaVersion2() { - return javaVersion2; - } - - public Integer getInt1() { - return int1; - } - - public int getInt2() { - return int2; - } - - public boolean isBooleanT() { - return booleanT; - } - - public BigDecimal getBigNumber() { - return bigNumber; - } - - public double getDoubleValue() { - return doubleValue; - } - - @Override - public String toString(){ - return super.toString() + ": testProperty="+testProperty+", value1="+value1+", value2="+value2 - +", int1="+int1+", int2="+int2+", booleanT="+booleanT+", bigNumber="+bigNumber - +", runtimeVersion="+runtimeVersion+", javaVersion2="+javaVersion2; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/346a4f38/modules/injection/cdi/src/test/java/org/apache/tamaya/integration/cdi/ConfiguredTest.java ---------------------------------------------------------------------- diff --git a/modules/injection/cdi/src/test/java/org/apache/tamaya/integration/cdi/ConfiguredTest.java b/modules/injection/cdi/src/test/java/org/apache/tamaya/integration/cdi/ConfiguredTest.java deleted file mode 100644 index 69e8ef9..0000000 --- a/modules/injection/cdi/src/test/java/org/apache/tamaya/integration/cdi/ConfiguredTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * 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. - * - */ -package org.apache.tamaya.integration.cdi; - -import org.apache.deltaspike.testcontrol.api.TestControl; -import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner; -import org.hamcrest.MatcherAssert; -import org.junit.Test; -import org.junit.runner.RunWith; - -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.inject.spi.CDI; -import javax.inject.Singleton; - -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -/** - * Tests for CDI integration. - */ -@RunWith(CdiTestRunner.class) -@TestControl(startScopes = {ApplicationScoped.class, Singleton.class}) -public class ConfiguredTest{ - - @Test - public void test_Configuration_is_injected_correctly(){ - ConfiguredClass item = CDI.current().select(ConfiguredClass.class).get(); - System.out.println("********************************************"); - System.out.println(item); - System.out.println("********************************************"); - double actual = 1234.5678; - MatcherAssert.assertThat(item.getDoubleValue(), is(actual)); - } - - @Test - public void test_Default_injections_are_accessible(){ - InjectedClass injectedClass = CDI.current().select(InjectedClass.class).get(); - System.out.println("********************************************"); - System.out.println(injectedClass); - System.out.println("********************************************"); - assertNotNull(injectedClass.builder1); - assertNotNull(injectedClass.builder2); - assertNotNull(injectedClass.config); - assertNotNull(injectedClass.configContext); - } - - @Test - public void test_Injected_builders_are_notSame(){ - InjectedClass injectedClass = CDI.current().select(InjectedClass.class).get(); - assertTrue(injectedClass.builder1 != injectedClass.builder2); - } - - @Test - public void test_Injected_configs_are_same(){ - InjectedClass injectedClass = CDI.current().select(InjectedClass.class).get(); - assertTrue(injectedClass.config == injectedClass.config2); - } - - @Test - public void test_Injected_configContexts_are_same(){ - InjectedClass injectedClass = CDI.current().select(InjectedClass.class).get(); - assertTrue(injectedClass.configContext == injectedClass.configContext2); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/346a4f38/modules/injection/cdi/src/test/java/org/apache/tamaya/integration/cdi/EnvironmentsTest.java ---------------------------------------------------------------------- diff --git a/modules/injection/cdi/src/test/java/org/apache/tamaya/integration/cdi/EnvironmentsTest.java b/modules/injection/cdi/src/test/java/org/apache/tamaya/integration/cdi/EnvironmentsTest.java deleted file mode 100644 index b697d27..0000000 --- a/modules/injection/cdi/src/test/java/org/apache/tamaya/integration/cdi/EnvironmentsTest.java +++ /dev/null @@ -1,83 +0,0 @@ -///* -// * 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.integration.cdi; -// -//import org.junit.Test; -// -//import java.util.Map; -//import java.util.Properties; -// -//import static org.junit.Assert.assertEquals; -// -///** -// * Tests the related environment properties exist -// */ -//public class EnvironmentsTest { -// -// @Test -// public void testGetProperties() throws Exception { -// -// final Properties test = Environments.getProperties("test"); -// -// // loaded from test.properties -// assertEquals("classpath:/test-service-wsdl.xml", test.getProperty("remote.wsdl.location")); -// -// // loaded from base.properties -// assertEquals("joecool", test.getProperty("remote.username")); -// } -// -// @Test(expected = IllegalArgumentException.class) -// public void noEnvFound() { -// Environments.getProperties("does not exists"); -// } -// -// @Test -// public void dev() throws Exception { -// -// final Properties test = Environments.getProperties("dev"); -// -// assertEquals("org.apache.openejb.cipher.StaticDESPasswordCipher", test.getProperty("cipher")); -// assertEquals("NjAq6q2agYVnvSMz+eYUZg==", test.getProperty("remote.password")); -// assertEquals("1443", test.getProperty("remote.port")); -// assertEquals("https://srv1114.supertribe.org:1443/remote/service/url", test.getProperty("remote.target.url")); -// assertEquals("srv1114.supertribe.org:1443", test.getProperty("remote.address")); -// assertEquals("srv1114.supertribe.org", test.getProperty("remote.host")); -// assertEquals("classpath:/service-wsdl.xml", test.getProperty("remote.wsdl.location")); -// assertEquals("joecool", test.getProperty("remote.username")); -// } -// -// @Test -// public void cert() throws Exception { -// final Properties test = Environments.getProperties("cert"); -// assertEquals("srv1016.supertribe.org", test.getProperty("remote.host")); -// assertEquals("joecool", test.getProperty("remote.username")); -// } -// -// @Test -// public void prod() throws Exception { -// final Properties test = Environments.getProperties("prod"); -// assertEquals("remotedb001.supertribe.org", test.getProperty("remote.host")); -// assertEquals("joecool", test.getProperty("remote.username")); -// } -// -// -// private static void generateAsserts(Properties test) { -// for (Map.Entry<Object, Object> entry : test.entrySet()) { -// System.out.printf("assertEquals(\"%s\", test.getProperty(\"%s\"));%n", entry.getProperty(), entry.getKey()); -// } -// } -//} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/346a4f38/modules/injection/cdi/src/test/java/org/apache/tamaya/integration/cdi/InjectedClass.java ---------------------------------------------------------------------- diff --git a/modules/injection/cdi/src/test/java/org/apache/tamaya/integration/cdi/InjectedClass.java b/modules/injection/cdi/src/test/java/org/apache/tamaya/integration/cdi/InjectedClass.java deleted file mode 100644 index 9b7bd23..0000000 --- a/modules/injection/cdi/src/test/java/org/apache/tamaya/integration/cdi/InjectedClass.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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. - * - */ -package org.apache.tamaya.integration.cdi; - -import org.apache.tamaya.Configuration; -import org.apache.tamaya.spi.ConfigurationContext; -import org.apache.tamaya.spi.ConfigurationContextBuilder; - -import javax.inject.Inject; -import javax.inject.Singleton; - -/** - * Class loaded by CDI to test correct injection of Configuration API artifacts. - */ -@Singleton -public class InjectedClass { - - @Inject - Configuration config; - - @Inject - Configuration config2; - - @Inject - ConfigurationContext configContext; - - @Inject - ConfigurationContext configContext2; - - @Inject - ConfigurationContextBuilder builder1; - - @Inject - ConfigurationContextBuilder builder2; - - @Override - public String toString() { - return "InjectedClass{" + - "config=" + config + - ", configContext=" + configContext + - ", builder1=" + builder1 + - ", builder2=" + builder2 + - '}'; - } -} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/346a4f38/modules/injection/cdi/src/test/java/org/apache/tamaya/integration/cdi/InterpolationTest.java ---------------------------------------------------------------------- diff --git a/modules/injection/cdi/src/test/java/org/apache/tamaya/integration/cdi/InterpolationTest.java b/modules/injection/cdi/src/test/java/org/apache/tamaya/integration/cdi/InterpolationTest.java deleted file mode 100644 index 56cc8c9..0000000 --- a/modules/injection/cdi/src/test/java/org/apache/tamaya/integration/cdi/InterpolationTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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.integration.cdi; -// -//import org.junit.Test; -//import org.tomitribe.util.IO; -// -//import java.net.URL; -//import java.util.Properties; -// -//import static org.junit.Assert.assertEquals; -// -//public class InterpolationTest { -// -// @Test -// public void testInterpolate() throws Exception { -// final Properties interpolated; -// { -// final Properties properties = new Properties(); -// properties.setProperty("foo.host", "localhost"); -// properties.setProperty("foo.port", "1234"); -// properties.setProperty("address", "http://${foo.host}:${foo.port}"); -// properties.setProperty("url", "${address}/webapp"); -// properties.setProperty("urlUnchanged", "${not an address}/webapp"); -// -// interpolated = Interpolation.interpolate(properties); -// } -// -// assertEquals("localhost", interpolated.getProperty("foo.host")); -// assertEquals("1234", interpolated.getProperty("foo.port")); -// assertEquals("http://localhost:1234", interpolated.getProperty("address")); -// assertEquals("http://localhost:1234/webapp", interpolated.getProperty("url")); -// assertEquals("${not an address}/webapp", interpolated.getProperty("urlUnchanged")); -// } -// -// @Test -// public void test() throws Exception { -// -// final ClassLoader loader = Thread.currentThread().getContextClassLoader(); -// -// final URL resource = loader.getResource("test.properties"); -// final Properties properties = Interpolation.interpolate(IO.readProperties(resource)); -// -// //remote.wsdl.location = classpath:/lx01116-zhr-active-partner-service-wsdl.xml -// assertEquals("classpath:/test-service-wsdl.xml", properties.getProperty("remote.wsdl.location")); -// } -// -//} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/346a4f38/modules/injection/cdi/src/test/java/org/apache/tamaya/integration/cdi/NotFoundNoDefault.java ---------------------------------------------------------------------- diff --git a/modules/injection/cdi/src/test/java/org/apache/tamaya/integration/cdi/NotFoundNoDefault.java b/modules/injection/cdi/src/test/java/org/apache/tamaya/integration/cdi/NotFoundNoDefault.java deleted file mode 100644 index 56151ec..0000000 --- a/modules/injection/cdi/src/test/java/org/apache/tamaya/integration/cdi/NotFoundNoDefault.java +++ /dev/null @@ -1,78 +0,0 @@ -///* -// * 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.integration.cdi; -// -//import org.apache.tamaya.inject.api.Config; -//import org.tomitribe.util.Duration; -// -//import javax.inject.Inject; -//import java.io.File; -// -//public class NotFoundNoDefault { -// -// @Inject -// @Config("string.bla") -// private String string; -// -// @Inject -// @Config("file.bla") -// private File file; -// -// @Inject -// @Config("duration.bla") -// private Duration duration; -// -// @Inject -// @Config("boolean.bla") -// private Boolean aBoolean; -// -// @Inject -// @Config("integer.bla") -// private Integer integer; -// -// public String getString() { -// return string; -// } -// -// public File getFile() { -// return file; -// } -// -// public Duration getDuration() { -// return duration; -// } -// -// public Boolean getaBoolean() { -// return aBoolean; -// } -// -// public Integer getInteger() { -// return integer; -// } -// -// @Override -// public String toString() { -// return "NotFoundNoDefault{" + -// "string='" + string + '\'' + -// ", file=" + file + -// ", duration=" + duration + -// ", aBoolean=" + aBoolean + -// ", integer=" + integer + -// '}'; -// } -// -// } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/346a4f38/modules/injection/cdi/src/test/java/org/apache/tamaya/integration/cdi/cfg/ProvidedPropertySource.java ---------------------------------------------------------------------- diff --git a/modules/injection/cdi/src/test/java/org/apache/tamaya/integration/cdi/cfg/ProvidedPropertySource.java b/modules/injection/cdi/src/test/java/org/apache/tamaya/integration/cdi/cfg/ProvidedPropertySource.java deleted file mode 100644 index 90692f3..0000000 --- a/modules/injection/cdi/src/test/java/org/apache/tamaya/integration/cdi/cfg/ProvidedPropertySource.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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. - * - */ -package org.apache.tamaya.integration.cdi.cfg; - -import org.apache.tamaya.spi.PropertySource; -import org.apache.tamaya.spi.PropertyValue; - -import javax.enterprise.inject.Vetoed; -import java.util.HashMap; -import java.util.Map; - -/** - * Created by Anatole on 17.09.2015. - */ -@Vetoed -class ProvidedPropertySource implements PropertySource{ - - final Map<String,PropertyValue> config = new HashMap<>(); - - public ProvidedPropertySource(){ - config.put("a.b.c.key3", PropertyValue.of("a.b.c.key3","keys current a.b.c.key3",getName())); - config.put("a.b.c.key4", PropertyValue.of("a.b.c.key4","keys current a.b.c.key4", getName())); - } - - @Override - public int getOrdinal() { - return 10; - } - - @Override - public String getName() { - return getClass().getName(); - } - - @Override - public PropertyValue get(String key) { - return config.get(key); - } - - @Override - public Map<String, PropertyValue> getProperties() { - return config; - } - - @Override - public boolean isScannable() { - return true; - } -} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/346a4f38/modules/injection/cdi/src/test/java/org/apache/tamaya/integration/cdi/cfg/TestConfigProvider.java ---------------------------------------------------------------------- diff --git a/modules/injection/cdi/src/test/java/org/apache/tamaya/integration/cdi/cfg/TestConfigProvider.java b/modules/injection/cdi/src/test/java/org/apache/tamaya/integration/cdi/cfg/TestConfigProvider.java deleted file mode 100644 index 7b89fba..0000000 --- a/modules/injection/cdi/src/test/java/org/apache/tamaya/integration/cdi/cfg/TestConfigProvider.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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. - */ -package org.apache.tamaya.integration.cdi.cfg; - -import org.apache.tamaya.spi.PropertySource; -import org.apache.tamaya.spi.PropertySourceProvider; - -import javax.enterprise.context.ApplicationScoped; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -/** - * Created by Anatole on 29.09.2014. - */ -@ApplicationScoped -public class TestConfigProvider implements PropertySourceProvider { - - private List<PropertySource> configs = new ArrayList<>(); - - public TestConfigProvider(){ - configs.add(new ProvidedPropertySource()); - } - - @Override - public Collection<PropertySource> getPropertySources() { - return configs; - } -}
