http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fe7cd8f1/modules/injection/standalone/src/main/java/org/apache/tamaya/inject/internal/Utils.java ---------------------------------------------------------------------- diff --git a/modules/injection/standalone/src/main/java/org/apache/tamaya/inject/internal/Utils.java b/modules/injection/standalone/src/main/java/org/apache/tamaya/inject/internal/Utils.java new file mode 100644 index 0000000..2c08467 --- /dev/null +++ b/modules/injection/standalone/src/main/java/org/apache/tamaya/inject/internal/Utils.java @@ -0,0 +1,128 @@ +/* + * 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.inject.internal; + +import java.lang.annotation.Annotation; +import java.lang.reflect.AccessibleObject; +import java.lang.reflect.AnnotatedElement; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Utility class simplifying some implementation aspects. + * Created by Anatole on 11.11.2014. + */ +@SuppressWarnings("unchecked") +public final class Utils { + + private static final Logger LOG = Logger.getLogger(Utils.class.getName()); + + private Utils() { + } + + /** + * Utility method to read out repeatable annotations. + * + * @param annotated the annotated instance. + * @param repeatableAnnotation the repeatable annotation type + * @param annotationContainer the container annotation type + * @param <T> the repeatable annotation type + * @param <R> the repeatable container annotation type + * @return a list with the annotations found (could be empty, but never null). + */ + public static <T extends Annotation, R extends Annotation> Collection<T> + getAnnotations(AnnotatedElement annotated, + Class<T> repeatableAnnotation, + Class<R> annotationContainer) { + List<T> result = new ArrayList<>(); + R containerAnnot = annotated.getAnnotation(annotationContainer); + if (containerAnnot != null) { + Method valueMethod; + try { + valueMethod = annotationContainer.getMethod("keys"); + result.addAll(Arrays.asList((T[]) valueMethod.invoke(containerAnnot))); + } catch (Exception e) { + LOG.log(Level.SEVERE, "Failed to evaluate repeatable annotation.", e); + } + } else { + T annot = annotated.getAnnotation(repeatableAnnotation); + if (annot != null) { + result.add(annot); + } + } + return result; + } + + /** + * Utility method to read out repeatable annotations. + * + * @param annotated the annotated instance. + * @param repeatableAnnotation the repeatable annotation type + * @param annotationContainer the container annotation type + * @param <T> the repeatable annotation type + * @param <R> the repeatable container annotation type + * @return a list with the annotations found (could be empty, but never null). + */ + public static <T extends Annotation, R extends Annotation> Collection<T> + getAnnotations(AccessibleObject annotated, + Class<T> repeatableAnnotation, + Class<R> annotationContainer) { + List<T> result = new ArrayList<>(); + R containerAnnot = annotated.getAnnotation(annotationContainer); + if (containerAnnot != null) { + Method valueMethod; + try { + valueMethod = annotationContainer.getMethod("keys"); + result.addAll(Arrays.asList((T[]) valueMethod.invoke(containerAnnot))); + } catch (Exception e) { + LOG.log(Level.SEVERE, "Failed to evaluate repeatable annotation.", e); + } + } else { + T annot = annotated.getAnnotation(repeatableAnnotation); + if (annot != null) { + result.add(annot); + } + } + return result; + } + + /** + * Utility method to read out repeatable annotations. + * + * @param annotationType the annotation type. + * @param objects the accessible objects to be looked up + * @param <T> the repeatable annotation type + * @return a list with the annotations found (could be empty, but never null). + */ + public static <T extends Annotation> T getAnnotation( + Class<T> annotationType, AnnotatedElement... objects) { + for (AnnotatedElement obj : objects) { + T annot = obj.getAnnotation(annotationType); + if (annot != null) { + return annot; + } + } + return null; + } +}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fe7cd8f1/modules/injection/standalone/src/main/java/org/apache/tamaya/inject/internal/package-info.java ---------------------------------------------------------------------- diff --git a/modules/injection/standalone/src/main/java/org/apache/tamaya/inject/internal/package-info.java b/modules/injection/standalone/src/main/java/org/apache/tamaya/inject/internal/package-info.java new file mode 100644 index 0000000..55e8cf6 --- /dev/null +++ b/modules/injection/standalone/src/main/java/org/apache/tamaya/inject/internal/package-info.java @@ -0,0 +1,22 @@ +/* + * 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. + */ +/** + * This package provides default implementation of a purely SE based injection mechanism. + */ +package org.apache.tamaya.inject.internal; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fe7cd8f1/modules/injection/standalone/src/main/java/org/apache/tamaya/inject/package-info.java ---------------------------------------------------------------------- diff --git a/modules/injection/standalone/src/main/java/org/apache/tamaya/inject/package-info.java b/modules/injection/standalone/src/main/java/org/apache/tamaya/inject/package-info.java new file mode 100644 index 0000000..4119248 --- /dev/null +++ b/modules/injection/standalone/src/main/java/org/apache/tamaya/inject/package-info.java @@ -0,0 +1,22 @@ +/* + * 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. + */ +/** + * Main SE based injection API. + */ +package org.apache.tamaya.inject; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fe7cd8f1/modules/injection/standalone/src/main/resources/META-INF/services/org.apache.tamaya.inject.ConfigurationInjector ---------------------------------------------------------------------- diff --git a/modules/injection/standalone/src/main/resources/META-INF/services/org.apache.tamaya.inject.ConfigurationInjector b/modules/injection/standalone/src/main/resources/META-INF/services/org.apache.tamaya.inject.ConfigurationInjector new file mode 100644 index 0000000..7204749 --- /dev/null +++ b/modules/injection/standalone/src/main/resources/META-INF/services/org.apache.tamaya.inject.ConfigurationInjector @@ -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 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. +# +org.apache.tamaya.inject.internal.DefaultConfigurationInjector \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fe7cd8f1/modules/injection/standalone/src/test/java/annottext/AnnotatedConfigBean.java ---------------------------------------------------------------------- diff --git a/modules/injection/standalone/src/test/java/annottext/AnnotatedConfigBean.java b/modules/injection/standalone/src/test/java/annottext/AnnotatedConfigBean.java new file mode 100644 index 0000000..3420977 --- /dev/null +++ b/modules/injection/standalone/src/test/java/annottext/AnnotatedConfigBean.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 annottext; + +import org.apache.tamaya.inject.api.DynamicValue; +import org.apache.tamaya.inject.api.NoConfig; +import org.apache.tamaya.inject.api.Config; + +import java.util.ArrayList; +import java.util.List; + +/** + * An example showing some basic annotations, using an interface to be proxied by the + * configuration system, nevertheless extending the overall Configuration interface. + * Created by Anatole on 15.02.14. + */ +public class AnnotatedConfigBean { + + @Config(value = {"foo.bar.myprop", "mp", "common.testdata.myProperty"}, defaultValue = "ET") + // @ConfigLoadPolicy(listener = MyListener.class) + public String myParameter; + + @Config("simple_value") + public String simpleValue; + + @Config + String anotherValue; + + @Config("host.name") + private String hostName; + + @Config("host.name") + private DynamicValue<String> dynamicHostname; + + @NoConfig + public String javaVersion; + + public String getAnotherValue(){ + return anotherValue; + } + + public String getHostName(){ + return hostName; + } + + public DynamicValue<String> getDynamicValue(){ + return dynamicHostname; + } + + @NoConfig + private List<String> events = new ArrayList<>(); + + // verify we don't try to inject final fields + public static final String CONSTANT = "a constant"; + + + @Config("java.version") + void setJavaVersion(String version){ + this.javaVersion = version; + } + +} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fe7cd8f1/modules/injection/standalone/src/test/java/annottext/AnnotatedConfigTemplate.java ---------------------------------------------------------------------- diff --git a/modules/injection/standalone/src/test/java/annottext/AnnotatedConfigTemplate.java b/modules/injection/standalone/src/test/java/annottext/AnnotatedConfigTemplate.java new file mode 100644 index 0000000..8c6d692 --- /dev/null +++ b/modules/injection/standalone/src/test/java/annottext/AnnotatedConfigTemplate.java @@ -0,0 +1,47 @@ +/* + * 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 annottext; + +import org.apache.tamaya.inject.api.DynamicValue; +import org.apache.tamaya.inject.api.Config; + +/** + * An example showing some basic annotations, using an interface to be proxied by the + * configuration system. + * Created by Anatole on 15.02.14. + */ +public interface AnnotatedConfigTemplate { + + @Config(value = {"foo.bar.myprop", "mp","common.testdata.myProperty"}, defaultValue = "ET") + // @ConfigLoadPolicy(listener = MyListener.class) + String myParameter(); + + @Config("simple_value") + String simpleValue(); + + @Config + String simplestValue(); + + @Config("host.name") + String hostName(); + + @Config("host.name") + DynamicValue<String> getDynamicValue(); + +} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fe7cd8f1/modules/injection/standalone/src/test/java/annottext/NonAnnotatedConfigBean.java ---------------------------------------------------------------------- diff --git a/modules/injection/standalone/src/test/java/annottext/NonAnnotatedConfigBean.java b/modules/injection/standalone/src/test/java/annottext/NonAnnotatedConfigBean.java new file mode 100644 index 0000000..87f8be7 --- /dev/null +++ b/modules/injection/standalone/src/test/java/annottext/NonAnnotatedConfigBean.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 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 annottext; + +import org.apache.tamaya.inject.api.Config; +import org.apache.tamaya.inject.api.DynamicValue; +import org.apache.tamaya.inject.api.NoConfig; + +import java.util.ArrayList; +import java.util.List; + +/** + * An example showing some basic annotations, using an interface to be proxied by the + * configuration system, nevertheless extending the overall Configuration interface. + * Created by Anatole on 15.02.14. + */ +public class NonAnnotatedConfigBean { + + public String simple_value = "Should be overridden!"; + + public String fieldKey; + + public String classFieldKey = "Foo"; + + public String fullKey; + + public String test2 = "This is not set."; + +} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fe7cd8f1/modules/injection/standalone/src/test/java/org/apache/tamaya/inject/TamayaInjectionTest.java ---------------------------------------------------------------------- diff --git a/modules/injection/standalone/src/test/java/org/apache/tamaya/inject/TamayaInjectionTest.java b/modules/injection/standalone/src/test/java/org/apache/tamaya/inject/TamayaInjectionTest.java new file mode 100644 index 0000000..d5a26c1 --- /dev/null +++ b/modules/injection/standalone/src/test/java/org/apache/tamaya/inject/TamayaInjectionTest.java @@ -0,0 +1,87 @@ +/* + * 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.inject; + +import annottext.AnnotatedConfigBean; +import annottext.AnnotatedConfigTemplate; +import annottext.NonAnnotatedConfigBean; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +/** + * Created by Anatole on 12.01.2015. + */ +public class TamayaInjectionTest { + + @Test + public void testInjectionNonAnnotatedClass(){ + assertNotNull(ConfigurationInjection.getConfigurationInjector()); + NonAnnotatedConfigBean testInstance = new NonAnnotatedConfigBean(); + assertEquals(testInstance.simple_value, "Should be overridden!"); + assertEquals(testInstance.classFieldKey, "Foo"); + assertEquals(testInstance.fieldKey, null); + assertEquals(testInstance.fullKey, null); + assertEquals(testInstance.test2, "This is not set."); + ConfigurationInjection.getConfigurationInjector().configure(testInstance); + assertEquals(testInstance.simple_value, "aSimpleValue"); + assertEquals(testInstance.classFieldKey, "Class-Field-Value"); + assertEquals(testInstance.fieldKey, "Field-Value"); + assertEquals(testInstance.fullKey, "Fullkey-Value"); + assertEquals(testInstance.test2, "This is not set."); + } + + @Test + public void testInjectionClass(){ + assertNotNull(ConfigurationInjection.getConfigurationInjector()); + AnnotatedConfigBean testInstance = new AnnotatedConfigBean(); + assertEquals(testInstance.getHostName(), null); + assertEquals(testInstance.getAnotherValue(), null); + assertEquals(testInstance.myParameter, null); + assertEquals(testInstance.simpleValue, null); + ConfigurationInjection.getConfigurationInjector().configure(testInstance); + assertEquals(testInstance.getHostName(), "tamaya01.incubator.apache.org"); + assertEquals(testInstance.getAnotherValue(), "HALLO!"); + assertEquals(testInstance.myParameter, "ET"); + assertEquals(testInstance.simpleValue, "aSimpleValue"); + assertNotNull(testInstance.getDynamicValue()); + assertTrue(testInstance.getDynamicValue().isPresent()); + assertEquals(testInstance.getDynamicValue().get(), "tamaya01.incubator.apache.org"); + assertEquals(testInstance.getHostName(), testInstance.getDynamicValue().get()); + assertEquals(testInstance.javaVersion, System.getProperty("java.version")); + } + + @Test + public void testConfigTemplate(){ + assertNotNull(ConfigurationInjection.getConfigurationInjector()); + AnnotatedConfigTemplate testInstance = ConfigurationInjection.getConfigurationInjector() + .createTemplate(AnnotatedConfigTemplate.class); + assertEquals(testInstance.hostName(), "tamaya01.incubator.apache.org"); + assertEquals(testInstance.myParameter(), "ET"); + assertEquals(testInstance.simpleValue(), "aSimpleValue"); + assertNotNull(testInstance.getDynamicValue()); + assertTrue(testInstance.getDynamicValue().isPresent()); + assertEquals(testInstance.getDynamicValue().get(), "tamaya01.incubator.apache.org"); + assertEquals(testInstance.hostName(), testInstance.getDynamicValue().get()); +// assertEquals(testInstance.simplestValue(), "HALLO!"); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fe7cd8f1/modules/injection/standalone/src/test/java/org/apache/tamaya/inject/TestPropertySource.java ---------------------------------------------------------------------- diff --git a/modules/injection/standalone/src/test/java/org/apache/tamaya/inject/TestPropertySource.java b/modules/injection/standalone/src/test/java/org/apache/tamaya/inject/TestPropertySource.java new file mode 100644 index 0000000..0853fd1 --- /dev/null +++ b/modules/injection/standalone/src/test/java/org/apache/tamaya/inject/TestPropertySource.java @@ -0,0 +1,68 @@ +/* + * 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.inject; + +import org.apache.tamaya.spi.PropertySource; +import org.apache.tamaya.spi.PropertyValue; + +import java.util.HashMap; +import java.util.Map; + +/** + * Created by Anatole on 12.01.2015. + */ +public class TestPropertySource implements PropertySource { + + private Map<String,String> properties = new HashMap<>(); + + public TestPropertySource(){ + properties.put("env.stage", "ET"); + properties.put("simple_value", "aSimpleValue"); + properties.put("host.name", "tamaya01.incubator.apache.org"); + properties.put("anotherValue", "HALLO!"); + properties.put("NonAnnotatedConfigBean.classFieldKey", "Class-Field-Value"); + properties.put("NonAnnotatedConfigBean.fieldKey", "Field-Value"); + properties.put("annottext.NonAnnotatedConfigBean.fullKey", "Fullkey-Value"); + } + + @Override + public int getOrdinal() { + return 0; + } + + @Override + public String getName() { + return getClass().getName(); + } + + @Override + public PropertyValue get(String key) { + return PropertyValue.of(key,properties.get(key),getName()); + } + + @Override + public Map<String, String> getProperties() { + return properties; + } + + @Override + public boolean isScannable() { + return true; + } +} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fe7cd8f1/modules/injection/standalone/src/test/java/org/apache/tamaya/inject/internal/DefaultDynamicValueTest.java ---------------------------------------------------------------------- diff --git a/modules/injection/standalone/src/test/java/org/apache/tamaya/inject/internal/DefaultDynamicValueTest.java b/modules/injection/standalone/src/test/java/org/apache/tamaya/inject/internal/DefaultDynamicValueTest.java new file mode 100644 index 0000000..f82d04b --- /dev/null +++ b/modules/injection/standalone/src/test/java/org/apache/tamaya/inject/internal/DefaultDynamicValueTest.java @@ -0,0 +1,315 @@ +/* + * 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.inject.internal; + +import org.apache.tamaya.ConfigException; +import org.apache.tamaya.ConfigurationProvider; +import org.apache.tamaya.inject.api.ConfiguredItemSupplier; +import org.apache.tamaya.inject.api.DynamicValue; +import org.apache.tamaya.inject.api.Config; +import org.apache.tamaya.inject.api.UpdatePolicy; +import org.apache.tamaya.spi.ConversionContext; +import org.apache.tamaya.spi.PropertyConverter; +import org.apache.tamaya.spi.PropertySource; +import org.apache.tamaya.spi.PropertyValue; +import org.junit.Test; + +import org.apache.tamaya.Configuration; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.HashMap; +import java.util.Map; + +import static org.junit.Assert.*; + +/** + * Tests for {@link org.apache.tamaya.inject.internal.DefaultDynamicValue}. + */ +public class DefaultDynamicValueTest { + + @Config("a") + String myValue; + + @Config("a") + String myValue2; + + @Config("a") + void setterMethod(String value){ + + } + + private PropertyChangeEvent event; + + private PropertyChangeListener consumer = new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + event = evt; + } + }; + + private Map<String,String> properties = new HashMap<>(); + private Configuration config = ConfigurationProvider.createConfiguration( + ConfigurationProvider.getConfigurationContextBuilder().addPropertySources( + new PropertySource() { + @Override + public int getOrdinal() { + return 0; + } + + @Override + public String getName() { + return "test"; + } + + @Override + public PropertyValue get(String key) { + return PropertyValue.of(key,properties.get(key),getName()); + } + + @Override + public Map<String, String> getProperties() { + return properties; + } + + @Override + public boolean isScannable() { + return false; + } + } + ).build()); + + @Test + public void testOf_Field() throws Exception { + DynamicValue val = DefaultDynamicValue.of(getClass().getDeclaredField("myValue"), + ConfigurationProvider.getConfiguration()); + assertNotNull(val); + } + + @Test + public void testOf_Method() throws Exception { + DynamicValue val = DefaultDynamicValue.of(getClass().getDeclaredMethod("setterMethod", String.class), + config); + assertNotNull(val); + } + + @Test + public void testCommitAndGet() throws Exception { + properties.put("a","aValue"); + DynamicValue val = DefaultDynamicValue.of(getClass().getDeclaredField("myValue"), + config); + assertNotNull(val); + assertEquals("aValue",val.evaluateValue()); + } + + @Test + public void testCommitAndGets() throws Exception { + properties.put("a","aValue"); + DynamicValue val = DefaultDynamicValue.of(getClass().getDeclaredField("myValue"), + config); + val.setUpdatePolicy(UpdatePolicy.EXPLCIT); + assertNotNull(val); + assertEquals("aValue",val.evaluateValue()); + // change config + val.get(); + this.properties.put("a", "aValue2"); + assertTrue(val.updateValue()); + assertEquals("aValue2", val.commitAndGet()); + } + + @Test + public void testCommit() throws Exception { + properties.put("a", "aValue"); + DynamicValue val = DefaultDynamicValue.of(getClass().getDeclaredField("myValue"), + config); + val.setUpdatePolicy(UpdatePolicy.EXPLCIT); + assertNotNull(val); + assertEquals("aValue", val.evaluateValue()); + // change config + val.get(); + this.properties.put("a", "aValue2"); + assertEquals("aValue2", val.evaluateValue()); + assertTrue(val.updateValue()); + val.commit(); + assertEquals("aValue2", val.get()); + } + + @Test + public void testGetSetUpdatePolicy() throws Exception { + DynamicValue val = DefaultDynamicValue.of(getClass().getDeclaredField("myValue"), + config); + for(UpdatePolicy pol: UpdatePolicy.values()) { + val.setUpdatePolicy(pol); + assertEquals(pol, val.getUpdatePolicy()); + } + } + + @Test + public void testAddRemoveListener() throws Exception { + properties.put("a","aValue"); + DynamicValue val = DefaultDynamicValue.of(getClass().getDeclaredField("myValue"), + config); + val.setUpdatePolicy(UpdatePolicy.IMMEDEATE); + val.addListener(consumer); + // change config + val.get(); + this.properties.put("a", "aValue2"); + val.get(); + assertNotNull(event); + event = null; + val.removeListener(consumer); + this.properties.put("a", "aValue3"); + val.updateValue(); + assertNull(event); + } + + @Test + public void testGet() throws Exception { + properties.put("a", "aValue"); + DynamicValue val = DefaultDynamicValue.of(getClass().getDeclaredField("myValue"), + config); + val.setUpdatePolicy(UpdatePolicy.IMMEDEATE); + properties.put("a", "aValue2"); + val.updateValue(); + assertEquals("aValue2", val.get()); + } + + @Test + public void testUpdateValue() throws Exception { + properties.put("a","aValue"); + DynamicValue val = DefaultDynamicValue.of(getClass().getDeclaredField("myValue"), + config); + val.setUpdatePolicy(UpdatePolicy.EXPLCIT); + assertNotNull(val.get()); + assertEquals("aValue", val.get()); + val.updateValue(); + assertEquals("aValue", val.get()); + val.setUpdatePolicy(UpdatePolicy.IMMEDEATE); + val.updateValue(); + assertEquals("aValue",val.get()); + } + + @Test + public void testEvaluateValue() throws Exception { + properties.put("a","aValue"); + DynamicValue val = DefaultDynamicValue.of(getClass().getDeclaredField("myValue"), + config); + val.setUpdatePolicy(UpdatePolicy.EXPLCIT); + assertNotNull(val.get()); + assertEquals("aValue",val.evaluateValue()); + properties.put("a", "aValue2"); + assertEquals("aValue2", val.evaluateValue()); + } + + @Test + public void testGetNewValue() throws Exception { + properties.put("a","aValue"); + DynamicValue val = DefaultDynamicValue.of(getClass().getDeclaredField("myValue"), + config); + val.setUpdatePolicy(UpdatePolicy.EXPLCIT); + val.get(); + assertNull(val.getNewValue()); + properties.put("a", "aValue2"); + val.get(); + assertNotNull(val.getNewValue()); + assertEquals("aValue2", val.getNewValue()); + val.commit(); + assertNull(val.getNewValue()); + } + + @Test + public void testIsPresent() throws Exception { + + } + + @Test + public void testIfPresent() throws Exception { + properties.put("a","aValue"); + DynamicValue val = DefaultDynamicValue.of(getClass().getDeclaredField("myValue"), + config); + val.setUpdatePolicy(UpdatePolicy.IMMEDEATE); + assertTrue(val.isPresent()); + properties.remove("a"); + val.updateValue(); + assertFalse(val.isPresent()); + } + + @Test + public void testOrElse() throws Exception { + DynamicValue val = DefaultDynamicValue.of(getClass().getDeclaredField("myValue"), + config); + val.setUpdatePolicy(UpdatePolicy.IMMEDEATE); + assertEquals("bla", val.orElse("bla")); + properties.put("a","aValue"); + val.updateValue(); + assertEquals("aValue", val.orElse("bla")); + } + + @Test + public void testOrElseGet() throws Exception { + DynamicValue val = DefaultDynamicValue.of(getClass().getDeclaredField("myValue"), + config); + val.setUpdatePolicy(UpdatePolicy.IMMEDEATE); + assertEquals("bla", val.orElseGet(new ConfiguredItemSupplier() { + @Override + public Object get() { + return "bla"; + } + })); + properties.put("a", "aValue"); + val.updateValue(); + assertEquals("aValue", val.orElseGet(new ConfiguredItemSupplier() { + @Override + public Object get() { + return "bla"; + } + })); + } + + @Test(expected = ConfigException.class) + public void testOrElseThrow() throws Throwable { + DynamicValue val = DefaultDynamicValue.of(getClass().getDeclaredField("myValue"), + config); + val.setUpdatePolicy(UpdatePolicy.EXPLCIT); + val.get(); + properties.put("a", "aValue"); + assertEquals("aValue", val.orElseThrow(new ConfiguredItemSupplier() { + @Override + public ConfigException get() { + return new ConfigException("bla"); + } + })); + properties.remove("a"); + val.updateValue(); + assertEquals("aValue", val.orElseThrow(new ConfiguredItemSupplier() { + @Override + public ConfigException get() { + return new ConfigException("bla"); + } + })); + } + + private static final class DoublicatingConverter implements PropertyConverter<String>{ + + @Override + public String convert(String value, ConversionContext context) { + return value + value; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fe7cd8f1/modules/injection/standalone/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource ---------------------------------------------------------------------- diff --git a/modules/injection/standalone/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource b/modules/injection/standalone/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource new file mode 100644 index 0000000..5dfb894 --- /dev/null +++ b/modules/injection/standalone/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource @@ -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 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. +# +org.apache.tamaya.inject.TestPropertySource \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fe7cd8f1/modules/json/pom.xml ---------------------------------------------------------------------- diff --git a/modules/json/pom.xml b/modules/json/pom.xml deleted file mode 100644 index 4957986..0000000 --- a/modules/json/pom.xml +++ /dev/null @@ -1,149 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- -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. ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.tamaya.ext</groupId> - <artifactId>tamaya-extensions</artifactId> - <version>0.3-incubating-SNAPSHOT</version> - <relativePath>..</relativePath> - </parent> - <artifactId>tamaya-json</artifactId> - <name>Apache Tamaya JSON Support</name> - <packaging>bundle</packaging> - <inceptionYear>2015</inceptionYear> - - <properties> - <jdkVersion>1.7</jdkVersion> - </properties> - - <dependencies> - <dependency> - <groupId>org.apache.tamaya</groupId> - <artifactId>tamaya-api</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - - <dependency> - <groupId>org.apache.tamaya</groupId> - <artifactId>tamaya-core</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - - <dependency> - <groupId>org.apache.tamaya.ext</groupId> - <artifactId>tamaya-formats</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.geronimo.specs</groupId> - <artifactId>geronimo-json_1.0_spec</artifactId> - </dependency> - <dependency> - <groupId>org.apache.johnzon</groupId> - <artifactId>johnzon-core</artifactId> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - </dependency> - <dependency> - <groupId>org.jboss.arquillian.daemon</groupId> - <artifactId>arquillian-daemon-container-managed</artifactId> - </dependency> - <dependency> - <groupId>org.jboss.arquillian.daemon</groupId> - <artifactId>arquillian-daemon-container-common</artifactId> - </dependency> - <dependency> - <groupId>org.jboss.arquillian.daemon</groupId> - <artifactId>arquillian-daemon-main</artifactId> - </dependency> - <dependency> - <groupId>org.jboss.arquillian.daemon</groupId> - <artifactId>arquillian-daemon-protocol-arquillian</artifactId> - </dependency> - <dependency> - <groupId>org.jboss.arquillian.daemon</groupId> - <artifactId>arquillian-daemon-protocol-wire</artifactId> - </dependency> - <dependency> - <groupId>org.jboss.arquillian.daemon</groupId> - <artifactId>arquillian-daemon-server</artifactId> - </dependency> - <dependency> - <groupId>org.jboss.arquillian.junit</groupId> - <artifactId>arquillian-junit-container</artifactId> - </dependency> - <dependency> - <groupId>org.hamcrest</groupId> - <artifactId>java-hamcrest</artifactId> - </dependency> - </dependencies> - - <build> - <plugins> - <plugin> - <artifactId>maven-dependency-plugin</artifactId> - <executions> - <execution> - <id>copyMain</id> - <phase>process-test-sources</phase> - <goals> - <goal>copy</goal> - </goals> - <configuration> - <outputDirectory>${project.build.directory}</outputDirectory> - <overWriteReleases>false</overWriteReleases> - <overWriteSnapshots>false</overWriteSnapshots> - <overWriteIfNewer>true</overWriteIfNewer> - <stripVersion>true</stripVersion> - <artifactItems> - <artifactItem> - <groupId>org.jboss.arquillian.daemon</groupId> - <artifactId>arquillian-daemon-main</artifactId> - </artifactItem> - </artifactItems> - </configuration> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-bundle-plugin</artifactId> - <extensions>true</extensions> - <configuration> - <instructions> - <Export-Package> - org.apache.tamaya.json - </Export-Package> - </instructions> - </configuration> - </plugin> - </plugins> - </build> - - -</project> http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fe7cd8f1/modules/json/src/main/java/org/apache/tamaya/json/JSONFormat.java ---------------------------------------------------------------------- diff --git a/modules/json/src/main/java/org/apache/tamaya/json/JSONFormat.java b/modules/json/src/main/java/org/apache/tamaya/json/JSONFormat.java deleted file mode 100644 index 8bdd414..0000000 --- a/modules/json/src/main/java/org/apache/tamaya/json/JSONFormat.java +++ /dev/null @@ -1,85 +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.json; - -import org.apache.tamaya.ConfigException; -import org.apache.tamaya.format.ConfigurationData; -import org.apache.tamaya.format.ConfigurationDataBuilder; -import org.apache.tamaya.format.ConfigurationFormat; - -import java.io.InputStream; -import java.net.URL; -import java.nio.charset.Charset; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -import javax.json.Json; -import javax.json.JsonException; -import javax.json.JsonObject; -import javax.json.JsonReader; -import javax.json.JsonReaderFactory; - -/** - * Implementation of the {@link org.apache.tamaya.format.ConfigurationFormat} - * able to read configuration properties represented in JSON - * - * @see <a href="http://www.json.org">JSON format specification</a> - */ -public class JSONFormat implements ConfigurationFormat { - /** Property that make Johnzon accept commentc. */ - public static final String JOHNZON_SUPPORTS_COMMENTS_PROP = "org.apache.johnzon.supports-comments"; - /** The reader factory used. */ - private final JsonReaderFactory readerFactory; - - /** - * Constructor, itniaitlizing zhe JSON reader factory. - */ - public JSONFormat(){ - Map<String, Object> config = new HashMap<>(); - config.put(JOHNZON_SUPPORTS_COMMENTS_PROP, true); - this.readerFactory = Json.createReaderFactory(config); - } - - @Override - public String getName() { - return "json"; - } - - @Override - public boolean accepts(URL url) { - return Objects.requireNonNull(url).getPath().endsWith(".json"); - } - - @Override - public ConfigurationData readConfiguration(String resource, InputStream inputStream) { - - try { - final JsonReader reader = this.readerFactory.createReader(inputStream, Charset.forName("UTF-8")); - JsonObject root = reader.readObject(); - HashMap<String, String> values = new HashMap<>(); - JSONVisitor visitor = new JSONVisitor(root, values); - visitor.run(); - return ConfigurationDataBuilder.of(resource, this).addProperties(values) - .build(); - } catch (JsonException e) { - throw new ConfigException("Failed to read data from " + resource, e); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fe7cd8f1/modules/json/src/main/java/org/apache/tamaya/json/JSONPropertySource.java ---------------------------------------------------------------------- diff --git a/modules/json/src/main/java/org/apache/tamaya/json/JSONPropertySource.java b/modules/json/src/main/java/org/apache/tamaya/json/JSONPropertySource.java deleted file mode 100644 index 43cfa73..0000000 --- a/modules/json/src/main/java/org/apache/tamaya/json/JSONPropertySource.java +++ /dev/null @@ -1,149 +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.json; - -import org.apache.tamaya.ConfigException; -import org.apache.tamaya.spi.PropertySource; -import org.apache.tamaya.spi.PropertyValue; - -import java.io.InputStream; -import java.net.URL; -import java.nio.charset.Charset; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.logging.Level; -import java.util.logging.Logger; - -import javax.json.Json; -import javax.json.JsonObject; -import javax.json.JsonReaderFactory; -import javax.json.JsonStructure; - -import static java.lang.String.format; - -/** - * Property source based on a JSON file. - */ -public class JSONPropertySource implements PropertySource { - /** Constant for enabling comments in Johnzon. */ - public static final String JOHNZON_SUPPORTS_COMMENTS_PROP = "org.apache.johnzon.supports-comments"; - - /** The underlying resource. */ - private final URL urlResource; - /** The values read. */ - private final Map<String, String> values; - /** The evaluated ordinal. */ - private int ordinal; - /** The JSON reader factory used. */ - private JsonReaderFactory readerFactory = initReaderFactory(); - - /** Initializes the factory to be used for creating readers. */ - private JsonReaderFactory initReaderFactory() { - Map<String, Object> config = new HashMap<>(); - config.put(JOHNZON_SUPPORTS_COMMENTS_PROP, true); - return Json.createReaderFactory(config); - } - - /** - * Constructor, hereby using 0 as the default ordinal. - * @param resource the resource modelled as URL, not null. - */ - public JSONPropertySource(URL resource) { - this(resource, 0); - } - - /** - * Constructor. - * @param resource the resource modelled as URL, not null. - * @param defaultOrdinal the defaultOrdinal to be used. - */ - public JSONPropertySource(URL resource, int defaultOrdinal) { - urlResource = Objects.requireNonNull(resource); - this.ordinal = defaultOrdinal; // may be overriden by read... - this.values = readConfig(urlResource); - if (this.values.containsKey(TAMAYA_ORDINAL)) { - this.ordinal = Integer.parseInt(this.values.get(TAMAYA_ORDINAL)); - } - Map<String, Object> config = new HashMap<>(); - config.put(JOHNZON_SUPPORTS_COMMENTS_PROP, true); - this.readerFactory = Json.createReaderFactory(config); - } - - - @Override - public int getOrdinal() { - PropertyValue configuredOrdinal = get(TAMAYA_ORDINAL); - if(configuredOrdinal!=null){ - try{ - return Integer.parseInt(configuredOrdinal.getValue()); - } catch(Exception e){ - Logger.getLogger(getClass().getName()).log(Level.WARNING, - "Configured Ordinal is not an int number: " + configuredOrdinal, e); - } - } - return ordinal; - } - - @Override - public String getName() { - return urlResource.toExternalForm(); - } - - @Override - public PropertyValue get(String key) { - return PropertyValue.of(key, getProperties().get(key), getName()); - } - - @Override - public Map<String, String> getProperties() { - return Collections.unmodifiableMap(values); - } - - /** - * Reads the configuration. - * @param urlResource soure of the configuration. - * @return the configuration read from the given resource URL. - * @throws ConfigException if resource URL cannot be read. - */ - protected Map<String, String> readConfig(URL urlResource) { - try (InputStream is = urlResource.openStream()) { - JsonStructure root = this.readerFactory.createReader(is, Charset.forName("UTF-8")).read(); - - // Test added. H. Saly, 15. Aug. 2015 - if (!(root instanceof JsonObject)) { - throw new ConfigException("Currently only JSON objects are supported"); - } - - Map<String, String> values = new HashMap<>(); - JSONVisitor visitor = new JSONVisitor((JsonObject)root, values); - visitor.run(); - return values; - } - catch (Throwable t) { - throw new ConfigException(format("Failed to read properties from %s", urlResource.toExternalForm()), t); - } - } - - @Override - public boolean isScannable() { - return true; - } -} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fe7cd8f1/modules/json/src/main/java/org/apache/tamaya/json/JSONVisitor.java ---------------------------------------------------------------------- diff --git a/modules/json/src/main/java/org/apache/tamaya/json/JSONVisitor.java b/modules/json/src/main/java/org/apache/tamaya/json/JSONVisitor.java deleted file mode 100644 index 2135ec5..0000000 --- a/modules/json/src/main/java/org/apache/tamaya/json/JSONVisitor.java +++ /dev/null @@ -1,119 +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.json; - -import org.apache.tamaya.ConfigException; - -import java.util.*; - -import javax.json.JsonArray; -import javax.json.JsonObject; -import javax.json.JsonString; -import javax.json.JsonStructure; -import javax.json.JsonValue; - -/** - * Visitor implementation to read a JSON formatted input source. - */ -class JSONVisitor { - private final JsonObject rootNode; - private final Map<String, String> targetStore; - - JSONVisitor(JsonObject startNode, Map<String, String> target) { - rootNode = startNode; - targetStore = target; - } - - public void run() { - Deque<VisitingContext> stack = new ArrayDeque<>(); - - stack.add(new VisitingContext(rootNode)); - boolean goOn = stack.peek().hasNext(); - - if (goOn) { - do { - Map.Entry<String, JsonValue> current = stack.peek().nextElement(); - - if (!(current.getValue() instanceof JsonStructure)) { - String key = stack.peek().getNSPrefix() + current.getKey(); - String value; - JsonValue jsonValue = current.getValue(); - switch(jsonValue.getValueType()) { - case NULL: value = null; break; - case FALSE: value = Boolean.FALSE.toString(); break; - case TRUE: value = Boolean.TRUE.toString(); break; - case NUMBER: value = jsonValue.toString(); break; - case STRING: value = ((JsonString) jsonValue).getString(); break; - default: - throw new ConfigException("Internal failure while processing JSON document."); - } - - targetStore.put(key, value); - } else if (current.getValue() instanceof JsonObject) { - String key = stack.peek().getNSPrefix() + current.getKey(); - JsonObject node = (JsonObject) current.getValue(); - stack.push(new VisitingContext(node, key)); - } else if (current.getValue() instanceof JsonArray) { - throw new ConfigException("Arrays are not supported at the moment."); - } else { - throw new ConfigException("Internal failure while processing JSON document."); - } - - goOn = stack.peek().hasNext(); - - while (!goOn && stack.size() > 0) { - stack.remove(); - goOn = (stack.size() > 0) && stack.peek().hasNext(); - } - } while (goOn); - } - } - - /** - * Context for a sub context visited. - */ - private static class VisitingContext { - private final String namespace; - private final JsonObject node; - private final Iterator<Map.Entry<String, JsonValue>> elements; - - public VisitingContext(JsonObject node) { - this(node, ""); - } - - public VisitingContext(JsonObject rootNode, String currentNamespace) { - namespace = currentNamespace; - node = rootNode; - elements = node.entrySet().iterator(); - } - - public Map.Entry<String, JsonValue> nextElement() { - return elements.next(); - } - - - public boolean hasNext() { - return elements.hasNext(); - } - - public String getNSPrefix() { - return namespace.isEmpty() ? namespace : namespace + "."; - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fe7cd8f1/modules/json/src/main/resources/META-INF/services/org.apache.tamaya.format.ConfigurationFormat ---------------------------------------------------------------------- diff --git a/modules/json/src/main/resources/META-INF/services/org.apache.tamaya.format.ConfigurationFormat b/modules/json/src/main/resources/META-INF/services/org.apache.tamaya.format.ConfigurationFormat deleted file mode 100644 index a843cbe..0000000 --- a/modules/json/src/main/resources/META-INF/services/org.apache.tamaya.format.ConfigurationFormat +++ /dev/null @@ -1,19 +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. -# -org.apache.tamaya.json.JSONFormat \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fe7cd8f1/modules/json/src/test/java/org/apache/tamaya/json/CommonJSONTestCaseCollection.java ---------------------------------------------------------------------- diff --git a/modules/json/src/test/java/org/apache/tamaya/json/CommonJSONTestCaseCollection.java b/modules/json/src/test/java/org/apache/tamaya/json/CommonJSONTestCaseCollection.java deleted file mode 100644 index 946878c..0000000 --- a/modules/json/src/test/java/org/apache/tamaya/json/CommonJSONTestCaseCollection.java +++ /dev/null @@ -1,190 +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.json; - -import org.apache.tamaya.ConfigException; -import org.apache.tamaya.spi.PropertySource; -import org.apache.tamaya.spi.PropertyValue; -import org.hamcrest.CoreMatchers; -import org.hamcrest.Matchers; -import org.junit.Test; - -import java.net.URL; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasSize; - -/** - * Class with a collection of common test cases each JSON processing - * class must be able to pass. - */ -public abstract class CommonJSONTestCaseCollection { - - abstract PropertySource getPropertiesFrom(URL source) throws Exception; - - @Test - public void canReadNonLatinCharacters() throws Exception { - URL configURL = JSONPropertySourceTest.class - .getResource("/configs/valid/cyrillic.json"); - - assertThat(configURL, Matchers.notNullValue()); - - PropertySource propertySource = getPropertiesFrom(configURL); - - assertThat(propertySource.get("name"), Matchers.notNullValue()); - assertThat(propertySource.get("name").getValue(), equalTo("\u041e\u043b\u0438\u0432\u0435\u0440")); - assertThat(propertySource.get("\u0444\u0430\u043c\u0438\u043b\u0438\u044f"), Matchers.notNullValue()); - assertThat(propertySource.get("\u0444\u0430\u043c\u0438\u043b\u0438\u044f").getValue(), Matchers.equalTo("Fischer")); - } - - @Test - public void canReadNestedStringOnlyJSONConfigFile() throws Exception { - URL configURL = JSONPropertySourceTest.class - .getResource("/configs/valid/simple-nested-string-only-config-1.json"); - - assertThat(configURL, CoreMatchers.notNullValue()); - - PropertySource properties = getPropertiesFrom(configURL); - - assertThat(properties.getProperties().keySet(), hasSize(5)); - - PropertyValue keyB = properties.get("b"); - PropertyValue keyDO = properties.get("d.o"); - PropertyValue keyDP = properties.get("d.p"); - - assertThat(keyB, notNullValue()); - assertThat(keyB.getValue(), equalTo("B")); - assertThat(keyDO, notNullValue()); - assertThat(keyDO.getValue(), equalTo("O")); - assertThat(keyDP, Matchers.notNullValue()); - assertThat(keyDP.getValue(), is("P")); - } - - @Test - public void canReadNestedStringOnlyJSONConfigFileWithObjectInTheMiddle() - throws Exception { - URL configURL = JSONPropertySourceTest.class - .getResource("/configs/valid/simple-nested-string-only-config-2.json"); - - assertThat(configURL, CoreMatchers.notNullValue()); - - PropertySource properties = getPropertiesFrom(configURL); - - assertThat(properties.getProperties().keySet(), hasSize(4)); - - PropertyValue keyA = properties.get("a"); - PropertyValue keyDO = properties.get("b.o"); - PropertyValue keyDP = properties.get("b.p"); - PropertyValue keyC = properties.get("c"); - - assertThat(keyA, notNullValue()); - assertThat(keyA.getValue(), is("A")); - assertThat(keyC, notNullValue()); - assertThat(keyC.getValue(), equalTo("C")); - assertThat(keyDO, notNullValue()); - assertThat(keyDO.getValue(), equalTo("O")); - assertThat(keyDP, notNullValue()); - assertThat(keyDP.getValue(), is("P")); - } - - @Test(expected = ConfigException.class) - public void canHandleIllegalJSONFileWhichContainsAnArray() throws Exception { - URL configURL = JSONPropertySourceTest.class.getResource("/configs/invalid/with-array.json"); - - assertThat(configURL, CoreMatchers.notNullValue()); - - getPropertiesFrom(configURL).getProperties(); - } - - @Test(expected = ConfigException.class) - public void canHandleIllegalJSONFileConsistingOfOneOpeningBracket() throws Exception { - URL configURL = JSONPropertySourceTest.class.getResource("/configs/invalid/only-opening-bracket.json"); - - assertThat(configURL, CoreMatchers.notNullValue()); - - getPropertiesFrom(configURL).getProperties(); - } - - @Test(expected = ConfigException.class) - public void canHandleIllegalJSONFileWhichIsEmpty() throws Exception { - URL configURL = JSONPropertySourceTest.class.getResource("/configs/invalid/empty-file.json"); - - assertThat(configURL, CoreMatchers.notNullValue()); - - getPropertiesFrom(configURL).getProperties(); - } - - @Test - public void priorityInConfigFileOverwriteExplicitlyGivenPriority() throws Exception { - URL configURL = JSONPropertySourceTest.class.getResource("/configs/valid/with-explicit-priority.json"); - - assertThat(configURL, CoreMatchers.notNullValue()); - - PropertySource properties = getPropertiesFrom(configURL); - - assertThat(properties.getOrdinal(), is(16784)); - } - - @Test - public void canReadFlatStringOnlyJSONConfigFile() throws Exception { - URL configURL = JSONPropertySourceTest.class.getResource("/configs/valid/simple-flat-string-only-config.json"); - - assertThat(configURL, CoreMatchers.notNullValue()); - - PropertySource properties = getPropertiesFrom(configURL); - - assertThat(properties.getProperties().keySet(), hasSize(3)); - - PropertyValue keyA = properties.get("a"); - PropertyValue keyB = properties.get("b"); - PropertyValue keyC = properties.get("c"); - - assertThat(keyA, notNullValue()); - assertThat(keyA.getValue(), equalTo("A")); - assertThat(keyB, notNullValue()); - assertThat(keyB.getValue(), is("B")); - assertThat(keyC, notNullValue()); - assertThat(keyC.getValue(), is("C")); - } - - @Test(expected = ConfigException.class) - public void emptyJSONFileResultsInConfigException() throws Exception { - URL configURL = JSONPropertySourceTest.class.getResource("/configs/invalid/empty-file.json"); - - assertThat(configURL, CoreMatchers.notNullValue()); - - PropertySource properties = getPropertiesFrom(configURL); - - properties.getProperties(); - } - - @Test - public void canHandleEmptyJSONObject() throws Exception { - URL configURL = JSONPropertySourceTest.class.getResource("/configs/valid/empty-object-config.json"); - - assertThat(configURL, CoreMatchers.notNullValue()); - - PropertySource properties = getPropertiesFrom(configURL); - - assertThat(properties.getProperties().keySet(), hasSize(0)); - } -} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fe7cd8f1/modules/json/src/test/java/org/apache/tamaya/json/JSONFormatIT.java ---------------------------------------------------------------------- diff --git a/modules/json/src/test/java/org/apache/tamaya/json/JSONFormatIT.java b/modules/json/src/test/java/org/apache/tamaya/json/JSONFormatIT.java deleted file mode 100644 index 851655e..0000000 --- a/modules/json/src/test/java/org/apache/tamaya/json/JSONFormatIT.java +++ /dev/null @@ -1,48 +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.json; - -import org.apache.tamaya.format.ConfigurationFormat; -import org.apache.tamaya.spi.ServiceContextManager; -import org.junit.Test; - -import java.util.List; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.notNullValue; - -/** - * Integration tests for {@link JSONFormat}. - */ -public class JSONFormatIT { - @Test - public void jsonFormatCanBeFoundViaServiceLoader() throws Exception { - List<ConfigurationFormat> formats = ServiceContextManager.getServiceContext() - .getServices(ConfigurationFormat.class); - - ConfigurationFormat format = null; - for (ConfigurationFormat f : formats) { - if (f instanceof JSONFormat) { - format = f; - break; - } - } - assertThat(format, notNullValue()); - } -} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fe7cd8f1/modules/json/src/test/java/org/apache/tamaya/json/JSONFormatTest.java ---------------------------------------------------------------------- diff --git a/modules/json/src/test/java/org/apache/tamaya/json/JSONFormatTest.java b/modules/json/src/test/java/org/apache/tamaya/json/JSONFormatTest.java deleted file mode 100644 index 9218046..0000000 --- a/modules/json/src/test/java/org/apache/tamaya/json/JSONFormatTest.java +++ /dev/null @@ -1,75 +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.json; - - -import org.apache.tamaya.format.ConfigurationData; -import org.apache.tamaya.format.FlattenedDefaultPropertySource; -import org.apache.tamaya.spi.PropertySource; -import org.junit.Test; - -import java.io.InputStream; -import java.net.URL; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.Is.is; - -public class JSONFormatTest extends CommonJSONTestCaseCollection { - private final JSONFormat format = new JSONFormat(); - - @Test(expected = NullPointerException.class) - public void acceptsNeedsNonNullParameter() throws Exception { - format.accepts(null); - } - - @Test - public void aNonJSONFileBasedURLIsNotAccepted() throws Exception { - URL url = new URL("file:///etc/service/conf.conf"); - - assertThat(format.accepts(url), is(false)); - } - - @Test - public void aJSONFileBasedURLIsAccepted() throws Exception { - URL url = new URL("file:///etc/service/conf.json"); - - assertThat(format.accepts(url), is(true)); - } - - @Test - public void aHTTPBasedURLIsNotAccepted() throws Exception { - URL url = new URL("http://nowhere.somewhere/conf.json"); - assertThat(format.accepts(url), is(true)); - } - - @Test - public void aFTPBasedURLIsNotAccepted() throws Exception { - URL url = new URL("ftp://nowhere.somewhere/a/b/c/d/conf.json"); - - assertThat(format.accepts(url), is(true)); - } - - @Override - PropertySource getPropertiesFrom(URL source) throws Exception { - try (InputStream is = source.openStream()) { - ConfigurationData data = format.readConfiguration(source.toString(), is); - return new FlattenedDefaultPropertySource(data); - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fe7cd8f1/modules/json/src/test/java/org/apache/tamaya/json/JSONPropertySourceTest.java ---------------------------------------------------------------------- diff --git a/modules/json/src/test/java/org/apache/tamaya/json/JSONPropertySourceTest.java b/modules/json/src/test/java/org/apache/tamaya/json/JSONPropertySourceTest.java deleted file mode 100644 index 9892446..0000000 --- a/modules/json/src/test/java/org/apache/tamaya/json/JSONPropertySourceTest.java +++ /dev/null @@ -1,56 +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.json; - -import org.apache.tamaya.ConfigException; -import org.apache.tamaya.spi.PropertySource; -import org.hamcrest.CoreMatchers; -import org.junit.Test; - -import java.net.URL; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertEquals; - -public class JSONPropertySourceTest extends CommonJSONTestCaseCollection { - - @Test - public void tamayaOrdinalKeywordIsNotPropagatedAsNormalProperty() throws Exception { - URL configURL = JSONPropertySourceTest.class.getResource("/configs/valid/with-explicit-priority.json"); - - assertThat(configURL, CoreMatchers.notNullValue()); - - JSONPropertySource source = new JSONPropertySource(configURL, 4); - assertEquals(source.get(PropertySource.TAMAYA_ORDINAL).getValue(), "16784"); - } - - @Test(expected=ConfigException.class) - public void testDoNotAcceptJsonArrays() throws Exception { - URL configURL = JSONPropertySourceTest.class.getResource("/configs/invalid/array.json"); - - assertThat(configURL, CoreMatchers.notNullValue()); - - new JSONPropertySource(configURL); - } - - @Override - PropertySource getPropertiesFrom(URL source) throws Exception { - return new JSONPropertySource(source); - } -} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fe7cd8f1/modules/json/src/test/resources/arquillian.xml ---------------------------------------------------------------------- diff --git a/modules/json/src/test/resources/arquillian.xml b/modules/json/src/test/resources/arquillian.xml deleted file mode 100644 index 1eeb58b..0000000 --- a/modules/json/src/test/resources/arquillian.xml +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- -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. ---> -<arquillian xmlns="http://jboss.org/schema/arquillian" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd"> - <container qualifier="daemon" default="true"> - <configuration> - <property name="host">localhost</property> - <property name="port">12346</property> - <property name="serverJarFile">target/arquillian-daemon-main.jar</property> - </configuration> - </container> -</arquillian> http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fe7cd8f1/modules/json/src/test/resources/configs/invalid/array.json ---------------------------------------------------------------------- diff --git a/modules/json/src/test/resources/configs/invalid/array.json b/modules/json/src/test/resources/configs/invalid/array.json deleted file mode 100644 index 0c2058a..0000000 --- a/modules/json/src/test/resources/configs/invalid/array.json +++ /dev/null @@ -1,21 +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. -*/ -[ - -] \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fe7cd8f1/modules/json/src/test/resources/configs/invalid/empty-file.json ---------------------------------------------------------------------- diff --git a/modules/json/src/test/resources/configs/invalid/empty-file.json b/modules/json/src/test/resources/configs/invalid/empty-file.json deleted file mode 100644 index f396085..0000000 --- a/modules/json/src/test/resources/configs/invalid/empty-file.json +++ /dev/null @@ -1,18 +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. -*/ \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fe7cd8f1/modules/json/src/test/resources/configs/invalid/only-opening-bracket.json ---------------------------------------------------------------------- diff --git a/modules/json/src/test/resources/configs/invalid/only-opening-bracket.json b/modules/json/src/test/resources/configs/invalid/only-opening-bracket.json deleted file mode 100644 index b936f69..0000000 --- a/modules/json/src/test/resources/configs/invalid/only-opening-bracket.json +++ /dev/null @@ -1,19 +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. -*/ -{ \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fe7cd8f1/modules/json/src/test/resources/configs/invalid/with-array.json ---------------------------------------------------------------------- diff --git a/modules/json/src/test/resources/configs/invalid/with-array.json b/modules/json/src/test/resources/configs/invalid/with-array.json deleted file mode 100644 index e623e49..0000000 --- a/modules/json/src/test/resources/configs/invalid/with-array.json +++ /dev/null @@ -1,27 +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. -*/ -{ - "a" : "A", - "b" : { - "c" : "C", - "d" : [ - "1", "2" - ] - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fe7cd8f1/modules/json/src/test/resources/configs/valid/cyrillic.json ---------------------------------------------------------------------- diff --git a/modules/json/src/test/resources/configs/valid/cyrillic.json b/modules/json/src/test/resources/configs/valid/cyrillic.json deleted file mode 100644 index b9f07b8..0000000 --- a/modules/json/src/test/resources/configs/valid/cyrillic.json +++ /dev/null @@ -1,22 +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. -*/ -{ - "name" : "ÐливеÑ", - "ÑамилиÑ" : "Fischer" -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fe7cd8f1/modules/json/src/test/resources/configs/valid/empty-object-config.json ---------------------------------------------------------------------- diff --git a/modules/json/src/test/resources/configs/valid/empty-object-config.json b/modules/json/src/test/resources/configs/valid/empty-object-config.json deleted file mode 100644 index 103c28d..0000000 --- a/modules/json/src/test/resources/configs/valid/empty-object-config.json +++ /dev/null @@ -1,20 +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. -*/ -{ -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fe7cd8f1/modules/json/src/test/resources/configs/valid/simple-flat-string-only-config.json ---------------------------------------------------------------------- diff --git a/modules/json/src/test/resources/configs/valid/simple-flat-string-only-config.json b/modules/json/src/test/resources/configs/valid/simple-flat-string-only-config.json deleted file mode 100644 index 02e2cd8..0000000 --- a/modules/json/src/test/resources/configs/valid/simple-flat-string-only-config.json +++ /dev/null @@ -1,23 +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. -*/ -{ - "a" : "A", - "b" : "B", - "c" : "C" -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/fe7cd8f1/modules/json/src/test/resources/configs/valid/simple-nested-string-only-config-1.json ---------------------------------------------------------------------- diff --git a/modules/json/src/test/resources/configs/valid/simple-nested-string-only-config-1.json b/modules/json/src/test/resources/configs/valid/simple-nested-string-only-config-1.json deleted file mode 100644 index fb2c4fe..0000000 --- a/modules/json/src/test/resources/configs/valid/simple-nested-string-only-config-1.json +++ /dev/null @@ -1,27 +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. -*/ -{ - "a": "A", - "b": "B", - "c": "C", - "d": { - "o": "O", - "p": "P" - } -}
