http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/10d711e6/metamodel/src/test/java/org/apache/tamaya/metamodel/ext/MyConverter.java ---------------------------------------------------------------------- diff --git a/metamodel/src/test/java/org/apache/tamaya/metamodel/ext/MyConverter.java b/metamodel/src/test/java/org/apache/tamaya/metamodel/ext/MyConverter.java new file mode 100644 index 0000000..e9ca5a5 --- /dev/null +++ b/metamodel/src/test/java/org/apache/tamaya/metamodel/ext/MyConverter.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tamaya.metamodel.ext; + +import org.apache.tamaya.spi.ConversionContext; +import org.apache.tamaya.spi.PropertyConverter; + +/** + * Created by atsticks on 17.04.17. + */ +public class MyConverter implements PropertyConverter<String> { + + @Override + public String convert(String value, ConversionContext context) { + return value; + } +}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/10d711e6/metamodel/src/test/java/org/apache/tamaya/metamodel/ext/MyFilter.java ---------------------------------------------------------------------- diff --git a/metamodel/src/test/java/org/apache/tamaya/metamodel/ext/MyFilter.java b/metamodel/src/test/java/org/apache/tamaya/metamodel/ext/MyFilter.java new file mode 100644 index 0000000..e819e2f --- /dev/null +++ b/metamodel/src/test/java/org/apache/tamaya/metamodel/ext/MyFilter.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tamaya.metamodel.ext; + +import org.apache.tamaya.spi.FilterContext; +import org.apache.tamaya.spi.PropertyFilter; +import org.apache.tamaya.spi.PropertyValue; + +/** + * Created by atsticks on 17.04.17. + */ +public class MyFilter implements PropertyFilter{ + @Override + public PropertyValue filterProperty(PropertyValue value, FilterContext context) { + return value; + } +} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/10d711e6/metamodel/src/test/java/org/apache/tamaya/metamodel/ext/MyPropertySource.java ---------------------------------------------------------------------- diff --git a/metamodel/src/test/java/org/apache/tamaya/metamodel/ext/MyPropertySource.java b/metamodel/src/test/java/org/apache/tamaya/metamodel/ext/MyPropertySource.java new file mode 100644 index 0000000..cdb4ae8 --- /dev/null +++ b/metamodel/src/test/java/org/apache/tamaya/metamodel/ext/MyPropertySource.java @@ -0,0 +1,35 @@ +/* + * 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.metamodel.ext; + + +import org.apache.tamaya.spi.PropertyValue; + +import java.util.Collections; +import java.util.Map; + +/** + * Created by atsticks on 17.04.17. + */ +public class MyPropertySource extends org.apache.tamaya.spisupport.BasePropertySource{ + @Override + public Map<String, PropertyValue> getProperties() { + return Collections.emptyMap(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/10d711e6/metamodel/src/test/resources/IntegrationTests/context-test.xml ---------------------------------------------------------------------- diff --git a/metamodel/src/test/resources/IntegrationTests/context-test.xml b/metamodel/src/test/resources/IntegrationTests/context-test.xml new file mode 100644 index 0000000..e1073f7 --- /dev/null +++ b/metamodel/src/test/resources/IntegrationTests/context-test.xml @@ -0,0 +1,29 @@ +<!-- +// 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. +// --> +<configuration> + <!-- Context is evaluated first. --> + <context> + <stage>${properties:system:STAGE?default=DEV}</stage> + <configdir>${properties:system:configdir?default=.}</configdir> + <app>${properties:system:APP?default=NONE}</app> + <context>${java:org.apache.tamaya.metamodel.MetaContext#id()}</context> + </context> + +</configuration> + http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/10d711e6/metamodel/src/test/resources/IntegrationTests/default-propertyconverters-test.xml ---------------------------------------------------------------------- diff --git a/metamodel/src/test/resources/IntegrationTests/default-propertyconverters-test.xml b/metamodel/src/test/resources/IntegrationTests/default-propertyconverters-test.xml new file mode 100644 index 0000000..91252cf --- /dev/null +++ b/metamodel/src/test/resources/IntegrationTests/default-propertyconverters-test.xml @@ -0,0 +1,31 @@ +<!-- +// 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. +// --> +<configuration> + + <!-- combinationPolicy class="" / --> + + <!-- Configuration definition. --> + + <property-converters> + <!--<converter type="AllInOneConverter"/>--> + <defaults/> + </property-converters> + +</configuration> + http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/10d711e6/metamodel/src/test/resources/IntegrationTests/default-propertyfilters-test.xml ---------------------------------------------------------------------- diff --git a/metamodel/src/test/resources/IntegrationTests/default-propertyfilters-test.xml b/metamodel/src/test/resources/IntegrationTests/default-propertyfilters-test.xml new file mode 100644 index 0000000..199f04f --- /dev/null +++ b/metamodel/src/test/resources/IntegrationTests/default-propertyfilters-test.xml @@ -0,0 +1,26 @@ +<!-- +// 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. +// --> +<configuration> + + <property-filters> + <defaults/> + </property-filters> + +</configuration> + http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/10d711e6/metamodel/src/test/resources/IntegrationTests/default-propertysources-test.xml ---------------------------------------------------------------------- diff --git a/metamodel/src/test/resources/IntegrationTests/default-propertysources-test.xml b/metamodel/src/test/resources/IntegrationTests/default-propertysources-test.xml new file mode 100644 index 0000000..a7270ec --- /dev/null +++ b/metamodel/src/test/resources/IntegrationTests/default-propertysources-test.xml @@ -0,0 +1,29 @@ +<!-- +// 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. +// --> +<configuration> + <!-- combinationPolicy class="" / --> + + <!-- Configuration definition. --> + + <property-sources> + <defaults /> + </property-sources> + +</configuration> + http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/10d711e6/metamodel/src/test/resources/IntegrationTests/propertyconverters-test.xml ---------------------------------------------------------------------- diff --git a/metamodel/src/test/resources/IntegrationTests/propertyconverters-test.xml b/metamodel/src/test/resources/IntegrationTests/propertyconverters-test.xml new file mode 100644 index 0000000..fe47b84 --- /dev/null +++ b/metamodel/src/test/resources/IntegrationTests/propertyconverters-test.xml @@ -0,0 +1,30 @@ +<!-- +// 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. +// --> +<configuration> + + <!-- combinationPolicy class="" / --> + + <!-- Configuration definition. --> + + <property-converters> + <org.apache.tamaya.metamodel.ext.MyConverter targetType="java.lang.String"/> + </property-converters> + +</configuration> + http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/10d711e6/metamodel/src/test/resources/IntegrationTests/propertyfilters-test.xml ---------------------------------------------------------------------- diff --git a/metamodel/src/test/resources/IntegrationTests/propertyfilters-test.xml b/metamodel/src/test/resources/IntegrationTests/propertyfilters-test.xml new file mode 100644 index 0000000..c1f4ee4 --- /dev/null +++ b/metamodel/src/test/resources/IntegrationTests/propertyfilters-test.xml @@ -0,0 +1,26 @@ +<!-- +// 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. +// --> +<configuration> + + <property-filters> + <Cached timeout="30000" maxSize="300" matches="cached.*"/> + </property-filters> + +</configuration> + http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/10d711e6/metamodel/src/test/resources/IntegrationTests/propertysources-test.xml ---------------------------------------------------------------------- diff --git a/metamodel/src/test/resources/IntegrationTests/propertysources-test.xml b/metamodel/src/test/resources/IntegrationTests/propertysources-test.xml new file mode 100644 index 0000000..831da19 --- /dev/null +++ b/metamodel/src/test/resources/IntegrationTests/propertysources-test.xml @@ -0,0 +1,25 @@ +<!-- +// 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. +// --> +<configuration> + <property-sources> + <org.apache.tamaya.metamodel.ext.MyPropertySource/> + <sys-properties /> + </property-sources> +</configuration> + http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/10d711e6/metamodel/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertyFilter ---------------------------------------------------------------------- diff --git a/metamodel/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertyFilter b/metamodel/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertyFilter new file mode 100644 index 0000000..80fa6c6 --- /dev/null +++ b/metamodel/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertyFilter @@ -0,0 +1,19 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +org.apache.tamaya.metamodel.ImmutableFilter \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/10d711e6/metamodel/src/test/resources/tamaya-config.xml ---------------------------------------------------------------------- diff --git a/metamodel/src/test/resources/tamaya-config.xml b/metamodel/src/test/resources/tamaya-config.xml index eb44f83..388d84c 100644 --- a/metamodel/src/test/resources/tamaya-config.xml +++ b/metamodel/src/test/resources/tamaya-config.xml @@ -19,77 +19,53 @@ <configuration> <!-- Context is evaluated first. --> <context> - <context-entry name="stage">${properties:system:STAGE?default=DEV}</context-entry> - <context-entry name="configdir">${properties:system:configdir?default=.}</context-entry> - <context-entry name="app">${properties:system.APP?default=NONE}</context-entry> - <context-entry name="context">${java:org.apache.tamaya.context.Context#id()}</context-entry> - <context-entry name="company">Trivadis</context-entry> - <context-entry name="default-formats">yaml,json</context-entry> - <context-entry name="default-refresh-period">5 SECOND</context-entry> + <stage>${properties:system:STAGE?default=DEV}</stage> + <configdir>${properties:system:configdir?default=.}</configdir> + <app>${properties:system.APP?default=NONE}</app> + <context>${java:org.apache.tamaya.context.Context#id()}</context> + <company>Trivadis</company> + <default-formats>yaml,json</default-formats> + <default-refresh-period>5 SECOND</default-refresh-period> </context> <context name="APP"> - <context-entry name="application">someAppName</context-entry> + <application>someAppName</application> </context> - <!-- combinationPolicy type="" / --> + <!-- combinationPolicy class="" / --> <!-- Configuration definition. --> <property-sources> - <source enabled="${stage=TEST || stage=PTA || stage=PROD}" - type="env-properties"> - <filter type="PropertyMapping"> - <param name="mapTarget">ENV.</param> - </filter> - <filter type="AccessMask"> - <param name="roles">admin,power-user</param> - <param name="policy">mask</param> - <param name="mask">*****</param> - <param name="matchExpression">SEC_</param> - </filter> - </source> - <source type="sys-properties" > - <filter type="ImmutablePropertySource" /> - </source> - <source type="file" refreshable="true"> - <name>config.json</name> - <param name="location">config.json</param> - </source> - <source type="file" refreshable="true"> - <name>config.xml</name> - <param name="location">config.xml</param> - <param name="formats">xml-properties</param> - </source> - <source-provider type="resource"> - <name>classpath:application-config.yml</name> - <param name="location">/META-INF/application-config.yml</param> - </source-provider> - <source type="ch.mypack.MyClassSource" /> + <env-properties enabled="${stage=TEST || stage=PTA || stage=PROD}"> + <filters> + <Map target="ENV."/> + <Mask policy="MULTIVALUE" + mask="*****" + matches="SEC_"/> + </filters> + </env-properties> + <sys-properties > + <filters> + <Immutable /> + </filters> + </sys-properties> + <file location="config.json" refreshable="true" /> + <file location="config.xml" formats="xml-properties" refreshable="true" /> + <resource location="/META-INF/application-config.yml"/> + <ch.mypack.MyClassSource /> <!--<include enabled="${stage==TEST}">TEST-config.xml</include>--> - <source-provider type="resource" enabled="${configdir != null}"> - <name>config-dir</name> - <param name="location">/${configdir}/**/*.json</param> - </source-provider> - <source type="url" refreshable="true"> - <name>remote</name> - <param name="location">https://www.confdrive.com/cfg/customerId=1234</param> - <param name="formats">json</param> - <filter type="CachedPropertySource"> - <param name="ttl">30 SECOND</param> - </filter> - </source> + <resources location="${configdir}/**/*.json" enabled="${configdir != null}" /> + <url location="https://www.confdrive.com/cfg/customerId=1234" + formats="json" + refreshable="true"> + <filters> + <Cached ttl="30 SECOND"/> + </filters> + </url> </property-sources> <property-filters> - <filter type="UsageTrackerFilter"/> - <filter type="AccessControl"> - <param name="roles">admin,power-user</param> - <param name="policy">hide</param> - <param name="expression">*.secret</param> - </filter> - <filter type="Cache"> - <param name="ttl">30000</param> - <param name="expression">cached.*</param> - </filter> + <Secured roles="admin,power-user" matches="*.secret" policy="hide"/> + <Cached timeout="30000" maxSize="300" matches="cached.*"/> </property-filters> <property-converters> <!--<converter type="AllInOneConverter"/>-->