From 702399219195d98db5b007596e772936388054bb Mon Sep 17 00:00:00 2001 From: gjoranv Date: Thu, 17 Aug 2017 11:06:40 +0200 Subject: Add test for package and namespace. --- .../config/codegen/NamespaceAndPackageTest.java | 33 ++++++++++++++++++++++ .../configdefinitions/namespace-and-package.def | 7 +++++ .../test/resources/configdefinitions/namespace.def | 3 +- .../test/resources/configdefinitions/package.def | 5 ++++ 4 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 config-lib/src/test/java/com/yahoo/config/codegen/NamespaceAndPackageTest.java create mode 100644 config-lib/src/test/resources/configdefinitions/namespace-and-package.def create mode 100644 config-lib/src/test/resources/configdefinitions/package.def (limited to 'config-lib') 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 -- cgit v1.2.3