diff options
author | Jon Bratseth <bratseth@yahoo-inc.com> | 2016-06-15 23:09:44 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@yahoo-inc.com> | 2016-06-15 23:09:44 +0200 |
commit | 72231250ed81e10d66bfe70701e64fa5fe50f712 (patch) | |
tree | 2728bba1131a6f6e5bdf95afec7d7ff9358dac50 /config/src/tests/api/api.cpp |
Publish
Diffstat (limited to 'config/src/tests/api/api.cpp')
-rw-r--r-- | config/src/tests/api/api.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
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(); } |