aboutsummaryrefslogtreecommitdiffstats
path: root/config/src/tests/api
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@yahoo-inc.com>2016-06-15 23:09:44 +0200
committerJon Bratseth <bratseth@yahoo-inc.com>2016-06-15 23:09:44 +0200
commit72231250ed81e10d66bfe70701e64fa5fe50f712 (patch)
tree2728bba1131a6f6e5bdf95afec7d7ff9358dac50 /config/src/tests/api
Publish
Diffstat (limited to 'config/src/tests/api')
-rw-r--r--config/src/tests/api/.gitignore3
-rw-r--r--config/src/tests/api/CMakeLists.txt9
-rw-r--r--config/src/tests/api/api.cpp45
3 files changed, 57 insertions, 0 deletions
diff --git a/config/src/tests/api/.gitignore b/config/src/tests/api/.gitignore
new file mode 100644
index 00000000000..67666db8b50
--- /dev/null
+++ b/config/src/tests/api/.gitignore
@@ -0,0 +1,3 @@
+/config-my.cpp
+/config-my.h
+config_api_test_app
diff --git a/config/src/tests/api/CMakeLists.txt b/config/src/tests/api/CMakeLists.txt
new file mode 100644
index 00000000000..93d12a5dc66
--- /dev/null
+++ b/config/src/tests/api/CMakeLists.txt
@@ -0,0 +1,9 @@
+# Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+vespa_add_executable(config_api_test_app
+ SOURCES
+ api.cpp
+ DEPENDS
+ config_cloudconfig
+)
+vespa_add_test(NAME config_api_test_app COMMAND config_api_test_app)
+vespa_generate_config(config_api_test_app ../../test/resources/configdefinitions/my.def)
diff --git a/config/src/tests/api/api.cpp b/config/src/tests/api/api.cpp
new file mode 100644
index 00000000000..54042fcef1f
--- /dev/null
+++ b/config/src/tests/api/api.cpp
@@ -0,0 +1,45 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+#include <vespa/fastos/fastos.h>
+#include <vespa/vespalib/testkit/test_kit.h>
+#include <vespa/config/config.h>
+#include <config-my.h>
+
+using namespace config;
+
+TEST("require that can subscribe with empty config id") {
+ ConfigSet set;
+ ConfigContext::SP ctx(new ConfigContext(set));
+ MyConfigBuilder builder;
+ builder.myField = "myfoo";
+ set.addBuilder("", &builder);
+ ConfigSubscriber subscriber(ctx);
+ ConfigHandle<MyConfig>::UP handle = subscriber.subscribe<MyConfig>("");
+ ASSERT_TRUE(subscriber.nextConfig(0));
+ std::unique_ptr<MyConfig> cfg(handle->getConfig());
+ ASSERT_TRUE(cfg.get() != NULL);
+ ASSERT_EQUAL("myfoo", cfg->myField);
+}
+
+/*
+ * TODO: Convert to frt test.
+TEST_MT_FFF("require that source may be unable to serve config temporarily", 2, ConfigContext::SP(new ConfigContext()),
+ ConfigSet(),
+ MyConfigBuilder()) {
+ if (thread_id == 0) {
+ ConfigSubscriber subscriber(f1, f2);
+ ConfigHandle<MyConfig>::UP handle = subscriber.subscribe<MyConfig>("myid", 10000);
+ ASSERT_TRUE(subscriber.nextConfig(10000));
+ std::unique_ptr<MyConfig> cfg(handle->getConfig());
+ ASSERT_TRUE(cfg.get() != NULL);
+ ASSERT_EQUAL("myfoo", cfg->myField);
+ } else {
+ FastOS_Thread::Sleep(1000);
+ f3.myField = "myfoo";
+ f2.addBuilder("myid", &f3);
+ f1->reload();
+
+ }
+}
+*/
+
+TEST_MAIN() { TEST_RUN_ALL(); }