You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tamaya.apache.org by an...@apache.org on 2016/10/30 17:25:45 UTC

[03/10] incubator-tamaya-sandbox git commit: TAMAYA-182: Adapted modules to new builder patter changes, including tests. Fixed compile errors, or excluded modules from compilation (see root pom).

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/041f5998/validation/src/main/java/org/apache/tamaya/validation/spi/ParameterModel.java
----------------------------------------------------------------------
diff --git a/validation/src/main/java/org/apache/tamaya/validation/spi/ParameterModel.java b/validation/src/main/java/org/apache/tamaya/validation/spi/ParameterModel.java
new file mode 100644
index 0000000..f6acafe
--- /dev/null
+++ b/validation/src/main/java/org/apache/tamaya/validation/spi/ParameterModel.java
@@ -0,0 +1,242 @@
+/*
+ * 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.validation.spi;
+
+import org.apache.tamaya.Configuration;
+import org.apache.tamaya.validation.ConfigModel;
+import org.apache.tamaya.validation.ModelTarget;
+import org.apache.tamaya.validation.Validation;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Objects;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Default configuration Model for a configuration parameter.
+ */
+public class ParameterModel extends AbstractConfigModel {
+    /** Optional regular expression for validating the value. */
+    private final String regEx;
+    /** The target type into which the value must be convertible. */
+    private final Class<?> type;
+
+    /**
+     * Internal constructor.
+     * @param builder the builder, not null.
+     */
+    protected ParameterModel(Builder builder) {
+        super(builder.owner, builder.name, builder.required, builder.description);
+        this.regEx = builder.regEx;
+        this.type = builder.type;
+    }
+
+    @Override
+    public ModelTarget getType() {
+        return ModelTarget.Parameter;
+    }
+
+    /**
+     * Get the required parameter type.
+     *
+     * @return the type.
+     */
+    public Class<?> getParameterType() {
+        return type;
+    }
+
+    @Override
+    public Collection<Validation> validate(Configuration config) {
+        List<Validation> result = new ArrayList<>(1);
+        String configValue = config.get(getName());
+        if (configValue == null && isRequired()) {
+            result.add(Validation.ofMissing(this));
+        }
+        if (configValue != null && regEx != null) {
+            if (!configValue.matches(regEx)) {
+                result.add(Validation.ofError(this, "Config value not matching expression: " + regEx + ", was " +
+                        configValue));
+            }
+        }
+        return result;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder();
+        b.append(getType()).append(": ").append(getName());
+        if (isRequired()) {
+            b.append(", required: ").append(isRequired());
+        }
+        if (regEx != null) {
+            b.append(", expression: ").append(regEx);
+        }
+        return b.toString();
+    }
+
+    /**
+     * Creates a new Builder instance.
+     * @param owner the owner name, not null.
+     * @param name the fully qualified parameter name.
+     * @return a new builder, never null.
+     */
+    public static Builder builder(String owner, String name) {
+        return new Builder(owner, name);
+    }
+
+    /**
+     * Creates a new ConfigModel
+     * @param owner the owner name, not null.
+     * @param name the fully qualified parameter name.
+     * @param required the required flag.
+     * @param expression an optional regular expression to validate a value.
+     * @return the new ConfigModel instance.
+     */
+    public static ConfigModel of(String owner, String name, boolean required, String expression) {
+        return new Builder(owner, name).setRequired(required).setExpression(expression).build();
+    }
+
+    /**
+     * Creates a new ConfigModel
+     * @param owner the owner name, not null.
+     * @param name the fully qualified parameter name.
+     * @param required the required flag.
+     * @return the new ConfigModel instance.
+     */
+    public static ConfigModel of(String owner, String name, boolean required) {
+        return new Builder(owner, name).setRequired(required).build();
+    }
+
+    /**
+     * Creates a new ConfigModel. The parameter will be defined as optional.
+     * @param owner the owner name, not null.
+     * @param name the fully qualified parameter name.
+     * @return the new ConfigModel instance.
+     */
+    public static ConfigModel of(String owner, String name) {
+        return new Builder(owner, name).setRequired(false).build();
+    }
+
+
+    /**
+     * A new Builder for creating ParameterModel instances.
+     */
+    public static class Builder {
+        /** The parameter's target type. */
+        private Class<?> type;
+        /** The owner. */
+        private String owner;
+        /** The fully qualified parameter name. */
+        private String name;
+        /** The optional validation expression. */
+        private String regEx;
+        /** The optional description. */
+        private String description;
+        /** The required flag. */
+        private boolean required;
+
+        /**
+         * Creates a new Builder.
+         * @param owner owner, not null.
+         * @param name the fully qualified parameter name, not null.
+         */
+        public Builder(String owner, String name) {
+            this.owner = Objects.requireNonNull(owner);
+            this.name = Objects.requireNonNull(name);
+        }
+
+        /**
+         * Sets the target type.
+         * @param type the type, not null.
+         * @return the Builder for chaining
+         */
+        public Builder setType(String type) {
+            try {
+                this.type = Class.forName(type);
+            } catch (ClassNotFoundException e) {
+                try {
+                    this.type = Class.forName("java.ui.lang."+type);
+                } catch (ClassNotFoundException e2) {
+                    Logger.getLogger(getClass().getName()).log(Level.INFO, "Failed to load parameter type: " + type, e2);
+                }
+            }
+            return this;
+        }
+
+        /**
+         * Sets the required flag.
+         * @param required the required flag.
+         * @return the Builder for chaining
+         */
+        public Builder setRequired(boolean required) {
+            this.required = required;
+            return this;
+        }
+
+        /**
+         * Sets the optional description
+         * @param description the description
+         * @return the Builder for chaining
+         */
+        public Builder setDescription(String description) {
+            this.description = description;
+            return this;
+        }
+
+        /**
+         * Sets the optional validation expression
+         * @param expression the validation expression
+         * @return the Builder for chaining
+         */
+        public Builder setExpression(String expression) {
+            this.regEx = expression;
+            return this;
+        }
+
+        /**
+         * Sets the owner name.
+         * @param owner the owner name, not null.
+         * @return the Builder for chaining
+         */
+        public Builder setOwner(String owner) {
+            this.owner = Objects.requireNonNull(owner);
+            return this;
+        }
+
+        /**
+         * Sets the fully qualified parameter name.
+         * @param name the fully qualified parameter name, not null.
+         * @return the Builder for chaining
+         */
+        public Builder setName(String name) {
+            this.name = Objects.requireNonNull(name);
+            return this;
+        }
+
+        /**
+         * Creates a new ConfigModel with the given parameters.
+         * @return a new ConfigModel , never null.
+         */
+        public ConfigModel build() {
+            return new ParameterModel(this);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/041f5998/validation/src/main/java/org/apache/tamaya/validation/spi/SectionModel.java
----------------------------------------------------------------------
diff --git a/validation/src/main/java/org/apache/tamaya/validation/spi/SectionModel.java b/validation/src/main/java/org/apache/tamaya/validation/spi/SectionModel.java
new file mode 100644
index 0000000..23d9f91
--- /dev/null
+++ b/validation/src/main/java/org/apache/tamaya/validation/spi/SectionModel.java
@@ -0,0 +1,202 @@
+/*
+ * 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.validation.spi;
+
+import org.apache.tamaya.Configuration;
+import org.apache.tamaya.validation.ConfigModel;
+import org.apache.tamaya.validation.ModelTarget;
+import org.apache.tamaya.validation.Validation;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * Default configuration Model for a configuration section.
+ */
+public class SectionModel extends GroupModel {
+
+    /**
+     * Creates a new builder.
+     * @param owner owner, not null.
+     * @param name the section name.
+     * @return a new builder instance.
+     */
+    public static Builder builder(String owner, String name){
+        return new Builder(owner, name);
+    }
+
+    /**
+     * Creates a section validation for the given section.
+     * @param owner owner, not null.
+     * @param name the fully qualified section name
+     * @param required flag, if the section is required to be present.
+     * @return the ConfigModel instance
+     */
+    public static ConfigModel of(String owner, String name, boolean required){
+        return new Builder(owner, name).setRequired(required).build();
+    }
+
+    /**
+     * Creates a section validation for the given section.
+     * @param owner owner, not null.
+     * @param name the fully qualified section name
+     * @param required flag, if the section is required to be present.
+     * @param configModels additional configModels
+     * @return a new builder, never null.
+     */
+    public static ConfigModel of(String owner, String name, boolean required, ConfigModel... configModels){
+        return new Builder(owner, name).setRequired(required).addValidations(configModels).build();
+    }
+
+    /**
+     * Internal constructor.
+     * @param builder the builder, not null.
+     */
+    protected SectionModel(Builder builder) {
+        super(builder.owner, builder.name, builder.childConfigModels);
+    }
+
+    @Override
+    public ModelTarget getType(){
+        return ModelTarget.Section;
+    }
+
+    @Override
+    public Collection<Validation> validate(Configuration config) {
+        Map<String,String> map = config.getProperties();
+        String lookupKey = getName() + '.';
+        boolean present = false;
+        for(String key:map.keySet()){
+            if(key.startsWith("_")){
+                continue;
+            }
+            if(key.startsWith(lookupKey)){
+                present = true;
+                break;
+            }
+        }
+        List<Validation> result = new ArrayList<>(1);
+        if(isRequired() && !present) {
+            result.add(Validation.ofMissing(this));
+        }
+        result.addAll(super.validate(config));
+        return result;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder();
+        b.append(getType()).append(": ").append(getName());
+        if(isRequired()) {
+            b.append(", required: " ).append(isRequired());
+        }
+        for(ConfigModel val:getValidations()){
+             b.append(", ").append(val.toString());
+        }
+        return b.toString();
+    }
+
+    /**
+     * Builder for setting up a AreaConfigModel instance.
+     */
+    public static class Builder{
+        /** The section owner. */
+        private String owner;
+        /** The section name. */
+        private String name;
+        /** The optional description. */
+        private String description;
+        /** The required flag. */
+        private boolean required;
+        /** The (optional) custom validations.*/
+        private final List<ConfigModel> childConfigModels = new ArrayList<>();
+
+        /**
+         * Creates a new Builder.
+         * @param owner owner, not null.
+         * @param sectionName the section name, not null.
+         */
+        public Builder(String owner, String sectionName){
+            this.owner = Objects.requireNonNull(owner);
+            this.name = Objects.requireNonNull(sectionName);
+        }
+
+        /**
+         * Add configModels.
+         * @param configModels the configModels, not null.
+         * @return the Builder for chaining.
+         */
+        public Builder addValidations(ConfigModel... configModels){
+            this.childConfigModels.addAll(Arrays.asList(configModels));
+            return this;
+        }
+
+        /**
+         * Add configModels.
+         * @param configModels the configModels, not null.
+         * @return the Builder for chaining.
+         */
+        public Builder addValidations(Collection<ConfigModel> configModels){
+            this.childConfigModels.addAll(configModels);
+            return this;
+        }
+
+        /**
+         * Sets the required flag.
+         * @param required zhe flag.
+         * @return the Builder for chaining.
+         */
+        public Builder setRequired(boolean required){
+            this.required = required;
+            return this;
+        }
+
+        /**
+         * Set the )optional) description.
+         * @param description the description.
+         * @return the Builder for chaining.
+         */
+        public Builder setDescription(String description){
+            this.description = description;
+            return this;
+        }
+
+        /**
+         * Set the section name
+         * @param name the section name, not null.
+         * @return the Builder for chaining.
+         */
+        public Builder setName(String name){
+            this.name = Objects.requireNonNull(name);
+            return this;
+        }
+
+        /**
+         * Build a new ConfigModel instance.
+         * @return the new ConfigModel instance, not null.
+         */
+        public ConfigModel build(){
+            return new SectionModel(this);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/041f5998/validation/src/main/resources/META-INF/services/org.apache.tamaya.validation.spi.ConfigDocumentationMBean
----------------------------------------------------------------------
diff --git a/validation/src/main/resources/META-INF/services/org.apache.tamaya.validation.spi.ConfigDocumentationMBean b/validation/src/main/resources/META-INF/services/org.apache.tamaya.validation.spi.ConfigDocumentationMBean
new file mode 100644
index 0000000..f41ad43
--- /dev/null
+++ b/validation/src/main/resources/META-INF/services/org.apache.tamaya.validation.spi.ConfigDocumentationMBean
@@ -0,0 +1,38 @@
+#
+# 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.
+#
+
+#
+# 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.validation.internal.ConfigDocumentationBean
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/041f5998/validation/src/main/resources/META-INF/services/org.apache.tamaya.validation.spi.ModelProviderSpi
----------------------------------------------------------------------
diff --git a/validation/src/main/resources/META-INF/services/org.apache.tamaya.validation.spi.ModelProviderSpi b/validation/src/main/resources/META-INF/services/org.apache.tamaya.validation.spi.ModelProviderSpi
new file mode 100644
index 0000000..3866a74
--- /dev/null
+++ b/validation/src/main/resources/META-INF/services/org.apache.tamaya.validation.spi.ModelProviderSpi
@@ -0,0 +1,41 @@
+#
+# 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.
+#
+
+#
+# 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.validation.internal.ConfiguredPropertiesModelProviderSpi
+org.apache.tamaya.validation.internal.ConfiguredInlineModelProviderSpi
+org.apache.tamaya.validation.internal.ConfiguredResourcesModelProviderSpi
+org.apache.tamaya.validation.internal.ConfiguredTypeEventsModelProvider
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/041f5998/validation/src/test/java/org/apache/tamaya/validation/ConfigModelProviderTest.java
----------------------------------------------------------------------
diff --git a/validation/src/test/java/org/apache/tamaya/validation/ConfigModelProviderTest.java b/validation/src/test/java/org/apache/tamaya/validation/ConfigModelProviderTest.java
new file mode 100644
index 0000000..dda2b67
--- /dev/null
+++ b/validation/src/test/java/org/apache/tamaya/validation/ConfigModelProviderTest.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.validation;
+
+import org.apache.tamaya.validation.spi.SectionModel;
+import org.apache.tamaya.validation.spi.ParameterModel;
+import org.apache.tamaya.validation.spi.GroupModel;
+import org.apache.tamaya.validation.spi.ModelProviderSpi;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+
+/**
+ * Created by Anatole on 09.08.2015.
+ */
+public class ConfigModelProviderTest implements ModelProviderSpi {
+
+    private List<ConfigModel> configModels = new ArrayList<>(1);
+
+    public ConfigModelProviderTest(){
+        configModels.add(new TestConfigModel());
+        configModels = Collections.unmodifiableList(configModels);
+    }
+
+    public Collection<ConfigModel> getConfigModels() {
+        return configModels;
+    }
+
+    private static final class TestConfigModel extends GroupModel {
+
+        public TestConfigModel(){
+            super("TestConfigModel", "TestConfig", new SectionModel.Builder("TestConfigModel",
+                    "a.test.existing").setRequired(true).build(),
+                    ParameterModel.of("TestConfigModel", "a.test.existing.aParam", true),
+                    ParameterModel.of("TestConfigModel", "a.test.existing.optionalParam"),
+                    ParameterModel.of("TestConfigModel", "a.test.existing.aABCParam", false, "[ABC].*"),
+                    new SectionModel.Builder("TestConfigModel", "a.test.notexisting").setRequired(true).build(),
+                    ParameterModel.of("TestConfigModel", "a.test.notexisting.aParam", true),
+                    ParameterModel.of("TestConfigModel", "a.test.notexisting.optionalParam"),
+                    ParameterModel.of("TestConfigModel", "a.test.existing.aABCParam2", false, "[ABC].*"));
+        }
+        @Override
+        public String getName() {
+            return "TestConfigConfigModel";
+        }
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/041f5998/validation/src/test/java/org/apache/tamaya/validation/ValidationTests.java
----------------------------------------------------------------------
diff --git a/validation/src/test/java/org/apache/tamaya/validation/ValidationTests.java b/validation/src/test/java/org/apache/tamaya/validation/ValidationTests.java
new file mode 100644
index 0000000..29c3801
--- /dev/null
+++ b/validation/src/test/java/org/apache/tamaya/validation/ValidationTests.java
@@ -0,0 +1,52 @@
+/*
+ * 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.validation;
+
+import org.junit.Test;
+
+/**
+ * Created by Anatole on 10.08.2015.
+ */
+public class ValidationTests {
+
+    @Test
+    public void testDefaults(){
+        System.err.println(ConfigModelManager.validate());
+    }
+
+    @Test
+    public void testAllValidations(){
+        System.err.println(ConfigModelManager.getModels());
+    }
+
+    @Test
+    public void testConfigInfo(){
+        System.err.println(ConfigModelManager.getConfigInfoText());
+    }
+
+    @Test
+    public void testAllValidationsInclUndefined(){
+        System.err.println("Including UNDEFINED: \n" + ConfigModelManager.validate(true));
+    }
+
+    @Test
+    public void testModels(){
+        System.err.println("MODELS: " +ConfigModelManager.getModels());
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/041f5998/validation/src/test/java/org/apache/tamaya/validation/internal/ConfigDocumentationBeanTest.java
----------------------------------------------------------------------
diff --git a/validation/src/test/java/org/apache/tamaya/validation/internal/ConfigDocumentationBeanTest.java b/validation/src/test/java/org/apache/tamaya/validation/internal/ConfigDocumentationBeanTest.java
new file mode 100644
index 0000000..39bf657
--- /dev/null
+++ b/validation/src/test/java/org/apache/tamaya/validation/internal/ConfigDocumentationBeanTest.java
@@ -0,0 +1,108 @@
+/*
+ * 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.validation.internal;
+
+import org.apache.tamaya.validation.ModelTarget;
+import org.junit.Test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Created by Anatole on 19.08.2015.
+ */
+public class ConfigDocumentationBeanTest {
+
+    private final ConfigDocumentationBean mbean = new ConfigDocumentationBean();
+
+    @Test
+    public void testValidate_NoUnknowns() throws Exception {
+        String results = mbean.validate(false);
+        assertNotNull(results);
+        assertFalse(results.trim().isEmpty());
+        assertTrue(results.contains("\"target\":\"Parameter\""));
+        assertTrue(results.contains("\"result\":\"MISSING\""));
+        assertFalse(results.contains("\"description\":\"Undefined key: "));
+        assertFalse(results.contains(" \"result\":\"UNDEFINED\""));
+    }
+
+    @Test
+    public void testValidate_WithUnknowns() throws Exception {
+        String results = mbean.validate(true);
+        assertNotNull(results);
+        assertFalse(results.trim().isEmpty());
+        // test transitive excludes of default sys properties
+        assertFalse(results.contains("\"name\":\"java"));
+        assertFalse(results.contains("\"name\":\"sun."));
+        assertFalse(results.contains("\"name\":\"file."));
+        // test others
+        assertTrue(results.contains("\"target\":\"Parameter\""));
+        assertTrue(results.contains("\"target\":\"Section\""));
+        assertTrue(results.contains("\"result\":\"MISSING\""));
+        assertTrue(results.contains("\"description\":\"Undefined key: "));
+        assertTrue(results.contains(" \"result\":\"UNDEFINED\""));
+    }
+
+    @Test
+    public void testGetConfigurationModel() throws Exception {
+        String results = mbean.getConfigurationModel();
+        assertNotNull(results);
+        assertFalse(results.trim().isEmpty());
+        assertTrue(results.contains("\"target\":\"Parameter\""));
+        assertTrue(results.contains("\"name\":\"MyNumber\""));
+        assertTrue(results.contains("\"name\":\"a.b.c\""));
+        assertTrue(results.contains("\"required\":true"));
+    }
+
+    @Test
+    public void testGetConfigurationModel_WithSection() throws Exception {
+        String results = mbean.getConfigurationModel(ModelTarget.Parameter);
+        assertNotNull(results);
+        assertFalse(results.trim().isEmpty());
+        assertTrue(results.contains("\"target\":\"Parameter\""));
+        assertFalse(results.contains("\"target\":\"Section\""));
+        assertTrue(results.contains("\"required\":true"));
+    }
+
+    @Test
+    public void testFindConfigurationModels() throws Exception {
+        String results = mbean.findConfigurationModels("a");
+        assertNotNull(results);
+        assertFalse(results.trim().isEmpty());
+        assertFalse(results.contains("\"target\":\"Parameter\""));
+        assertTrue(results.contains("\"target\":\"Section\""));
+    }
+
+    @Test
+    public void testFindValidationModels() throws Exception {
+        String results = mbean.findValidationModels("a", ModelTarget.Section);
+        assertNotNull(results);
+        assertFalse(results.trim().isEmpty());
+        assertFalse(results.contains("\"target\":\"Parameter\""));
+        assertTrue(results.contains("\"target\":\"Section\""));
+        System.out.println(results);
+    }
+
+    @Test
+    public void testToString() throws Exception {
+        String toString = mbean.toString();
+        System.out.println(toString);
+    }
+}
\ No newline at end of file