[TAMAYA-291] Wrote first test for the Injection API.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/be78b85a Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/be78b85a Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/be78b85a Branch: refs/heads/master Commit: be78b85a8ade0f1db0ee8900262da2e38c8ffd42 Parents: 315067b Author: Oliver B. Fischer <[email protected]> Authored: Sat Sep 23 17:34:36 2017 +0200 Committer: Oliver B. Fischer <[email protected]> Committed: Sat Sep 23 17:34:36 2017 +0200 ---------------------------------------------------------------------- modules/injection/injection-api/pom.xml | 8 ++++ .../tamaya/inject/spi/InjectionUtilsTest.java | 48 ++++++++++++++++++++ 2 files changed, 56 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/be78b85a/modules/injection/injection-api/pom.xml ---------------------------------------------------------------------- diff --git a/modules/injection/injection-api/pom.xml b/modules/injection/injection-api/pom.xml index 925db07..eec38b7 100644 --- a/modules/injection/injection-api/pom.xml +++ b/modules/injection/injection-api/pom.xml @@ -59,6 +59,14 @@ under the License. <scope>provided</scope> <optional>true</optional> </dependency> + <dependency> + <groupId>org.assertj</groupId> + <artifactId>assertj-core</artifactId> + </dependency> + <dependency> + <groupId>org.hamcrest</groupId> + <artifactId>java-hamcrest</artifactId> + </dependency> </dependencies> </project> http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/be78b85a/modules/injection/injection-api/src/test/java/org/apache/tamaya/inject/spi/InjectionUtilsTest.java ---------------------------------------------------------------------- diff --git a/modules/injection/injection-api/src/test/java/org/apache/tamaya/inject/spi/InjectionUtilsTest.java b/modules/injection/injection-api/src/test/java/org/apache/tamaya/inject/spi/InjectionUtilsTest.java new file mode 100644 index 0000000..5164209 --- /dev/null +++ b/modules/injection/injection-api/src/test/java/org/apache/tamaya/inject/spi/InjectionUtilsTest.java @@ -0,0 +1,48 @@ +/* + * 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.spi; + +import org.junit.Test; + +import java.lang.reflect.Field; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +public class InjectionUtilsTest { + + @Test + public void getKeysReturnsEmptyListForNonAnnotatedField() { + class Klazz { + public String field; + protected String protectedField; + private String privateField; + } + + Field field = Klazz.class.getFields()[0]; + + List<String> foundKeys = InjectionUtils.getKeys(field); + + assertThat(foundKeys).isNotNull() + .contains("org.apache.tamaya.inject.spi.InjectionUtilsTest$1Klazz.field", + "Klazz.field", + "field"); + } + +} \ No newline at end of file
