pivotal-jbarrett commented on a change in pull request #804:
URL: https://github.com/apache/geode-native/pull/804#discussion_r632084836
##########
File path: cppcache/integration/test/CachingProxyTest.cpp
##########
@@ -51,86 +53,67 @@ class CachingProxyTest : public ::testing::Test {
~CachingProxyTest() override = default;
- void SetUp() override {}
+ void SetUp() override {
+ cache.getPoolManager()
+ .createFactory()
+ .addLocator("localhost", cluster.getLocatorPort())
+ .create("pool");
+
+ region = cache.createRegionFactory(RegionShortcut::CACHING_PROXY)
+ .setPoolName("pool")
+ .create("region");
+ }
void TearDown() override {}
Cluster cluster = Cluster{LocatorCount{1}, ServerCount{1}};
+ Cache cache = CacheFactory().create();
Review comment:
@mreddington Two issues:
1. We are initializing test specific objects in the fixture's, these will
not be per-test method instances of these objects.
2. We are performing complex and exception throwing initialization of a
member variable in the initialization of a type before the constructor is
invoked. This particular factory can take variable parameters, like connection
time outs, which could not be forwarded from some constructor or member method
on this type. Initialization of a variable should never be done like this in
production code so it also shouldn't in test code.
What this attempt to use the test fixture setup method has shown us it that
we have a deficiency in how we defined the construction of `Cache` in that you
can't declare it without also initializing it with some complex builder. Like
many other state holding types in C++11 it should default construct to some
safe but unusable state for its declaration, like `std::shared_ptr` default
initializes to `nullptr`. It should then allow rvalue assignment from the value
returned from the factory so that it can be fully initialized in the `SetUp`
method. Similar to how someone with a `Application` class would declare it as a
member and then initialize it someone in the application lifecycle.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]