diff options
author | gjoranv <gv@oath.com> | 2017-08-17 11:06:40 +0200 |
---|---|---|
committer | gjoranv <gv@oath.com> | 2017-08-17 12:13:12 +0200 |
commit | 702399219195d98db5b007596e772936388054bb (patch) | |
tree | 2ecf52ed30dcbbd7276ba7a5136cd60db242615f /config-lib | |
parent | 2b2d0ea6280b54ad37f85b091e6a46b1566d430b (diff) |
Add test for package and namespace.
Diffstat (limited to 'config-lib')
4 files changed, 46 insertions, 2 deletions
diff --git a/config-lib/src/test/java/com/yahoo/config/codegen/NamespaceAndPackageTest.java b/config-lib/src/test/java/com/yahoo/config/codegen/NamespaceAndPackageTest.java new file mode 100644 index 00000000000..904d1fc049a --- /dev/null +++ b/config-lib/src/test/java/com/yahoo/config/codegen/NamespaceAndPackageTest.java @@ -0,0 +1,33 @@ +package com.yahoo.config.codegen; + +import com.github.myproject.NamespaceAndPackageConfig; +import com.github.myproject.PackageConfig; +import com.yahoo.my.namespace.NamespaceConfig; +import org.junit.Test; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + +/** + * @author gjoranv + */ +public class NamespaceAndPackageTest { + private static String NAMESPACE = "my.namespace"; + private static String PACKAGE = "com.github.myproject"; + + @Test + public void namespace_is_set_from_def_file() { + assertThat(NamespaceConfig.CONFIG_DEF_NAMESPACE, is(NAMESPACE)); + } + + @Test + public void package_is_used_as_namespace_when_namespace_is_not_set_explicitly() { + assertThat(PackageConfig.CONFIG_DEF_NAMESPACE, is(PACKAGE)); + } + + @Test + public void package_does_not_override_namespace() { + assertThat(NamespaceAndPackageConfig.CONFIG_DEF_NAMESPACE, is(NAMESPACE)); + + } +} diff --git a/config-lib/src/test/resources/configdefinitions/namespace-and-package.def b/config-lib/src/test/resources/configdefinitions/namespace-and-package.def new file mode 100644 index 00000000000..4e61d25f05f --- /dev/null +++ b/config-lib/src/test/resources/configdefinitions/namespace-and-package.def @@ -0,0 +1,7 @@ +# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +namespace=my.namespace + +package=com.github.myproject + +a int diff --git a/config-lib/src/test/resources/configdefinitions/namespace.def b/config-lib/src/test/resources/configdefinitions/namespace.def index d92dc656fe7..b1406fc1bc4 100644 --- a/config-lib/src/test/resources/configdefinitions/namespace.def +++ b/config-lib/src/test/resources/configdefinitions/namespace.def @@ -1,6 +1,5 @@ # Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -namespace=test -namespace=myproject.config +namespace=my.namespace a int diff --git a/config-lib/src/test/resources/configdefinitions/package.def b/config-lib/src/test/resources/configdefinitions/package.def new file mode 100644 index 00000000000..eba915738a5 --- /dev/null +++ b/config-lib/src/test/resources/configdefinitions/package.def @@ -0,0 +1,5 @@ +# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +package=com.github.myproject + +a int |